Intersection Return back
(L) [2007/10/03] [tgm] [Intersection Return] Wayback!First of all: Hi @ all!
This is a great Forum, and I was watching it for a while, without being registered.  
I was developing a little Raytracer, until I figured out I have some problems with the overall design. I just was returning the closest intersection.
Which gave me a hard time with transparent Shadows and stuff. I wonder how you guys Return the intersections? Do you return just the best, or all (if so would you use a vector or a map?? I guess a Map would be fitting better) or just the first two or three ones??
greetz tgm
(L) [2007/10/03] [lycium] [Intersection Return] Wayback!heya tgm, welcome to the forums :)
returning the closest intersection: where in the code do you mean? generally one has 2x intersection methods at the scene and object level, for ray tracing (nearest intersection) and ray testing (checking for occlusion along a ray segment).
transparent shadows: i suppose you mean something like tinted glass? the way to do that properly is to make the surface transmissive and define some absorption coefficients (rgb) for beer's law (since one doesn't have infinitely thin surfaces in real life). this doesn't require returning multiple intersections, you just compute the surface scattering, and trace another ray.
(L) [2007/10/03] [tgm] [Intersection Return] Wayback!Thx for the fast help..
Ok, I guess the thing was, that I just used one Intersection code for an Objekt, that is used for shadow testing and occlusion testing...
If I would do a function that instead of returning a intersection, returns a value that will be multiplied with the light intensity, everything should work, right??
I was thinging about something like this, but somehow I was sure this would be a bad idea^^[SMILEY Rolling Eyes]
gretz TGM
(L) [2007/10/03] [lycium] [Intersection Return] Wayback!the best way is to do both (methods for nearest intersection and colour from a given ray).
so in your "scene" class, you have a method that returns a nearest intersection given a ray, a method that checks if an intersection exists along a given ray segment (really this is a good idea for speed reasons, but you can ignore it for now), and a method that returns the colour given a ray.
so typical usage is:
1. call ray-colour method to give you the colour for your eye ray.
2. it calls the nearest-intersection method to get the nearest intersection for all scene objects.
3. it calls all the objects' nearest-intersection methods to get their nearest intersection, taking the minimum of all.
4. it then calls the nearest object's normal-getting method, and passes this nearest intersection info back to the ray-colour method.
5. ray-colour method now does lighting, like for example checking rays from the intersection point to all light sources for occlusion before adding its contribution.
6. suppose it hit a 20% reflective surface, then it recursively calls the ray-colour method given the intersection point and the reflection direction, adding 20% of its result to the return value. (refraction is similar)
i suppose that's your basic ray tracer in a nutshell. tbh, you should first read some basic tutorials before posting here ;) for example check out [LINK http://fuzzyphoton.tripod.com/]
(L) [2007/10/03] [tgm] [Intersection Return] Wayback!^^ I'm not that a newbe.. [SMILEY Embarassed]
[LINK http://www.c-plusplus.de/forum/viewtopic-var-p-is-1260876.html]
my old one got moste of this stuff, and he is doing preety much what you said^^
Render device->(sends a ray) to ->scene(get the best on from every object) returns an Intersection class.
The intersection holds inforamtion about Position, normal, material and objekt of the intersection.
The Render device now calls the intersections material getColor function, that will do all lighting calculation and return the color of the visible pixel.
For getColor  function there are submaps which a material can use for example to get specular component, mirror component, light influence etc...
thats pretty much it.. It is very oop structured and so easily expendable.
back