]> OCCT Git - occt-copy.git/commitdiff
0031225: Visualization, TKOpenGl - support cubemap for environment texture within...
authormzernova <mzernova@opencascade.com>
Fri, 13 Dec 2019 08:55:50 +0000 (11:55 +0300)
committerbugmaster <bugmaster@opencascade.com>
Fri, 27 Dec 2019 13:26:48 +0000 (16:26 +0300)
Ray-Tracing now handles IBL and background cubemaps in similar way as PBR.
Ambient light source is handled by Ray-Tracing in similar way as PBR,
e.g. as coefficient for environment map (IBL) or as constant light source.

Test script generating PBR spheres has been moved to Samples
and now shared by PBR and Path-Tracing tests.

16 files changed:
samples/tcl/pathtrace_ball.tcl
samples/tcl/pathtrace_cube.tcl
samples/tcl/pathtrace_materials.tcl
samples/tcl/vis_pbr_spheres.tcl [new file with mode: 0644]
src/OpenGl/OpenGl_View.hxx
src/OpenGl/OpenGl_View_Raytrace.cxx
src/Shaders/PathtraceBase.fs
src/Shaders/RaytraceBase.fs
src/Shaders/Shaders_PathtraceBase_fs.pxx
src/Shaders/Shaders_RaytraceBase_fs.pxx
tests/v3d/glsl/pbr_spheres
tests/v3d/raytrace/dof_mono
tests/v3d/raytrace/dof_stereo
tests/v3d/raytrace/pbr_spheres [new file with mode: 0644]
tests/v3d/raytrace/textures
tests/v3d/raytrace/tone_mapping

index b065eaab664318eb7fe8efef841b16715e369fcb..911c0eb2903d3c18b1c85acb142d83adf4083c89 100644 (file)
@@ -57,11 +57,10 @@ for {set i 0} {$i < 12} {incr i} {
 }
 
 # Configure light sources
-vlight del 1
-vlight change 0 head 0
-vlight change 0 direction -0.25 -1 -1
-vlight change 0 sm 0.3
-vlight change 0 int 10
+vlight -change 0 -head 0
+vlight -change 0 -direction -0.25 -1 -1
+vlight -change 0 -sm   0.3
+vlight -change 0 -int 10.0
 
 # Load environment map
 vtextureenv on 1
index ad7c88ac047d584d620e5897e41917ad014f9dd8..ef6e0a22ab4ce66ce6efc2225bcf078b764344e6 100644 (file)
@@ -12,11 +12,8 @@ vinit name=View1 w=512 h=512
 vglinfo
 
 # setup light sources
-vlight del 0
-vlight del 1
-vlight add positional head 0 pos 0.5 0.5 0.85
-vlight change 0 sm 0.06
-vlight change 0 int 30.0
+vlight -clear
+vlight -add positional -head 0 -pos 0.5 0.5 0.85 -sm 0.06 -int 30.0
 
 vvbo 0
 vsetdispmode 1
index e22344d5f36faf4852321ecd25ace177f2bc2f59..b404588d61a1aef50f83e7a7b0675a638ee1c5f2 100644 (file)
@@ -208,8 +208,9 @@ vviewparams -eye 139.412 -1.62643 178.037
 vviewparams -size 170.508
 
 # Restore light source parameters
-vlight clear
-vlight add directional direction -0.303949 -0.434084 -0.848048 smoothness 0.3 intensity 12
+vlight -clear
+vlight -add ambient
+vlight -add directional -direction -0.303949 -0.434084 -0.848048 -smoothness 0.3 -intensity 12
 
 # Load environment map
 vtextureenv on 1
diff --git a/samples/tcl/vis_pbr_spheres.tcl b/samples/tcl/vis_pbr_spheres.tcl
new file mode 100644 (file)
index 0000000..0f6904b
--- /dev/null
@@ -0,0 +1,91 @@
+# Script demonstrating PBR metallic-roughness material properties
+#Category: Visualization
+#Title: PBR metallic-rougness spheres
+
+pload XDE OCAF MODELING VISUALIZATION
+psphere s 0.35
+
+catch { Close D }
+XNewDoc D
+
+# grid of spheres
+set THE_UPPER 6
+foreach i [list 0 3] {
+  set aPrefix ""
+  set aColor "GRAY80"
+  if { $i != 0 } {
+    set aPrefix "g_";
+    set aColor "CCB11D"
+  }
+  set aColShapes {}
+  for { set m 0 } { $m <= $THE_UPPER } { incr m } {
+    set aRowShapes {}
+    for { set r 0 } { $r <= $THE_UPPER } { incr r } {
+      set aName ${aPrefix}m${m}r${r}
+      copy s $aName
+      lappend aRowShapes $aName
+      ttranslate $aName ${r} ${i} ${m}
+    }
+    set aName ${aPrefix}m${m}
+    compound {*}$aRowShapes $aName
+    lappend aColShapes $aName
+  }
+  set aName ${aPrefix}spheres
+  compound {*}$aColShapes $aName
+  set aLabName "Gray Spheres"
+  if { $i != 0 } { set aLabName "Golden Spheres" }
+  set aLabComp [XAddShape D $aName 0]
+  SetName D $aLabComp $aLabName
+
+  for { set m 0 } { $m <= $THE_UPPER } { incr m } {
+    set aMet [expr 100 * ${m}/$THE_UPPER]
+    set aName ${aPrefix}m${m}
+    XAddComponent D $aLabComp $aName
+    set aLabCompCol [XFindShape D $aName]
+    SetName D $aLabCompCol "${aPrefix}m${aMet}%"
+    SetName D {*}[XFindComponent D $aName] "${aPrefix}m${aMet}%"
+    for { set r 0 } { $r <= $THE_UPPER } { incr r } {
+      set aRoug [expr 100 * ${r}/$THE_UPPER]
+      set aName ${aPrefix}m${m}r${r}
+      XAddComponent D $aLabCompCol $aName
+      set aLab [XFindComponent D $aName]
+      SetName D {*}$aLab "${aPrefix}m${aMet}%_r${aRoug}%"
+      XAddVisMaterial D $aName -baseColor $aColor -metallic ${m}/$THE_UPPER -roughness ${r}/$THE_UPPER
+      XSetVisMaterial D {*}$aLab $aName
+    }
+  }
+}
+set aLab [XFindShape D s]
+SetName D {*}$aLab "Sphere"
+
+XGetAllVisMaterials D
+
+# labels
+text2brep tm  "Metal"     -plane 0 -1 0 0 0 -1 -height 0.5 -pos -0.5 0  6.5 -halign left  -valign top -font monospace
+text2brep tnm "Non-metal" -plane 0 -1 0 0 0 -1 -height 0.5 -pos -0.5 0 -0.5 -halign right -valign top -font monospace
+text2brep ts  "Smooth"    -plane 0 -1 0 1 0  0 -height 0.5 -pos -0.5 0 -0.5 -halign left  -valign top -font monospace
+text2brep tr  "Rough"     -plane 0 -1 0 1 0  0 -height 0.5 -pos  6.5 0 -0.5 -halign right -valign top -font monospace
+compound tm tnm ts tr labs
+set aLab [XAddShape D labs 0]
+SetName D $aLab "Labels"
+XAddComponent D $aLab tm
+XAddComponent D $aLab tnm
+XAddComponent D $aLab ts
+XAddComponent D $aLab tr
+SetName D {*}[XFindComponent D tm]  "Metal"
+SetName D    [XFindShape     D tm]  "Metal"
+SetName D {*}[XFindComponent D tnm] "Non-metal"
+SetName D    [XFindShape     D tnm] "Non-metal"
+SetName D {*}[XFindComponent D ts]  "Smooth"
+SetName D    [XFindShape     D ts]  "Smooth"
+SetName D {*}[XFindComponent D tr]  "Rough"
+SetName D    [XFindShape     D tr]  "Rough"
+
+vclear
+vinit View1 -width 768 -height 768
+vfront
+vrenderparams -shadingModel PBR
+vlight -change 0 -intensity 2.5
+XDisplay -dispMode 1 D
+vcamera -ortho
+vfit
index ddf1b537c9a8431bdf52367eabf357a17ac1c27c..8f39d03f22dc668eeb0fd929882e86a830ced6e9 100644 (file)
@@ -629,8 +629,8 @@ protected: //! @name data types related to ray-tracing
     // ray-tracing params
     OpenGl_RT_uShadowsEnabled,
     OpenGl_RT_uReflectEnabled,
