HLSL rules!

Texture splatting using my own shader program is now ready. I must confess I should have migrated to shaders a long time ago. I’m always afraid to have to deal with hardware incompatibilities, but benefits are huge. The same result (even better) with less texture units… and so programmable pipelines can be faster than fixed ones!! I realized too that I now have extra “space” to add further  terrain effects on a single pass in the future.

Nothing is perfect… I’d like Nyne to be able to run on aging laptops, so I’m dealing with old shader version restrictions. But that’s still simpler than the old way. Moreover, I still have plenty of data space directly on vertex… and so more improvements to come!


Alpha with fragment shader

Still working on my HLSL fragment program for terrain splatting. Above is my alpha map.

alpha    = alpha*alpha + alpha * dupCO.r * dupCO.g ;
alpha    = sqrt( alpha ) ;
alpha    = clamp( alpha , 0 , 1 ) ;

Simple process with the under laying texture to avoid a too smooth texture transition. Not perfect… but it’ll be my starting point !

Fixed pipelines s*cks

Up to now, splatting was achieved using the fixed-pipeline. But 1/ PSSM needs for itself 3 texture units so I won’t be able to integrate this on a one-pass texture. And 2/ Fixed and programmable pipelines can’t deal together… I have to say good-bye to my old beloved fixed texture unit functions and switch to a full vertex shaders solution. That’s life…

PSSM fixed!

F*cking f*ck! My PSSM is now ready. It was a pure headache to fix it. Ogre built-in function are great…

Ogre::PSSMShadowCameraSetup* pssmSetup = new Ogre::PSSMShadowCameraSetup();

…but the downside (for me) is tha it makes more difficult to understand how the whole thing works. After hours searching WHY my shadow textures were hidden depending on camera’s angle… I finally get that there were default mechanisms against me…

pssmSetup->setOptimalAdjustFactor(n, 0);

And that was it! Since I needed to use my split point computation… Ogre’s auto adjust was destroying all my efforts 😉

Looking for PSSM

1- Stencil: I need to fix shadows. Until today, I had great tight shadows… but… stencil shadows. And here, since sun’s light is moving according to daytime, it’s completely, irremediably, impossible to ask any CPU to generates stencils (I tried… and rendering dropped down from 180 to an absurd 12 FPS).

2- Texture: texture based… not much better. Standard texture shadows do retro-projection, that’s nothing but a hack. Not a big issue in box space like rooms, or in a scene where light comes from above… but the main goal is to place shadows on cities’ buildings.

3- Z-depth: Shaders depth shadow. Well that’s the picture above. On massive scale scenes like Nyne does there is no more left than 4×4 pixel for closest objets on a 1024×1024 texture. And I do not plan to use 8192² alpha texture (65 Mb!!) to get a poor 32×32 definition shadow.

4- PSSM: at the end of the day, I can’t skip using parallel split shadows (PSSM). The main idea is to use only a couple of textures to isolate closest objets which need detailed shadows, and further objets. This idea is pretty smart…

A quite complete Gems3 paper: http://http.developer.nvidia.com/GPUGems3/gpugems3_ch10.html