Jump to content

Slight Tangent Normal Map Confusion


Pryme8
 Share

Recommended Posts

So, my mind is kinda messed up from this.  It seems to be the opposite of what I was expecting.
So when a normal map is generated from a black and white image and is set in tangent space does the "raised" elements look like they are going in or out on the normal map.

So when I generated my normal map initially I just used the values that I used where not inverted and I noticed that the elements seemed to be concave not convex, so I switched my x value to be inverted so on the Shader I output 1.0-x, y, 0.0, 1.0 respectively and it fixed the lighting direction on the mesh, but kept the look of the normal map as inverted like the example below on the left.

I then just for experimenting inverted the y as well, and it output the normal map on the right.

So now I am confused, which one is correct?  Cause that's confusing to me that the normal map on the left will look the same with 1.0-x, y will look the same as x,y on the normal map image, but when actually applied seems to invert the bump.
Here is a example:
nMap.thumb.png.ba12dcdf5df699242d94f31378f5b8d3.png

 

const NormalmapGenerator0 =
`varying vec2 vUV;

uniform vec2 textureSize;
uniform sampler2D textureSampler;

void main(){
    vec2 unit = vec2(1.0)/textureSize;
    float x = ((texture2D(textureSampler, vUV+(unit*vec2(-1.,0.))).r
    -texture2D(textureSampler, vUV+(unit*vec2(1.,0.))).r)+1.)*0.5;
    float y = ((texture2D(textureSampler, vUV+(unit*vec2(0.,1.))).r
    -texture2D(textureSampler, vUV+(unit*vec2(0.,-1.))).r)+1.)*0.5;
#if defined(invertDepth)
    	gl_FragColor = vec4(x, y, 1.0, 1.0);
#else
	gl_FragColor = vec4(1.0-x, 1.0-y, 1.0, 1.0);
#endif

}`;

There is the shader. So the question comes up now, which is the correct output, if different once will produce the same results but seemly should not... *BRAIN EXPLODING* 

vec4(x, y, 1.0, 1.0);
or 
vec4(1.0-x, y, 1.0, 1.0);
or
vec4(x,1.0- y, 1.0, 1.0);
or
vec4(1.0-x,1.0- y, 1.0, 1.0);

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...