-
public class MaterialInstance
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enumMaterialInstance.BooleanElementpublic enumMaterialInstance.IntElementpublic enumMaterialInstance.FloatElementpublic enumMaterialInstance.StencilOperationOperations that control how the stencil buffer is updated.
public enumMaterialInstance.StencilFace
-
Constructor Summary
Constructors Constructor Description MaterialInstance(Engine engine, long nativeMaterialInstance)
-
Method Summary
Modifier and Type Method Description static MaterialInstanceduplicate(@NonNull() MaterialInstance other, String name)Creates a new MaterialInstance using another MaterialInstance as a template for initialization. MaterialgetMaterial()StringgetName()voidsetParameter(@NonNull() String name, boolean x)Sets the value of a bool parameter. voidsetParameter(@NonNull() String name, float x)Sets the value of a float parameter. voidsetParameter(@NonNull() String name, int x)Sets the value of an int parameter. voidsetParameter(@NonNull() String name, boolean x, boolean y)Sets the value of a bool2 parameter. voidsetParameter(@NonNull() String name, float x, float y)Sets the value of a float2 parameter. voidsetParameter(@NonNull() String name, int x, int y)Sets the value of an int2 parameter. voidsetParameter(@NonNull() String name, boolean x, boolean y, boolean z)Sets the value of a bool3 parameter. voidsetParameter(@NonNull() String name, float x, float y, float z)Sets the value of a float3 parameter. voidsetParameter(@NonNull() String name, int x, int y, int z)Sets the value of a int3 parameter. voidsetParameter(@NonNull() String name, boolean x, boolean y, boolean z, boolean w)Sets the value of a bool4 parameter. voidsetParameter(@NonNull() String name, float x, float y, float z, float w)Sets the value of a float4 parameter. voidsetParameter(@NonNull() String name, int x, int y, int z, int w)Sets the value of a int4 parameter. voidsetParameter(@NonNull() String name, @NonNull() Texture texture, @NonNull() TextureSampler sampler)Sets a texture and sampler parameter on this material's default instance. voidsetParameter(@NonNull() String name, @NonNull() MaterialInstance.BooleanElement type, @NonNull() Array<boolean> v, @IntRange(from = 0) int offset, @IntRange(from = 1) int count)Set a bool parameter array by name. voidsetParameter(@NonNull() String name, @NonNull() MaterialInstance.IntElement type, @NonNull() Array<int> v, @IntRange(from = 0) int offset, @IntRange(from = 1) int count)Set an int parameter array by name. voidsetParameter(@NonNull() String name, @NonNull() MaterialInstance.FloatElement type, @NonNull() Array<float> v, @IntRange(from = 0) int offset, @IntRange(from = 1) int count)Set a float parameter array by name. voidsetParameter(@NonNull() String name, @NonNull() Colors.RgbType type, float r, float g, float b)Sets the color of the given parameter on this material's default instance. voidsetParameter(@NonNull() String name, @NonNull() Colors.RgbaType type, float r, float g, float b, float a)Sets the color of the given parameter on this material's default instance. voidsetScissor(@IntRange(from = 0) int left, @IntRange(from = 0) int bottom, @IntRange(from = 0) int width, @IntRange(from = 0) int height)Set-up a custom scissor rectangle; by default it is disabled. voidunsetScissor()Returns the scissor rectangle to its default disabled setting. voidsetPolygonOffset(float scale, float constant)Sets a polygon offset that will be applied to all renderables drawn with this materialinstance.The value of the offset is scale * dz + r * constant, where dz is the change in depthrelative to the screen area of the triangle, and r is the smallest value that is guaranteedto produce a resolvable offset for a given implementation. voidsetMaskThreshold(float threshold)Overrides the minimum alpha value a fragment must have to not be discarded when the blendmode is MASKED. floatgetMaskThreshold()Gets the minimum alpha value a fragment must have to not be discarded when the blendmode is MASKED voidsetSpecularAntiAliasingVariance(float variance)Sets the screen space variance of the filter kernel used when applying specularanti-aliasing. floatgetSpecularAntiAliasingVariance()Gets the screen space variance of the filter kernel used when applying specularanti-aliasing. voidsetSpecularAntiAliasingThreshold(float threshold)Sets the clamping threshold used to suppress estimation errors when applying specularanti-aliasing. floatgetSpecularAntiAliasingThreshold()Gets the clamping threshold used to suppress estimation errors when applying specularanti-aliasing. voidsetDoubleSided(boolean doubleSided)Enables or disables double-sided lighting if the parent Material has double-sided capability,otherwise prints a warning. booleanisDoubleSided()Returns whether double-sided lighting is enabled when the parent Material has double-sidedcapability. voidsetCullingMode(@NonNull() Material.CullingMode mode)Overrides the default triangle culling state that was set on the material. Material.CullingModegetCullingMode()Returns the face culling mode. voidsetColorWrite(boolean enable)Overrides the default color-buffer write state that was set on the material. booleanisColorWriteEnabled()Returns whether color write is enabled. voidsetDepthWrite(boolean enable)Overrides the default depth-buffer write state that was set on the material. booleanisDepthWriteEnabled()Returns whether depth write is enabled. voidsetStencilWrite(boolean enable)Enables or Disable stencil writes booleanisStencilWriteEnabled()Returns whether stencil write is enabled. voidsetDepthCulling(boolean enable)Overrides the default depth testing state that was set on the material. booleanisDepthCullingEnabled()Returns whether depth culling is enabled. voidsetStencilCompareFunction(TextureSampler.CompareFunction func, MaterialInstance.StencilFace face)Sets the stencil comparison function (default is ALWAYS). voidsetStencilCompareFunction(TextureSampler.CompareFunction func)Sets the stencil comparison function for both front and back-facing polygons. voidsetStencilOpStencilFail(MaterialInstance.StencilOperation op, MaterialInstance.StencilFace face)Sets the stencil fail operation (default is KEEP). voidsetStencilOpStencilFail(MaterialInstance.StencilOperation op)Sets the stencil fail operation for both front and back-facing polygons. voidsetStencilOpDepthFail(MaterialInstance.StencilOperation op, MaterialInstance.StencilFace face)Sets the depth fail operation (default is KEEP). voidsetStencilOpDepthFail(MaterialInstance.StencilOperation op)Sets the depth fail operation for both front and back-facing polygons. voidsetStencilOpDepthStencilPass(MaterialInstance.StencilOperation op, MaterialInstance.StencilFace face)Sets the depth-stencil pass operation (default is KEEP). voidsetStencilOpDepthStencilPass(MaterialInstance.StencilOperation op)Sets the depth-stencil pass operation for both front and back-facing polygons. voidsetStencilReferenceValue(@IntRange(from = 0, to = 255) int value, MaterialInstance.StencilFace face)Sets the stencil reference value (default is 0). voidsetStencilReferenceValue(@IntRange(from = 0, to = 255) int value)Sets the stencil reference value for both front and back-facing polygons. voidsetStencilReadMask(@IntRange(from = 0, to = 255) int readMask, MaterialInstance.StencilFace face)Sets the stencil read mask (default is 0xFF). voidsetStencilReadMask(@IntRange(from = 0, to = 255) int readMask)Sets the stencil read mask for both front and back-facing polygons. voidsetStencilWriteMask(@IntRange(from = 0, to = 255) int writeMask, MaterialInstance.StencilFace face)Sets the stencil write mask (default is 0xFF). voidsetStencilWriteMask(int writeMask)Sets the stencil write mask for both front and back-facing polygons. longgetNativeObject()-
-
Constructor Detail
-
MaterialInstance
MaterialInstance(Engine engine, long nativeMaterialInstance)
-
-
Method Detail
-
duplicate
@NonNull() static MaterialInstance duplicate(@NonNull() MaterialInstance other, String name)
Creates a new MaterialInstance using another MaterialInstance as a template for initialization.The new MaterialInstance is an instance of the same Material of the template instance andmust be destroyed just like any other MaterialInstance.
- Parameters:
other- A MaterialInstance to use as a template for initializing a new instancename- A name for the new MaterialInstance or nullptr to use the template's name
-
getMaterial
@NonNull() Material getMaterial()
-
setParameter
void setParameter(@NonNull() String name, boolean x)
Sets the value of a bool parameter.
- Parameters:
name- the name of the material parameterx- the value of the material parameter
-
setParameter
void setParameter(@NonNull() String name, float x)
Sets the value of a float parameter.
- Parameters:
name- the name of the material parameterx- the value of the material parameter
-
setParameter
void setParameter(@NonNull() String name, int x)
Sets the value of an int parameter.
- Parameters:
name- the name of the material parameterx- the value of the material parameter
-
setParameter
void setParameter(@NonNull() String name, boolean x, boolean y)
Sets the value of a bool2 parameter.
- Parameters:
name- the name of the material parameterx- the value of the first componenty- the value of the second component
-
setParameter
void setParameter(@NonNull() String name, float x, float y)
Sets the value of a float2 parameter.
- Parameters:
name- the name of the material parameterx- the value of the first componenty- the value of the second component
-
setParameter
void setParameter(@NonNull() String name, int x, int y)
Sets the value of an int2 parameter.
- Parameters:
name- the name of the material parameterx- the value of the first componenty- the value of the second component
-
setParameter
void setParameter(@NonNull() String name, boolean x, boolean y, boolean z)
Sets the value of a bool3 parameter.
- Parameters:
name- the name of the material parameterx- the value of the first componenty- the value of the second componentz- the value of the third component
-
setParameter
void setParameter(@NonNull() String name, float x, float y, float z)
Sets the value of a float3 parameter.
- Parameters:
name- the name of the material parameterx- the value of the first componenty- the value of the second componentz- the value of the third component
-
setParameter
void setParameter(@NonNull() String name, int x, int y, int z)
Sets the value of a int3 parameter.
- Parameters:
name- the name of the material parameterx- the value of the first componenty- the value of the second componentz- the value of the third component
-
setParameter
void setParameter(@NonNull() String name, boolean x, boolean y, boolean z, boolean w)
Sets the value of a bool4 parameter.
- Parameters:
name- the name of the material parameterx- the value of the first componenty- the value of the second componentz- the value of the third componentw- the value of the fourth component
-
setParameter
void setParameter(@NonNull() String name, float x, float y, float z, float w)
Sets the value of a float4 parameter.
- Parameters:
name- the name of the material parameterx- the value of the first componenty- the value of the second componentz- the value of the third componentw- the value of the fourth component
-
setParameter
void setParameter(@NonNull() String name, int x, int y, int z, int w)
Sets the value of a int4 parameter.
- Parameters:
name- the name of the material parameterx- the value of the first componenty- the value of the second componentz- the value of the third componentw- the value of the fourth component
-
setParameter
void setParameter(@NonNull() String name, @NonNull() Texture texture, @NonNull() TextureSampler sampler)
Sets a texture and sampler parameter on this material's default instance.
Note: Depth textures can't be sampled with a linear filter unless the comparison mode is setto COMPARE_TO_TEXTURE.
- Parameters:
name- The name of the material texture parametertexture- The texture to set as parametersampler- The sampler to be used with this texture
-
setParameter
void setParameter(@NonNull() String name, @NonNull() MaterialInstance.BooleanElement type, @NonNull() Array<boolean> v, @IntRange(from = 0) int offset, @IntRange(from = 1) int count)
Set a bool parameter array by name.
- Parameters:
name- name of the parameter array as defined by this Materialtype- the number of components for each individual parameterv- array of values to set to the named parameter arrayoffset- the number of elements invto skipcount- the number of elements in the parameter array to setFor example, to set a parameter array of 4 bool4s:{@code * boolean[] a = new boolean[4 * 4]; * instance.setParameter("param", MaterialInstance.BooleanElement.BOOL4, a, 0, 4); * }
-
setParameter
void setParameter(@NonNull() String name, @NonNull() MaterialInstance.IntElement type, @NonNull() Array<int> v, @IntRange(from = 0) int offset, @IntRange(from = 1) int count)
Set an int parameter array by name.
- Parameters:
name- name of the parameter array as defined by this Materialtype- the number of components for each individual parameterv- array of values to set to the named parameter arrayoffset- the number of elements invto skipcount- the number of elements in the parameter array to setFor example, to set a parameter array of 4 int4s:{@code * int[] a = new int[4 * 4]; * instance.setParameter("param", MaterialInstance.IntElement.INT4, a, 0, 4); * }
-
setParameter
void setParameter(@NonNull() String name, @NonNull() MaterialInstance.FloatElement type, @NonNull() Array<float> v, @IntRange(from = 0) int offset, @IntRange(from = 1) int count)
Set a float parameter array by name.
- Parameters:
name- name of the parameter array as defined by this Materialtype- the number of components for each individual parameterv- array of values to set to the named parameter arrayoffset- the number of elements invto skipcount- the number of elements in the parameter array to setFor example, to set a parameter array of 4 float4s:{@code * float[] a = new float[4 * 4]; * material.setDefaultParameter("param", MaterialInstance.FloatElement.FLOAT4, a, 0, 4); * }
-
setParameter
void setParameter(@NonNull() String name, @NonNull() Colors.RgbType type, float r, float g, float b)
Sets the color of the given parameter on this material's default instance.
- Parameters:
name- the name of the material color parametertype- whether the color is specified in the linear or sRGB spacer- red componentg- green componentb- blue component
-
setParameter
void setParameter(@NonNull() String name, @NonNull() Colors.RgbaType type, float r, float g, float b, float a)
Sets the color of the given parameter on this material's default instance.
- Parameters:
name- the name of the material color parametertype- whether the color is specified in the linear or sRGB spacer- red componentg- green componentb- blue componenta- alpha component
-
setScissor
void setScissor(@IntRange(from = 0) int left, @IntRange(from = 0) int bottom, @IntRange(from = 0) int width, @IntRange(from = 0) int height)
Set-up a custom scissor rectangle; by default it is disabled.
The scissor rectangle gets clipped by the View's viewport, in other words, the scissorcannot affect fragments outside of the View's Viewport.
Currently the scissor is not compatible with dynamic resolution and should always bedisabled when dynamic resolution is used.
- Parameters:
left- left coordinate of the scissor box relative to the viewportbottom- bottom coordinate of the scissor box relative to the viewportwidth- width of the scissor boxheight- height of the scissor box
-
unsetScissor
void unsetScissor()
Returns the scissor rectangle to its default disabled setting.
Currently the scissor is not compatible with dynamic resolution and should always bedisabled when dynamic resolution is used.
-
setPolygonOffset
void setPolygonOffset(float scale, float constant)
Sets a polygon offset that will be applied to all renderables drawn with this materialinstance.The value of the offset is scale * dz + r * constant, where dz is the change in depthrelative to the screen area of the triangle, and r is the smallest value that is guaranteedto produce a resolvable offset for a given implementation. This offset is added before thedepth test.Warning: using a polygon offset other than zero has a significant negative performanceimpact, as most implementations have to disable early depth culling. DO NOT USE unlessabsolutely necessary.
- Parameters:
scale- scale factor used to create a variable depth offset for each triangleconstant- scale factor used to create a constant depth offset for each triangle
-
setMaskThreshold
void setMaskThreshold(float threshold)
Overrides the minimum alpha value a fragment must have to not be discarded when the blendmode is MASKED. Defaults to 0.4 if it has not been set in the parent Material. The specifiedvalue should be between 0 and 1 and will be clamped if necessary.
-
getMaskThreshold
float getMaskThreshold()
Gets the minimum alpha value a fragment must have to not be discarded when the blendmode is MASKED
-
setSpecularAntiAliasingVariance
void setSpecularAntiAliasingVariance(float variance)
Sets the screen space variance of the filter kernel used when applying specularanti-aliasing. The default value is set to 0.15. The specified value should be between0 and 1 and will be clamped if necessary.
-
getSpecularAntiAliasingVariance
float getSpecularAntiAliasingVariance()
Gets the screen space variance of the filter kernel used when applying specularanti-aliasing.
-
setSpecularAntiAliasingThreshold
void setSpecularAntiAliasingThreshold(float threshold)
Sets the clamping threshold used to suppress estimation errors when applying specularanti-aliasing. The default value is set to 0.2. The specified value should be between 0and 1 and will be clamped if necessary.
-
getSpecularAntiAliasingThreshold
float getSpecularAntiAliasingThreshold()
Gets the clamping threshold used to suppress estimation errors when applying specularanti-aliasing.
-
setDoubleSided
void setDoubleSided(boolean doubleSided)
Enables or disables double-sided lighting if the parent Material has double-sided capability,otherwise prints a warning. If double-sided lighting is enabled, backface culling isautomatically disabled.
-
isDoubleSided
boolean isDoubleSided()
Returns whether double-sided lighting is enabled when the parent Material has double-sidedcapability.
-
setCullingMode
void setCullingMode(@NonNull() Material.CullingMode mode)
Overrides the default triangle culling state that was set on the material.
-
getCullingMode
@NonNull() Material.CullingMode getCullingMode()
Returns the face culling mode.
-
setColorWrite
void setColorWrite(boolean enable)
Overrides the default color-buffer write state that was set on the material.
-
isColorWriteEnabled
boolean isColorWriteEnabled()
Returns whether color write is enabled.
-
setDepthWrite
void setDepthWrite(boolean enable)
Overrides the default depth-buffer write state that was set on the material.
-
isDepthWriteEnabled
boolean isDepthWriteEnabled()
Returns whether depth write is enabled.
-
setStencilWrite
void setStencilWrite(boolean enable)
Enables or Disable stencil writes
-
isStencilWriteEnabled
boolean isStencilWriteEnabled()
Returns whether stencil write is enabled.
-
setDepthCulling
void setDepthCulling(boolean enable)
Overrides the default depth testing state that was set on the material.
-
isDepthCullingEnabled
boolean isDepthCullingEnabled()
Returns whether depth culling is enabled.
-
setStencilCompareFunction
void setStencilCompareFunction(TextureSampler.CompareFunction func, MaterialInstance.StencilFace face)
Sets the stencil comparison function (default is ALWAYS).
It's possible to set separate stencil comparison functions; one for front-facing polygons,and one for back-facing polygons. The face parameter determines the comparison function(s)updated by this call.
- Parameters:
func- the stencil comparison functionface- the faces to update the comparison function for
-
setStencilCompareFunction
void setStencilCompareFunction(TextureSampler.CompareFunction func)
Sets the stencil comparison function for both front and back-facing polygons.
-
setStencilOpStencilFail
void setStencilOpStencilFail(MaterialInstance.StencilOperation op, MaterialInstance.StencilFace face)
Sets the stencil fail operation (default is KEEP).
The stencil fail operation is performed to update values in the stencil buffer when thestencil test fails.
It's possible to set separate stencil fail operations; one for front-facing polygons, and onefor back-facing polygons. The face parameter determines the stencil fail operation(s) updatedby this call.
- Parameters:
op- the stencil fail operationface- the faces to update the stencil fail operation for
-
setStencilOpStencilFail
void setStencilOpStencilFail(MaterialInstance.StencilOperation op)
Sets the stencil fail operation for both front and back-facing polygons.
-
setStencilOpDepthFail
void setStencilOpDepthFail(MaterialInstance.StencilOperation op, MaterialInstance.StencilFace face)
Sets the depth fail operation (default is KEEP).
The depth fail operation is performed to update values in the stencil buffer when the depthtest fails.
It's possible to set separate depth fail operations; one for front-facing polygons, and onefor back-facing polygons. The face parameter determines the depth fail operation(s) updatedby this call.
- Parameters:
op- the depth fail operationface- the faces to update the depth fail operation for
-
setStencilOpDepthFail
void setStencilOpDepthFail(MaterialInstance.StencilOperation op)
Sets the depth fail operation for both front and back-facing polygons.
-
setStencilOpDepthStencilPass
void setStencilOpDepthStencilPass(MaterialInstance.StencilOperation op, MaterialInstance.StencilFace face)
Sets the depth-stencil pass operation (default is KEEP).
The depth-stencil pass operation is performed to update values in the stencil buffer whenboth the stencil test and depth test pass.
It's possible to set separate depth-stencil pass operations; one for front-facing polygons,and one for back-facing polygons. The face parameter determines the depth-stencil passoperation(s) updated by this call.
- Parameters:
op- the depth-stencil pass operationface- the faces to update the depth-stencil operation for
-
setStencilOpDepthStencilPass
void setStencilOpDepthStencilPass(MaterialInstance.StencilOperation op)
Sets the depth-stencil pass operation for both front and back-facing polygons.
-
setStencilReferenceValue
void setStencilReferenceValue(@IntRange(from = 0, to = 255) int value, MaterialInstance.StencilFace face)
Sets the stencil reference value (default is 0).
The stencil reference value is the left-hand side for stencil comparison tests. It's alsoused as the replacement stencil value when StencilOperation is REPLACE.
It's possible to set separate stencil reference values; one for front-facing polygons, andone for back-facing polygons. The face parameter determines the reference value(s) updated bythis call.
- Parameters:
value- the stencil reference value (only the least significant 8 bits are used)face- the faces to update the reference value for
-
setStencilReferenceValue
void setStencilReferenceValue(@IntRange(from = 0, to = 255) int value)
Sets the stencil reference value for both front and back-facing polygons.
-
setStencilReadMask
void setStencilReadMask(@IntRange(from = 0, to = 255) int readMask, MaterialInstance.StencilFace face)
Sets the stencil read mask (default is 0xFF).
The stencil read mask masks the bits of the values participating in the stencil comparisontest- both the value read from the stencil buffer and the reference value.
It's possible to set separate stencil read masks; one for front-facing polygons, and one forback-facing polygons. The face parameter determines the stencil read mask(s) updated by thiscall.
- Parameters:
readMask- the read mask (only the least significant 8 bits are used)face- the faces to update the read mask for
-
setStencilReadMask
void setStencilReadMask(@IntRange(from = 0, to = 255) int readMask)
Sets the stencil read mask for both front and back-facing polygons.
-
setStencilWriteMask
void setStencilWriteMask(@IntRange(from = 0, to = 255) int writeMask, MaterialInstance.StencilFace face)
Sets the stencil write mask (default is 0xFF).
The stencil write mask masks the bits in the stencil buffer updated by stencil operations.
It's possible to set separate stencil write masks; one for front-facing polygons, and one forback-facing polygons. The face parameter determines the stencil write mask(s) updated by thiscall.
- Parameters:
writeMask- the write mask (only the least significant 8 bits are used)face- the faces to update the read mask for
-
setStencilWriteMask
void setStencilWriteMask(int writeMask)
Sets the stencil write mask for both front and back-facing polygons.
-
getNativeObject
long getNativeObject()
-
-
-
-