]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
some more hlsl fixes
authorRudolf Polzer <divverent@xonotic.org>
Mon, 28 Jan 2013 15:34:53 +0000 (16:34 +0100)
committerRudolf Polzer <divverent@xonotic.org>
Mon, 28 Jan 2013 15:34:53 +0000 (16:34 +0100)
gl_rmain.c
shader_hlsl.h

index 0322fdd671ace22638becd6bd5851e10e6814bea..c7b64f153aa6ae53d65f0553544fb6a9989884fa 100644 (file)
@@ -868,7 +868,6 @@ typedef struct r_glsl_permutation_s
        int loc_BounceGridMatrix;
        int loc_BounceGridIntensity;
        int loc_BitValue;
-       int loc_Rand1f;
        int loc_Rand2f;
 }
 r_glsl_permutation_t;
@@ -1220,7 +1219,6 @@ static void R_GLSL_CompilePermutation(r_glsl_permutation_t *p, unsigned int mode
                p->loc_BounceGridMatrix           = qglGetUniformLocation(p->program, "BounceGridMatrix");
                p->loc_BounceGridIntensity        = qglGetUniformLocation(p->program, "BounceGridIntensity");
                p->loc_BitValue                   = qglGetUniformLocation(p->program, "BitValue");
-               p->loc_Rand1f                     = qglGetUniformLocation(p->program, "Rand1f");
                p->loc_Rand2f                     = qglGetUniformLocation(p->program, "Rand2f");
                // initialize the samplers to refer to the texture units we use
                p->tex_Texture_First = -1;
@@ -1341,7 +1339,6 @@ static void R_SetupShader_SetPermutationGLSL(unsigned int mode, unsigned int per
        if (r_glsl_permutation->loc_ModelViewProjectionMatrix >= 0) qglUniformMatrix4fv(r_glsl_permutation->loc_ModelViewProjectionMatrix, 1, false, gl_modelviewprojection16f);
        if (r_glsl_permutation->loc_ModelViewMatrix >= 0) qglUniformMatrix4fv(r_glsl_permutation->loc_ModelViewMatrix, 1, false, gl_modelview16f);
        if (r_glsl_permutation->loc_ClientTime >= 0) qglUniform1f(r_glsl_permutation->loc_ClientTime, cl.time);
-       if (r_glsl_permutation->loc_Rand1f     >= 0) qglUniform1f(r_glsl_permutation->loc_Rand1f, lhrandom(-1.0,1.0));
        if (r_glsl_permutation->loc_Rand2f     >= 0) qglUniform2f(r_glsl_permutation->loc_Rand2f, lhrandom(-1.0,1.0), lhrandom(-1.0,1.0));
        if (r_glsl_permutation->loc_BitValue   >= 0){
                switch(r_viewfbo.integer){
@@ -1444,7 +1441,9 @@ typedef enum D3DPSREGISTER_e
        D3DPSREGISTER_NormalmapScrollBlend = 52,
        D3DPSREGISTER_OffsetMapping_LodDistance = 53,
        D3DPSREGISTER_OffsetMapping_Bias = 54,
-       // next at 54
+       D3DPSREGISTER_OffsetMapping_BitValue = 55,
+       D3DPSREGISTER_OffsetMapping_Rand2f = 56,
+       // next at 57
 }
 D3DPSREGISTER_t;
 
@@ -1850,6 +1849,14 @@ void R_SetupShader_SetPermutationHLSL(unsigned int mode, unsigned int permutatio
        hlslVSSetParameter16f(D3DVSREGISTER_ModelViewProjectionMatrix, gl_modelviewprojection16f);
        hlslVSSetParameter16f(D3DVSREGISTER_ModelViewMatrix, gl_modelview16f);
        hlslPSSetParameter1f(D3DPSREGISTER_ClientTime, cl.time);
+       hlslPSSetParameter2f(D3DPSREGISTER_Rand2f, lhrandom(-1.0,1.0), lhrandom(-1.0,1.0));
+       switch(r_viewfbo.integer){
+               case 0:
+               case 1:  hlslPSSetParameter1f(D3DPSREGISTER_BitValue, pow(2, -8))); break;
+               case 2:  hlslPSSetParameter1f(D3DPSREGISTER_BitValue, pow(2,-10)); break;
+               case 3:
+               default: hlslPSSetParameter1f(D3DPSREGISTER_BitValue, pow(2,-23));
+       };
 }
 #endif
 
index 8a994b735a59379d9bbd5bff14d6453188d7d560..a8a42637f9553365fd14ab5ae5f7ef73fa337c3d 100644 (file)
 "              uniform sampler Texture_First  : register(s0),\n"
 "              uniform sampler Texture_Second : register(s1),\n"
 "              uniform sampler Texture_Dither : register(s2),\n"
-"              uniform half   BitValue : register(c0),\n"
-"              uniform half      Alpha : register(c1),\n"
-"              uniform float2   Rand2f : register(c2),\n"
+"              uniform half   BitValue : register(c55),\n"
+"              uniform float2   Rand2f : register(c56),\n"
+"              uniform half      Alpha : register(c0),\n"
 "              out float4 dp_FragColor : COLOR\n"
 "              )\n"
 "              {\n"
 "                      float2 tc = TexCoord;\n"
 "                      float3 tex1 = tex2D(Texture_First,  tc).rgb;\n"
 "                      float3 tex1 = tex2D(Texture_Second, tc).rgb;\n"
-"                      float3 tex3 = tex2D(Texture_Dither, tc).rgb;\n"
+"                      float3 tex3 = tex2D(Texture_Dither, tc*8.0+Rand2f).rgb;\n"
 "                      dp_FragColor = (Alpha)*tex1 + (1.0-Alpha)*tex2 + (tex3-0.5)*BitValue;\n"
 "              }\n"
 "      #endif\n"