]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
changed offsetmapping to use forward step math, greatly improved quality
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 28 Feb 2011 20:34:51 +0000 (20:34 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 28 Feb 2011 20:34:51 +0000 (20:34 +0000)
changed HLSL shader offsetmapping to 2 sample to match GLSL

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10871 d7cf8633-e32d-0410-b094-e92efae38249

gl_rmain.c

index 61be332ba818d46883dea73babec4b5dc49de4f5..d76503790227fe0da685f8b3f717006843cb7a68 100644 (file)
@@ -1196,15 +1196,12 @@ static const char *builtinshaderstring =
 "      return RT.xy;\n"
 "#else\n"
 "      // 2 sample offset mapping (only 2 samples because of ATI Radeon 9500-9800/X300 limits)\n"
-"      // this basically moves forward the full distance, and then backs up based\n"
-"      // on height of samples\n"
 "      //vec2 OffsetVector = vec2(EyeVector.xy * ((1.0 / EyeVector.z) * OffsetMapping_Scale) * vec2(-1, 1));\n"
 "      //vec2 OffsetVector = vec2(normalize(EyeVector.xy) * OffsetMapping_Scale * vec2(-1, 1));\n"
 "      vec2 OffsetVector = vec2(normalize(EyeVector).xy * OffsetMapping_Scale * vec2(-1, 1));\n"
-"      TexCoord += OffsetVector;\n"
 "      OffsetVector *= 0.5;\n"
-"      TexCoord -= OffsetVector * texture2D(Texture_Normal, TexCoord).a;\n"
-"      TexCoord -= OffsetVector * texture2D(Texture_Normal, TexCoord).a;\n"
+"      TexCoord += OffsetVector * (1.0 - texture2D(Texture_Normal, TexCoord).a);\n"
+"      TexCoord += OffsetVector * (1.0 - texture2D(Texture_Normal, TexCoord).a);\n"
 "      return TexCoord;\n"
 "#endif\n"
 "}\n"
@@ -2438,17 +2435,13 @@ const char *builtinhlslshaderstring =
 "      RT += OffsetVector * (step(tex2D(Texture_Normal, RT.xy).a, RT.z) * 0.0625 - 0.03125);\n"
 "      return RT.xy;\n"
 "#else\n"
-"      // 3 sample offset mapping (only 3 samples because of ATI Radeon 9500-9800/X300 limits)\n"
-"      // this basically moves forward the full distance, and then backs up based\n"
-"      // on height of samples\n"
+"      // 2 sample offset mapping (only 2 samples because of ATI Radeon 9500-9800/X300 limits)\n"
 "      //float2 OffsetVector = float2(EyeVector.xy * ((1.0 / EyeVector.z) * OffsetMapping_Scale) * float2(-1, 1));\n"
 "      //float2 OffsetVector = float2(normalize(EyeVector.xy) * OffsetMapping_Scale * float2(-1, 1));\n"
 "      float2 OffsetVector = float2(normalize(EyeVector).xy * OffsetMapping_Scale * float2(-1, 1));\n"
-"      TexCoord += OffsetVector;\n"
-"      OffsetVector *= 0.333;\n"
-"      TexCoord -= OffsetVector * tex2D(Texture_Normal, TexCoord).a;\n"
-"      TexCoord -= OffsetVector * tex2D(Texture_Normal, TexCoord).a;\n"
-"      TexCoord -= OffsetVector * tex2D(Texture_Normal, TexCoord).a;\n"
+"      OffsetVector *= 0.5;\n"
+"      TexCoord += OffsetVector * (1.0 - tex2D(Texture_Normal, TexCoord).a);\n"
+"      TexCoord += OffsetVector * (1.0 - tex2D(Texture_Normal, TexCoord).a);\n"
 "      return TexCoord;\n"
 "#endif\n"
 "}\n"