From 0a9997b078c42aac6b5cb9eca43564e8dd39f95c Mon Sep 17 00:00:00 2001 From: havoc Date: Mon, 28 Feb 2011 20:34:51 +0000 Subject: [PATCH] changed offsetmapping to use forward step math, greatly improved quality 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 | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/gl_rmain.c b/gl_rmain.c index 61be332b..d7650379 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -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" -- 2.39.2