Re: [osg-users] Alpha blending not working on IOS

2011-03-29 Thread Stephan Huber
Hi Thomas,

Am 28.03.11 22:40, schrieb Thomas Hogarth:
 Has anyone used alpha blending on IOS successfully? I could have sworn I
 have in the past but I've been at this for about two hours now with no luck.

I had alpha blending working on IOS, but I used vertex-colors, not
materials, and everything worked as expected.

If I find some spare time, I can test this code again.

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


Re: [osg-users] Alpha blending not working on IOS

2011-03-29 Thread Sergey Polischuk
Hi, ThomasTry setting BlendFunc to stateset also. I think you'll want something like osg::BlendFunc(ONE_MINUS_SRC_ALPHA, SRC_ALPHA);Cheers,Sergey.29.03.2011, 00:40, "Thomas Hogarth" thomas.hoga...@gmail.com:Hi AllThis may be a slightly dumb question but I can't seem to get alpha blending to work on IOS. I've just finished porting my windows code (which works fine) over to IOS but now my Hud Objects alpha doesn't seem to work. The code I use to enable alpha blending on my hud objects is   osg::BlendEquation* blendEquation = new osg::BlendEquation(osg::BlendEquation::FUNC_ADD);   m_stateset-setAttributeAndModes(blendEquation,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);   //tell to sort the mesh before displaying it   m_stateset-setRenderingHint(osg::StateSet::TRANSPARENT_BIN);   m_stateset-setMode(GL_BLEND, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);   m_stateset-setMode(GL_ALPHA_TEST, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);// just added this now as a test but still no luck I then set the alpha via a material which is already applied to the stateset with m_material-setAlpha(osg::Material::FRONT_AND_BACK, m_alpha); But no matter what I set m_alpha to I can always see the hud objects (even if i set it to zero). I checked the format of my eaglLayer and it iskEAGLColorFormatRGBA8 as it should be. Has anyone used alpha blending on IOS successfully? I could havesworn I have in the past but I've been at this for about two hours now with no luck. Thanks for any helpTom  ___osg-users mailing listosg-users@lists.openscenegraph.orghttp://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] Alpha blending not working on IOS

2011-03-29 Thread Thomas Hogarth
Hi Stephan

Problem solved, I created a .osg file in 3DS Max with a transparent material
and that worked. The only difference I could see between that files stateset
and my hud objects stateset was that Lighting was enabled. So I re enabled
lighting on my hud object and now the alpha blending is working as
expected. Must be some kind of optimisation made by the ios drivers, to not
use the material info if lighting is disabled, which is why your vertex
colour metod worked.

Now the question is do I keep using materials for this or should I switch to
vertex colours to improve performance.

Anyhow, for anyone else with the problem of alpha blending not working on
IOS when using a material, make sure you have lighting enabled.

Cheers
Tom


On 29 March 2011 08:53, Stephan Huber ratzf...@digitalmind.de wrote:

 Hi Thomas,

 Am 28.03.11 22:40, schrieb Thomas Hogarth:
  Has anyone used alpha blending on IOS successfully? I could have sworn I
  have in the past but I've been at this for about two hours now with no
 luck.

 I had alpha blending working on IOS, but I used vertex-colors, not
 materials, and everything worked as expected.

 If I find some spare time, I can test this code again.

 cheers,
 Stephan

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


Re: [osg-users] Alpha blending not working on IOS

2011-03-29 Thread Thomas Hogarth
Hi Sergey

Thanks for the tip, I did try that but still no luck, turned out to be that
lighting was disabled. I just sent another message with a bit more info.

Thanks again
Tom

PS
I'll quickly test if it was a combination of the two.


On 29 March 2011 10:32, Sergey Polischuk pol...@yandex.ru wrote:

 Hi, Thomas

 Try setting BlendFunc to stateset also. I think you'll want something like
 osg::BlendFunc(ONE_MINUS_SRC_ALPHA, SRC_ALPHA);

 Cheers,
 Sergey.

 29.03.2011, 00:40, Thomas Hogarth thomas.hoga...@gmail.com:

 Hi All

 This may be a slightly dumb question but I can't seem to get alpha blending
 to work on IOS. I've just finished porting my windows code (which works
 fine) over to IOS but now my Hud Objects alpha doesn't seem to work.

 The code I use to enable alpha blending on my hud objects is


  osg::BlendEquation* blendEquation = new osg::BlendEquation(osg::
 BlendEquation::FUNC_ADD);

  m_stateset-setAttributeAndModes(blendEquation,osg::StateAttribute::
 OVERRIDE|osg::StateAttribute::ON);

  //tell to sort the mesh before displaying it

  m_stateset-setRenderingHint(osg::StateSet::TRANSPARENT_BIN);

  m_stateset-setMode(GL_BLEND, osg::StateAttribute::ON | osg::
 StateAttribute::OVERRIDE);
  m_stateset-setMode(GL_ALPHA_TEST, osg::StateAttribute::ON | osg::
 StateAttribute::OVERRIDE);// just added this now as a test but still no
 luck

 I then set the alpha via a material which is already applied to the
 stateset with

 m_material-setAlpha(osg::Material::FRONT_AND_BACK, m_alpha);



 But no matter what I set m_alpha to I can always see the hud objects (even
 if i set it to zero). I checked the format of my eaglLayer and it is 
 kEAGLColorFormatRGBA8
 as it should be.


 Has anyone used alpha blending on IOS successfully? I could have sworn I
 have in the past but I've been at this for about two hours now with no luck.


 Thanks for any help

 Tom


 ___
 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] Alpha blending not working on IOS

