<div dir="ltr">Also, if it matters, I found that I can get the rendering I'd expect if I explicitly set the BlendFunc in the special case of Isosurface:<div><br></div><div><div> if (volumeProperties.useIsosurface){</div><div> stateset->setAttribute(new osg::BlendFunc(GL_ONE, GL_ZERO), osg::StateAttribute::ON);</div><div> }</div></div><div><br></div><div>I'm not sure why I need to do this in OSG 3.4 when I didn't in OSG 3.0, probably another issue with the viewer or something on my end.</div><div><br></div><div>- Alex</div><div><br></div><div><br></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Feb 11, 2016 at 2:49 PM Alex Taylor <<a href="mailto:alextaylor@gmail.com">alextaylor@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div dir="ltr" style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif"><div dir="ltr" style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif"><div><p><span style="font-size:12pt">Hi Robert,</span></p>
<br>
Thanks so much, the thread you referenced, "osgViewer/Renderer ctor<br>
set wrong defaults for SceneView" has mostly resolved the blending issues I was having. I now call:<br>
<br>
<span style="font-family:'Courier New',monospace"><span style="font-family:'Courier New',monospace"> osg::ref_ptr<osg::StateSet> stateSet = osgCamera->getOrCreateStateSet();</span></span><br style="font-family:'Courier New',monospace">
<span style="font-family:'Courier New',monospace"><span style="font-family:'Courier New',monospace"> stateSet->setGlobalDefaults();</span></span><br>
<br>
When setting up my Camera. Things *mostly* look good now. I am still having one lingering problem with the way my isosurfaces are rendering with RayTracedTechnique as a result of the OSG 3.4 upgrade from OSG 3.0. I'm using RayTracedTechnique with the default
shaders used by RayTracedTechnique, no hardcoded shaders paths or anything like that.<br>
<br>
<span style="font-family:'Courier New',monospace"> if (volumeProperties.volumeTechnique == VolumeTechnique::RayTraced){</span><br style="font-family:'Courier New',monospace">
<span style="font-family:'Courier New',monospace"> osg::ref_ptr<osgVolume::RayTracedTechnique> rayTraced = new osgVolume::RayTracedTechnique();</span><br style="font-family:'Courier New',monospace">
<span style="font-family:'Courier New',monospace"> tile->setVolumeTechnique(rayTraced.get());</span><br style="font-family:'Courier New',monospace">
<span style="font-family:'Courier New',monospace"> osg::ref_ptr<osg::FrontFace> frontFace(new osg::FrontFace(osg::FrontFace::CLOCKWISE));</span><br style="font-family:'Courier New',monospace">
<span style="font-family:'Courier New',monospace"> stateset->setAttribute(frontFace.get(), osg::StateAttribute::PROTECTED);</span><br style="font-family:'Courier New',monospace">
<br style="font-family:'Courier New',monospace">
<span style="font-family:'Courier New',monospace"> } else if (volumeProperties.volumeTechnique == VolumeTechnique::FixedFunction) {</span><br style="font-family:'Courier New',monospace">
<span style="font-family:'Courier New',monospace"> tile->setVolumeTechnique(new osgVolume::FixedFunctionTechnique());</span><br style="font-family:'Courier New',monospace">
<span style="font-family:'Courier New',monospace"> stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF | osg::StateAttribute::OVERRIDE);</span><br style="font-family:'Courier New',monospace">
<span style="font-family:'Courier New',monospace"> } else {</span><br style="font-family:'Courier New',monospace">
<span style="font-family:'Courier New',monospace"> throw hg::PropertyException("VolumeTechnique");</span><br style="font-family:'Courier New',monospace">
<span style="font-family:'Courier New',monospace"> }</span><br style="font-family:'Courier New',monospace">
<br style="font-family:'Courier New',monospace">
<span style="font-family:'Courier New',monospace"> layer->addProperty(new osgVolume::TransferFunctionProperty(volumeProperties.transferFunction.get()));</span><br style="font-family:'Courier New',monospace">
<span style="font-family:'Courier New',monospace"> layer->addProperty(new osgVolume::AlphaFuncProperty(volumeProperties.alphaFunc));</span><br style="font-family:'Courier New',monospace">
<span style="font-family:'Courier New',monospace"> layer->addProperty(new osgVolume::SampleDensityProperty(volumeProperties.sampleDensity));</span><br style="font-family:'Courier New',monospace">
<span style="font-family:'Courier New',monospace"> layer->addProperty(new osgVolume::SampleDensityWhenMovingProperty(volumeProperties.sampleDensityWhenMoving));</span><br style="font-family:'Courier New',monospace">
<span style="font-family:'Courier New',monospace"> if (volumeProperties.useLighting) layer->addProperty(new osgVolume::LightingProperty);</span><br style="font-family:'Courier New',monospace">
<span style="font-family:'Courier New',monospace"> if (volumeProperties.useIsosurface) layer->addProperty(new osgVolume::IsoSurfaceProperty(volumeProperties.alphaFunc));</span><br style="font-family:'Courier New',monospace">
<span style="font-family:'Courier New',monospace"> if (volumeProperties.useMaximumIntensityProjection) layer->addProperty(new osgVolume::MaximumIntensityProjectionProperty());</span><br style="font-family:'Courier New',monospace">
<br>
Attached is what I see for isosurfaces in OSG 3.4 vs. OSG 3.0. The OSG 3.4 isosurfaces are rendering very "washed out" looking. I suspect I'm still having some sort of Blending issue with the Isosurface specifically. Any thoughts on what that might be happening?
<div><br>
</div>
<div>Either way, I have really appreciated your help.<br>
</div>
<div><br>
</div>
<div>- Alex<br>
</div>
<div>
<div>________________________________________<br>
From: osg-users <<a href="mailto:osg-users-bounces@lists.openscenegraph.org" target="_blank">osg-users-bounces@lists.openscenegraph.org</a>> on behalf of Robert Osfield <<a href="mailto:robert.osfield@gmail.com" target="_blank">robert.osfield@gmail.com</a>><br>
Sent: Thursday, February 4, 2016 6:43 AM<br>
To: OpenSceneGraph Users</div></div></div></div></div><div dir="ltr" style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif"><div dir="ltr" style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif"><div><div><div><br>
Subject: Re: [osg-users] Changes in osgVolume from 3.0 to 3.4<br>
<br></div></div></div></div></div><div dir="ltr" style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif"><div dir="ltr" style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif"><div><div><div>
Hi Alex,<br>
<br>
The blending difference might be down to a bug fix elsewhere in the<br>
OSG. Have a look at yesterdays discussion "osgViewer/Renderer ctor<br>
set wrong defaults for SceneView", in particular my replies that<br>
explain how a bug fix (in OSG-3.2 onwards) to the way that global<br>
State is managed reveals a deficiency in the viewer set up.<br>
<br>
As the light direction issue, the new way is more general purpose, the<br>
old behaviour isn't required, the old shaders aren't maintained. If<br>
you want the old shaders and uniform set up you'll need to write these<br>
yourself, or just adopt the new approach and have your viewer<br>
manipulate the main light source using the viewer's Light or an<br>
osg::LightSource placed in the scene.<br>
<br>
Robert.<br>
<br>
osg-users<br>
x<br>
<br>
On 3 February 2016 at 21:11, Alex Taylor <<a href="mailto:alextaylor@gmail.com" target="_blank">alextaylor@gmail.com</a>> wrote:<br>
> Robert,<br>
><br>
> Thanks. There are two main culprits the behavior change I was seeing. The<br>
> first is that for some reason, between OSG 3.0 and 3.4, I now need to<br>
> explicitly set a BlendFunc. With the exception of MIP, it looks like the<br>
> rest of osgVolume just renders with a default BlendFunc and doesn't<br>
> explictly set anything.<br>
><br>
> I found that by setting<br>
><br>
> stateset->setAttribute(new osg::BlendFunc(GL_SRC_ALPHA,<br>
> GL_ONE_MINUS_SRC_ALPHA), osg::StateAttribute::ON);<br>
><br>
> There is a second issue I want to ask about:<br>
><br>
> It looks to me there was a change to the shaders I'm using regarding the<br>
> position of the light source between OSG 3.0 and OSG 3.4:<br>
><br>
> <a href="https://github.com/openscenegraph/osg/commit/4525ec49a386b48608fdb3107033a1c915d928e6" target="_blank">
https://github.com/openscenegraph/osg/commit/4525ec49a386b48608fdb3107033a1c915d928e6</a><br>
><br>
> The change is to honor the lightDirection from GL_LIGHT0 rather than use the<br>
> eye direction as the direction of the light source.<br>
><br>
> If I wanted to get the old behavior of using the eyeDirection, is there an<br>
> easy way to go about that?<br>
><br>
> Thanks,<br>
><br>
> Alex<br>
><br>
><br>
> On Thu, Jan 28, 2016 at 3:16 PM Robert Osfield <<a href="mailto:robert.osfield@gmail.com" target="_blank">robert.osfield@gmail.com</a>><br>
> wrote:<br>
>><br>
>> Hi Alex,<br>
>><br>
>> There were quite a few improvements to osgVolume between OSG-3.0 and<br>
>> OSG-3.4, both in shaders and the introduction of the new MultiPassTechnique.<br>
>> One thing to look at with your own setup is that you aren't picking up on<br>
>> old<br>
>> shaders such as by having your own path to old shaders.<br>
>><br>
>> It's quite a while since I did the work on osgVolume, around two years, so<br>
>> won't be able to be specific without viewing code and being able to<br>
>> reproduce the problems you are seeing first hand.<br>
>><br>
>> Robert.<br>
>><br>
>> On 28 January 2016 at 15:25, Alex Taylor <<a href="mailto:alextaylor@gmail.com" target="_blank">alextaylor@gmail.com</a>> wrote:<br>
>>><br>
>>> Hi,<br>
>>><br>
>>> I'm working on upgrading the OSG version used in the product I work on.<br>
>>> When OSG is upgraded with the same client code, I'm noticing differences is<br>
>>> the way my volumes are rendered with all of the rendering algorithms that I<br>
>>> can't explain. I've fixed the parameters I'm using to define the osgVolume<br>
>>> in both versions, so it can't be a matter of picking up a different default<br>
>>> option for a parameter.<br>
>>><br>
>>> OSG 3.4 Fixed Function<br>
>>><br>
>>> OSG 3.0 Fixed Function<br>
>>><br>
>>><br>
>>> OSG 3.4 Ray Traced Lit<br>
>>><br>
>>><br>
>>> OSG 3.0 Ray Traced Lit<br>
>>><br>
>>><br>
>>><br>
>>> OSG 3.4 Isosurface<br>
>>><br>
>>> OSG 3.0 Isosurface<br>
>>><br>
>>><br>
>>> In the Ray Traced cases, I'm using the properties:<br>
>>><br>
>>> AlphaFunc = 0.02;<br>
>>> SampleDensity = 0.005;<br>
>>><br>
>>> I'm using setting the TransferFunctionProperty, so I'm using the shaders<br>
>>> to do the alpha/color mapping.<br>
>>><br>
>>> For the FixedFunctionTechnique, I'm using AlphaFunc = 0.02, and using the<br>
>>> applyTransferFunction function to obtain an RGBA mapped osg::Image buffer.<br>
>>><br>
>>> It's very possible that the upgrade to 3.4 has changed something else in<br>
>>> my overall use of OSG elsewhere in the pipeline, unrelated to osgVolume,<br>
>>> that is causing this issue. That said, I thought i'd ask if visually anyone<br>
>>> has a guess it what might have changed between osg 3.0 and osg 3.4 that<br>
>>> might explain these visual differences.<br>
>>><br>
>>> Thanks for your help,<br>
>>><br>
>>> Alex<br>
>>><br>
>>><br>
>>><br>
>>> _______________________________________________<br>
>>> osg-users mailing list<br>
>>> <a href="mailto:osg-users@lists.openscenegraph.org" target="_blank">osg-users@lists.openscenegraph.org</a><br>
>>> <a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" target="_blank">
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
>>><br>
>><br>
>> _______________________________________________<br>
>> osg-users mailing list<br>
>> <a href="mailto:osg-users@lists.openscenegraph.org" target="_blank">osg-users@lists.openscenegraph.org</a><br>
>> <a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" target="_blank">
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
><br>
><br>
> _______________________________________________<br>
> osg-users mailing list<br>
> <a href="mailto:osg-users@lists.openscenegraph.org" target="_blank">osg-users@lists.openscenegraph.org</a><br>
> <a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" target="_blank">
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
><br>
_______________________________________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org" target="_blank">osg-users@lists.openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
</div></div></div></div></div></div></div>
_______________________________________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org" target="_blank">osg-users@lists.openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
</blockquote></div></div>