Re: [osg-users] PNG and Collada
I have looked at bit harder at the code now and I now realise that I only partially fixed Sketchup's broken Collada stuff. Sketchup is putting the texture image sampler reference into the Collada diffuse parameter and sets the transparent parameter to a fixed opaque white colour. The plugin assumes assumes that when tranparency processing is active (the spec says this is when either transparent or transparency is present) the colour information should come from the transparent parameter which is either a fixed colour or a texture sampler. So as things are as the moment the plugin will not use ONE_MINUS_SRC_ALPHA as the blend function unless transparent is a image sampler rather than a fixed colour. As far as I can see this is a grey area in the Collada spec. I think our current interpretation is reasonable as I cannot see another way to distinguish between from the Collada document when to use ONE_MINUS_CONSTANT_ALPHA and ONE_MINUS_SRC_ALPHA as the OpenGL blend function. Any one got any thoughts on this? Sketchup and Google Earth are two of the biggest users of Collada, so sheer weight of numbers makes it difficult to argue against their interpretation of the spec. If only we really knew what it was! I asked a similar question when I originally submitted the changes a year go and got no replies. So once again. Does anyone have any further information about how this should be interpreted? Also any information on how the major players intepret it would be useful! Roger Roger James wrote: Alessandro, I put the GoogleMode flag into the dae writer in December 2007 after examing the dae files ouput by Sketchup at that time. Here is the comment from the SVN log. 8. User can supply an experimental GoogleMode option on output. The plugin will try to emulate the way Sketchup specifies transparency (i.e. the inverse of what it should be!). I am still struggling to get GE to understand transparency, anyone know what it expects? Sketchup at that time wrote dae files that did not conform to the Collada specification. It may or may not still do so, I have not checked recently. At around the same time I put a check into the dae reader code to set a flag if the authoring tool field in the collada header contained the words "Google Sketchup". Have a look at daeRMaterials.cpp and search for m_AuthoringTool and you will see how the current reader handles transparency settings it thinks come from Sketchup. Looking at your osg file below it looks like whatever the the transparency value was in the incoming dae file the material is actually being treated as opaque (transparency * constant colour alpha 0.99) and not put in the transparent bin. This may not be correct behaviour any more. Roger aalessandro terenzi wrote: I'm experiencing some problem with collada models and transparency texture maps. I saw that in May someone had the same problem but finally I couldn't find a solution. I tried with osg2.2.0 and 2.6.0 and it looks like that transparency doesn't work with collada models and png texture maps. I checked Robert's suggestion and converted to .osg to check if GL_BLEND function was enabled or not and it looks like it is... here follow a piece of the converted .osg file. Geode { name "material10" nodeMask 0x cullingActive TRUE StateSet { DataVariance STATIC rendering_hint DEFAULT_BIN renderBinMode INHERIT GL_CULL_FACE OFF GL_BLEND ON Material { ColorMode OFF ambientColor 0 0 0 1 diffuseColor 0.8 0.8 0.8 1 specularColor 0.33 0.33 0.33 1 emissionColor 0 0 0 1 shininess 20 } BlendFunc { source CONSTANT_ALPHA destination ONE_MINUS_CONSTANT_ALPHA } BlendColor { constantColor 1 1 1 1 } textureUnit 0 { GL_TEXTURE_2D ON Texture2D { file "images/texture9.png" wrap_s REPEAT wrap_t REPEAT wrap_r CLAMP min_filter NEAREST_MIPMAP_LINEAR mag_filter LINEAR maxAnisotropy 1 borderColor 0 0 0 0 borderWidth 0 useHardwareMipMapGeneration TRUE unRefImageDataAfterApply TRUE internalFormatMode USE_IMAGE_DATA_FORMAT resizeNonPowerOfTwo TRUE } } } [...gemoterty data follow here...] Is there something wrong with this file? Someone talked about a problem in Sketchup with png files, actually the models I'm dealing with come from Sketchup...is there really a problem with Sketchup? Someone talked about a 'GoogleMode' in the collada plugin butit looks like it is an option used for writing collada files not for reading. Thank you for any advice or direction. Alessandro ___ 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 mailing
Re: [osg-users] PNG and Collada
I have just looked at the latest Collada spec (1.5.1) and they have changed the default for the opaque attribute of the transparent from A_ONE (1 is opaque) to A_ZERO (0 is opaque). This would will fix some of the Sketchup inconsistencies as and when Skertchup gets round to specifying version 1.5.1 in the documnet header. Well I guess the big guys can change basic defaults whenever they fell like it. It means we will have to check for schema versions in the plugin now! Roger Roger James wrote: I have looked at bit harder at the code now and I now realise that I only partially fixed Sketchup's broken Collada stuff. Sketchup is putting the texture image sampler reference into the Collada diffuse parameter and sets the transparent parameter to a fixed opaque white colour. The plugin assumes assumes that when tranparency processing is active (the spec says this is when either transparent or transparency is present) the colour information should come from the transparent parameter which is either a fixed colour or a texture sampler. So as things are as the moment the plugin will not use ONE_MINUS_SRC_ALPHA as the blend function unless transparent is a image sampler rather than a fixed colour. As far as I can see this is a grey area in the Collada spec. I think our current interpretation is reasonable as I cannot see another way to distinguish between from the Collada document when to use ONE_MINUS_CONSTANT_ALPHA and ONE_MINUS_SRC_ALPHA as the OpenGL blend function. Any one got any thoughts on this? Sketchup and Google Earth are two of the biggest users of Collada, so sheer weight of numbers makes it difficult to argue against their interpretation of the spec. If only we really knew what it was! I asked a similar question when I originally submitted the changes a year go and got no replies. So once again. Does anyone have any further information about how this should be interpreted? Also any information on how the major players intepret it would be useful! Roger Roger James wrote: Alessandro, I put the GoogleMode flag into the dae writer in December 2007 after examing the dae files ouput by Sketchup at that time. Here is the comment from the SVN log. 8. User can supply an experimental GoogleMode option on output. The plugin will try to emulate the way Sketchup specifies transparency (i.e. the inverse of what it should be!). I am still struggling to get GE to understand transparency, anyone know what it expects? Sketchup at that time wrote dae files that did not conform to the Collada specification. It may or may not still do so, I have not checked recently. At around the same time I put a check into the dae reader code to set a flag if the authoring tool field in the collada header contained the words "Google Sketchup". Have a look at daeRMaterials.cpp and search for m_AuthoringTool and you will see how the current reader handles transparency settings it thinks come from Sketchup. Looking at your osg file below it looks like whatever the the transparency value was in the incoming dae file the material is actually being treated as opaque (transparency * constant colour alpha 0.99) and not put in the transparent bin. This may not be correct behaviour any more. Roger aalessandro terenzi wrote: I'm experiencing some problem with collada models and transparency texture maps. I saw that in May someone had the same problem but finally I couldn't find a solution. I tried with osg2.2.0 and 2.6.0 and it looks like that transparency doesn't work with collada models and png texture maps. I checked Robert's suggestion and converted to .osg to check if GL_BLEND function was enabled or not and it looks like it is... here follow a piece of the converted .osg file. Geode { name "material10" nodeMask 0x cullingActive TRUE StateSet { DataVariance STATIC rendering_hint DEFAULT_BIN renderBinMode INHERIT GL_CULL_FACE OFF GL_BLEND ON Material { ColorMode OFF ambientColor 0 0 0 1 diffuseColor 0.8 0.8 0.8 1 specularColor 0.33 0.33 0.33 1 emissionColor 0 0 0 1 shininess 20 } BlendFunc { source CONSTANT_ALPHA destination ONE_MINUS_CONSTANT_ALPHA } BlendColor { constantColor 1 1 1 1 } textureUnit 0 { GL_TEXTURE_2D ON Texture2D { file "images/texture9.png" wrap_s REPEAT wrap_t REPEAT wrap_r CLAMP min_filter NEAREST_MIPMAP_LINEAR mag_filter LINEAR maxAnisotropy 1 borderColor 0 0 0 0 borderWidth 0 useHardwareMipMapGeneration TRUE unRefImageDataAfterApply TRUE internalFormatMode USE_IMAGE_DATA_FORMAT resizeNonPowerOfTwo TRUE } } } [...gemoterty data follow here...] Is there something wrong with this file? Someone talked about a problem in Sketchup with png files, actually the models I'm dealing with come from Sketchup...is there really a problem with Sketchup? Someone talked about a 'GoogleMode' in the collada plugin butit looks like it is an option
Re: [osg-users] PNG and Collada
As a temporary workaround, I'm trying to fix my .dae models by modifying their scenegraphs in the following way: I created a node visitor that looks for Geodes whose blending in turned ON, then for such geodes I change the the blending function in the way I wrote in my previous mail and also change the rendering_hint to TRANSPARENT_BIN. Actually I'm not sure if this is 'safe' because I could change those attributes and modes also for geometries that do not need this. Maybe I could restrict these changes only to geodes that contain a png texture or that satisfy other conditions, which? How can I find out that a geode use a particular texture? I mean, for example, is there a way to get the file name of the texture applied to a geode? Thanks. Alessandro On Sat, Nov 15, 2008 at 6:07 PM, alessandro terenzi [EMAIL PROTECTED]wrote: I tried to set TRANSPARENT_BIN rendering hint but this didn't solve the problem. But I noticed another difference instead. First I tried this: - created a box in 3dsmax with a png texture applied in the diffuse slot - exported using osgexp (keeping the original texture file, ie png) - osgconv to get a .dae model - osgviewer of the .dae model and transparency is correctly handled. Then I created a similiar model with the same texture with Sketchup, created a .dae and converted into .osg. I compared the 'correct' .osg with the .osg 'from' Sketchup and I noticed that there is a difference in the BlendFunc section, in particular: in the correct .osg file: BlendFunc { source SRC_ALPHA destination ONE_MINUS_SRC_ALPHA } and in the not-working file: BlendFunc { source CONSTANT_ALPHA destination ONE_MINUS_CONSTANT_ALPHA } Changing these two lines make the transparency work as expected even in the model that comes from Sketchup. Accidently I also noticed that converting from .dae to .osg and back to .dae, result in the textures being completely transparent! Regards. Alessandro On Sat, Nov 15, 2008 at 1:22 PM, Jean-Sébastien Guay [EMAIL PROTECTED] wrote: Hi Alessandro, If you change this: rendering_hint DEFAULT_BIN to this: rendering_hint TRANSPARENT_BIN and then load the file in osgviewer, does that work? The two things you need to get proper transparency is enabling GL_BLEND and giving the TRANSPARENT_BIN rendering hint, so that the drawables are depth sorted. The .osg file you had seemed to have only one of the two. This may indicate a bug in the Collada loader. Hope this helps, J-S -- __ Jean-Sebastien Guay[EMAIL PROTECTED] http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ 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] PNG and Collada
I'm experiencing some problem with collada models and transparency texture maps. I saw that in May someone had the same problem but finally I couldn't find a solution. I tried with osg2.2.0 and 2.6.0 and it looks like that transparency doesn't work with collada models and png texture maps. I checked Robert's suggestion and converted to .osg to check if GL_BLEND function was enabled or not and it looks like it is... here follow a piece of the converted .osg file. Geode { name material10 nodeMask 0x cullingActive TRUE StateSet { DataVariance STATIC rendering_hint DEFAULT_BIN renderBinMode INHERIT GL_CULL_FACE OFF GL_BLEND ON Material { ColorMode OFF ambientColor 0 0 0 1 diffuseColor 0.8 0.8 0.8 1 specularColor 0.33 0.33 0.33 1 emissionColor 0 0 0 1 shininess 20 } BlendFunc { source CONSTANT_ALPHA destination ONE_MINUS_CONSTANT_ALPHA } BlendColor { constantColor 1 1 1 1 } textureUnit 0 { GL_TEXTURE_2D ON Texture2D { file images/texture9.png wrap_s REPEAT wrap_t REPEAT wrap_r CLAMP min_filter NEAREST_MIPMAP_LINEAR mag_filter LINEAR maxAnisotropy 1 borderColor 0 0 0 0 borderWidth 0 useHardwareMipMapGeneration TRUE unRefImageDataAfterApply TRUE internalFormatMode USE_IMAGE_DATA_FORMAT resizeNonPowerOfTwo TRUE } } } [...gemoterty data follow here...] Is there something wrong with this file? Someone talked about a problem in Sketchup with png files, actually the models I'm dealing with come from Sketchup...is there really a problem with Sketchup? Someone talked about a 'GoogleMode' in the collada plugin but it looks like it is an option used for writing collada files not for reading. Thank you for any advice or direction. Alessandro ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PNG and Collada
Hi Alessandro, If you change this: rendering_hint DEFAULT_BIN to this: rendering_hint TRANSPARENT_BIN and then load the file in osgviewer, does that work? The two things you need to get proper transparency is enabling GL_BLEND and giving the TRANSPARENT_BIN rendering hint, so that the drawables are depth sorted. The .osg file you had seemed to have only one of the two. This may indicate a bug in the Collada loader. Hope this helps, J-S -- __ Jean-Sebastien Guay[EMAIL PROTECTED] http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PNG and Collada
Alessandro, I put the GoogleMode flag into the dae writer in December 2007 after examing the dae files ouput by Sketchup at that time. Here is the comment from the SVN log. 8. User can supply an experimental GoogleMode option on output. The plugin will try to emulate the way Sketchup specifies transparency (i.e. the inverse of what it should be!). I am still struggling to get GE to understand transparency, anyone know what it expects? Sketchup at that time wrote dae files that did not conform to the Collada specification. It may or may not still do so, I have not checked recently. At around the same time I put a check into the dae reader code to set a flag if the authoring tool field in the collada header contained the words "Google Sketchup". Have a look at daeRMaterials.cpp and search for m_AuthoringTool and you will see how the current reader handles transparency settings it thinks come from Sketchup. Looking at your osg file below it looks like whatever the the transparency value was in the incoming dae file the material is actually being treated as opaque (transparency * constant colour alpha 0.99) and not put in the transparent bin. This may not be correct behaviour any more. Roger aalessandro terenzi wrote: I'm experiencing some problem with collada models and transparency texture maps. I saw that in May someone had the same problem but finally I couldn't find a solution. I tried with osg2.2.0 and 2.6.0 and it looks like that transparency doesn't work with collada models and png texture maps. I checked Robert's suggestion and converted to .osg to check if GL_BLEND function was enabled or not and it looks like it is... here follow a piece of the converted .osg file. Geode { name "material10" nodeMask 0x cullingActive TRUE StateSet { DataVariance STATIC rendering_hint DEFAULT_BIN renderBinMode INHERIT GL_CULL_FACE OFF GL_BLEND ON Material { ColorMode OFF ambientColor 0 0 0 1 diffuseColor 0.8 0.8 0.8 1 specularColor 0.33 0.33 0.33 1 emissionColor 0 0 0 1 shininess 20 } BlendFunc { source CONSTANT_ALPHA destination ONE_MINUS_CONSTANT_ALPHA } BlendColor { constantColor 1 1 1 1 } textureUnit 0 { GL_TEXTURE_2D ON Texture2D { file "images/texture9.png" wrap_s REPEAT wrap_t REPEAT wrap_r CLAMP min_filter NEAREST_MIPMAP_LINEAR mag_filter LINEAR maxAnisotropy 1 borderColor 0 0 0 0 borderWidth 0 useHardwareMipMapGeneration TRUE unRefImageDataAfterApply TRUE internalFormatMode USE_IMAGE_DATA_FORMAT resizeNonPowerOfTwo TRUE } } } [...gemoterty data follow here...] Is there something wrong with this file? Someone talked about a problem in Sketchup with png files, actually the models I'm dealing with come from Sketchup...is there really a problem with Sketchup? Someone talked about a 'GoogleMode' in the collada plugin butit looks like it is an option used for writing collada files not for reading. Thank you for any advice or direction. Alessandro ___ 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] PNG and Collada
I am currently refactoring the Collada plugin and ran into this problem last week. I solved it, though not in a really satisfactory way. Hopefully I will have the refactored plugin available for submission coming week. kind regards, Roland Smeenk From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of alessandro terenzi Sent: zaterdag 15 november 2008 12:09 To: OpenSceneGraph Users Subject: [osg-users] PNG and Collada I'm experiencing some problem with collada models and transparency texture maps. I saw that in May someone had the same problem but finally I couldn't find a solution. I tried with osg2.2.0 and 2.6.0 and it looks like that transparency doesn't work with collada models and png texture maps. I checked Robert's suggestion and converted to .osg to check if GL_BLEND function was enabled or not and it looks like it is... here follow a piece of the converted .osg file. Geode { name material10 nodeMask 0x cullingActive TRUE StateSet { DataVariance STATIC rendering_hint DEFAULT_BIN renderBinMode INHERIT GL_CULL_FACE OFF GL_BLEND ON Material { ColorMode OFF ambientColor 0 0 0 1 diffuseColor 0.8 0.8 0.8 1 specularColor 0.33 0.33 0.33 1 emissionColor 0 0 0 1 shininess 20 } BlendFunc { source CONSTANT_ALPHA destination ONE_MINUS_CONSTANT_ALPHA } BlendColor { constantColor 1 1 1 1 } textureUnit 0 { GL_TEXTURE_2D ON Texture2D { file images/texture9.png wrap_s REPEAT wrap_t REPEAT wrap_r CLAMP min_filter NEAREST_MIPMAP_LINEAR mag_filter LINEAR maxAnisotropy 1 borderColor 0 0 0 0 borderWidth 0 useHardwareMipMapGeneration TRUE unRefImageDataAfterApply TRUE internalFormatMode USE_IMAGE_DATA_FORMAT resizeNonPowerOfTwo TRUE } } } [...gemoterty data follow here...] Is there something wrong with this file? Someone talked about a problem in Sketchup with png files, actually the models I'm dealing with come from Sketchup...is there really a problem with Sketchup? Someone talked about a 'GoogleMode' in the collada plugin but it looks like it is an option used for writing collada files not for reading. Thank you for any advice or direction. Alessandro This e-mail and its contents are subject to the DISCLAIMER at http://www.tno.nl/disclaimer/email.html ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] PNG and Collada
I tried to set TRANSPARENT_BIN rendering hint but this didn't solve the problem. But I noticed another difference instead. First I tried this: - created a box in 3dsmax with a png texture applied in the diffuse slot - exported using osgexp (keeping the original texture file, ie png) - osgconv to get a .dae model - osgviewer of the .dae model and transparency is correctly handled. Then I created a similiar model with the same texture with Sketchup, created a .dae and converted into .osg. I compared the 'correct' .osg with the .osg 'from' Sketchup and I noticed that there is a difference in the BlendFunc section, in particular: in the correct .osg file: BlendFunc { source SRC_ALPHA destination ONE_MINUS_SRC_ALPHA } and in the not-working file: BlendFunc { source CONSTANT_ALPHA destination ONE_MINUS_CONSTANT_ALPHA } Changing these two lines make the transparency work as expected even in the model that comes from Sketchup. Accidently I also noticed that converting from .dae to .osg and back to .dae, result in the textures being completely transparent! Regards. Alessandro On Sat, Nov 15, 2008 at 1:22 PM, Jean-Sébastien Guay [EMAIL PROTECTED] wrote: Hi Alessandro, If you change this: rendering_hint DEFAULT_BIN to this: rendering_hint TRANSPARENT_BIN and then load the file in osgviewer, does that work? The two things you need to get proper transparency is enabling GL_BLEND and giving the TRANSPARENT_BIN rendering hint, so that the drawables are depth sorted. The .osg file you had seemed to have only one of the two. This may indicate a bug in the Collada loader. Hope this helps, J-S -- __ Jean-Sebastien Guay[EMAIL PROTECTED] http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ 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