This topic is 3858 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I've been trying to get this temporary relief map shader working and it does for the most part... but there's a large annoyance whenever the camera's z value (set up so that it's also the z value in tangent space). What it looks like when you get closer is the whole texture gets smaller and eventually wraps around and inverts in both x/y direction.. The new 'relief map' part of the shader is as follows
	float depth = 0.4; //apparent depth of the texture

float numsteps = 300.0; //large but just to reduce aliasing in the stub
float stepsize = 1.0/numsteps;

float3 rayPos = float3(texCoords, 0.0f); //entry point for the ray

/* The following direction I'm iffy about, it works when z is larger than 1.6 making the relief map look correct. This is reflecting about the tangent plane I believe... */
float3 rayDir = -vEyeVector/vEyeVector.z; //direction for the ray
rayDir.z = 1.0f/depth;
rayDir = normalize(rayDir);

float3 rayEnd = rayPos + rayDir/rayDir.z; //ray hits the bottom boundary
float delta = length(rayPos-rayEnd)/numsteps;

float3 lastPos = rayPos;

for (int i = 0; i < numsteps; i++) {
float height = tex2D(heightmapTexture, rayPos.xy).r;
if (rayPos.z > height)
break;
lastPos = rayPos;
rayPos += delta*rayDir;
}


Is there something I'm missing? Can't seem to find any simple relief map code/help, maybe should just hop on and try cone mapping, but I'd like to learn the basics first. Thanks

##### Share on other sites
False alarm, passing in the wrong parameter to the code block for the camera's center position. Never underestimate quick and messy code!

1. 1
2. 2
JoeJ
20
3. 3
frob
19
4. 4
5. 5

• 10
• 11
• 12
• 13
• 9
• ### Forum Statistics

• Total Topics
632207
• Total Posts
3004773

×