4

I am writing a texture splatting pixel shader for meshes (not terrain) whereby I find a UV position from a raycast, which I convert to a local position, and then calculate a bounding box around that position.

Then when cycling through the UVs (also converted to local positions) in the shader I am able to check if each UV is within the bounding box, and hence set a colour.

enter image description here

The bit I am struggling with is how to map each local position to the bounding box so I can then map that result to the splat texture using UVs or percentages.

In the image above I have 6 splat points. As you can see the one is crossing an edge so I need to be able to transform the 3D position along all axes.

I was thinking I could flatten/unfold the 3D point, but I'm not sure how to do this with all axes.

Any ideas?

Thanks!

Garth Wood
  • 41
  • 2

0 Answers0