diff --git a/README.md b/README.md index 5254bcab..eab7f74f 100644 --- a/README.md +++ b/README.md @@ -166,9 +166,12 @@ any other Steam features. The RBDOOM-3-BFG Edition GPL Source Code release includes functionality for rendering Bink Videos through FFmpeg or libbinkdec. ### Back End Rendering of Stencil Shadows -The Doom 3 BFG Edition GPL Source Code release does not include functionality enabling rendering +The RBOOM-3-BFG Edition GPL Source Code release includes functionality enabling rendering of stencil shadows via the "depth fail" method, a functionality commonly known as "Carmack's Reverse". +This method was patented by Creative Labs and has finally expired on 2019-10-13. +(see https://patents.google.com/patent/US6384822B1/en for expiration status) + --- ## License See docs/COPYING.txt for the GNU GENERAL PUBLIC LICENSE diff --git a/neo/renderer/OpenGL/RenderBackend_GL.cpp b/neo/renderer/OpenGL/RenderBackend_GL.cpp index cc7070ce..edd002c8 100644 --- a/neo/renderer/OpenGL/RenderBackend_GL.cpp +++ b/neo/renderer/OpenGL/RenderBackend_GL.cpp @@ -1614,7 +1614,9 @@ void idRenderBackend::DrawStencilShadowPass( const drawSurf_t* drawSurf, const b } else { - // Z-fail + // Z-fail (Carmack's Reverse) + glStencilOpSeparate( GL_FRONT, GL_KEEP, GL_DECR, GL_KEEP ); + glStencilOpSeparate( GL_BACK, GL_KEEP, GL_INCR, GL_KEEP ); } // get vertex buffer diff --git a/neo/renderer/RenderBackend.cpp b/neo/renderer/RenderBackend.cpp index 06251325..3a36d049 100644 --- a/neo/renderer/RenderBackend.cpp +++ b/neo/renderer/RenderBackend.cpp @@ -42,7 +42,7 @@ If you have questions concerning this license or the applicable additional terms idCVar r_drawEyeColor( "r_drawEyeColor", "0", CVAR_RENDERER | CVAR_BOOL, "Draw a colored box, red = left eye, blue = right eye, grey = non-stereo" ); idCVar r_motionBlur( "r_motionBlur", "0", CVAR_RENDERER | CVAR_INTEGER | CVAR_ARCHIVE, "1 - 5, log2 of the number of motion blur samples" ); idCVar r_forceZPassStencilShadows( "r_forceZPassStencilShadows", "0", CVAR_RENDERER | CVAR_BOOL, "force Z-pass rendering for performance testing" ); -idCVar r_useStencilShadowPreload( "r_useStencilShadowPreload", "1", CVAR_RENDERER | CVAR_BOOL, "use stencil shadow preload algorithm instead of Z-fail" ); +idCVar r_useStencilShadowPreload( "r_useStencilShadowPreload", "0", CVAR_RENDERER | CVAR_BOOL, "use stencil shadow preload algorithm instead of Z-fail" ); idCVar r_skipShaderPasses( "r_skipShaderPasses", "0", CVAR_RENDERER | CVAR_BOOL, "" ); idCVar r_skipInteractionFastPath( "r_skipInteractionFastPath", "1", CVAR_RENDERER | CVAR_BOOL, "" ); idCVar r_useLightStencilSelect( "r_useLightStencilSelect", "0", CVAR_RENDERER | CVAR_BOOL, "use stencil select pass" ); diff --git a/neo/renderer/Vulkan/RenderBackend_VK.cpp b/neo/renderer/Vulkan/RenderBackend_VK.cpp index ea110ced..13109276 100644 --- a/neo/renderer/Vulkan/RenderBackend_VK.cpp +++ b/neo/renderer/Vulkan/RenderBackend_VK.cpp @@ -2321,7 +2321,11 @@ void idRenderBackend::DrawStencilShadowPass( const drawSurf_t* drawSurf, const b } else { - // Z-fail + // Z-fail (Carmack's Reverse) + uint64 stencil = GLS_STENCIL_OP_FAIL_KEEP | GLS_STENCIL_OP_ZFAIL_DECR | GLS_STENCIL_OP_PASS_KEEP + | GLS_BACK_STENCIL_OP_FAIL_KEEP | GLS_BACK_STENCIL_OP_ZFAIL_INCR | GLS_BACK_STENCIL_OP_PASS_KEEP; + + GL_State( ( glStateBits & ~GLS_STENCIL_OP_BITS ) | stencil ); } // get vertex buffer