Page 1 of 2

ssRay - my OWN path tracing program

Posted: Tue Aug 19, 2008 12:22 am
by Severi
Hi all!

A short story about me. I've using POVRay since late 80's. This year I decided to learn some C++ and programmed a simple physics simulator. Yeah, it worked but was a bit boring. Then I read POVRay forums and noticed a few posts about path tracing (someone there made a patch to convert POVRay into path tracer). The images looked a lot better than anything normal POVRay can produce so I got interested.

The algorithm looked quite simple so I wanted to try if I can do it also. Then I started programming ssRay which you can find here:

http://www.saunalahti.fi/~sevesalm/ssRay/ssRay.php

It is still lacks some fundamental features but the images look promising - IMO!

Now I'm trying to figure out how to handle light sources. Now light sources are just objects with emission. I simply trace the ray and if it hits emitting object, it returns...well...light. I was thinking that you could "scan" lightsources separately at each bounce for direct lighting. The problem is I don't know how to sample them.

For example:
- I hit a diffuse surface.
- I have a cube light source which is partially visible.

How do I take a random point on that cube to check the actual lighting without affecting bias. I guess I simply cannot generate a random point on the surface of the cube. And how about spherical light source or a general unbiased method?

Yeah, then I have to program transformations (I suck at matrices) and acceleration structures. Then I'm partially happy. :lol:

But anyway, this is a fun project and images made with LuxRender and Indigo Renderer just motivates to continue.

Posted: Tue Aug 19, 2008 2:53 am
by pixie
:shock: :shock:

Neat!

Posted: Tue Aug 19, 2008 4:34 am
by vmuriel
Nice man.

Posted: Tue Aug 19, 2008 6:40 am
by alex22
Try using barycentric coordinates. If you have a triangle with points A, B and C, then you can define a point P on the surface as:
A*w+B*u+C*v=P
where w+u+v=1
So what you do is set two random numbers for two of the variables u,v or w and set the third variable so they all add up to 1. Then add them together as shown above to create P.
There might be faster ways, but it should work. Used it for my own Raytracer, but there for triangle intersection testing.

edit: Just thought about the random numbers. If it set for example u to 0.663 and v to 0.532 you'd have a problem because the sum is already above 1 and P won't be in the triangle area. So if you work with random numbers between 0 and 1 you should adjust the second random number so it can't be bigger than the first.
For example u:=randomnumber
v:=randomnumber*(1-u)
w:=1-(v+u)

Posted: Tue Aug 19, 2008 7:08 am
by matsta
Wow very nice! those look amazing! great job man!

greetz
mat

Posted: Sat Aug 23, 2008 9:30 pm
by lycium
you should consider posting on ompf instead of hijacking indigo's forum :/

Posted: Sat Aug 23, 2008 10:59 pm
by PureSpider
This is the off-topic-area so calm down lol

Posted: Fri Sep 19, 2008 10:41 pm
by Severi
Yeah, if off-topic isn't on-topic on off-topic, then what is?? :lol:

This is how I do it now on spherical light:

1. Choose a random point on the sphere. (Actually only on the surface that could be visible)
2. Take a radiance reading from that point if it is really visible.
3. Scale the value based on the ratio of solid angle of the visible sphere surface and hemisphere. This is the answer I was looking for.

The speedup after evaluating direct lighting was 20x-40x! So this was worth it.

The next thing is to make this work on other shapes besides spheres. The problem is that it is very difficult to sample a direction on a projected solid angle if the shape is something else than a sphere. But I think I could do this: bound every shape by a sphere and sample that instead. Some rays then miss the actual shape but that is not a big problem.

I hope I am on the right tracks here.

Posted: Sat Feb 21, 2009 11:55 pm
by Severi
Some new images after I implemented kd-tree which is working quite well now.

A simple city with DOF:

Image

And the Stanford Dragon, in silver and in greenish glass:

Image

Posted: Sun Feb 22, 2009 12:11 am
by PureSpider
Those images look amazing!
Keep it up!

Posted: Sun Feb 22, 2009 7:04 am
by neo0.
Are there any plans for a user interface?

Posted: Sun Feb 22, 2009 9:31 am
by PureSpider
Did you even bother reading the site of the program?
http://www.saunalahti.fi/~sevesalm/ssRay/Features.php wrote:UI which lets the user select the rectangle area being rendered for faster preview

Posted: Sun Feb 22, 2009 9:44 am
by Kram1032
Pretty nice stuff :D Keep it up :)


OT: What happened to all the other raytracers, mentioned in the past here?
I mean from some you hear things from time to time/they actually got pretty famous, but most more or less............ disappeared...

Posted: Sun Feb 22, 2009 2:28 pm
by Big Fan
almost like this one did ;)

Posted: Sun Feb 22, 2009 3:14 pm
by neo0.
UI which lets the user select the rectangle area being rendered for faster preview
OK. Um.. Yeah.. :roll: That doesn't say much. I meant a UI that can do things more than that.. Like all the things you would need to actually use the program.. Like object translations (move, scale, rotate, etc.) and materials.

Right now SSray looks to be a fantastic renderer, but it still obviously a front end, some way for the user to interact with it.

So I guess about now I should be chipping in with did you even bother to read my post? :wink: