Hi all,

I'm currently working on integrating RenderMonkey Glass shader into 
OpenSceneGraph. There, i need to pass cubemap as uniform. For creating cubemap 
i'm using osg::TextureCubeMap class.  It seems like glsl doesn't process 
texture as it should. 


Code:

    osg::ref_ptr<osg::TextureCubeMap> cubemap = new osg::TextureCubeMap;

    osg::Image* imagePosX = osgDB::readImageFile("images/cm_right.tga");
    osg::Image* imageNegX = osgDB::readImageFile("images/cm_left.tga");
    osg::Image* imagePosY = osgDB::readImageFile("images/cm_bottom.tga");
    osg::Image* imageNegY = osgDB::readImageFile("images/cm_top.tga");
    osg::Image* imagePosZ = osgDB::readImageFile("images/cm_front.tga");
    osg::Image* imageNegZ = osgDB::readImageFile("images/cm_back.tga");

    if (imagePosX && imageNegX && imagePosY && imageNegY && imagePosZ && 
imageNegZ)
    {
        cubemap->setImage(osg::TextureCubeMap::POSITIVE_X, imagePosX);
        cubemap->setImage(osg::TextureCubeMap::NEGATIVE_X, imageNegX);
        cubemap->setImage(osg::TextureCubeMap::POSITIVE_Y, imagePosY);
        cubemap->setImage(osg::TextureCubeMap::NEGATIVE_Y, imageNegY);
        cubemap->setImage(osg::TextureCubeMap::POSITIVE_Z, imagePosZ);
        cubemap->setImage(osg::TextureCubeMap::NEGATIVE_Z, imageNegZ);

        cubemap->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
        cubemap->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
        cubemap->setWrap(osg::Texture::WRAP_R, osg::Texture::CLAMP_TO_EDGE);

        cubemap->setFilter(osg::Texture::MIN_FILTER, 
osg::Texture::LINEAR_MIPMAP_LINEAR);
        cubemap->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
    }

    osg::StateSet* stateset = model->getOrCreateStateSet();


    osg::Shader* vertexShader = new osg::Shader( osg::Shader::VERTEX );
    osg::Shader* fragmentShader = new osg::Shader( osg::Shader::FRAGMENT );
    vertexShader->loadShaderSourceFromFile( "winglass.vert" );
    fragmentShader->loadShaderSourceFromFile( "winglass.frag" );

    osg::Program* program = new osg::Program;
    program->addShader( vertexShader );
    program->addShader( fragmentShader );
    stateset->setAttributeAndModes( program, osg::StateAttribute::ON );

    osg::Uniform* environment = new osg::Uniform(osg::Uniform::SAMPLER_CUBE, 
"Environment");
    environment->set(cubemap.get());
    stateset->addUniform( environment );




What is wrong?

Kind regards,
Turgut[/code]

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





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to