ssRay - my OWN path tracing program
ssRay - my OWN path tracing program
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.
But anyway, this is a fun project and images made with LuxRender and Indigo Renderer just motivates to continue.
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.
But anyway, this is a fun project and images made with LuxRender and Indigo Renderer just motivates to continue.
Last edited by Severi on Fri Feb 13, 2009 12:21 pm, edited 1 time in total.
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)
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)
Last edited by alex22 on Tue Aug 19, 2008 7:26 am, edited 2 times in total.
- PureSpider
- Posts: 1459
- Joined: Tue Apr 08, 2008 9:37 am
- Location: Karlsruhe, BW, Germany
- Contact:
Yeah, if off-topic isn't on-topic on off-topic, then what is??
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.
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.
- PureSpider
- Posts: 1459
- Joined: Tue Apr 08, 2008 9:37 am
- Location: Karlsruhe, BW, Germany
- Contact:
- PureSpider
- Posts: 1459
- Joined: Tue Apr 08, 2008 9:37 am
- Location: Karlsruhe, BW, Germany
- Contact:
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
OK. Um.. Yeah.. 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.UI which lets the user select the rectangle area being rendered for faster preview
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?
Who is online
Users browsing this forum: No registered users and 96 guests