Re: [osg-users] [osgPlugins] collada and ambient occlusion maps - only with diffuse texture?

2009-04-21 Thread Roger James




Martin Scheffler wrote:

  Hi,

I use 3ds Max render-to-texture to generate ambient occlusion maps.
I then export the model to collada (with the nextgen plugin) and try to load them into osg.
For some meshes I get this message: "Ambient occlusion map only supported when diffuse texture also specified", and the occlusion map is not loaded.

Is that a collada thing or a shortcoming of the osg collada importer?
Can I circumvent it by adding small one-color textures to the no-texture materials? Or is there a better way?

Thank you.

-

Martin,

It is the way the Collada importer is written. I admit that I thought I
had good reason for making it work that way when I wrote that bit,
however, now, I cannot remember what that reason was!

It  was something to do with mapping the Collada Common profile, which
is supposed to represent a fixed a function pipeline, on to the OpenGL
fixed function pipeline.

This is what the code does when both the diffuse and ambient texture
maps are present.

    // Set the ambient and diffuse colour white so that the
incoming fragment colour ends up as a
    // lit white colour. I modulate both textures onto this
to approximate the lighting equation.
    // Using a zero diffuse and then an ADD of the diffuse
texture seems overlit to me.
    mat->setAmbient( osg::Material::FRONT_AND_BACK,
osg::Vec4( 1.0f, 1.0f, 1.0f, 1.0f ) );
    mat->setDiffuse( osg::Material::FRONT_AND_BACK,
osg::Vec4( 1.0f, 1.0f, 1.0f, 1.0f ) );
    // Use the ambient texture map as an occlusion map.
    ss->setTextureMode( AMBIENT_OCCLUSION_UNIT,
GL_TEXTURE_2D, GL_TRUE );
    ss->setTextureAttribute(AMBIENT_OCCLUSION_UNIT, new
osg::TexEnv(osg::TexEnv::MODULATE) );
    ss->setTextureAttribute( AMBIENT_OCCLUSION_UNIT,
AmbientStateAttribute );
    // Modulate in the diffuse texture
    ss->setTextureMode( MAIN_TEXTURE_UNIT,
GL_TEXTURE_2D, GL_TRUE );
    ss->setTextureAttribute(MAIN_TEXTURE_UNIT, new
osg::TexEnv(osg::TexEnv::MODULATE) );
    ss->setTextureAttribute( MAIN_TEXTURE_UNIT,
DiffuseStateAttribute );

So setting up a texture for your diffuse colour should probably work.

Roger
 


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


[osg-users] [osgPlugins] collada and ambient occlusion maps - only with diffuse texture?

2009-04-21 Thread Martin Scheffler
Hi,

I use 3ds Max render-to-texture to generate ambient occlusion maps.
I then export the model to collada (with the nextgen plugin) and try to load 
them into osg.
For some meshes I get this message: "Ambient occlusion map only supported when 
diffuse texture also specified", and the occlusion map is not loaded.

Is that a collada thing or a shortcoming of the osg collada importer?
Can I circumvent it by adding small one-color textures to the no-texture 
materials? Or is there a better way?

Thank you.

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





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