@@ -2857,6 +2857,34 @@ void R_DrawWorldSurfaceLeafStatic(CWorldSurfaceModel* pModel, CWorldSurfaceLeaf*
28572857 WSurfProgramState |= WSURF_SHADOW_CASTER_ENABLED;
28582858 }
28592859
2860+ else if (R_ShouldDrawGlowStencilEnableDepthTest ())
2861+ {
2862+ // Don't draw color, double side
2863+ WSurfProgramState |= WSURF_STENCIL_NO_GLOW_COLOR_ENABLED | WSURF_DOUBLE_FACE_ENABLED | WSURF_SHADOW_CASTER_ENABLED;
2864+ }
2865+ else if (R_ShouldDrawGlowStencilWallHackBehindWallOnly ())
2866+ {
2867+ // Don't draw color
2868+ WSurfProgramState |= WSURF_STENCIL_NO_GLOW_COLOR_ENABLED | WSURF_STENCIL_NO_GLOW_BLUR_ENABLED | WSURF_SHADOW_CASTER_ENABLED;
2869+ }
2870+ else if (R_ShouldDrawGlowStencilWallHack ())
2871+ {
2872+ // Don't draw color
2873+ WSurfProgramState |= WSURF_STENCIL_NO_GLOW_BLUR_ENABLED | WSURF_SHADOW_CASTER_ENABLED;
2874+ }
2875+ else if (R_ShouldDrawGlowStencil ())
2876+ {
2877+ WSurfProgramState |= WSURF_STENCIL_NO_GLOW_BLUR_ENABLED;
2878+ }
2879+ else if (R_ShouldDrawGlowColor () || R_ShouldDrawGlowColorWallHack ())
2880+ {
2881+ WSurfProgramState |= WSURF_GLOW_COLOR_ENABLED;
2882+ }
2883+ else if (R_ShouldDrawGlowColorWallHackBehindWallOnly ())
2884+ {
2885+ WSurfProgramState |= WSURF_GLOW_COLOR_ENABLED | WSURF_DOUBLE_FACE_ENABLED;
2886+ }
2887+
28602888 if (R_IsRenderingMultiView ())
28612889 {
28622890 WSurfProgramState |= WSURF_MULTIVIEW_ENABLED;
@@ -2933,13 +2961,57 @@ void R_DrawWorldSurfaceLeafStatic(CWorldSurfaceModel* pModel, CWorldSurfaceLeaf*
29332961
29342962 R_DrawWorldSurfaceLeafBegin (pLeaf);
29352963
2936- if (r_draw_opaque )
2964+ if (R_ShouldDrawGlowColorWallHackBehindWallOnly () )
29372965 {
2938- GL_BeginStencilWrite (STENCIL_MASK_HAS_DECAL, STENCIL_MASK_ALL);
2966+ GL_BeginStencilCompareNotEqual (STENCIL_MASK_NO_GLOW_COLOR, STENCIL_MASK_NO_GLOW_COLOR);
2967+ }
2968+ else if (R_ShouldDrawGlowColorWallHack ())
2969+ {
2970+
2971+ }
2972+ else if (R_ShouldDrawGlowColor ())
2973+ {
2974+
29392975 }
29402976 else
29412977 {
2942- GL_BeginStencilWrite (STENCIL_MASK_HAS_DECAL, STENCIL_MASK_HAS_DECAL);
2978+ if (r_draw_opaque)
2979+ {
2980+ int iStencilRef = STENCIL_MASK_HAS_DECAL;
2981+ int iStencilMask = STENCIL_MASK_ALL;
2982+
2983+ if (WSurfProgramState & WSURF_STENCIL_NO_GLOW_BLUR_ENABLED)
2984+ iStencilRef |= STENCIL_MASK_NO_GLOW_BLUR;
2985+
2986+ if (WSurfProgramState & WSURF_STENCIL_NO_GLOW_COLOR_ENABLED)
2987+ iStencilRef |= STENCIL_MASK_NO_GLOW_COLOR;
2988+
2989+ GL_BeginStencilWrite (iStencilRef, iStencilMask);
2990+ }
2991+ else
2992+ {
2993+ int iStencilRef = STENCIL_MASK_HAS_DECAL;
2994+ int iStencilMask = STENCIL_MASK_HAS_DECAL;
2995+
2996+ if (WSurfProgramState & WSURF_STENCIL_NO_GLOW_BLUR_ENABLED)
2997+ {
2998+ iStencilRef |= STENCIL_MASK_NO_GLOW_BLUR;
2999+ iStencilMask |= STENCIL_MASK_NO_GLOW_BLUR;
3000+ }
3001+
3002+ if (WSurfProgramState & WSURF_STENCIL_NO_GLOW_COLOR_ENABLED)
3003+ {
3004+ iStencilRef |= STENCIL_MASK_NO_GLOW_COLOR;
3005+ iStencilMask |= STENCIL_MASK_NO_GLOW_COLOR;
3006+ }
3007+
3008+ GL_BeginStencilWrite (iStencilRef, iStencilMask);
3009+ }
3010+ }
3011+
3012+ if (WSurfProgramState & WSURF_DOUBLE_FACE_ENABLED)
3013+ {
3014+ glDisable (GL_CULL_FACE);
29433015 }
29443016
29453017 wsurf_program_t prog = { 0 };
@@ -2953,6 +3025,8 @@ void R_DrawWorldSurfaceLeafStatic(CWorldSurfaceModel* pModel, CWorldSurfaceLeaf*
29533025
29543026 GL_UseProgram (0 );
29553027
3028+ glEnable (GL_CULL_FACE);
3029+
29563030 R_DrawWorldSurfaceLeafEnd ();
29573031 }
29583032
@@ -3366,6 +3440,9 @@ void R_DrawWorldSurfaceModel(const std::shared_ptr<CWorldSurfaceModel>& pModel,
33663440{
33673441 GL_BeginDebugGroupFormat (" R_DrawWorldSurfaceModel - %s" , ent->model ? ent->model ->name : " <empty>" );
33683442
3443+ bool bOriginalDiffuseTexture = g_WorldSurfaceRenderer.bDiffuseTexture ;
3444+ bool bOriginalLightmapTexture = g_WorldSurfaceRenderer.bLightmapTexture ;
3445+
33693446 entity_ubo_t EntityUBO;
33703447 Matrix4x4_Transpose (EntityUBO.r_entityMatrix , r_entity_matrix);
33713448 memcpy (EntityUBO.r_color , r_entity_color, sizeof (vec4));
@@ -3380,6 +3457,8 @@ void R_DrawWorldSurfaceModel(const std::shared_ptr<CWorldSurfaceModel>& pModel,
33803457 EntityUBO.r_color [3 ] = 1 ;
33813458
33823459 EntityUBO.r_scale = max ((*currententity)->curstate .renderamt * 0 .05f , 0 .05f );
3460+
3461+ // TODO bind shellchrome?
33833462 }
33843463 else if (
33853464 R_ShouldDrawGlowColor () ||
@@ -3392,11 +3471,17 @@ void R_DrawWorldSurfaceModel(const std::shared_ptr<CWorldSurfaceModel>& pModel,
33923471 EntityUBO.r_color [3 ] = (*r_blend);
33933472
33943473 EntityUBO.r_scale = max ((*currententity)->curstate .renderamt * 0 .05f , 0 .05f );
3474+
3475+ g_WorldSurfaceRenderer.bDiffuseTexture = false ;
3476+ g_WorldSurfaceRenderer.bLightmapTexture = false ;
33953477 }
33963478 else if (R_ShouldDrawGlowStencilEnableDepthTest ())
33973479 {
33983480 // Same size as DrawGlowColor
33993481 EntityUBO.r_scale = max ((*currententity)->curstate .renderamt * 0 .05f , 0 .05f ) + 0 .05f ;
3482+
3483+ g_WorldSurfaceRenderer.bDiffuseTexture = false ;
3484+ g_WorldSurfaceRenderer.bLightmapTexture = false ;
34003485 }
34013486
34023487 GL_UploadSubDataToUBO (g_WorldSurfaceRenderer.hEntityUBO , 0 , sizeof (EntityUBO), &EntityUBO);
@@ -3541,6 +3626,25 @@ void R_DrawWorldSurfaceModel(const std::shared_ptr<CWorldSurfaceModel>& pModel,
35413626 R_DrawWorldSurfaceLeafAnim (pModel.get (), pLeaf.get ());
35423627 }
35433628 }
3629+
3630+ if (!R_IsRenderingGlowColor () && !R_IsRenderingGlowStencil () && !R_IsRenderingGlowStencilEnableDepthTest ())
3631+ {
3632+ if ((*currententity)->curstate .renderfx == kRenderFxPostProcessGlow )
3633+ {
3634+ g_PostProcessGlowColorEntities.emplace_back ((*currententity));
3635+ }
3636+ else if ((*currententity)->curstate .renderfx == kRenderFxPostProcessGlowWallHack )
3637+ {
3638+ g_PostProcessGlowStencilEntities.emplace_back ((*currententity));
3639+ g_PostProcessGlowColorEntities.emplace_back ((*currententity));
3640+ }
3641+ else if ((*currententity)->curstate .renderfx == kRenderFxPostProcessGlowWallHackBehindWallOnly )
3642+ {
3643+ g_PostProcessGlowStencilEntities.emplace_back ((*currententity));
3644+ g_PostProcessGlowEnableDepthTestStencilEntities.emplace_back ((*currententity));
3645+ g_PostProcessGlowColorEntities.emplace_back ((*currententity));
3646+ }
3647+ }
35443648 }
35453649
35463650 R_DrawDecals (ent);
@@ -3556,6 +3660,9 @@ void R_DrawWorldSurfaceModel(const std::shared_ptr<CWorldSurfaceModel>& pModel,
35563660 }
35573661 }
35583662
3663+ g_WorldSurfaceRenderer.bDiffuseTexture = bOriginalDiffuseTexture;
3664+ g_WorldSurfaceRenderer.bLightmapTexture = bOriginalLightmapTexture;
3665+
35593666 if (pLeaf)
35603667 {
35613668 R_DrawWaters (pModel.get (), pLeaf.get (), ent);
0 commit comments