2011-03-29 Thread Thomas Hogarth
Just to confirm

It was only the Lighting issue, although Sergey's tip is still a good one

Tom

On 29 March 2011 10:35, Thomas Hogarth thomas.hoga...@gmail.com wrote:

 Hi Sergey

 Thanks for the tip, I did try that but still no luck, turned out to be that
 lighting was disabled. I just sent another message with a bit more info.

 Thanks again
 Tom

 PS
 I'll quickly test if it was a combination of the two.


 On 29 March 2011 10:32, Sergey Polischuk pol...@yandex.ru wrote:

 Hi, Thomas

 Try setting BlendFunc to stateset also. I think you'll want something like
 osg::BlendFunc(ONE_MINUS_SRC_ALPHA, SRC_ALPHA);

 Cheers,
 Sergey.

 29.03.2011, 00:40, Thomas Hogarth thomas.hoga...@gmail.com:

 Hi All

 This may be a slightly dumb question but I can't seem to get alpha
 blending to work on IOS. I've just finished porting my windows code (which
 works fine) over to IOS but now my Hud Objects alpha doesn't seem to work.

 The code I use to enable alpha blending on my hud objects is


  osg::BlendEquation* blendEquation = new osg::BlendEquation(osg::
 BlendEquation::FUNC_ADD);

  m_stateset-setAttributeAndModes(blendEquation,osg::StateAttribute::
 OVERRIDE|osg::StateAttribute::ON);

  //tell to sort the mesh before displaying it

  m_stateset-setRenderingHint(osg::StateSet::TRANSPARENT_BIN);

  m_stateset-setMode(GL_BLEND, osg::StateAttribute::ON | osg::
 StateAttribute::OVERRIDE);
  m_stateset-setMode(GL_ALPHA_TEST, osg::StateAttribute::ON | osg::
 StateAttribute::OVERRIDE);// just added this now as a test but still no
 luck

 I then set the alpha via a material which is already applied to the
 stateset with

 m_material-setAlpha(osg::Material::FRONT_AND_BACK, m_alpha);



 But no matter what I set m_alpha to I can always see the hud objects (even
 if i set it to zero). I checked the format of my eaglLayer and it is 
 kEAGLColorFormatRGBA8
 as it should be.


 Has anyone used alpha blending on IOS successfully? I could have sworn I
 have in the past but I've been at this for about two hours now with no luck.


 Thanks for any help

 Tom


 ___
 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] Alpha blending not working on IOS

2011-03-28 Thread Thomas Hogarth
Hi All

This may be a slightly dumb question but I can't seem to get alpha blending
to work on IOS. I've just finished porting my windows code (which works
fine) over to IOS but now my Hud Objects alpha doesn't seem to work.

The code I use to enable alpha blending on my hud objects is

osg::BlendEquation* blendEquation = new osg::BlendEquation(osg::
BlendEquation::FUNC_ADD);

 m_stateset-setAttributeAndModes(blendEquation,osg::StateAttribute::
OVERRIDE|osg::StateAttribute::ON);

 //tell to sort the mesh before displaying it

 m_stateset-setRenderingHint(osg::StateSet::TRANSPARENT_BIN);

 m_stateset-setMode(GL_BLEND, osg::StateAttribute::ON | osg::StateAttribute
::OVERRIDE);
 m_stateset-setMode(GL_ALPHA_TEST, osg::StateAttribute::ON | osg::
StateAttribute::OVERRIDE);// just added this now as a test but still no luck

I then set the alpha via a material which is already applied to the stateset
with

   m_material-setAlpha(osg::Material::FRONT_AND_BACK, m_alpha);



But no matter what I set m_alpha to I can always see the hud objects (even
if i set it to zero). I checked the format of my eaglLayer and it is
kEAGLColorFormatRGBA8
as it should be.


Has anyone used alpha blending on IOS successfully? I could have sworn I
have in the past but I've been at this for about two hours now with no luck.


Thanks for any help

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