HI Ankur,

osgUtil::ShaderGen was written for GL2 rather than GLES2, and we've
just quickly used this class as a fallback to provide some basic
fallback functionality, it's certainly not a ideal solution for GLES2
or able to cope with all fixed function state.

I'm not personally working on updating ShaderGen for GLES2, and I'm
not aware of others doing this work, but they may be.  Feel free to
dive in an help improve ShaderGen's support for GLES2.

Robert.

On Fri, Apr 15, 2011 at 1:21 PM, Ankur Gandhi <ank.gan...@tcs.com> wrote:
> Hi Robert,
>
> I am using OSG 2.9.11 dev release. recently I have started working on OSG 
> over GLES2.  Although my OSG based code is working fine on OpenGL based 
> system, i face similar issues that of Yun-Ta on GLES2. My test application is 
> importing a plain 3ds max object onto screen along with light source. when i 
> run the program, i get following output.
>
>
> libEGL warning: failed to create DRM screen
> libEGL warning: use software fallback
> GraphicsWindowX11::init() - eglInitialize() succeded eglMajorVersion=1 
> iMinorVersion=4
> GraphicsWindowX11::init() - window created =1
> VERTEX glCompileShader "" FAILED
> VERTEX Shader "" infolog:
> 0:0(0): error: `osg_Normal' redeclared
> 0:19(34): error: `gl_LightSource' undeclared
> 0:19(46): error: type mismatch
>
> FRAGMENT glCompileShader "" FAILED
> FRAGMENT Shader "" infolog:
> 0:20(20): error: syntax error, unexpected NEW_IDENTIFIER, expecting ',' or ';'
>
> glLinkProgram "" FAILED
> Program "" infolog:
> linking with uncompiled shaderlinking with uncompiled shader
> Warning: detected OpenGL error 'invalid enumerant' at after 
> RenderBin::draw(..)
> Warning: detected OpenGL error 'invalid enumerant' at end of SceneView::draw()
> Warning: detected OpenGL error 'invalid enumerant' after applying GLMode 0xb50
> Warning: detected OpenGL error 'invalid enumerant' after applying GLMode 0xb50
> Warning: detected OpenGL error 'invalid enumerant' after applying GLMode 0xb50
> Warning: detected OpenGL error 'invalid enumerant' after applying GLMode 0xb50
> Warning: detected OpenGL error 'invalid enumerant' after applying GLMode 0xb50
> Warning: detected OpenGL error 'invalid enumerant' after applying GLMode 0xb50
>
>
> I was just wondering if work on ShaderGen is going on in some other branch or 
> something? or am i doing anything wrong here to run 3ds max object over GLES2?
>
> any help would be appreciated.
>
> Thanking you in anticipation.
>
> Regards,
> Ankur
>
>
>
> robertosfield wrote:
>> Hi Yun-Ta,
>>
>> ShaderGen assumes OpenGL 2 feature set, so items like the built in
>> gl_* uniforms and vertex attributes are used.  osg::State does map
>> automatically a number of these uniforms for GLE2 but doing a search
>> and replace of them, this isn't exhaustive though.
>>
>> The work I'm just starting now on shader composition will make
>> ShaderGen completely redundant and will properly support GLES 2, GL3
>> and GL4, so the issues you are seeing should disappear completely.
>>
>> Robert.
>>
>> On Wed, Jun 30, 2010 at 6:08 PM,  <> wrote:
>>
>> >  Hi all,
>> >
>> > I am trying to test OSG (2.9.8) on N900 with OpenGL ES2.
>> > However, ShaderGen.cpp seems to be not fully compatible with OpenGL ES2
>> > standard.
>> >
>> > For instance, gl_LightSource is not defined in ES2 and precision
>> > attribute (mediump / highp / lowp) has been missing. The later one can
>> > be easily fixed while the first one using undefined variables is more
>> > difficult to work around.
>> >
>> > Here is the GLSL code generated from ShaderGen.cpp:
>> > Nokia-N900:/home/user/osg-data# /opt/osg/bin/osgviewer cessna.osg
>> > GraphicsWindowX11::init() - eglInitialize() succeded eglMajorVersion=1
>> > iMinorVersion=4
>> > GraphicsWindowX11::init() - window created =1
>> > State::convertShaderSourceToOsgBuiltIns()
>> > ++Before Converted source
>> > varying vec3 normalDir;
>> > varying vec3 lightDir;
>> > varying vec3 viewDir;
>> >
>> > void main()
>> > {
>> >   gl_Position = ftransform();
>> >   normalDir = gl_NormalMatrix * gl_Normal;
>> >   vec3 dir = -vec3(gl_ModelViewMatrix * gl_Vertex);
>> >   viewDir = dir;
>> >   vec4 lpos = gl_LightSource[0].position;
>> >   if (lpos.w == 0.0)
>> >     lightDir = lpos.xyz;
>> >   else
>> >     lightDir = lpos.xyz + dir;
>> > }
>> >
>> > ++++++++
>> > -------- Converted source
>> > uniform mat3 osg_NormalMatrix;
>> > uniform mat4 osg_ModelViewProjectionMatrix;
>> > uniform mat4 osg_ModelViewMatrix;
>> > attribute vec4 osg_Vertex;
>> > attribute vec3 osg_Normal;
>> > varying vec3 normalDir;
>> > varying vec3 lightDir;
>> > varying vec3 viewDir;
>> >
>> > void main()
>> > {
>> >   gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;
>> >   normalDir = osg_NormalMatrix * osg_Normal;
>> >   vec3 dir = -vec3(osg_ModelViewMatrix * osg_Vertex);
>> >   viewDir = dir;
>> >   vec4 lpos = gl_LightSource[0].position;
>> >   if (lpos.w == 0.0)
>> >     lightDir = lpos.xyz;
>> >   else
>> >     lightDir = lpos.xyz + dir;
>> > }
>> >
>> > ----------------
>> > VERTEX glCompileShader "" FAILED
>> > VERTEX Shader "" infolog:
>> > Compile failed.
>> > ERROR: 0:16: 'gl_LightSource' : undeclared identifer
>> > ERROR: 0:16: 'gl_LightSource' : left of '[' is not of type array,
>> > matrix, or vector
>> > ERROR: 0:16: 'position' : illegal vector field selection
>> > ERROR: 0:16: 'assign' :  cannot convert from 'float' to '4-component
>> > vector of float'
>> > ERROR: 4 compilation errors. No code generated.
>> >
>> >
>> > FRAGMENT glCompileShader "" FAILED
>> > FRAGMENT Shader "" infolog:
>> > Compile failed.
>> > ERROR: 0:1: 'vec3' : No precision defined for this type
>> > ERROR: 0:2: 'vec3' : No precision defined for this type
>> > ERROR: 0:3: 'vec3' : No precision defined for this type
>> > ERROR: 0:7: 'vec4' : No precision defined for this type
>> > ERROR: 0:8: 'vec3' : No precision defined for this type
>> > ERROR: 0:9: 'vec3' : No precision defined for this type
>> > ERROR: 0:10: 'vec3' : No precision defined for this type
>> > ERROR: 0:11: 'vec4' : No precision defined for this type
>> > ERROR: 0:11: 'gl_FrontLightModelProduct' : undeclared identifer
>> > ....
>> >
>> > Any suggestion?
>> >
>> > Thanks.
>> > Best Regards,
>> > Yun-Ta
>> > _______________________________________________
>> > osg-users mailing list
>> >
>> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>> >
>> >
>> _______________________________________________
>> osg-users mailing list
>>
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>>  ------------------
>> Post generated by Mail2Forum
>
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=38499#38499
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to