11-27-2010, 11:18 PM
(This post was last modified: 01-20-2011, 12:52 AM by master[mind].)

So I said I'd dig around the engine code, and I did. In finding the offset mapping shader, I bumped into the relief mapping shader. I said, "Hmmm, 14 passes is not a small number, I wonder if less will make a difference." 8 less passes later, I reached this result:

Click to Enlarge

LQ:

HQ:

In some cases, the "LQ" method looks even better than the "HQ" method. O_o

Now notice that framerate difference in the first image from both...

41 - HQ

69 - LQ

O_o

Exactly...

It's where the relief is combined with Realtime World Lighting and the warpzone. Largest hitting spot in the map.

Here are the changes made to gl_rmain.c:

At line 1133, change this chunk:

To this chunk:

And make the same changes at line 2318.

Test it for yourself to see what I mean. BTW, the "height" difference is already compensated for in the .375 value. The offset mapping scale cvar doesn't need to be changed from .02. Maybe someone wants to calculate the more accurate value than .375? But it's close enough. The height is almost exactly identical.

The biggest visual difference is when you observe the texture at a really short distance, thats why I recommend it be a menu option, LQ vs HQ. I will point out that HQ seems to overcompensate frequently and produce strange artifacts while LQ seems to be dead accurate. One recommendation I make is to add a few more iterations of jitter, that would most likely remove the "banding" more visible in HQ without creating the strange artifacts present from 8 extra iterations....

Yeah, hope that's helpful, I'd commit it to git, but I don't have any portion of git setup to run with this project, or an account/name.

Click to Enlarge

LQ:

HQ:

In some cases, the "LQ" method looks even better than the "HQ" method. O_o

Now notice that framerate difference in the first image from both...

41 - HQ

69 - LQ

O_o

Exactly...

It's where the relief is combined with Realtime World Lighting and the warpzone. Largest hitting spot in the map.

Here are the changes made to gl_rmain.c:

At line 1133, change this chunk:

Code:

`"#ifdef USEOFFSETMAPPING_RELIEFMAPPING\n"`

" // 14 sample relief mapping: linear search and then binary search\n"

" // this basically steps forward a small amount repeatedly until it finds\n"

" // itself inside solid, then jitters forward and back using decreasing\n"

" // amounts to find the impact\n"

" //vec3 OffsetVector = vec3(EyeVector.xy * ((1.0 / EyeVector.z) * OffsetMapping_Scale) * vec2(-1, 1), -1);\n"

" //vec3 OffsetVector = vec3(normalize(EyeVector.xy) * OffsetMapping_Scale * vec2(-1, 1), -1);\n"

" vec3 OffsetVector = vec3(normalize(EyeVector).xy * OffsetMapping_Scale * vec2(-1, 1), -1);\n"

" vec3 RT = vec3(TexCoord, 1);\n"

" OffsetVector *= 0.1;\n"

" RT += OffsetVector * step(texture2D(Texture_Normal, RT.xy).a, RT.z);\n"

" RT += OffsetVector * step(texture2D(Texture_Normal, RT.xy).a, RT.z);\n"

" RT += OffsetVector * step(texture2D(Texture_Normal, RT.xy).a, RT.z);\n"

" RT += OffsetVector * step(texture2D(Texture_Normal, RT.xy).a, RT.z);\n"

" RT += OffsetVector * step(texture2D(Texture_Normal, RT.xy).a, RT.z);\n"

" RT += OffsetVector * step(texture2D(Texture_Normal, RT.xy).a, RT.z);\n"

" RT += OffsetVector * step(texture2D(Texture_Normal, RT.xy).a, RT.z);\n"

" RT += OffsetVector * step(texture2D(Texture_Normal, RT.xy).a, RT.z);\n"

" RT += OffsetVector * step(texture2D(Texture_Normal, RT.xy).a, RT.z);\n"

" RT += OffsetVector * (step(texture2D(Texture_Normal, RT.xy).a, RT.z) - 0.5);\n"

" RT += OffsetVector * (step(texture2D(Texture_Normal, RT.xy).a, RT.z) * 0.5 - 0.25);\n"

" RT += OffsetVector * (step(texture2D(Texture_Normal, RT.xy).a, RT.z) * 0.25 - 0.125);\n"

" RT += OffsetVector * (step(texture2D(Texture_Normal, RT.xy).a, RT.z) * 0.125 - 0.0625);\n"

" RT += OffsetVector * (step(texture2D(Texture_Normal, RT.xy).a, RT.z) * 0.0625 - 0.03125);\n"

" return RT.xy;\n"

To this chunk:

Code:

`"#ifdef USEOFFSETMAPPING_RELIEFMAPPING\n"`

" // 6 sample relief mapping: linear search and then binary search\n"

" // this basically steps forward a small amount then jitters forward and back using decreasing\n"

" // amounts to find the impact\n"

" //vec3 OffsetVector = vec3(EyeVector.xy * ((1.0 / EyeVector.z) * OffsetMapping_Scale) * vec2(-1, 1), -1);\n"

" //vec3 OffsetVector = vec3(normalize(EyeVector.xy) * OffsetMapping_Scale * vec2(-1, 1), -1);\n"

" vec3 OffsetVector = vec3(normalize(EyeVector).xy * OffsetMapping_Scale * vec2(-1, 1), -1);\n"

" vec3 RT = vec3(TexCoord, 1);\n"

" OffsetVector *= 0.375;\n"

" RT += OffsetVector * step(texture2D(Texture_Normal, RT.xy).a, RT.z);\n"

" RT += OffsetVector * (step(texture2D(Texture_Normal, RT.xy).a, RT.z) - 0.5);\n"

" RT += OffsetVector * (step(texture2D(Texture_Normal, RT.xy).a, RT.z) * 0.5 - 0.25);\n"

" RT += OffsetVector * (step(texture2D(Texture_Normal, RT.xy).a, RT.z) * 0.25 - 0.125);\n"

" RT += OffsetVector * (step(texture2D(Texture_Normal, RT.xy).a, RT.z) * 0.125 - 0.0625);\n"

" RT += OffsetVector * (step(texture2D(Texture_Normal, RT.xy).a, RT.z) * 0.0625 - 0.03125);\n"

" RT += OffsetVector * (step(texture2D(Texture_Normal, RT.xy).a, RT.z) * 0.03125 - 0.015625);\n"

" return RT.xy;\n"

And make the same changes at line 2318.

Test it for yourself to see what I mean. BTW, the "height" difference is already compensated for in the .375 value. The offset mapping scale cvar doesn't need to be changed from .02. Maybe someone wants to calculate the more accurate value than .375? But it's close enough. The height is almost exactly identical.

The biggest visual difference is when you observe the texture at a really short distance, thats why I recommend it be a menu option, LQ vs HQ. I will point out that HQ seems to overcompensate frequently and produce strange artifacts while LQ seems to be dead accurate. One recommendation I make is to add a few more iterations of jitter, that would most likely remove the "banding" more visible in HQ without creating the strange artifacts present from 8 extra iterations....

Yeah, hope that's helpful, I'd commit it to git, but I don't have any portion of git setup to run with this project, or an account/name.