|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jme3.material.RenderState
public class RenderState
RenderState
specifies material rendering properties that cannot
be controlled by a shader on a Material
. The properties
allow manipulation of rendering features such as depth testing, alpha blending,
face culling, stencil operations, and much more.
Nested Class Summary | |
---|---|
static class |
RenderState.BlendMode
BlendMode specifies the blending operation to use. |
static class |
RenderState.FaceCullMode
FaceCullMode specifies the criteria for faces to be culled. |
static class |
RenderState.StencilOperation
StencilOperation specifies the stencil operation to use
in a certain scenario as specified in setStencil(boolean,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.TestFunction,
com.jme3.material.RenderState.TestFunction) |
static class |
RenderState.TestFunction
TestFunction specifies the testing function for stencil test
function and alpha test function. |
Field Summary | |
---|---|
static RenderState |
ADDITIONAL
The ADDITIONAL render state is identical to the
DEFAULT render state except that all apply
values are set to false. |
static RenderState |
DEFAULT
The DEFAULT render state is the one used by default
on all materials unless changed otherwise by the user. |
static RenderState |
NULL
The NULL render state is identical to the DEFAULT
render state except that depth testing and face culling are disabled. |
Constructor Summary | |
---|---|
RenderState()
|
Method Summary | |
---|---|
RenderState |
clone()
Create a clone of this RenderState |
int |
contentHashCode()
|
RenderState |
copyMergedTo(RenderState additionalState,
RenderState state)
Merges this state and additionalState into
the parameter state based on a specific criteria. |
boolean |
equals(java.lang.Object o)
returns true if the given renderState is equall to this one |
float |
getAlphaFallOff()
Retrieve the alpha falloff value. |
RenderState.StencilOperation |
getBackStencilDepthFailOperation()
Retrieve the back depth test fail operation. |
RenderState.StencilOperation |
getBackStencilDepthPassOperation()
Retrieve the back depth test pass operation. |
RenderState.TestFunction |
getBackStencilFunction()
Retrieve the back stencil function. |
RenderState.StencilOperation |
getBackStencilStencilFailOperation()
Retrieve the back stencil fail operation. |
RenderState.BlendMode |
getBlendMode()
Retrieve the blend mode. |
RenderState.FaceCullMode |
getFaceCullMode()
Retrieve the face cull mode. |
RenderState.StencilOperation |
getFrontStencilDepthFailOperation()
Retrieve the front depth test fail operation. |
RenderState.StencilOperation |
getFrontStencilDepthPassOperation()
Retrieve the front depth test pass operation. |
RenderState.TestFunction |
getFrontStencilFunction()
Retrieve the front stencil function. |
RenderState.StencilOperation |
getFrontStencilStencilFailOperation()
Retrieve the front stencil fail operation. |
float |
getPolyOffsetFactor()
Retrieve the poly offset factor value. |
float |
getPolyOffsetUnits()
Retrieve the poly offset units value. |
boolean |
isAlphaTest()
Check if alpha test is enabled. |
boolean |
isApplyAlphaFallOff()
|
boolean |
isApplyAlphaTest()
|
boolean |
isApplyBlendMode()
|
boolean |
isApplyColorWrite()
|
boolean |
isApplyCullMode()
|
boolean |
isApplyDepthTest()
|
boolean |
isApplyDepthWrite()
|
boolean |
isApplyPointSprite()
|
boolean |
isApplyPolyOffset()
|
boolean |
isApplyWireFrame()
|
boolean |
isColorWrite()
Check if color writing is enabled. |
boolean |
isDepthTest()
Check if depth test is enabled. |
boolean |
isDepthWrite()
Check if depth write is enabled. |
boolean |
isPointSprite()
Check if point sprite mode is enabled |
boolean |
isPolyOffset()
Check if polygon offset is enabled. |
boolean |
isStencilTest()
Check if stencil test is enabled. |
boolean |
isWireframe()
Check if wireframe mode is enabled. |
void |
read(JmeImporter im)
|
void |
setAlphaFallOff(float alphaFallOff)
Sets the alpha fall off value for alpha testing. |
void |
setAlphaTest(boolean alphaTest)
Enable alpha testing. |
void |
setBlendMode(RenderState.BlendMode blendMode)
Set the blending mode. |
void |
setColorWrite(boolean colorWrite)
Enable writing color. |
void |
setDepthTest(boolean depthTest)
Enable depth testing. |
void |
setDepthWrite(boolean depthWrite)
Enable depth writing. |
void |
setFaceCullMode(RenderState.FaceCullMode cullMode)
Set the face culling mode. |
void |
setPointSprite(boolean pointSprite)
Enables point sprite mode. |
void |
setPolyOffset(float factor,
float units)
Offsets the on-screen z-order of the material's polygons, to combat visual artefacts like stitching, bleeding and z-fighting for overlapping polygons. |
void |
setStencil(boolean enabled,
RenderState.StencilOperation _frontStencilStencilFailOperation,
RenderState.StencilOperation _frontStencilDepthFailOperation,
RenderState.StencilOperation _frontStencilDepthPassOperation,
RenderState.StencilOperation _backStencilStencilFailOperation,
RenderState.StencilOperation _backStencilDepthFailOperation,
RenderState.StencilOperation _backStencilDepthPassOperation,
RenderState.TestFunction _frontStencilFunction,
RenderState.TestFunction _backStencilFunction)
Enable stencil testing. |
void |
setWireframe(boolean wireframe)
Enables wireframe rendering mode. |
java.lang.String |
toString()
|
void |
write(JmeExporter ex)
|
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final RenderState DEFAULT
DEFAULT
render state is the one used by default
on all materials unless changed otherwise by the user.
It has the following properties:
public static final RenderState NULL
NULL
render state is identical to the DEFAULT
render state except that depth testing and face culling are disabled.
public static final RenderState ADDITIONAL
ADDITIONAL
render state is identical to the
DEFAULT
render state except that all apply
values are set to false. This allows the ADDITIONAL
render
state to be combined with other state but only influencing values
that were changed from the original.
Constructor Detail |
---|
public RenderState()
Method Detail |
---|
public void write(JmeExporter ex) throws java.io.IOException
write
in interface Savable
java.io.IOException
public void read(JmeImporter im) throws java.io.IOException
read
in interface Savable
java.io.IOException
public RenderState clone()
RenderState
clone
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- the renderState to compate to
public void setPointSprite(boolean pointSprite)
When point sprite is enabled, any meshes
with the type of Mesh.Mode.Points
will be rendered as 2D quads
with texturing enabled. Fragment shaders can write to the
gl_PointCoord
variable to manipulate the texture coordinate
for each pixel. The size of the 2D quad can be controlled by writing
to the gl_PointSize
variable in the vertex shader.
pointSprite
- Enables Point Sprite mode.public void setAlphaFallOff(float alphaFallOff)
If the pixel's alpha value is greater than the
alphaFallOff
then the pixel will be rendered, otherwise
the pixel will be discarded.
alphaFallOff
- The alpha of all rendered pixels must be higher
than this value to be rendered. This value should be between 0 and 1.setAlphaTest(boolean)
public void setAlphaTest(boolean alphaTest)
When alpha testing is enabled, all input pixels' alpha are compared
to the constant alpha falloff
.
If the input alpha is greater than the falloff, the pixel will be rendered,
otherwise it will be discarded.
alphaTest
- Set to true to enable alpha testing.setAlphaFallOff(float)
public void setColorWrite(boolean colorWrite)
When color write is enabled, the result of a fragment shader, the
gl_FragColor
, will be rendered into the color buffer
(including alpha).
colorWrite
- Set to true to enable color writing.public void setFaceCullMode(RenderState.FaceCullMode cullMode)
See the RenderState.FaceCullMode
enum on what each value does.
Face culling will project the triangle's points onto the screen
and determine if the triangle is in counter-clockwise order or
clockwise order. If a triangle is in counter-clockwise order, then
it is considered a front-facing triangle, otherwise, it is considered
a back-facing triangle.
cullMode
- the face culling mode.public void setBlendMode(RenderState.BlendMode blendMode)
When blending is enabled, (blendMode
is not RenderState.BlendMode.Off
)
the input pixel will be blended with the pixel
already in the color buffer. The blending operation is determined
by the RenderState.BlendMode
. For example, the RenderState.BlendMode.Additive
will add the input pixel's color to the color already in the color buffer:
Result = Source Color + Destination Color
blendMode
- The blend mode to use. Set to RenderState.BlendMode.Off
to disable blending.public void setDepthTest(boolean depthTest)
When depth testing is enabled, a pixel must pass the depth test before it is written to the color buffer. The input pixel's depth value must be less than or equal than the value already in the depth buffer to pass the depth test.
depthTest
- Enable or disable depth testing.public void setDepthWrite(boolean depthWrite)
After passing the depth test
,
a pixel's depth value will be written into the depth buffer if
depth writing is enabled.
depthWrite
- True to enable writing to the depth buffer.public void setWireframe(boolean wireframe)
When in wireframe mode, meshes
rendered in triangle mode
will not be solid, but instead, only the edges of the triangles
will be rendered.
wireframe
- True to enable wireframe mode.public void setPolyOffset(float factor, float units)
factor
- scales the maximum Z slope, with respect to X or Y of the polygonunits
- scales the minimum resolvable depth buffer valuepublic void setStencil(boolean enabled, RenderState.StencilOperation _frontStencilStencilFailOperation, RenderState.StencilOperation _frontStencilDepthFailOperation, RenderState.StencilOperation _frontStencilDepthPassOperation, RenderState.StencilOperation _backStencilStencilFailOperation, RenderState.StencilOperation _backStencilDepthFailOperation, RenderState.StencilOperation _backStencilDepthPassOperation, RenderState.TestFunction _frontStencilFunction, RenderState.TestFunction _backStencilFunction)
Stencil testing can be used to filter pixels according to the stencil buffer. Objects can be rendered with some stencil operation to manipulate the values in the stencil buffer, then, other objects can be rendered to test against the values written previously.
enabled
- Set to true to enable stencil functionality. If false
all other parameters are ignored._frontStencilStencilFailOperation
- Sets the operation to occur when
a front-facing triangle fails the front stencil function._frontStencilDepthFailOperation
- Sets the operation to occur when
a front-facing triangle fails the depth test._frontStencilDepthPassOperation
- Set the operation to occur when
a front-facing triangle passes the depth test._backStencilStencilFailOperation
- Set the operation to occur when
a back-facing triangle fails the back stencil function._backStencilDepthFailOperation
- Set the operation to occur when
a back-facing triangle fails the depth test._backStencilDepthPassOperation
- Set the operation to occur when
a back-facing triangle passes the depth test._frontStencilFunction
- Set the test function for front-facing triangles._backStencilFunction
- Set the test function for back-facing triangles.public boolean isStencilTest()
public RenderState.StencilOperation getFrontStencilStencilFailOperation()
setStencil(boolean,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.TestFunction,
com.jme3.material.RenderState.TestFunction)
public RenderState.StencilOperation getFrontStencilDepthFailOperation()
setStencil(boolean,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.TestFunction,
com.jme3.material.RenderState.TestFunction)
public RenderState.StencilOperation getFrontStencilDepthPassOperation()
setStencil(boolean,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.TestFunction,
com.jme3.material.RenderState.TestFunction)
public RenderState.StencilOperation getBackStencilStencilFailOperation()
setStencil(boolean,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.TestFunction,
com.jme3.material.RenderState.TestFunction)
public RenderState.StencilOperation getBackStencilDepthFailOperation()
setStencil(boolean,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.TestFunction,
com.jme3.material.RenderState.TestFunction)
public RenderState.StencilOperation getBackStencilDepthPassOperation()
setStencil(boolean,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.TestFunction,
com.jme3.material.RenderState.TestFunction)
public RenderState.TestFunction getFrontStencilFunction()
setStencil(boolean,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.TestFunction,
com.jme3.material.RenderState.TestFunction)
public RenderState.TestFunction getBackStencilFunction()
setStencil(boolean,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.StencilOperation,
com.jme3.material.RenderState.TestFunction,
com.jme3.material.RenderState.TestFunction)
public RenderState.BlendMode getBlendMode()
public boolean isPointSprite()
setPointSprite(boolean)
public boolean isAlphaTest()
setAlphaTest(boolean)
public RenderState.FaceCullMode getFaceCullMode()
setFaceCullMode(com.jme3.material.RenderState.FaceCullMode)
public boolean isDepthTest()
setDepthTest(boolean)
public boolean isDepthWrite()
setDepthWrite(boolean)
public boolean isWireframe()
setWireframe(boolean)
public boolean isColorWrite()
setColorWrite(boolean)
public float getPolyOffsetFactor()
setPolyOffset(float, float)
public float getPolyOffsetUnits()
setPolyOffset(float, float)
public boolean isPolyOffset()
setPolyOffset(float, float)
public float getAlphaFallOff()
setAlphaFallOff(float)
public boolean isApplyAlphaFallOff()
public boolean isApplyAlphaTest()
public boolean isApplyBlendMode()
public boolean isApplyColorWrite()
public boolean isApplyCullMode()
public boolean isApplyDepthTest()
public boolean isApplyDepthWrite()
public boolean isApplyPointSprite()
public boolean isApplyPolyOffset()
public boolean isApplyWireFrame()
public int contentHashCode()
public RenderState copyMergedTo(RenderState additionalState, RenderState state)
this
state and additionalState
into
the parameter state
based on a specific criteria.
The criteria for this merge is the following:
For every given property, such as alpha test or depth write, check
if it was modified from the original in the additionalState
if it was modified, then copy the property from the additionalState
into the parameter state
, otherwise, copy the property from this
into the parameter state
. If additionalState
is null
, then no modifications are made and this
is returned,
otherwise, the parameter state
is returned with the result
of the merge.
additionalState
- The additionalState
, from which data is taken only
if it was modified by the user.state
- Contains output of the method if additionalState
is not null.
state
if additionalState
is non-null,
otherwise returns this
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |