How to save vertices position as Texture?

Hello everyone!

I want to record the vertices position in GPU and share the data with other shaders. I can get uv、position、MVP matrix in vertex shader, I wonder if there any way to save the position data as a Texture according to the uv mapping.

I have tried the renderTargetTexture,but RTT only show image in current view and not has right uv mapping too. I think the correct Texture should has right uvmapping of the mesh and other shaders can access the data by this mesh’s uv.

Thanks!

I think the main problem is how to record the 3D data into texture by Shader.

A similar situation is that draw on 3D objects and get results in 2D texture.

There are 2 different concepts, not sure about the 1 you are refering to.
1st one is to render in UV space. And potentially, render mesh position in UV space.
For this one, instead of outputing mesh.position * MVP, you output mesh.uv.
Then, for each texel, the fragment outputs the mesh position coming from the VS.
The same technic (UV space rendering) is usefull when painting on the mesh
the second concept is to store mesh vertices position in a texture (a float texture or a normalized RGBA8 one). It allows to do things like this : Mesh shattering with baked physics | by Babylon.js | Medium

Thanks for your quick reply! I think the UV space rendering is what I want. Could you please provide a playground for demo?

Check line 25, instead of transformed vertices position in world space, the output is the UV. Try it with an unwrapped mesh coming from a .gltf for example.

1 Like

Woo, thanks!