Jump to content

  • Log In with Google      Sign In   
  • Create Account

How to find uv coordinates for a 3D triangle?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 larspensjo   Members   -  Reputation: 1540

Like
0Likes
Like

Posted 04 January 2014 - 04:21 PM

I am using the uv coordinate as a seed for a 2D simplex noise to create surface effects. If the triangle has the normal pointing at z, then xy can be used as uv coordinates.

 

However, the triangles have more or less random orientations. I suppose I need a rotation so as to have the normal aligned with e.g. z, then I can again use xy as uv. I have difficulties to find out how to do this rotation.

 

It may be that the problem can have more than one solution, but I only need one. Is there an efficient algorithm for this?

 


Current project: Ephenation.
Sharing OpenGL experiences: http://ephenationopengl.blogspot.com/

Sponsor:

#2 unbird   Crossbones+   -  Reputation: 4977

Like
1Likes
Like

Posted 05 January 2014 - 03:43 AM

You could play with tri-planar projection, like shown in this GPU Gems article. But I rather recommend using a 3D noise as source, so you can feed the positions directly.



#3 larspensjo   Members   -  Reputation: 1540

Like
0Likes
Like

Posted 07 January 2014 - 03:46 AM

There is an implementation of 3d Simplex noise at github/ashima/webgl-noise. I was mainly worried about higher performance costs as the 3D noise is more complex than the 2D noise. But it turned out this added a negligible time to the shader.


Current project: Ephenation.
Sharing OpenGL experiences: http://ephenationopengl.blogspot.com/




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS