timofy.co.uk - Blog
Project Completed PDF Print E-mail
Written by Tim   
Tuesday, 07 July 2009 18:55

I completed my project on refraction and caustics at the beginning of last month. I'll show some of the results of that here and try to give a brief overview of some things I used that I haven't mentioned before. First the pictures!

Refraction Caustic map Catacaustic

Refraction

Not much has changed from the refraction techniques I have already mentioned. The biggest improvement is that I adpated the algorithm by Shah et al. for caustics to instead intersect with local geometry. This got rid of the artifacts mentioned in the last post. It works in a similar way to that which Shah et al. describe, however you must also render the colour of nearby geometry to a texture so that the pixel shader for the refractive object can look it up. I experimented with various ways of getting around the problem of total internal reflection, but in then end I just opted to use pseudo- (one-sided) refraction for TIR.

I developed a couple of techniques to reduce some of the aliasing when the refracted rays don't index into the texture. These were

  • Edge testing
  • Bounded refraction deviation

Edge testing involves discarding pixels at the edge of the model. In essence the reason for this is because their normals are probably perpendicular to the viewing direction and so the refracted ray will not index the texture. Bounded refraction deviation involves making sure the refracted ray doesn't deviate too much from the incident light ray. This allows for higher refractive indices to be used.

 



Refraction with edge pixels Refraction without edge pixels

Caustics

For the caustics there were several intersting papers that I incorporated near the end. One mentioned a technique to achieve Gaussian blurring without a second pass, by Wyman. The basic idea was also mentioned by Jensen in his book 'Realistic Image Synthesis Using Photon Mapping'. I also implemented a new technique for generating a caustic map, dubbed Adaptive Caustics by Wyman. It is a clever idea that uses gemoetry shaders to move away from a regular grid of photons for sampling to generate the caustic map and instead creates photons where they will be useful.

I also adapted all the caustic stuff to reflective caustics (catacaustics) as shown in the images above. This was fairly straight forward however required some heuristic to discard certain 'photons' that weren't worth having. I accomplised this by

  • Discarding photons that land behind the view point
  • Discarding photons that have travelled too far

 

Overall it was an enjoyable project and I feel I achieved some nice results. To conclude here is an image showing the refraction and projected caustics:

 

Last Updated on Saturday, 17 October 2009 16:17
 
Variance Shadow Maps, Nearby Geometry and Better Caustic Maps PDF Print E-mail
Written by Tim   
Sunday, 26 April 2009 12:09

Recently I have implemented variance shadow mapping (VSM) so that the shadow map can be combined with caustics at a later stage. The paper by Donnelly and Lauritzen is available here. GPU Gems 3 also covers it well and the chapter is available online here. Note that you must filter the depth map to get results, I am using a filter width of 5. Below is a comparison of soft and hard shadows, click on the images for a full size picture.

Hard Shadows VSM Soft Shadows Aliasing

To improve the look of refractive objects I have implemented an algorithm based on the Shah, Konttinen and Pattanaik paper for caustics. Here they present an algorithm for finding the intersection with background geometry of non-coherent rays in a GPU shader. The method is described as a single step of an iterative algorithm. I have extended this by performing ten iterations to intersect with the background geometry. My implementation still has a few parts which "show through" into the environment map and still requires some improvement. Below is a picture from an angle that does not produce artifacts.

Lastly I have made some improvements to the the caustic mapping to allow higher resolution caustic maps at respectable frame rates. Below shows a caustic map with a resolution of 512x512 which is generated at a frame rate of about 55 whilst VSM and nearby geometry refraction is also rendered (click the images for full-size pictures).

 
Caustic Maps PDF Print E-mail
Written by Tim   
Tuesday, 31 March 2009 00:00

After a lot of tinkering with shaders I've finally managed to generate some reasonable caustic maps. I'm using a combination of tehniques to generate them. To generate the initial caustic map I use a method proposed by Shah, Konttinen and Pattanaik. This is a clever technique which first projects photons through every pixel in a fixed size texture (I have chosen 128x128). The photons are projected in the vertex shader to their final position on the texture after refractions have occured. The resulting colour is set based on the how many photons end up at a particular position. The colour is also weighted by an intensity term that takes the dot product between the surface normal of the receiving geometry and the incident photon direction.

It is evident from the above image that the caustic map is very coarse so next I use a technique proposed by Wyman to smooth the caustic map. I implemented this method with another shader which essentially applies a Gaussian blur to the caustic map using a 5x5 filter kernel. This produces nice results and smooths the caustic map.

The results after smoothing are much more pleasing. The next step is to project the caustic map onto nearby geometry and see what optimisations can be made to the algorithm so that larger resolution caustic maps can be generated in real-time. I will probably do a little bit of tinkering with the blurring algorthim as well to see if I can achieve better results as currently is seems that a lot of detail/colour variation is lost.

Last Updated on Saturday, 17 October 2009 16:08
 
<< Start < Prev 1 2 Next > End >>

Page 1 of 2