Re: [osg-users] How to handle cameras in the scene graph when rendering to framebuffer

2017-02-24 Thread Robert Osfield
Hi Werner,

In principle what you are doing should be possible.  What is going
wrong in your instance is impossible to say without seeing how you are
setting up the viewer Camera's and the in scene graph Camera's.

Robert.

On 24 February 2017 at 16:44, Werner Modenbach
 wrote:
> Hi all,
> sorry for so many questions today.
>
> My scene graph has additional cameras as children somewhere in the scene
> graph.
> For example a hud camera for a background image.
>
> I do screenshots by adding a slave camera to the main camera which renders
> the scene to the FB.
> Unfortunately this rendering doesn't show the parts of the nested cameras,
> i.e. no
> background wallpaper.
> What is the recommended way to solve this?
>
> Thanks for any help.
>
> - Werner -
>
>
> ___
> 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


[osg-users] How to handle cameras in the scene graph when rendering to framebuffer

2017-02-24 Thread Werner Modenbach

Hi all,
sorry for so many questions today.

My scene graph has additional cameras as children somewhere in the scene 
graph.

For example a hud camera for a background image.

I do screenshots by adding a slave camera to the main camera which 
renders the scene to the FB.
Unfortunately this rendering doesn't show the parts of the nested 
cameras, i.e. no

background wallpaper.
What is the recommended way to solve this?

Thanks for any help.

- Werner -


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


Re: [osg-users] issue with 3ds model after upgrading to 3.5.5

2017-02-24 Thread Philippe Renon
I used git bisect to find when the issue was introduced.
Culprit commit is 
https://github.com/openscenegraph/OpenSceneGraph/commit/3609d84cef43bca784b5f3c5e448e7f475e6
 

@mrchlblng, I must have messed up something when testing your patch.
I retested it again 3.5.5 and it fixes the 3ds plugin issue I was having :)

Cheers,
Philippe.

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





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


Re: [osg-users] Camera resize vs setViewport

2017-02-24 Thread Robert Osfield
On 24 February 2017 at 15:18, Ravi Mathur  wrote:
> Thanks Robert. But still, why does resize() not accept x/y arguments? As it 
> is now, it cannot be used with CompositeViewer where Cameras are distributed 
> around the window with various Viewports. Is it just intended for use with 
> the regular osg::Viewer?

It's a resize of the window.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Text colors in shaders

2017-02-24 Thread Robert Osfield
On 24 February 2017 at 15:15, Werner Modenbach
 wrote:
> Hi Robert,
>
> thanks for the good explanations - as we are used from your side :-)
> I cannot switch completely to gl3 because I have customers whose
> hardware/driver doesn't support it
> So at the start of the application I analyze it and use the
>
> camera->getGraphicsContext()->getState()->setUseModelViewAndProjectionUniforms(useGL3);
> camera->getGraphicsContext()->getState()->setUseVertexAttributeAliasing(useGL3);
>
> accordingly. It's for sure a burden but what can I do?

I don't know witthout testing your specific shader and scene graph setup.

For your own work, if you can't switching completely to GL3 why not
just use standard OSG build and not bother with the aliasing.  For
decent GL drivers you should get access to modern GL features via the
OSG extension system, you don't need to go explicitly enabling GL3/GL4
features. the only exception is OSX and their CL3 core profile mess.

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


Re: [osg-users] osgShadow and gl3

2017-02-24 Thread Robert Osfield
HI Werner,

In the stable releases rhere isn't any built in support for remapping
built in types like osg::TexGen that set the gl_EyePlane etc.
attributes to osg_EyePlane uniforms.

I have an experimental branch, shader_pipeline, that has the
beginnings of a mapping to do this but it's not yet ready for general
testing.

For yourself, if you can build the OSG without specifically limiting
yourself to GL core profile then you'll get a better experience.  The
exception right now is OSX because Apple have taken the approach of
not implementation any modern GL features, and even GL3 they've
limited to a subset of only the GL3 core profile, no backwards
compatibility is provided.  OSX doesn't support GL4 yet, and no signs
of Vulkan support so it kinda looks like Apple are happy to relegate
OSX boxes to graphics backwater.

Robert.

Robert.

On 24 February 2017 at 14:52, Werner Modenbach
 wrote:
> Hi all,
>
> my project needs gl3 features and so I use the following methods:
>
> camera->getGraphicsContext()->getState()->setUseModelViewAndProjectionUniforms(useGL3);
> camera->getGraphicsContext()->getState()->setUseVertexAttributeAliasing(useGL3);
>
> Of course I need my own shaders then.
> I'm trying to make osgShadow working with my project.
> So far I have found the shader codes in StandardShadowMap and I try merging
> the functionality with my own shaders.
> Where I'm struggling is the gl_EyePlane[STRQ] stuff. It seems that is not
> made available as osg_EyePlane[STRQ] like other
> gl_ variables. Am I right? Is there any known way to get this working?
>
> Also there are cameras used inside shadowmaps. Those cameras have their own
> shaders (?) which are not gl3 conformant.
> Can this be influenced from my application?
>
> Thanks for any hints.
>
> - Werner -
>
> ___
> 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] Camera resize vs setViewport

2017-02-24 Thread Ravi Mathur
Thanks Robert. But still, why does resize() not accept x/y arguments? As it is 
now, it cannot be used with CompositeViewer where Cameras are distributed 
around the window with various Viewports. Is it just intended for use with the 
regular osg::Viewer?


robertosfield wrote:
> Hi Ravi,
> 
> The resize is primarily for responding to window resize events where
> you need to adjust the viewport and projection matrix to provide
> sensible on screen behaviour.
> 
> The setViewport() method just sets the viewport, it doesn't try to do
> anything with any other paramters such as the projection matrix.
> 
> Robert.
> 


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





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


Re: [osg-users] Text colors in shaders

2017-02-24 Thread Werner Modenbach

Hi Robert,

thanks for the good explanations - as we are used from your side :-)
I cannot switch completely to gl3 because I have customers whose 
hardware/driver doesn't support it

So at the start of the application I analyze it and use the

camera->getGraphicsContext()->getState()->setUseModelViewAndProjectionUniforms(useGL3);
camera->getGraphicsContext()->getState()->setUseVertexAttributeAliasing(useGL3);

accordingly. It's for sure a burden but what can I do?

Thanks for your excellent support!

- Werner -

Am 24.02.2017 um 16:09 schrieb Robert Osfield:

On 24 February 2017 at 14:30, Werner Modenbach
 wrote:

that's great. It works with the shader you suggested.
Strange is, that just using vertex color doesn't work. It seems alpha is set
to transparent (0).
Also a texture is set but only alpha has a meaning. Texture color is black.
That looks odd to me.

If you build the OSG against the GL3 core profile it maps the texture
format to GL_RED rather than GL_ALPHA as the later is no longer
supported.  The graphics hardware doesn't expand GL_RED in the same
way as GL_ALPHA so it can cause problems.  It's a bit of pain having
GL pull the rug from GL_ALPHA as it has a particularly useful mapping.
Potentially one could use texture swizzle to get round this but it's
not support on all GL versions.

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


--
*TEXION Software Solutions, Rotter Bruch 26a, D-52068 Aachen*
Phone: +49 241 475757-0
Fax: +49 241 475757-29
Web: http://texion.eu
eMail: i...@texion.eu
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Text colors in shaders

2017-02-24 Thread Robert Osfield
On 24 February 2017 at 14:30, Werner Modenbach
 wrote:
> that's great. It works with the shader you suggested.
> Strange is, that just using vertex color doesn't work. It seems alpha is set
> to transparent (0).
> Also a texture is set but only alpha has a meaning. Texture color is black.
> That looks odd to me.

If you build the OSG against the GL3 core profile it maps the texture
format to GL_RED rather than GL_ALPHA as the later is no longer
supported.  The graphics hardware doesn't expand GL_RED in the same
way as GL_ALPHA so it can cause problems.  It's a bit of pain having
GL pull the rug from GL_ALPHA as it has a particularly useful mapping.
Potentially one could use texture swizzle to get round this but it's
not support on all GL versions.

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


