Thursday, November 17, 2011

Ready for Radiance Gathering!

Success! I was able to pass large amounts of photon data down to the shader.

This was the part I was worrying about for a while. When I initially had photon casting and rendered them on the shader, the performance was terrible (10-15 fps). I only had about 50-100 photons, which is nowhere near enough for a good render, and I didn't even have incident angle data - I was only passing down positions and color (power). This worried me. This week, with a completed photon scattering step, I started passing down the complete photon data (position, color, and incident angles) in much larger numbers, but I did not render them out. When I first ran it, I was expecting my laptop to burst into flames. However, it was completely okay. So I proofed that the shader can handle large amounts of floating point data without failing. This is a huge relief, and I am now ready to move onto radiance gathering on the shader! This is exciting!

The numbers I was working with was:
  • 500 photons initially cast from light source
  • ~1030 photons total after photon scattering
  • 3 attributes per photon: position, color (power), incident angle
  • 3 floats per attribute (each type of vec3)
  • ~1030 x 3 x 3 = ~9270 floats passed to shader
I also figured out a way to modify constant values on the shader. GLSL ES requires that arrays have a constant size (i.e., known by shader at compile time.) Up until now, I have been hard-coding array sizes as constants by hand (for shape count and photon count). With a Russian Roulette photon scattering, a variable array size is necessary since the total number of photons cannot be determined. I resolved this by modifying the shader code (the actual shader program string) using Javascript before it is used by WebGL. This works beautifully and I am now able to get a variable sized array for photons and for shapes.

No comments:

Post a Comment