NormalRecalcControl not working outside of SDK

I made a custom terrain editor, but the NormalRecalcControl doesn’t work properly in my editor.

I have confirmed that the control is enabled and assigned to the proper terrain, but when I sculpt hills, the normals do not appear to update immediately as they do when I sculpt the same exact terrain in the SDK

I have also confirmed that the NormalRecalControl is properly updating the normal values in the terrain’s normal buffer - it is just not being passed to the shader (similar to another terrain issue with Point Lights that I’m having and troubleshooting in a separate thread)

Similar to my other problem, whenever I cut/paste the terrain, the normal values will then appear properly.
So it is like the recalculated normal values are not being updated in the shader, even though the NormalRecalcControl is updating them in the mesh buffers. (I can also post a video validating that the mesh buffer gets updated even though the normal values are inaccurate in the shader, if anyone is doubting this strange behavior)

Any help is appreciated :slightly_smiling_face:

How?

Based on the contact normal returned by colliding a Ray with a point in the terrain that has recently been sculpted. Although this is going under the assumption that the contact normal returned from ray collisions is pulled directly from the normal buffer (correct me if I’m wrong on this)

I have a tool in my editor that places spatials wherever you click, and there’s an option to place the spatial so it is oriented perpendicular to the terrain, so I can tell that the contactNormal is correct in this short example video because the tree is correctly oriented when I place it on an area of the terrain that does not have its normals visually updated as it should (as indicated by the stretched texture - the terrain is in tri-planar mode so if the normals were getting updated properly in the shader, then the texture would not be stretched where I’ve sculpted)

The simplest explanation is that the buffer used for picking is not the same one used in the mesh. As I recall, JME’s standard terrain does special optimizations using the heightmap and custom code to pick from the height map. So it’s possible that the height map could be used to generate a collision while the mesh data itself was never updated.

So if you want to see if the normals are correct, the only sure way is to look in the Mesh’s normal buffer.

1 Like