[osg-users] osgShadow and gl3

2017-02-24 Thread Werner Modenbach

Hi all,

my project needs gl3 features and so I use the following methods:

camera->getGraphicsContext()->getState()->setUseModelViewAndProjectionUniforms(useGL3); 

camera->getGraphicsContext()->getState()->setUseVertexAttributeAliasing(useGL3); 



Of course I need my own shaders then.
I'm trying to make osgShadow working with my project.
So far I have found the shader codes in StandardShadowMap and I try 
merging the functionality with my own shaders.
Where I'm struggling is the gl_EyePlane[STRQ] stuff. It seems that is 
not made available as osg_EyePlane[STRQ] like other

gl_ variables. Am I right? Is there any known way to get this working?

Also there are cameras used inside shadowmaps. Those cameras have their 
own shaders (?) which are not gl3 conformant.

Can this be influenced from my application?

Thanks for any hints.

- Werner -

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


Re: [osg-users] Text colors in shaders

2017-02-24 Thread Werner Modenbach

Hi Sebastian,

that's great. It works with the shader you suggested.
Strange is, that just using vertex color doesn't work. It seems alpha is 
set to transparent (0).

Also a texture is set but only alpha has a meaning. Texture color is black.
That looks odd to me.

But anyway, I'm happy now.

- Werner -

Am 24.02.2017 um 13:16 schrieb Sebastian Messerschmidt:



Am 2/24/2017 um 12:57 PM schrieb Werner Modenbach:

Dear all,

my project needs gl3 features and so I use the following methods:


camera->getGraphicsContext()->getState()->setUseModelViewAndProjectionUniforms(useGL3); 



camera->getGraphicsContext()->getState()->setUseVertexAttributeAliasing(useGL3); 



Of course I need my own shaders then.
But I also like having built-in functionality like StatsHandler.
To set a simple shader for the StatsHandlers camera I do like that:

osgViewer::StatsHandler*sthd=newosgViewer::StatsHandler;

view->addEventHandler(sthd);

if(useGL3){
stateSet=sthd->getCamera()->getOrCreateStateSet();

stateSet->getOrCreateUniform(BASE_TEXTURE_UNIFORM,osg::Uniform::INT_SAMPLER_2D)->set(BASE_TEXTURE_UNIT); 



stateSet->setTextureAttributeAndModes(BASE_TEXTURE_UNIT,textur_weiss.get(),osg::StateAttribute::ON); 



installDefaultShader(stateSet);

}

The shaders are really simple:
VERTEX

uniformmat4osg_ModelViewProjectionMatrix;
uniformmat4osg_ModelViewMatrix;

uniformmat3osg_NormalMatrix;

uniformvec3lightPosition0=vec3(0.0f,0.0f,1.0f);

invec4osg_Vertex;

invec4osg_Normal;

invec4osg_Color;

invec4osg_MultiTexCoord0;

outvec3normal;

outvec3lightDir;

outvec4vertexColor;

outvec2textureCoord;

voidmain(){

normal=normalize(osg_NormalMatrix*osg_Normal.xyz);

vec3vertexPos=vec3(osg_ModelViewMatrix*osg_Vertex);

lightDir=normalize(lightPosition0-vertexPos);

vertexColor=osg_Color;

textureCoord=osg_MultiTexCoord0.xy;

gl_Position=osg_ModelViewProjectionMatrix*osg_Vertex;

}


FRAGMENT

uniformsampler2DbaseTexture;

invec3normal;
invec3lightDir;

invec4vertexColor;

invec2textureCoord;

outvec4fragData;

voidmain(){

vec4textureColor=texture2D(baseTexture,textureCoord);
fragData=vertexColor*textureColor;

}


That works fine for the graphics but all text is black. Obviously text
does not set osg_Color .


osg_Color is an alias for the color-vertex attribute. Colors are set in
void Text::drawForegroundText ~line 1628. So there should be colors.

My fragment shader looks like this:

