Jump to content
  • Advertisement
Sign in to follow this  
Luonnos

Questions about ray tracing

This topic is 3719 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm about to start writing a ray tracer and I have a few questions. Should I store my rays and vectors as a starting point and 2 angles, or as a starting point and a point to signify direction? I want to have reflections, refractions, ray-sphere intersections, and ray-triangle intersections, but use sin and cos as little as possible. For a computer image, what should the angle of a human viewing frustum be? How do you express texture coordinates on a sphere? I'm pretty new to graphics programming. Thanks for the help.

Share this post


Link to post
Share on other sites
Advertisement
Hi

I think this series of articles written by Jacco Bikker answer most of your questions, and it's a good starting point. I've learnt much from them.

Good luck for raytracing

Share this post


Link to post
Share on other sites
If you have any questions after reading them, feel free to post here again. I am monitoring all topics related to ray tracing. :)

- Jacco.

Share this post


Link to post
Share on other sites
Quote:
Original post by Almonsin
Hi

I think this series of articles written by Jacco Bikker answer most of your questions, and it's a good starting point. I've learnt much from them.

Good luck for raytracing


We all learned much from them :-) Anyway, as a fast answer, use a starting point and a normalized (unit length) vector as the ray direction. This is the representation used 90% of the times in a raytracer...
In addition, someone adds a few other infos: length of the ray (i.e. to specify the max distance to take into consideration), time (for example for motion blur) and so on.

Share this post


Link to post
Share on other sites
I started writing the ray tracer and I'm getting (mostly) correct images. However, around the edges of two walls meeting rounding error is causing pixels to randomly decide which wall they are on. Is there any way to prevent this? Maybe a different ray-triangle intersection test?

Share this post


Link to post
Share on other sites
Dunno, which test is Phantom (Jacco) using ... but you can always swap from float precision to double precision. Anyway it'll slow down your tracer.

I personally recommend barycentric coordinate intersection test from here:

http://www.cs.virginia.edu/~gfx/Courses/2003/ImageSynthesis/papers/Acceleration/Fast%20MinimumStorage%20RayTriangle%20Intersection.pdf

Which is IMHO pretty fast to beginning. Of course there are many ways how to speed this up ... SIMD 2x2 ray packet, etc.

Share this post


Link to post
Share on other sites
Thanks Vilem, I just had to put in a short section of code which removes the randomness near the edges. It checks if the depth to two triangles is very close, if it is, it uses the triangle that has the lowest index number in the array of triangles.

I also have mirror reflectance on some surfaces, but the lack of shading makes it look like bad transparency. Here's a picture of a Cornell box with a reflecting cube on the floor (it looks wrong, but it's technically right)

http://i294.photobucket.com/albums/mm95/Luonnos/rayTracerScreenShot1.jpg

It's a 500 by 500 scene with four times supersampling and 30 triangles.

Share this post


Link to post
Share on other sites
Sorry for 2 posts in a row, but I'm working on refractions now and (maybe) having some problems. I've changed my scene so that the two side walls are reflective and the small box is refractive. It has Beer's law on, and it's black. I'm trying to make Snell's law work, but it's looking kind of weird. It his an index of refraction of 1.33 and the air has 1.0003. Does this look right?

http://i294.photobucket.com/albums/mm95/Luonnos/rayTracerScreenShot3.jpg
(the quality is really bad from photobucket)

Here is my (psuedo) code for Snell's law:

double n;
if(rayIsRefracting) n=objectRefractIndex/airRefractIndex;
else n=airRefractIndex/objectRefractIndex;
double c1=-dot(ray.rayDirection,objectNormal);
double c2=sqrt(1-n*n*(1-c1*c1));
if(c2>0){
refractRay.rayDirection=(n*ray.rayDirection)-(n*c1+c2)*objectNormal;
}else{
refractRay.rayDirection=ray.rayDirection;
}

There are some weird things in the image. Are they right? Is my code?

Share this post


Link to post
Share on other sites
Ingo Wald's publications

you might find this page interesting

also have a look at
"Plücker coordinates"
and triangle structure that store neighbour triangle informations

e.g.: with plücker coordinates and neighbouring triangle information you only need to perform one ray-edge test per triangle

I need a dual quad core sometime soon to write my own raytracer


Do you know any resources about how to raytrace large volume datasets efficiently?
I am currently working on a voxel based terrain approach that lets you deform almost anything and I want to combine it with a ray tracer somewhen later

The voxels are run length encoded to save memory

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!