- Home /
Mapping a texture onto a virtual sphere
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 sphere around that position . This all happens in the shader.
Then when cycling through the UVs (also converted to local positions) in the shader I am able to check if each UV/position is within the sphere, and hence set a colour.
The bit I am struggling with is how to map each position to the sphere so I can then map that to the splat texture using UVs or percentages.
In the image above I have 5 splat points. As you can see the one is crossing an edge so I need to be able to transform the position along all axes.
I tried stereographic projection and also converting the 3D point to a spherical coordinate, but it didn't seem to work. Not sure if it is an axes directional issue.
Any ideas?
Thanks!
Your answer
Follow this Question
Related Questions
Can I make the self-illumin shader use a second UV channel for the illumination texture? 1 Answer
Why is my UV'd texture displaying wrapped with the wrong scale? 0 Answers
How to combine several Materials into one? 0 Answers
Incorrect lighting projecting normal map downwards in world space 1 Answer
How can I convert the texture coordinates of the multi-spite to 0-1? 0 Answers