Hi,

First of all thanks for the great work you've benn doing so far. I'm trying to 
build up a post processing setup using osgCompute but I have some problems.
This is how my scene graph looks like:

Computation (Render before children)
|-> Camera (Relative, attached MRT textures and using FBO)
|........|--> Scene
|-> Camera (Absolute, Orthogonal 2D Camera)
.........|--> Quad Geometry using Target Texture

I'm generating the MRTs and Target textures as follows:

Code:

        char MrtName[80];
        for(int i = 0; i < 4; i++)
        {
                MRTTexture[i] = new osgCuda::Texture2D;
                MRTTexture[i]->setTextureSize(textureWidth, textureHeight);
                
MRTTexture[i]->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
                
MRTTexture[i]->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
                MRTTexture[i]->setInternalFormat(GL_RGBA32F_ARB);
                MRTTexture[i]->setSourceFormat(GL_RGBA);
                MRTTexture[i]->setSourceType(GL_FLOAT);
                sprintf(MrtName, "MRT%d", i);
                MRTTexture[i]->addIdentifier(MrtName);
        }

        //Target
        *Target = new osgCuda::Texture2D;  
        (*Target)->setInternalFormat( GL_RGBA32F_ARB );
        (*Target)->setSourceFormat( GL_RGBA );
        (*Target)->setSourceType( GL_FLOAT );
        (*Target)->setTextureWidth( textureWidth );
        (*Target)->setTextureHeight( textureHeight );
        (*Target)->setFilter(osg::Texture2D::MIN_FILTER, 
osg::Texture2D::NEAREST);
        (*Target)->setFilter(osg::Texture2D::MAG_FILTER, 
osg::Texture2D::NEAREST);
        (*Target)->addIdentifier( "TARGET" );




And this is how I call my kernel:

Code:

        virtual void launch()
        {
                if( isClear() )
                        return;

                swap(  _blocks, 
                        _threads,
                        Target->map(osgCompute::MAP_DEVICE_TARGET),
                        MRT0->map(osgCompute::MAP_DEVICE_SOURCE),
                        Target->getPitch(),
                        MRT0->getPitch(),
                        Target->getDimension(0),
                        Target->getDimension(1) );
        }




And this is the kernel:

Code:

__global__ 
void swapKernel( float4* dst, float4* src, unsigned int dstPitch, unsigned int 
srcPitch, unsigned int imageWidth, unsigned int imageHeight ) 
{
    // compute thread dimension
    unsigned int x = blockIdx.x * blockDim.x + threadIdx.x;
    unsigned int y = blockIdx.y * blockDim.y + threadIdx.y;
    if( x < imageWidth && y < imageHeight )
    {
        float4* dstPixel = (float4*)(((char*) dst) + dstPitch * y ) + x;
        float4* srcPixel = (float4*)(((char*) src) + srcPitch * y ) + x;

        // swap channels
        *dstPixel = *srcPixel;
                //*dstPixel = make_float4( ((float) x / (float) imageWidth) 
,((float) y / (float) imageHeight), 0, 1 );
    }
}



I'm sure MRT's are setup correctly since when I attach any of the MRT's to the 
Quad I can see the scene.
I'm also sure that kernel is working properly since when I write texture 
coordinates to the target I can see them.
However when I try to copy the MRT to the Target I see a black screen.

I couldn't find whats wrong with this setup. Any help would be appreciated.
Thanks in advance!

Cheers,
Serkan[/code]

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=36216#36216





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to