From a88e0e48a46d64181a5891114d0ebb19e1424a9f Mon Sep 17 00:00:00 2001 From: divverent Date: Sat, 10 Mar 2012 12:39:29 +0000 Subject: [PATCH] allow MATERIALFLAG_CAMERA to fade out git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11752 d7cf8633-e32d-0410-b094-e92efae38249 --- dpsoftrast.h | 2 +- gl_rmain.c | 6 +++--- shader_glsl.h | 4 ++++ shader_hlsl.h | 4 ++++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/dpsoftrast.h b/dpsoftrast.h index 69228ef8..eb3df2ba 100644 --- a/dpsoftrast.h +++ b/dpsoftrast.h @@ -188,7 +188,7 @@ typedef enum shaderpermutation_e SHADERPERMUTATION_SHADOWMAPVSDCT = 1<<19, ///< (lightsource) use virtual shadow depth cube texture for shadowmap indexing SHADERPERMUTATION_SHADOWMAPORTHO = 1<<20, ///< (lightsource) use orthographic shadowmap projection SHADERPERMUTATION_DEFERREDLIGHTMAP = 1<<21, ///< (lightmap) read Texture_ScreenDiffuse/Specular textures and add them on top of lightmapping - SHADERPERMUTATION_ALPHAKILL = 1<<22, ///< (deferredgeometry) discard pixel if diffuse texture alpha below 0.5 + SHADERPERMUTATION_ALPHAKILL = 1<<22, ///< (deferredgeometry) discard pixel if diffuse texture alpha below 0.5, (generic) apply global alpha SHADERPERMUTATION_REFLECTCUBE = 1<<23, ///< fake reflections using global cubemap (not HDRI light probe) SHADERPERMUTATION_NORMALMAPSCROLLBLEND = 1<<24, ///< (water) counter-direction normalmaps scrolling SHADERPERMUTATION_BOUNCEGRID = 1<<25, ///< (lightmap) use Texture_BounceGrid as an additional source of ambient light diff --git a/gl_rmain.c b/gl_rmain.c index 3c5177ae..256b5e44 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -2182,9 +2182,9 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting, else { mode = SHADERMODE_GENERIC; - permutation |= SHADERPERMUTATION_DIFFUSE; - GL_BlendFunc(GL_ONE, GL_ZERO); - blendfuncflags = R_BlendFuncFlags(GL_ONE, GL_ZERO); + permutation |= SHADERPERMUTATION_DIFFUSE | SHADERPERMUTATION_ALPHAKILL; + GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + blendfuncflags = R_BlendFuncFlags(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } if (vid.allowalphatocoverage) GL_AlphaToCoverage(false); diff --git a/shader_glsl.h b/shader_glsl.h index 722fc3d6..1833bdf3 100644 --- a/shader_glsl.h +++ b/shader_glsl.h @@ -326,6 +326,7 @@ "#ifdef USESPECULAR\n" "dp_varying mediump vec2 TexCoord2;\n" "#endif\n" +"uniform myhalf Alpha;\n" "#ifdef VERTEX_SHADER\n" "void main(void)\n" "{\n" @@ -387,6 +388,9 @@ " dp_FragColor.g = dp_texture2D(Texture_GammaRamps, vec2(dp_FragColor.g, 0)).g;\n" " dp_FragColor.b = dp_texture2D(Texture_GammaRamps, vec2(dp_FragColor.b, 0)).b;\n" "#endif\n" +"#ifdef USEALPHAKILL\n" +" dp_FragColor.a *= Alpha;\n" +"#endif\n" "}\n" "#endif\n" "#else // !MODE_GENERIC\n" diff --git a/shader_hlsl.h b/shader_hlsl.h index 8e9ee064..20770d18 100644 --- a/shader_hlsl.h +++ b/shader_hlsl.h @@ -298,6 +298,7 @@ "#ifdef USEGAMMARAMPS\n" "uniform sampler Texture_GammaRamps : register(s2),\n" "#endif\n" +"uniform half Alpha : register(c0),\n" "out float4 dp_FragColor : COLOR\n" ")\n" "{\n" @@ -332,6 +333,9 @@ " dp_FragColor.g = tex2D(Texture_GammaRamps, vec2(dp_FragColor.g, 0)).g;\n" " dp_FragColor.b = tex2D(Texture_GammaRamps, vec2(dp_FragColor.b, 0)).b;\n" "#endif\n" +"#ifdef USEALPHAKILL\n" +" dp_FragColor.a *= Alpha;\n" +"#endif\n" "}\n" "#endif\n" "#else // !MODE_GENERIC\n" -- 2.39.2