Pryme8 Posted July 27, 2018 Share Posted July 27, 2018 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: 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); Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 1, 2018 Author Share Posted August 1, 2018 *UPDATE* The answer is : vec4(1.0-x, y, 1.0, 1.0); GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.