Can you add the texture as well?

cheers

Thank you Sebastian!


On Tue, May 13, 2014 at 11:18 AM, Sebastian Messerschmidt <[email protected] <mailto:[email protected]>> wrote:

    Hi Patrik,

    Simply attach the code (probably compress it with zip) so others
    might check on this too.
    Hi Sebastian,

    I have dig down and find the resolution of the OpenGL error, I
    passed an int or double instead of a float into the shader. There
    is something strange with how I assign the texture, I rewrote it as

    [code]
    osg::Uniform* specEnvMap = new
    osg::Uniform(osg::Uniform::SAMPLER_CUBE,"SpecularEnvMap");
    specEnvMap->set(tex);
    osg::Uniform* diffEnvMap = new
    osg::Uniform(osg::Uniform::SAMPLER_CUBE, "DiffuseEnvMap");
    diffEnvMap->set(tex);
    [/code]

    To make sure that it is of type sampleCube.

    I could upload all code, since I'm trying to write a minimal
    program which demonstrates Image Based Lighting. It is two files,
    one header and one cpp, in total 170 lines. Would that be of any
    help?

    kind regards
    Patrik


    On Tue, May 13, 2014 at 11:04 AM, Sebastian Messerschmidt
    <[email protected]
    <mailto:[email protected]>> wrote:

        Hi Patrik,


        Okay, I've digged a bit deeper into your code. Somehow your
        code to add the textures seems awkward. You are assigning the
        cubemap to the first texture unit and create 3 uniforms to
        texture unit 0.
        It is hard to tell what is going wrong on your side, given
        that small piece of code, but since you get an OpenGL error
        you should chase it down. It might be related to binding the
        texture to multiple sampler objects on the same texture
        unit.  Try to step back and bind the cubemap to a simple
        program with exactly one cubemap sampler and do some
        debugging with a simple cubemapping shader.
        There is a osgcubemap example which you could extend to use
        shaders (beware that TexGen will not work with shaders, so
        you will have to write your own in the vertex shader, which
        is not complicated though)

        I don't know the specific example you are referring to, so I
        cannot really give your more pointers unless you prepare a
        small compiling example.

        Hi Sebastian,

        Yes, that works as well, the sphere is red.

        cheers
        Patrik


        On Tue, May 13, 2014 at 10:32 AM, Sebastian Messerschmidt
        <[email protected]
        <mailto:[email protected]>> wrote:

            Hi Patrik,

            Hi Sebastian,

            The baseColor is applied to the sphere, so I can see my
            shader is in use. No differences when using osgShadow
            or not.
            Yes because it is the first texture unit. Fixed function
            pipeline and osgShadow will handle it. Please follwo my
            advice and change the output of the fragment shader to
            gl_FragColor = vec4(1,0,0,1) or gl_FragData[0] =
            vec4(1,0,0,1)
            to see if it is _really_ your shader.

            cheers
            Sebastian


            Cheers
            Patrik


            On Tue, May 13, 2014 at 10:03 AM, Sebastian
            Messerschmidt <[email protected]
            <mailto:[email protected]>> wrote:

                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]  
<mailto:[email protected]>
                
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


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




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


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




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


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




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


    _______________________________________________
    osg-users mailing list
    [email protected]
    <mailto:[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

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

Reply via email to