GRP1 discussion

Programming topics can be found here.
120448
Posts: 11
Joined: Mon Sep 30, 2013 1:00 pm

Re: GRP1 discussion

Post by 120448 » Mon Oct 28, 2013 3:01 pm

Awesome stuff Tom!

This is my BVH renderer that I made today:
Image
Marc Peyré
Programmer - 2nd year
http://twirlbound.com

bikker
Posts: 67
Joined: Fri Sep 27, 2013 12:40 pm

Re: GRP1 discussion

Post by bikker » Tue Oct 29, 2013 12:03 pm

Here's an interesting site I ran into a while ago:
https://www.shadertoy.com/
It's basically an online IDE for writing shaders, and people use it to build little demos that run entirely on the GPU. Quite a few of them are ray tracing related, and the people that write them are *very* skilled. You might be able to pick up a thing or two (like efficient ray/sphere intersection). Code for all shaders is available, and you can actually modify and re-run on the fly. :)
-Jacco.

121649
Posts: 6
Joined: Sun Sep 29, 2013 6:53 pm

Re: GRP1 discussion

Post by 121649 » Thu Oct 31, 2013 12:19 am

Image

Some people really are assholes when it comes to parking their car.
Hello, I am replicant #121649.

bikker
Posts: 67
Joined: Fri Sep 27, 2013 12:40 pm

Re: GRP1 discussion

Post by bikker » Thu Oct 31, 2013 10:20 am

Is that 12fps for that scene? Nice!

121649
Posts: 6
Joined: Sun Sep 29, 2013 6:53 pm

Re: GRP1 discussion

Post by 121649 » Thu Oct 31, 2013 8:47 pm

bikker wrote:Is that 12fps for that scene? Nice!
No, sadly. The fps was incorrect because my job manager is broken. :(
Hello, I am replicant #121649.

120448
Posts: 11
Joined: Mon Sep 30, 2013 1:00 pm

Re: GRP1 discussion

Post by 120448 » Thu Oct 31, 2013 11:54 pm

I have a question about the energy redistribution regarding importance sampling. As you no longer scale the energy with N dot L, the energy of all the rays will never be below 1. It would only increase due to Russian Roulette and this causes very bright spot in corners where the rays bounce a lot. My question is, what factors are affecting the energy after each bounce?
Marc Peyré
Programmer - 2nd year
http://twirlbound.com

bikker
Posts: 67
Joined: Fri Sep 27, 2013 12:40 pm

Re: GRP1 discussion

Post by bikker » Fri Nov 01, 2013 10:42 am

120448 wrote:I have a question about the energy redistribution regarding importance sampling. As you no longer scale the energy with N dot L, the energy of all the rays will never be below 1. It would only increase due to Russian Roulette and this causes very bright spot in corners where the rays bounce a lot. My question is, what factors are affecting the energy after each bounce?
After each bounce, you still scale by N dot L. However, when using IS, you also scale by 1/PDF, or in English, the probability of selecting a direction. Since the PDF is proportional to N dot L, these cancel out, and ray energy is left unmodified, except for the 'normalization factor' for the PDF: Integrating N dot L yields a surface of PI, so you need to divide by PI.

Obviously this is only true for diffuse bounces; for specular bounces things get more tricky. It gets worse when the BRDF is a blend of diffuse and specular, or a blend of pure specular (mirror) and diffuse and so on. In that case, you may want to actually perform both steps: scale by N dot L, divide by PDF, to make sure everything remains correct. That's what I do in Arauna2.

Scaling also happens for explicit light rays (direct connections to the light source); in that case, you need to calculate the probability of hitting the light source using a random ray. This is proportional to the dot between the light surface normal and the light ray, scaled by N dot L, and scaled by 1/r^2.

Russian roulette is also a form of IS, and therefore rays that are not terminated are scaled by 1/P, where P is the survival probability. IS is everywhere. :)

Due to all this scaling, some paths can transfer a lot of energy, but this compensates for all the paths that are not generated and directions that are seldomly considered. Especially long paths can transfer a lot of energy, and when these paths stumble upon a light source, you get bright spots ('fireflies'). There's not much you can do about that, but if you loosen the requirements in terms of mathematical correctness, you have some options:

1. Filter the final image: any pixel that deviates too much from it's neighbors in terms of brightness is toned down;
2. (better:) Clamp max path transport: any path that brings back more than a certain amount of energy is toned down. This is what VRay3 does, and Arauna2 also uses this trick. Arauna2 has a slider that lets you specify the clamp value. A low clamp value tends to kill caustics, but a high clamp value results in fireflies.

So you're doing nothing wrong, and fireflies are a normal result... Ultimately they should go away, but if you can't wait, try the clamp.

It gets really beautiful when you start doing 'multiple importance sampling' by the way, but the theory is hairy. One example for direct light connections: a direct light connection could theoretically be achieved in two ways. One is the direct connection (PDF is N dot L times NL dot L times 1/r^2); the other is through a regular bounce, by evaluating the BRDF. For small distant lights, option 1 is the best, since a bounce is unlikely to hit the light. However, for large nearby lights, sometimes option 2 is better. For a single direction L, you can evaluate both, and then combine them using the power heuristic, yielding an optimal blend between the two. This greatly helps for wall sections near a large ceiling light. You can take MIS to extremes using bidirectional path tracing, where paths from the light and to the light are combined using the power heuristic to always use the optimal PDF. But that's really something for another course. :)

- Jacco.

User avatar
121068
Posts: 3
Joined: Sat Sep 28, 2013 4:19 pm

Re: GRP1 discussion

Post by 121068 » Mon Nov 04, 2013 1:22 pm

Hey all, I am doing the final bits and pieces of my path tracer, however I noticed after rendering a Cornell box (for about 1 hour and 40 minutes) that a strange green horizontal section on the right wall starts to show.

Image

It has a hard edge and is a bit ugly. I have no clue as to why this appears like this. Any ideas? The annoying thing is that it becomes visible after rendering for about 30 minutes, so it is difficult to debug.
Bas van Zutphen
2GA-2PR

bikker
Posts: 67
Joined: Fri Sep 27, 2013 12:40 pm

Re: GRP1 discussion

Post by bikker » Mon Nov 04, 2013 9:26 pm

Are you using an alternative to the standard random generator?
Also: it could be an indirect shadow of light bouncing off the red wall, occluded by the large block... It seems to match the height of that block.
On the other hand: it appears to be brighter, and gets darker again at the height of the smaller block. I think you need to check your random number generator. :)

User avatar
121068
Posts: 3
Joined: Sat Sep 28, 2013 4:19 pm

Re: GRP1 discussion

Post by 121068 » Mon Nov 04, 2013 10:47 pm

I use "George Marsaglia's The mother of all random number generators" to get my random numbers. A number of sources say it is pretty good and fast.

http://www.stat.berkeley.edu/classes/s243/mother.c

I believe I have fixed the issue by the way. When I do a random bounce off a diffuse surface instead of choosing a random direction in a box I use a hemisphere instead. It is probably a little bit slower, but it does look better and it seems to solve the strange wall issue as well. This is the result:

Image

I also changed the Cornell box model slightly: the lamp is now a little lower than the ceiling, which means it emits light towards the ceiling making the area around the lamp a bit brighter. :)
Bas van Zutphen
2GA-2PR

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests