# Parallax Occlusion Mapping

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

## Recommended Posts

Anyone have a decent GLSL example of POM?

##### Share on other sites

hm, thanks. i'll try to take a look although i'm doing forward rendering so it might be a bit tricky

##### Share on other sites

i got it running without errors but the results are screwy :/ would be grateful for anyone else with another example

##### Share on other sites

i got it running without errors but the results are screwy :/ would be grateful for anyone else with another example

it has nothing to do with deferred rendering, I just used that for lighting. You need to make sure your generated tangent vector are ok, then I suppose after doing normal mapping this shouldn't be much challenge either. The directx sdk has a great example.

##### Share on other sites

so . . . it "kind of" works, but mainly up close from only one direction and far away it gets too distorted.. here's a vid, take a look (only the brick in the hallway[texture you supplied] is parallaxed)

Also, this is how I calculate my tangent stuff in the vertex shader:

vec3 c1 = cross( v_Normal, vec3( 0, 0, 1 ) );
vec3 c2 = cross( v_Normal, vec3( 0, 1, 0 ) );
vec3 tangent;
if( length( c1 ) > length( c2 ) ) tangent = normalize( c1 );
else tangent = normalize( c2 );
vec3 n = normalize( V_NormalMatrix * v_Normal );
vec3 t = normalize( V_NormalMatrix * tangent );
vec3 b = cross( n, t );

I see that which is probably basically what you have as your vertex_output.tbn

At first i thought vs_to_ts was the same as vertex_output.tbn, but apparently not... So i tried this instead:

mat3 vs_to_ts = mat3(t.x,b.x,n.x,t.y,b.y,n.y,t.z,b.z,n.z );

and these are the results I got. No distortion. . . but still seems somewhat wrong? It like... goes from one direction to the other, based on the direction i'm viewing it from..

It almost seems like my tangent calculations are wrong? But, I use them in my specular normalmapping which works perfectly fine, so I don't think they're off..

##### Share on other sites

Hmm, I just tried by implementing the one from this page, and I get basically the same results

http://www.gamedev.net/page/resources/_/technical/graphics-programming-and-theory/a-closer-look-at-parallax-occlusion-mapping-r3262

Maybe that's how it's supposed to be. Also might not be worth the performance hit

you quite possible have some problems with coordinate spaces or your tangents/normals etc. aren't good. it should look like this (look at the floor: stable, solid, great at grazing angles):

performance wise, it should be rougly the same speed as tessellation, but this doesn't have to be tweaked that much. So it IS worth the implementation (imho). It does have some performance impact but that should be ok.

Edited by Yours3!f

##### Share on other sites

so . . . it "kind of" works, but mainly up close from only one direction and far away it gets too distorted.. here's a vid, take a look (only the brick in the hallway[texture you supplied] is parallaxed)

Also, this is how I calculate my tangent stuff in the vertex shader:

vec3 c1 = cross( v_Normal, vec3( 0, 0, 1 ) );
vec3 c2 = cross( v_Normal, vec3( 0, 1, 0 ) );
vec3 tangent;
if( length( c1 ) > length( c2 ) ) tangent = normalize( c1 );
else tangent = normalize( c2 );
vec3 n = normalize( V_NormalMatrix * v_Normal );
vec3 t = normalize( V_NormalMatrix * tangent );
vec3 b = cross( n, t );

I see that which is probably basically what you have as your vertex_output.tbn

At first i thought vs_to_ts was the same as vertex_output.tbn, but apparently not... So i tried this instead:

mat3 vs_to_ts = mat3(t.x,b.x,n.x,t.y,b.y,n.y,t.z,b.z,n.z );

and these are the results I got. No distortion. . . but still seems somewhat wrong? It like... goes from one direction to the other, based on the direction i'm viewing it from..

It almost seems like my tangent calculations are wrong? But, I use them in my specular normalmapping which works perfectly fine, so I don't think they're off..

hey there, I only had time to look at this now, here's how I calculate the tangents (on the cpu):
https://github.com/Yours3lf/libmymath/blob/master/mymath/mm_util.h#L102

• 10
• 13
• 13
• 14
• 12