class SceneMaterial
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)))
}
| Name | Summary |
|---|---|
SceneMaterial | constructor(texture: SceneTexture, alphaMode: AlphaMode = AlphaMode.OPAQUE, shader: String = "") Creates a material with the specified texture and alpha mode. |
| Name | Summary |
|---|---|
Companion | object Companion |
| Name | Summary |
|---|---|
handle | var handle: Long |
params | var params: Array<SceneMaterialAttribute>? |
texture | var texture: SceneTexture? |
textures | var textures: <Error class: unknown class> |
| Name | Summary |
|---|---|
destroy | fun destroy() |
setAlbedoColor | fun setAlbedoColor(color: <Error class: unknown class>) Sets the albedo (base color) for this material. |
setAlbedoTexture | fun setAlbedoTexture(texture: SceneTexture?) Sets the primary albedo (base color) texture for this material. |
setAttribute | fun setAttribute(index: Int, v: Vector4) Sets a Vector4 attribute value by index for a custom shader. fun setAttribute(index: Int, v: SceneTexture?) Sets a texture attribute by index for a custom shader. fun setAttribute(name: String, v: Vector4) Sets a Vector4 attribute value by name for a custom shader. fun setAttribute(name: String, v: SceneTexture?) Sets a texture attribute by name for a custom shader. |
setBlendMode | fun setBlendMode(blendMode: BlendMode) Sets the blend mode for this material. By default, custom materials are opaque. |
setColorWrite | fun setColorWrite(mask: Int) Sets which color channels should be written to the framebuffer. By default, a custom material writes all channels. |
setDepthTest | fun setDepthTest(depthTest: DepthTest) Sets the depth testing function for this material. By default, faces aren’t shaded if occluded by other geometry. |
setDepthWrite | fun setDepthWrite(depthWrite: DepthWrite) Sets whether this material should write to the depth buffer. By default, custom materials write depth. |
setMetalRoughness | fun setMetalRoughness(roughness: Float) Configures the material as metallic with the specified roughness physically-based rendering. |
setRepeat | fun setRepeat(scaleX: Float, scaleY: Float, offsetX: Float, offsetY: Float) This controls how the texture is tiled and positioned on the surface. |
setRoughness | fun setRoughness(roughness: Float) Configures the material as non-metallic with the specified roughness for physically-based rendering. |
setRoughnessMetallicness | fun setRoughnessMetallicness(roughness: Float, metallicnesss: Float) Sets both roughness and metallicness properties for physically-based rendering. |
setSidedness | fun setSidedness(sidedness: MaterialSidedness) Sets whether faces should be rendered on one side, both sides, or neither. By default, only the front faces are rendered. |
setSortOrder | fun setSortOrder(sortOrder: SortOrder) Sets the render sort order for this material. By default, custom materials have opaque sort order. |
setStereoMode | fun setStereoMode(mode: StereoMode) Sets the stereo rendering mode for this material. This can allow you to display sterescopic 3D media. |
setTexture | fun setTexture(binding: String, texture: SceneTexture) Sets the texture for a named attribute in a custom shader. |
setUnlit | fun setUnlit(isUnlit: Boolean) Sets whether this material should be rendered without lighting calculations. |
object Companion
| Name | Summary |
|---|---|
HOLE_PUNCH_PANEL_SHADER | val HOLE_PUNCH_PANEL_SHADER: String 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. |
HOLE_PUNCH_SHADER | val HOLE_PUNCH_SHADER: String Hole punch shader to indescriminately punch holes on the geometry. Hole punching is used to cut out space for layers to be rendered. |
PHYSICALLY_BASED_SHADER | val PHYSICALLY_BASED_SHADER: String Our default physically based renderer. This is complete with lighting and IBL. Has the highest graphical fidelity but is also the most compute intensive |
TEXTURED_UNLIT_SHADER | val TEXTURED_UNLIT_SHADER: String |
UNLIT_SHADER | val UNLIT_SHADER: String |
| Name | Summary |
|---|---|
custom | fun custom(shader: String, params: Array<SceneMaterialAttribute>, vertexLayout: VertexLayout = VertexLayout.COMPACT): SceneMaterial Create a custom material with a custom shader and params. Learn more about how to create custom shader materials here: https://developers.meta.com/horizon/documentation/spatial-sdk/spatial-sdk-custom-shaders#custom-materials |
depthOnly | fun depthOnly(isPrePass: Boolean): SceneMaterial Creates a material that only writes to the depth buffer. |
passthrough | fun passthrough(): SceneMaterial Creates a material for rendering passthrough content. |