feat: add configurable rendering modes - #45
Conversation
- Add RED contracts for rendering mode state, editor workflow, and focused BIRP observations. - Validate expected RED failures and preserve the existing shader manifest contract.
- Add shared Opaque, Cutout, and Transparent shader state with an atomic material normalizer. - Validate focused material, rendering, canonical baseline, and compiler contracts.
- Add shared rendering mode and Cutoff drawers to the Shader-Core material Inspector. - Validate multi-target Undo, read-only refresh, source attributes, and the Inspector matrix.
- Cover rendering mode ABI and generated source in release consumer validation. - Publish the 0.2.0 rendering mode contract and stabilize Daily scene fixtures.
- Align the release probe manifest with Shader-Core conventional phase discovery. - Restore generated source coverage for the postpixel alpha contract.
- Match the generated alpha probe without depending on HLSL whitespace. - Restore the release fixture manifest after the failed metadata experiment.
- Align package metadata and public documentation with the 0.2.0-beta.1 prerelease. - Preserve package dependencies and release fixtures while validating metadata and document consistency. Co-authored-by: Copilot <copilot@github.com>
Up to standards ✅🟢 Issues
|
| Category | Results |
|---|---|
| CodeStyle | 86 minor |
| Complexity | 1 minor |
🟢 Metrics 361 complexity · 22 duplication
Metric Results Complexity 361 Duplication 22
AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Pull request overview
Adds a public, configurable rendering-mode ABI (_RenderingMode) across all PureBase shaders, with centralized Editor-side normalization and expanded test/contract coverage to ensure stable shader/pass/material behavior across Opaque, Cutout (default), and Transparent.
Changes:
- Introduces
_RenderingMode(Opaque/Cutout/Transparent) and mode-driven render-state plumbing (blend, ZWrite, keywords, pass enablement) across all product shaders via shared HLSL. - Adds Editor tooling: a Shader-Core Inspector popup + a deterministic normalizer (
PureBaseMaterialRenderingMode) and a menu action to resync selected materials. - Extends Daily + Release validation contracts and updates English/Japanese documentation; bumps package identity to
0.2.0-beta.1.
Reviewed changes
Copilot reviewed 42 out of 48 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Tests/Release/Run-PureBaseReleaseValidation.Tests.ps1 | Updates release-validation expectations/matrix ordering to include the rendering-mode contract row. |
| Tests/Release/Run-PureBaseReleaseValidation.ps1 | Extends release harness contracts (source fragments, property ABI, matrix rows) for rendering mode coverage. |
| Tests/Release/Modules/RenderingMode/PostPixelAlpha/phase_postpixel.hlsl.meta | Adds Unity meta for the release-only postpixel alpha probe include. |
| Tests/Release/Modules/RenderingMode/PostPixelAlpha/phase_postpixel.hlsl | Adds a deterministic postpixel alpha probe snippet for Transparent-mode contract checks. |
| Tests/Release/Modules/RenderingMode/PostPixelAlpha/jp.penguin.purebase.release.renderingmode.postpixel-alpha.scmodule.meta | Adds Unity meta for the release fixture module. |
| Tests/Release/Modules/RenderingMode/PostPixelAlpha/jp.penguin.purebase.release.renderingmode.postpixel-alpha.scmodule | Adds a release fixture module that injects the postpixel alpha probe. |
| Tests/Release/Modules/RenderingMode/PostPixelAlpha.meta | Adds folder meta for the release fixture module directory. |
| Tests/Release/Modules/RenderingMode.meta | Adds folder meta for the rendering-mode release module root. |
| Tests/Release/ConsumerProject/Assets/Editor/PureBaseConsumerRenderingModeTests.cs.meta | Adds Unity meta for the new consumer rendering-mode contract tests. |
| Tests/Release/ConsumerProject/Assets/Editor/PureBaseConsumerRenderingModeTests.cs | Adds cold-consumer ABI/state-table validation for rendering modes and the postpixel alpha probe. |
| Tests/Release/ConsumerProject/Assets/Editor/PureBase.Release.Consumer.Tests.asmdef | Updates consumer test assembly references to include PureBase.Editor. |
| Tests/README.md | Documents the rendering-mode coverage included in test contracts. |
| Tests/Fixtures/Materials/PureBaseLegacyCutout.mat.meta | Adds Unity meta for the legacy Cutout material fixture. |
| Tests/Fixtures/Materials/PureBaseLegacyCutout.mat | Adds a legacy material fixture used to ensure read-only Inspector binding does not mutate pre-mode materials. |
| Tests/Daily/Editor/PureBaseValidationSceneRegressionTests.cs | Adjusts lightmap-count observation semantics and adds a regression test for additive owner-scene lightmap behavior. |
| Tests/Daily/Editor/PureBaseRenderingModeRenderingTests.cs.meta | Adds Unity meta for the new rendering-mode rendering observation tests. |
| Tests/Daily/Editor/PureBaseRenderingModeRenderingTests.cs | Adds numeric BIRP rendering observations validating alpha/depth/shadow/meta behavior across modes. |
| Tests/Daily/Editor/PureBaseRenderingModeContractTests.cs.meta | Adds Unity meta for the new rendering-mode Editor-side contract tests. |
| Tests/Daily/Editor/PureBaseRenderingModeContractTests.cs | Adds extensive Editor-side ABI/state/atomicity/persistence/undo contracts for rendering modes and drawers. |
| Shaders/sc_common.hlsl | Updates shadow-caster clipping semantics to be mode-aware via shared coverage helpers. |
| Shaders/PureBaseUnlit.scshader | Adds hidden render-state properties, mode keywords, mode-aware blending/ZWrite, and mode-aware Meta clipping. |
| Shaders/PureBaseUnlit_properties.hlsl | Adds _RenderingMode property and updates Cutoff attribute to use the new drawer wrapper. |
| Shaders/PureBaseToon.scshader | Same as Unlit: adds mode-driven render-state, keywords, and Meta clipping behavior. |
| Shaders/PureBaseToon_properties.hlsl | Adds _RenderingMode and updates Cutoff attribute wiring. |
| Shaders/PureBasePBR.scshader | Same as Unlit/Toon: adds mode-driven render-state, keywords, and Meta clipping behavior. |
| Shaders/PureBasePBR_properties.hlsl | Adds _RenderingMode and updates Cutoff attribute wiring. |
| Shaders/PureBaseHybrid.scshader | Same as PBR: adds mode-driven render-state, keywords, and Meta clipping behavior. |
| Shaders/PureBaseHybrid_properties.hlsl | Adds _RenderingMode and updates Cutoff attribute wiring. |
| Shaders/lang/ja-JP.po.meta | Adds Unity meta for the Japanese localization file. |
| Shaders/lang/ja-JP.po | Adds Japanese localization strings for rendering mode UI/help text. |
| Shaders/Common/surface.hlsl | Centralizes mode-aware coverage clipping in shared surface initialization. |
| Shaders/Common/rendering_mode.hlsl.meta | Adds Unity meta for the shared rendering-mode include. |
| Shaders/Common/rendering_mode.hlsl | Introduces shared mode-aware clip and output-alpha helpers. |
| Shaders/Common/birp_host.hlsl | Integrates shared rendering-mode output-alpha behavior into the common fragment host ordering. |
| README.md | Updates package identity/version, documents rendering modes and Editor normalization entry points. |
| README.ja.md | Japanese README updates mirroring the rendering-mode and version documentation changes. |
| package.json | Bumps package version and updates release download URL to 0.2.0-beta.1. |
| Editor/PureBaseRenderingModeElement.cs.meta | Adds Unity meta for the new Shader-Core Inspector rendering-mode popup element. |
| Editor/PureBaseRenderingModeElement.cs | Adds the rendering-mode popup UI, localized labels, and atomic multi-target apply boundary. |
| Editor/PureBaseRenderingMode.cs.meta | Adds Unity meta for the new rendering-mode enum + normalizer implementation. |
| Editor/PureBaseRenderingMode.cs | Adds PureBaseRenderingMode enum and PureBaseMaterialRenderingMode normalizer + resync menu action. |
| Editor/PureBaseCutoffElement.cs.meta | Adds Unity meta for the Cutoff visibility wrapper element. |
| Editor/PureBaseCutoffElement.cs | Adds mode-aware visibility for Cutoff control (shown only for Cutout selections). |
| Editor/PureBase.Editor.asmdef | Adds Shader-Core assembly reference for the new Editor tooling. |
| Docs/technical-information.md | Updates technical docs for rendering modes, ABI, and updated release identity. |
| Docs/technical-information.ja.md | Japanese technical docs updates for rendering-mode ABI/state and release identity. |
| Docs/pure-base-shader-contract.md | Extends the stable shader contract to include rendering-mode ABI and mode-driven pass/state behavior. |
| CHANGELOG | Adds 0.2.0-beta.1 entry describing the rendering-mode feature and related contracts. |
Files not reviewed (6)
- Editor/PureBaseCutoffElement.cs.meta: Generated file
- Editor/PureBaseRenderingMode.cs.meta: Generated file
- Editor/PureBaseRenderingModeElement.cs.meta: Generated file
- Shaders/Common/rendering_mode.hlsl.meta: Generated file
- Shaders/lang/ja-JP.po.meta: Generated file
- Tests/Daily/Editor/PureBaseRenderingModeContractTests.cs.meta: Generated file
Suppressed comments (1)
Shaders/Common/rendering_mode.hlsl:37
- This block uses tab indentation (\t) for preprocessor directives and statements. To match the rest of the shader code, use spaces for indentation here.
#if defined(PUREBASE_RENDERING_TRANSPARENT)
color.a = coverage;
#else
color.a = 1;
#endif
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Pull Request Overview
The PR implements a configurable rendering mode system (Opaque, Cutout, and Transparent) with centralized editor synchronization. However, the PR is currently not up to project standards due to a high volume of new quality issues and significant code duplication in the test suites. A high-priority concern exists in PureBaseRenderingMode.cs where expensive JSON parsing and Regex are used to retrieve material tags instead of the native Unity API. Addressing these performance and architectural concerns is recommended before merging to maintain maintainability and editor responsiveness.
About this PR
- The PR introduces 101 new quality issues and substantial code duplication (46 clones), primarily within the test suites. While the functionality is correct, the high density of issues and clones suggests a need for refactoring and extraction of shared utility methods to meet quality standards.
Test suggestions
- Verify state normalization logic for all three rendering modes (Opaque, Cutout, Transparent).
- Verify that Transparent mode correctly disables ShadowCaster and Meta passes at the material level.
- Verify that opening or refreshing the Inspector on a legacy material does not trigger automatic migration or dirty the asset.
- Verify that rendering output alpha correctly reflects mode-specific logic (coverage-aware in Transparent, constant 1 in others).
- Verify atomicity and rollback of batch material normalization if a target fails validation.
- Verify that the Cutoff property drawer correctly toggles visibility based on the rendering mode selection.
TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 06e58939d7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- Add a deterministic non-PureBase rendering-mode fixture and remove optional-package test discovery. - Verify the Daily suite in Unity and isolated batchmode with protected state unchanged.
- Add a distinct owner LightingData fixture to preserve additive scene discrimination in generated CI projects. - Verify Pester and fresh Unity Daily regression results with protected state unchanged.
- Mark the owner LightingData fixture as a Git binary asset beside the canonical fixture rule. - Verify Git attributes, the direct line-ending checker, and focused Pester tests.
- Move the rendering-mode alpha probe into the approved standard PostPixel test fixture and remove the unapproved module. - Verify isolated Daily source-order coverage and preserve release-matrix Toon selection.
- Replace oversized editor-state constructors with equivalent internal object initialization. - Mark unused Shader-Core drawer callback parameters as discards and verify rollback contracts.
- Split Daily rendering-mode contract and readback test responsibilities into partial sources while preserving public test identities. - Verify all Daily tests and protected project/package state hashes remain unchanged.
- Extract private source-order and material-state assertion helpers from the consumer rendering-mode tests. - Preserve the release runner filter and validate the refactor with diagnostics and local static analysis.
- Declare the ShadowCaster preview-scene fixture as IDisposable with an explicit empty constructor. - Verify full Daily behavior and protected project/package state remain unchanged.
- Make the private Meta readback state constructor public while retaining its enclosing fixture visibility. - Verify Daily readback behavior and protected project/package state remain unchanged. Co-authored-by: Copilot <copilot@github.com>
- Preserve fallback-valued RenderType overrides through failed batch rollback and centralize supported shader detection. - Validate the focused rollback contract and full Daily assembly with zero Console errors.
Summary
_RenderingModeinteger ABI.0.2.0-beta.1in package metadata and public documentation.Validation
1fcd83c3a5552748ec31579bc9e60b0f7a5c9552.06e5893commit changes only the0.2.0-beta.1metadata and public documentation identity; its JSON, documentation consistency, encoding, diagnostics, and scoped diff checks passed locally.Notes