New feature: Custom textures for depth map calculation

Xavyiy

10-02-2009 22:44:14

Hi all,

As some people can know, there're serious problems with transluscent objects(Like vegetables, etc) in the water and Hydrax in current versions. This is due to Hydrax depth map is calculated considering that all objects are opaque.
So... How to solve it? Easy: Using custom textures to tell Hydrax where objects are transluscent or opaque.

For example: (First screenshot without the new approach applied, and the second one with new feature applied)




But... how to tell it to Hydrax?, just adding this: (Only to materials that are going to be inside the water)
mHydrax->getMaterialManager()->addDepthTextureTechnique(
static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().getByName("Palm"))
->createTechnique(), "PalmAlpha.png", "a");

Where Palm is the Palm's material, "PalmAlpha.png" is the texture where alpha values are stored, and "a" is the channel where the alpha information are stored(r,g,b or a).
After doing it, you can get your Hydrax depth technique(YourMaterial->getTechnique(1)->getPass(0)->...) and modify all material options (depth write, depth check, etc) as needed.

This feature is now ready for next release (0.5v), which hope is going to be released this weekend or, the next one.

Xavi

scratchyrice

12-02-2009 12:10:11

Very nice, Simple solution indeed! Looking forward to the next release XD

Cheers

Scratchy