Skip to content

Conversation

@eraflo
Copy link
Owner

@eraflo eraflo commented Dec 8, 2025

Description

Implements a complete material system aligned with SAA/CLAD architecture. This PR introduces universal material types in the core and corresponding WGSL shaders in the sandbox, establishing the foundation for the rendering pipeline.

Key Changes:

  • Material Types (khora-core/src/asset/materials/):

    • AlphaMode: Added Opaque, Mask, and Blend transparency modes.
    • StandardMaterial: Full PBR metallic-roughness workflow implementation.
    • EmissiveMaterial: Support for self-illuminating surfaces with HDR.
    • WireframeMaterial: Debug visualization with configurable line width.
    • UnlitMaterial: Enhanced version with alpha mode support.
    • Note: Texture fields are currently commented out pending the Asset System completion ([Feature] Implement Basic Lighting Models (Track shader complexity/perf) #48).
  • WGSL Shaders (examples/sandbox/assets/shaders/):

    • standard_pbr.wgsl: Cook-Torrance BRDF with Fresnel-Schlick.
    • emissive.wgsl: HDR emissive handling with tone mapping.
    • wireframe.wgsl: Edge detection using barycentric coordinates.
    • unlit.wgsl: Simplified shader for sandbox compatibility.
  • Architecture:

    • Defined materials as data contracts in khora-core.
    • Designed for adaptive rendering via RenderAgent.
  • Closes [Feature] Implement Material System #47

Type of change

Please check the boxes that apply or delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring / Performance improvements
  • Build system / CI improvements
  • Other (please describe):

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce, if applicable. Please also list any relevant details for your test configuration.

  • New unit tests added/updated for the changes.
  • All existing unit tests pass with these changes.

Test Configuration (if relevant for manual testing):

  • Unit Tests: Added 30+ new unit tests covering all material types (Standard, Emissive, Wireframe, Unlit) and Alpha modes.
  • Workspace: Verified that all workspace tests are passing.

Checklist:

Before submitting your pull request, please make sure you have completed the following:

  • I have read the CONTRIBUTING.md file (if it exists and is relevant for this type of contribution).
  • My code follows the style guidelines of this project. I have run cargo fmt --all -- --check locally and it passes.
  • My code has been linted with cargo clippy --workspace --all-targets --all-features -- -D warnings and there are no new clippy warnings.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas or for complex logic.
  • I have made corresponding changes to the documentation (if applicable).
  • My changes generate no new compiler warnings.
  • I have added tests that prove my fix is effective or that my feature works (if applicable).
  • New and existing unit tests pass locally with my changes (cargo test --workspace --all-targets --all-features).
  • Any dependent changes have been merged and published in downstream modules (if applicable).

Screenshots (if applicable)

N/A

Further comments or questions for the reviewer

Full shader integration and pipeline selection will be implemented in issue #48 (Basic Lighting Models). This PR focuses on the data structures and shader logic foundations.

Implements a complete material system aligned with SAA/CLAD architecture:
Material Types (khora-core/src/asset/materials/):
- AlphaMode enum: Opaque, Mask, Blend transparency modes
- StandardMaterial: Full PBR metallic-roughness workflow
- EmissiveMaterial: Self-illuminating surfaces with HDR support
- WireframeMaterial: Debug visualization with configurable line width
- Enhanced UnlitMaterial: Added alpha mode support
WGSL Shaders (examples/sandbox/assets/shaders/):
- standard_pbr.wgsl: Cook-Torrance BRDF with Fresnel-Schlick
- emissive.wgsl: HDR emissive with tone mapping
- wireframe.wgsl: Barycentric coordinate edge detection
- unlit.wgsl: Simplified for sandbox compatibility
Testing:
- 30+ unit tests covering all material types
- All workspace tests passing
Architecture:
- Materials as data contracts in khora-core (universal types)
- Texture fields commented until asset system complete (#48)
- Ready for adaptive rendering via RenderAgent
Note: Full shader integration and pipeline selection will be
implemented in issue #48 (Basic Lighting Models).
@eraflo eraflo linked an issue Dec 8, 2025 that may be closed by this pull request
@eraflo eraflo merged commit ba5b192 into main Dec 8, 2025
5 checks passed
@eraflo eraflo deleted the 47-feature-implement-material-system branch December 8, 2025 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Implement Material System

2 participants