Dynamic Ambient Occlusion and Indirect Lighting

This sample was presented on the Nvida witesite, which detail a new idea to calculate the ambient occlusion and indirect lighting for dynamic objects under real time mode while still keep a good performace. 
The basic idea of such kind of dynamic ambient occlusion and indirect lighting is take the vertex relationships into account. The relationship means whether one vertex cast shadow to other, what will happen when one caster already in shadow, and the most important one is how much one cast to other. After serveral calculation pass for all those dynamic vertex array, we could get a value for all vertex that could be used to dark the  surface. That is for the ambient occlusion.

If we could find a way to calculate how one vertex cast shadow to others, we could find some similar method to calculate how one vertex re-light to others. Those light means indirect lights bound among those vertexs. That is indirect lighting. Here is screen shot about the dynamic ambient occlusion effect will be:
demo_screen
The technique provided here is one method that could get more realistic image. The best one is the phsyical lighting, which is too time consuming to implment it at real time. But some one already find some methods to improve the ambient lighting, like light mapping, spherical harmonic pre-lighting, BRDF with simplified fuction (or precaluted some values into texture) and so on. All of them could have a good performance.

I download the source code, and try to re-built on my compute. But I was failed because of the hardware limitation, it seems my computer OpenGL Pixel Shader Language could not support ‘while’ instruction. To make the program could run I have to replace the ‘while’ loop with a limit ‘for’ loop. The ‘while’ loop used to go though find all vertex that will cast shadow to a given one vertex. I think this part could be improved by find the most n items that contributes the most instead of list all items. Or Maybe I could find this issue by using some higher version OpenGL library. OpenGL ARB fuction too old not to use some advacned features on windows OS.
Here is the screen shot that work with limit first 12 items ‘for’ loop and ‘while’ removed: (use loop 12 times because of the limitation of the pixel shader instructions size, it seems the shader compile will convert loop instruction into un-loop instruction, that mean duplicate the code with looped times )
my_screen_shot

The full source code and translated document could be found from here.

原文地址:https://www.cnblogs.com/open-coder/p/3440303.html