Re: [osg-users] Temporarily overriding alpha channel

2019-04-07 Thread Claudio Benghi
Hi all,

If anyone finds this useful, my current solution, combining help from this 
thread and Paul Martz at http://forum.openscenegraph.org/viewtopic.php?t=13877, 
looks like the following:


Code:

osg::StateSet* state = _rootGroup->getOrCreateStateSet();
if (op == 1)
{
 state->removeAttribute(osg::StateAttribute::BLENDCOLOR);
 state->removeAttribute(osg::StateAttribute::BLENDFUNC);
 state->setRenderingHint(osg::StateSet::DEFAULT_BIN);
}
else
{
 osg::BlendColor* bc = new osg::BlendColor(osg::Vec4(1.0, 1.0, 1.0, op));
 osg::BlendFunc *bf = new osg::BlendFunc();
 state->setAttributeAndModes(bf, osg::StateAttribute::ON);
 state->setAttributeAndModes(bc, osg::StateAttribute::ON);
 bf->setSource(osg::BlendFunc::CONSTANT_ALPHA);
 bf->setDestination(osg::BlendFunc::ONE_MINUS_CONSTANT_ALPHA);
 state->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
}




Next I'll try to see if I can set a material so that the blend settings are 
ignored for a part of the sub-tree.

Thanks for all the help that carried me this far!
Claudio

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





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


Re: [osg-users] Temporarily overriding alpha channel

2019-04-07 Thread Claudio Benghi
Thanks Chris,

Apologies for the long delay, I've been moving home from the last post, I will 
be able to pickup your advice this week.

I'll have good look at the fixed pipeline blending functions.

Thank you!
Claudio

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





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


Re: [osg-users] Temporarily overriding alpha channel

2019-02-18 Thread Chris Hanson
So, all OSG state (including Uniforms) are managed in a hierarchical
manner, with override rules. So, you can select a section of the graph and
designate all of it to have Uniforms defining transparency and all of the
scene below that Uniform state will have those Uniforms applied and be
transparent.

BUT, you can also apply a State and Uniform(s) to a subset of the graph
WITHIN that transparent graph to override the first set of uniforms and
make it non-transparent. This would achieve the effect you are looking for.


You could do this with either shader-based transparency or just with
simple blending mode states with OpenGL Fixed Function features.


On Mon, Feb 18, 2019 at 1:02 PM Claudio Benghi 
wrote:

> Thanks Chris,
> that's very helpful. I'll have a look at your code.
>
> I've uploaded a video that might give you an idea of what I'm aiming at.
>
> In the video, I have a similar functionality in a open source WPF viewer
> that I've produced.
> The slider on the bottom left of the UI makes all objects transparent to
> allow to see the location of the selected walls through the walls of a
> building.
>
> https://youtu.be/7n3K52c1GtU
>
> Any selected wall, instead, is kept opaque.
>
> I think an uniform could be the solution, but it would need a way to
> exclude some elements of the scene from its application.
>
> Any suggestion is welcome.
>
> All the best,
> Claudio
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=75634#75634
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>


-- 
Chris 'Xenon' Hanson, omo sanza lettere. xe...@alphapixel.com
http://www.alphapixel.com/
Training • Consulting • Contracting
3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL 4 •
GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL
Legal/IP • Forensics • Imaging • UAVs • GIS • GPS •
osgEarth • Terrain • Telemetry • Cryptography • LIDAR • Embedded • Mobile •
iPhone/iPad/iOS • Android
@alphapixel  facebook.com/alphapixel (775)
623-PIXL [7495]
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Temporarily overriding alpha channel

2019-02-18 Thread Claudio Benghi
Thanks Chris,
that's very helpful. I'll have a look at your code.

I've uploaded a video that might give you an idea of what I'm aiming at.

In the video, I have a similar functionality in a open source WPF viewer that 
I've produced.
The slider on the bottom left of the UI makes all objects transparent to allow 
to see the location of the selected walls through the walls of a building.

https://youtu.be/7n3K52c1GtU

Any selected wall, instead, is kept opaque. 

I think an uniform could be the solution, but it would need a way to exclude 
some elements of the scene from its application. 

Any suggestion is welcome.

All the best,
Claudio

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





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


Re: [osg-users] Temporarily overriding alpha channel

2019-02-15 Thread Chris Hanson
Normally I'd do this with some kind of shader and a Uniform to control the
transparency.

If you haven't seen it already, I'd take a look at this set of code we did
for a client a few years ago:

http://alphapixel.com/project/osg-transparency-toolkit/

It was made for large complex CAD scenes where z-sorting is not always an
option. It has a couple of non-sorted transparency approximations with
various side-effects, plus an Order Independent Transparency implementation
you can easily slap into a scene.


I'm not totally sure what you mean by transparency "channel". Channel
usually refers to an image-based transparency/alpha channel, which isn't
usually necessary in order to make a whole subgraph transparent. You'd just
need to set some blend state and such on a parent node and then remove it
when you didn't want it.

Maybe explain more clearly what you think you need and what difficulty you
are imagining it will have?


On Fri, Feb 15, 2019 at 5:41 PM Claudio Benghi 
wrote:

> Hi,
>
> Is there a way to override the transparency channel of a sub tree in the
> scene?
>
> My application shows buildings and their components and I want to give the
> user a sort of x-ray vision in some circumstances to help locate items
> behind walls.
>
> I know that ideally this would require to z-sort all the elements in the
> view, but I'm not much concerned with the correct sorting at the moment.
>
> These models are sometimes *very* large, so something that uses an
> override value that I can then cheaply remove would be ideal.
>
> Any ideas?
>
> Thanks,
> Claudio
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=75632#75632
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>


-- 
Chris 'Xenon' Hanson, omo sanza lettere. xe...@alphapixel.com
http://www.alphapixel.com/
Training • Consulting • Contracting
3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL 4 •
GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL
Legal/IP • Forensics • Imaging • UAVs • GIS • GPS •
osgEarth • Terrain • Telemetry • Cryptography • LIDAR • Embedded • Mobile •
iPhone/iPad/iOS • Android
@alphapixel  facebook.com/alphapixel (775)
623-PIXL [7495]
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org