Raytracer (8)

1 Name: #!/usr/bin/anonymous : 2006-08-01 22:17 ID:Woi2Qqh0

How do I made a raytracer?

2 Name: #!/usr/bin/anonymous : 2006-08-01 22:55 ID:Heaven

You need to shot rays.

3 Name: dmpk2k!hinhT6kz2E : 2006-08-02 04:02 ID:Heaven

Best summary ever.

This is like asking how to build a car. Where to start?

4 Name: #!/usr/bin/anonymous : 2006-08-02 04:29 ID:ucNRsQ2C

For each pixel in image {
Create ray from eyepoint passing through this pixel
Initialize NearestT to INFINITY and NearestObject to NULL

For every object in scene {
If ray intersects this object {
If t of intersection is less than NearestT {
Set NearestT to t of the intersection
Set NearestObject to this object
}
}
}

If NearestObject is NULL {
Fill this pixel with background color
} Else {
Shoot a ray to each light source to check if in shadow
If surface is reflective, generate reflection ray: recurse
If surface is transparent, generate refraction ray: recurse
Use NearestObject and NearestT to compute shading function
Fill this pixel with color result of shading function
}
}

5 Name: 4 : 2006-08-02 04:30 ID:ucNRsQ2C

Oops, kareha ate the indentation. I C&Ped that from http://en.wikipedia.org/wiki/Raytracer#Algorithm:_classical_recursive_ray_tracing go there

6 Name: #!/usr/bin/anonymous : 2006-08-03 22:51 ID:Woi2Qqh0

>>5
Thanks for the link. The ray-sphere intersection article helped.

7 Name: #!/usr/bin/anonymous : 2008-01-29 00:00 ID:adKdsLgL

8 Name: #!/usr/bin/anonymous : 2008-02-01 13:26 ID:VhMZ1sug

Incidentally the book they link from there:

http://www.amazon.com/Computer-Graphics-Principles-Practice-2nd/dp/0201848406

It's very good. I learned all this stuff on the first edition of said book.

This thread has been closed. You cannot post in this thread any longer.