|
M3G 1.1 -- Jun 22, 2005 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.microedition.m3g.Object3D javax.microedition.m3g.CompositingMode
An Appearance component encapsulating per-pixel compositing attributes.
Depth offset is added to the depth (Z) value of a pixel prior to depth test and depth write. The offset is constant across a polygon. Depth offset is used to prevent Z fighting, which makes coplanar polygons intersect each other on the screen due to the limited resolution of the depth buffer. Depth offset allows, for example, white lines on a highway or scorch marks on a wall (decals in general) to be implemented with polygons instead of textures. Depth offset has no effect if depth buffering is disabled.
Blending combines the incoming fragment's R, G, B, and A values with the R, G, B, and A values stored in the frame buffer at the incoming fragment's location. The table below defines the available blending modes, in terms of the source color Cs = (Rs, Gs, Bs, As) and the destination color Cd = (Rd, Gd, Bd, Ad). The source color is the incoming fragment's color value, while the destination color is the pre-existing color value in the frame buffer. The corresponding OpenGL source and destination blend functions are included in the table for reference.
Mode | Definition | OpenGL src blend func | OpenGL dst blend func |
---|---|---|---|
REPLACE |
Cd = Cs | ONE |
ZERO |
ALPHA_ADD |
Cd = Cs As + Cd | SRC_ALPHA |
ONE |
ALPHA |
Cd = Cs As + Cd (1 - As) | SRC_ALPHA |
ONE_MINUS_SRC_ALPHA |
MODULATE |
Cd = Cs Cd | DST_COLOR |
ZERO |
MODULATE_X2 |
Cd = 2 Cs Cd | DST_COLOR |
SRC_COLOR |
Depth offset is computed according to section 3.5.5 in the OpenGL 1.3 specification. Per-fragment operations are done according to sections 4.1 and 4.2, with the following exceptions:
GEQUAL
;LEQUAL
;FUNC_ADD
;Multisampling is not supported explicitly, but implementations may use it internally to implement full-scene antialiasing. The full-scene antialiasing hint can be enabled or disabled in Graphics3D. Similarly, the dithering hint in Graphics3D may be implemented using the per-fragment dithering feature of OpenGL.
Field Summary | |
static int |
ALPHA
Selects the alpha blend mode. |
static int |
ALPHA_ADD
Selects the additive blend mode. |
static int |
MODULATE
Selects the basic modulating blending mode; source pixels are multiplied with the destination pixels. |
static int |
MODULATE_X2
Selects the brighter modulating blending mode. |
static int |
REPLACE
Selects the replace mode. |
Constructor Summary | |
CompositingMode()
Constructs a CompositingMode object with default values. |
Method Summary | |
float |
getAlphaThreshold()
Retrieves the current alpha testing threshold. |
int |
getBlending()
Retrieves the current frame buffer blending mode. |
float |
getDepthOffsetFactor()
Retrieves the current depth offset slope factor. |
float |
getDepthOffsetUnits()
Retrieves the current constant depth offset. |
boolean |
isAlphaWriteEnabled()
Queries whether alpha writing is enabled. |
boolean |
isColorWriteEnabled()
Queries whether color writing is enabled. |
boolean |
isDepthTestEnabled()
Queries whether depth testing is enabled. |
boolean |
isDepthWriteEnabled()
Queries whether depth writing is enabled. |
void |
setAlphaThreshold(float threshold)
Sets the threshold value for alpha testing. |
void |
setAlphaWriteEnable(boolean enable)
Enables or disables writing of fragment alpha values into the color buffer. |
void |
setBlending(int mode)
Selects a method of combining the pixel to be rendered with the pixel already in the frame buffer. |
void |
setColorWriteEnable(boolean enable)
Enables or disables writing of fragment color values into the color buffer. |
void |
setDepthOffset(float factor,
float units)
Defines a value that is added to the screen space Z coordinate of a pixel immediately before depth test and depth write. |
void |
setDepthTestEnable(boolean enable)
Enables or disables depth testing. |
void |
setDepthWriteEnable(boolean enable)
Enables or disables writing of fragment depth values into the depth buffer. |
Methods inherited from class javax.microedition.m3g.Object3D |
addAnimationTrack, animate, duplicate, find, getAnimationTrack, getAnimationTrackCount, getReferences, getUserID, getUserObject, removeAnimationTrack, setUserID, setUserObject |
Field Detail |
public static final int ALPHA
Selects the alpha blend mode. A weighted average of the source and destination pixels is computed.
public static final int ALPHA_ADD
Selects the additive blend mode. The source pixel is first scaled by the source alpha and then summed with the destination pixel.
public static final int MODULATE
Selects the basic modulating blending mode; source pixels are multiplied with the destination pixels.
public static final int MODULATE_X2
Selects the brighter modulating blending mode. This is the same as basic modulation, but the results are multiplied by two (and saturated to 1.0) to compensate for the loss of luminance caused by the component-wise multiplication.
public static final int REPLACE
Selects the replace mode. The destination pixel is overwritten with the source pixel.
Constructor Detail |
public CompositingMode()
Constructs a CompositingMode object with default values. The default values are:
REPLACE
Method Detail |
public void setBlending(int mode)
Selects a method of combining the pixel to be rendered with the pixel already in the frame buffer. Blending is applied as the very last step of the pixel processing pipeline.
mode
- the new blending mode
java.lang.IllegalArgumentException
- if mode
is not one
of the symbolic constants listed abovegetBlending
public int getBlending()
Retrieves the current frame buffer blending mode.
setBlending
public void setAlphaThreshold(float threshold)
Sets the threshold value for alpha testing. If the alpha component of a fragment is less than the alpha threshold, the fragment is not rendered. Consequently, if the threshold is 1.0, only fragments with the maximum alpha value (1.0) will be drawn, and if the threshold is 0.0, all fragments will be drawn.
threshold
- the new alpha threshold; must be [0, 1]
java.lang.IllegalArgumentException
- if threshold
is
negative or greater than 1.0getAlphaThreshold
public float getAlphaThreshold()
Retrieves the current alpha testing threshold.
setAlphaThreshold
public void setAlphaWriteEnable(boolean enable)
Enables or disables writing of fragment alpha values into the color buffer.
enable
- true to enable alpha write; false
to disable itsetColorWriteEnable
public boolean isAlphaWriteEnabled()
Queries whether alpha writing is enabled.
isColorWriteEnabled
public void setColorWriteEnable(boolean enable)
Enables or disables writing of fragment color values into the color buffer.
enable
- true to enable color write; false
to disable itsetAlphaWriteEnable
public boolean isColorWriteEnabled()
Queries whether color writing is enabled.
isAlphaWriteEnabled
public void setDepthWriteEnable(boolean enable)
Enables or disables writing of fragment depth values into the depth buffer. If depth buffering is not enabled in the current Graphics3D, this setting has no effect; nothing will be written anyway.
If both depth testing and depth writing are enabled, and a fragment passes the depth test, that fragment's depth value is written to the depth buffer at the corresponding position.
If depth testing is disabled and depth writing is enabled, a fragment's depth value is always written to the depth buffer.
If depth writing is disabled, a fragment's depth value is never written to the depth buffer.
enable
- true to enable depth write; false
to disable itpublic boolean isDepthWriteEnabled()
Queries whether depth writing is enabled.
public void setDepthTestEnable(boolean enable)
Enables or disables depth testing. If depth testing is enabled, a fragment is written to the frame buffer if and only if its depth component is less than or equal to the corresponding value in the depth buffer. If there is no depth buffer in the current rendering target, this setting has no effect; the fragment will be written anyway.
enable
- true to enable depth test; false to
disable itpublic boolean isDepthTestEnabled()
Queries whether depth testing is enabled.
public void setDepthOffset(float factor, float units)
Defines a value that is added to the screen space Z coordinate of a pixel immediately before depth test and depth write. The depth offset is computed for each polygon with the following formula:
factor
- slope dependent depth offsetunits
- constant depth offsetgetDepthOffsetFactor
,
getDepthOffsetUnits
public float getDepthOffsetFactor()
Retrieves the current depth offset slope factor. This is the
factor
parameter set in
setDepthOffset
.
setDepthOffset
public float getDepthOffsetUnits()
Retrieves the current constant depth offset. This is the
units
parameter set in
setDepthOffset
.
setDepthOffset
|
M3G 1.1 -- Jun 22, 2005 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |