Sign in to follow this  

Displacement of vertex height from a grey scale texture on CPU

This topic is 1408 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am lost on how to do this correctly...

 

I have a grey scale texture with 0-255 values for heights of my mesh, but the texture size is 256x256 and the mesh only has 409 vertices. Problem is I don't understand how I can do a one to one ratio here to offset the vertex height to match the texture. How are others going about this? I am assuming you need to sample an area and not use all 256x256 pixels in the displacement texture?

 

If anyone has code for this I would appreciate it to study from as I am totally lost here.

 

Thanks!

Share this post


Link to post
Share on other sites

A typical displacement map is sampled like any other texture: using a set of texture coordinates (like from a uv map). You can use adaptive tessellation to create additional vertices that sample this map in between the original vertices.

 

If you want to do a one-on-one mapping of 409 displacement values tied to 409 vertices it makes more sense to store them as a vertex-(weight-)-map and use them as a vertex shader input (next to position, uvs, etc.).

Share this post


Link to post
Share on other sites
Sign in to follow this