Hi Patrick,

from a glimpse it seems you are setting up the shader to the geode while using osgShadow, which will override your shaders. I guess you need to set the shaders at the shadowTechnique. Could you try it without osgShadow or simply do some shader debugging by setting the gl_FragColor to some debug value to see if your shader is used at all?

cheers
Sebastian
HI,

I'm trying to implement Image Based Lighting in a scene. but I think I miss something essential. I have copied the fragment shader and vertex shader from the orange book, ch 12/Image Based Lighting. Created a sphere which shall be the emissive surface.

When I run I receive following warning/error msg:
Warning: detected OpenGL error 'invalid operation' at After Renderer::compile.

The sphere is colored by the base-color, but it is not emissive. What kind of attributes do I need to set to get it work, or should I make things in a different order? See code below.

Kind regards
Patrik

This is the main code:
[code]
osgShadow::ShadowedScene* scene(new osgShadow::ShadowedScene());
osgShadow::ShadowMap* sm(new osgShadow::ShadowMap());
sm->setTextureSize(osg::Vec2s(512,512));
scene->setShadowTechnique(sm);
osg::Group* root = new osg::Group;
osg::Geode* em = new osg::Geode();
em->addDrawable(new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(0,0,0), 10.0) ) );
osg::Geode* geode = new osg::Geode();
geode->addDrawable(new osg::ShapeDrawable( new osg::Cylinder(osg::Vec3(0,0,-3.0),10,0.2 ) )) ;
geode->setCullingActive(true);
root->addChild(em);
root->addChild(geode);
scene->addChild(root);
osg::TextureCubeMap* tex = readCubeMap();

{
osg::StateSet* ss = em->getOrCreateStateSet();
        osg::Program* program = new osg::Program;
        program->setName( "IBL" );
program->addShader( new osg::Shader( osg::Shader::VERTEX, IBLVertSource ) ); program->addShader( new osg::Shader( osg::Shader::FRAGMENT, IBLFragSource ) );
ss->setAttributeAndModes( program, osg::StateAttribute::ON );
osg::Uniform* baseColor = new osg::Uniform( "BaseColor", osg::Vec3(0.2, 0.4, 0.6) );
osg::Uniform* specular = new osg::Uniform( "SpecularPercent", 0);
osg::Uniform* diffuse = new osg::Uniform( "DiffusePercent", 1.0);
osg::Uniform* specEnvMap = new osg::Uniform("SpecularEnvMap", 0);
osg::Uniform* diffEnvMap = new osg::Uniform( "DiffuseEnvMap", 0);
ss->setTextureAttributeAndModes(0, tex, osg::StateAttribute::ON );
ss->addUniform( baseColor );
ss->addUniform( specular );
ss->addUniform( diffuse );
ss->addUniform( specEnvMap );
ss->addUniform( diffEnvMap );
    }

viewer.setSceneData(scene);
viewer.run();
[/code]


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

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

Reply via email to