I want to map a texture onto an object so that it gets fitted onto the entire screenspace projection of the object, i.e. for each vertical cross-section of the object as visible by the camera, the pixel values of the texture are linearly mapped it fits the height of the cross-section. I drew a picture to try to explain what I want.

enter image description here

I can only think of how to fit the texture to the screenspace projection of the mesh bounds (by passing screenspace projected bounds to a shader which linearly remaps the UVs), which would result in some of the texture getting cut off (where the mesh does not reach the extent of the bounds). How can I fit it to the extents of the actual mesh?

The reason I am doing this is that I want to fit TMPro text into the shape of a mesh as seen by the camera, and I thought it would be most doable if I captured the text through a RenderTexture. However, this might require that I keep creating and destroying RenderTextures at runtime, so if there's a way to do it without RenderTextures then that might be even better.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.