#version 440
#extension GL_ARB_enhanced_layouts : enable
#extension GL_ARB_separate_shader_objects : enable

layout (location=0) out vec4 FragmentData;

layout(location=1) in block
{
mediump vec2 tex_coord;
mediump vec4 color;
} In;


uniform sampler2D osg_Texture;

void main()
{

vec4 diffuse_color = In.color;

diffuse_color *=  texture2D(osg_Texture, In.tex_coord).a;

FragmentData = diffuse_color;
}

which seems to work. As you can see I'm using the alpha channel only.

Cheers
Sebastian



Unfortunately I failed discovering the reason in the sources of osg.

Can anyone give me a hint on how to solve this?

Many thanks in advance

- Werner -



___
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


--
*TEXION Software Solutions, Rotter Bruch 26a, D-52068 Aachen*
Phone: +49 241 475757-0
Fax: +49 241 475757-29
Web: http://texion.eu
eMail: i...@texion.eu
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Text colors in shaders

2017-02-24 Thread Sebastian Messerschmidt



Am 2/24/2017 um 12:57 PM schrieb Werner Modenbach:

Dear all,

my project needs gl3 features and so I use the following methods:


camera->getGraphicsContext()->getState()->setUseModelViewAndProjectionUniforms(useGL3);

camera->getGraphicsContext()->getState()->setUseVertexAttributeAliasing(useGL3);

Of course I need my own shaders then.
But I also like having built-in functionality like StatsHandler.
To set a simple shader for the StatsHandlers camera I do like that:

osgViewer::StatsHandler*sthd=newosgViewer::StatsHandler;

view->addEventHandler(sthd);

if(useGL3){
stateSet=sthd->getCamera()->getOrCreateStateSet();

stateSet->getOrCreateUniform(BASE_TEXTURE_UNIFORM,osg::Uniform::INT_SAMPLER_2D)->set(BASE_TEXTURE_UNIT);

stateSet->setTextureAttributeAndModes(BASE_TEXTURE_UNIT,textur_weiss.get(),osg::StateAttribute::ON);

installDefaultShader(stateSet);

}

The shaders are really simple:
VERTEX

uniformmat4osg_ModelViewProjectionMatrix;
uniformmat4osg_ModelViewMatrix;

uniformmat3osg_NormalMatrix;

uniformvec3lightPosition0=vec3(0.0f,0.0f,1.0f);

invec4osg_Vertex;

invec4osg_Normal;

invec4osg_Color;

invec4osg_MultiTexCoord0;

outvec3normal;

outvec3lightDir;

outvec4vertexColor;

outvec2textureCoord;

voidmain(){

normal=normalize(osg_NormalMatrix*osg_Normal.xyz);

vec3vertexPos=vec3(osg_ModelViewMatrix*osg_Vertex);

lightDir=normalize(lightPosition0-vertexPos);

vertexColor=osg_Color;

textureCoord=osg_MultiTexCoord0.xy;

gl_Position=osg_ModelViewProjectionMatrix*osg_Vertex;

}


FRAGMENT

uniformsampler2DbaseTexture;

invec3normal;
invec3lightDir;

invec4vertexColor;

invec2textureCoord;

outvec4fragData;

voidmain(){

vec4textureColor=texture2D(baseTexture,textureCoord);
fragData=vertexColor*textureColor;

}


That works fine for the graphics but all text is black. Obviously text
does not set osg_Color .


osg_Color is an alias for the color-vertex attribute. Colors are set in
void Text::drawForegroundText ~line 1628. So there should be colors.

My fragment shader looks like this:

#version 440
#extension GL_ARB_enhanced_layouts : enable
#extension GL_ARB_separate_shader_objects : enable

layout (location=0) out vec4 FragmentData;

layout(location=1) in block
{
mediump vec2 tex_coord;
mediump vec4 color;
} In;


uniform sampler2D osg_Texture;

void main()
{

vec4 diffuse_color = In.color;

diffuse_color *=  texture2D(osg_Texture, In.tex_coord).a;

FragmentData = diffuse_color;
}

which seems to work. As you can see I'm using the alpha channel only.

