Jason Daly wrote:
Roger James wrote:

if (transparent or transparency element present in the technique)
{
    // Turn on the OpenGL blender
    Calculate a blending factor using transparent and transparency according to the "opaque" mode in force.
    // Decide whether to use GL_SRC_XXX or GL_CONSTANT _XXX in the OpenGL blender
    if (the calculated factor would mean opacity when  applied)
       Use the relevant blend factor from the incoming lit and textured fragment
    else
       Use the previously calculated blending factor as a constant blend factor
}

I would appreciate any comments you have, time permitting of course.

The only thing that worries me about this is that you're using the <transparent>/<transparency> tags to decide when to enable blending.  I'd suggest you add one more check to see if your calculated blending factor results in the surface being fully opaque before you enable blending.  I say this because I've made a lot of use of the ColladaMAX plugin from Feeling Software, and every single model I've exported with that plugin has transparent/transparency set on all of its materials, even if they're actually fully opaque.

The problem I have is deciding if the surface is going to end up fully opaque when there is a texture in the diffuse channel supplying the incoming fragments alpha component. The best I can come up with is this, but it is messy and does not take it account any modification of the incoming frgaments alpha component by the application of the lighting equation.

if (transparent or transparency element present in the technique)
{
     Calculate a blending factor using transparent and transparency according to the "opaque" mode in force.
    // Decide whether to use GL_SRC_XXX or GL_CONSTANT _XXX in the OpenGL blender
    if (the calculated factor would mean opacity when  applied)
    {
       if (there is a translucent texture in the diffuse channel)
       {
           Use the relevant blend factor from the incoming lit and textured fragment
           Turn on the OpenGL blender
       }
       else if  (the calculated factor along with the alpha from the constant diffuse colour  woud result in a translucent colour)
       {
           Use the relevant blend factor from the incoming lit and textured fragment
           Turn on the OpenGL blender
       }
    }
    else
    {
       Use the previously calculated blending factor as a constant blend factor
       Turn on the OpenGL blender
    }
}

I cannot believe that a profile that is meant to represent fixed functionality ends up this messy. It just highlights the _opacity_ of the spec in this area :-)

Roger


_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to