1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0032403: Visualization - RayTracing renders all object as white color in view with white background

OpenGl_Caps::buffersOpaqueAlpha is now set to TRUE by default.
OpenGl_View::runPathtrace - fixed higlighting with PathTracing turned on and buffersOpaqueAlpha=true.
This commit is contained in:
kgv 2021-08-25 10:55:38 +03:00 committed by bugmaster
parent 45d498ef1f
commit 8a77384b0c
4 changed files with 22 additions and 26 deletions

View File

@ -35,7 +35,7 @@ OpenGl_Caps::OpenGl_Caps()
swapInterval (1),
useZeroToOneDepth (Standard_False),
buffersNoSwap (Standard_False),
buffersOpaqueAlpha(Standard_False),
buffersOpaqueAlpha(Standard_True),
contextStereo (Standard_False),
contextDebug (Standard_False),
contextSyncDebug (Standard_False),
@ -54,8 +54,7 @@ OpenGl_Caps::OpenGl_Caps()
glslDumpLevel (OpenGl_ShaderProgramDumpLevel_Off)
{
#if defined(__EMSCRIPTEN__)
buffersNoSwap = true; // swap has no effect in WebGL
buffersOpaqueAlpha = true; // avoid unexpected blending of canvas with page background
buffersNoSwap = true; // swap has no effect in WebGL
#endif
#ifdef OCCT_DEBUG
contextDebug = true;

View File

@ -56,7 +56,7 @@ public: //! @name context creation parameters
* (e.g. it could be opaque or not in case of transparent material).
* With alpha writes disabled, color buffer will be kept opaque.
*
* OFF by default.
* ON by default.
*/
Standard_Boolean buffersOpaqueAlpha;

View File

@ -2861,14 +2861,14 @@ Standard_Boolean OpenGl_View::runRaytrace (const Standard_Integer theSize
{
myRaytraceFBO1[aFBOIdx]->BindBuffer (theGlContext);
glClear (GL_DEPTH_BUFFER_BIT); // render the image with depth
theGlContext->core11fwd->glClear (GL_DEPTH_BUFFER_BIT); // render the image with depth
}
theGlContext->core20fwd->glDrawArrays (GL_TRIANGLES, 0, 6);
if (myRenderParams.IsAntialiasingEnabled)
{
glDisable (GL_DEPTH_TEST); // improve jagged edges without depth buffer
theGlContext->core11fwd->glDisable (GL_DEPTH_TEST); // improve jagged edges without depth buffer
// bind ray-tracing output image as input
myRaytraceFBO1[aFBOIdx]->ColorTexture()->Bind (theGlContext, OpenGl_RT_FsaaInputTexture);
@ -2924,7 +2924,7 @@ Standard_Boolean OpenGl_View::runRaytrace (const Standard_Integer theSize
const Handle(OpenGl_FrameBuffer)& aRenderImageFramebuffer = myRaytraceFBO2[aFBOIdx];
const Handle(OpenGl_FrameBuffer)& aDepthSourceFramebuffer = myRaytraceFBO1[aFBOIdx];
glEnable (GL_DEPTH_TEST);
theGlContext->core11fwd->glEnable (GL_DEPTH_TEST);
// Display filtered image
theGlContext->BindProgram (myOutImageProgram);
@ -3032,11 +3032,13 @@ Standard_Boolean OpenGl_View::runPathtrace (const Standard_Integer
// extend viewport here, so that tiles at boundaries (cut tile size by target rendering viewport)
// redirected to inner tiles (full tile size) are drawn entirely
const Graphic3d_Vec2i anOffsetViewport = myTileSampler.OffsetTilesViewport (myAccumFrames > 1); // shrunk offsets texture will be uploaded since 3rd frame
glViewport (0, 0, anOffsetViewport.x(), anOffsetViewport.y());
theGlContext->core11fwd->glViewport (0, 0, anOffsetViewport.x(), anOffsetViewport.y());
}
const NCollection_Vec4<bool> aColorMask = theGlContext->ColorMaskRGBA();
theGlContext->SetColorMaskRGBA (NCollection_Vec4<bool> (true)); // force writes into all components, including alpha
// Generate for the given RNG seed
glDisable (GL_DEPTH_TEST);
theGlContext->core11fwd->glDisable (GL_DEPTH_TEST);
// Adaptive Screen Sampling computes the same overall amount of samples per frame redraw as normal Path Tracing,
// but distributes them unequally across pixels (grouped in tiles), so that some pixels do not receive new samples at all.
@ -3070,10 +3072,11 @@ Standard_Boolean OpenGl_View::runPathtrace (const Standard_Integer
}
aRenderImageFramebuffer->UnbindBuffer (theGlContext);
theGlContext->SetColorMaskRGBA (aColorMask);
if (myRaytraceParameters.AdaptiveScreenSampling
&& myRaytraceParameters.AdaptiveScreenSamplingAtomic)
{
glViewport (0, 0, theSizeX, theSizeY);
theGlContext->core11fwd->glViewport (0, 0, theSizeX, theSizeY);
}
return true;
}
@ -3125,7 +3128,7 @@ Standard_Boolean OpenGl_View::runPathtraceOut (const Graphic3d_Camera::Projectio
aRenderImageFramebuffer->ColorTexture()->Bind (theGlContext, OpenGl_RT_PrevAccumTexture);
// Copy accumulated image with correct depth values
glEnable (GL_DEPTH_TEST);
theGlContext->core11fwd->glEnable (GL_DEPTH_TEST);
theGlContext->core20fwd->glDrawArrays (GL_TRIANGLES, 0, 6);
aRenderImageFramebuffer->ColorTexture()->Unbind (theGlContext, OpenGl_RT_PrevAccumTexture);
@ -3190,7 +3193,7 @@ Standard_Boolean OpenGl_View::raytrace (const Standard_Integer theSizeX,
0, GL_DEBUG_SEVERITY_MEDIUM, "Error: Failed to acquire OpenGL image textures");
}
glDisable (GL_BLEND);
theGlContext->core11fwd->glDisable (GL_BLEND);
const Standard_Boolean aResult = runRaytraceShaders (theSizeX,
theSizeY,

View File

@ -2,34 +2,28 @@ puts "============"
puts "OCC26726 erase selected objects"
puts "============"
puts ""
pload VISUALIZATION
pload VISUALIZATION
vclear
vclose all
vinit View1
vsetdispmode 1
box b0 5 0 0 1 1 1
box b1 0 5 0 1 1 1
box b2 0 0 5 1 1 1
box b3 5 5 5 1 1 1
vdisplay b0 b1 b2 b3
vdump $imagedir/${casename}_0.png
vdisplay b0 b1 b2 b3 -dispMode 1
vfit
vdump $imagedir/${casename}_0.png
vselect 0 0 500 500
verase
vdump $imagedir/${casename}_1.png
set info_b0 [vreadpixel 205 355 name]
set info_b1 [vreadpixel 205 190 name]
set info_b2 [vreadpixel 60 100 name]
set info_b3 [vreadpixel 350 100 name]
if { $info_b0 != "BLACK 0" || $info_b1 != "BLACK 0" || $info_b2 != "BLACK 0" || $info_b3 != "BLACK 0" } {
set info_b0 [vreadpixel 205 355 -rgb -name]
set info_b1 [vreadpixel 205 190 -rgb -name]
set info_b2 [vreadpixel 60 100 -rgb -name]
set info_b3 [vreadpixel 350 100 -rgb -name]
if { $info_b0 != "BLACK" || $info_b1 != "BLACK" || $info_b2 != "BLACK" || $info_b3 != "BLACK" } {
puts "Error: OCC26726 is reproduced. AIS_InteractiveContext::EraseSelected is incorrect."
}