Sunday, May 20, 2007

GPU Geometry Clipmaps v1.1 in progress




I am going to make a game demo and need GPUgc to manage terrain's demo. I notice that there is some bugs in my old version. First, the generation of normal maps that were too sharp. Now, I use another way to find normals and to use them while keeping the same memory usage. I also rewrite the system that let the user control max height and height scale so that it fully support the z encoding/decoding in the shader without artefacts. I plan to rewrite/correct more parts and add a "LoadFromBMP" function. Of course, i will release it once done :).

In the screenshot z goes from 0 to 1023 with a scale of 20.0 -> 20 * 1024 different values.

Friday, May 11, 2007

CryEngine2 atmospheric approach on GPU



I ported their approach on GPU and update is fast ! A 6200 can update a 256x256 map with 64 samples 9-11 times per second. With a temporary texture, you can update small quads but it's so fast that it's useless. Of course, no APG/PCIe bandwith, no cpu needed.

I also tryed to map texture into a full dome where viewer is at Origin. Some work needed to be done on shader to handle this but at last there is artefacts caused by poor tesselation of dome (always 32 rows, 32 cols on screenshots) and the uniform distribution of samples cause by low resolution texture stretching (8x8, 32x32). Problems that do not exist when using original code from O'Neil 's GPU Gems II or with a higher resolution map.

Note : On CryEngine2 they seem to map texture on a low tesselate geodesic dome. I use Oneil optimisations (GPU Gems II) which is much simpler than crytek that uses Nishita with 2D table.

Saturday, May 5, 2007

Shafts of light alias God Rays





How to mix an atmospheric model with "radial blur" to achieve outdoor shafts of light ? Well, draw your dome with your atmospheric shader, write (max(MiePhase) * ShaftsPower) to alpha value of backbuffer. Copy backbuffer's alpha to a smaller render target, use radial blur with projected sun 's position as center even if it's outside screen. Subtract radial blur's alpha from original rendertarget's alpha. Mix rendertarget with backbuffer to illuminate or darken, as you wish.

There is no artefacts when sun is behind viewer because the alpha map is done with the MiePhase function. If ShaftsPower is high enough, backbuffer's alpha values will be 1 even if the sun is behind viewer and it will causes artifacts. Using other functions can give smoother results
like log2( max(MiePhase) * 2500.0f ).

For the screenshots, i used log2( max(MiePhase) * 2500.0f ), 16 samples for radial blur, 256x256 rendertargets and a bloom effect( glow + highlight ). it's not 100% perfect yet.