Material
Abstract base class for materials.
This class provides the foundation for all material types. It defines properties that control how objects appear when rendered, including color, transparency, blending, depth testing, and more.
Materials are optimized for GameCube's TEV (Texture Environment) unit and GX pipeline.
Methods
Material()
Default constructor - creates a material with default values
Material(const string& name)
Constructor with custom name
| name | Human-readable name for the material |
virtual void apply()
Applies this material's settings to the GX pipeline
virtual void update()
Updates material state (called each frame)
virtual Material* clone() const
Creates a copy of this material
virtual void copy(const Material& source)
Copies properties from another material
| source | Source material to copy from |
virtual void setupTEVStages()
Configures TEV stages for this material (GameCube requirement)
virtual void dispose()
Frees GPU-related resources
void updateGXState()
Updates GX pipeline state based on material properties
void setupBlending()
Configures GX blending based on material settings
void setupDepthTesting()
Configures GX depth testing based on material settings
void setupFaceCulling()
Configures GX face culling based on material settings
Properties
| isMaterial | bool | Read |
| name | string | Optional name for the material |
| id | u32 | Unique identifier |
| uuid | string | UUID string |
| color | Color | Base color (RGBA) |
| opacity | f32 | Opacity value (0.0 |
| transparent | bool | Whether material is transparent |
| alphaTest | f32 | Alpha test threshold (0.0 |
| blending | Blending | Blending mode |
| blendSrc | u8 | Source blend factor (GX blend factor) |
| blendDst | u8 | Destination blend factor (GX blend factor) |
| blendSrcAlpha | u8 | Source alpha blend factor |
| blendDstAlpha | u8 | Destination alpha blend factor |
| blendEquation | u8 | Blend equation (GX logic op) |
| blendEquationAlpha | u8 | Alpha blend equation |
| side | Side | Which side of faces to render |
| shadowSide | Side | Which side casts shadows |
| colorWrite | bool | Whether to write to color buffer |
| depthTest | bool | Whether to perform depth testing |
| depthWrite | bool | Whether to write to depth buffer |
| depthFunc | DepthFunc | Depth comparison function |
| polygonOffset | bool | threejs.org/docs/#Material.polygonOffset |
| polygonOffsetFactor | f32 | Polygon offset factor |
| polygonOffsetUnits | f32 | Polygon offset units |
| map | Texture * | Main texture (will be Texture* later) |
| alphaMap | Texture * | Alpha/dissolve texture for transparency |
| envMap | Texture * | Environment map |
| lightMap | Texture * | Light map |
| normalMap | Texture * | Normal map |
| specularMap | Texture * | Specular map |
| emissiveMap | Texture * | Emissive map |
| useTexture | bool | Whether to use texture mapping |
| useAlphaMap | bool | Whether to use alpha map for transparency |
| vertexColors | bool | Whether to use vertex colors |
| wireframe | bool | Whether to render as wireframe |
| wireframeLinewidth | f32 | Line width for wireframe (limited support on GameCube) |
| visible | bool | Whether material is visible |
| needsUpdate | bool | Whether material needs recompilation |
| version | u32 | Version counter for updates |
| tevStages | u8 | Number of TEV stages to use |
| useHardwareLighting | bool | Whether to use GX hardware lighting |