Vital.sandbox
Model

self:set_material_feature

Shared

Enables or disables a specific rendering feature on a material


Syntax

local status = self:set_material_feature(component, material, feature, state)

Parameters

TypeNameDescription
stringcomponentPath of the component containing the material
stringmaterialName of the material to modify
Supports * as a wildcard to match multiple materials by pattern
intfeatureFeature index to toggle
Refer Features section
boolstateDetermines the feature state:
• When true - enables the specified feature
• When false - disables the specified feature

Returns

TypeNameDescription
boolstatustrue on successful execution, or false on failure

Features

ValueNameDescription
0FEATURE_EMISSIONEnables or disables emission, allowing the material to emit light
1FEATURE_NORMAL_MAPPINGEnables or disables a normal map to simulate surface detail
2FEATURE_RIMEnables or disables rim lighting for a backlit glow effect
3FEATURE_CLEARCOATEnables or disables a clearcoat layer, simulating a glossy top coat
4FEATURE_ANISOTROPYEnables or disables anisotropic reflections
5FEATURE_AMBIENT_OCCLUSIONEnables or disables ambient occlusion to darken crevices
6FEATURE_HEIGHT_MAPPINGEnables or disables a heightmap for parallax depth effects
7FEATURE_SUBSURFACE_SCATTERINGEnables or disables subsurface scattering, used for skin and organic surfaces
8FEATURE_SUBSURFACE_TRANSMITTANCEEnables or disables light transmittance through the surface
9FEATURE_BACKLIGHTEnables or disables backlight, simulating light passing through thin surfaces
10FEATURE_REFRACTIONEnables or disables refraction for transparent distortion effects
11FEATURE_DETAILEnables or disables a detail layer (secondary albedo/normal)
12FEATURE_BENT_NORMAL_MAPPINGEnables or disables bent normal mapping to improve ambient occlusion accuracy

Examples

Toggle various material's features on a model
local entity = model.create("character")

--Enable emission on a specific material
entity:set_material_feature("Skeleton3D/Body", "skin", 0, true)

--Disable subsurface scattering
entity:set_material_feature("Skeleton3D/Head", "face", 7, false)

--Toggle rim lighting on all head materials using a wildcard
entity:set_material_feature("Skeleton3D/Head", "*", 2, true)

On this page