]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
r_glsl_deluxemapping 2 support for vertexlit surfaces, deluxemap forced surfaces...
authorvortex <vortex@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 31 Jul 2011 21:54:13 +0000 (21:54 +0000)
committerRudolf Polzer <divverent@xonotic.org>
Sun, 14 Aug 2011 14:37:32 +0000 (16:37 +0200)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11262 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=a14d8ac6ca1ca641b68a666983531298ee036576

dpsoftrast.h
gl_rmain.c
model_shared.c
model_shared.h
r_shadow.c
shader_glsl.h
shader_hlsl.h
snd_main.c
vid_shared.c

index 3f267a2e669d191e69a69ae12b5f4ed3c2d1e05b..1d2f4d7c3b60c523b64d027cedb49e098c9e6288 100644 (file)
@@ -151,6 +151,8 @@ typedef enum shadermode_e
        SHADERMODE_FAKELIGHT, ///< (fakelight) modulate texture by "fake" lighting (no lightmaps, no nothing)
        SHADERMODE_LIGHTDIRECTIONMAP_MODELSPACE, ///< (lightmap) use directional pixel shading from texture containing modelspace light directions (q3bsp deluxemap)
        SHADERMODE_LIGHTDIRECTIONMAP_TANGENTSPACE, ///< (lightmap) use directional pixel shading from texture containing tangentspace light directions (q1bsp deluxemap)
+       SHADERMODE_LIGHTDIRECTIONMAP_FORCED_LIGHTMAP, // forced deluxemapping for lightmapped surfaces
+       SHADERMODE_LIGHTDIRECTIONMAP_FORCED_VERTEXCOLOR, // forced deluxemapping for vertexlit surfaces
        SHADERMODE_LIGHTDIRECTION, ///< (lightmap) use directional pixel shading from fixed light direction (q3bsp)
        SHADERMODE_LIGHTSOURCE, ///< (lightsource) use directional pixel shading from light source (rtlight)
        SHADERMODE_REFRACTION, ///< refract background (the material is rendered normally after this pass)
