Hi Rakash, Right now, for OpenGL ES 2.0, you have no alternative but to write shaders and uniforms to do all the vertex and framgemet shader operations, the traditional fixed function pipeline is a non op. There is a utility osgUtil::ShaderGen but this was designed for GL2.0 shaders that can help generate some shaders to replace the fixed function state, but it's not written explictly for GLES 2.0 and uses built-ins that don't exist under GLES. Please also remember that all gl_ built-ins don't exist under GLES, the OSG try to rewrite the gl_ uniforms to use osg_ versions such as osg_ModelViewProjectionMatrix, but it's not a complete mapping. What you should assume is no builts at all.
In the future my plan is to have a Shader Composer system for the OSG that will provide an automatic mapping from fixed function state in the form of uniforms and shaders. I've written about 1/3rd of the infrastructure for this funcitonality, but right now it's not operational. Robert. On Fri, Sep 10, 2010 at 12:29 PM, Rakesh Parmar <[email protected]> wrote: > Hi List, > Thanks for all the support.Now I am able to build Osg with opengl ES 2.0 > without Qt and can run the sample programs. > I am able to load the .3ds file but I am unable to render the correct > material on the screen. > > Following is the source code I m using: > > > Code: > > #include <osgViewer/Viewer> > #include <osgDB/ReadFile> > #include <osg/MatrixTransform> > #include <iostream> > #include <osg/ShapeDrawable> > #include <osg/Geode> > #include <osgDB/ReadFile> > #include<stdio.h> > //#include<osg/vec3> > #include<Uniform> > using namespace osg; > > osg::Uniform* _ClrUniform; > > static const char* vertSource = { > > "// colors a fragment based on its position\n" > "uniform vec3 color; \n" > "varying mediump vec4 Finalcolor;\n" > "void main(void) {\n" > "Finalcolor = color;\n" > "gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" > "}\n" > }; > > static const char* fragSource = { > //SHADER_COMPAT > "varying mediump vec4 Finalcolor;\n" > "void main(void) {\n" > "gl_FragColor = Finalcolor;\n" > "}\n" > }; > > int main( int, char ** ) > { > osgViewer::Viewer viewer; > > osg::setNotifyLevel(osg::INFO); > > ref_ptr<Group> m_root = new Group; > > osg::Geode* geode = (osg::Geode* )osgDB::readNodeFile( "info_icon.3ds" ); > > osg::Program* program = new osg::Program; > program->setName("shader"); > program->addShader(new osg::Shader(osg::Shader::VERTEX, vertSource)); > program->addShader(new osg::Shader(osg::Shader::FRAGMENT, fragSource)); > > geode->getOrCreateStateSet()->setAttributeAndModes(program, > osg::StateAttribute::ON); > > _ClrUniform = new osg::Uniform("color",osg::Vec3(1.0,0.0,0.0));//Initializing > the uniform > > osg::StateSet *stateSet = geode->getOrCreateStateSet(); > stateSet->addUniform(_ClrUniform); > stateSet->setMode(GL_BLEND, osg::StateAttribute::ON); > > m_root->addChild(geode); > > viewer.setUpViewInWindow( 32, 32, 1024, 600 ); > viewer.setSceneData(m_root.get()); > return viewer.run(); > } > > > I have looked at material.cpp and tried to set the Uniform for material.But > somehow its not updating in the application.It is taking black color by > default. > > I think that, they have not handled the material property for ES 2.0 in > material.cpp > I have tried modifying the code in material.cpp in void > Material::apply(State&) const function. > The modified code is as follows: > > > > osg::Uniform* _myClrUniform; > _myClrUniform->set( osg::Vec3(_diffuseFront.x(), _diffuseFront.y(), > _diffuseFront.z()) ); > > [/code] > > How can I set the material property of every object through application for > .3DS file? > Any help will be appreciated. > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=31514#31514 > > > > > > _______________________________________________ > 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

