Hello everyone, I found a great ocean material. I hope to use this material to achieve the effect of objects floating and sinking with waves, but I don’t know the height of the waves at a certain position. Is there any information for reference?
It depends on your needs.
If you need the height information on the CPU, I don’t see any other solution than recoding the vertex displacement shader. Basically port the shader code to JS. Maybe it’s possible with transform feedback. idk if it’s available. @Evgeni_Popov will know for sure.
Another solution if you only want to place objects for rendering, without getting placement on the CPU is to code a new shader that compute a world matrix (position + derivatives). It’s more or less copy/pasting a subset of the nme graph into a new graph.
No, transform feedback is not available in the NME. I’m not even sure it is available for use by the end user…
We use it internally for the particle system but I don’t think there’s an external interface that a user can use to leverage the transform feedback feature. Even if it was possible, you would still need to read back the data from the GPU to CPU, which takes time. The best solution would probably be what you suggest, that is to make a shader that would compute a new world matrix for the object, based on the water shader code.