efactor(shader): migrate GLSL shaders to ShaderLab and clean up shader infrastructure #2961
Draft
zhuxudong wants to merge 11 commits intogalacean:dev/2.0from
Draft
efactor(shader): migrate GLSL shaders to ShaderLab and clean up shader infrastructure #2961zhuxudong wants to merge 11 commits intogalacean:dev/2.0from
zhuxudong wants to merge 11 commits intogalacean:dev/2.0from
Conversation
… and clean up old files All GLSL chunks and complete shaders have been migrated from packages/core/src/shaderlib/ to packages/shader/src/shaders/ with a unified directory structure. ShaderLib.ts is now an empty runtime registry populated by the shader package's registerIncludes(). Old VS/FS shader pairs in extra/ are replaced by ShaderLab .shader files. Post-process and AO GLSL includes updated to use new .glsl-suffixed keys. Blit.vs.glsl relocated from extra/ to shaderlib root.
… assertions Move camera_ProjectionParams declaration from Transform.glsl to Common.glsl where it is actually used by remapDepthBufferEyeDepth(). Update ShaderLab test to match new PBR.shader structure with inlined ShadowCaster/DepthOnly passes. Fix PrecompileABTest macro expansion test to find Forward Pass by name instead of hardcoded index.
…te PostProcess/AO Split shader package into two layers, create .shader files for PostProcess and AO, simplify FXAA3_11.glsl for ShaderLab compatibility, remove Shader.create() from core passes.
…ng with pre-migration source FXAA3_11.glsl was incorrectly stripped of conditional branches (FXAA_DISCARD, FXAA_FAST_PIXEL_OFFSET, FXAA_GATHER4_ALPHA) and type alias macros during the initial migration. Restore the full original 1028-line version to preserve all code paths. FinalAntiAliasing.glsl now includes the FXAA_GLSL_130/120 conditional defines and uses FxaaFloat type aliases, matching the pre-migration FinalAntiAliasing.fs.glsl source exactly.
…ly across all material shaders PBR/BlinnPhong/Unlit/PBRSpecular now reference Utility/ShadowMap and Utility/DepthOnly via UsePass instead of inlining or referencing PBR. Fix _resolveUsePass to handle shader names containing "/" by parsing from the end. Reorder registerShaders() so Utility shaders are created before material shaders.
- Remove `path` parameter from `Shader.create()` ShaderLab overload - Remove `_shaderRootPath` from ShaderPass - Remove `basePathForIncludeKey` from IShaderLab, ShaderLab, and Preprocessor - Remove relative path resolution in Preprocessor._replace() - Delete ShaderChunkLoader and simplify ShaderLoader - Clean up basePath references in tests and devtools example
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…alacean#2960 - Delete unused noise files (NoiseCellular, NoisePerlin, NoisePsrd, NoiseSimplex) - Add NoiseSimplexGrad.glsl with simplexGrad() returning vec3 gradient - Add algorithm attribution comments to NoiseCommon.glsl - Add Particle/Module/NoiseModule.glsl with curl noise sampling - Integrate noise velocity into ParticleFeedback.glsl - Update Shaders/index.ts registrations for new includes
- Remove _createShader wrapper that handled ShaderPool name conflicts - ShaderPool no longer registers VS/FS fallbacks, so no conflict exists - Fix Shaders/index.ts noise registrations reverted by case issue
…m core - Strip shader package to zero dependencies (pure data exports only) - Move include registration to ShaderPool.init() and shader registration to ShaderPool.registerShaders() in core - Split exports: ShaderLibrary/index.ts for fragmentList, Shaders/index.ts for complete shader sources - Auto-register built-in shaders in Engine._initialize() after ShaderLab is set, so external callers no longer need manual register calls - Remove registerIncludes/registerShaders from all tests, examples, e2e - Update docs to reflect automatic registration
… DepthOnly passes - ShadowMap.shader: bind RenderQueueType = material_ShadowCasterRenderQueue - DepthOnly.shader: bind RenderQueueType = material_DepthOnlyRenderQueue - Remove duplicate lowercase shaders/utility/ entries from git index
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
core/shaderlib(raw GLSL + rollup-plugin-glsl) toshaderpackage as ShaderLab.shaderfilesShaders/(ShaderLab entry points) andShaderLibrary/(GLSL include fragments)UsePassto reference themShaderChunkLoaderand shader path/chunk loading infrastructure (_shaderRootPath,basePathForIncludeKey)_resolveUsePassto support shader names containing "/" (e.g.Utility/ShadowMap)Motivation
Raw GLSL shaders scattered across
core/shaderlibrelied onrollup-plugin-glslfor bundling and lacked the renderstate / pass structure that ShaderLab provides. This migration:
shaderpackage with a clear Shaders + ShaderLibrary layoutregisterIncludes()for includeregistration and ShaderLab for shader creation
Key Changes
Shader Migration (
packages/shader/)BackgroundTexture, Particle, Blit, BlitScreen, ShadowMap, DepthOnly, PostProcess shaders (Bloom, SAO, FinalSRGB,
FinalAntiAliasing, UberShader)
.glslinclude fragments organized by category (Common, Lighting, PBR, Skin, Shadow, Fog,PostProcess, Particle)
UsePass Architecture
Utility/ShadowMapandUtility/DepthOnlyare canonical shared passesUsePass "Utility/ShadowMap/Default/ShadowCaster"registerShaders(): Utility first, then material shadersInfrastructure Cleanup
ShaderChunkLoader, remove_shaderRootPath,basePathForIncludeKeyfrom Preprocessor/ShaderLab/IShaderLabShader.create()only accepts ShaderLab source (vertex/fragment string overload removed from implementation, kept asoverload signature for now)
_resolveUsePassparses from end to handle multi-segment shader namesKnown Issue
Precompile.test.tssuite fails at load time becauseFinalAntiAliasing.shaderincludes FXAA3_11.glsl which usesconditional
#definetype aliases (FxaaFloat,FxaaBool) — the Preprocessor collects these as macros causing parsefailures. To be fixed on
fix/shaderlabbranch.Test Plan
npm run buildpassesnpx vitest run tests/src/shader-lab/— 62/62 tests pass_createFromPrecompiledround-trip works for PBR