From d64b00435e6ef5133af4e249db19ffaafa988bb9 Mon Sep 17 00:00:00 2001 From: havoc Date: Tue, 29 Mar 2011 23:15:08 +0000 Subject: [PATCH] r_shadow_deferred now checks for r_shadow_gloss 0 and does not use the second color attachment if so, giving a modest speed boost for testing but deferred is still way too slow for practical use even with this... git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10983 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rmain.c | 2 +- r_shadow.c | 5 ++++- shader_glsl.h | 22 +++++++++++++--------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/gl_rmain.c b/gl_rmain.c index 1a775d39..d5e82c56 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -2888,7 +2888,7 @@ void R_SetupShader_DeferredLight(const rtlight_t *rtlight) permutation |= SHADERPERMUTATION_CUBEFILTER; if (diffusescale > 0) permutation |= SHADERPERMUTATION_DIFFUSE; - if (specularscale > 0) + if (specularscale > 0 && r_shadow_gloss.integer > 0) permutation |= SHADERPERMUTATION_SPECULAR | SHADERPERMUTATION_DIFFUSE; if (r_shadow_usingshadowmap2d) { diff --git a/r_shadow.c b/r_shadow.c index a1dc9969..0afa3b3c 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -2287,7 +2287,10 @@ void R_Shadow_RenderMode_DrawDeferredLight(qboolean stenciltest, qboolean shadow // only draw light where this geometry was already rendered AND the // stencil is 128 (values other than this mean shadow) R_SetStencil(stenciltest, 255, GL_KEEP, GL_KEEP, GL_KEEP, GL_EQUAL, 128, 255); - R_Mesh_SetRenderTargets(r_shadow_prepasslightingdiffusespecularfbo, r_shadow_prepassgeometrydepthtexture, r_shadow_prepasslightingdiffusetexture, r_shadow_prepasslightingspeculartexture, NULL, NULL); + if (rsurface.rtlight->specularscale > 0 && r_shadow_gloss.integer > 0) + R_Mesh_SetRenderTargets(r_shadow_prepasslightingdiffusespecularfbo, r_shadow_prepassgeometrydepthtexture, r_shadow_prepasslightingdiffusetexture, r_shadow_prepasslightingspeculartexture, NULL, NULL); + else + R_Mesh_SetRenderTargets(r_shadow_prepasslightingdiffusefbo, r_shadow_prepassgeometrydepthtexture, r_shadow_prepasslightingdiffusetexture, NULL, NULL, NULL); r_shadow_usingshadowmap2d = shadowmapping; diff --git a/shader_glsl.h b/shader_glsl.h index fd94cbcc..65a70d9e 100644 --- a/shader_glsl.h +++ b/shader_glsl.h @@ -917,22 +917,26 @@ " fade *= ShadowMapCompare(CubeVector);\n" "#endif\n" "\n" -"#ifdef USEDIFFUSE\n" -" gl_FragData[0] = vec4((DeferredColor_Ambient + DeferredColor_Diffuse * diffuse) * fade, 1.0);\n" -"#else\n" -" gl_FragData[0] = vec4(DeferredColor_Ambient * fade, 1.0);\n" -"#endif\n" "#ifdef USESPECULAR\n" +" gl_FragData[0] = vec4((DeferredColor_Ambient + DeferredColor_Diffuse * diffuse) * fade, 1.0);\n" " gl_FragData[1] = vec4(DeferredColor_Specular * (specular * fade), 1.0);\n" -"#else\n" -" gl_FragData[1] = vec4(0.0, 0.0, 0.0, 1.0);\n" -"#endif\n" -"\n" "# ifdef USECUBEFILTER\n" " vec3 cubecolor = dp_textureCube(Texture_Cube, CubeVector).rgb;\n" " gl_FragData[0].rgb *= cubecolor;\n" " gl_FragData[1].rgb *= cubecolor;\n" "# endif\n" +"#else\n" +"# ifdef USEDIFFUSE\n" +" gl_FragColor = vec4((DeferredColor_Ambient + DeferredColor_Diffuse * diffuse) * fade, 1.0);\n" +"# else\n" +" gl_FragColor = vec4(DeferredColor_Ambient * fade, 1.0);\n" +"# endif\n" +"# ifdef USECUBEFILTER\n" +" vec3 cubecolor = dp_textureCube(Texture_Cube, CubeVector).rgb;\n" +" gl_FragColor.rgb *= cubecolor;\n" +"# endif\n" +"#endif\n" +" \n" "}\n" "#endif // FRAGMENT_SHADER\n" "#else // !MODE_DEFERREDLIGHTSOURCE\n" -- 2.39.2