Class MaterialCompiler
java.lang.Object
dev.engine.graphics.common.material.MaterialCompiler
Compiles material properties into shader code and GPU-uploadable data.
This bridges the gap between the user's property bag (MaterialData) and the GPU's typed buffers + shader structs. The user never writes shader code for standard materials — this generates everything automatically.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringgenerateMaterialCbuffer(MaterialData mat, int binding) Generates a Slang cbuffer with the material's properties inlined.static StringGenerates a Slang struct definition from the material's actual properties.static StringinjectMaterialData(String source, MaterialData mat, int binding) Injects material struct/cbuffer into shader source, replacing the// __MATERIAL_DATA__placeholder.static voidregisterType(Class<?> javaType, String slangType, int sizeInBytes) Registers a custom type for material → Slang mapping.static ByteBufferSerializes the material's property values into a ByteBuffer for GPU upload.static StringshaderKey(MaterialData mat) Derives a shader key from a material's shaderHint + property set.
-
Method Details
-
shaderKey
Derives a shader key from a material's shaderHint + property set. Same key = same shader variant. Different properties = different key. -
generateMaterialStruct
Generates a Slang struct definition from the material's actual properties. -
generateMaterialCbuffer
Generates a Slang cbuffer with the material's properties inlined. -
serializeMaterialData
Serializes the material's property values into a ByteBuffer for GPU upload. Properties are laid out in the same order as the generated struct. -
injectMaterialData
Injects material struct/cbuffer into shader source, replacing the// __MATERIAL_DATA__placeholder. -
registerType
-