public class SoMaterial extends SoNode
SoMaterial
sets several components of the current material during traversal. The ambientColor, diffuseColor, emissiveColor, specularColor and shininess fields are interpreted according to the classic OpenGL lighting model. The transparency field is effectively the inverse of "opacity" or "alpha value".
If lighting is turned off (SoLightModel
set to BASE_COLOR), only the diffuse color and transparency fields are used to render geometry.
Multiple values can be specified for the diffuseColor
and transparency
fields. Different shapes interpret materials with multiple values differently. To bind materials to shapes, use an SoMaterialBinding
node.
Several other nodes can be used to set diffuse color and transparency. If the other color values are not needed, these nodes use a little less memory than an The color components specified for lights mean something different than for materials. For a light, the numbers correspond to a percentage of full intensity for each color. If the R, G, and B values for a light's color are all 1.0, the light is the brightest possible white. If the values are 0.5, the color is still white, but only at half intensity, so it appears gray. If R=G=1 and B=0 (full red and green with no blue), the light appears yellow. The intensity can also be modulated using the For materials, the numbers correspond to the reflected percentages of those colors. So if R=1, G=0.5, and B=0 for a material, that material reflects all the incoming red light, half the incoming green, and none of the incoming blue light. In other words, if an OpenGL light has components (LR, LG, LB), and a material has corresponding components (MR, MG, MB), then, ignoring all other reflectivity effects, the light that arrives at the eye is given by (LR*MR, LG*MG, LB*MB). As a result, for example, shining a pure blue light on a pure red cone has no visible effect.
Similarly, if you have two lights that send (R1, G1, B1) and (R2, G2, B2) to the eye, the components are added, giving (R1+R2, G1+G2, B1+B2). If any of the sums are greater than 1 (corresponding to a color brighter than the hardware can display), the component is clamped to 1.
Override material: To force all geometry following/below this node to use specific color and transparency values, call the setOverride() method with true. Overriding the diffuse color and transparency overrides the color and transparency values in other nodes including It is also possible to override only a subset of the The default transparency algorithm is SCREEN_DOOR. To get a nice appearance for transparent objects you must change this to another value, for example, BLEND or DELAYED_BLEND, using the setTransparencyType method in the Viewer class or using an Material {
Action behavior:
See also:
SoMaterial
node, especially if multiple color values are specified. Generally SoVertexProperty
is the most efficient mechanism and may provide better performance than using SoMaterial
. Note that for these nodes transparency is set as "alpha value" (inverse of transparency).
Lighting and material RGB values: SoBaseColor
node.
SoPackedColor
node.
SoVertexProperty
.
SoLight.intensity
field.
SoPackedColor
and SoVertexProperty
. This can be useful, for example, to highlight a selected object.
SoMaterial
fields. If, for example, you only want to override the diffuse color, but not the other values, call setIgnored(true) on the fields that you do not want to override. But note that this selective override technique only works on other SoMaterial
nodes! For SoPackedColor
and SoVertexProperty
, the diffuseColor and transparency values are bound together and cannot be overridden separately. If you want, for example, to force transparency to 0 (making all geometry opaque), use an SoTransparencyType
node with the
type field set to NO_TRANSPARENCY.
Transparency: SoTransparencyType
node. See SoGLRenderAction
for a discussion of transparency algorithms and rendering order.
File format/default:
}
ambientColor 0.2 0.2 0.2
diffuseColor 0.8 0.8 0.8
specularColor 0 0 0
reflectiveColor 0 0 0
emissiveColor 0 0 0
shininess 0.2
transparency 0
receiveShadow false
SoGLRenderAction
, SoCallbackAction
Sets the ambient color, the diffuse color, the specular color, the emissive color, the shininess, and the transparency of the current material. Sets: SoLazyElement
, SoMaterialElement
SoBaseColor
, SoLightModel
, SoMaterialBinding
, SoPackedColor
, SoVertexProperty
, SoDirectVizManager
Inventor.ConstructorCommand
Modifier and Type | Field and Description |
---|---|
SoMFColor |
ambientColor
Ambient color of the surface.
|
SoMFColor |
diffuseColor
Diffuse color(s) of the surface.
|
SoMFColor |
emissiveColor
Emissive color of the surface.
|
SoSFBool |
receiveShadow
DirectViz rendering only.
|
SoMFColor |
reflectiveColor
DirectViz rendering only.
|
SoMFFloat |
shininess
Shininess coefficient of the surface.
|
SoMFColor |
specularColor
Specular color of the surface.
|
SoMFFloat |
transparency
Transparency value(s) of the surface.
|
VERBOSE_LEVEL, ZeroHandle
Constructor and Description |
---|
SoMaterial()
Creates a material node with default settings.
|
affectsState, callback, copy, copy, distribute, doAction, getAlternateRep, getBoundingBox, getByName, getMatrix, getPrimitiveCount, getRenderUnitID, GLRender, GLRenderBelowPath, GLRenderInPath, GLRenderOffPath, grabEventsCleanup, grabEventsSetup, handleEvent, isBoundingBoxIgnoring, isOverride, pick, rayPick, search, setOverride, touch, write
copyFieldValues, copyFieldValues, enableNotify, fieldsAreEqual, get, getAllFields, getEventIn, getEventOut, getField, getFieldName, hasDefaultValues, isNotifyEnabled, set, setToDefaults
dispose, getEXTERNPROTO, getName, getPROTO, isDisposable, isSynchronizable, setName, setSynchronizable
getAddress, getNativeResourceHandle, startInternalThreads, stopInternalThreads
public final SoMFColor ambientColor
Ambient reflectance affects the overall color of the object. Because diffuse reflectance is brightest where an object is directly illuminated, ambient reflectance is most noticeable where an object receives no direct illumination. An object's total ambient reflectance is affected by the global ambient light (see SoEnvironment
) and ambient light from individual light sources. Like diffuse reflectance, ambient reflectance is not affected by the position of the camera.
public final SoMFColor diffuseColor
Diffuse reflectance plays the most important role in determining the appearance of an object. It's affected by the color of the incident light(s) and the angle of each incident light relative to the object's normal direction. (It's most intense where the incident light falls perpendicular to the surface.) The position of the camera doesn't affect diffuse reflectance at all.
public final SoMFColor specularColor
Specular reflection from an object produces highlights. Unlike ambient and diffuse reflection, the amount of specular reflection does depend on the location of the camera - it's brightest along the direct angle of reflection. To see this, imagine looking at a metallic ball outdoors in the sunlight. As you move your head, the highlight created by the sunlight moves with you to some extent. However, if you move your head too much, you lose the highlight entirely.
This field specifies the color of the reflected light. The shininess
field controls the size and brightness of the highlight.
public final SoMFColor emissiveColor
Emissive color makes an object appear to be giving off light of that color, independent of any lights (or lack of lights) in the scene. It can be useful for highlighting selected objects in the scene.
public final SoMFFloat shininess
The dot product of the vector reflected by the surface normal and the inverted light vector is raised to the "Shininess" power. The higher the shininess number, the smaller the resulting specular highlight turns out to be.
public final SoMFFloat transparency
If the transparency type is SoGLRenderAction.SCREEN_DOOR
then only the first transparency value will be used (See SoGLRenderAction.SCREEN_DOOR
description). With other transparency types, multiple transparencies will be used, if the SoMaterial
node contains as many transparencies as diffuse colors. If there are not as many transparencies as diffuse colors, only the first transparency will be used.
Transparency is the inverse of "opacity" or "alpha" value.
public final SoSFBool receiveShadow
public final SoMFColor reflectiveColor
Generated on January 23, 2025, Copyright © Thermo Fisher Scientific. All rights reserved. http://www.openinventor.com