Hi people,
Now that I have achieved texturing my cubes I would like to add ambient occlusion using the AmbientOcclusionCalculator.
I looked at the Thermite project but couldn't really find out what are the steps required to send the resulting volume to the GPU.
For now I'm computing my AmbientOcclusionVolume each time a chunk is updated and then storing it into a 3D texture. (the same thing that Thermite does)
To create the 3D texture :
Code:
mAmbientOcclusionVolumeTexture = Ogre::TextureManager::getSingleton().createManual(
"AmbientOcclusionVolumeTexture" + Ogre::StringConverter::toString(x) + "_" + Ogre::StringConverter::toString(y), // Name of texture
"General", // Name of resource group in which the texture should be created
Ogre::TEX_TYPE_3D, // Texture type
ChunkSizeX, // Width
ChunkSizeY, // Height
ChunkSizeZ, // Depth (Must be 1 for two dimensional textures)
0, // Number of mipmaps
Ogre::PF_L8, // Pixel format
Ogre::TU_STATIC_WRITE_ONLY // usage
);
x and y are the coordinates of the chunk.
Copying the computed volume into this texture :
Code:
Ogre::HardwarePixelBuffer* pixelBuffer = mAmbientOcclusionVolumeTexture.getPointer()->getBuffer().getPointer();
Ogre::PixelBox pixelBox(mAmbientOcclusionVolumeTexture->getWidth(),mAmbientOcclusionVolumeTexture->getHeight(),mAmbientOcclusionVolumeTexture->getDepth(), mAmbientOcclusionVolumeTexture->getFormat(), ambientOcclusionVolume->getRawData());
pixelBuffer->blitFromMemory(pixelBox);
I'm certainly missing something because the computation seems to take place (it's using one CPU core for some time) but nothing can be seen.