]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
support alphaGen vertex
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 13 Dec 2011 20:44:37 +0000 (20:44 +0000)
committerRudolf Polzer <divverent@xonotic.org>
Tue, 13 Dec 2011 21:03:55 +0000 (22:03 +0100)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11615 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=ac06747ee6947f193afc671a8457869ea85dcf40

dpsoftrast.h
gl_rmain.c
model_brush.h
model_shared.c
shader_glsl.h
shader_hlsl.h

index c30f69a6b4fbf63e4e06e44c1314d7b85f31601e..69228ef86cdad0318ebdc5ce3987a46ecc66d7f5 100644 (file)
@@ -195,7 +195,8 @@ typedef enum shaderpermutation_e
        SHADERPERMUTATION_BOUNCEGRIDDIRECTIONAL = 1<<26, ///< (lightmap) use 16-component pixels in bouncegrid texture for directional lighting rather than standard 4-component
        SHADERPERMUTATION_TRIPPY = 1<<27, ///< use trippy vertex shader effect
        SHADERPERMUTATION_DEPTHRGB = 1<<28, ///< read/write depth values in RGB color coded format for older hardware without depth samplers
-       SHADERPERMUTATION_COUNT = 29 ///< size of shaderpermutationinfo array
+       SHADERPERMUTATION_ALPHAGEN_VERTEX = 1<<29, ///< alphaGen vertex
+       SHADERPERMUTATION_COUNT = 30 ///< size of shaderpermutationinfo array
 }
 shaderpermutation_t;
 
index 3f1123fb82fb1c487b37d35d05657bdb74f83032..4b0ca40ce213bc50a1317bd5d0e1034845556254 100644 (file)
@@ -655,6 +655,7 @@ shaderpermutationinfo_t shaderpermutationinfo[SHADERPERMUTATION_COUNT] =
        {"#define USEBOUNCEGRIDDIRECTIONAL\n", " bouncegriddirectional"}, // TODO make this a static parm
        {"#define USETRIPPY\n", " trippy"},
        {"#define USEDEPTHRGB\n", " depthrgb"},
+       {"#define USEALPHAGENVERTEX\n", "alphagenvertex"}
 };
 
 // NOTE: MUST MATCH ORDER OF SHADERMODE_* ENUMS!
@@ -2209,6 +2210,8 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting,
                }
                if (rsurface.texture->currentmaterialflags & MATERIALFLAG_VERTEXTEXTUREBLEND)
                        permutation |= SHADERPERMUTATION_VERTEXTEXTUREBLEND;
+               if (rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHAGEN_VERTEX)
+                       permutation |= SHADERPERMUTATION_ALPHAGEN_VERTEX;
                // light source
                mode = SHADERMODE_LIGHTSOURCE;
                if (rsurface.rtlight->currentcubemap != r_texture_whitecube)
@@ -2251,6 +2254,8 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting,
                }
                if (rsurface.texture->currentmaterialflags & MATERIALFLAG_VERTEXTEXTUREBLEND)
                        permutation |= SHADERPERMUTATION_VERTEXTEXTUREBLEND;
+               if (rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHAGEN_VERTEX)
+                       permutation |= SHADERPERMUTATION_ALPHAGEN_VERTEX;
                // unshaded geometry (fullbright or ambient model lighting)
                mode = SHADERMODE_FLATCOLOR;
                ambientscale = diffusescale = specularscale = 0;
@@ -2300,6 +2305,8 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting,
                }
                if (rsurface.texture->currentmaterialflags & MATERIALFLAG_VERTEXTEXTUREBLEND)
                        permutation |= SHADERPERMUTATION_VERTEXTEXTUREBLEND;
+               if (rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHAGEN_VERTEX)
+                       permutation |= SHADERPERMUTATION_ALPHAGEN_VERTEX;
                // directional model lighting
                mode = SHADERMODE_LIGHTDIRECTION;
                if (rsurface.texture->glowtexture && r_hdr_glowintensity.value > 0 && !gl_lightmaps.integer)
@@ -2359,6 +2366,8 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting,
                }
                if (rsurface.texture->currentmaterialflags & MATERIALFLAG_VERTEXTEXTUREBLEND)
                        permutation |= SHADERPERMUTATION_VERTEXTEXTUREBLEND;
+               if (rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHAGEN_VERTEX)
+                       permutation |= SHADERPERMUTATION_ALPHAGEN_VERTEX;
                // ambient model lighting
                mode = SHADERMODE_LIGHTDIRECTION;
                if (rsurface.texture->glowtexture && r_hdr_glowintensity.value > 0 && !gl_lightmaps.integer)
@@ -2415,6 +2424,8 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting,
                }
                if (rsurface.texture->currentmaterialflags & MATERIALFLAG_VERTEXTEXTUREBLEND)
                        permutation |= SHADERPERMUTATION_VERTEXTEXTUREBLEND;
+               if (rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHAGEN_VERTEX)
+                       permutation |= SHADERPERMUTATION_ALPHAGEN_VERTEX;
                // lightmapped wall
                if (rsurface.texture->glowtexture && r_hdr_glowintensity.value > 0 && !gl_lightmaps.integer)
                        permutation |= SHADERPERMUTATION_GLOW;
index f1b60e0e7dc15b79a80eb01f1a99e4259316345b..8020d14ab7990154ef71dc402feebdfc01c616fc 100644 (file)
@@ -118,6 +118,8 @@ mplane_t;
 #define MATERIALFLAG_CAMERA 67108864
 // disable rtlight on surface, use R_LightPoint instead
 #define MATERIALFLAG_NORTLIGHT 134217728
+// alphagen vertex
+#define MATERIALFLAG_ALPHAGEN_VERTEX 268435456
 // combined mask of all attributes that require depth sorted rendering
 #define MATERIALFLAGMASK_DEPTHSORTED (MATERIALFLAG_BLENDED | MATERIALFLAG_NODEPTHTEST)
 // combined mask of all attributes that cause some sort of transparency
index 92cf45a5bf30d49f81e4b2c41acb10ddbee65ce9..546321142dfae605d7e6a5bec3dd746cee9e9ea7 100644 (file)
@@ -2572,6 +2572,8 @@ nothing                GL_ZERO GL_ONE
                        texture->basematerialflags |= MATERIALFLAG_NOSHADOW;
                if (shader->dpnortlight)
                        texture->basematerialflags |= MATERIALFLAG_NORTLIGHT;
+               if (shader->vertexalpha)
+                       texture->basematerialflags |= MATERIALFLAG_ALPHAGEN_VERTEX;
                memcpy(texture->deforms, shader->deforms, sizeof(texture->deforms));
                texture->reflectmin = shader->reflectmin;
                texture->reflectmax = shader->reflectmax;
index 8c13a2a6e5e599e68b331a9867b250305f7dfab3..aa962c850ac8eff6930cdedb3537e915aab59bf4 100644 (file)
 "#endif\n"
 "void main(void)\n"
 "{\n"
-"#if defined(MODE_VERTEXCOLOR) || defined(USEVERTEXTEXTUREBLEND) || defined(MODE_LIGHTDIRECTIONMAP_FORCED_VERTEXCOLOR)\n"
+"#if defined(MODE_VERTEXCOLOR) || defined(USEVERTEXTEXTUREBLEND) || defined(MODE_LIGHTDIRECTIONMAP_FORCED_VERTEXCOLOR) || defined(USEALPHAGENVERTEX)\n"
 "      VertexColor = Attrib_Color;\n"
 "#endif\n"
 "      // copy the surface texcoord\n"
 "      color.a = 1.0;\n"
 "      //color = mix(cast_myhalf4(1, 0, 0, 1), color, terrainblend);\n"
 "#endif\n"
+"#ifdef USEALPHAGENVERTEX\n"
+"      color.a *= VertexColor.a;\n"
+"#endif\n"
 "\n"
 "      // get the surface normal\n"
 "#ifdef USEVERTEXTEXTUREBLEND\n"
index f20f8329e7ad7d45a651175e789ad3fb857b84e3..78f291c619449265a5aed050caafe5f586188f05 100644 (file)
 "#ifdef USESHADOWMAPORTHO\n"
 "uniform float4x4 ShadowMapMatrix : register(c16),\n"
 "#endif\n"
-"#if defined(MODE_VERTEXCOLOR) || defined(USEVERTEXTEXTUREBLEND)\n"
+"#if defined(MODE_VERTEXCOLOR) || defined(USEVERTEXTEXTUREBLEND) || defined(MODE_LIGHTDIRECTIONMAP_FORCED_VERTEXCOLOR) || defined(USEALPHAGENVERTEX)\n"
 "out float4 gl_FrontColor : COLOR,\n"
 "#endif\n"
 "out float4 TexCoordBoth : TEXCOORD0,\n"
 "out float4 gl_Position : POSITION\n"
 ")\n"
 "{\n"
-"#if defined(MODE_VERTEXCOLOR) || defined(USEVERTEXTEXTUREBLEND)\n"
+"#if defined(MODE_VERTEXCOLOR) || defined(USEVERTEXTEXTUREBLEND) || defined(MODE_LIGHTDIRECTIONMAP_FORCED_VERTEXCOLOR) || defined(USEALPHAGENVERTEX)\n"
 "      gl_FrontColor = gl_Color;\n"
 "#endif\n"
 "      // copy the surface texcoord\n"
 "      //color = half4(lerp(float4(1, 0, 0, 1), color, terrainblend));\n"
 "#endif\n"
 "#endif\n"
+"#ifdef USEALPHAGENVERTEX\n"
+"      color.a *= gl_FrontColor.a;\n"
+"#endif\n"
 "\n"
 "      // get the surface normal\n"
 "#ifdef USEVERTEXTEXTUREBLEND\n"