# Thread: Raytracing steps

1. ## Raytracing steps

Originally Posted by jdarling
Hey Nitrogen, any chance you would post up a simple sample application showing this off. As I said, I've never played with ray tracing, but I'd love to see code around it
Hey thanks! It's one of those projects that I didnt want to post up in it's original state because it's so inflexible and horribly stale... I had grand schemes for making it like a little 3D modeller with the 4 viewport business etc. But it never got past that point. Yea I used the Flipcode articles about it.. Really good tutorial that.

The image above took 3.2 seconds to render 640x480 on my AthlonX2 4200.

Yea, raytracing isnt that big of a visual difference from good pixel shaders (and the pixel shaders run a hundred times faster), but you can still use it for small apps like building webpage buttons or rendering logos etc.

2. ## Raytracing steps

There is a realtime ray tracing version of quake.

http://www.q4rt.de/

http://www.theinquirer.net/default.aspx?article=36452

3. ## Raytracing steps

to Nitrogen >> Have you solved a sampling(antialiasing) in your raytracer ?

4. ## Raytracing steps

[pascal]
Ray.Dir := Normalise(VecSub(Pos, cam.Origin));
Col:= Raytrace(Ray, 0 , HitPrim, Ch);
if (LastPrim <> Ch) or (LastPrims[Rx] <> Ch) then //If last hit primitive is different to this one
begin
For SubX := -1 to 1 do
for SubY := -1 to 1 do
if (SubX <> 0) or (SubY <> 0) then //Already sampled the center point.
begin
D := Pos;
D := VecAdd(D,VecMult(A, SubX*0.5));
D := VecAdd(D,VecMult(B, SubY*0.5)); //Adds a slight offset in 3D space
Ray.Dir := Normalise(VecSub(D, cam.Origin));
AccCol:= Raytrace(Ray, 0 , HitPrim, Ch);
Col := VecAdd(Col, AccCol); //Add subsample to accumulator color

end;
P^ := Rgb(round(Col[0]*255/9), round(Col[1]*255/9), round(Col[2]*255/9)); //average all 9 subsamples.

end
else
P^ := Rgb(round(Col[0]*255), round(Col[1]*255), round(Col[2]*255));
[/pascal]

Basically you just send off 9 rays for 1 pixel. Each with a slight offset.
The trick comes when you record the last hit primitive, because you dont need to antialias pixels inside primitives, only on the boundaries between primitives.

5. ## Raytracing steps

The blue pixels are the only ones that are antialiased: Note how you must antialias both the primitive boundaries and the shadow boundaries.

Heres that scene again without the blue:

One problem with this approach is that you can only have an antialiased area of one pixel between primitives or shadows.

6. ## Raytracing steps

thank you nitrogen again .

7. ## Raytracing steps

Not a problem , post your results here for everyone to see.

Raytracing is one of the more beautiful aspects of programming.

8. ## Raytracing steps

nothing special in my render :-) Just simple test like this :

It will be looong way until my render will be able to do something like this :-)

It is unbelievably what today renderer's like Maxwell render or VRay can do. Really amazing things.

9. ## Raytracing steps

Can you do refraction yet?

10. ## Raytracing steps

yes, I have implemented refraction algorithm, from what I see on the flipcode website, tere is raytracing tutorial...
however, I need to implement transparency to objects...
I think refraction is more visible when the object is little transparent...
I try to do some other things now, exactly improve the speed of rendering...

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•