NodeMaterial HeightToNormal

Hi

I tried to use HeightToNormal to generate normal map.

But when you rotate the camera colors of heightMap are constantly changing and make the height faked by formal always move. The output always is doing something instead of being stable like the normal texture would be.

I only get black rendering of mesh in nme.
Did you try to plug the mesh position into world position? instead of pluging in position transformed by world transform. To rephrase it, try to simplify the shader and remove any transformation.
Then, when it works, plug them back until something goes wrong.


looks like the force normalization should be disabled on the tangent nodes.

@sebavan

Hi Yes it should be disabled. But anyway its still makes the normal behave like shimmering water when you have it on a plane and you rotate camera left to right. Its not stable like the texture would be. Its changing the colors and makes at the end shadows to move with it. instead rotate to see the shadows from a different angle.

Any suggestion to that ?

move camera here left to right it should not change the colors.

Yup, this sounds strange, let me add @Deltakosh to have a look when he ll be back from vacation next week.

HI

Any updates on this one?

@Deltakosh will be back tomorrow so you can expect news during the week

Well the problem is that the system is using dfdx, dfdy to compute the new normal and this is heavily relying on interpolation on a plane with only so few vertices.

This is not a bug per se but more a limitation. You should add more subdivisions to your mesh to compensate

1 Like

@Deltakosh

I made a new PR. The additional mesh has nothing to do with the shader. Or it least it should not.

So here if I connect output of noise to output nothing is moving. And the shape is visible.

But when I plug output of normal the situation changes and the normal is not even close to look like the shape from the noise.

So there is no way this Normal would simulate the shape of the height map from above? Or I’m missing something?

Regards
Peter

Same answer my friend: you need to subdivide the supporting mesh far more and in NME we cannot update that

In other words: it will work if you do it on a custom PG where you create a more detailed plane

@Deltakosh

I don’t think it makes any difference with adding more geometry:

The noise is still moving around when you move the camera and also the Normal does not generate anything similar to heightmap:

Playground:

I would expect something like this:

But I cant make it happen or the use case for this is completely different.

Digging more into it:

Ok I’m working with @Evgeni_Popov to understand why the shader (heightToNormal) does not work as expected

For the records, Unity has the same issue: [SOLVED] Height to Nomal in shader - Unity Engine - Unity Discussions

@Evgeni_Popov found the culprit!
Fix HeightToNormal block by deltakosh · Pull Request #15613 · BabylonJS/Babylon.js (github.com)

2 Likes