Skip to content

feat: add minimal Toon SH lighting - #58

Merged
PenguinMaintainer merged 11 commits into
masterfrom
future/minimal-liltoon-lighting-port
Aug 12, 2026
Merged

feat: add minimal Toon SH lighting#58
PenguinMaintainer merged 11 commits into
masterfrom
future/minimal-liltoon-lighting-port

Conversation

@PenguinDOOM

Copy link
Copy Markdown
Collaborator

Summary

  • Add Toon-only stable dominant light direction and bright/dark SH environment bands, while retaining the existing binary direct response.
  • Preserve Shader-Core 0.1.9 ownership of BIRP light acquisition, lightmaps, shadows, phase dispatch, and additional-light enumeration; ForwardAdd remains environment-free.
  • Keep Hybrid/PBR direct and indirect ownership unchanged apart from the existing inline binary diffuse factor.
  • Document the 0.2.0-beta.2 compatibility/provenance boundary for lilToon 2.3.4 and OpenLit 1.0.2.
  • Export hosted Release runtime evidence: readbacks, cold-reset receipts, summaries, and relevant logs.

Validation

  • Hosted Release validation 31464812403: passed on 426f6bf60892489356ae09e28304783ecd5d66ef using Unity 2022.3.22f1 and Shader-Core 0.1.9.
  • Hosted Automation 31464671497: passed (Pester and actionlint).
  • Hosted CodeQL 31464674628: passed (C# and Actions).
  • Toon fixture: 8/8 passed; source/static/generated contracts: 8/8 passed; PBR/Hybrid Meta boundary: 1/1 passed.
  • Local automation suite: 350 passed, 0 failed, 1 skipped.

Known Limitations

  • Exact-head Daily D3D11 was not run: the workflow requires a pull_request or push master event.
  • Codacy Cloud was not run: the read-only repository endpoint returned Not Found; no passing Codacy result is claimed.

No tag, GitHub Release, or VPM repository mutation is included.

- Add intentional RED tests for fixed dominant-direction and two-band SH behavior.
- Verify lightmap, ForwardAdd, Hybrid, and ABI boundaries with focused Unity tests.
- Add Toon-only dominant direction and bright/dark spherical-harmonics lighting.
- Preserve Shader-Core, ForwardAdd, PBR, and Hybrid contracts with focused Unity tests.
- Document Toon lighting ownership, compatibility, and lilToon/OpenLit provenance.
- Align package identity and shipped documentation with 0.2.0-beta.2.
- Reopen valid-but-unloaded fixture scenes through the existing controlled scope.

- Verify the static-lightmap transaction in the Daily test suite.
- Upload runtime readbacks, cold reset receipts, summaries, and logs from validation runs.

- Preserve strict package and repository-state evidence exports.
- Require all approved runtime evidence paths in hosted review contracts.

- Keep direct artifact child paths free of parent-directory traversal.
@PenguinDOOM
PenguinDOOM requested review from a team and a lite review from Copilot August 11, 2026 17:03
@PenguinDOOM PenguinDOOM added the enhancement New feature or request label Aug 11, 2026
@PenguinDOOM PenguinDOOM added this to the 0.2.0 milestone Aug 11, 2026
@PenguinDOOM PenguinDOOM linked an issue Aug 11, 2026 that may be closed by this pull request
12 tasks
@codacy-production

codacy-production Bot commented Aug 11, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 2 minor

Results:
2 new issues

Category Results
CodeStyle 2 minor

View in Codacy

🟢 Metrics 78 complexity · 0 duplication

Metric Results
Complexity 78
Duplication 0

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a minimal, Toon-only spherical-harmonics (SH) lighting implementation to Pure-Base’s BIRP host, keeping Shader-Core responsible for light acquisition/lightmaps/shadows and preserving existing PBR/Hybrid ownership boundaries. The change is reinforced with deterministic Daily contracts, workflow artifact export contracts, and documentation/versioning updates for the 0.2.0-beta.2 boundary.

Changes:

  • Introduces Toon dominant-direction + bright/dark two-band SH evaluation via a new shared HLSL helper, wired into the Toon model and BIRP host while keeping ForwardAdd environment-free.
  • Adds/extends automated contracts (Daily + Release/Hosted workflow checks) to lock down Toon lighting behavior, lightmap determinism expectations, and evidence export paths.
  • Bumps package/documentation versioning to 0.2.0-beta.2 and records provenance/compatibility boundaries (lilToon/OpenLit concepts).

Reviewed changes

Copilot reviewed 18 out of 20 changed files in this pull request and generated no comments.

Show a summary per file
File Description
Shaders/Common/toon_lighting.hlsl New minimal Toon lighting helper (binary direct factor, dominant direction, two-band SH).
Shaders/Common/toon_lighting.hlsl.meta Unity importer metadata for the new shader include.
Shaders/Models/toon.hlsl Routes Toon direct + ambient to the helper and defines aggregate-direction selection hook.
Shaders/Models/pbr.hlsl Defines PBR aggregate-direction selection hook to preserve existing PBR/Hybrid direction behavior.
Shaders/Common/birp_host.hlsl Adds aggregate-direction selection hook + ensures ForwardAdd remains environment-free.
Tests/Daily/Editor/PureBaseToonLightingContractTests.cs New deterministic runtime/oracle contracts for Toon SH bands/direction and Hybrid/PBR boundaries.
Tests/Daily/Editor/PureBaseToonLightingContractTests.cs.meta Unity importer metadata for the new Daily test.
Tests/Daily/Editor/PureBaseValidationSceneRegressionTests.cs Adds regression coverage asserting a committed Toon static lightmap produces a finite nonzero delta via transient clone readback.
Tests/Daily/Editor/PureBaseRenderingModeRenderingTests.SourceContracts.cs Adds source-order/ownership contracts ensuring Toon-only inclusion and host/environment/ForwardAdd boundaries.
Tests/Release/Run-PureBaseReleaseValidation.Tests.ps1 Adds contract asserting the Release workflow uploads evidence (including runner-side runtime artifacts).
.github/workflows/release-validation.yml Extends evidence artifact upload paths to include runtime readbacks, cold reset receipts, summaries, and logs.
.github/tests/HostedUnityReviewContracts.Tests.ps1 Updates Hosted review contracts to require the expanded evidence upload path list exactly.
Docs/technical-information.md Documents Toon lighting boundary/ownership and updates version to 0.2.0-beta.2.
Docs/technical-information.ja.md Japanese counterpart of the Toon boundary/ownership + version update.
Docs/pure-base-shader-contract.md Updates contracted Toon/Hybrid behavior description and adds compatibility/boundary classification.
README.md Updates package version reference and clarifies independence/provenance language.
README.ja.md Japanese counterpart of README version + independence/provenance clarification.
NOTICE Adds explicit third-party lighting concept provenance and inspected-source references (lilToon/OpenLit).
package.json Bumps package version and release URL to 0.2.0-beta.2.
CHANGELOG Adds 0.2.0-beta.2 entry summarizing Toon lighting + contract additions.
Files not reviewed (2)
  • Shaders/Common/toon_lighting.hlsl.meta: Generated file
  • Tests/Daily/Editor/PureBaseToonLightingContractTests.cs.meta: Generated file

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@codacy-production codacy-production Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

The PR introduces a minimal Toon lighting model for the Built-in Render Pipeline, but currently does not meet quality standards. A significant logic error was identified in birp_host.hlsl, where the environment light calculation may cause double-lighting when lightmaps are active.

Additionally, while the test coverage for the new lighting model is extensive, the validation suite introduces maintenance debt. Specifically, the test cleanup logic in ToonLightingCaptureScope is overly complex, and the lack of proper equality implementation for SH coefficients may lead to performance overhead during test execution. These issues should be resolved to ensure a stable and maintainable lighting implementation.

About this PR

  • The newly added test suite for Toon lighting contracts contains systemic maintainability issues, including high cyclomatic complexity in resource cleanup and suboptimal equality checks for large structs. Ensure that test code follows the same quality and performance standards as production code.

Test suggestions

  • Verify Toon dominant light direction calculation matches the expected C# oracle for both standard and degenerate (zero-length) vectors.
  • Verify Toon SH evaluation correctly selects between bright and dark bands based on the surface normal.
  • Confirm that ForwardAdd point lights ignore SH environment contribution and preserve destination alpha.
  • Ensure Hybrid materials retain PBR direct specular behavior and ignore injected Toon SH directions.
  • Verify that static lightmaps contribute finite, nonzero baked delta to Toon surfaces in the validation scene.

TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback

Comment thread Tests/Daily/Editor/PureBaseToonLightingContractTests.cs Outdated
Comment thread Tests/Daily/Editor/PureBaseToonLightingContractTests.cs
Comment thread Shaders/Common/birp_host.hlsl
- Split Toon runtime contract support and extract focused test assertion helpers.

- Document the non-comparison SH carrier rationale and retain Unity fixture validation.
- Replace the shared normal texture in the isolated Toon capture with a deterministic fixture-owned neutral texture.
- Validate the four historical readback failures and the 67-test Daily EditMode assembly.
@PenguinDOOM
PenguinDOOM enabled auto-merge August 11, 2026 21:15
@PenguinDOOM
PenguinDOOM disabled auto-merge August 11, 2026 21:15
@PenguinDOOM
PenguinDOOM enabled auto-merge (squash) August 11, 2026 21:15
- Build a completed nonpersistent mesh for each isolated Toon lighting draw instead of mutating shared vertex state.
- Validate the historical D3D11 contracts and the 67-test Daily EditMode assembly.
@PenguinDOOM
PenguinDOOM disabled auto-merge August 12, 2026 03:39
PenguinDOOM and others added 2 commits August 12, 2026 13:05
- Render Toon lighting contracts with isolated BIRP renderer and ForcePixel lights instead of synthetic direct-light globals.
- Validate focused Toon contracts and the full Daily EditMode assembly locally.
- Extract preview-scene resource initialization from the Toon lighting capture constructor.
- Verify focused Toon contracts and the complete Daily EditMode assembly locally.

Co-authored-by: Copilot <copilot@github.com>
@PenguinMaintainer
PenguinMaintainer enabled auto-merge (squash) August 12, 2026 05:46
@PenguinMaintainer
PenguinMaintainer merged commit b42cf44 into master Aug 12, 2026
16 of 17 checks passed
@PenguinMaintainer
PenguinMaintainer deleted the future/minimal-liltoon-lighting-port branch August 12, 2026 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Toonに必要最小限のlilToonライティングを移植する

3 participants