Forward ray tracing

Post updates of what you've been working on, make your development announcements, etc.

Moderator: samw3

User avatar
Calin
Posts: 354
Joined: Sun Dec 16, 2007 12:52 pm
Location: Moldova, Chisinau (now in Romania)

Forward ray tracing

Postby Calin » Thu Jan 08, 2009 11:19 pm

... I couldn't find anything on it on the internet though it's nothing over the edge.

Forward raytracing follows the natural model of light travel. The rays a cast from the light rather than from the screen. Since the resulting image is overlapping magnified versions of objects you need a 'human eye' device to get a focused image. The objects need to be built from spheres.
The reason why people don't use this method of rt is because most rays get scatered in all direction as in real life and only a small fraction falls on the capturing/exposure area.
However if you want to have multiple viewports (stereo vision, multiple users etc) on the scene this proves to be a good thing since you don't have to repeat the raytracing all over again for each viewport (each viewport does have to have it's own eye device though)
I will branch off a tread to log my work on the raytracer (to keep me motivated).
Last edited by Calin on Wed Feb 18, 2009 2:53 am, edited 2 times in total.
the problem is not to be stupid but to be stupid in the wrong places
____
Gorillaz
http://proimpact2.googlepages.com/1.jpg
User avatar
Calin
Posts: 354
Joined: Sun Dec 16, 2007 12:52 pm
Location: Moldova, Chisinau (now in Romania)

Re: Forward ray tracing

Postby Calin » Thu Jan 08, 2009 11:53 pm

There is heavy duty math you have to deal with in a ray tracer. I'm not a math guy so I will start by avoiding the math and take care of the logistic. I will use C++ to code.
the problem is not to be stupid but to be stupid in the wrong places
____
Gorillaz
http://proimpact2.googlepages.com/1.jpg
User avatar
JeTSpice
TALKer!
Posts: 2423
Joined: Sun Dec 16, 2007 10:39 am
Location: Coeur d'Alene, ID
Contact:

Re: Forward ray tracing

Postby JeTSpice » Fri Jan 09, 2009 9:44 am

forward ray tracing sounds very cool. So, all the rays are drawn first, and only once? Then the camera moves within a 3/d matrix or something?
User avatar
Calin
Posts: 354
Joined: Sun Dec 16, 2007 12:52 pm
Location: Moldova, Chisinau (now in Romania)

Re: Forward ray tracing

Postby Calin » Fri Jan 09, 2009 2:33 pm

If you draw the rays only once you can move your camera arround however you still need to test all the rays in the scene agains the camera to know which ones hit the camera (it can be optimised with a culling tree which you'd need to have in place anyways) and focus the image each frame since FRT produces diffuse images. The real problem though is that you can only have still enviroments. If you have dynamic objects you need to recast the rays to get the new position of objects.

[edit] I actually spent 15 minutes writing things when I realized what your question is actually about so this is just the last part )
the problem is not to be stupid but to be stupid in the wrong places
____
Gorillaz
http://proimpact2.googlepages.com/1.jpg
User avatar
JeTSpice
TALKer!
Posts: 2423
Joined: Sun Dec 16, 2007 10:39 am
Location: Coeur d'Alene, ID
Contact:

Re: Forward ray tracing

Postby JeTSpice » Fri Jan 09, 2009 2:54 pm

i'm thinking of a 3D dirty rectangles approach

first, the game does a forward ray trace

each frame, it refigures only those things which have dynamically moved

or do those rays effect everything on screen?
christo
Posts: 612
Joined: Sun Dec 16, 2007 11:38 am

Re: Forward ray tracing

Postby christo » Fri Jan 09, 2009 5:42 pm

My guess(since I have no experience with this) is that you would need to determine which rays are blocked and unblocked by the objects motion and determine if those rays hit another object and then update those objects accordingly. So not everything just the moving objects and those effected by the move. This is assuming the rays stop at the first object they come in contact to. reflective surfaces could be more difficult since there would be angle of reflection and additional objects effected.
User avatar
JeTSpice
TALKer!
Posts: 2423
Joined: Sun Dec 16, 2007 10:39 am
Location: Coeur d'Alene, ID
Contact:

Re: Forward ray tracing

