Sign in to follow this  

How does ray tracing works?

This topic is 4236 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

Guest Anonymous Poster
So you cast the rays from the camera onto the world bouncing on objects until it hits a light source?
Is there an opposite technique of casting rays from light source and seeing if it hits the camera?

Share this post


Link to post
Share on other sites
Quote:
Is there an opposite technique of casting rays from light source and seeing if it hits the camera?


sure but it's rarely used because you have to shoot billions of rays to get a properly lit scenes.

regards,
m4gnus

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster

Is there an opposite technique of casting rays from light source and seeing if it hits the camera?


The name 'raytracing' actually refers to what you just described. What we usually mean with 'raytracing' is 'backward raytracing'. The main difference between the two (rendering times aside) is that the raytracing can also reproduce effects like indirect illumination (see also global illumination) and caustics. These effects are most often achieved with GI algorithms like Radiosity (for indirect illumination) or photon tracing (for both).

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:


The name 'raytracing' actually refers to what you just described. What we usually mean with 'raytracing' is 'backward raytracing'. The main difference between the two (rendering times aside) is that the raytracing can also reproduce effects like indirect illumination (see also global illumination) and caustics. These effects are most often achieved with GI algorithms like Radiosity (for indirect illumination) or photon tracing (for both).



the one is forward raytracing and the other one is backward raytracing but some people keep arguing which is which...

regards,
m4gnus

Share this post


Link to post
Share on other sites
Quote:
Original post by The C modest god
Can someone explain me the idea behind ray tracing and why is it so slow?

Thanks in advance.


Its slow because for each pixel your firing a ray into a scene & you then have to keep track of that ray as it propogates around the scene. Typically a basic raytracer will do the following:

* Note - very abstract description!

1.Fire ray through pixel into the scene from the eye(x,y) position.

2.Test for intersection -> If it intersects with an object how should the ray behave? -> If object is reflective generate new ray (usually through recursion) and cast in the reflected direction from the point of the parent rays intersection. Now follow this ray and repeat 2 until recursive limit is reached. make note of each objects colour because this will be used to determine final colour of each pixel at the eye(x,y).

3. Calculate local illumination -> recursive ray tracing (backwards) can only model specular lighting therefore to "simulate" diffuse lighting you need to fake it through a local illumination model (e.g. Phong Lighting (not phong shading - thats different)).

4. Set eye(x,y) pixel colour to be the culmination of each ray spawned from the initial eye(x,y)

So for a scene resolution of 1024 x 768 @ 1 pixel per ray (more if you use supersampling) you'll be firing at least 786, 000 + rays and thats not including the rays spawned from parents where a reflective surface has been encountered.

You can speed it up using spatial subdivision techniques like octrees or process more than one ray at a time.

Regards,

Ste

Share this post


Link to post
Share on other sites
It is also be possible to instead of tracing a ray for each pixel, instead trace a ray for a neighbour of pixels.

I've never tried this but it sounds like an obvious optimisation. :)

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
So you cast the rays from the camera onto the world bouncing on objects until it hits a light source?
Is there an opposite technique of casting rays from light source and seeing if it hits the camera?


MaxPayne is working on something like this, I believe. Forward ray-tracing in order to generate the image itself.

Usually forward ray-tracing is used to preprocess an approximation to the physical light transport throughout the scene, and not actually to draw it per se. This is referred to as global illumination sometimes.

One starts by casting a few (thousand) rays from the light source(s). As each ray travels through the environment, its energy is absorbed by matter that it comes into contact with.

As the absorbed light energy increases throughout the scene, it becomes lit in essence.

The more rays / the longer the light transport simulation runs, the more accurate the final solution appears.

Then in a second pass, the light energy map is used as a colour texture during the traditional backward ray-tracing method.

I'm pretty sure that it was Half Life 2 that used this preprocessed light energy map method for its static lighting recently.

Even Quake used this method. :)

Share this post


Link to post
Share on other sites
[quote]Original post by taby
Quote:
Original post by Anonymous Poster
...

I'm pretty sure that it was Half Life 2 that used this preprocessed light energy map method for its static lighting recently.

Even Quake used this method. :)


Quake 1 does not use radiosity for the lightmaps, but quake 2 does.

Share this post


Link to post
Share on other sites
I know ray tracing is slow but how would i go about doing it at a faster rate?
Like i see in 3ds max Ray Tracing an image so you can have reflections can take a considerable amount of time

but how are they doing the same task 50 times a second in games like counter striker source or that Project Offset they are working on the quality is awesome yet to render something like that in 3ds it takes ages so whats different?

Share this post


Link to post
Share on other sites
There are tons of ways to get ray tracing faster. Have a look at our forum at www.ompf.org/forums for detailed discussions.

Currently the fastest ray tracers cast more than 10M rays per second through a scene consisting of several thousands of polygons. We achieved frame rates of 5-8 on scenes of 80k triangles, at a resolution of 1024x1024.

The basic ingredients to achieve this:

- Highly optimized spatial subdivision (kd-tree);
- Packet tracing: Using SIMD to trace 2x2 or 4x4 rays at once;
- Code and data that respects the cache;
- Multi-core processing.

Currently our pictures aren't pretty (we are optimizing the basic process), but the code is extremely fast. Still nowhere near fast enough for games though. The Cell processor might be able to ray trace a game. It's architecture is very suitable for real time ray tracing.

Share this post


Link to post
Share on other sites

This topic is 4236 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this