Class MaterialData
java.lang.Object
dev.engine.core.material.MaterialData
- All Implemented Interfaces:
Component
Immutable material data — a typed property map that is a component.
The shader always accesses material data through a generated Slang interface. The engine generates the appropriate implementation (UBO, SSBO, bindless) based on the upload strategy. Shader code never changes.
Render state overrides are stored in a nested PropertyMap<RenderState>
under the RENDER_STATE key, keeping material and render state concerns separated.
var mat = MaterialData.create()
.set(MaterialData.ALBEDO_COLOR, new Vec3(1, 0, 0))
.set(MaterialData.ROUGHNESS, 0.5f)
.withRenderState(RenderState.CULL_MODE, CullMode.FRONT);
entity.add(mat);
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PropertyKey<MaterialData, Vec3> static final PropertyKey<MaterialData, Vec3> static final PropertyKey<MaterialData, Vec3> static final PropertyKey<MaterialData, Float> static final PropertyKey<MaterialData, Float> static final PropertyKey<MaterialData, Float> static final PropertyKey<MaterialData, PropertyMap<?>> static final PropertyKey<MaterialData, Float> -
Method Summary
Modifier and TypeMethodDescriptionstatic MaterialDatacreate()Creates an empty material.static MaterialDataCreates with an explicit shader hint (e.g.<T> Tget(PropertyKey<MaterialData, T> key) booleanhas(PropertyKey<MaterialData, ?> key) Set<PropertyKey<MaterialData, ?>> keys()static MaterialData<R> PropertyMap<R> Returns the render state overrides for this material, or null if none.<T> MaterialDataset(PropertyKey<MaterialData, T> key, T value) intsize()slotType()One slot per entity — replaces any existing material.toString()static MaterialData<R,T> MaterialData withRenderState(PropertyKey<R, T> key, T value) Adds a render state override to this material.withShader(String hint)
-
Field Details
-
ALBEDO_COLOR
-
ROUGHNESS
-
METALLIC
-
EMISSIVE
-
OPACITY
-
NORMAL_STRENGTH
-
COLOR
-
RENDER_STATE
-
-
Method Details
-
create
Creates an empty material. -
create
Creates with an explicit shader hint (e.g. "PBR", "UNLIT", "custom/toon.slang"). -
set
-
withRenderState
Adds a render state override to this material. Render state keys are stored in a nested PropertyMap underRENDER_STATE. -
renderState
Returns the render state overrides for this material, or null if none. -
withShader
-
get
-
has
-
keys
-
size
public int size() -
properties
-
shaderHint
-
pbr
-
unlit
-
slotType
-
toString
-