Cheers
Sebastian



Unfortunately I failed discovering the reason in the sources of osg.

Can anyone give me a hint on how to solve this?

Many thanks in advance

- Werner -



___
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


[osg-users] Text colors in shaders

2017-02-24 Thread Werner Modenbach

Dear all,

my project needs gl3 features and so I use the following methods:

camera->getGraphicsContext()->getState()->setUseModelViewAndProjectionUniforms(useGL3);

camera->getGraphicsContext()->getState()->setUseVertexAttributeAliasing(useGL3);

Of course I need my own shaders then.
But I also like having built-in functionality like StatsHandler.
To set a simple shader for the StatsHandlers camera I do like that:

osgViewer::StatsHandler*sthd=newosgViewer::StatsHandler;

view->addEventHandler(sthd);

if(useGL3){
stateSet=sthd->getCamera()->getOrCreateStateSet();

stateSet->getOrCreateUniform(BASE_TEXTURE_UNIFORM,osg::Uniform::INT_SAMPLER_2D)->set(BASE_TEXTURE_UNIT);

stateSet->setTextureAttributeAndModes(BASE_TEXTURE_UNIT,textur_weiss.get(),osg::StateAttribute::ON);

installDefaultShader(stateSet);

}

The shaders are really simple:
VERTEX

uniformmat4osg_ModelViewProjectionMatrix;
uniformmat4osg_ModelViewMatrix;

uniformmat3osg_NormalMatrix;

uniformvec3lightPosition0=vec3(0.0f,0.0f,1.0f);

invec4osg_Vertex;

invec4osg_Normal;

invec4osg_Color;

invec4osg_MultiTexCoord0;

outvec3normal;

outvec3lightDir;

outvec4vertexColor;

outvec2textureCoord;

voidmain(){

normal=normalize(osg_NormalMatrix*osg_Normal.xyz);

vec3vertexPos=vec3(osg_ModelViewMatrix*osg_Vertex);

lightDir=normalize(lightPosition0-vertexPos);

vertexColor=osg_Color;

textureCoord=osg_MultiTexCoord0.xy;

gl_Position=osg_ModelViewProjectionMatrix*osg_Vertex;

}


FRAGMENT

uniformsampler2DbaseTexture;

invec3normal;
invec3lightDir;

invec4vertexColor;

invec2textureCoord;

outvec4fragData;

voidmain(){

vec4textureColor=texture2D(baseTexture,textureCoord);
fragData=vertexColor*textureColor;

}


That works fine for the graphics but all text is black. Obviously text 
does not set osg_Color .

Unfortunately I failed discovering the reason in the sources of osg.

Can anyone give me a hint on how to solve this?

Many thanks in advance

- Werner -

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


Re: [osg-users] Camera resize vs setViewport

2017-02-24 Thread Robert Osfield
Hi Ravi,

The resize is primarily for responding to window resize events where
you need to adjust the viewport and projection matrix to provide
sensible on screen behaviour.

The setViewport() method just sets the viewport, it doesn't try to do
anything with any other paramters such as the projection matrix.

Robert.

On 24 February 2017 at 03:13, Ravi Mathur  wrote:
> Hi all,
>
> In osg::Camera, there exist two resize functions: Camera::resize(width, 
> height) and Camera::setViewport(x, y, width, height). I'm confused 
> conceptually as to when to use which one. Some examples use resize 
> (osgdistortion), whereas others use setViewport (osghud).
>
> Looking at the Camera.cpp code, it looks like resize() calls setViewport(), 
> but why does it not then accept x/y position arguments? For example, I have a 
> CompositeViewer with multiple Views. Each View has a master & slave (HUD) 
> camera, which are set up in a grid format on the GraphicsContext. I 
> initialize each master/slave combo using setViewport() but I can't use 
> Camera::resize() since I can't pass it the x/y coordinates.
>
> What am I missing here? When is it appropriate to call Camera::resize() 
> instead of Camera::setViewport()?
>
> Thanks,
> Ravi
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=70333#70333
>
>
>
>
>
> ___
> 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