Normalmap left/right Y flipped depend on point of view issue - help :)

I already explained this. Up in the normal map is not necessarily up in your model.

Imagine if one side of the forehead was at one angle and the other side was at another angle. (Not hard to imagine because your image is exactly that.) Changing the y value in the NORMAL MAP will have really strange results on the MODEL. Because in one case you are pointing your normals at one odd direction and in the other case you are pointing them in a completely different odd direction.

You cannot mess with the normal map values, really, unless you do it consistently.

1 Like

ok got it, thanks :slight_smile: , anyway im glad i think i solved all problems with it. not sure why blender exported different tangent Y direction for second model. maybe 2.8 bug.

@nehon once said:

Anyway, there are 2 ā€œstandardsā€ for normal maps: direct x standard and opengl standard. the difference between them is that the green channel is inverted
I guess one would expect that we support the opengl way, but actually we support the directx way because itā€™s what blender supports and we thought itā€™d be easier in blender to JME workflow.

based on this, if default normalType value is ā€œcompatibleā€ with blender, then it should always work if normalType not defined. But for some reason its not. so need change normalType or re-generate tangents via JME. or its about .gltf exporter.

i see there already were some issues before:

normalType will not fix tangents. Tangents will not fix normal type. These are two completely different things.

Tangents tell us the orientation of the normalmap image relative to the model. Normal type tells us which way to interpret the green channel. The only cases where these two things will even remotely align are when your tangents are EXACTLY (1, 0, 0).

ā€œnormalType not definedā€ can mean 100 different thingsā€¦ only ONE of which is ā€œit was never set by anythingā€. Iā€™m not convinced that you have confirmed thatā€¦ or at least I have not seen a runtime dump of the actual material parameters used at runtime to render the model at runtime.

99 things along the way could have set normal type.

1 Like

normalType will not fix tangents. Tangents will not fix normal type. These are two completely different things.

Tangents tell us the orientation of the normalmap image relative to the model. Normal type tells us which way to interpret the green channel. The only cases where these two things will even remotely align are when your tangents are EXACTLY (1, 0, 0).

then im really not sure why both models were working with opposite normalTypes when tangents were generated via .gltf exporter (-1 for first and 1 for second) .

and when i generated Tangents via SDK, it suddently work for both models with normalType -1 (and also undefined normalType too)

maybe like you said ā€œalign are when your tangents are EXACTLY (1, 0, 0).ā€ condition was met

ā€œnormalType not definedā€ can mean 100 different thingsā€¦ only ONE of which is ā€œit was never set by anythingā€. Iā€™m not convinced that you have confirmed thatā€¦ or at least I have not seen a runtime dump of the actual material parameters used at runtime to render the model at runtime.

99 things along the way could have set normal type.

not sure if i understand correctly.

i were changing normalType dynamically in SDK and see efect on model immidietly. correct, if i removed param from material, i needed to re-open model to see change. i dont think SDK lie somewhere, runtime parameters i think cant be changed via SDK not via material.

Yeah, Iā€™m not sitting in front of your computer so I do not know all of the different variables. I can only keep repeating (over and over) the facts about how it actually works in the renderer.

Letā€™s say you have a cube and youā€™ve unrolled it in such a way that the UVā€™s look like this:

Flipping the y value of the normal map to an incorrect value will look ok for at least one side but totally bonkers (in completely different ways) for the other sides.

The tangents are telling us where the bases of each of those sides are.

Conceptually:

(Itā€™s actually the inverse of this because the texture already knows what itā€™s ā€˜baseā€™ isā€¦ the tangents are telling where the REAL texture base is in 3D spaceā€¦ but think of it like if you wanted to project the visual 3D base back into texture space for that image.)

I can only tell you that this is definitely 100% how it works. I canā€™t tell you why your asset pipeline is giving you different results that you havenā€™t figured out the variables for. It could be a bunch of different things (one model still has mirror modifier, the other has it applied, etcā€¦ too many things to guess.)

But thatā€™s how the values work in the end.

1 Like

i were always not sure how tangents work.

now i tried understand what you said, but im still not sure if i get it properly.

im not sure what you mean via ā€œbaseā€ word.

do my concent match yours?(so tangents transform texture to know what pixels to read alike):

tangnets

but now when i think, its what is done before fragmentshaderā€¦ so i probably still dont know.

Iā€™m not sure whatā€™s what in that picture.

It seems like if the upper left corner is the UV map then there is no issue because tangents will align perfectly with the base of the texture.

Base of texture: the bottom of the texture. t = 0 (v=0),ā€¦ the base. The texture base. Not sure how else to say the bottom line of the texture.

The tangent vector shows us which direction the bottom line, v=0, of the texture is in 3D space relative to some vertex.

If you think of my example where the base of the sides is the line that adjoins the BOTTOM of the cube, then you can imagine that the tangent vectors point in very different directions for each vertex.

normalType ONLY DEALS WITH HOW TO INTERPRET THE GREEN CHANNEL. Effectively, this means the y of the normalmap normalā€¦ which as shown can point in entirely different directions on the model itself.

1 Like

ok, i think i got it.

so what tangent do, is just telling what is BASE(bottom line of the texture - vector of it) of each face(because each face have some UV coord) in current point of view of model.

so now i also dont know how tangents would help for this normalType issueā€¦ but it doā€¦ its oddā€¦

but anyway one question. why some materials(like unshaded) still work without generating tangents? i understand generator make binormals(needed for normalmaps) or however name it, this is something more than just telling base of texture as i understand.

You only need tangents for normal maps and height maps so you know which direction ā€œawayā€ isā€¦ ie: which direction to project the surface.

Normal maps and height maps = lighting. If you donā€™t have lighting then you donā€™t have normal maps and height maps.

Unshaded = no lighting = no normal maps or height maps = no tangents.

The binormal is the third axis of the TBN space (second axis in order of tangent, binormal, normal). Tangent points along the base of the texture (v=0) binormal points along the side of the texture (u=0) and normal points ā€œoutā€.

Just like the normal can curve across the surface, so must the tangent and binormal. So each fragment has its own local interpolated TBN letting it know which direction that normal map (or height map) vector actually points. ie: TBN turns normap map x,y,z into 3D x,y,z.

No, there are two different issues. Messed up tangents and messed up normal type. Messing with one hides the problems with the otherā€¦ sometimes.

In the end, both have to be correct.

1 Like

so just technical question.

so this is how normalmap works:

we have binormal direction from tangent of current pixel(im not sure what pass tangents further).
so each pixel it check binormal direction, and the more it match colors(RGB - depend on vector direction) the more lit pixel.

so when in my example i have seam in middle and same line go from left to up in texture and in second it go left to down in texture, so tangent binormal say right-up is direction of ā€œholeā€ down side for (right one on screenshot) and it say left-up for second(left on screenshot)

now sure how normalType just flip Y. if i think correct that is not from vector, but matrix (xyzw) so its not always predictible.

btw. looking at my models now, any direction of view and light seems correct.

reference:

Iā€™m kind of running out of ways to explain this.

Here is your normal map with tangent and binormal drawn in:

Here is your 3D face with the same tangent and binormal lines drawn in:

1 Like

ok, tangents i understood correclty,

now i also understand binormals correctly, thanks :slight_smile:

And in that picture, if you set the normalType backwards then you are effectively telling rendering that the binormals are upside down. You can see how if the normals were not generated with that in mind that it would create a seam down the middle. They will be pointing in strange opposite directions now.

1 Like

yes, thank you very much for telling me how tangents and binormal and normalType works.

:+1: