Skip to content

EntropyCanvas::MaterialData

Shared material data - portable across SDK, Server, Portal. More…

#include <MaterialData.h>

Name
voidsetVec4(const std::string & propName, const glm::vec4 & value)
Set a vec4 property (also used for colors).
voidsetVec3(const std::string & propName, const glm::vec3 & value)
Set a vec3 property.
voidsetVec2(const std::string & propName, const glm::vec2 & value)
Set a vec2 property.
voidsetTextureRef(const std::string & name, const AssetId & textureAssetId)
Set a texture reference by name.
voidsetMat4(const std::string & propName, const glm::mat4 & value)
Set a mat4 property.
voidsetMat3(const std::string & propName, const glm::mat3 & value)
Set a mat3 property.
voidsetInt(const std::string & propName, int32_t value)
Set an int property.
voidsetFloat(const std::string & propName, float value)
Set a float property.
boolisValid() const
Check if this is valid (has a shader assigned).
boolisTransparent() const
Check if this material uses transparency.
boolisKeywordEnabled(const std::string & keyword) const
Check if a keyword is enabled.
std::optional< AssetId >getTextureRef(const std::string & name) const
Get a texture reference by name.
voidenableKeyword(const std::string & keyword)
Enable a shader keyword.
voiddisableKeyword(const std::string & keyword)
Disable a shader keyword.
MaterialDatacreateUnlit(const std::string & materialName)
Create an Unlit material with default values.
MaterialDatacreatePBR(const std::string & materialName)
Create a PBR material with default values.
std::vector< std::pair< std::string, AssetId > >allTextureRefs() const
Get all texture references.
Name
uint64_tversion
Monotonic version number for change tracking.
AssetIdshaderAssetId
Shader asset ID (content hash of shader source) Use BuiltinShaders constants for built-in shaders.
int32_trenderQueue
Render queue priority (default: 2000 = Geometry) Background=1000, Geometry=2000, AlphaTest=2450, Transparent=3000, Overlay=4000, UI=5000.
boolreceivesShadows
Whether this material receives shadows.
std::map< std::string, MaterialPropertyValue >properties
Material properties (ordered for deterministic serialization).
std::stringname
Human-readable material name.
uint64_tmodifiedAt
Timestamp of last modification (microseconds since Unix epoch).
std::vector< std::string >enabledKeywords
Enabled shader keywords (converted to bitmask by Portal).
booldepthWrite
Whether this material writes to the depth buffer.
uint64_tcreatorSessionId
Session that created this material (for ownership/cleanup).
boolcastsShadows
Whether this material casts shadows.
std::stringappId
Creating application identifier.
struct EntropyCanvas::MaterialData;

Shared material data - portable across SDK, Server, Portal.

This struct contains all material properties in a serializable format. Portal’s Material class contains this and adds GPU-specific members.

Properties map is ordered (std::map) for deterministic serialization and USD output consistency.

inline void setVec4(
const std::string & propName,
const glm::vec4 & value
)

Set a vec4 property (also used for colors).

inline void setVec3(
const std::string & propName,
const glm::vec3 & value
)

Set a vec3 property.

inline void setVec2(
const std::string & propName,
const glm::vec2 & value
)

Set a vec2 property.

inline void setTextureRef(
const std::string & name,
const AssetId & textureAssetId
)

Set a texture reference by name.

Parameters:

  • name Texture name (must match shader declaration)
  • textureAssetId AssetId of the uploaded texture

Generic texture reference API - no predefined slots. The name should match the texture declaration in the shader.

inline void setMat4(
const std::string & propName,
const glm::mat4 & value
)

Set a mat4 property.

inline void setMat3(
const std::string & propName,
const glm::mat3 & value
)

Set a mat3 property.

inline void setInt(
const std::string & propName,
int32_t value
)

Set an int property.

inline void setFloat(
const std::string & propName,
float value
)

Set a float property.

inline bool isValid() const

Check if this is valid (has a shader assigned).

inline bool isTransparent() const

Check if this material uses transparency.

inline bool isKeywordEnabled(
const std::string & keyword
) const

Check if a keyword is enabled.

inline std::optional< AssetId > getTextureRef(
const std::string & name
) const

Get a texture reference by name.

Parameters:

  • name Texture name to look up

Return: AssetId if texture reference exists, nullopt otherwise

inline void enableKeyword(
const std::string & keyword
)

Enable a shader keyword.

inline void disableKeyword(
const std::string & keyword
)

Disable a shader keyword.

static inline MaterialData createUnlit(
const std::string & materialName
)

Create an Unlit material with default values.

Parameters:

  • materialName Human-readable name for the material

Return: MaterialData configured for unlit rendering

static inline MaterialData createPBR(
const std::string & materialName
)

Create a PBR material with default values.

Parameters:

  • materialName Human-readable name for the material

Return: MaterialData configured for PBR rendering

inline std::vector< std::pair< std::string, AssetId > > allTextureRefs() const

Get all texture references.

Return: Vector of (name, AssetId) pairs for all texture references

Returns all properties that are AssetId references.

uint64_t version = 0;

Monotonic version number for change tracking.

AssetId shaderAssetId;

Shader asset ID (content hash of shader source) Use BuiltinShaders constants for built-in shaders.

int32_t renderQueue = 2000;

Render queue priority (default: 2000 = Geometry) Background=1000, Geometry=2000, AlphaTest=2450, Transparent=3000, Overlay=4000, UI=5000.

bool receivesShadows = true;

Whether this material receives shadows.

std::map< std::string, MaterialPropertyValue > properties;

Material properties (ordered for deterministic serialization).

std::string name;

Human-readable material name.

uint64_t modifiedAt = 0;

Timestamp of last modification (microseconds since Unix epoch).

std::vector< std::string > enabledKeywords;

Enabled shader keywords (converted to bitmask by Portal).

bool depthWrite = true;

Whether this material writes to the depth buffer.

uint64_t creatorSessionId = 0;

Session that created this material (for ownership/cleanup).

bool castsShadows = true;

Whether this material casts shadows.

std::string appId;

Creating application identifier.


Updated on 2026-01-26 at 17:14:35 -0500