Shader
self:remove_from_material
ClientRemoves a shader assignment previously made with `self:apply_to_material`
Syntax
local count = self:remove_from_material(
model,
component,
material
)Surfaces fall back to the next best shader.
- What is removed — this shader's own assignments on the given target that are covered by
componentandmaterial."*"covers everything, soself:remove_from_material(model, "*", "*")removes all of them. - Fallback — each affected surface is handed to the next best assignment (highest priority, then most recently applied) and returns to its original material only when no other shader covers it.
- Target — a model instance removes assignments made for that model.
"*"/nilremoves assignments made with"*". The two do not affect each other.
Parameters
| Type | Name | Description |
|---|---|---|
model | string | nil | model | Model instance to remove from Use "*" / nil to remove the persistent assignment made for every model |
string | component | Mesh component name or wildcard pattern to match |
string | material | Surface material name or wildcard pattern to match |
Returns
| Type | Name | Description |
|---|---|---|
int | count | Number of surfaces that were handed to another shader or restored |
Examples
core.model.load("character", "models/character.glb")
local model = core.model.create("character")
local entity = core.shader.create("assets/shaders/dissolve.glsl", core.shader.shader_mode.SPATIAL)
entity:apply_to_material(model, "*", "*")
entity:remove_from_material(model, "*", "*")local entity = core.shader.create("assets/shaders/dissolve.glsl", core.shader.shader_mode.SPATIAL)
entity:remove_from_material("*", "*", "*")core.model.load("character", "models/character.glb")
local model = core.model.create("character")
local a = core.shader.create("assets/shaders/toon.glsl", core.shader.shader_mode.SPATIAL)
local b = core.shader.create("assets/shaders/dissolve.glsl", core.shader.shader_mode.SPATIAL)
a:apply_to_material(model, "*", "*")
b:apply_to_material(model, "*", "*") -- b is shown
b:remove_from_material(model, "*", "*") -- a is shown again