Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Making a texture 'point' at something?


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
4 replies to this topic

#1 Kryzon   Prime Members   -  Reputation: 3314

Like
2Likes
Like

Posted 08 May 2013 - 01:31 AM

The game "Conker's Bad Fur Day" for the Nintendo 64 boasts several special effects never seen before in that platform at the time, even featuring a rudimentary shadow-mapping effect.

One of the special effects of this game is especially intriguing. It occurs when you're using the "POV" camera mode to look around the level and happen to orbit around the character's face. His eyes follow the camera.

 

I've looked at the wireframe for the character mesh and noticed the character's eyes are entirely represented by texturing. They aren't "decal" meshes as one would expect. So the effect of movable eyes is somehow achieved by transforming the texture's matrix so as to make it slide.

 

Here's some footage from the game:

 

I was wondering what would be the math theory behind this, to compute an UV offset for an "eye" texture based on a point of origin (the position of the eye) and a point of destination in space (the object being looked at).



Sponsor:

#2 Dawoodoz   Members   -  Reputation: 331

Like
1Likes
Like

Posted 08 May 2013 - 01:58 AM

Apply a UV offset from a constant buffer to move the eyes like that. Then you cover the edges by lerping the eyes to visibility where the skin's alpha is low. You can use a tangent function to compute the offset in the head's space.


Edited by Dawoodoz, 08 May 2013 - 01:59 AM.

My open source DirectX 10/11 graphics engine. https://sites.google.com/site/dawoodoz

"My design pattern is the simplest to understand. Everyone else is just too stupid to understand it."


#3 Hodgman   Moderators   -  Reputation: 31938

Like
2Likes
Like

Posted 08 May 2013 - 08:31 AM

If you assume the eyes are a sphere, and you can calculate the UV coordinates of any point on the sphere, then you just need to normalize your direction (to turn it into a point on the sphere), and then transform that point into UV-space. Then subtract the UV coordinates of where the pupils are "at rest", and you've got your UV offset.

#4 Kryzon   Prime Members   -  Reputation: 3314

Like
0Likes
Like

Posted 08 May 2013 - 12:25 PM

You can use a tangent function to compute the offset in the head's space.

Could you elaborate on this?

What would you be comparing to get the tangent?

 

 

EDIT: On Hodgman's suggestion, there's code to calculate the UVs of a point on a sphere based on a normalized direction (i.e: a radius connecting the center of the sphere to the point where you want to find the UVs). It's from the wikipedia article on UV Mapping:

 

761ef477fca2de40aed0cbbae3cbf9ca.png

ad415e568bc911ec29c8233d7c26bef2.png

 

So I could take the vector from [center of eye] to [object being looked at], normalize it and use that as d.


Edited by Kryzon, 08 May 2013 - 12:57 PM.


#5 Dawoodoz   Members   -  Reputation: 331

Like
1Likes
Like

Posted 09 May 2013 - 03:30 AM


You can use a tangent function to compute the offset in the head's space.

Could you elaborate on this?

What would you be comparing to get the tangent?

 

 

EDIT: On Hodgman's suggestion, there's code to calculate the UVs of a point on a sphere based on a normalized direction (i.e: a radius connecting the center of the sphere to the point where you want to find the UVs). It's from the wikipedia article on UV Mapping:

 

761ef477fca2de40aed0cbbae3cbf9ca.png

ad415e568bc911ec29c8233d7c26bef2.png

 

So I could take the vector from [center of eye] to [object being looked at], normalize it and use that as d.

 

It all depends on how you projected the textures in the first place and flat eyes will always be a rough approximation. if you want real precision, you can rotate 3D spheres instead.


My open source DirectX 10/11 graphics engine. https://sites.google.com/site/dawoodoz

"My design pattern is the simplest to understand. Everyone else is just too stupid to understand it."





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