UV coordinates in 3d space?

I’m trying to cast rays out from UV coordinate points on meshes. Haven’t gotten too far yet, but my idea is casting out rays from a UV coordinate point on the mesh and then casting them in the direction of the mesh normal at that point.

Any tips would be greatly appreciated,
Ethan

A projector might be simpler and accomplish what you need.

How would a Projector help here?

I’ll admit I’m just having a bit of fun at the moment since my scripting skills are relativley limited… I’m sitting next to Yoggy everyday watching him perform scripting magic at times so my own scripting skills have been swept under the carpet to save face :wink:

I’m trying to create a simple Unity based Ambient Occlusion calculator… just a proof of concept and something to freshen up my interest in Unity scripting since I’ve been doing 100% art creation over the last couple of months.

Tonight I got it working based upon raycasting from each vertice on a mesh and raycasting outwards from the normal direction at that vertice and writing a grayscale pixel into the texture based on the raycast distance. Actually it looks decent if the mesh is super high poly, but I’d love to be able to cast rays from a much larger array of UV coordinates instead of just the vertices. My problem is how to find the 3D origin point from the UV information to cast the rays from. I guess I’m looking for the opposite of RaycastHit.textureCoord possibly :wink:

Thanks for any more hints,
Ethan

Interpolate across each triangle. Each triangle has three indexes corresponding to the three vertice indexes. So you can interpolate between those three vertices positions, those three vertice normals, and those three UVs.

Cheers,
-Jon

p.s. Cool idea!

The google word you want is “polygon scanline conversion”

The code is quite hard to get completely right, though…