Thx for the compliment!
x3n wrote:
in which language do you write the shader program?
Main language is Cg (C for graphics). The "wrapping format" for defining gui-variables, techniques, passes and rendertargets is CgFX. It is supported by Autodesk Maya or Nvidia FX Composer, a popular free shader IDE, where I'm testing and tweaking my shader. FX Composer's advantage is to have one click conversion between many Cg dialects, GLSL and HLSL (since there's no huge difference between them).
Then in Orxonox, OGRE-Material and -Compositor-Scripts will take over the function of CgFX.
x3n wrote:
does this only work if the light is in front of the camera and is visible through some "clouds" or does it also work if the light is to your left (or right) and the rays go across the screen?
If you meant "out of the screen", then the former:
In my implementation, the sun is rendered as a white 3d sphere on screen. Then it can be overdrawn by black light-obstacles. Z-Buffer may be enabled too. A 35x 2D radial blur is applied, with the sun as the centerpoint and is combined with the regular renderbuffer - altogether very efficient.
When the sun is out of boundary it does not get drawn on the godraybuffer, and therefore is not radial blured.
But there are probably many workarounds. One would be to extend the rendertarget around the edges. Another to determine mathematically the sun's dimensions... everything sort of slow.
The simplest one I've already implemented. At the begin I clear the godraybuffer with the hazecolor, at least brighter than black. Obstacles are then blured like shadows, and even when the sun says goodbye, there are still rays with the right direction.
- FX Composer showing the testing of the godray shader. In the 3d view you can see the impact of the "out of boundary-sun" exception ;) and the haze. Note that the sun-obstacle target is used as the render target too, and therefore the haze has too much intensity and little contrast. This won't be that way in the game.
- godrays_testing.jpg (141.38 KiB) Viewed 19731 times
I believe that godrays which are too present in every camera-view, distract from the game itself... although it could be a tactical gameplay feature to dazzle the enemy
. What do you think?