- Home /
Raycast on mesh deformed by shader
Hi,
I have a sphere (planet) where i deform its mesh through a shader - but raycasting against it seems a bit tricky.
I know I could just pre-compute the vertex positions and copy the mesh into a mesh-collider, but I'd like to be able to adjust the heightlevels at runtime (craters and whatnot) without having to rebuild the mesh (65k+ verts).
Is there any way to get the surface position after the shader has done its tranformation?
Thanks :)
Edit: derp.. just found the question being asked elsewhere, but the answer didn't really offer any solution.
I get that I cant update the 'physics mesh' every frame - but was wondering if some trickery could be done by reading out the heightvalue from the same map that the shader uses to transform the mesh, and then offsetting the raycast based on mapheight and angle of the raycast?
Edit2: Should probably mention that I'm not really interested in the actual hit point of the raycast - I only need it so that I can translate the point into a coordinate on a 2D grid.