index b5faeb344e6cddfbffba8d1e0d484d05af13c6fa..383be057ae417f403760ac50762617ac41f91748 100644 (file)
@@ -220,6 +220,7 @@ cvar_t r_glsl_vertextextureblend_usebothalphas = {CVAR_SAVE, "r_glsl_vertextextu
 cvar_t r_framedatasize = {CVAR_SAVE, "r_framedatasize", "0.5", "size of renderer data cache used during one frame (for skeletal animation caching, light processing, etc)"};
 
 extern cvar_t v_glslgamma;
+extern cvar_t v_glslgamma_2d;
 
 extern qboolean v_flipped_state;
 
@@ -690,6 +691,8 @@ shadermodeinfo_t glslshadermodeinfo[SHADERMODE_COUNT] =
        {"glsl/default.glsl", NULL, "glsl/default.glsl", "#define MODE_FAKELIGHT\n", " fakelight"},
        {"glsl/default.glsl", NULL, "glsl/default.glsl", "#define MODE_LIGHTDIRECTIONMAP_MODELSPACE\n", " lightdirectionmap_modelspace"},
        {"glsl/default.glsl", NULL, "glsl/default.glsl", "#define MODE_LIGHTDIRECTIONMAP_TANGENTSPACE\n", " lightdirectionmap_tangentspace"},
+       {"glsl/default.glsl", NULL, "glsl/default.glsl", "#define MODE_LIGHTDIRECTIONMAP_FORCED_LIGHTMAP\n", " lightdirectionmap_forced_lightmap"},
+       {"glsl/default.glsl", NULL, "glsl/default.glsl", "#define MODE_LIGHTDIRECTIONMAP_FORCED_VERTEXCOLOR\n", " lightdirectionmap_forced_vertexcolor"},
        {"glsl/default.glsl", NULL, "glsl/default.glsl", "#define MODE_LIGHTDIRECTION\n", " lightdirection"},
        {"glsl/default.glsl", NULL, "glsl/default.glsl", "#define MODE_LIGHTSOURCE\n", " lightsource"},
        {"glsl/default.glsl", NULL, "glsl/default.glsl", "#define MODE_REFRACTION\n", " refraction"},
@@ -710,6 +713,8 @@ shadermodeinfo_t hlslshadermodeinfo[SHADERMODE_COUNT] =
        {"hlsl/default.hlsl", NULL, "hlsl/default.hlsl", "#define MODE_FAKELIGHT\n", " fakelight"},
        {"hlsl/default.hlsl", NULL, "hlsl/default.hlsl", "#define MODE_LIGHTDIRECTIONMAP_MODELSPACE\n", " lightdirectionmap_modelspace"},
        {"hlsl/default.hlsl", NULL, "hlsl/default.hlsl", "#define MODE_LIGHTDIRECTIONMAP_TANGENTSPACE\n", " lightdirectionmap_tangentspace"},
+       {"glsl/default.glsl", NULL, "glsl/default.glsl", "#define MODE_LIGHTDIRECTIONMAP_FORCED_LIGHTMAP\n", " lightdirectionmap_forced_lightmap"},
+       {"glsl/default.glsl", NULL, "glsl/default.glsl", "#define MODE_LIGHTDIRECTIONMAP_FORCED_VERTEXCOLOR\n", " lightdirectionmap_forced_vertexcolor"},
        {"hlsl/default.hlsl", NULL, "hlsl/default.hlsl", "#define MODE_LIGHTDIRECTION\n", " lightdirection"},
        {"hlsl/default.hlsl", NULL, "hlsl/default.hlsl", "#define MODE_LIGHTSOURCE\n", " lightsource"},
        {"hlsl/default.hlsl", NULL, "hlsl/default.hlsl", "#define MODE_REFRACTION\n", " refraction"},
@@ -1910,9 +1915,8 @@ void R_SetupShader_Generic(rtexture_t *first, rtexture_t *second, int texturemod
                permutation |= SHADERPERMUTATION_SPECULAR;
        if (texturemode == GL_MODULATE)
                permutation |= SHADERPERMUTATION_COLORMAPPING;
-// LordHavoc: VorteX broke the game by doing this, and did not cvar it properly, and did not add the proper checks (r_texture_sRGB_2d.integer would need to be checked), and it breaks with vid_sRGB where the gamma ramps are altered...
-//     if (usegamma && r_texture_gammaramps && v_glslgamma.integer && !vid_gammatables_trivial)
-//             permutation |= SHADERPERMUTATION_GAMMARAMPS;
+       if (usegamma && v_glslgamma.integer && v_glslgamma_2d.integer && !vid.sRGB2D && r_texture_gammaramps && !vid_gammatables_trivial)
+               permutation |= SHADERPERMUTATION_GAMMARAMPS;
        else if (texturemode == GL_ADD)
                permutation |= SHADERPERMUTATION_GLOW;
        else if (texturemode == GL_DECAL)
@@ -2465,10 +2469,13 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting,
                        if (specularscale > 0)
                                permutation |= SHADERPERMUTATION_SPECULAR | SHADERPERMUTATION_DIFFUSE;
                }
-               else if (r_glsl_deluxemapping.integer >= 2 && rsurface.uselightmaptexture)
+               else if (r_glsl_deluxemapping.integer >= 2)
                {
                        // fake deluxemapping (uniform light direction in tangentspace)
-                       mode = SHADERMODE_LIGHTDIRECTIONMAP_TANGENTSPACE;
+                       if (rsurface.uselightmaptexture)
+                               mode = SHADERMODE_LIGHTDIRECTIONMAP_FORCED_LIGHTMAP;
+                       else
+                               mode = SHADERMODE_LIGHTDIRECTIONMAP_FORCED_VERTEXCOLOR;
                        permutation |= SHADERPERMUTATION_DIFFUSE;
                        if (specularscale > 0)
                                permutation |= SHADERPERMUTATION_SPECULAR | SHADERPERMUTATION_DIFFUSE;
index d4021ee0bf46731690676e6f984dde0b60c26fe3..0fc772824c4a23e4da119883ab14376c9a31c09c 100644 (file)
@@ -2155,6 +2155,10 @@ void Mod_LoadQ3Shaders(void)
                                {
                                        shader.specularpowermod = atof(parameter[1]);
                                }
+                               else if (!strcasecmp(parameter[0], "dprtlightambient") && numparameters >= 2)
+                               {
+                                       shader.rtlightambient = atof(parameter[1]);
+                               }
                                else if (!strcasecmp(parameter[0], "dpoffsetmapping") && numparameters >= 3)
                                {
                                        if (!strcasecmp(parameter[1], "disable") || !strcasecmp(parameter[1], "none") || !strcasecmp(parameter[1], "off"))
@@ -2437,6 +2441,7 @@ nothing                GL_ZERO GL_ONE
                texture->offsetscale = shader->offsetscale;
                texture->specularscalemod = shader->specularscalemod;
                texture->specularpowermod = shader->specularpowermod;
+               texture->rtlightambient = shader->rtlightambient;
                if (shader->dpreflectcube[0])
                        texture->reflectcubetexture = R_GetCubemap(shader->dpreflectcube);
 
index c34890cad8af0c43ee088e057f387b2a303817a0..8b73377e53f1c6ce1fae104337d6bf13858e6b99 100644 (file)
@@ -475,6 +475,9 @@ typedef struct q3shaderinfo_s
        // gloss
        float specularscalemod;
        float specularpowermod;
+
+       // rtlightning ambient addition
+       float rtlightambient;
 #define Q3SHADERINFO_COMPARE_END specularpowermod
 }
 q3shaderinfo_t;
@@ -613,6 +616,9 @@ typedef struct texture_s
        // gloss
        float specularscalemod;
        float specularpowermod;
+
+       // diffuse and ambient
+       float rtlightambient;
 }
  texture_t;
 
index 5e7c5eb7be08914efc8b2d387a5066f396216cd3..0e2ba506c90d77b76fd553bb970efcdecafff32c 100644 (file)
@@ -3321,8 +3321,8 @@ void R_Shadow_RenderLighting(int texturenumsurfaces, const msurface_t **textures
        qboolean negated;
        float lightcolor[3];
        VectorCopy(rsurface.rtlight->currentcolor, lightcolor);
-       ambientscale = rsurface.rtlight->ambientscale;
-       diffusescale = rsurface.rtlight->diffusescale;
+       ambientscale = rsurface.rtlight->ambientscale + rsurface.texture->rtlightambient;
+       diffusescale = rsurface.rtlight->diffusescale * max(0, 1.0 - rsurface.texture->rtlightambient);
        specularscale = rsurface.rtlight->specularscale * rsurface.texture->specularscale;
        if (!r_shadow_usenormalmap.integer)
        {
index 570b6748e4dabbc8cfb48ddedc94aeea69d500de..dda544bec3c47760e1878f99e7b0d6cd959b3d46 100644 (file)
@@ -57,7 +57,7 @@
 "#if defined(USEFOGINSIDE) || defined(USEFOGOUTSIDE) || defined(USEFOGHEIGHTTEXTURE)\n"
 "# define USEFOG\n"
 "#endif\n"
-"#if defined(MODE_LIGHTMAP) || defined(MODE_LIGHTDIRECTIONMAP_MODELSPACE) || defined(MODE_LIGHTDIRECTIONMAP_TANGENTSPACE)\n"
+"#if defined(MODE_LIGHTMAP) || defined(MODE_LIGHTDIRECTIONMAP_MODELSPACE) || defined(MODE_LIGHTDIRECTIONMAP_TANGENTSPACE) || defined(MODE_LIGHTDIRECTIONMAP_FORCED_LIGHTMAP)\n"
 "# define USELIGHTMAP\n"
 "#endif\n"
 "#if defined(USESPECULAR) || defined(USEOFFSETMAPPING) || defined(USEREFLECTCUBE) || defined(MODE_FAKELIGHT) || defined(USEFOG)\n"
 "#endif\n"
 "void main(void)\n"
 "{\n"
-"#if defined(MODE_VERTEXCOLOR) || defined(USEVERTEXTEXTUREBLEND)\n"
+"#if defined(MODE_VERTEXCOLOR) || defined(USEVERTEXTEXTUREBLEND) || defined(MODE_LIGHTDIRECTIONMAP_FORCED_VERTEXCOLOR)\n"
 "      VertexColor = Attrib_Color;\n"
 "#endif\n"
 "      // copy the surface texcoord\n"
 "\n"
 "\n"
 "#ifdef MODE_LIGHTDIRECTION\n"
-"#define SHADING\n"
-"#ifdef USEDIFFUSE\n"
-"      myhalf3 lightnormal = myhalf3(normalize(LightVector));\n"
-"#endif\n"
-"#define lightcolor LightColor\n"
+"      #define SHADING\n"
+"      #ifdef USEDIFFUSE\n"
+"              myhalf3 lightnormal = myhalf3(normalize(LightVector));\n"
+"      #endif\n"
+"      #define lightcolor LightColor\n"
 "#endif // MODE_LIGHTDIRECTION\n"
 "#ifdef MODE_LIGHTDIRECTIONMAP_MODELSPACE\n"
-"#define SHADING\n"
+"   #define SHADING\n"
 "      // deluxemap lightmapping using light vectors in modelspace (q3map2 -light -deluxe)\n"
 "      myhalf3 lightnormal_modelspace = myhalf3(dp_texture2D(Texture_Deluxemap, TexCoordSurfaceLightmap.zw)) * 2.0 + myhalf3(-1.0, -1.0, -1.0);\n"
 "      myhalf3 lightcolor = myhalf3(dp_texture2D(Texture_Lightmap, TexCoordSurfaceLightmap.zw));\n"
 "      lightcolor *= 1.0 / max(0.25, lightnormal.z);\n"
 "#endif // MODE_LIGHTDIRECTIONMAP_MODELSPACE\n"
 "#ifdef MODE_LIGHTDIRECTIONMAP_TANGENTSPACE\n"
-"#define SHADING\n"
+"   #define SHADING\n"
 "      // deluxemap lightmapping using light vectors in tangentspace (hmap2 -light)\n"
 "      myhalf3 lightnormal = myhalf3(dp_texture2D(Texture_Deluxemap, TexCoordSurfaceLightmap.zw)) * 2.0 + myhalf3(-1.0, -1.0, -1.0);\n"
 "      myhalf3 lightcolor = myhalf3(dp_texture2D(Texture_Lightmap, TexCoordSurfaceLightmap.zw));\n"
 "#endif\n"
-"\n"
-"\n"
-"\n"
-"\n"
+"#if defined(MODE_LIGHTDIRECTIONMAP_FORCED_LIGHTMAP) || defined(MODE_LIGHTDIRECTIONMAP_FORCED_VERTEXCOLOR)\n"
+"      #define SHADING\n"
+"      // forced deluxemap on lightmapped/vertexlit surfaces\n"
+"      myhalf3 lightnormal = myhalf3(0.0, 0.0, 1.0);\n"
+"   #ifdef USELIGHTMAP\n"
+"              myhalf3 lightcolor = myhalf3(dp_texture2D(Texture_Lightmap, TexCoordSurfaceLightmap.zw));\n"
+"   #else\n"
+"              myhalf3 lightcolor = myhalf3(VertexColor.rgb);\n"
+"   #endif\n"
+"#endif\n"
 "#ifdef MODE_FAKELIGHT\n"
-"#define SHADING\n"
-"myhalf3 lightnormal = myhalf3(normalize(EyeVectorFogDepth.xyz));\n"
-"myhalf3 lightcolor = myhalf3(1.0);\n"
+"      #define SHADING\n"
+"      myhalf3 lightnormal = myhalf3(normalize(EyeVectorFogDepth.xyz));\n"
+"      myhalf3 lightcolor = myhalf3(1.0);\n"
 "#endif // MODE_FAKELIGHT\n"
 "\n"
 "\n"
index 322611755fe0a87d20109a5e957f38a6c4eab097..1296711385ed4c8770000b70bfa2f8e9475d46e9 100644 (file)
@@ -10,7 +10,7 @@
 "#if defined(USEFOGINSIDE) || defined(USEFOGOUTSIDE) || defined(USEFOGHEIGHTTEXTURE)\n"
 "# define USEFOG\n"
 "#endif\n"
-"#if defined(MODE_LIGHTMAP) || defined(MODE_LIGHTDIRECTIONMAP_MODELSPACE) || defined(MODE_LIGHTDIRECTIONMAP_TANGENTSPACE)\n"
+"#if defined(MODE_LIGHTMAP) || defined(MODE_LIGHTDIRECTIONMAP_MODELSPACE) || defined(MODE_LIGHTDIRECTIONMAP_TANGENTSPACE) || defined(MODE_LIGHTDIRECTIONMAP_FORCED_LIGHTMAP)\n"
 "#define USELIGHTMAP\n"
 "#endif\n"
 "#if defined(USESPECULAR) || defined(USEOFFSETMAPPING) || defined(USEREFLECTCUBE) || defined(MODE_FAKELIGHT)\n"
 "(\n"
 "float4 gl_Vertex : POSITION,\n"
 "uniform float4x4 ModelViewProjectionMatrix : register(c8),\n"
-"#if defined(USEVERTEXTEXTUREBLEND) || defined(MODE_VERTEXCOLOR)\n"
+"#if defined(USEVERTEXTEXTUREBLEND) || defined(MODE_VERTEXCOLOR) || defined(MODE_LIGHTDIRECTIONMAP_FORCED_VERTEXCOLOR)\n"
 "float4 gl_Color : COLOR0,\n"
 "#endif\n"
 "float4 gl_MultiTexCoord0 : TEXCOORD0,\n"
 "\n"
 "\n"
 "#ifdef MODE_LIGHTDIRECTION\n"
-"#define SHADING\n"
-"#ifdef USEDIFFUSE\n"
-"      half3 lightnormal = half3(normalize(LightVector));\n"
-"#endif\n"
-"#define lightcolor LightColor\n"
+"      #define SHADING\n"
+"      #ifdef USEDIFFUSE\n"
+"              half3 lightnormal = half3(normalize(LightVector));\n"
+"      #endif\n"
+"      #define lightcolor LightColor\n"
 "#endif // MODE_LIGHTDIRECTION\n"
 "#ifdef MODE_LIGHTDIRECTIONMAP_MODELSPACE\n"
-"#define SHADING\n"
+"      #define SHADING\n"
 "      // deluxemap lightmapping using light vectors in modelspace (q3map2 -light -deluxe)\n"
 "      half3 lightnormal_modelspace = half3(tex2D(Texture_Deluxemap, TexCoordLightmap).rgb) * 2.0 + half3(-1.0, -1.0, -1.0);\n"
 "      half3 lightcolor = half3(tex2D(Texture_Lightmap, TexCoordLightmap).rgb);\n"
 "      lightcolor *= 1.0 / max(0.25, lightnormal.z);\n"
 "#endif // MODE_LIGHTDIRECTIONMAP_MODELSPACE\n"
 "#ifdef MODE_LIGHTDIRECTIONMAP_TANGENTSPACE\n"
-"#define SHADING\n"
+"      #define SHADING\n"
 "      // deluxemap lightmapping using light vectors in tangentspace (hmap2 -light)\n"
 "      half3 lightnormal = half3(tex2D(Texture_Deluxemap, TexCoordLightmap).rgb) * 2.0 + half3(-1.0, -1.0, -1.0);\n"
 "      half3 lightcolor = half3(tex2D(Texture_Lightmap, TexCoordLightmap).rgb);\n"
 "#endif\n"
-"\n"
-"\n"
-"\n"
-"\n"
+"#if defined(MODE_LIGHTDIRECTIONMAP_FORCED_LIGHTMAP) || defined(MODE_LIGHTDIRECTIONMAP_FORCED_VERTEXCOLOR)\n"
+"      #define SHADING\n"
+"      // forced deluxemap on lightmapped/vertexlit surfaces\n"
+"      half3 lightnormal = half3(0.0, 0.0, 1.0);\n"
+"   #ifdef USELIGHTMAP\n"
+"              half3 lightcolor = half3(tex2D(Texture_Lightmap, TexCoordLightmap).rgb);\n"
+"   #else\n"
+"              half3 lightcolor = half3(gl_FrontColor.rgb);\n"
+"   #endif\n"
+"#endif\n"
 "#ifdef MODE_FAKELIGHT\n"
-"#define SHADING\n"
-"half3 lightnormal = half3(normalize(EyeVector));\n"
-"half3 lightcolor = half3(1.0,1.0,1.0);\n"
+"      #define SHADING\n"
+"      half3 lightnormal = half3(normalize(EyeVector));\n"
+"      half3 lightcolor = half3(1.0,1.0,1.0);\n"
 "#endif // MODE_FAKELIGHT\n"
 "\n"
 "\n"
index e537d8388661b63d0c35345d6ff1568d9ffdff5b..8376007a3a23128409bdd69875cbb8c7759c71ce 100644 (file)
@@ -977,6 +977,15 @@ sfx_t *S_FindName (const char *name)
                if(!strcmp (sfx->name, name))
                        return sfx;
 
+       // check for # in the beginning, try lookup by soundindex
+       if (name[0] == '#' && name[1])
+       {
+               int soundindex = atoi(name + 1);
+               if (soundindex > 0 && soundindex < MAX_SOUNDS)
+                       if (cl.sound_precache[soundindex]->name[0])
+                               return cl.sound_precache[soundindex];
+       }
+
        // Add a sfx_t struct for this sound
        sfx = (sfx_t *)Mem_Alloc (snd_mempool, sizeof (*sfx));
        memset (sfx, 0, sizeof(*sfx));
index c34f1c82e795f81da570e04bcf3546495bafb061..e6259b655914e5b4cc3266f98e44a332accdb22b 100644 (file)
@@ -198,6 +198,8 @@ cvar_t v_color_white_g = {CVAR_SAVE, "v_color_white_g", "1", "desired color of w
 cvar_t v_color_white_b = {CVAR_SAVE, "v_color_white_b", "1", "desired color of white"};
 cvar_t v_hwgamma = {CVAR_SAVE, "v_hwgamma", "0", "enables use of hardware gamma correction ramps if available (note: does not work very well on Windows2000 and above), values are 0 = off, 1 = attempt to use hardware gamma, 2 = use hardware gamma whether it works or not"};
 cvar_t v_glslgamma = {CVAR_SAVE, "v_glslgamma", "1", "enables use of GLSL to apply gamma correction ramps if available (note: overrides v_hwgamma)"};
+cvar_t v_glslgamma_2d = {CVAR_SAVE, "v_glslgamma_2d", "0", "applies GLSL gamma to 2d pictures (HUD, fonts)"};
+
 cvar_t v_psycho = {0, "v_psycho", "0", "easter egg"};
 
 // brand of graphics chip
@@ -1649,6 +1651,7 @@ void VID_Shared_Init(void)
 
        Cvar_RegisterVariable(&v_hwgamma);
        Cvar_RegisterVariable(&v_glslgamma);
+       Cvar_RegisterVariable(&v_glslgamma_2d);
 
        Cvar_RegisterVariable(&v_psycho);