vclear
vclose all
-vinit name=View1 w=512 h=512 t=256 l=1024
-vsetdispmode 1
-vcamera -persp -fovy 60
-
-vtrihedron tr0
-vzbufftrihedron
-
# Declaration global variables
global startTimeTyre
global currentTimeTyre
set folderEnv "D:/TmpFiles/for_video/Environment"
set folderVideo "D:/TmpFiles/for_video/Result"
+set width 512
+set height 512
+
# Settings
set isEditLight 1
set isGI 1
-set isAnim 1
+set isAnim 0
+
+vinit name=View1 w=${width} h=${height} t=256 l=1024
+vsetdispmode 1
+vcamera -persp -fovy 60
-#road
-puts "Loading road..."
-#vdisplayobj road "${folderEnv}/roadV2.obj"
-#vlocrotate road 0 0 0 1 0 0 90
-#vlocscale road 1 1 0 102400
-#vloctranslate road 0 1.0008 3.5
+vzbufftrihedron
#building0
puts "Loading the first building..."
#vlocrotate building0 0 0 0 0 1 0 45
#vloctranslate building0 -6 3 3
-
#House N090614
puts "Loading the second building..."
+#height 7000
#vdisplayobj building1 "${folderEnv}/Scene BuildingN090614.obj"
-#vlocscale building1 1 1 1 21845
+#vlocscale building1 1 1 1 15555
#vloctranslate building1 -1 1 1
#vlocrotate building1 0 0 0 0 0 1 180
#Building1
puts "Loading the third building..."
#vdisplayobj building2 "${folderEnv}/Scene BuildingN101213.obj"
-#vlocscale building2 1 1 1 21845
+#vlocscale building2 1 1 1 15555
#vloctranslate building2 -1 1 1
#vlocrotate building2 0 0 0 0 0 1 180
#lawn
puts "Loading lawn..."
#vdisplayobj lawn "${folderEnv}/Scene Lawn.obj"
-#vlocscale lawn 1 1 1 21485
+#vlocscale lawn 1 1 1 15555
#vloctranslate lawn -1 1 1
#vlocrotate lawn 0 0 0 0 0 1 180
#vsetmaterial lawn plastic
#bench0
puts "Loading the first bench..."
#vdisplayobj bench0 "${folderEnv}/Scene BenchN210815.obj"
-#vlocscale bench0 1 1 1 21485
+#vlocscale bench0 1 1 1 15555
#vloctranslate bench0 -1 1 1
#vlocrotate bench0 0 0 0 0 0 1 180
#urn0
puts "Loading the first urn..."
-vdisplayobj urn0 "${folderEnv}/Scene Urn.obj"
-vlocscale urn0 1 1 1 21485
-vloctranslate urn0 -1 1 1
-vlocrotate urn0 0 0 0 0 0 1 180
+#vdisplayobj urn0 "${folderEnv}/Scene Urn.obj"
+#vlocscale urn0 1 1 1 15555
+#vloctranslate urn0 -1 1 1
+#vlocrotate urn0 0 0 0 0 0 1 180
+
+#The ground
+puts "Loading the ground..."
+#vdisplayobj ground "${folderEnv}/Scene Ground.obj"
+#vlocscale ground 1 1 1 25000
+#vloctranslate ground -1 1 1
+#vlocrotate ground 0 0 0 0 0 1 180
+
+vdisplayobj building0 "${folderEnv}/Scene Building0.obj"
+#vloctranslate building0 21494 886 0
+
+vdisplayobj building1 "${folderEnv}/Scene Building1.obj"
+#vloctranslate building1 21494 886 0
-vviewparams -eye 24631.990743707178 -5440.5284854311521 10802.013424258917
-vviewparams -at 5913.1650096036392 5334.3047672616967 5730.8013468954196
-vviewparams -proj 0.84373094111182723 -0.48566402239936912 0.22857943117746968
-vviewparams -up -0.41631981347694685 -0.32330155298659913 0.84979639840550847
+vdisplayobj pave0 "${folderEnv}/Scene Pave0.obj"
+#vloctranslate pave0 21494 886 0
+
+vdisplayobj pave1 "${folderEnv}/Scene Pave1.obj"
+#vloctranslate pave1 21494 886 0
+
+vdisplayobj ground "${folderEnv}/Scene Ground 1.obj"
+#vloctranslate ground 21494 886 0
+vviewparams -eye 2791.5312733012979 -725.23102548487986 116.8841126550864
+vviewparams -at 1725.2371931049909 335.97379619693942 -283.97309576949539
+vviewparams -proj 0.68489870691961574 -0.68162979017282999 0.257477359021686
+vviewparams -up -0.077576623573434436 0.2831440641922589 0.95593478145092925
if { ${isEditLight} == 1 } {
vlight change 0 head 0
vlight change 0 sm 0.1
vlight change 0 int 300
- vlight change 0 direction 1 1 -1
+ vlight change 0 direction -1 0.2 -1
}
vtextureenv on 4
if { ${isGI} == 1 } {
vrenderparams -gi
vrenderparams -brng
+ #vrenderparams -filter on
}
+vdisplayobj tyre_3 "${folderTyre}/tyre_3.5600.obj"
+#vloctranslate tyre_3 0 0 500
+
+#vdisplayobj pave "${folderEnv}/pave.obj"
+#vloctranslate pave 0 0 500
+
proc Anim0 {thePts theLocalPts theName} {
global startTimeTyre
global currentTimeTyre
if { ${currentTimeTyre} <= ${endTimeTyre} } {
puts "Loading tyre_${currentTimeTyre}..."
vdisplayobj tyre_${currentTimeTyre} "${folderTyre}/tyre_3.${currentTimeTyre}.obj"
+ #vrender -spp 10
+ vloctranslate tyre_${currentTimeTyre} 0 0 500
+ #vrender -spp 1
}
set currentTimeTyre [expr ${currentTimeTyre} + ${stepTimeTyre}]
if { ${isAnim} == 1 } {
vanim anim0 -reset -onRedraw Anim0
- vanim anim -reset -addSlice 0.0 0.5 anim0
- vanim -play anim -playFps 60 -record "${folderVideo}/video.mkv" -recWidth 1920 -recHeight 1080
+ vanim anim -reset -addSlice 0.0 3.0 anim0
+ vanim -play anim -playFps 20 -record "${folderVideo}/video.mkv" -recWidth 1920 -recHeight 1080
}
IsTransparentShadowEnabled (Standard_False),
UseEnvironmentMapBackground (Standard_False),
CoherentPathTracingMode (Standard_False),
+ IsGIFilteringEnabled (Standard_False),
+ RadianceClampValue (10.0),
// stereoscopic parameters
StereoMode (Graphic3d_StereoMode_QuadBuffer),
AnaglyphFilter (Anaglyph_RedCyan_Optimized),
Standard_Boolean IsTransparentShadowEnabled; //!< enables/disables light propagation through transparent media, False by default
Standard_Boolean UseEnvironmentMapBackground; //!< enables/disables environment map background
Standard_Boolean CoherentPathTracingMode; //!< enables/disables 'coherent' tracing mode (single RNG seed within 16x16 image blocks)
+ Standard_Boolean IsGIFilteringEnabled; //!< enables/disables post-processing of GI rendering results
+ Standard_Real RadianceClampValue; //!< maximum radiance value which will not be clamped.
Graphic3d_StereoMode StereoMode; //!< stereoscopic output mode, Graphic3d_StereoMode_QuadBuffer by default
Anaglyph AnaglyphFilter; //!< filter for anaglyph output, Anaglyph_RedCyan_Optimized by default
OpenGl_RT_uSphereMapForBack,
OpenGl_RT_uTexSamplersArray,
OpenGl_RT_uBlockedRngEnabled,
+ OpenGl_RT_uMaxRadiance,
// sampled frame params
OpenGl_RT_uSampleWeight,
OpenGl_RT_uFrameRndSeed,
+ OpenGl_RT_uBilateralEnabled,
// adaptive FSAA params
OpenGl_RT_uOffsetX,
aShaderProgram->GetUniformLocation (theGlContext, "uSphereMapForBack");
myUniformLocations[anIndex][OpenGl_RT_uBlockedRngEnabled] =
aShaderProgram->GetUniformLocation (theGlContext, "uBlockedRngEnabled");
+ myUniformLocations[anIndex][OpenGl_RT_uMaxRadiance] =
+ aShaderProgram->GetUniformLocation (theGlContext, "uMaxRadiance");
myUniformLocations[anIndex][OpenGl_RT_uSampleWeight] =
aShaderProgram->GetUniformLocation (theGlContext, "uSampleWeight");
theGlContext->BindProgram (myOutImageProgram);
+ myUniformLocations[0][OpenGl_RT_uBilateralEnabled] =
+ myOutImageProgram->GetUniformLocation (theGlContext, "uBilateralEnabled");
+
myOutImageProgram->SetSampler (theGlContext,
"uInputTexture", OpenGl_RT_PrevAccumTexture);
myRNG.SetSeed();
}
- // Set frame accumulation weight
myRaytraceProgram->SetUniform (theGlContext,
- myUniformLocations[0][OpenGl_RT_uSampleWeight], 1.f / (myAccumFrames + 1));
+ myUniformLocations[0][OpenGl_RT_uMaxRadiance], static_cast<Standard_ShortReal> (myRenderParams.RadianceClampValue));
// Set random number generator seed
myRaytraceProgram->SetUniform (theGlContext,
myUniformLocations[0][OpenGl_RT_uFrameRndSeed], static_cast<Standard_Integer> (myRNG.NextInt() >> 2));
- }
- theGlContext->core20fwd->glDrawArrays (GL_TRIANGLES, 0, 6);
+ Standard_Integer aSamplesPerPixel = myRenderParams.SamplesPerPixel;
+
+ if (aSamplesPerPixel == 0)
+ {
+ // Set frame accumulation weight
+ myRaytraceProgram->SetUniform (theGlContext,
+ myUniformLocations[0][OpenGl_RT_uSampleWeight], 1.f / (myAccumFrames + 1));
+
+ theGlContext->core20fwd->glDrawArrays (GL_TRIANGLES, 0, 6);
+ }
+ else
+ {
+ for (int aPassIndex = 0; aPassIndex < aSamplesPerPixel; ++aPassIndex)
+ {
+ aRenderFramebuffer = (myAccumFrames + aPassIndex) % 2 ? myRaytraceFBO1[aFBOIdx] : myRaytraceFBO2[aFBOIdx];
+ anAccumFramebuffer = (myAccumFrames + aPassIndex) % 2 ? myRaytraceFBO2[aFBOIdx] : myRaytraceFBO1[aFBOIdx];
+
+ aRenderFramebuffer->BindBuffer (theGlContext);
+
+ anAccumFramebuffer->ColorTexture()->Bind (
+ theGlContext, GL_TEXTURE0 + OpenGl_RT_PrevAccumTexture);
+
+ // Set frame accumulation weight
+ myRaytraceProgram->SetUniform (theGlContext,
+ myUniformLocations[0][OpenGl_RT_uSampleWeight], 1.f / (myAccumFrames + aPassIndex + 1));
+
+ // Set random number generator seed
+ myRaytraceProgram->SetUniform (theGlContext,
+ myUniformLocations[0][OpenGl_RT_uFrameRndSeed], static_cast<Standard_Integer> (myRNG.NextInt() >> 2));
+
+ theGlContext->core20fwd->glDrawArrays (GL_TRIANGLES, 0, 6);
+ //++myAccumFrames;
+ glFinish();
+ }
+ }
+ }
+ else
+ {
+ theGlContext->core20fwd->glDrawArrays (GL_TRIANGLES, 0, 6);
+ ++myAccumFrames;
+ }
if (myRaytraceParameters.GlobalIllumination)
{
aRenderFramebuffer->DepthStencilTexture()->Bind (
theGlContext, GL_TEXTURE0 + OpenGl_RT_DepthTexture);
+ myOutImageProgram->SetUniform (theGlContext,
+ myUniformLocations[0][OpenGl_RT_uBilateralEnabled], myRenderParams.IsGIFilteringEnabled ? 1 : 0);
+
theGlContext->core20fwd->glDrawArrays (GL_TRIANGLES, 0, 6);
aRenderFramebuffer->DepthStencilTexture()->Unbind (
if (myRenderParams.Method == Graphic3d_RM_RAYTRACING
&& myRenderParams.IsGlobalIlluminationEnabled)
{
- myAccumFrames++;
+ myAccumFrames += myRenderParams.SamplesPerPixel;
}
// bind default FBO
//! Ray tracing depth image.
uniform sampler2D uDepthTexture;
+uniform int uBilateralEnabled;
+
//! Output pixel color.
out vec4 OutColor;
+const float rI = 0.270 * 1.0f; // The intensity radius (in pixels).
+const float rL = 1.71 * 0.5f; // The geometric radius (in pixels).
+const int WindowSize = 8; // The window size (in pixels).
+
+float gaussian (float theL, float theR)
+{
+ return exp (-theL * theL / (2.0f * theR * theR));
+}
+
+vec4 bilateral()
+{
+ // Get the sizes
+ int aWindow = WindowSize / 2;
+ vec4 anOutCol = vec4 (0.f, 0.f, 0.f, 0.f);
+ vec4 aRefCol = texelFetch (uInputTexture, ivec2 (gl_FragCoord.xy), 0);
+ float aNorm = 0.f;
+
+ // Compute the kernel
+ for (int i = -aWindow; i <= aWindow; i++)
+ {
+ for (int j = -aWindow; j <= aWindow; j++)
+ {
+ vec4 aCol = texelFetch (uInputTexture, ivec2 (gl_FragCoord.xy) + ivec2 (j, i), 0);
+ float A = gaussian (distance (aCol, aRefCol), rI);
+ float B = gaussian (length (vec2(j, i)), rL);
+ anOutCol += aCol * A * B;
+ aNorm += A * B;
+ }
+ }
+ return anOutCol * (1.f / aNorm);
+}
+
void main (void)
{
- vec4 aColor = texelFetch (uInputTexture, ivec2 (gl_FragCoord.xy), 0);
+ vec4 aColor;
+
+ if (bool (uBilateralEnabled))
+ {
+ aColor = bilateral();
+ }
+ else
+ {
+ aColor = texelFetch (uInputTexture, ivec2 (gl_FragCoord.xy), 0);
+ }
float aDepth = texelFetch (uDepthTexture, ivec2 (gl_FragCoord.xy), 0).r;
gl_FragDepth = aDepth;
// apply gamma correction (we use gamma = 2)
OutColor = vec4 (sqrt (aColor.rgb), aColor.a);
-}
+}
\ No newline at end of file
//! Increases performance up to 4 times, but noise becomes structured.
uniform int uBlockedRngEnabled;
-#define MAX_RADIANCE vec3 (10.f)
+//! Maximum value for radiance clamping.
+uniform float uMaxRadiance;
// =======================================================================
// function : main
aColor.rgb = ZERO;
}
- aColor.rgb = min (aColor.rgb, MAX_RADIANCE);
+ aColor.rgb = min (aColor.rgb, vec3 (uMaxRadiance));
OutColor = mix (texture2D (uAccumTexture, vPixel), aColor, uSampleWeight);
#else
theDI << "reflections: " << (aParams.IsReflectionEnabled ? "on" : "off") << "\n";
theDI << "gleam: " << (aParams.IsTransparentShadowEnabled ? "on" : "off") << "\n";
theDI << "GI: " << (aParams.IsGlobalIlluminationEnabled ? "on" : "off") << "\n";
+ theDI << "samples: " << aParams.SamplesPerPixel << "\n";
+ theDI << "filtering: " << (aParams.IsGIFilteringEnabled ? "on" : "off") << "\n";
theDI << "blocked RNG: " << (aParams.CoherentPathTracingMode ? "on" : "off") << "\n";
theDI << "shadingModel: ";
switch (aView->ShadingModel())
aParams.RaytracingDepth = aDepth;
}
}
+ else if (aFlag == "-maxrad"
+ || aFlag == "-rclamp")
+ {
+ if (toPrint)
+ {
+ theDI << aParams.RadianceClampValue << " ";
+ continue;
+ }
+ else if (++anArgIter >= theArgNb)
+ {
+ std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n";
+ return 1;
+ }
+
+ aParams.RadianceClampValue = Draw::Atoi (theArgVec[anArgIter]);
+ }
+ else if (aFlag == "-samples"
+ || aFlag == "-spp")
+ {
+ if (toPrint)
+ {
+ theDI << aParams.SamplesPerPixel << " ";
+ continue;
+ }
+ else if (++anArgIter >= theArgNb)
+ {
+ std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n";
+ return 1;
+ }
+
+ const Standard_Integer aSamples = Draw::Atoi (theArgVec[anArgIter]);
+
+ if (aSamples < 0)
+ {
+ std::cerr << "Error: invalid ray-tracing samples per pixel " << aSamples << ". SPP should be a positive number.\n";
+ return 1;
+ }
+ else
+ {
+ aParams.SamplesPerPixel = aSamples;
+ }
+ }
else if (aFlag == "-shad"
|| aFlag == "-shadows")
{
aParams.RaytracingDepth = Min (aParams.RaytracingDepth, 10);
}
}
+ else if (aFlag == "-filter" || aFlag == "-pp" )
+ {
+ if (toPrint)
+ {
+ theDI << (aParams.IsGIFilteringEnabled ? "on" : "off") << " ";
+ continue;
+ }
+
+ Standard_Boolean toEnable = Standard_True;
+ if (++anArgIter < theArgNb
+ && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+ {
+ --anArgIter;
+ }
+ aParams.IsGIFilteringEnabled = toEnable;
+ }
else if (aFlag == "-blockedrng"
|| aFlag == "-brng")
{