public class RenderState extends java.lang.Object implements java.lang.Cloneable, Savable
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.Modifier and Type | Class and Description |
---|---|
static class |
RenderState.BlendEquation
BlendEquation specifies the blending equation to combine
pixels. |
static class |
RenderState.BlendEquationAlpha
BlendEquationAlpha specifies the blending equation to
combine pixels for the alpha component. |
static class |
RenderState.BlendFunc
BlendFunc defines the blending functions for use with
BlendMode.Custom . |
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. |
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
RenderState() |
Modifier and Type | Method and Description |
---|---|
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 equal to this one
|
float |
getAlphaFallOff()
Deprecated.
|
RenderState.TestFunction |
getAlphaFunc()
Deprecated.
|
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.BlendEquation |
getBlendEquation()
Retrieve the blend equation.
|
RenderState.BlendEquationAlpha |
getBlendEquationAlpha()
Retrieve the blend equation used for the alpha component.
|
RenderState.BlendMode |
getBlendMode()
Retrieve the blend mode.
|
RenderState.BlendFunc |
getCustomDfactorAlpha()
Provides the destination factor for the alpha component in
BlendMode.Custom . |
RenderState.BlendFunc |
getCustomDfactorRGB()
Provides the destination factor for the RGB components in
BlendMode.Custom . |
RenderState.BlendFunc |
getCustomSfactorAlpha()
Provides the source factor for the alpha component in
BlendMode.Custom . |
RenderState.BlendFunc |
getCustomSfactorRGB()
Provides the source factor for the RGB components in
BlendMode.Custom . |
RenderState.TestFunction |
getDepthFunc()
Retrieve the depth comparison function
|
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 |
getLineWidth()
returns the wireframe line width
|
float |
getPolyOffsetFactor()
Retrieve the poly offset factor value.
|
float |
getPolyOffsetUnits()
Retrieve the poly offset units value.
|
boolean |
isAlphaTest()
Deprecated.
To use alpha test, set the
AlphaDiscardThreshold
material parameter. |
boolean |
isApplyBlendMode() |
boolean |
isApplyColorWrite() |
boolean |
isApplyCullMode() |
boolean |
isApplyDepthFunc() |
boolean |
isApplyDepthTest() |
boolean |
isApplyDepthWrite() |
boolean |
isApplyLineWidth() |
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()
Deprecated.
Always returns true since point sprite is always 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 |
set(RenderState state) |
void |
setAlphaFallOff(float alphaFallOff)
Deprecated.
Does nothing. To use alpha test, set the
AlphaDiscardThreshold material parameter. |
void |
setAlphaFunc(RenderState.TestFunction alphaFunc)
Deprecated.
|
void |
setAlphaTest(boolean alphaTest)
Deprecated.
Does nothing. To use alpha test, set the
AlphaDiscardThreshold material parameter. |
void |
setBlendEquation(RenderState.BlendEquation blendEquation)
Set the blending equation for the color component (RGB).
|
void |
setBlendEquationAlpha(RenderState.BlendEquationAlpha blendEquationAlpha)
Set the blending equation for the alpha component.
|
void |
setBlendMode(RenderState.BlendMode blendMode)
Set the blending mode.
|
void |
setColorWrite(boolean colorWrite)
Enable writing color.
|
void |
setCustomBlendFactors(RenderState.BlendFunc sfactorRGB,
RenderState.BlendFunc dfactorRGB,
RenderState.BlendFunc sfactorAlpha,
RenderState.BlendFunc dfactorAlpha)
Sets the blend factors used for the source and destination color.
|
void |
setDepthFunc(RenderState.TestFunction depthFunc)
Set the depth conparison function to the given TestFunction
default is LessOrEqual (GL_LEQUAL)
|
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 |
setLineWidth(float lineWidth)
Sets the mesh line width.
|
void |
setPointSprite(boolean pointSprite)
Deprecated.
Does nothing. Point sprite is already enabled by default for
all supported platforms. jME3 does not support rendering conventional
point clouds.
|
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) |
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.public void write(JmeExporter ex) throws java.io.IOException
public void read(JmeImporter im) throws 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 compare to@Deprecated public void setPointSprite(boolean pointSprite)
@Deprecated public void setAlphaFallOff(float alphaFallOff)
AlphaDiscardThreshold
material parameter.alphaFallOff
- does nothing@Deprecated public void setAlphaTest(boolean alphaTest)
AlphaDiscardThreshold
material parameter.alphaTest
- does nothingpublic 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 setBlendEquation(RenderState.BlendEquation blendEquation)
The blending equation determines, how the RGB values of the input pixel
will be blended with the RGB values of the pixel already in the color buffer.
For example, RenderState.BlendEquation.Add
will add the input pixel's color
to the color already in the color buffer:
Result = Source Color + Destination Color
Note: This gets only used in RenderState.BlendMode.Custom
mode.
All other blend modes will ignore this setting.
blendEquation
- The RenderState.BlendEquation
to use.public void setBlendEquationAlpha(RenderState.BlendEquationAlpha blendEquationAlpha)
The alpha blending equation determines, how the alpha values of the input pixel
will be blended with the alpha values of the pixel already in the color buffer.
For example, RenderState.BlendEquationAlpha.Add
will add the input pixel's color
to the color already in the color buffer:
Result = Source Color + Destination Color
Note: This gets only used in RenderState.BlendMode.Custom
mode.
All other blend modes will ignore this setting.
blendEquationAlpha
- The RenderState.BlendEquationAlpha
to use.public void setCustomBlendFactors(RenderState.BlendFunc sfactorRGB, RenderState.BlendFunc dfactorRGB, RenderState.BlendFunc sfactorAlpha, RenderState.BlendFunc dfactorAlpha)
These factors will be multiplied with the color values of the input pixel
and the pixel already in the color buffer, before both colors gets combined by the RenderState.BlendEquation
.
Note: This gets only used in RenderState.BlendMode.Custom
mode.
All other blend modes will ignore this setting.
sfactorRGB
- The source blend factor for RGB components.dfactorRGB
- The destination blend factor for RGB components.sfactorAlpha
- The source blend factor for the alpha component.dfactorAlpha
- The destination blend factor for the alpha component.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 void setDepthFunc(RenderState.TestFunction depthFunc)
depthFunc
- the depth comparison functionRenderState.TestFunction
,
setDepthTest(boolean)
@Deprecated public void setAlphaFunc(RenderState.TestFunction alphaFunc)
public void setLineWidth(float lineWidth)
setWireframe(boolean)
or with a mesh in
Mesh.Mode.Lines
mode.lineWidth
- the line width.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.BlendEquation getBlendEquation()
public RenderState.BlendEquationAlpha getBlendEquationAlpha()
public RenderState.BlendMode getBlendMode()
public RenderState.BlendFunc getCustomSfactorRGB()
BlendMode.Custom
.public RenderState.BlendFunc getCustomDfactorRGB()
BlendMode.Custom
.public RenderState.BlendFunc getCustomSfactorAlpha()
BlendMode.Custom
.public RenderState.BlendFunc getCustomDfactorAlpha()
BlendMode.Custom
.@Deprecated public boolean isPointSprite()
setPointSprite(boolean)
@Deprecated public boolean isAlphaTest()
AlphaDiscardThreshold
material parameter.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)
@Deprecated public float getAlphaFallOff()
public RenderState.TestFunction getDepthFunc()
setDepthFunc(com.jme3.material.RenderState.TestFunction)
@Deprecated public RenderState.TestFunction getAlphaFunc()
RenderState.TestFunction.Greater
.public float getLineWidth()
public boolean isApplyBlendMode()
public boolean isApplyColorWrite()
public boolean isApplyCullMode()
public boolean isApplyDepthTest()
public boolean isApplyDepthWrite()
public boolean isApplyPolyOffset()
public boolean isApplyWireFrame()
public boolean isApplyDepthFunc()
public boolean isApplyLineWidth()
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 void set(RenderState state)
public java.lang.String toString()
toString
in class java.lang.Object