SceneMaterial(SceneTexture(getDrawable(R.drawable.Grass))).apply {
setRepeat(5f, 5f, 0f, 0f)
setRoughness(0.7f)
}
customMaterial =
SceneMaterial.custom(
"grassShader",
arrayOf<SceneMaterialAttribute>(
SceneMaterialAttribute("color", SceneMaterialDataType.Vector4),
SceneMaterialAttribute("textureA", SceneMaterialDataType.Texture2D),
))
.apply {
setAttribute("color", Vector4(1f, 0f, 0f, 1f))
setTexture("textureA", SceneTexture(getDrawable(R.drawable.Grass)))
}
class SceneMaterial
SceneMaterial
(
texture
, alphaMode
, shader
)
|
Creates a material with the specified texture and alpha mode.
Signature
constructor(texture: SceneTexture, alphaMode: AlphaMode = AlphaMode.OPAQUE, shader: String = "") Parameters
shader:
String
Returns |
handle
: Long
[Get] |
Signature
var handle: Long |
params
: Array?
[Get] |
Signature
var params: Array<SceneMaterialAttribute>? |
texture
: SceneTexture?
[Get] |
Signature
var texture: SceneTexture? |
textures
: HashMap<String, SceneTexture>()
[Get] |
Signature
var textures: HashMap<String, SceneTexture>() |
destroy
()
|
Signature
fun destroy() |
getAttributeIndex
(
name
)
|
Gets the index of a named attribute in a custom shader.
Signature
fun getAttributeIndex(name: String): Int Parameters
name:
String
Returns
Int
|
setAlbedoColor
(
color
)
|
Sets the albedo (base color) for this material.
Signature
fun setAlbedoColor(color: Color) Parameters
color:
Color
|
setAlbedoTexture
(
texture
)
|
Sets the primary albedo (base color) texture for this material.
Signature
fun setAlbedoTexture(texture: SceneTexture?) Parameters |
setAttribute
(
name
, v
)
|
Sets a Vector4 attribute value by name for a custom shader.
Signature
fun setAttribute(name: String, v: Vector4) Parameters
name:
String
|
setAttribute
(
name
, v
)
|
Sets a texture attribute by name for a custom shader.
Signature
fun setAttribute(name: String, v: SceneTexture?) Parameters
name:
String
|
setAttribute
(
index
, v
)
|
Sets a Vector4 attribute value by index for a custom shader.
Signature
fun setAttribute(index: Int, v: Vector4) Parameters
index:
Int
|
setAttribute
(
index
, v
)
|
Sets a texture attribute by index for a custom shader.
Signature
fun setAttribute(index: Int, v: SceneTexture?) Parameters
index:
Int
|
setBlendMode
(
blendMode
)
|
Sets the blend mode for this material. By default, custom materials are opaque.
Signature
fun setBlendMode(blendMode: BlendMode) Parameters |
setColorWrite
(
mask
)
|
Sets which color channels should be written to the framebuffer. By default, a custom material writes all channels.
Signature
fun setColorWrite(mask: Int) Parameters
mask:
Int
|
setDepthTest
(
depthTest
)
|
Sets the depth testing function for this material. By default, faces aren't shaded if occluded by other geometry.
Signature
fun setDepthTest(depthTest: DepthTest) Parameters |
setDepthWrite
(
depthWrite
)
|
Sets whether this material should write to the depth buffer. By default, custom materials write depth.
Signature
fun setDepthWrite(depthWrite: DepthWrite) Parameters |
setMetalRoughness
(
roughness
)
|
Configures the material as metallic with the specified roughness for physically-based rendering.
Signature
fun setMetalRoughness(roughness: Float) Parameters
roughness:
Float
|
setRenderOrder
(
renderOrder
)
|
Sets a render order offset for this material, allowing fine-grained control over render ordering within the same sort order category.
This value acts as an override to the sort order, providing additional control over the rendering sequence. Objects with higher render order values are rendered later.
Signature
fun setRenderOrder(renderOrder: Int) Parameters
renderOrder:
Int
|
setRepeat
(
scaleX
, scaleY
, offsetX
, offsetY
)
|
This controls how the texture is tiled and positioned on the surface.
Signature
fun setRepeat(scaleX: Float, scaleY: Float, offsetX: Float, offsetY: Float) Parameters
scaleX:
Float
scaleY:
Float
offsetX:
Float
offsetY:
Float
|
setRoughness
(
roughness
)
|
Configures the material as non-metallic with the specified roughness for physically-based rendering.
Signature
fun setRoughness(roughness: Float) Parameters
roughness:
Float
|
setRoughnessMetallicness
(
roughness
, metallicness
)
|
Sets both roughness and metallicness properties for physically-based rendering.
Signature
fun setRoughnessMetallicness(roughness: Float, metallicness: Float) Parameters
roughness:
Float
metallicness:
Float
|
setSidedness
(
sidedness
)
|
Sets whether faces should be rendered on one side, both sides, or neither. By default, only the front faces are rendered.
Signature
fun setSidedness(sidedness: MaterialSidedness) Parameters |
setSortOrder
(
sortOrder
)
|
Sets the render sort order for this material. By default, custom materials have opaque sort order.
Signature
fun setSortOrder(sortOrder: SortOrder) Parameters |
setStereoMode
(
mode
)
|
Sets the stereo rendering mode for this material. This can allow you to display stereoscopic 3D media.
Signature
fun setStereoMode(mode: StereoMode) Parameters |
setTexture
(
binding
, texture
)
|
Sets the texture for a named attribute in a custom shader.
Signature
fun setTexture(binding: String, texture: SceneTexture) Parameters
binding:
String
|
setUnlit
(
isUnlit
)
|
Sets whether this material should be rendered without lighting calculations.
Unlit materials ignore scene lighting and are rendered with full brightness. For best performance, you can alternatively utilize the SceneMaterial.UNLIT_SHADER shader override.
Signature
fun setUnlit(isUnlit: Boolean) Parameters
isUnlit:
Boolean
|
HOLE_PUNCH_PANEL_ALPHA_SHADER
: String
[Get] |
Hole punch shader which does not feather the edge, and might have black lines on the edge.
Used in conjunction with AlphaMode.MASKED_HOLE_PUNCH or AlphaBlendMode.TRANSLUCENT_HOLE_PUNCH
Signature
val HOLE_PUNCH_PANEL_ALPHA_SHADER: String |
HOLE_PUNCH_PANEL_EDGE_SHADER
: String
[Get] |
Hole punch shader which detects and feathers the edges but not the alpha regions in the texture.
Used in conjunction with AlphaMode.MASKED_HOLE_PUNCH or AlphaBlendMode.TRANSLUCENT_HOLE_PUNCH
Signature
val HOLE_PUNCH_PANEL_EDGE_SHADER: String |
HOLE_PUNCH_PANEL_FEATHER_SHADER
: String
[Get] |
Hole punch shader which detects and feathers the edges and the alpha regions in the texture.
Used in conjunction with AlphaMode.MASKED_HOLE_PUNCH or AlphaBlendMode.TRANSLUCENT_HOLE_PUNCH
Signature
val HOLE_PUNCH_PANEL_FEATHER_SHADER: String |
HOLE_PUNCH_PANEL_SHADER
: String
[Get] |
Shader similar to HOLE_PUNCH_SHADER but instead factors in the transparency of the base color (panel). This shader will likely need to be used if you have transparency in your panel so we don't have to punch holes on the areas that are transparent. If you are setting this on your panel, you will likely need to use forceSceneTexture = true.
Used in conjunction with AlphaMode.HOLE_PUNCH
Signature
val HOLE_PUNCH_PANEL_SHADER: String |
HOLE_PUNCH_SHADER
: String
[Get] |
Hole punch shader to indiscriminately punch holes on the geometry. Hole punching is used to cut out space for layers to be rendered.
Used in conjunction with AlphaMode.HOLE_PUNCH
Signature
val HOLE_PUNCH_SHADER: String |
PHYSICALLY_BASED_SHADER
: String
[Get] |
Our default physically based renderer. This is complete with lighting and IBL. Has the highest graphical fidelity but is also the most compute intensive
Signature
val PHYSICALLY_BASED_SHADER: String |
TEXTURED_UNLIT_SHADER
: String
[Get] |
Signature
val TEXTURED_UNLIT_SHADER: String |
UNLIT_SHADER
: String
[Get] |
Signature
val UNLIT_SHADER: String |
custom
(
shader
, params
, vertexLayout
)
|
Create a custom material with a custom shader and params. Learn more about how to create custom shader materials here.
Signature
fun custom(shader: String, params: Array<SceneMaterialAttribute>, vertexLayout: VertexLayout = VertexLayout.COMPACT): SceneMaterial Parameters
shader:
String
params:
Array
Returns |
depthOnly
(
isPrePass
)
|
Creates a material that only writes to the depth buffer.
Depth-only materials are useful for creating invisible geometry that still participates in depth testing, such as collision surfaces or occlusion volumes.
Signature
fun depthOnly(isPrePass: Boolean): SceneMaterial Parameters
isPrePass:
Boolean
|
passthrough
()
|
Creates a material for rendering passthrough content.
Passthrough materials allow the real world to be visible through virtual content, which is essential for mixed reality applications.
Signature
fun passthrough(): SceneMaterial |