void ShaderShadowMapEngine::updateShadowTexChunk(SSMEngineData *data)
{
    TextureObjChunk *bufTex = data->getShadowTexChunk();
    
    if(bufTex == NULL)
    {
        TextureObjChunkUnrecPtr newBufTex = TextureObjChunk::createLocal();
        newBufTex->setMinFilter     (GL_LINEAR              );
        newBufTex->setMagFilter     (GL_LINEAR              );
        newBufTex->setWrapS         (GL_CLAMP_TO_EDGE       );
        newBufTex->setWrapT         (GL_CLAMP_TO_EDGE       );
        newBufTex->setWrapR         (GL_CLAMP_TO_EDGE       );
        newBufTex->setScale         (false                  );
        newBufTex->setInternalFormat(GL_DEPTH_COMPONENT24   );
        newBufTex->setExternalFormat(GL_DEPTH_COMPONENT     );
        newBufTex->setCompareMode   (GL_COMPARE_R_TO_TEXTURE);
        newBufTex->setCompareFunc   (GL_LESS                );
        newBufTex->setDepthMode     (GL_LUMINANCE           );

        data->setShadowTexChunk(newBufTex);
        this->setShadowTexChunk(newBufTex);
    }
}
void ColorDisplayFilter::process(DisplayFilterStageData *pData)
{
    SimpleSHLChunk *pShader = pData->getColorFilterShader();

    if(pShader == NULL || this->getFilterShader() != pShader)
    {
        pShader = this->getFilterShader();

        OSG_ASSERT(pShader != NULL);
        
        ChunkMaterial *pCMat = pData->getBaseMaterial();

        OSG_ASSERT(pCMat != NULL);

        pCMat->addChunk(pShader);

        commitChanges();

        pData->setColorFilterShader(pShader);
    }



    TextureObjChunk *pColTex = pData->getColorFilterTexture();

    if(pData->getInitColTableFrom() != this)
    {
        if(pColTex == NULL)
        {
            TextureObjChunkUnrecPtr pTex = TextureObjChunk::createLocal();

            pTex->setMinFilter(GL_LINEAR            );
            pTex->setMagFilter(GL_LINEAR            );
            pTex->setWrapS    (GL_CLAMP_TO_EDGE     );
            pTex->setWrapT    (GL_CLAMP_TO_EDGE     );
            pTex->setWrapR    (GL_CLAMP_TO_EDGE     );

            pData->setColorFilterTexture(pTex);

            ChunkMaterial *pCMat = pData->getBaseMaterial();
            
            OSG_ASSERT(pCMat != NULL);
            
            pCMat->addChunk(pTex, 1);

            pColTex = pTex;
        }

        pData->setInitColTableFrom(this);

        pColTex->setImage(this->getTableImage());

        commitChanges();
    }

    OSG_ASSERT(pShader != NULL);
    OSG_ASSERT(pColTex != NULL);

    pShader->setIgnore(false);
    pColTex->setIgnore(false);
}