Re: [osg-users] Check if sampler2D is valid in fragment shader

2017-01-03 Thread Alberto Luaces
"Rômulo Cerqueira" writes:

> Hi Sebastian,
>
> I have used the last openscenegraph stable package in ubuntu (version
> 3.2.3 - https://launchpad.net/ubuntu/+source/openscenegraph), and
> there is no setDefine() method in osg::StateSet (only for 2.4 and
> newer). There is a different way?
>

Hi Rômulo, you also have OSG 3.4 available in Yakkety (current stable)
under a slightly different name:

https://launchpad.net/ubuntu/+source/openscenegraph-3.4

-- 
Alberto

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


Re: [osg-users] Check if sampler2D is valid in fragment shader

2017-01-03 Thread Rômulo Cerqueira
Hi,


> 
> I can create a minimal example if you're stuck with this. 
> 


I will appreciate this, please.
... 

Thank you!

Cheers,
Rômulo

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





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


Re: [osg-users] Check if sampler2D is valid in fragment shader

2017-01-03 Thread Sebastian Messerschmidt

Hi, yes there is:

Simply assign one Program with shaders handling texturing and the 
non-texturing variant at the appropriate state-sets. Be sure to share 
the programs (don't create a new one per instance) to keep performance up.


I can create a minimal example if you're stuck with this.

Cheers
Sebastian

Hi Sebastian,

I have used the last openscenegraph stable package in ubuntu (version 3.2.3 - 
https://launchpad.net/ubuntu/+source/openscenegraph), and there is no 
setDefine() method in osg::StateSet (only for 2.4 and newer). There is a 
different way?

Cheers,
Rômulo

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





___
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] Check if sampler2D is valid in fragment shader

2017-01-03 Thread Christian Buchner
Pragmatic shader composition was added to the repository around Feb 13,
2015, and most likely into OSG 3.4 and newer only.

A link to the relevant thread started by Robert Osfield is here:
http://markmail.org/message/mjxjn4vujpvz3wfz#query:+page:1+mid:vogwv7uwhoefcln6+state:results


2017-01-03 14:48 GMT+01:00 Rômulo Cerqueira :

> Hi Sebastian,
>
> I have used the last openscenegraph stable package in ubuntu (version
> 3.2.3 - https://launchpad.net/ubuntu/+source/openscenegraph), and there
> is no setDefine() method in osg::StateSet (only for 2.4 and newer). There
> is a different way?
>
> Cheers,
> Rômulo
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=69840#69840
>
>
>
>
>
> ___
> 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] Check if sampler2D is valid in fragment shader

2017-01-03 Thread Rômulo Cerqueira
Hi Sebastian,

I have used the last openscenegraph stable package in ubuntu (version 3.2.3 - 
https://launchpad.net/ubuntu/+source/openscenegraph), and there is no 
setDefine() method in osg::StateSet (only for 2.4 and newer). There is a 
different way?

Cheers,
Rômulo

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





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


Re: [osg-users] Check if sampler2D is valid in fragment shader

2016-12-29 Thread Sebastian Messerschmidt



Am 29.12.2016 um 17:07 schrieb Rômulo Cerqueira:

Hi Christian,



You could traverse the scene graph and check the state sets to see if they bind 
a texture to a texture unit.

Then depending on these findings, choose the correct shader code.


I appreciated it. Can you give me some example?
Basically alot of scenegraph handling is built around the 
VisitorPattern. To use it, derive your visitor from the osg::NodeVisitor 
base class and override the appropriate apply-functions.

There are a lot of examples in the OSG code base and the examples.
In your case you might want to consider to use the osg::Node-apply 
function and simply check for a StateSet which contains the texture. In 
case you find a texture you might use the proposed pragmatic shader 
composition.
Simply set a "USE_TEXTURE"-define for the nodes with textures (via the 
stateSet->setDefine).


Cheers
Sebastian


...

Thank you!

Cheers,
Rômulo

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





___
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] Check if sampler2D is valid in fragment shader

2016-12-29 Thread Rômulo Cerqueira
Hi Christian,


> You could traverse the scene graph and check the state sets to see if they 
> bind a texture to a texture unit. 
> 
> Then depending on these findings, choose the correct shader code. 


I appreciated it. Can you give me some example?
... 

Thank you!

Cheers,
Rômulo

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





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


Re: [osg-users] Check if sampler2D is valid in fragment shader

2016-12-29 Thread Christian Buchner
> I will receive the final scene with or without textures

You could traverse the scene graph and check the state sets to see if they
bind a texture to a texture unit.
Then depending on these findings, choose the correct shader code.

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


Re: [osg-users] Check if sampler2D is valid in fragment shader

2016-12-28 Thread Rômulo Cerqueira
Hi Sebastian,


> 
> There is no direct way. If you need shaders with and without texturing 
> you should bind different programs to the affected geometries. 
> 


I think my problem is a little bit different. I will receive the final scene 
with or without textures and process it properly. I won't participate in the 
scene development.

... 

Thank you!

Cheers,
Rômulo

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





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


Re: [osg-users] Check if sampler2D is valid in fragment shader

2016-12-27 Thread Sebastian Messerschmidt



Hi Rômulo,

Hi,

is there a way to check if a texture (as uniform sampler2D) is valid in 
fragment shader?
There is no direct way. If you need shaders with and without texturing 
you should bind different programs to the affected geometries.
Also OSG has the pragmatic-shadercomposition which allows you to use 
#defines to be set in the OSG-code. See the osgshadercomposition for 
reference.




This is my current code:


Code:

if (textureSize(myTexture, 0).x > 1) {
// do something with the texture
}
else {
// process without texture information
}
You shouldn't use this. AFAIK there is no rule how the driver evaluates 
non-bound samplers, so this might lead to undesired behavior. Even if it 
is working it will cost some amount of performance.


Cheers
Sebastian




...

Thank you in advance!

Cheers,
Rômulo

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





___
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] Check if sampler2D is valid in fragment shader

2016-12-26 Thread Rômulo Cerqueira
Hi,

is there a way to check if a texture (as uniform sampler2D) is valid in 
fragment shader?

This is my current code:


Code:

if (textureSize(myTexture, 0).x > 1) {
// do something with the texture
}
else {
// process without texture information
}



... 

Thank you in advance!

Cheers,
Rômulo

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





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