Normal Map shading problems

On your simple beveled box, one thing that occurs to me to try to see if it’s the effect I’m talking about… subdivide the box. The more subdivided the better but 8 should be good.

If the odd shadowing becomes less pronounced then it’s likely an interpolation error and not a tangents error.

Yep I’ll try that.
Not sure I completely get what your diagram is about though :stuck_out_tongue:
The thing is… there is a way to get rid of this error, since blender and substance manage it, but I don’t know it yet. I’m trying to figure it out, and ponder if it’s worth the effort and if it fits the needs of JME.

When a vec3 is interpolated in shader, it’s a linear interpolation from tip to tip… like those yellow lines. So, say the bottom picture is of the interpolation of a normal pointing 45 degrees to the left and 45 degrees to the right. The yellow vectors are what you’d get in the shader.

Usually, we then normalize them because that’s what is useful to us… unit vectors. Those are the red lines (but I’ve shortened them artificially so we can see what’s behind them). Those are the vectors we’d actually use in the shader.

The green lines are the ideal… that’s what would happen if we actually interpolated vectors by rotation instead of interpolating their tips linearly. (We can’t do it but that’s the mathematically correct view.)

The red vectors towards the edges are shallower than the ideal. The red vectors towards the middle are steeper.

Note: it also could be that this is already accounted for in the normal map… but then the normal map would be extremely geometry specific.

It’s possible that blender and substance painter are doing better interpolation.

It’s also possible that this has nothing to do with anything.

1 Like

ok,now I get what the diagram is about :wink: Makes sense.

It’s annoying how wise you are Paul =)

If the normal map has been generated with the assumption that tangent vectors are linearly interpolated, wouldn’t this fix the issue? Also like you mentioned, if the box was subdivided further, the artifacts would be reduced.

Yes but I want it to work as is…
I could also make a better uv layout so that tangents are not so distorted. But I don’t want to modify the model.
I want to get as close as I can from what blender and substance do.

My request that you try subdividing was only to do assessment. If it doesn’t change anything then you know it’s a JME math problem.

yes yes, I got that, not sure Kirill meant the same thing.

Yep, I was clarifying.

Might it be possible that their shaders include a “counter factor” to fight against the effects of linear interpolation? Or even an automatic subdivision of the geometry? Or tesselation?
But try what Paul suggested first.
I think I’ve suggested in this thread before to subdivide those extremely thin triangles too.

There are no extremely thin triangles on the cube… which is why it makes a good test case.

We encountered a problem, I don’t have idea if it is somehow related to above conversation,. @winhelp will show his model in blender, I’ll show how it looks ingame.

  1. ingame screen, notice the column on the left, this is not the shadow, it is caused by normals.

  2. normalmaps - they are ok.Ignore the edges.

  3. normals - it is better visible on the right column. Somehow normals try to make it round, there is an ‘gradient’ that causes the issu shown on screen 1.

The question is: is something wrong with our model or there is a problem with JME?

hu… what’s wrong actually?
I can’t see any artifact…

Also view space normals as in the last screen has nothing to do with Normal mapping

that gradient visible on the right column, from the edge to its center, this should be plain but the normals are like on round object.

Well… idk… it looks fine to me.
Anyway… if it was related to this issue the atrifact would be obvious really…
Here the light is comming from a very steep angle…looks like it’s correct…

Yes, the light acts as it should, the question is why the normals aren’t perpendicular to the surface.

If it’s the normals and not the normal maps… then it has to be the geometry. No way around it, really.

Note: you could also try adding a normals mesh to see if the lines are pointing where you expect.

http://javadoc.jmonkeyengine.org/com/jme3/util/TangentBinormalGenerator.html#genNormalLines(com.jme3.scene.Mesh,%20float)

Mhmm, now we are looking what is wrong.