Skip to content

Material system design draft-1 #402

Open
@Pikachuxxxx

Description

@Pikachuxxxx

Overview

The system defines how materials are classified, configured, and rendered across different rendering passes. It handles various material domains (like Surface, Unlit, PostProcess, etc.) and their associated passes (e.g., Deferred, GBuffer, Depth, Wireframe). It also includes support for debugging modes and shader variant management.

Overview

1. Material Domain

A MaterialDomain defines the nature of a material and how it interacts with lighting and shading. It determines which rendering passes are required to render the material properly. The domain helps the system configure appropriate pipeline states and shaders.

Material Domain Types:

  • Domain_Surface: Materials that interact with lighting and have standard rendering passes (e.g., opaque or translucent).
  • Domain_Unlit: Materials that do not interact with lighting (e.g., UI, decals).
  • Domain_PostProcess: Materials used for full-screen effects (e.g., bloom, motion blur).
  • Domain_Volumetric: Materials for volumetric effects like fog and clouds.
  • Domain_Debug: Materials used for debugging (e.g., wireframe mode, visualizing normals, UVs).
  • Domain_Transparent: Materials that require special handling for transparency (e.g., glass, water).

2. Material Pass Type

A MaterialPassType defines the different stages or phases of rendering a material. These passes are tied to a MaterialDomain and describe how the material should be rendered in different contexts (forward rendering, depth prepass, etc.).

Common Pass Types:

  • PASS_GBUFFER: Used in deferred shading to write geometry to GBuffer.
  • PASS_FORWARD: Used in forward shading, typically for unlit materials or lighting passes.
  • PASS_DEPTH_PRE: A depth-only prepass, used for shadow map generation or other depth tests.
  • PASS_WIREFRAME: Used for debugging to render geometry as wireframes.
  • PASS_MOTION_VECTOR: For capturing motion vectors for post-processing.
  • PASS_CUSTOM: For custom, user-defined passes (e.g., post-processing effects).

3. Material Pipeline

The MaterialPipeline structure holds the configuration for how a material is rendered. This configuration includes the associated domain, the rendering passes required, and the pipeline settings for each pass (e.g., blend mode, depth func, culling mode) and shader variants for each pass.

Structure:

typedef struct MaterialPipeline {
    MaterialDomain    domain;    // Material's domain (Surface, Unlit, etc.)
    MaterialPassType  passes[MAX_PASSES]; // List of passes to be used.
    uint32_t          pass_count; // Number of passes.
    RZPipelineHandle pipeline; // State for the pipeline (depth func, blending).
    RZShaderHandle*           shaders[MAX_PASSES]; // Shader variants used for each pass.
} MaterialPipeline;

This is the abstract structure that represents the material, to create a material, we need info like MaterialDoamin, PassTypes will be deduced automatically bases on the material domain, and also we need to provide the shader module and RZPipelineDesc external to create the above struct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ArchitectureIssues related to API/ Engine design and architecture.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions