Re: [osg-users] GLES link error for unidentified Program

2018-01-25 Thread Robert Osfield
Hi Alessandro,

OK, this shader is a default provided to at least give something to
render.  osg::DisplaySettings::ShaderHint is what controls the
addition of this fallback, in a GLES build it defaults to GLES2 or
GLES3, you can override this and switch it off via:

 
osg::DisplaySettings::instance()->setShaderHint(osg::DisplaySettings::SHADER_NONE);

The fallback shaders can be found at OpenSceneGraph/src/osg/StateSet.cpp.

Robert.


On 25 January 2018 at 16:19, Alessandro Terenzi  wrote:
> Hi Robert,
> and thanks again for your help and suggestions. I'm aware of the remapping 
> done by OSG under the hood, indeed I had no issues with this when targeting 
> GLES 2 with version 3.4.0.
>
> I investigated my issue further and found out that a osg::Program is added to 
> the scene graph by the StateSet::setGlobalDefaults() method which does 
> something like this:
>
>
> Code:
> osg::DisplaySettings::ShaderHint shaderHint = 
> osg::DisplaySettings::instance()->getShaderHint();
> if (shaderHint==osg::DisplaySettings::SHADER_GL3 || 
> shaderHint==osg::DisplaySettings::SHADER_GLES3)
> {
> OSG_INFO<<"   StateSet::setGlobalDefaults() Setting up GL3 compatible 
> shaders"<
> osg::ref_ptr program = new osg::Program;
> program->addShader(new osg::Shader(osg::Shader::VERTEX, 
> gl3_VertexShader));
> program->addShader(new osg::Shader(osg::Shader::FRAGMENT, 
> gl3_FragmentShader));
> setAttributeAndModes(program.get());
> setTextureAttribute(0, createDefaultTexture());
> addUniform(new osg::Uniform("baseTexture", 0));
> }
>
>
>
> this automatically added program is the one that fails while linking.
>
> Now I'm trying to understand why it fails, but my question is: why is this 
> program added? Is it supposed to provide a 'default' program in case there's 
> nothing else in the scene graph? Can I avoid it to be added?
>
> I'm also trying to understand where StateSet::setGlobalDefaults() is called 
> in the first place...
>
> Cheers,
> Alessandro
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=72862#72862
>
>
>
>
>
> ___
> 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


Re: [osg-users] GLES link error for unidentified Program

2018-01-25 Thread Alessandro Terenzi
I did some more tests, tried to remove that 'program' from 
StateSet::setGlobalDefaults () and I realised that, at last, that very program 
is really not tried to be linked at all (it looks like the attached shaders are 
not even compiled, but I'm not 100% sure). 

So, I cannot say that the error comes from that 'program' in 
StateSet::setGlobalDefaults(), also because I tried to print the addresses of 
the 'program's being linked and I cannot track the origin of the one that fails 
to link...I also tried to get its attached shaders during the application loop 
but none is really attached to that program (calling getNumShaders() returns 0 
on the 'program' that is not linked).

I think that what I am missing is a deeper understanding about what happens 
beyond the setup of the simple scene graph that I explicitly do with my code. 
Is there the possibility that OSG automatically creates a 'program' somewhere 
else beyond my explicit code? Any suggestion where to look? I tried to search 
for strings like "new osg::Program" or "getOrCreateProgram" but could not 
figure out anything yet...

Thanks.
Alessandro

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] GLES link error for unidentified Program

2018-01-25 Thread Robert Osfield
Hi Alessandro,

I would recommend doing the tests on a desktop system and manually
select GLES builds, this should make it easier to go through the
various possibilities.

I would also recommend use git master if you aren't already.  At least
that way if you come across bugs then we can get them fixed more
easily.

Also could you test some standard OSG examples to see what happens.

Robert.

On 25 January 2018 at 18:05, Alessandro Terenzi  wrote:
> I did some more tests, tried to remove that 'program' from 
> StateSet::setGlobalDefaults () and I realised that, at last, that very 
> program is really not tried to be linked at all (it looks like the attached 
> shaders are not even compiled, but I'm not 100% sure).
>
> So, I cannot say that the error comes from that 'program' in 
> StateSet::setGlobalDefaults(), also because I tried to print the addresses of 
> the 'program's being linked and I cannot track the origin of the one that 
> fails to link...I also tried to get its attached shaders during the 
> application loop but none is really attached to that program (calling 
> getNumShaders() returns 0 on the 'program' that is not linked).
>
> I think that what I am missing is a deeper understanding about what happens 
> beyond the setup of the simple scene graph that I explicitly do with my code. 
> Is there the possibility that OSG automatically creates a 'program' somewhere 
> else beyond my explicit code? Any suggestion where to look? I tried to search 
> for strings like "new osg::Program" or "getOrCreateProgram" but could not 
> figure out anything yet...
>
> Thanks.
> Alessandro
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=72863#72863
>
>
>
>
>
> ___
> 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


Re: [osg-users] GLES link error for unidentified Program

2018-01-25 Thread Alessandro Terenzi
Hi Robert,
and thanks again for your help and suggestions. I'm aware of the remapping done 
by OSG under the hood, indeed I had no issues with this when targeting GLES 2 
with version 3.4.0.

I investigated my issue further and found out that a osg::Program is added to 
the scene graph by the StateSet::setGlobalDefaults() method which does 
something like this:

  
Code:
osg::DisplaySettings::ShaderHint shaderHint = 
osg::DisplaySettings::instance()->getShaderHint();
if (shaderHint==osg::DisplaySettings::SHADER_GL3 || 
shaderHint==osg::DisplaySettings::SHADER_GLES3)
{
OSG_INFO<<"   StateSet::setGlobalDefaults() Setting up GL3 compatible 
shaders"<addShader(new osg::Shader(osg::Shader::VERTEX, 
gl3_VertexShader));
program->addShader(new osg::Shader(osg::Shader::FRAGMENT, 
gl3_FragmentShader));
setAttributeAndModes(program.get());
setTextureAttribute(0, createDefaultTexture());
addUniform(new osg::Uniform("baseTexture", 0));
}



this automatically added program is the one that fails while linking. 

Now I'm trying to understand why it fails, but my question is: why is this 
program added? Is it supposed to provide a 'default' program in case there's 
nothing else in the scene graph? Can I avoid it to be added? 

I'm also trying to understand where StateSet::setGlobalDefaults() is called in 
the first place...

Cheers,
Alessandro

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] GLES link error for unidentified Program

2018-01-25 Thread Robert Osfield
Hi Alessandro,

I tested the models under my GL2 build of the OSG and the dump1.osgt
worked fine for me without any errors.  I don't have time to test GLES
right now.

The vertex shader doesn't provide any hint for the precision, it might
be the the GLES drivers GLSL compiler is having an issue with that.

Also when targeting just GLES you always have to use the OSG's version
of gl_ModelViewMatrix, gl_Vertex etc, so you'll need to use
osg_ModelViewMatrix, osg_Vertex etc.  The osg::State class will by
default be remapping these for you with the GLES2+ build so behind the
scenes this is being handled for you.  While you should be aware that
this is happening, I don't think it's related to the issue you are
seeing.  If you want to keep the shaders portable to GL2 then leaving
the gl_ModelViewMatrix in place is fine.

The master version of the OSG now provide support for inject
environmental values via osg::DisplaySettings::setValues(..), and
provides some defaults for these like OSG_GLSL_VERSION and
$OSG_PRECISSION_FLOAT tailored for the build type such as GL/GL3/GLES.
You can see this in action in the text.vert now in OpenSceneGraph-Data
master and OSG master (and recent dev release):

$OSG_GLSL_VERSION
$OSG_PRECISION_FLOAT

$OSG_VARYING_OUT vec2 texCoord;
$OSG_VARYING_OUT vec4 vertexColor;

void main(void)
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
texCoord = gl_MultiTexCoord0.xy;
vertexColor = gl_Color;
}

It might be that it would be appropriate to use these to help with
future shaders to allow you to port between platforms easily.

Robert.

On 24 January 2018 at 16:18, Alessandro Terenzi  wrote:
> Hi,
> I used to work with OSG 3.4.0 (stable) and now I'm trying version 3.5.10 on 
> iOS (trying both GLES 2 and 3) but now I having the following error when the 
> first frame is drawn:
>
> glLinkProgram 0x1c41cda70"" FAILED
> Program "" infolog:
> ERROR: OpenGL ES requires exactly one vertex and one fragment shader to 
> validly link.
>
> Note that I have only one quad to which I apply a texture, I'm using a single 
> 'vertex' and 'fragment shader' and there's only on 'program' around. The same 
> code works fine with OSG 3.4.0 and even though with version 3.5.10 there is 
> the above error, the texture is nonetheless displayed.
>
> If I use a more verbose notification level I see that my program "BckProgram" 
> is compiled and linked correctly but then another program with empty name is 
> tried to be linked and it is the one for which I'm receiving the above error, 
> but I did not create a second program anywhere... am I missing something?
>
> And here's the verbose log:
>
> View::init()
> cull()
> cull() got SceneView 0x106510300
> ShaderComposer::~ShaderComposer() 0x1c02d7450
> Uniform Adding parent
> Uniform Adding parent
> Uniform Adding parent
> Uniform Adding parent
> Uniform Adding parent
> Uniform Adding parent
> Uniform Adding parent
> end cull() 0x1065101f0
> draw() got SceneView 0x106510300
> Renderer::compile()
> State::convertShaderSourceToOsgBuiltIns()
> ++Before Converted source
> varying vec2 texcoord;
> void main(void)
> {
> texcoord = gl_MultiTexCoord0.xy;
> gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
> }
>
> 
>  Converted source
> attribute vec4 osg_MultiTexCoord0;
> attribute vec4 osg_Vertex;
> uniform mat4 osg_ModelViewProjectionMatrix;
> varying vec2 texcoord;
> void main(void)
> {
> texcoord = osg_MultiTexCoord0.xy;
> gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;
> }
>
> 
>
> Compiling A :VERTEX source:
> 1: attribute vec4 osg_MultiTexCoord0;
> 2: attribute vec4 osg_Vertex;
> 3: uniform mat4 osg_ModelViewProjectionMatrix;
> 4: varying vec2 texcoord;
> 5: void main(void)
> 6: {
> 7: texcoord = osg_MultiTexCoord0.xy;
> 8: gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex;
> 9: }
>
> State::convertShaderSourceToOsgBuiltIns()
> ++Before Converted source
> precision mediump float;
> uniform sampler2D texture0;
> varying vec2 texcoord;
> void main(void)
> {
> gl_FragColor = texture2D( texture0, vec2(texcoord.x, 1.0-texcoord.y));
> }
>
> 
>  Converted source
> precision mediump float;
> uniform sampler2D texture0;
> varying vec2 texcoord;
> void main(void)
> {
> gl_FragColor = texture2D( texture0, vec2(texcoord.x, 1.0-texcoord.y));
> }
>
> 
>
> Compiling A :FRAGMENT source:
> 1: precision mediump float;
> 2: uniform sampler2D texture0;
> 3: varying vec2 texcoord;
> 4: void main(void)
> 5: {
> 6: gl_FragColor = texture2D( texture0, vec2(texcoord.x, 
> 1.0-texcoord.y));
> 7: }
>
> Linking osg::Program "BckProgram" id=3 contextID=0
> State's vertex attrib binding 2, osg_Color
> State's vertex attrib binding 12, osg_FogCoord
> State's vertex attrib binding 3, osg_MultiTexCoord0
> State's vertex attrib binding 4, osg_MultiTexCoord1
> State's vertex attrib