Your Materials have color mode set to DIFFUSE. In OpenGL parlance, this enables GL_COLOR_MATERIAL and causes the diffuse lighting component to come from the primary color instead of the material diffuse color.

Remove the color mode setting (or leave it set to default OFF) and you will see the Material diffuse color used when lighting is enabled.
   -Paul


On 10/11/2011 9:34 AM, Dan West wrote:
Hi Paul,

   Thanks for the replies.

   I wasn't using Materials initially, but I tried adding them to see if they 
would make a difference. The two geometries are still showing up as the same 
color, but it didn't seem to be because of the Materials being the same.

   Here's another .osg file with some better color coding:


Code:
Camera {
   UniqueID Camera_0
   nodeMask 0xffffffff
   cullingActive FALSE
   StateSet {
     rendering_hint DEFAULT_BIN
     renderBinMode INHERIT
     Viewport {
       UniqueID Viewport_1
       x 0
       y 0
       width 2046
       height 2048
     }
     textureUnit 0 {
     }
     textureUnit 1 {
     }
     textureUnit 2 {
     }
     textureUnit 3 {
       GL_TEXTURE_GEN_S OVERRIDE|OFF
       GL_TEXTURE_GEN_T OVERRIDE|OFF
       GL_TEXTURE_GEN_R OVERRIDE|OFF
       GL_TEXTURE_GEN_Q OVERRIDE|OFF
       TexGen {
         mode OBJECT_LINEAR
         plane_s 1 0 0 0
         plane_t 0 1 0 0
         plane_r 0 0 1 0
         plane_q 0 0 0 1
       }
     }
   }
   referenceFrame ABSOLUTE
   clearColor 0 0.4 0 1
   clearMask 0x100
   Use Viewport_1
   transformOrder PRE_MULTIPLY
   ProjectionMatrix {
     0.000977517 0 0 0
     0 0.000976563 0 0
     0 0 -0.002002 0
     -0 -0 -1.002 1
   }
   ViewMatrix {
     1 0 -0 0
     -0 1 -0 0
     0 0 1 0
     0 0 -500 1
   }
   renderOrder PRE_RENDER
   renderTargetImplementation FRAME_BUFFER_OBJECT
   renderTargetFallback PIXEL_BUFFER_RTT
   drawBuffer 0
   readBuffer 0
   bufferComponent COLOR_BUFFER {
     internalFormat 0
     Texture2D {
       UniqueID Texture2D_2
       DataVariance DYNAMIC
       wrap_s CLAMP
       wrap_t CLAMP
       wrap_r CLAMP
       min_filter LINEAR
       mag_filter LINEAR
       maxAnisotropy 1
       borderColor 0 0 0 0
       borderWidth 0
       useHardwareMipMapGeneration TRUE
       unRefImageDataAfterApply FALSE
       internalFormatMode USE_USER_DEFINED_FORMAT
       internalFormat GL_RGBA
       resizeNonPowerOfTwo TRUE
     }
     level 0
     face 0
     mipMapGeneration FALSE
   }
   num_children 2
   MatrixTransform {
     UniqueID MatrixTransform_3
     nodeMask 0xffffffff
     cullingActive TRUE
     referenceFrame RELATIVE
     Matrix {
       20.46 0 0 0
       0 20.48 0 0
       0 0 1 0
       0 0 0 1
     }
     num_children 1
     Geode {
       UniqueID Geode_4
       DataVariance DYNAMIC
       nodeMask 0xffffffff
       cullingActive TRUE
       num_drawables 1
       Geometry {
         UniqueID Geometry_5
         DataVariance DYNAMIC
         StateSet {
           rendering_hint DEFAULT_BIN
           renderBinMode INHERIT
           Material {
             ColorMode DIFFUSE
             ambientColor 0.2 0.2 0.2 1
             diffuseColor 1 1 0 1
             specularColor 0 0 0 1
             emissionColor 0 0 0 1
             shininess 0
           }
         }
         useDisplayList TRUE
         useVertexBufferObjects FALSE
         PrimitiveSets 1
         {
           DrawArrays QUADS 0 4
         }
         VertexArray UniqueID Vec3Array_6 Vec3Array 4
         {
           0.5 0.5 0
           -0.5 0.5 0
           -0.5 -0.5 0
           0.5 -0.5 0
         }
         NormalBinding OVERALL
         NormalArray UniqueID Vec3Array_7 Vec3Array 1
         {
           0 0 1
         }
         ColorBinding OVERALL
         ColorArray UniqueID Vec4Array_8 Vec4Array 1
         {
           0 1 0 1
         }
       }
     }
   }
   MatrixTransform {
     nodeMask 0xffffffff
     cullingActive TRUE
     referenceFrame RELATIVE
     Matrix {
       1 0 0 0
       0 1 0 0
       0 0 1 0
       0 0 0 1
     }
     num_children 1
     Geode {
       UniqueID Geode_9
       DataVariance DYNAMIC
       nodeMask 0xffffffff
       cullingActive TRUE
       num_drawables 1
       Geometry {
         UniqueID Geometry_10
         DataVariance DYNAMIC
         StateSet {
           rendering_hint DEFAULT_BIN
           renderBinMode INHERIT
           Material {
             ColorMode DIFFUSE
             ambientColor 0.2 0.2 0.2 1
             diffuseColor 1 0 1 1
             specularColor 0 0 0 1
             emissionColor 0 0 0 1
             shininess 0
           }
         }
         useDisplayList TRUE
         useVertexBufferObjects FALSE
         PrimitiveSets 1
         {
           DrawArrays TRIANGLE_FAN 0 18
         }
         VertexArray UniqueID Vec3Array_11 Vec3Array 18
         {
           0 0 0
           1 0 0
           0.92388 0.382683 0
           0.707107 0.707107 0
           0.382683 0.92388 0
           6.12323e-017 1 0
           -0.382683 0.92388 0
           -0.707107 0.707107 0
           -0.92388 0.382683 0
           -1 1.22465e-016 0
           -0.92388 -0.382683 0
           -0.707107 -0.707107 0
           -0.382683 -0.92388 0
           -1.83697e-016 -1 0
           0.382683 -0.92388 0
           0.707107 -0.707107 0
           0.92388 -0.382683 0
           1 0 0
         }
         NormalBinding OVERALL
         NormalArray UniqueID Vec3Array_12 Vec3Array 1
         {
           0 0 1
         }
         ColorBinding OVERALL
         ColorArray UniqueID Vec4Array_13 Vec4Array 1
         {
           1 0 0 1
         }
       }
     }
   }
}




   In this version, I've made sure both geometries have Materials as well as 
color buffers. In this case, I would expect the material to override the color 
buffer (since lighting is enabled). However, the square (first attached child) 
shows up green (from its color array), instead of yellow (from the material). 
The circle (second attached child) shows up green as well (from the square's 
color array), instead of red (from its color array) or magenta (from its 
material).

   Am I setting the materials wrong or something? I would expect them to be 
fully enabled since the ColorMode is set to diffuse and the Material is showing 
up as expected in the OSG file.

~ Dan

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





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




--
  -Paul Martz      Skew Matrix Software
                   http://www.skew-matrix.com/

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

Reply via email to