Postby JeTSpice » Fri Jan 09, 2009 7:58 pm

most objects that are moving in a game don't have too much reflectivity. It's usually the environment. If this were possible, then you wouldn't have to raytrace each character with all the other ones, just with the environment. You'd still have to do shadows and light sources. Guessing...

At one time, i had an idea of using the camera like a cathode ray tube, scanning the environment, and displaying what it sees.
User avatar
Calin
Posts: 354
Joined: Sun Dec 16, 2007 12:52 pm
Location: Moldova, Chisinau (now in Romania)

Re: Forward ray tracing

Postby Calin » Sat Jan 10, 2009 2:57 am

[quote]2:54 pm

christo is right, you need to find and retrace the rays that fall on the object moving. In FRT shadows are byproduct they appear automatically where direct rays don't fall. (the area is darker compared to areas which recieve direct light, it's actually 100% black without indirect lighting)
Light sources is where the rays come from.


[quote]7:58 pm (1)

You are right. Actually you'd get something similar to video encoding. The pixels that don't move don't get updated, only those that move.

[quote]7:58 pm (2)

That's what common raytracing does.

This optimization is really puzzling (although it's only theory so far ) )

[Edit] you can get reflections (and radiosity) working as well. You can use a volume to find the rays passing through and retrace them
the problem is not to be stupid but to be stupid in the wrong places
____
Gorillaz
http://proimpact2.googlepages.com/1.jpg
User avatar
PFC
Posts: 633
Joined: Sun Dec 16, 2007 5:57 pm
Location: Canada

Re: Forward ray tracing

Postby PFC » Tue Jan 13, 2009 7:50 am

curious: how would you store all the rays in memory for future use?
User avatar
Calin
Posts: 354
Joined: Sun Dec 16, 2007 12:52 pm
Location: Moldova, Chisinau (now in Romania)

Re: Forward ray tracing

Postby Calin » Tue Jan 13, 2009 10:19 am

what do you mean?

[edit Jan 13 10:51 am]

you can use a list, array, etc. It's a data type.
the problem is not to be stupid but to be stupid in the wrong places
____
Gorillaz
http://proimpact2.googlepages.com/1.jpg
User avatar
PFC
Posts: 633
Joined: Sun Dec 16, 2007 5:57 pm
Location: Canada

Re: Forward ray tracing

Postby PFC » Tue Jan 13, 2009 5:02 pm

ok, I was just wondering if you where gonna use some sort of compression for it as that would be a HUGE amount of rays to make anything seem realisic purly from the rays captured.
I don't know how this would be implemented, but perhaps something like defining groups of rays over an area if they have similar or identical properties. Like a refective peice of flat metal would reflect the rays almost in a perfect equal prysm shaped beam, so a rectangle with a direction could be used to define all of those rays.

I'm interested in hearing how your going to go about rasterising in a system based on rays hitting the eyes since most wont and you need a very high concentration in order to get a decent picture
User avatar
Mene-Mene
TALKer!
Posts: 2760
Joined: Sun Dec 16, 2007 7:10 am
Location: Indiana, United States

Re: Forward ray tracing

Postby Mene-Mene » Tue Jan 13, 2009 7:07 pm

I hope you make it good... I wouldn't mind a ray tracer, just make it for blender...
M^2 out-
It's Time to get Terminal!
User avatar
jestermax
Posts: 398
Joined: Sun Dec 16, 2007 9:14 am
Location: Ontario, Canada

Re: Forward ray tracing

Postby jestermax » Tue Jan 13, 2009 8:48 pm

Hey! I just started writing a traditional ray tracer (eye to scene). You MAY want to make it so you can't say "i'm not a math guy" though since that's pretty much ALL a ray tracer is.
User avatar
samw3
Site Admin
Posts: 1239
Joined: Sun Dec 16, 2007 2:00 pm
Location: Toccoa, GA
Contact:

Re: Forward ray tracing

Postby samw3 » Tue Jan 13, 2009 9:00 pm

This sounds *extremely* CPU intensive. My best guess for an algorithm for this would be.
  1. Locate a texel that is a direct shot from the light source and trace a ray to it.
  2. Adjust the color and intensity of the light as well as the angle of the ray, refraction, etc.
  3. Determine the diffusion angle cone and find line-of-site texels in that cone and cast rays to each. Probably distributing the power over a curve. i.e. texels on the outside of the cone receive less power than those on the inside.
  4. Repeat from that point as if each of the diffused rays were a light source itself until the energy of the light falls below a darkness threshold.
  5. Do this mad hopping around for all light sources against all in-view texels again and again until all energy has been used up for each ray.
  6. Record any color strikes on the camera "retina", mix with previous strikes.
  7. display the camera's image
A cool effect would be instead of recording the strikes against the camera, record all the properties of each ray entering the lens of the camera, then by adjusting the focal point of the "retina" you could quickly re-render, adjusting the focus of the scene. That would look really cool I think.

Still, it seems like it could take years to render an image.. unless you did a net distributed thing.
User avatar
SSquared
Posts: 1351
Joined: Sun Dec 16, 2007 9:14 am
Location: The Beautiful Pacific Northwest
Contact:

Re: Forward ray tracing

Postby SSquared » Tue Jan 13, 2009 9:02 pm

You should watch Tron and the 'behind the scenes' DVD. Absolutely fascinating documentary on computer graphics. Much, if not all, of the graphics in the movie used ray tracing using the major computer graphics companies of the day. At the time, it was a big gamble to create the movie.
My quote: Have I mentioned I love C# and the iPad?
Another quote: Have I mentioned I love the iPad?
User avatar
JeTSpice
TALKer!
Posts: 2423
Joined: Sun Dec 16, 2007 10:39 am
Location: Coeur d'Alene, ID
Contact:

Re: Forward ray tracing

Postby JeTSpice » Tue Jan 13, 2009 9:52 pm

Oh, this whole time I was thinking about using eye-to-subject in a game, as in After you complete the raytracing matrices, you can move around in it in real time.
User avatar
SSquared
Posts: 1351
Joined: Sun Dec 16, 2007 9:14 am
Location: The Beautiful Pacific Northwest
Contact:

Re: Forward ray tracing

Postby SSquared » Wed Jan 14, 2009 1:02 am

That would be totally neat. Actually, Intel is currently working on real-time ray tracing video chips.
My quote: Have I mentioned I love C# and the iPad?
Another quote: Have I mentioned I love the iPad?
User avatar
Calin
Posts: 354
Joined: Sun Dec 16, 2007 12:52 pm
Location: Moldova, Chisinau (now in Romania)

Re: Forward ray tracing

Postby Calin » Wed Jan 14, 2009 6:19 am

// at Jan 13, 5:02 pm (2)

I'm not 'hitting' for commercial quality rt output.

// at Jan 13, 7:07 pm.

I don't think blender is on my mind right now.

// at Jan 13, 8:48 pm

Actually there's more physics than math to it
Last edited by Calin on Wed Jan 14, 2009 7:11 am, edited 2 times in total.
the problem is not to be stupid but to be stupid in the wrong places
____
Gorillaz
http://proimpact2.googlepages.com/1.jpg
User avatar
Mene-Mene
TALKer!
Posts: 2760
Joined: Sun Dec 16, 2007 7:10 am
Location: Indiana, United States

Re: Forward ray tracing

Postby Mene-Mene » Wed Jan 14, 2009 6:46 am

Physics is kind of a subdivision of math...
M^2 out-
It's Time to get Terminal!
User avatar
Calin
Posts: 354
Joined: Sun Dec 16, 2007 12:52 pm
Location: Moldova, Chisinau (now in Romania)

Re: Forward ray tracing

Postby Calin » Wed Jan 14, 2009 7:11 am

// samw3

(1)

You don't need texels. You just fire arbittray ray into 'nothingness'. Imagine your light source as a mirror ball used in discotheques. It disperses light rays evenly all across the room. Imagine a pannel in the room. That pannel is the capturing area, the closer you move the pannel towards the ball the more of the balls rays it will recieve.

(2)

Getting the image focused is actually mandatory because the panel records a diffse image .
the problem is not to be stupid but to be stupid in the wrong places
____
Gorillaz
http://proimpact2.googlepages.com/1.jpg

Who is online

Users browsing this forum: No registered users and 8 guests

cron