GLSL Parallax Mapping

Started by
18 comments, last by Vexator 17 years, 8 months ago
Try the following for the height map sampling.
// use a scale of 0.05, try bias of 0 for nowfloat height = texture2D(heightMap, gl_TexCoord[0]).r - bias;float offset = scale * (2.0 * height - 1.0);vec2 newTexCoord = gl_TexCoord[0].st + viewVector.xy * height;

My shader does something to that affect.

Hope that helps

Advertisement
Ok, so here's the change that I made:

// Get the height value and calculate the new texture coord.
float height = texture2D(heightMap, texCoord).r - bias;
float offset = scale * (2.0 * height - 1.0);
vec2 newTexCoord = texCoord.st + viewVector.xy * offset;

And what I did was as I lowered the size of scale it looked more like a normal texture. When I put it at 0.0001 it nearly looked like the original texture which makes sense because there's less offset. So here's my question, would it be possible that I have the wrong viewVector or something like that?
Douglas Eugene Reisinger II
Projects/Profile Site
A few swift calculation changes and I'm almost there
float scale = 0.05float bias = 0.025float height = texture2D(heightMap, texCoord).r;//float offset = scale * (2.0 * height - 1.0);float offset = (height * scale) - bias;vec2 newTexCoord = texCoord.st + (viewVectorNew.xy * offset);


Here are the results
Almost Working...
Douglas Eugene Reisinger II
Projects/Profile Site
maybe you should take a look at the rendermonkey and shaderdesigner examples and look how they did it :)
Wunderwerk Engine is an OpenGL-based, shader-driven, cross-platform game engine. It is targeted at aspiring game designers who have been kept from realizing their ideas due to lacking programming skills.

blog.wunderwerk-engine.com
I have made some parallax stuff too, but it looks kind of what the second screenshot shows, kind of messy and stretched. I used the code from the Shader Designer example. Though, I read someplace that I should use a heightmap that is bigger in size than the normal texture (i.e. texture = 256x256, heightmap = 512x512 instead of the other way around). Can this really be true?
i had the same problems with the shader designer sample as well, but i thought that it was simply my fault. their examples seem to be coded for a static camera only.. the intensity of the light was influenced by my camera movement, etc Oo
Wunderwerk Engine is an OpenGL-based, shader-driven, cross-platform game engine. It is targeted at aspiring game designers who have been kept from realizing their ideas due to lacking programming skills.

blog.wunderwerk-engine.com
Ah yes, that is correct... Shader Designer uses a static camera.. hmm, so how did you solve it? Should only be a small revamp of some portion of the code I guess :)
Are u sure that the camera an light uses right coordinates when you send to the shader? With my TBN matrix I need to negate the tangent vector.

ains
I am not even sure I am calculating the tangents and binormals correctly :)
http://www.terathon.com/code/tangent.php

works fine, using it in my engine, too.
Wunderwerk Engine is an OpenGL-based, shader-driven, cross-platform game engine. It is targeted at aspiring game designers who have been kept from realizing their ideas due to lacking programming skills.

blog.wunderwerk-engine.com

This topic is closed to new replies.

Advertisement