Jump to content

  • Log In with Google      Sign In   
  • Create Account

Applying texture on a sphere [raytracing]


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

#1 Frénésie   Members   -  Reputation: 101

Like
0Likes
Like

Posted 31 May 2012 - 07:35 AM

Hi guys !

I'm doing a raytracer in C. I have to apply textures on a sphere. I have the coordinates x, y,z where my ray hits the sphere, the radius of the sphere and a function that returns the color of the pixel of the texture for a given x and y.

Do you have a formula to get the x,y of the texture from the x,y,z of the sphere and the radius r ?

Ty !

Sponsor:

#2 cignox1   Members   -  Reputation: 723

Like
0Likes
Like

Posted 31 May 2012 - 08:19 AM

I don't have my code at the moment, but I remember that there is a simple addition to the intersection formula that gives u,v parameters of the intersection point. You just have to specify a couple of vectors defining the orientation of te sphere.

Those uv can then be scaled/translated/rotated/clipped any way you want and in the end you do a get(u,v) on the texture (where u and v are presumably normalized so that 0 is completely left and 1 is completely right - same thing for top and bottom).

Hope this helps

#3 Frénésie   Members   -  Reputation: 101

Like
0Likes
Like

Posted 31 May 2012 - 02:48 PM

I have to specify a couple of vector to define the sphere ? On the 0.x axe and 0.y axe ? And is it on a cartesian reference ?

#4 Lil_Lloyd   Members   -  Reputation: 287

Like
1Likes
Like

Posted 31 May 2012 - 05:07 PM

This should be of some help...

http://www.flipcode.com/archives/Raytracing_Topics_Techniques-Part_6_Textures_Cameras_and_Speed.shtml

#5 cignox1   Members   -  Reputation: 723

Like
0Likes
Like

Posted 04 June 2012 - 05:16 AM

I have to specify a couple of vector to define the sphere ? On the 0.x axe and 0.y axe ? And is it on a cartesian reference ?

I think that you need to define at least the north (and perhaps even the west) vectors, so that rotations applied to the sphere reflect on the texture orientation...

#6 Bacterius   Crossbones+   -  Reputation: 9304

Like
0Likes
Like

Posted 04 June 2012 - 06:06 AM

Two words: spherical coordinates.
One link: sphere texture mapping.

The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

 

- Pessimal Algorithms and Simplexity Analysis





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