-    OpenGl_RT_uSphereMapEnabled,
-    OpenGl_RT_uSphereMapForBack,
+    OpenGl_RT_uEnvMapEnabled,
+    OpenGl_RT_uEnvMapForBack,
     OpenGl_RT_uTexSamplersArray,
     OpenGl_RT_uBlockedRngEnabled,
 
@@ -762,6 +762,9 @@ protected: //! @name data types related to ray-tracing
     //! Enables/disables depth-of-field effect (path tracing, perspective camera).
     Standard_Boolean DepthOfField;
 
+    //! Enables/disables cubemap backgraund.
+    Standard_Boolean CubemapForBack;
+
     //! Tone mapping method for path tracing.
     Graphic3d_ToneMappingMethod ToneMappingMethod;
 
@@ -778,6 +781,7 @@ protected: //! @name data types related to ray-tracing
       UseEnvMapForBackground (Standard_False),
       RadianceClampingValue  (30.0),
       DepthOfField           (Standard_False),
+      CubemapForBack         (Standard_False),
       ToneMappingMethod      (Graphic3d_ToneMappingMethod_Disabled) { }
   };
 
index 86ba3c1099b1a5370fe85efbf576375008a25fb0..266a82a99aa2730bed01d0dc7e2199f365d3b157 100644 (file)
@@ -45,7 +45,7 @@ namespace
 namespace
 {
   //! Defines OpenGL texture samplers.
-  static const Graphic3d_TextureUnit OpenGl_RT_EnvironmentMapTexture = Graphic3d_TextureUnit_0;
+  static const Graphic3d_TextureUnit OpenGl_RT_EnvMapTexture = Graphic3d_TextureUnit_0;
 
   static const Graphic3d_TextureUnit OpenGl_RT_SceneNodeInfoTexture  = Graphic3d_TextureUnit_1;
   static const Graphic3d_TextureUnit OpenGl_RT_SceneMinPointTexture  = Graphic3d_TextureUnit_2;
@@ -1160,6 +1160,11 @@ TCollection_AsciiString OpenGl_View::generateShaderPrefix (const Handle(OpenGl_C
     }
   }
 
+  if (myRaytraceParameters.CubemapForBack)
+  {
+    aPrefixString += TCollection_AsciiString("\n#define BACKGROUND_CUBEMAP");
+  }
+
   if (myRaytraceParameters.DepthOfField)
   {
     aPrefixString += TCollection_AsciiString("\n#define DEPTH_OF_FIELD");
@@ -1368,6 +1373,13 @@ Standard_Boolean OpenGl_View::initRaytraceResources (const Standard_Integer theS
     }
     myTileSampler.SetSize (myRenderParams, myRaytraceParameters.AdaptiveScreenSampling ? Graphic3d_Vec2i (theSizeX, theSizeY) : Graphic3d_Vec2i (0, 0));
 
+    const bool isCubemapForBack = !myBackgroundCubeMap.IsNull();
+    if (myRaytraceParameters.CubemapForBack != isCubemapForBack)
+    {
+      myRaytraceParameters.CubemapForBack = isCubemapForBack;
+      aToRebuildShaders = Standard_True;
+    }
+
     const bool toEnableDof = !myCamera->IsOrthographic() && myRaytraceParameters.GlobalIllumination;
     if (myRaytraceParameters.DepthOfField != toEnableDof)
     {
@@ -1606,7 +1618,7 @@ Standard_Boolean OpenGl_View::initRaytraceResources (const Standard_Integer theS
       aShaderProgram->SetSampler (theGlContext, 
         "uSceneTransformTexture", OpenGl_RT_SceneTransformTexture);
       aShaderProgram->SetSampler (theGlContext,
-        "uEnvironmentMapTexture", OpenGl_RT_EnvironmentMapTexture);
+        "uEnvMapTexture", OpenGl_RT_EnvMapTexture);
       aShaderProgram->SetSampler (theGlContext,
         "uRaytraceMaterialTexture", OpenGl_RT_RaytraceMaterialTexture);
       aShaderProgram->SetSampler (theGlContext,
@@ -1670,10 +1682,10 @@ Standard_Boolean OpenGl_View::initRaytraceResources (const Standard_Integer theS
         aShaderProgram->GetUniformLocation (theGlContext, "uShadowsEnabled");
       myUniformLocations[anIndex][OpenGl_RT_uReflectEnabled] =
         aShaderProgram->GetUniformLocation (theGlContext, "uReflectEnabled");
-      myUniformLocations[anIndex][OpenGl_RT_uSphereMapEnabled] =
-        aShaderProgram->GetUniformLocation (theGlContext, "uSphereMapEnabled");
-      myUniformLocations[anIndex][OpenGl_RT_uSphereMapForBack] =
-        aShaderProgram->GetUniformLocation (theGlContext, "uSphereMapForBack");
+      myUniformLocations[anIndex][OpenGl_RT_uEnvMapEnabled] =
+        aShaderProgram->GetUniformLocation (theGlContext, "uEnvMapEnabled");
+      myUniformLocations[anIndex][OpenGl_RT_uEnvMapForBack] =
+        aShaderProgram->GetUniformLocation (theGlContext, "uEnvMapForBack");
       myUniformLocations[anIndex][OpenGl_RT_uBlockedRngEnabled] =
         aShaderProgram->GetUniformLocation (theGlContext, "uBlockedRngEnabled");
 
@@ -2377,12 +2389,11 @@ Standard_Boolean OpenGl_View::uploadRaytraceData (const Handle(OpenGl_Context)&
 Standard_Boolean OpenGl_View::updateRaytraceLightSources (const OpenGl_Mat4& theInvModelView, const Handle(OpenGl_Context)& theGlContext)
 {
   std::vector<Handle(Graphic3d_CLight)> aLightSources;
-  myRaytraceGeometry.Ambient = BVH_Vec4f (0.f, 0.f, 0.f, 0.f);
+  Graphic3d_Vec4 aNewAmbient (0.0f);
   if (myShadingModel != Graphic3d_TOSM_UNLIT
   && !myLights.IsNull())
   {
-    const Graphic3d_Vec4& anAmbient = myLights->AmbientColor();
-    myRaytraceGeometry.Ambient = BVH_Vec4f (anAmbient.r(), anAmbient.g(), anAmbient.b(), 0.0f);
+    aNewAmbient.SetValues (myLights->AmbientColor().rgb(), 0.0f);
 
     // move positional light sources at the front of the list
     aLightSources.reserve (myLights->Extent());
@@ -2406,6 +2417,12 @@ Standard_Boolean OpenGl_View::updateRaytraceLightSources (const OpenGl_Mat4& the
     }
   }
 
+  if (!myRaytraceGeometry.Ambient.IsEqual (aNewAmbient))
+  {
+    myAccumFrames = 0;
+    myRaytraceGeometry.Ambient = aNewAmbient;
+  }
+
   // get number of 'real' (not ambient) light sources
   const size_t aNbLights = aLightSources.size();
   Standard_Boolean wasUpdated = myRaytraceGeometry.Sources.size () != aNbLights;
@@ -2541,7 +2558,7 @@ Standard_Boolean OpenGl_View::setUniformState (const Standard_Integer        the
 
   theProgram->SetUniform(theGlContext, "uApertureRadius", myRenderParams.CameraApertureRadius);
   theProgram->SetUniform(theGlContext, "uFocalPlaneDist", myRenderParams.CameraFocalPlaneDist);
-  
+
   // Set camera state
   theProgram->SetUniform (theGlContext,
     myUniformLocations[theProgramId][OpenGl_RT_uOriginLB], aOrigins[0]);
@@ -2616,16 +2633,30 @@ Standard_Boolean OpenGl_View::setUniformState (const Standard_Integer        the
   theProgram->SetUniform (theGlContext, myUniformLocations[theProgramId][OpenGl_RT_uBackColorBot], aBackColorBot);
 
   // Set environment map parameters
-  const Standard_Boolean toDisableEnvironmentMap = myTextureEnv.IsNull()
-                                               ||  myTextureEnv->IsEmpty()
-                                               || !myTextureEnv->First()->IsValid();
-
-  theProgram->SetUniform (theGlContext,
-    myUniformLocations[theProgramId][OpenGl_RT_uSphereMapEnabled], toDisableEnvironmentMap ? 0 : 1);
+  const Handle(OpenGl_TextureSet)& anEnvTextureSet = myRaytraceParameters.CubemapForBack
+                                                   ? myCubeMapParams->TextureSet (theGlContext)
+                                                   : myTextureEnv;
+  const bool toDisableEnvironmentMap = anEnvTextureSet.IsNull()
+                                   ||  anEnvTextureSet->IsEmpty()
+                                   || !anEnvTextureSet->First()->IsValid();
+  theProgram->SetUniform (theGlContext, myUniformLocations[theProgramId][OpenGl_RT_uEnvMapEnabled],
+                          toDisableEnvironmentMap ? 0 : 1);
+  if (myRaytraceParameters.CubemapForBack)
+  {
+    theProgram->SetUniform (theGlContext, "uZCoeff", myBackgroundCubeMap->ZIsInverted() ? -1 :  1);
+    theProgram->SetUniform (theGlContext, "uYCoeff", myBackgroundCubeMap->IsTopDown()   ?  1 : -1);
+    theProgram->SetUniform (theGlContext, myUniformLocations[theProgramId][OpenGl_RT_uEnvMapForBack],
+                            myBackgroundType == Graphic3d_TOB_CUBEMAP ? 1 : 0);
+  }
+  else
+  {
+    theProgram->SetUniform (theGlContext, myUniformLocations[theProgramId][OpenGl_RT_uEnvMapForBack],
+                            myRenderParams.UseEnvironmentMapBackground ? 1 : 0);
+  }
 
+  // Set ambient light source
   theProgram->SetUniform (theGlContext,
-    myUniformLocations[theProgramId][OpenGl_RT_uSphereMapForBack], myRenderParams.UseEnvironmentMapBackground ?  1 : 0);
-
+                          myUniformLocations[theProgramId][OpenGl_RT_uLightAmbnt], myRaytraceGeometry.Ambient);
   if (myRenderParams.IsGlobalIlluminationEnabled) // GI parameters
   {
     theProgram->SetUniform (theGlContext,
@@ -2646,10 +2677,6 @@ Standard_Boolean OpenGl_View::setUniformState (const Standard_Integer        the
   }
   else // RT parameters
   {
-    // Set ambient light source
-    theProgram->SetUniform (theGlContext,
-      myUniformLocations[theProgramId][OpenGl_RT_uLightAmbnt], myRaytraceGeometry.Ambient);
-
     // Enable/disable run-time ray-tracing effects
     theProgram->SetUniform (theGlContext,
       myUniformLocations[theProgramId][OpenGl_RT_uShadowsEnabled], myRenderParams.IsShadowEnabled ?  1 : 0);
@@ -2690,11 +2717,14 @@ void OpenGl_View::bindRaytraceTextures (const Handle(OpenGl_Context)& theGlConte
   #endif
   }
 
-  if (!myTextureEnv.IsNull()
-   && !myTextureEnv->IsEmpty()
-   &&  myTextureEnv->First()->IsValid())
+  const Handle(OpenGl_TextureSet)& anEnvTextureSet = myRaytraceParameters.CubemapForBack
+                                                   ? myCubeMapParams->TextureSet (theGlContext)
+                                                   : myTextureEnv;
+  if (!anEnvTextureSet.IsNull()
+   && !anEnvTextureSet->IsEmpty()
+   &&  anEnvTextureSet->First()->IsValid())
   {
-    myTextureEnv->First()->Bind (theGlContext, OpenGl_RT_EnvironmentMapTexture);
+    anEnvTextureSet->First()->Bind (theGlContext, OpenGl_RT_EnvMapTexture);
   }
 
   mySceneMinPointTexture   ->BindTexture (theGlContext, OpenGl_RT_SceneMinPointTexture);
index fbc132759e3d91ae505a7f408172820757603a26..0d8c9085586cfb7dcbf94e8506472e7a880b17d6 100644 (file)
@@ -580,20 +580,6 @@ float SampleBsdfLayered (in SBSDF theBSDF, in vec3 theWo, out vec3 theWi, inout
 // Handlers and samplers for light sources
 //////////////////////////////////////////////////////////////////////////////////////////////
 
-// =======================================================================
-// function : Latlong
-// purpose  : Converts world direction to environment texture coordinates
-// =======================================================================
-vec2 Latlong (in vec3 thePoint)
-{
-  float aPsi = acos (-thePoint.z);
-
-  float aPhi = atan (thePoint.y, thePoint.x) + M_PI;
-
-  return vec2 (aPhi * 0.1591549f,
-               aPsi * 0.3183098f);
-}
-
 //=======================================================================
 // function : SampleLight
 // purpose  : General sampling function for directional and point lights
@@ -701,13 +687,30 @@ vec3 IntersectLight (in SRay theRay, in int theDepth, in float theHitDistance, o
 
   if (thePDF == 0.f && theHitDistance == MAXFLOAT) // light source not found
   {
-    if (theDepth + uSphereMapForBack == 0) // view ray and map is hidden
+    if (theDepth + uEnvMapForBack == 0) // view ray and map is hidden
     {
       aTotalRadiance = BackgroundColor().rgb;
     }
     else
     {
-      aTotalRadiance = FetchEnvironment (Latlong (theRay.Direct)).rgb;
+    #ifdef BACKGROUND_CUBEMAP
+      if (theDepth == 0)
+      {
+        vec2 aPixel = uEyeSize * (vPixel - vec2 (0.5)) * 2.0;
+        vec2 anAperturePnt = sampleUniformDisk() * uApertureRadius;
+        vec3 aLocalDir = normalize (vec3 (aPixel * uFocalPlaneDist - anAperturePnt, uFocalPlaneDist));
+        vec3 aDirect = uEyeView * aLocalDir.z +
+                       uEyeSide * aLocalDir.x +
+                       uEyeVert * aLocalDir.y;
+        aTotalRadiance = FetchEnvironment (aDirect, 1.0, true).rgb;
+      }
+      else
+      {
+        aTotalRadiance = FetchEnvironment (theRay.Direct, 1.0, false).rgb;
+      }
+    #else
+      aTotalRadiance = FetchEnvironment (theRay.Direct, 1.0, theDepth == 0).rgb;
+    #endif
     }
   #ifdef THE_SHIFT_sRGB
     aTotalRadiance = pow (aTotalRadiance, vec3 (2.f));
index 261327c019c2e1de466627fcdd397dbf99686f5a..5c73a6773a9ce44b9cbf6b20cc71880641cddc11 100644 (file)
@@ -70,8 +70,18 @@ uniform isamplerBuffer uGeometryTriangTexture;
 uniform samplerBuffer uRaytraceMaterialTexture;
 //! Texture buffer of light source properties.
 uniform samplerBuffer uRaytraceLightSrcTexture;
-//! Environment map texture.
-uniform sampler2D uEnvironmentMapTexture;
+
+#ifdef BACKGROUND_CUBEMAP
+  //! Environment cubemap texture.
+  uniform samplerCube uEnvMapTexture;
+  //! Coefficient of Y controlling horizontal flip of cubemap
+  uniform int uYCoeff;
+  //! Coefficient of Z controlling vertical flip of cubemap
+  uniform int uZCoeff;
+#else
+  //! Environment map texture.
+  uniform sampler2D uEnvMapTexture;
+#endif
 
 //! Total number of light sources.
 uniform int uLightCount;
@@ -82,10 +92,10 @@ uniform vec4 uGlobalAmbient;
 uniform int uShadowsEnabled;
 //! Enables/disables specular reflections.
 uniform int uReflectEnabled;
-//! Enables/disables spherical environment map.
-uniform int uSphereMapEnabled;
+//! Enables/disables environment map lighting.
+uniform int uEnvMapEnabled;
 //! Enables/disables environment map background.
-uniform int uSphereMapForBack;
+uniform int uEnvMapForBack;
 
 //! Radius of bounding sphere of the scene.
 uniform float uSceneRadius;
@@ -848,6 +858,17 @@ vec2 Latlong (in vec3 thePoint, in float theRadius)
                aPsi * 0.3183098f);
 }
 
+#ifdef BACKGROUND_CUBEMAP
+//! Transform texture coordinates for cubemap lookup.
+vec3 cubemapVectorTransform (in vec3 theVec, in float theRadius)
+{
+  vec3 aVec = theVec.yzx;
+  aVec.y *= float(uYCoeff);
+  aVec.z *= float(uZCoeff);
+  return aVec;
+}
+#endif
+
 // =======================================================================
 // function : SmoothNormal
 // purpose  : Interpolates normal across the triangle
@@ -909,10 +930,25 @@ vec2 SmoothUV (in vec2 theUV, in ivec4 theTriangle)
 // function : FetchEnvironment
 // purpose  :
 // =======================================================================
-vec4 FetchEnvironment (in vec2 theTexCoord)
+vec4 FetchEnvironment (in vec3 theTexCoord, in float theRadius, in bool theIsBackground)
 {
-  return uSphereMapEnabled == 0 ?
-    vec4 (0.f, 0.f, 0.f, 1.f) : textureLod (uEnvironmentMapTexture, theTexCoord, 0.f);
+  if (uEnvMapEnabled == 0)
+  {
+#ifdef PATH_TRACING
+    return theIsBackground ? vec4 (0.0, 0.0, 0.0, 1.0) : uGlobalAmbient;
+#else
+    return vec4 (0.0, 0.0, 0.0, 1.0);
+#endif
+  }
+
+  vec4 anAmbScale = theIsBackground ? vec4(1.0) : uGlobalAmbient;
+  vec4 anEnvColor =
+#ifdef BACKGROUND_CUBEMAP
+    textureLod (uEnvMapTexture, cubemapVectorTransform (theTexCoord, theRadius), 0.0);
+#else
+    textureLod (uEnvMapTexture, Latlong (theTexCoord, theRadius), 0.0);
+#endif
+  return anEnvColor * anAmbScale;
 }
 
 // =======================================================================
@@ -979,12 +1015,11 @@ vec4 Radiance (in SRay theRay, in vec3 theInverse)
     {
       vec4 aColor = vec4 (0.0);
 
-      if (bool(uSphereMapForBack) || aWeight.w == 0.0f /* reflection */)
+      if (bool(uEnvMapForBack) || aWeight.w == 0.0f /* reflection */)
       {
         float aTime = IntersectSphere (theRay, uSceneRadius);
 
-        aColor = FetchEnvironment (Latlong (
-          theRay.Direct * aTime + theRay.Origin, uSceneRadius));
+        aColor = FetchEnvironment (theRay.Direct * aTime + theRay.Origin, uSceneRadius, aWeight.w != 0.0);
       }
       else
       {
index 6d33da8e9cb7bf872e57b6d3104bda026b5e3609..3db4426aebac9df97e3b5828ae12c9d8adad89a7 100644 (file)
@@ -583,20 +583,6 @@ static const char Shaders_PathtraceBase_fs[] =
   "// Handlers and samplers for light sources\n"
   "//////////////////////////////////////////////////////////////////////////////////////////////\n"
   "\n"
-  "// =======================================================================\n"
-  "// function : Latlong\n"
-  "// purpose  : Converts world direction to environment texture coordinates\n"
-  "// =======================================================================\n"
-  "vec2 Latlong (in vec3 thePoint)\n"
-  "{\n"
-  "  float aPsi = acos (-thePoint.z);\n"
-  "\n"
-  "  float aPhi = atan (thePoint.y, thePoint.x) + M_PI;\n"
-  "\n"
-  "  return vec2 (aPhi * 0.1591549f,\n"
-  "               aPsi * 0.3183098f);\n"
-  "}\n"
-  "\n"
   "//=======================================================================\n"
   "// function : SampleLight\n"
   "// purpose  : General sampling function for directional and point lights\n"
@@ -704,13 +690,30 @@ static const char Shaders_PathtraceBase_fs[] =
   "\n"
   "  if (thePDF == 0.f && theHitDistance == MAXFLOAT) // light source not found\n"
   "  {\n"
-  "    if (theDepth + uSphereMapForBack == 0) // view ray and map is hidden\n"
+  "    if (theDepth + uEnvMapForBack == 0) // view ray and map is hidden\n"
   "    {\n"
   "      aTotalRadiance = BackgroundColor().rgb;\n"
   "    }\n"
   "    else\n"
   "    {\n"
-  "      aTotalRadiance = FetchEnvironment (Latlong (theRay.Direct)).rgb;\n"
+  "    #ifdef BACKGROUND_CUBEMAP\n"
+  "      if (theDepth == 0)\n"
+  "      {\n"
+  "        vec2 aPixel = uEyeSize * (vPixel - vec2 (0.5)) * 2.0;\n"
+  "        vec2 anAperturePnt = sampleUniformDisk() * uApertureRadius;\n"
+  "        vec3 aLocalDir = normalize (vec3 (aPixel * uFocalPlaneDist - anAperturePnt, uFocalPlaneDist));\n"
+  "        vec3 aDirect = uEyeView * aLocalDir.z +\n"
+  "                       uEyeSide * aLocalDir.x +\n"
+  "                       uEyeVert * aLocalDir.y;\n"
+  "        aTotalRadiance = FetchEnvironment (aDirect, 1.0, true).rgb;\n"
+  "      }\n"
+  "      else\n"
+  "      {\n"
+  "        aTotalRadiance = FetchEnvironment (theRay.Direct, 1.0, false).rgb;\n"
+  "      }\n"
+  "    #else\n"
+  "      aTotalRadiance = FetchEnvironment (theRay.Direct, 1.0, theDepth == 0).rgb;\n"
+  "    #endif\n"
   "    }\n"
   "  #ifdef THE_SHIFT_sRGB\n"
   "    aTotalRadiance = pow (aTotalRadiance, vec3 (2.f));\n"
index 43c36ba64a1fafb1be8db015b1b25d426b8bfaa3..6b852d4a4b456374c3c3e93c3b93f8f96d624676 100644 (file)
@@ -73,8 +73,18 @@ static const char Shaders_RaytraceBase_fs[] =
   "uniform samplerBuffer uRaytraceMaterialTexture;\n"
   "//! Texture buffer of light source properties.\n"
   "uniform samplerBuffer uRaytraceLightSrcTexture;\n"
-  "//! Environment map texture.\n"
-  "uniform sampler2D uEnvironmentMapTexture;\n"
+  "\n"
+  "#ifdef BACKGROUND_CUBEMAP\n"
+  "  //! Environment cubemap texture.\n"
+  "  uniform samplerCube uEnvMapTexture;\n"
+  "  //! Coefficient of Y controlling horizontal flip of cubemap\n"
+  "  uniform int uYCoeff;\n"
+  "  //! Coefficient of Z controlling vertical flip of cubemap\n"
+  "  uniform int uZCoeff;\n"
+  "#else\n"
+  "  //! Environment map texture.\n"
+  "  uniform sampler2D uEnvMapTexture;\n"
+  "#endif\n"
   "\n"
   "//! Total number of light sources.\n"
   "uniform int uLightCount;\n"
@@ -85,10 +95,10 @@ static const char Shaders_RaytraceBase_fs[] =
   "uniform int uShadowsEnabled;\n"
   "//! Enables/disables specular reflections.\n"
   "uniform int uReflectEnabled;\n"
-  "//! Enables/disables spherical environment map.\n"
-  "uniform int uSphereMapEnabled;\n"
+  "//! Enables/disables environment map lighting.\n"
+  "uniform int uEnvMapEnabled;\n"
   "//! Enables/disables environment map background.\n"
-  "uniform int uSphereMapForBack;\n"
+  "uniform int uEnvMapForBack;\n"
   "\n"
   "//! Radius of bounding sphere of the scene.\n"
   "uniform float uSceneRadius;\n"
@@ -851,6 +861,17 @@ static const char Shaders_RaytraceBase_fs[] =
   "               aPsi * 0.3183098f);\n"
   "}\n"
   "\n"
+  "#ifdef BACKGROUND_CUBEMAP\n"
+  "//! Transform texture coordinates for cubemap lookup.\n"
+  "vec3 cubemapVectorTransform (in vec3 theVec, in float theRadius)\n"
+  "{\n"
+  "  vec3 aVec = theVec.yzx;\n"
+  "  aVec.y *= float(uYCoeff);\n"
+  "  aVec.z *= float(uZCoeff);\n"
+  "  return aVec;\n"
+  "}\n"
+  "#endif\n"
+  "\n"
   "// =======================================================================\n"
   "// function : SmoothNormal\n"
   "// purpose  : Interpolates normal across the triangle\n"
@@ -912,10 +933,25 @@ static const char Shaders_RaytraceBase_fs[] =
   "// function : FetchEnvironment\n"
   "// purpose  :\n"
   "// =======================================================================\n"
-  "vec4 FetchEnvironment (in vec2 theTexCoord)\n"
+  "vec4 FetchEnvironment (in vec3 theTexCoord, in float theRadius, in bool theIsBackground)\n"
   "{\n"
-  "  return uSphereMapEnabled == 0 ?\n"
-  "    vec4 (0.f, 0.f, 0.f, 1.f) : textureLod (uEnvironmentMapTexture, theTexCoord, 0.f);\n"
+  "  if (uEnvMapEnabled == 0)\n"
+  "  {\n"
+  "#ifdef PATH_TRACING\n"
+  "    return theIsBackground ? vec4 (0.0, 0.0, 0.0, 1.0) : uGlobalAmbient;\n"
+  "#else\n"
+  "    return vec4 (0.0, 0.0, 0.0, 1.0);\n"
+  "#endif\n"
+  "  }\n"
+  "\n"
+  "  vec4 anAmbScale = theIsBackground ? vec4(1.0) : uGlobalAmbient;\n"
+  "  vec4 anEnvColor =\n"
+  "#ifdef BACKGROUND_CUBEMAP\n"
+  "    textureLod (uEnvMapTexture, cubemapVectorTransform (theTexCoord, theRadius), 0.0);\n"
+  "#else\n"
+  "    textureLod (uEnvMapTexture, Latlong (theTexCoord, theRadius), 0.0);\n"
+  "#endif\n"
+  "  return anEnvColor * anAmbScale;\n"
   "}\n"
   "\n"
   "// =======================================================================\n"
@@ -982,12 +1018,11 @@ static const char Shaders_RaytraceBase_fs[] =
   "    {\n"
   "      vec4 aColor = vec4 (0.0);\n"
   "\n"
-  "      if (bool(uSphereMapForBack) || aWeight.w == 0.0f /* reflection */)\n"
+  "      if (bool(uEnvMapForBack) || aWeight.w == 0.0f /* reflection */)\n"
   "      {\n"
   "        float aTime = IntersectSphere (theRay, uSceneRadius);\n"
   "\n"
-  "        aColor = FetchEnvironment (Latlong (\n"
-  "          theRay.Direct * aTime + theRay.Origin, uSceneRadius));\n"
+  "        aColor = FetchEnvironment (theRay.Direct * aTime + theRay.Origin, uSceneRadius, aWeight.w != 0.0);\n"
   "      }\n"
   "      else\n"
   "      {\n"
index 752c07e7f2229d5c953079b10bd3cbac5f043f08..335bce42241c6abf6ac6448f628a9dcc9583c0c2 100644 (file)
@@ -3,91 +3,10 @@ puts "0030700: Visualization, TKOpenGl - support PBR Metallic-Roughness shading
 puts "Spheres grid with different roughness values"
 puts "========"
 
-pload XDE OCAF MODELING VISUALIZATION
-psphere s 0.35
-
-catch { Close D }
-XNewDoc D
-
-# grid of spheres
-set THE_UPPER 6
-foreach i [list 0 3] {
-  set aPrefix ""
-  set aColor "GRAY80"
-  if { $i != 0 } {
-    set aPrefix "g_";
-    set aColor "CCB11D"
-  }
-  set aColShapes {}
-  for { set m 0 } { $m <= $THE_UPPER } { incr m } {
-    set aRowShapes {}
-    for { set r 0 } { $r <= $THE_UPPER } { incr r } {
-      set aName ${aPrefix}m${m}r${r}
-      copy s $aName
-      lappend aRowShapes $aName
-      ttranslate $aName ${r} ${i} ${m}
-    }
-    set aName ${aPrefix}m${m}
-    compound {*}$aRowShapes $aName
-    lappend aColShapes $aName
-  }
-  set aName ${aPrefix}spheres
-  compound {*}$aColShapes $aName
-  set aLabName "Gray Spheres"
-  if { $i != 0 } { set aLabName "Golden Spheres" }
-  set aLabComp [XAddShape D $aName 0]
-  SetName D $aLabComp $aLabName
-
-  for { set m 0 } { $m <= $THE_UPPER } { incr m } {
-    set aMet [expr 100 * ${m}/$THE_UPPER]
-    set aName ${aPrefix}m${m}
-    XAddComponent D $aLabComp $aName
-    set aLabCompCol [XFindShape D $aName]
-    SetName D $aLabCompCol "${aPrefix}m${aMet}%"
-    SetName D {*}[XFindComponent D $aName] "${aPrefix}m${aMet}%"
-    for { set r 0 } { $r <= $THE_UPPER } { incr r } {
-      set aRoug [expr 100 * ${r}/$THE_UPPER]
-      set aName ${aPrefix}m${m}r${r}
-      XAddComponent D $aLabCompCol $aName
-      set aLab [XFindComponent D $aName]
-      SetName D {*}$aLab "${aPrefix}m${aMet}%_r${aRoug}%"
-      XAddVisMaterial D $aName -baseColor $aColor -metallic ${m}/$THE_UPPER -roughness ${r}/$THE_UPPER
-      XSetVisMaterial D {*}$aLab $aName
-    }
-  }
-}
-set aLab [XFindShape D s]
-SetName D {*}$aLab "Sphere"
-
-XGetAllVisMaterials D
-
-# labels
-text2brep tm  "Metal"     -plane 0 -1 0 0 0 -1 -height 0.5 -pos -0.5 0  6.5 -halign left  -valign top -font monospace
-text2brep tnm "Non-metal" -plane 0 -1 0 0 0 -1 -height 0.5 -pos -0.5 0 -0.5 -halign right -valign top -font monospace
-text2brep ts  "Smooth"    -plane 0 -1 0 1 0  0 -height 0.5 -pos -0.5 0 -0.5 -halign left  -valign top -font monospace
-text2brep tr  "Rough"     -plane 0 -1 0 1 0  0 -height 0.5 -pos  6.5 0 -0.5 -halign right -valign top -font monospace
-compound tm tnm ts tr labs
-set aLab [XAddShape D labs 0]
-SetName D $aLab "Labels"
-XAddComponent D $aLab tm
-XAddComponent D $aLab tnm
-XAddComponent D $aLab ts
-XAddComponent D $aLab tr
-SetName D {*}[XFindComponent D tm]  "Metal"
-SetName D    [XFindShape     D tm]  "Metal"
-SetName D {*}[XFindComponent D tnm] "Non-metal"
-SetName D    [XFindShape     D tnm] "Non-metal"
-SetName D {*}[XFindComponent D ts]  "Smooth"
-SetName D    [XFindShape     D ts]  "Smooth"
-SetName D {*}[XFindComponent D tr]  "Rough"
-SetName D    [XFindShape     D tr]  "Rough"
-
 vclear
-vinit View1 -width 768 -height 768
-vfront
-vrenderparams -shadingModel PBR
-vlight -change 0 -intensity 2.5
-XDisplay -dispMode 1 D
+vclose ALL
+source $env(CSF_OCCTSamplesPath)/tcl/vis_pbr_spheres.tcl
+
 vcamera -ortho
 vfit
 vlight -change 1 -intensity 0.0001
index a91985002954aff68dafb1dffc01a008c90e6255..f06431cfc2e04b6a018fc0101a43d50307188598 100644 (file)
@@ -2,69 +2,7 @@ puts "========"
 puts "Ray Tracing - check depth-of-field"
 puts "========"
 
-pload MODELING VISUALIZATION
-
-vclear
-vinit View1
-
-vlight add positional head 0 pos 0.5 0.5 0.85
-vlight change 0 sm 0.06
-vlight change 0 int 25.0
-
-vsetdispmode 1
-vcamera -persp
-
-box b 1 1 1 
-explode b FACE 
-vdisplay -noupdate b_1 b_2 b_3 b_5 b_6
-vlocation -noupdate b_1 -setLocation  1  0  0
-vlocation -noupdate b_2 -setLocation -1  0  0
-vlocation -noupdate b_3 -setLocation  0  1  0
-vlocation -noupdate b_5 -setLocation  0  0  1
-vlocation -noupdate b_6 -setLocation  0  0 -1
-
-vsetmaterial -noupdate b_1 plastic
-vsetmaterial -noupdate b_2 plastic
-vsetmaterial -noupdate b_3 plastic
-vsetmaterial -noupdate b_5 plastic
-vsetmaterial -noupdate b_6 plastic
-vbsdf b_1 -kd 1 0.3 0.3 -ks 0
-vbsdf b_2 -kd 0.3 0.5 1 -ks 0
-vbsdf b_3 -kd 1 -ks 0
-vbsdf b_5 -kd 1 -ks 0
-vbsdf b_6 -kd 1 -ks 0
-
-vfront
-vfit
-
-psphere s 0.2
-vdisplay     -noupdate s
-vlocation    -noupdate s -setLocation 0.21 0.3 0.2
-vsetmaterial -noupdate s glass
-vbsdf s -absorpColor 0.8 0.8 1.0
-vbsdf s -absorpCoeff 6
-
-box c 0.3 0.3 0.2
-vdisplay     -noupdate c
-vlocation    -noupdate c -setLocation 0.55 0.3 0.0
-vlocation    -noupdate c -rotate 0 0 0 0 0 1 -30
-vsetmaterial -noupdate c plastic
-vbsdf c -kd 1.0 0.8 0.2 -ks 0.3 -n
-
-box g 0.15 0.15 0.3
-vdisplay     -noupdate g
-vlocation    -noupdate g -setLocation 0.7 0.25 0.2
-vlocation    -noupdate g -rotate 0 0 0 0 0 1 10
-vsetmaterial -noupdate g glass
-vbsdf g -absorpColor 0.8 1.0 0.8
-vbsdf g -absorpCoeff 6
-
-psphere r 0.1
-vdisplay -noupdate r
-vsetmaterial -noupdate r plastic
-vbsdf r -kd 0.5 0.9 0.3 -ks 0.3 -baseRoughness 0.0 -n
-vbsdf r -baseFresnel Constant 1.0
-vlocation r -setLocation 0.5 0.65 0.1
+source $env(CSF_OCCTSamplesPath)/tcl/pathtrace_cube.tcl
 
 vrenderparams -ray -gi -rayDepth 10 -iss
 vrenderparams -aperture 0.1 -focal 2.0
index ec3e094c83d500e4791aca717054c5ce56311c14..61e1c289cfcc6b915fd13a514331223d1e43425d 100644 (file)
@@ -2,69 +2,7 @@ puts "========"
 puts "Ray Tracing - check depth-of-field"
 puts "========"
 
-pload MODELING VISUALIZATION
-
-vclear
-vinit View1
-
-vlight add positional head 0 pos 0.5 0.5 0.85
-vlight change 0 sm 0.06
-vlight change 0 int 25.0
-
-vsetdispmode 1
-vcamera -persp
-
-box b 1 1 1 
-explode b FACE 
-vdisplay -noupdate b_1 b_2 b_3 b_5 b_6
-vlocation -noupdate b_1 -setLocation  1  0  0
-vlocation -noupdate b_2 -setLocation -1  0  0
-vlocation -noupdate b_3 -setLocation  0  1  0
-vlocation -noupdate b_5 -setLocation  0  0  1
-vlocation -noupdate b_6 -setLocation  0  0 -1
-
-vsetmaterial -noupdate b_1 plastic
-vsetmaterial -noupdate b_2 plastic
-vsetmaterial -noupdate b_3 plastic
-vsetmaterial -noupdate b_5 plastic
-vsetmaterial -noupdate b_6 plastic
-vbsdf b_1 -kd 1 0.3 0.3 -ks 0
-vbsdf b_2 -kd 0.3 0.5 1 -ks 0
-vbsdf b_3 -kd 1 -ks 0
-vbsdf b_5 -kd 1 -ks 0
-vbsdf b_6 -kd 1 -ks 0
-
-vfront
-vfit
-
-psphere s 0.2
-vdisplay     -noupdate s
-vlocation    -noupdate s -setLocation 0.21 0.3 0.2
-vsetmaterial -noupdate s glass
-vbsdf s -absorpColor 0.8 0.8 1.0
-vbsdf s -absorpCoeff 6
-
-box c 0.3 0.3 0.2
-vdisplay     -noupdate c
-vlocation    -noupdate c -setLocation 0.55 0.3 0.0
-vlocation    -noupdate c -rotate 0 0 0 0 0 1 -30
-vsetmaterial -noupdate c plastic
-vbsdf c -kd 1.0 0.8 0.2 -ks 0.3 -n
-
-box g 0.15 0.15 0.3
-vdisplay     -noupdate g
-vlocation    -noupdate g -setLocation 0.7 0.25 0.2
-vlocation    -noupdate g -rotate 0 0 0 0 0 1 10
-vsetmaterial -noupdate g glass
-vbsdf g -absorpColor 0.8 1.0 0.8
-vbsdf g -absorpCoeff 6
-
-psphere r 0.1
-vdisplay -noupdate r
-vsetmaterial -noupdate r plastic
-vbsdf r -kd 0.5 0.9 0.3 -ks 0.3 -baseRoughness 0.0 -n
-vbsdf r -baseFresnel Constant 1.0
-vlocation r -setLocation 0.5 0.65 0.1
+source $env(CSF_OCCTSamplesPath)/tcl/pathtrace_cube.tcl
 
 vrenderparams -ray -gi -rayDepth 10 -iss
 vrenderparams -aperture 0.1 -focal 2.0
diff --git a/tests/v3d/raytrace/pbr_spheres b/tests/v3d/raytrace/pbr_spheres
new file mode 100644 (file)
index 0000000..e22f0ee
--- /dev/null
@@ -0,0 +1,40 @@
+puts "========"
+puts "0031225: Visualization, TKOpenGl - support cubemap for environment texture within Ray-Tracing"
+puts "Spheres grid with different roughness values"
+puts "========"
+
+vclear
+vclose ALL
+source $env(CSF_OCCTSamplesPath)/tcl/vis_pbr_spheres.tcl
+
+vrenderparams -ray -gi -rayDepth 10
+vcamera -ortho
+vfit
+vlight -change 1 -intensity 0.0001
+vfps 200
+vdump $::imagedir/${::casename}_ortho0.png
+
+vlight -change 1 -intensity 0.3
+vfps 200
+vdump $::imagedir/${::casename}_ortho30.png
+
+vcamera -persp
+vfit
+vlight -change 1 -intensity 0.0001
+vfps 200
+vdump $::imagedir/${::casename}_persp0.png
+
+vlight -change 1 -intensity 0.3
+vfps 200
+vdump $::imagedir/${::casename}_persp30.png
+
+set aCubeMap [locate_data_file Circus_CubeMap_V.png]
+vlight -change 1 -intensity 1
+vbackground -cubemap $aCubeMap
+vcamera -ortho
+vfps 200
+vdump $::imagedir/${::casename}_orthoenv.png
+
+vcamera -persp
+vfps 200
+vdump $::imagedir/${::casename}_perspenv.png
index 35de06025d9e4137036a9bf5812dfb72a91dc85d..b6d3518e1e163b5cd99587ef5b2962e60b232e13 100644 (file)
@@ -70,6 +70,9 @@ vsetcolor wall2 green
 vfront
 vturnview 0 -0.3 0
 vfit
-vlight -change 0 -dir -0.577 -0.577 -0.577
-vlight add directional
+vlight -clear
+vlight -add ambient
+vlight -add directional -dir -0.577 -0.577 -0.577 -head 1
+vlight -add directional -dir  0.577, 0.577, 0.577 -head 0
+
 vrenderparams -raytrace -raydepth 3 -shadows on -reflections -fsaa
index e950aaeeb869770aa155f91b95da5c516eb6d5a2..91f31b841e6f8293696226c1385f99932da712e5 100644 (file)
@@ -2,69 +2,7 @@ puts "========"
 puts "Ray Tracing - check tone mapping"
 puts "========"
 
-pload MODELING VISUALIZATION
-
-vclear
-vinit View1
-
-vlight add positional head 0 pos 0.5 0.5 0.85
-vlight change 0 sm 0.06
-vlight change 0 int 25.0
-
-vsetdispmode 1
-vcamera -persp
-
-box b 1 1 1 
-explode b FACE 
-vdisplay -noupdate b_1 b_2 b_3 b_5 b_6
-vlocation -noupdate b_1 -setLocation  1  0  0
-vlocation -noupdate b_2 -setLocation -1  0  0
-vlocation -noupdate b_3 -setLocation  0  1  0
-vlocation -noupdate b_5 -setLocation  0  0  1
-vlocation -noupdate b_6 -setLocation  0  0 -1
-
-vsetmaterial -noupdate b_1 plastic
-vsetmaterial -noupdate b_2 plastic
-vsetmaterial -noupdate b_3 plastic
-vsetmaterial -noupdate b_5 plastic
-vsetmaterial -noupdate b_6 plastic
-vbsdf b_1 -kd 1 0.3 0.3 -ks 0
-vbsdf b_2 -kd 0.3 0.5 1 -ks 0
-vbsdf b_3 -kd 1 -ks 0
-vbsdf b_5 -kd 1 -ks 0
-vbsdf b_6 -kd 1 -ks 0
-
-vfront
-vfit
-
-psphere s 0.2
-vdisplay     -noupdate s
-vlocation    -noupdate s -setLocation 0.21 0.3 0.2
-vsetmaterial -noupdate s glass
-vbsdf s -absorpColor 0.8 0.8 1.0
-vbsdf s -absorpCoeff 6
-
-box c 0.3 0.3 0.2
-vdisplay     -noupdate c
-vlocation    -noupdate c -setLocation 0.55 0.3 0.0
-vlocation    -noupdate c -rotate 0 0 0 0 0 1 -30
-vsetmaterial -noupdate c plastic
-vbsdf c -kd 1.0 0.8 0.2 -ks 0.3 -n
-
-box g 0.15 0.15 0.3
-vdisplay     -noupdate g
-vlocation    -noupdate g -setLocation 0.7 0.25 0.2
-vlocation    -noupdate g -rotate 0 0 0 0 0 1 10
-vsetmaterial -noupdate g glass
-vbsdf g -absorpColor 0.8 1.0 0.8
-vbsdf g -absorpCoeff 6
-
-psphere r 0.1
-vdisplay -noupdate r
-vsetmaterial -noupdate r plastic
-vbsdf r -kd 0.5 0.9 0.3 -ks 0.3 -baseRoughness 0.0 -n
-vbsdf r -baseFresnel Constant 1.0
-vlocation r -setLocation 0.5 0.65 0.1
+source $env(CSF_OCCTSamplesPath)/tcl/pathtrace_cube.tcl
 
 vrenderparams -ray -gi -rayDepth 10 -iss