@zephyr3d/scene 0.9.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animation/animationset.js +135 -133
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/cloth/gpu_cloth_system.js +9 -1
- package/dist/animation/cloth/gpu_cloth_system.js.map +1 -1
- package/dist/animation/fixed_geometry_cache_track.js +5 -1
- package/dist/animation/fixed_geometry_cache_track.js.map +1 -1
- package/dist/animation/geometry_cache_utils.js +20 -4
- package/dist/animation/geometry_cache_utils.js.map +1 -1
- package/dist/animation/ik/ik_angle_constraint.js +2 -6
- package/dist/animation/ik/ik_angle_constraint.js.map +1 -1
- package/dist/animation/ik/two_bone_ik_solver.js +2 -6
- package/dist/animation/ik/two_bone_ik_solver.js.map +1 -1
- package/dist/animation/joint_dynamics/collision.js +60 -12
- package/dist/animation/joint_dynamics/collision.js.map +1 -1
- package/dist/animation/joint_dynamics/constraints.js +20 -4
- package/dist/animation/joint_dynamics/constraints.js.map +1 -1
- package/dist/animation/joint_dynamics/controller.js +151 -103
- package/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/animation/joint_dynamics/solver.js +21 -11
- package/dist/animation/joint_dynamics/solver.js.map +1 -1
- package/dist/animation/joint_dynamics/types.js +15 -3
- package/dist/animation/joint_dynamics/types.js.map +1 -1
- package/dist/animation/pca_geometry_cache_track.js +5 -1
- package/dist/animation/pca_geometry_cache_track.js.map +1 -1
- package/dist/animation/skeleton.js +2 -2
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/skeleton_modifier.js +2 -6
- package/dist/animation/skeleton_modifier.js.map +1 -1
- package/dist/animation/spring/spring_system.js +87 -114
- package/dist/animation/spring/spring_system.js.map +1 -1
- package/dist/app/app.js.map +1 -1
- package/dist/app/engine.js +1 -1
- package/dist/app/engine.js.map +1 -1
- package/dist/app/screen.js +4 -4
- package/dist/app/screen.js.map +1 -1
- package/dist/app/scriptingsystem.js +24 -1
- package/dist/app/scriptingsystem.js.map +1 -1
- package/dist/app/scriptregistry.js +22 -1
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/assetmanager.js +2 -2
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/model.js +3 -3
- package/dist/asset/model.js.map +1 -1
- package/dist/camera/camera.js +185 -185
- package/dist/camera/camera.js.map +1 -1
- package/dist/camera/orbit.js.map +1 -1
- package/dist/index.d.ts +794 -261
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/material/material.js +290 -288
- package/dist/material/material.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/sprite.js +6 -6
- package/dist/material/sprite.js.map +1 -1
- package/dist/material/terrain-cm.js +2 -2
- package/dist/material/terrain-cm.js.map +1 -1
- package/dist/posteffect/taa.js +31 -39
- package/dist/posteffect/taa.js.map +1 -1
- package/dist/render/drawable.js +5 -1
- package/dist/render/drawable.js.map +1 -1
- package/dist/render/rendergraph/device_pool_allocator.js +29 -3
- package/dist/render/rendergraph/device_pool_allocator.js.map +1 -1
- package/dist/render/rendergraph/executor.js +283 -33
- package/dist/render/rendergraph/executor.js.map +1 -1
- package/dist/render/rendergraph/forward_plus_builder.js +338 -108
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/render/rendergraph/history_resource_manager.js +236 -156
- package/dist/render/rendergraph/history_resource_manager.js.map +1 -1
- package/dist/render/rendergraph/history_resources.js +10 -0
- package/dist/render/rendergraph/history_resources.js.map +1 -0
- package/dist/render/rendergraph/rendergraph.js +162 -35
- package/dist/render/rendergraph/rendergraph.js.map +1 -1
- package/dist/render/rendergraph/types.js +36 -16
- package/dist/render/rendergraph/types.js.map +1 -1
- package/dist/render/rendertarget.js +5 -1
- package/dist/render/rendertarget.js.map +1 -1
- package/dist/render/screenrendertarget.js +5 -1
- package/dist/render/screenrendertarget.js.map +1 -1
- package/dist/render/sky.js +4 -4
- package/dist/render/sky.js.map +1 -1
- package/dist/scene/basesprite.js +2 -2
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/graph_node.js +1 -1
- package/dist/scene/graph_node.js.map +1 -1
- package/dist/scene/mesh.js +4 -20
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/particlesys.js +1 -1
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/scene_node.js +2 -2
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/script_attachment.js +15 -3
- package/dist/scene/script_attachment.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +3 -3
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shapes/box.js +1 -1
- package/dist/shapes/box.js.map +1 -1
- package/dist/shapes/capsule.js +0 -3
- package/dist/shapes/capsule.js.map +1 -1
- package/dist/shapes/cylinder.js +0 -3
- package/dist/shapes/cylinder.js.map +1 -1
- package/dist/shapes/plane.js +0 -3
- package/dist/shapes/plane.js.map +1 -1
- package/dist/shapes/tetrahedron.js +3 -9
- package/dist/shapes/tetrahedron.js.map +1 -1
- package/dist/shapes/torus.js +4 -7
- package/dist/shapes/torus.js.map +1 -1
- package/dist/utility/blueprint/material/inputs.js +3 -3
- package/dist/utility/blueprint/material/inputs.js.map +1 -1
- package/dist/utility/blueprint/material/ir.js +493 -493
- package/dist/utility/blueprint/material/ir.js.map +1 -1
- package/dist/utility/serialization/manager.js +34 -3
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +45 -0
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +53 -0
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/common.js +10 -0
- package/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/utility/serialization/scene/light.js +30 -0
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +63 -0
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +11 -0
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/misc.js +2 -0
- package/dist/utility/serialization/scene/misc.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +19 -0
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/particle.js +22 -0
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/primitive.js +33 -0
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/scene.js +39 -0
- package/dist/utility/serialization/scene/scene.js.map +1 -1
- package/dist/utility/serialization/scene/script.js +2 -0
- package/dist/utility/serialization/scene/script.js.map +1 -1
- package/dist/utility/serialization/scene/sprite.js +6 -0
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +9 -0
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/water.js +21 -0
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/serialization/types.js +5 -1
- package/dist/utility/serialization/types.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"material.js","sources":["../../src/material/material.ts"],"sourcesContent":["import type { AbstractDevice, BindGroup, GPUProgram, RenderStateSet } from '@zephyr3d/device';\r\nimport { ProgramBuilder } from '@zephyr3d/device';\r\nimport type { Primitive } from '../render/primitive';\r\nimport type { DrawContext } from '../render/drawable';\r\nimport { QUEUE_OPAQUE } from '../values';\r\nimport { RenderBundleWrapper } from '../render/renderbundle_wrapper';\r\nimport { Disposable } from '@zephyr3d/base';\r\nimport type { Clonable, IDisposable, Nullable } from '@zephyr3d/base';\r\nimport { getEngine } from '../app/api';\r\n\r\ntype MaterialState = {\r\n program: GPUProgram;\r\n bindGroup: Nullable<BindGroup>;\r\n bindGroupTag: string;\r\n renderStateSet: RenderStateSet;\r\n materialTag: number;\r\n};\r\n\r\n/**\r\n * Base class for all materials.\r\n *\r\n * Responsibilities:\r\n * - Defines a multi-pass rendering interface (`numPasses`, `apply`, `bind`, `draw`, `drawPrimitive`).\r\n * - Builds and caches GPU shader programs per pass and per-render-context hash.\r\n * - Manages a per-material bind group (typically at index 2) for uniforms and resources.\r\n * - Updates render states per pass (`updateRenderStates`) and uploads uniforms (`_applyUniforms`).\r\n * - Tracks \"option\" changes that affect shader variant hashing and render bundles.\r\n *\r\n * Caching and hashing:\r\n * - `createHash(pass)` produces a stable hash representing shader variant options for a pass.\r\n * Override `_createHash()` in subclasses to encode feature toggles (defines, keywords, macros).\r\n * - The global hash used to key `MaterialState` also includes `ctx.materialFlags` and\r\n * `ctx.renderPassHash`, allowing context-sensitive variants (e.g., MSAA, MRT layout).\r\n * - GPU programs are additionally memoized in a global static `_programCache` across materials\r\n * by `constructor.name` + hash, to avoid recompilation of identical variants.\r\n *\r\n * Bind groups and uniforms:\r\n * - If a program declares a bind group layout at index 2 (i.e., `bindGroupLayouts.length > 2`),\r\n * `apply()` will allocate the group and keep it in the state. Subclasses should fill it in\r\n * `_applyUniforms()`.\r\n * - `applyUniforms()` only calls `_applyUniforms()` when `needUpdate` is true, based on\r\n * `_optionTag` changes (see `optionChanged()`).\r\n *\r\n * Lifecycle:\r\n * - Constructed materials register a persistent ID into a global registry for serialization.\r\n * - `apply(ctx)` prepares all passes: creates/gets state, programs, bind groups, render states,\r\n * and uploads uniforms as needed.\r\n * - `bind(device, pass)` binds the program, bind group (index 2), and render states.\r\n * - `draw(primitive, ctx, numInstances)` runs all passes, calling `bind()` and `drawPrimitive()`.\r\n * - `onDispose()` releases bind groups and registry entries.\r\n *\r\n * Extending:\r\n * - Override `_createProgram(pb, ctx, pass)` to build a shader.\r\n * - Override `_applyUniforms(bindGroup, ctx, pass)` to upload uniforms and resources.\r\n * - Override `updateRenderStates(pass, renderStates, ctx)` to set depth, blend, cull, etc.\r\n * - Override `_createHash()` to encode options that affect program compilation.\r\n * - Override `supportLighting`, `supportInstancing`, `isTransparentPass`, `getQueueType`, etc.\r\n *\r\n * Thread-safety:\r\n * - Intended for main-thread use in a renderer driving WebGPU/WebGL-like devices.\r\n *\r\n * @public\r\n */\r\nexport class Material extends Disposable implements Clonable<Material>, IDisposable {\r\n /**\r\n * Monotonic instance ID counter.\r\n * @internal\r\n */\r\n private static _nextId = 0;\r\n /**\r\n * Global program cache keyed by global hash\r\n */\r\n private static _programCache: { [hash: string]: GPUProgram } = {};\r\n /**\r\n * Per-material state cache keyed by global hash (material + context + pass).\r\n * @internal\r\n */\r\n private _states: { [hash: string]: MaterialState };\r\n /**\r\n * Number of rendering passes.\r\n * Subclasses can increase this to implement multi-pass rendering.\r\n * @internal\r\n */\r\n protected _numPasses: number;\r\n /**\r\n * Per-pass hash cached results. Length scales with `numPasses`.\r\n * @internal\r\n */\r\n protected _hash: Nullable<string>[];\r\n /**\r\n * Incremented each time options change (via `optionChanged`), used to decide whether\r\n * uniforms need update on next `apply()`.\r\n * @internal\r\n */\r\n private _optionTag: number;\r\n /**\r\n * Unique runtime instance ID.\r\n * @internal\r\n */\r\n protected readonly _id: number;\r\n /**\r\n * Latest computed global hash per pass, set during `apply()`, read in `bind()`.\r\n * @internal\r\n */\r\n private _currentHash: string[];\r\n /**\r\n * Incremented when material states affecting render bundles change (e.g., bind group id changes\r\n * or `optionChanged(true)`), used to trigger re-recording of render bundles.\r\n * @internal\r\n */\r\n private _changeTag: number;\r\n /**\r\n * Unique program id counter for naming compiled programs.\r\n * @internal\r\n */\r\n private _nextProgramId = 0;\r\n /**\r\n * Create a new material instance.\r\n *\r\n * - Initializes one pass by default.\r\n * - Prepares per-pass hash storage and change tracking.\r\n * - Registers a persistent ID in the global registry.\r\n */\r\n constructor() {\r\n super();\r\n this._id = ++Material._nextId;\r\n this._nextProgramId = 0;\r\n this._states = {};\r\n this._numPasses = 1;\r\n this._hash = [null];\r\n this._optionTag = 0;\r\n this._changeTag = 0;\r\n this._currentHash = [];\r\n }\r\n /**\r\n * Create a shallow clone of this material.\r\n *\r\n * Note: The base implementation returns a base `Material`. Subclasses should\r\n * override to return their own type and copy custom fields.\r\n */\r\n clone() {\r\n const other = new Material();\r\n other.copyFrom(this);\r\n return other;\r\n }\r\n /**\r\n * Copy basic properties from another material.\r\n *\r\n * Disposes existing bind groups/states, copies `numPasses`. Subclasses should\r\n * extend this to copy their own fields and call `optionChanged(true)` if\r\n * shader-affecting options differ.\r\n *\r\n * @param other - Source material.\r\n */\r\n copyFrom(other: this) {\r\n this.clearCache();\r\n this._numPasses = other._numPasses;\r\n getEngine().resourceManager.setAssetId(this, getEngine().resourceManager.getAssetId(other.coreMaterial));\r\n }\r\n /**\r\n * Incremented when the material’s GPU-relevant state changes and render bundles\r\n * may need to be rebuilt.\r\n */\r\n get changeTag() {\r\n return this._changeTag;\r\n }\r\n /**\r\n * Runtime-unique numeric identifier for the material instance.\r\n */\r\n get instanceId() {\r\n return this._id;\r\n }\r\n /**\r\n * Number of rendering passes this material uses.\r\n *\r\n * Increasing this will expand the per-pass hash cache; make sure to implement\r\n * `createHash(pass)`, `_createProgram(pb, ctx, pass)`, and `updateRenderStates(pass, ...)`\r\n * accordingly for each pass.\r\n */\r\n get numPasses() {\r\n return this._numPasses;\r\n }\r\n set numPasses(val) {\r\n while (this._hash.length < val) {\r\n this._hash.push(null);\r\n }\r\n this._numPasses = val;\r\n }\r\n /**\r\n * Get or compute the per-pass shader hash used for program caching.\r\n *\r\n * Calls `createHash(pass)` lazily and caches the result.\r\n * @internal\r\n */\r\n protected getHash(pass: number) {\r\n if (this._hash[pass] === null) {\r\n this._hash[pass] = this.createHash(pass);\r\n }\r\n return this._hash[pass];\r\n }\r\n /**\r\n * Return the queue type to which this material belongs.\r\n *\r\n * Override this in transparent or special materials (e.g., post-process).\r\n */\r\n getQueueType(): number {\r\n return QUEUE_OPAQUE;\r\n }\r\n /**\r\n * Whether the given pass is transparent.\r\n *\r\n * Used to place draw calls into appropriate render queues and set blending states.\r\n */\r\n isTransparentPass(_pass: number): boolean {\r\n return false;\r\n }\r\n /**\r\n * Whether this material's shading is affected by scene lights.\r\n *\r\n * Override and return `false` for unlit materials.\r\n */\r\n supportLighting(): boolean {\r\n return true;\r\n }\r\n /**\r\n * Whether this material supports hardware instancing.\r\n *\r\n * Override and return `false` if per-instance data is not supported in the shader.\r\n */\r\n supportInstancing(): boolean {\r\n return true;\r\n }\r\n /** Returns true if this is a instance of material */\r\n isBatchable(): boolean {\r\n return false;\r\n }\r\n\r\n /**\r\n * Whether this material requires the scene color texture (e.g., for refraction).\r\n */\r\n needSceneColor(): boolean {\r\n return false;\r\n }\r\n /**\r\n * Whether this material requires the linear scene depth texture (e.g., for depth-aware effects).\r\n */\r\n needSceneDepth(): boolean {\r\n return false;\r\n }\r\n /**\r\n * Create a material instance (instance-uniform-driven variant).\r\n *\r\n * Base returns `null`. Subclasses that support instancing can return a lightweight instance.\r\n */\r\n createInstance(): this {\r\n throw new Error('Abstract function call');\r\n }\r\n /**\r\n * Returns the core material that owns GPU state.\r\n *\r\n * Instances may delegate to a shared core to reuse compiled programs and caches.\r\n * @internal\r\n */\r\n get coreMaterial(): this {\r\n return this;\r\n }\r\n /**\r\n * Prepare the material for drawing across all passes for the given draw context.\r\n *\r\n * Steps per pass:\r\n * - Compute global hash (material variant + context).\r\n * - Retrieve or build the GPU program, cache in `_programCache`.\r\n * - Create per-material bind group (index 2) if the program exposes it.\r\n * - Update uniforms if `_optionTag` indicates changes since last apply.\r\n * - Update and cache render states for the pass.\r\n * - Detect bind group GPU ID changes to bump `changeTag` and notify `RenderBundleWrapper`.\r\n *\r\n * @param ctx - Draw context (device, flags, pass hash, instance data, etc.).\r\n * @returns `true` if successful; `false` if any pass lacks a valid program.\r\n */\r\n apply(ctx: DrawContext) {\r\n for (let pass = 0; pass < this._numPasses; pass++) {\r\n const hash = this.calcGlobalHash(ctx, pass);\r\n let state = this._states[hash];\r\n if (!state) {\r\n let program = Material._programCache[hash];\r\n if (!program) {\r\n program = this.createProgram(ctx, pass) ?? null;\r\n program.name = `@${this.constructor.name}_program_${this._nextProgramId++}`;\r\n Material._programCache[hash] = program;\r\n }\r\n const bindGroup =\r\n program.bindGroupLayouts.length > 2\r\n ? ctx.device.createBindGroup(program.bindGroupLayouts[2])\r\n : null;\r\n state = {\r\n program,\r\n bindGroup,\r\n bindGroupTag: bindGroup?.getGPUId() ?? '',\r\n renderStateSet: ctx.device.createRenderStateSet(),\r\n materialTag: -1\r\n };\r\n this._states[hash] = state;\r\n }\r\n if (!state.program) {\r\n return false;\r\n }\r\n if (state.bindGroup) {\r\n this.applyUniforms(state.bindGroup, ctx, state.materialTag !== this._optionTag, pass);\r\n }\r\n state.materialTag = this._optionTag;\r\n this.updateRenderStates(pass, state.renderStateSet, ctx);\r\n this._currentHash[pass] = hash;\r\n if (state.bindGroup) {\r\n const id = state.bindGroup.getGPUId();\r\n if (id !== state.bindGroupTag) {\r\n state.bindGroupTag = id;\r\n this._changeTag++;\r\n RenderBundleWrapper.materialChanged(this.coreMaterial);\r\n }\r\n }\r\n }\r\n return true;\r\n }\r\n /**\r\n * Bind the program, bind group, and render states for the specified pass.\r\n *\r\n * Must be called after `apply(ctx)` for the same pass.\r\n *\r\n * @param device - Rendering device.\r\n * @param pass - Pass index to bind.\r\n * @returns `true` on success; `false` if state or program missing.\r\n * @internal\r\n */\r\n bind(device: AbstractDevice, pass: number) {\r\n const hash = this._currentHash[pass];\r\n const state = this._states[hash];\r\n if (!state) {\r\n console.error('Material.bind() failed: state not found');\r\n return false;\r\n }\r\n if (!state.program) {\r\n return false;\r\n }\r\n device.setProgram(state.program);\r\n if (state.bindGroup) {\r\n device.setBindGroup(2, state.bindGroup);\r\n }\r\n device.setRenderStates(state.renderStateSet);\r\n return true;\r\n }\r\n /**\r\n * Compute the global hash for the given pass and draw context.\r\n *\r\n * Includes:\r\n * - Per-pass material hash from `getHash(pass)`.\r\n * - `ctx.materialFlags` for context-dependent toggles.\r\n * - `ctx.renderPassHash` for framebuffer/attachment layout variants.\r\n * @internal\r\n */\r\n private calcGlobalHash(ctx: DrawContext, pass: number) {\r\n return `${this.getHash(pass)}:${ctx.materialFlags}:${ctx.renderPassHash}`;\r\n }\r\n /**\r\n * Draw a primitive for all passes using this material.\r\n *\r\n * Calls `bind()` then `drawPrimitive()` per pass. If `numInstances` is zero,\r\n * and `ctx.instanceData` exists, uses `ctx.instanceData.numInstances`.\r\n *\r\n * @param primitive - Geometry to draw.\r\n * @param ctx - Draw context.\r\n * @param numInstances - Instance count; 0 means auto-detect from context.\r\n * @internal\r\n */\r\n draw(primitive: Primitive, ctx: DrawContext, numInstances = 0) {\r\n for (let pass = 0; pass < this._numPasses; pass++) {\r\n this.bind(ctx.device, pass);\r\n this.drawPrimitive(pass, primitive, ctx, numInstances);\r\n }\r\n }\r\n /**\r\n * Conditionally update uniforms/resources into the material bind group.\r\n *\r\n * Delegates to `_applyUniforms()` when `needUpdate` is true (based on `_optionTag` check).\r\n *\r\n * @param bindGroup - Material bind group at index 2 (may be `null` if program has no layout).\r\n * @param ctx - Draw context.\r\n * @param needUpdate - Whether uniforms need to be refreshed.\r\n * @param pass - Pass index.\r\n */\r\n applyUniforms(bindGroup: BindGroup, ctx: DrawContext, needUpdate: boolean, pass: number) {\r\n if (needUpdate) {\r\n this._applyUniforms(bindGroup, ctx, pass);\r\n }\r\n }\r\n /**\r\n * Notify the material that some option changed.\r\n *\r\n * - Always increments `_optionTag`. This will trigger uniforms update on next `apply()`.\r\n * - If `changeHash` is true, clears per-pass hashes so programs/states will be rebuilt,\r\n * increments `_changeTag`, and notifies `RenderBundleWrapper` to regenerate recorded bundles.\r\n *\r\n * @param changeHash - Set true if the change affects shader compilation or render states.\r\n * @internal\r\n */\r\n optionChanged(changeHash: boolean) {\r\n this._optionTag++;\r\n if (changeHash) {\r\n for (let i = 0; i < this._numPasses; i++) {\r\n this._hash[i] = null;\r\n }\r\n this._changeTag++;\r\n RenderBundleWrapper.materialChanged(this.coreMaterial);\r\n }\r\n }\r\n clearCache() {\r\n for (const k in this._states) {\r\n this._states[k]?.bindGroup?.dispose();\r\n }\r\n this._states = {};\r\n }\r\n /**\r\n * Convert a pass index to a hash seed string.\r\n *\r\n * Subclasses may override to encode per-pass role (e.g., \"depth\", \"forward\", \"shadow\").\r\n *\r\n * @param pass - Pass number.\r\n * @returns String used when building full hash.\r\n */\r\n passToHash(pass: number) {\r\n return String(pass);\r\n }\r\n /**\r\n * Build the material hash for a pass (excluding context-dependent parts).\r\n *\r\n * Default formula: `${constructor.name}|${pass}|${_createHash()}`\r\n *\r\n * @param pass - Pass number.\r\n * @returns Hash string used in program caching.\r\n * @internal\r\n */\r\n createHash(pass: number) {\r\n return `${this.constructor.name}|${pass}|${this._createHash()}`;\r\n }\r\n /**\r\n * Issue the actual draw call for a pass.\r\n *\r\n * Override for custom per-pass draw behavior if necessary. The default implementation:\r\n * - Draws instanced if `numInstances > 0`.\r\n * - Else uses `ctx.instanceData.numInstances` if available.\r\n * - Else issues a non-instanced draw.\r\n *\r\n * @param pass - Pass number.\r\n * @param primitive - Primitive to draw.\r\n * @param ctx - Draw context.\r\n * @param numInstances - Explicit instance count (0 = auto).\r\n */\r\n drawPrimitive(pass: number, primitive: Primitive, ctx: DrawContext, numInstances: number) {\r\n if (numInstances > 0) {\r\n primitive.drawInstanced(numInstances);\r\n } else if (ctx.instanceData) {\r\n primitive.drawInstanced(ctx.instanceData.numInstances);\r\n } else {\r\n primitive.draw();\r\n }\r\n }\r\n /**\r\n * Dispose the material and release GPU-side resource references.\r\n *\r\n * - Unregisters from the global registry.\r\n * - Disposes the per-material bind groups kept in `_states`.\r\n */\r\n protected onDispose() {\r\n super.onDispose();\r\n this.clearCache();\r\n }\r\n /**\r\n * Build the GPU program for a pass.\r\n *\r\n * Default creates a `ProgramBuilder` and calls `_createProgram(pb, ctx, pass)`.\r\n * Subclasses should override `_createProgram` instead of this method unless\r\n * they need to replace builder instantiation.\r\n *\r\n * @param ctx - Draw context.\r\n * @param pass - Pass number.\r\n * @returns The compiled `GPUProgram`, or `null` on failure.\r\n * @internal\r\n */\r\n protected createProgram(ctx: DrawContext, pass: number) {\r\n const pb = new ProgramBuilder(ctx.device);\r\n return this._createProgram(pb, ctx, pass);\r\n }\r\n /**\r\n * Create and compile the shader program for this material/pass.\r\n *\r\n * Implement in subclasses:\r\n * - Define shader stages, entry points, macros/defines, and resource layouts.\r\n * - Return a compiled `GPUProgram`.\r\n *\r\n * @param pb - Program builder.\r\n * @param ctx - Draw context.\r\n * @param _pass - Pass number.\r\n * @returns The created program, or `null` on failure.\r\n */\r\n protected _createProgram(_pb: ProgramBuilder, _ctx: DrawContext, _pass: number): GPUProgram {\r\n throw new Error('Abstract function call');\r\n }\r\n /**\r\n * Upload uniforms and bind resources to the per-material bind group (index 2).\r\n *\r\n * Implement in subclasses to:\r\n * - Write uniform buffers/textures/samplers to the `bindGroup`.\r\n * - Respect the current `pass` and `ctx`.\r\n *\r\n * @param _bindGroup - The bind group to populate.\r\n * @param _ctx - Draw context.\r\n * @param _pass - Pass number.\r\n */\r\n protected _applyUniforms(_bindGroup: BindGroup, _ctx: DrawContext, _pass: number) {}\r\n /**\r\n * Update render states (depth/stencil, blending, rasterization) for the pass.\r\n *\r\n * Implement in subclasses based on transparency, double-sidedness, depth writes/tests,\r\n * color mask, stencil ops, etc., and any context flags in `ctx`.\r\n *\r\n * @param _pass - Current pass index.\r\n * @param _renderStates - Render state set to mutate.\r\n * @param _ctx - Draw context.\r\n */\r\n protected updateRenderStates(_pass: number, _renderStates: RenderStateSet, _ctx: DrawContext) {}\r\n /**\r\n * Compute the material-specific portion of the shader hash for the current options.\r\n *\r\n * Subclasses should override to include macro/define sets that influence program compilation.\r\n * Example return: `\"USE_NORMALMAP=1;ALPHA_MODE=BLEND;RECEIVE_SHADOWS=1\"`.\r\n *\r\n * @returns Hash fragment string (no context/pass info).\r\n */\r\n protected _createHash() {\r\n return '';\r\n }\r\n /**\r\n * Whether this is a lightweight instance of a core material.\r\n *\r\n * Instances typically share GPU programs with a core and only override instance uniforms.\r\n * @internal\r\n */\r\n get $isInstance(): boolean {\r\n return false;\r\n }\r\n /**\r\n * Instance-uniform buffer for material instances, if supported.\r\n *\r\n * Returned as a typed Float32 view over a backing ArrayBuffer.\r\n * @internal\r\n */\r\n get $instanceUniforms(): Float32Array<ArrayBuffer> {\r\n throw new Error('Abstract function call');\r\n }\r\n}\r\n"],"names":["Material","Disposable","_nextId","_programCache","_nextProgramId","_id","_states","_numPasses","_hash","_optionTag","_changeTag","_currentHash","clone","other","copyFrom","clearCache","getEngine","resourceManager","setAssetId","getAssetId","coreMaterial","changeTag","instanceId","numPasses","val","length","push","getHash","pass","createHash","getQueueType","QUEUE_OPAQUE","isTransparentPass","_pass","supportLighting","supportInstancing","isBatchable","needSceneColor","needSceneDepth","createInstance","Error","apply","ctx","hash","calcGlobalHash","state","program","createProgram","name","bindGroup","bindGroupLayouts","device","createBindGroup","bindGroupTag","getGPUId","renderStateSet","createRenderStateSet","materialTag","applyUniforms","updateRenderStates","id","RenderBundleWrapper","materialChanged","bind","console","error","setProgram","setBindGroup","setRenderStates","materialFlags","renderPassHash","draw","primitive","numInstances","drawPrimitive","needUpdate","_applyUniforms","optionChanged","changeHash","i","k","dispose","passToHash","String","_createHash","drawInstanced","instanceData","onDispose","pb","ProgramBuilder","_createProgram","_pb","_ctx","_bindGroup","_renderStates","$isInstance","$instanceUniforms"],"mappings":";;;;;;AAkBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA6CO,MAAMA,QAAiBC,SAAAA,UAAAA,CAAAA;AAC5B;;;MAIA,OAAeC,UAAU,CAAE;AAC3B;;MAGA,OAAeC,aAAgD,GAAA,EAAG;AAClE;;;AAGC,MACD,OAAmD;AACnD;;;;AAIC,MACD,UAA6B;AAC7B;;;AAGC,MACD,KAAoC;AACpC;;;;AAIC,MACD,UAA2B;AAC3B;;;AAGC,MACD,GAA+B;A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xC,QAAA,OAAO,IAAI,CAACuC,cAAc,CAACF,IAAI9C,GAAKd,EAAAA,IAAAA,CAAAA;AACtC;AACA;;;;;;;;;;;AAWC,MACD,cAAyB+D,CAAAA,GAAmB,EAAEC,IAAiB,EAAE3D,KAAa,EAAc;AAC1F,QAAA,MAAM,IAAIO,KAAM,CAAA,wBAAA,CAAA;AAClB;AACA;;;;;;;;;;MAWUoC,eAAeiB,UAAqB,EAAED,IAAiB,EAAE3D,KAAa,EAAE;AAClF;;;;;;;;;MAUU0B,mBAAmB1B,KAAa,EAAE6D,aAA6B,EAAEF,IAAiB,EAAE;AAC9F;;;;;;;AAOC,MACD,WAAwB,GAAA;QACtB,OAAO,EAAA;AACT;AACA;;;;;AAKC,MACD,IAAIG,WAAuB,GAAA;QACzB,OAAO,KAAA;AACT;AACA;;;;;AAKC,MACD,IAAIC,iBAA+C,GAAA;AACjD,QAAA,MAAM,IAAIxD,KAAM,CAAA,wBAAA,CAAA;AAClB;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"material.js","sources":["../../src/material/material.ts"],"sourcesContent":["import type { AbstractDevice, BindGroup, GPUProgram, RenderStateSet } from '@zephyr3d/device';\nimport { ProgramBuilder } from '@zephyr3d/device';\nimport type { Primitive } from '../render/primitive';\nimport type { DrawContext } from '../render/drawable';\nimport { QUEUE_OPAQUE } from '../values';\nimport { RenderBundleWrapper } from '../render/renderbundle_wrapper';\nimport { Disposable } from '@zephyr3d/base';\nimport type { Clonable, IDisposable, Nullable } from '@zephyr3d/base';\nimport { getEngine } from '../app/api';\n\ntype MaterialState = {\n program: GPUProgram;\n bindGroup: Nullable<BindGroup>;\n bindGroupTag: string;\n renderStateSet: RenderStateSet;\n materialTag: number;\n};\n\n/**\n * Base class for all materials.\n *\n * Responsibilities:\n * - Defines a multi-pass rendering interface (`numPasses`, `apply`, `bind`, `draw`, `drawPrimitive`).\n * - Builds and caches GPU shader programs per pass and per-render-context hash.\n * - Manages a per-material bind group (typically at index 2) for uniforms and resources.\n * - Updates render states per pass (`updateRenderStates`) and uploads uniforms (`_applyUniforms`).\n * - Tracks \"option\" changes that affect shader variant hashing and render bundles.\n *\n * Caching and hashing:\n * - `createHash(pass)` produces a stable hash representing shader variant options for a pass.\n * Override `_createHash()` in subclasses to encode feature toggles (defines, keywords, macros).\n * - The global hash used to key `MaterialState` also includes `ctx.materialFlags` and\n * `ctx.renderPassHash`, allowing context-sensitive variants (e.g., MSAA, MRT layout).\n * - GPU programs are additionally memoized in a global static `_programCache` across materials\n * by `constructor.name` + hash, to avoid recompilation of identical variants.\n *\n * Bind groups and uniforms:\n * - If a program declares a bind group layout at index 2 (i.e., `bindGroupLayouts.length > 2`),\n * `apply()` will allocate the group and keep it in the state. Subclasses should fill it in\n * `_applyUniforms()`.\n * - `applyUniforms()` only calls `_applyUniforms()` when `needUpdate` is true, based on\n * `_optionTag` changes (see `optionChanged()`).\n *\n * Lifecycle:\n * - Constructed materials register a persistent ID into a global registry for serialization.\n * - `apply(ctx)` prepares all passes: creates/gets state, programs, bind groups, render states,\n * and uploads uniforms as needed.\n * - `bind(device, pass)` binds the program, bind group (index 2), and render states.\n * - `draw(primitive, ctx, numInstances)` runs all passes, calling `bind()` and `drawPrimitive()`.\n * - `onDispose()` releases bind groups and registry entries.\n *\n * Extending:\n * - Override `_createProgram(pb, ctx, pass)` to build a shader.\n * - Override `_applyUniforms(bindGroup, ctx, pass)` to upload uniforms and resources.\n * - Override `updateRenderStates(pass, renderStates, ctx)` to set depth, blend, cull, etc.\n * - Override `_createHash()` to encode options that affect program compilation.\n * - Override `supportLighting`, `supportInstancing`, `isTransparentPass`, `getQueueType`, etc.\n *\n * Thread-safety:\n * - Intended for main-thread use in a renderer driving WebGPU/WebGL-like devices.\n *\n * @public\n */\nexport class Material extends Disposable implements Clonable<Material>, IDisposable {\n /**\n * Monotonic instance ID counter.\n * @internal\n */\n private static _nextId = 0;\n /**\n * Global program cache keyed by global hash\n */\n private static _programCache: { [hash: string]: GPUProgram } = {};\n /**\n * Per-material state cache keyed by global hash (material + context + pass).\n * @internal\n */\n private _states: { [hash: string]: MaterialState };\n /**\n * Number of rendering passes.\n * Subclasses can increase this to implement multi-pass rendering.\n * @internal\n */\n protected _numPasses: number;\n /**\n * Per-pass hash cached results. Length scales with `numPasses`.\n * @internal\n */\n protected _hash: Nullable<string>[];\n /**\n * Incremented each time options change (via `optionChanged`), used to decide whether\n * uniforms need update on next `apply()`.\n * @internal\n */\n private _optionTag: number;\n /**\n * Unique runtime instance ID.\n * @internal\n */\n protected readonly _id: number;\n /**\n * Latest computed global hash per pass, set during `apply()`, read in `bind()`.\n * @internal\n */\n private _currentHash: string[];\n /**\n * Incremented when material states affecting render bundles change (e.g., bind group id changes\n * or `optionChanged(true)`), used to trigger re-recording of render bundles.\n * @internal\n */\n private _changeTag: number;\n /**\n * Unique program id counter for naming compiled programs.\n * @internal\n */\n private _nextProgramId = 0;\n /**\n * Create a new material instance.\n *\n * - Initializes one pass by default.\n * - Prepares per-pass hash storage and change tracking.\n * - Registers a persistent ID in the global registry.\n */\n constructor() {\n super();\n this._id = ++Material._nextId;\n this._nextProgramId = 0;\n this._states = {};\n this._numPasses = 1;\n this._hash = [null];\n this._optionTag = 0;\n this._changeTag = 0;\n this._currentHash = [];\n }\n /**\n * Create a shallow clone of this material.\n *\n * Note: The base implementation returns a base `Material`. Subclasses should\n * override to return their own type and copy custom fields.\n */\n clone() {\n const other = new Material();\n other.copyFrom(this);\n return other;\n }\n /**\n * Copy basic properties from another material.\n *\n * Disposes existing bind groups/states, copies `numPasses`. Subclasses should\n * extend this to copy their own fields and call `optionChanged(true)` if\n * shader-affecting options differ.\n *\n * @param other - Source material.\n */\n copyFrom(other: this) {\n this.clearCache();\n this._numPasses = other._numPasses;\n getEngine().resourceManager.setAssetId(this, getEngine().resourceManager.getAssetId(other.coreMaterial));\n }\n /**\n * Incremented when the material’s GPU-relevant state changes and render bundles\n * may need to be rebuilt.\n */\n get changeTag() {\n return this._changeTag;\n }\n /**\n * Runtime-unique numeric identifier for the material instance.\n */\n get instanceId() {\n return this._id;\n }\n /**\n * Number of rendering passes this material uses.\n *\n * Increasing this will expand the per-pass hash cache; make sure to implement\n * `createHash(pass)`, `_createProgram(pb, ctx, pass)`, and `updateRenderStates(pass, ...)`\n * accordingly for each pass.\n */\n get numPasses() {\n return this._numPasses;\n }\n set numPasses(val) {\n while (this._hash.length < val) {\n this._hash.push(null);\n }\n this._numPasses = val;\n }\n /**\n * Get or compute the per-pass shader hash used for program caching.\n *\n * Calls `createHash(pass)` lazily and caches the result.\n * @internal\n */\n protected getHash(pass: number) {\n if (this._hash[pass] === null) {\n this._hash[pass] = this.createHash(pass);\n }\n return this._hash[pass];\n }\n /**\n * Return the queue type to which this material belongs.\n *\n * Override this in transparent or special materials (e.g., post-process).\n */\n getQueueType(): number {\n return QUEUE_OPAQUE;\n }\n /**\n * Whether the given pass is transparent.\n *\n * Used to place draw calls into appropriate render queues and set blending states.\n */\n isTransparentPass(_pass: number): boolean {\n return false;\n }\n /**\n * Whether this material's shading is affected by scene lights.\n *\n * Override and return `false` for unlit materials.\n */\n supportLighting(): boolean {\n return true;\n }\n /**\n * Whether this material supports hardware instancing.\n *\n * Override and return `false` if per-instance data is not supported in the shader.\n */\n supportInstancing(): boolean {\n return true;\n }\n /** Returns true if this is a instance of material */\n isBatchable(): boolean {\n return false;\n }\n\n /**\n * Whether this material requires the scene color texture (e.g., for refraction).\n */\n needSceneColor(): boolean {\n return false;\n }\n /**\n * Whether this material requires the linear scene depth texture (e.g., for depth-aware effects).\n */\n needSceneDepth(): boolean {\n return false;\n }\n /**\n * Create a material instance (instance-uniform-driven variant).\n *\n * Base returns `null`. Subclasses that support instancing can return a lightweight instance.\n */\n createInstance(): this {\n throw new Error('Abstract function call');\n }\n /**\n * Returns the core material that owns GPU state.\n *\n * Instances may delegate to a shared core to reuse compiled programs and caches.\n * @public\n */\n get coreMaterial(): this {\n return this;\n }\n /**\n * Prepare the material for drawing across all passes for the given draw context.\n *\n * Steps per pass:\n * - Compute global hash (material variant + context).\n * - Retrieve or build the GPU program, cache in `_programCache`.\n * - Create per-material bind group (index 2) if the program exposes it.\n * - Update uniforms if `_optionTag` indicates changes since last apply.\n * - Update and cache render states for the pass.\n * - Detect bind group GPU ID changes to bump `changeTag` and notify `RenderBundleWrapper`.\n *\n * @param ctx - Draw context (device, flags, pass hash, instance data, etc.).\n * @returns `true` if successful; `false` if any pass lacks a valid program.\n */\n apply(ctx: DrawContext) {\n for (let pass = 0; pass < this._numPasses; pass++) {\n const hash = this.calcGlobalHash(ctx, pass);\n let state = this._states[hash];\n if (!state) {\n let program = Material._programCache[hash];\n if (!program) {\n program = this.createProgram(ctx, pass) ?? null;\n program.name = `@${this.constructor.name}_program_${this._nextProgramId++}`;\n Material._programCache[hash] = program;\n }\n const bindGroup =\n program.bindGroupLayouts.length > 2\n ? ctx.device.createBindGroup(program.bindGroupLayouts[2])\n : null;\n state = {\n program,\n bindGroup,\n bindGroupTag: bindGroup?.getGPUId() ?? '',\n renderStateSet: ctx.device.createRenderStateSet(),\n materialTag: -1\n };\n this._states[hash] = state;\n }\n if (!state.program) {\n return false;\n }\n if (state.bindGroup) {\n this.applyUniforms(state.bindGroup, ctx, state.materialTag !== this._optionTag, pass);\n }\n state.materialTag = this._optionTag;\n this.updateRenderStates(pass, state.renderStateSet, ctx);\n this._currentHash[pass] = hash;\n if (state.bindGroup) {\n const id = state.bindGroup.getGPUId();\n if (id !== state.bindGroupTag) {\n state.bindGroupTag = id;\n this._changeTag++;\n RenderBundleWrapper.materialChanged(this.coreMaterial);\n }\n }\n }\n return true;\n }\n /**\n * Bind the program, bind group, and render states for the specified pass.\n *\n * Must be called after `apply(ctx)` for the same pass.\n *\n * @param device - Rendering device.\n * @param pass - Pass index to bind.\n * @returns `true` on success; `false` if state or program missing.\n * @internal\n */\n bind(device: AbstractDevice, pass: number) {\n const hash = this._currentHash[pass];\n const state = this._states[hash];\n if (!state) {\n console.error('Material.bind() failed: state not found');\n return false;\n }\n if (!state.program) {\n return false;\n }\n device.setProgram(state.program);\n if (state.bindGroup) {\n device.setBindGroup(2, state.bindGroup);\n }\n device.setRenderStates(state.renderStateSet);\n return true;\n }\n /**\n * Compute the global hash for the given pass and draw context.\n *\n * Includes:\n * - Per-pass material hash from `getHash(pass)`.\n * - `ctx.materialFlags` for context-dependent toggles.\n * - `ctx.renderPassHash` for framebuffer/attachment layout variants.\n * @internal\n */\n private calcGlobalHash(ctx: DrawContext, pass: number) {\n return `${this.getHash(pass)}:${ctx.materialFlags}:${ctx.renderPassHash}`;\n }\n /**\n * Draw a primitive for all passes using this material.\n *\n * Calls `bind()` then `drawPrimitive()` per pass. If `numInstances` is zero,\n * and `ctx.instanceData` exists, uses `ctx.instanceData.numInstances`.\n *\n * @param primitive - Geometry to draw.\n * @param ctx - Draw context.\n * @param numInstances - Instance count; 0 means auto-detect from context.\n * @internal\n */\n draw(primitive: Primitive, ctx: DrawContext, numInstances = 0) {\n for (let pass = 0; pass < this._numPasses; pass++) {\n this.bind(ctx.device, pass);\n this.drawPrimitive(pass, primitive, ctx, numInstances);\n }\n }\n /**\n * Conditionally update uniforms/resources into the material bind group.\n *\n * Delegates to `_applyUniforms()` when `needUpdate` is true (based on `_optionTag` check).\n *\n * @param bindGroup - Material bind group at index 2 (may be `null` if program has no layout).\n * @param ctx - Draw context.\n * @param needUpdate - Whether uniforms need to be refreshed.\n * @param pass - Pass index.\n */\n applyUniforms(bindGroup: BindGroup, ctx: DrawContext, needUpdate: boolean, pass: number) {\n if (needUpdate) {\n this._applyUniforms(bindGroup, ctx, pass);\n }\n }\n /**\n * Notify the material that some option changed.\n *\n * - Always increments `_optionTag`. This will trigger uniforms update on next `apply()`.\n * - If `changeHash` is true, clears per-pass hashes so programs/states will be rebuilt,\n * increments `_changeTag`, and notifies `RenderBundleWrapper` to regenerate recorded bundles.\n *\n * @param changeHash - Set true if the change affects shader compilation or render states.\n * @internal\n */\n optionChanged(changeHash: boolean) {\n this._optionTag++;\n if (changeHash) {\n for (let i = 0; i < this._numPasses; i++) {\n this._hash[i] = null;\n }\n this._changeTag++;\n RenderBundleWrapper.materialChanged(this.coreMaterial);\n }\n }\n clearCache() {\n for (const k in this._states) {\n this._states[k]?.bindGroup?.dispose();\n Material._programCache[k]?.dispose();\n delete Material._programCache[k];\n }\n this._states = {};\n }\n /**\n * Convert a pass index to a hash seed string.\n *\n * Subclasses may override to encode per-pass role (e.g., \"depth\", \"forward\", \"shadow\").\n *\n * @param pass - Pass number.\n * @returns String used when building full hash.\n */\n passToHash(pass: number) {\n return String(pass);\n }\n /**\n * Build the material hash for a pass (excluding context-dependent parts).\n *\n * Default formula: `${constructor.name}|${pass}|${_createHash()}`\n *\n * @param pass - Pass number.\n * @returns Hash string used in program caching.\n * @internal\n */\n createHash(pass: number) {\n return `${this.constructor.name}|${pass}|${this._createHash()}`;\n }\n /**\n * Issue the actual draw call for a pass.\n *\n * Override for custom per-pass draw behavior if necessary. The default implementation:\n * - Draws instanced if `numInstances > 0`.\n * - Else uses `ctx.instanceData.numInstances` if available.\n * - Else issues a non-instanced draw.\n *\n * @param pass - Pass number.\n * @param primitive - Primitive to draw.\n * @param ctx - Draw context.\n * @param numInstances - Explicit instance count (0 = auto).\n */\n drawPrimitive(pass: number, primitive: Primitive, ctx: DrawContext, numInstances: number) {\n if (numInstances > 0) {\n primitive.drawInstanced(numInstances);\n } else if (ctx.instanceData) {\n primitive.drawInstanced(ctx.instanceData.numInstances);\n } else {\n primitive.draw();\n }\n }\n /**\n * Dispose the material and release GPU-side resource references.\n *\n * - Unregisters from the global registry.\n * - Disposes the per-material bind groups kept in `_states`.\n */\n protected onDispose() {\n super.onDispose();\n this.clearCache();\n }\n /**\n * Build the GPU program for a pass.\n *\n * Default creates a `ProgramBuilder` and calls `_createProgram(pb, ctx, pass)`.\n * Subclasses should override `_createProgram` instead of this method unless\n * they need to replace builder instantiation.\n *\n * @param ctx - Draw context.\n * @param pass - Pass number.\n * @returns The compiled `GPUProgram`, or `null` on failure.\n * @internal\n */\n protected createProgram(ctx: DrawContext, pass: number) {\n const pb = new ProgramBuilder(ctx.device);\n return this._createProgram(pb, ctx, pass);\n }\n /**\n * Create and compile the shader program for this material/pass.\n *\n * Implement in subclasses:\n * - Define shader stages, entry points, macros/defines, and resource layouts.\n * - Return a compiled `GPUProgram`.\n *\n * @param pb - Program builder.\n * @param ctx - Draw context.\n * @param _pass - Pass number.\n * @returns The created program, or `null` on failure.\n */\n protected _createProgram(_pb: ProgramBuilder, _ctx: DrawContext, _pass: number): GPUProgram {\n throw new Error('Abstract function call');\n }\n /**\n * Upload uniforms and bind resources to the per-material bind group (index 2).\n *\n * Implement in subclasses to:\n * - Write uniform buffers/textures/samplers to the `bindGroup`.\n * - Respect the current `pass` and `ctx`.\n *\n * @param _bindGroup - The bind group to populate.\n * @param _ctx - Draw context.\n * @param _pass - Pass number.\n */\n protected _applyUniforms(_bindGroup: BindGroup, _ctx: DrawContext, _pass: number) {}\n /**\n * Update render states (depth/stencil, blending, rasterization) for the pass.\n *\n * Implement in subclasses based on transparency, double-sidedness, depth writes/tests,\n * color mask, stencil ops, etc., and any context flags in `ctx`.\n *\n * @param _pass - Current pass index.\n * @param _renderStates - Render state set to mutate.\n * @param _ctx - Draw context.\n */\n protected updateRenderStates(_pass: number, _renderStates: RenderStateSet, _ctx: DrawContext) {}\n /**\n * Compute the material-specific portion of the shader hash for the current options.\n *\n * Subclasses should override to include macro/define sets that influence program compilation.\n * Example return: `\"USE_NORMALMAP=1;ALPHA_MODE=BLEND;RECEIVE_SHADOWS=1\"`.\n *\n * @returns Hash fragment string (no context/pass info).\n */\n protected _createHash() {\n return '';\n }\n /**\n * Whether this is a lightweight instance of a core material.\n *\n * Instances typically share GPU programs with a core and only override instance uniforms.\n * @internal\n */\n get $isInstance(): boolean {\n return false;\n }\n /**\n * Instance-uniform buffer for material instances, if supported.\n *\n * Returned as a typed Float32 view over a backing ArrayBuffer.\n * @internal\n */\n get $instanceUniforms(): Float32Array<ArrayBuffer> {\n throw new Error('Abstract function call');\n }\n}\n"],"names":["Material","Disposable","_nextId","_programCache","_nextProgramId","_id","_states","_numPasses","_hash","_optionTag","_changeTag","_currentHash","clone","other","copyFrom","clearCache","getEngine","resourceManager","setAssetId","getAssetId","coreMaterial","changeTag","instanceId","numPasses","val","length","push","getHash","pass","createHash","getQueueType","QUEUE_OPAQUE","isTransparentPass","_pass","supportLighting","supportInstancing","isBatchable","needSceneColor","needSceneDepth","createInstance","Error","apply","ctx","hash","calcGlobalHash","state","program","createProgram","name","bindGroup","bindGroupLayouts","device","createBindGroup","bindGroupTag","getGPUId","renderStateSet","createRenderStateSet","materialTag","applyUniforms","updateRenderStates","id","RenderBundleWrapper","materialChanged","bind","console","error","setProgram","setBindGroup","setRenderStates","materialFlags","renderPassHash","draw","primitive","numInstances","drawPrimitive","needUpdate","_applyUniforms","optionChanged","changeHash","i","k","dispose","passToHash","String","_createHash","drawInstanced","instanceData","onDispose","pb","ProgramBuilder","_createProgram","_pb","_ctx","_bindGroup","_renderStates","$isInstance","$instanceUniforms"],"mappings":";;;;;;AAkBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA6CO,MAAMA,QAAiBC,SAAAA,UAAAA,CAAAA;AAC5B;;;MAIA,OAAeC,UAAU,CAAE;AAC3B;;MAGA,OAAeC,aAAgD,GAAA,EAAG;AAClE;;;AAGC,MACD,OAAmD;AACnD;;;;AAIC,MACD,UAA6B;AAC7B;;;AAGC,MACD,KAAoC;AACpC;;;;AAIC,MACD,UAA2B;AAC3B;;;AAGC,MACD,GAA+B;AAC/B;;;AAGC,MACD,YAA+B;AAC/B;;;;AAIC,MACD,UAA2B;AAC3B;;;MAIQC,iBAAiB,CAAE;AAC3B;;;;;;AAMC,MACD,WAAc,EAAA;QACZ,KAAK,EAAA;AACL,QAAA,IAAI,CAACC,GAAG,GAAG,EAAEL,SAASE,OAAO;QAC7B,IAAI,CAACE,cAAc,GAAG,CAAA;QACtB,IAAI,CAAC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CAAAA,GAAmB,EAAEC,IAAiB,EAAE3D,KAAa,EAAc;AAC1F,QAAA,MAAM,IAAIO,KAAM,CAAA,wBAAA,CAAA;AAClB;AACA;;;;;;;;;;MAWUoC,eAAeiB,UAAqB,EAAED,IAAiB,EAAE3D,KAAa,EAAE;AAClF;;;;;;;;;MAUU0B,mBAAmB1B,KAAa,EAAE6D,aAA6B,EAAEF,IAAiB,EAAE;AAC9F;;;;;;;AAOC,MACD,WAAwB,GAAA;QACtB,OAAO,EAAA;AACT;AACA;;;;;AAKC,MACD,IAAIG,WAAuB,GAAA;QACzB,OAAO,KAAA;AACT;AACA;;;;;AAKC,MACD,IAAIC,iBAA+C,GAAA;AACjD,QAAA,MAAM,IAAIxD,KAAM,CAAA,wBAAA,CAAA;AAClB;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pbrmetallicroughness.js","sources":["../../../../src/material/mixins/lightmodel/pbrmetallicroughness.ts"],"sourcesContent":["import type { BindGroup, PBFunctionScope, PBInsideFunctionScope, PBShaderExp } from '@zephyr3d/device';\r\nimport type { MeshMaterial } from '../../meshmaterial';\r\nimport { applyMaterialMixins } from '../../meshmaterial';\r\nimport type { TextureMixinInstanceTypes } from '../texture';\r\nimport { mixinTextureProps } from '../texture';\r\nimport type { IMixinPBRCommon } from '../pbr/common';\r\nimport { mixinPBRCommon } from '../pbr/common';\r\nimport type { DrawContext } from '../../../render';\r\nimport type { Immutable } from '@zephyr3d/base';\r\nimport { Vector2, Vector4 } from '@zephyr3d/base';\r\nimport type { IMixinLight } from '../lit';\r\nimport { mixinLight } from '../lit';\r\nimport { ShaderHelper } from '../../shader/helper';\r\nimport {\r\n LIGHT_TYPE_POINT,\r\n LIGHT_TYPE_RECT,\r\n MaterialVaryingFlags,\r\n RENDER_PASS_TYPE_LIGHT\r\n} from '../../../values';\r\n\r\nexport type PBRReflectionMode = 'none' | 'ggx' | 'anisotropic' | 'glint';\r\n\r\nconst PBR_REFLECTION_MODE: Record<PBRReflectionMode, number> = {\r\n none: 0,\r\n ggx: 1,\r\n anisotropic: 2,\r\n glint: 3\r\n};\r\n\r\n/**\r\n * Interface for PBRMetallicRoughness lighting model mixin\r\n * @public\r\n */\r\nexport type IMixinPBRMetallicRoughness = {\r\n metallic: number;\r\n roughness: number;\r\n specularFactor: Vector4;\r\n reflectionMode: PBRReflectionMode;\r\n anisotropy: number;\r\n anisotropyDirection: number;\r\n anisotropyDirectionScaleBias: Vector2;\r\n PBRLight(\r\n scope: PBInsideFunctionScope,\r\n worldPos: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n albedo: PBShaderExp,\r\n TBN: PBShaderExp,\r\n outRoughness?: PBShaderExp\r\n ): PBShaderExp;\r\n calculateMetallic(scope: PBInsideFunctionScope, albedo: PBShaderExp, normal: PBShaderExp): PBShaderExp;\r\n calculateRoughness(scope: PBInsideFunctionScope, albedo: PBShaderExp, normal: PBShaderExp): PBShaderExp;\r\n calculateSpecularFactor(\r\n scope: PBInsideFunctionScope,\r\n albedo: PBShaderExp,\r\n normal: PBShaderExp\r\n ): PBShaderExp;\r\n calculateCommonData(\r\n scope: PBInsideFunctionScope,\r\n albedo: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n TBN: PBShaderExp,\r\n data: PBShaderExp\r\n ): void;\r\n} & IMixinPBRCommon &\r\n IMixinLight &\r\n TextureMixinInstanceTypes<\r\n ['metallicRoughness', 'occlusion', 'specular', 'specularColor', 'anisotropyDirection']\r\n >;\r\n\r\n/**\r\n * PBRMetallicRoughness lighting model mixin\r\n * @param BaseCls - Class to mix in\r\n * @returns Mixed class\r\n * @public\r\n */\r\nexport function mixinPBRMetallicRoughness<T extends typeof MeshMaterial>(BaseCls: T) {\r\n if ((BaseCls as any).pbrMetallicRoughnessMixed) {\r\n return BaseCls as T & { new (...args: any[]): IMixinPBRMetallicRoughness };\r\n }\r\n const S = applyMaterialMixins(\r\n BaseCls,\r\n mixinPBRCommon,\r\n mixinLight,\r\n mixinTextureProps('metallicRoughness'),\r\n mixinTextureProps('specular'),\r\n mixinTextureProps('specularColor'),\r\n mixinTextureProps('anisotropyDirection')\r\n );\r\n const METALLIC_UNIFORM = S.defineInstanceUniform('metallic', 'float', 'Metallic');\r\n const ROUGHNESS_UNIFORM = S.defineInstanceUniform('roughness', 'float', 'Roughness');\r\n const SPECULAR_FACTOR_UNFORM = S.defineInstanceUniform('specularFactor', 'rgba', 'SpecularFactor');\r\n\r\n return class extends S {\r\n static readonly pbrMetallicRoughnessMixed = true;\r\n private _metallic: number;\r\n private _roughness: number;\r\n private readonly _specularFactor: Vector4;\r\n private _reflectionMode: PBRReflectionMode;\r\n private _anisotropy: number;\r\n private _anisotropyDirection: number;\r\n private readonly _anisotropyDirectionScaleBias: Vector2;\r\n constructor() {\r\n super();\r\n this._metallic = 1;\r\n this._roughness = 1;\r\n this._specularFactor = Vector4.one();\r\n this._reflectionMode = 'ggx';\r\n this._anisotropy = 0.75;\r\n this._anisotropyDirection = 0;\r\n this._anisotropyDirectionScaleBias = new Vector2(1, 0);\r\n }\r\n copyFrom(other: this) {\r\n super.copyFrom(other);\r\n this.metallic = other.metallic;\r\n this.roughness = other.roughness;\r\n this.specularFactor = other.specularFactor;\r\n this.reflectionMode = other.reflectionMode;\r\n this.anisotropy = other.anisotropy;\r\n this.anisotropyDirection = other.anisotropyDirection;\r\n this.anisotropyDirectionScaleBias = other.anisotropyDirectionScaleBias;\r\n }\r\n get metallic() {\r\n return this._metallic;\r\n }\r\n set metallic(val) {\r\n if (val !== this._metallic) {\r\n this._metallic = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get roughness() {\r\n return this._roughness;\r\n }\r\n set roughness(val) {\r\n if (val !== this._roughness) {\r\n this._roughness = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get specularFactor(): Immutable<Vector4> {\r\n return this._specularFactor;\r\n }\r\n set specularFactor(val: Immutable<Vector4>) {\r\n if (!val.equalsTo(this._specularFactor)) {\r\n this._specularFactor.set(val);\r\n this.uniformChanged();\r\n }\r\n }\r\n directLighting(\r\n scope: PBInsideFunctionScope,\r\n lightDir: PBShaderExp,\r\n lightColor: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n commonData: PBShaderExp,\r\n diffuseScale: PBShaderExp,\r\n specularScale: PBShaderExp,\r\n sourceRadiusFactor: PBShaderExp,\r\n outColor: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n const that = this as any;\r\n const funcName = 'Z_PBRMR_DirectLighting';\r\n pb.func(\r\n funcName,\r\n [\r\n pb.vec3('L'),\r\n pb.vec3('lightColor'),\r\n pb.vec3('normal'),\r\n pb.vec3('viewVec'),\r\n that.getCommonDatasStruct(scope)('data'),\r\n pb.float('diffuseScale'),\r\n pb.float('specularScale'),\r\n pb.float('sourceRadiusFactor'),\r\n pb.vec3('outColor').inout()\r\n ],\r\n function () {\r\n this.$l.reflectionMode = this.zReflectionMode;\r\n this.$l.anisotropy = this.zAnisotropy;\r\n this.$l.anisotropyDirection = this.zAnisotropyDirection;\r\n this.$l.anisotropyDirectionScaleBias = this.zAnisotropyDirectionScaleBias;\r\n this.$l.H = pb.normalize(pb.add(this.viewVec, this.L));\r\n this.$l.NoH = pb.clamp(pb.dot(this.normal, this.H), 0, 1);\r\n this.$l.NoL = pb.clamp(pb.dot(this.normal, this.L), 0, 1);\r\n this.$l.NoV = pb.clamp(pb.dot(this.normal, this.viewVec), 0, 1);\r\n this.$if(pb.greaterThan(this.NoL, 0), function () {\r\n this.$l.VoH = pb.clamp(pb.dot(this.viewVec, this.H), 0, 1);\r\n this.$l.schlickFresnel = that.fresnelSchlick(this, this.VoH, this.data.f0.rgb, this.data.f90);\r\n if (that.iridescence) {\r\n this.$l.F = pb.mix(\r\n this.schlickFresnel,\r\n this.data.iridescenceFresnel,\r\n this.data.iridescenceFactor.x\r\n );\r\n } else {\r\n this.$l.F = this.schlickFresnel;\r\n }\r\n this.$l.specularRoughness = pb.clamp(pb.add(this.data.roughness, this.sourceRadiusFactor), 0, 1);\r\n this.$l.alphaRoughness = pb.mul(this.specularRoughness, this.specularRoughness);\r\n this.$l.Dggx = that.distributionGGX(this, this.NoH, this.alphaRoughness);\r\n this.$l.D = this.Dggx;\r\n this.$if(pb.equal(this.reflectionMode, PBR_REFLECTION_MODE.anisotropic), function () {\r\n this.$l.dirAngle = pb.mul(this.anisotropyDirection, Math.PI / 180);\r\n if (that.anisotropyDirectionTexture) {\r\n this.$l.dirSample = that.sampleAnisotropyDirectionTexture(this);\r\n this.$l.dirAngle = pb.mul(\r\n pb.add(\r\n pb.mul(this.dirSample.r, this.anisotropyDirectionScaleBias.x),\r\n this.anisotropyDirectionScaleBias.y\r\n ),\r\n Math.PI / 180\r\n );\r\n }\r\n this.$l.anisoAngle = this.dirAngle;\r\n this.$l.up = pb.vec3(0, 1, 0);\r\n this.$l.t0 = pb.normalize(pb.cross(this.up, this.normal));\r\n this.$if(pb.lessThan(pb.length(this.t0), 0.001), function () {\r\n this.t0 = pb.normalize(pb.cross(pb.vec3(1, 0, 0), this.normal));\r\n });\r\n this.$l.b0 = pb.normalize(pb.cross(this.normal, this.t0));\r\n this.$l.tangent = pb.normalize(\r\n pb.add(pb.mul(this.t0, pb.cos(this.anisoAngle)), pb.mul(this.b0, pb.sin(this.anisoAngle)))\r\n );\r\n this.$l.bitangent = pb.normalize(pb.cross(this.normal, this.tangent));\r\n this.$l.ToH = pb.dot(this.tangent, this.H);\r\n this.$l.BoH = pb.dot(this.bitangent, this.H);\r\n this.$l.at = pb.max(pb.mul(this.alphaRoughness, pb.add(1, this.anisotropy)), 0.0001);\r\n this.$l.ab = pb.max(pb.mul(this.alphaRoughness, pb.sub(1, this.anisotropy)), 0.0001);\r\n this.$l.anisoDenom = pb.mul(\r\n Math.PI,\r\n this.at,\r\n this.ab,\r\n pb.pow(\r\n pb.add(\r\n pb.div(pb.mul(this.ToH, this.ToH), pb.mul(this.at, this.at)),\r\n pb.div(pb.mul(this.BoH, this.BoH), pb.mul(this.ab, this.ab)),\r\n pb.mul(this.NoH, this.NoH)\r\n ),\r\n 2\r\n )\r\n );\r\n this.D = pb.div(1, pb.max(this.anisoDenom, 0.0001));\r\n }).$elseif(pb.equal(this.reflectionMode, PBR_REFLECTION_MODE.glint), function () {\r\n this.$l.glintNoise = pb.fract(\r\n pb.mul(\r\n pb.sin(pb.add(pb.dot(this.H, pb.vec3(127.1, 311.7, 74.7)), pb.mul(this.NoH, 43.1))),\r\n 43758.5453\r\n )\r\n );\r\n this.$l.glintMask = pb.smoothStep(0.97, 1, this.glintNoise);\r\n this.D = pb.mul(this.Dggx, pb.add(1, pb.mul(this.glintMask, 8)));\r\n });\r\n this.$l.V = that.visGGX(this, this.NoV, this.NoL, this.alphaRoughness);\r\n this.$l.specular = pb.mul(\r\n this.lightColor,\r\n this.D,\r\n this.V,\r\n this.F,\r\n this.data.specularWeight,\r\n this.specularScale\r\n );\r\n if (that.sheen) {\r\n this.specular = pb.mul(this.specular, this.data.sheenAlbedoScaling);\r\n }\r\n this.$if(pb.equal(this.reflectionMode, PBR_REFLECTION_MODE.none), function () {\r\n this.specular = pb.vec3(0);\r\n });\r\n this.outColor = pb.add(this.outColor, this.specular);\r\n if (that.iridescence) {\r\n this.$l.iridescenceFresnelMax = pb.vec3(\r\n pb.max(\r\n pb.max(this.data.iridescenceFresnel.r, this.data.iridescenceFresnel.g),\r\n this.data.iridescenceFresnel.b\r\n )\r\n );\r\n this.F = pb.mix(this.schlickFresnel, this.iridescenceFresnelMax, this.data.iridescenceFactor.x);\r\n }\r\n this.$l.diffuseBRDF = pb.mul(\r\n pb.sub(pb.vec3(1), pb.mul(this.F, this.data.specularWeight)),\r\n pb.div(this.data.diffuse.rgb, Math.PI)\r\n );\r\n this.$l.diffuse = pb.mul(\r\n this.lightColor,\r\n pb.max(this.diffuseBRDF, pb.vec3(0)),\r\n this.diffuseScale\r\n );\r\n if (that.transmission && that.drawContext.renderPass!.type === RENDER_PASS_TYPE_LIGHT) {\r\n this.$l.transmissionRay = that.getVolumeTransmissionRay(\r\n this,\r\n this.normal,\r\n this.viewVec,\r\n this.data.thicknessFactor,\r\n this.data.f0.a\r\n );\r\n this.$l.pointToLight = pb.normalize(pb.sub(this.L, this.transmissionRay));\r\n this.$l.transmittedLight = pb.mul(\r\n this.lightColor,\r\n that.getPunctualRadianceTransmission(\r\n this,\r\n this.normal,\r\n this.viewVec,\r\n this.pointToLight,\r\n this.alphaRoughness,\r\n this.data.f0.rgb,\r\n this.data.f90.rgb,\r\n this.data.diffuse.rgb,\r\n this.data.f0.a\r\n )\r\n );\r\n this.transmittedLight = that.applyVolumeAttenuation(\r\n this,\r\n this.transmittedLight,\r\n pb.length(this.transmissionRay),\r\n this.data.attenuationColor,\r\n this.data.attenuationDistance\r\n );\r\n this.diffuse = pb.mix(this.diffuse, this.transmittedLight, this.data.transmissionFactor);\r\n }\r\n if (that.sheen) {\r\n this.diffuse = pb.mul(this.diffuse, this.data.sheenAlbedoScaling);\r\n }\r\n this.outColor = pb.add(this.outColor, this.diffuse);\r\n if (that.sheen) {\r\n this.$l.sheenD = that.D_Charlie(this, this.NoH, this.data.sheenRoughness);\r\n this.$l.sheenV = that.V_Ashikhmin(this, this.NoL, this.NoV);\r\n this.outColor = pb.add(\r\n this.outColor,\r\n pb.mul(this.lightColor, this.data.sheenColor, this.sheenD, this.sheenV)\r\n );\r\n }\r\n if (that.clearcoat) {\r\n this.alphaRoughness = pb.mul(this.data.ccFactor.y, this.data.ccFactor.y);\r\n this.NoH = pb.clamp(pb.dot(this.data.ccNormal, this.H), 0, 1);\r\n this.NoL = pb.clamp(pb.dot(this.data.ccNormal, this.L), 0, 1);\r\n this.ccF0 = pb.vec3(pb.pow(pb.div(pb.sub(this.data.f0.a, 1), pb.add(this.data.f0.a, 1)), 2));\r\n this.F = that.fresnelSchlick(this, this.VoH, this.ccF0, pb.vec3(1));\r\n this.D = that.distributionGGX(this, this.NoH, this.alphaRoughness);\r\n this.V = that.visGGX(this, this.data.ccNoV, this.NoL, this.alphaRoughness);\r\n this.outColor = pb.add(this.outColor, pb.mul(this.D, this.V, this.F, this.data.ccFactor.x));\r\n }\r\n });\r\n }\r\n );\r\n scope.$g[funcName](\r\n lightDir,\r\n lightColor,\r\n normal,\r\n viewVec,\r\n commonData,\r\n diffuseScale,\r\n specularScale,\r\n sourceRadiusFactor,\r\n outColor\r\n );\r\n }\r\n get reflectionMode() {\r\n return this._reflectionMode;\r\n }\r\n set reflectionMode(val: PBRReflectionMode) {\r\n if (val !== this._reflectionMode) {\r\n this._reflectionMode = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get anisotropy() {\r\n return this._anisotropy;\r\n }\r\n set anisotropy(val) {\r\n const clamped = Math.max(-0.95, Math.min(0.95, val));\r\n if (clamped !== this._anisotropy) {\r\n this._anisotropy = clamped;\r\n this.uniformChanged();\r\n }\r\n }\r\n get anisotropyDirection() {\r\n return this._anisotropyDirection;\r\n }\r\n set anisotropyDirection(val) {\r\n if (val !== this._anisotropyDirection) {\r\n this._anisotropyDirection = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get anisotropyDirectionScaleBias(): Immutable<Vector2> {\r\n return this._anisotropyDirectionScaleBias;\r\n }\r\n set anisotropyDirectionScaleBias(val: Immutable<Vector2>) {\r\n if (!val.equalsTo(this._anisotropyDirectionScaleBias)) {\r\n this._anisotropyDirectionScaleBias.set(val);\r\n this.uniformChanged();\r\n }\r\n }\r\n calculateAnisotropyDirectionScaleBias(scope: PBInsideFunctionScope) {\r\n return scope.zAnisotropyDirectionScaleBias as PBShaderExp;\r\n }\r\n PBRLight(\r\n scope: PBInsideFunctionScope,\r\n worldPos: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n albedo: PBShaderExp,\r\n TBN: PBShaderExp,\r\n outRoughness?: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n const funcName = 'Z_PBRMetallicRoughnessLight';\r\n const that = this;\r\n pb.func(\r\n funcName,\r\n [\r\n pb.vec3('worldPos'),\r\n pb.vec3('normal'),\r\n pb.mat3('TBN'),\r\n pb.vec3('viewVec'),\r\n pb.vec4('albedo'),\r\n ...(outRoughness ? [pb.vec4('outRoughness').out()] : [])\r\n ],\r\n function () {\r\n this.$l.pbrData = that.getCommonData(this, this.albedo, this.normal, this.viewVec, this.TBN);\r\n this.$l.lightingColor = pb.vec3(0);\r\n this.$l.emissiveColor = that.calculateEmissiveColor(this);\r\n if (outRoughness) {\r\n that.indirectLighting(\r\n this,\r\n this.normal,\r\n this.viewVec,\r\n this.pbrData,\r\n this.lightingColor,\r\n this.outRoughness\r\n );\r\n } else {\r\n that.indirectLighting(this, this.normal, this.viewVec, this.pbrData, this.lightingColor);\r\n }\r\n that.forEachLight(this, function (type, posRange, dirCutoff, colorIntensity, extra, shadow) {\r\n this.$if(pb.equal(type, LIGHT_TYPE_RECT), function () {\r\n that.directRectLight(\r\n this,\r\n this.worldPos,\r\n this.normal,\r\n this.viewVec,\r\n this.pbrData,\r\n posRange,\r\n dirCutoff,\r\n extra,\r\n colorIntensity,\r\n this.lightingColor\r\n );\r\n }).$else(function () {\r\n this.$l.diffuse = pb.vec3();\r\n this.$l.specular = pb.vec3();\r\n this.$l.diffuseScale = pb.float(1);\r\n this.$l.specularScale = pb.float(1);\r\n this.$l.sourceRadiusFactor = pb.float(0);\r\n this.$if(pb.equal(type, LIGHT_TYPE_POINT), function () {\r\n this.diffuseScale = extra.x;\r\n this.specularScale = extra.y;\r\n this.sourceRadiusFactor = pb.div(\r\n extra.z,\r\n pb.max(pb.distance(posRange.xyz, this.worldPos), 0.0001)\r\n );\r\n });\r\n this.$l.lightAtten = that.calculateLightAttenuation(\r\n this,\r\n type,\r\n this.worldPos,\r\n posRange,\r\n dirCutoff\r\n );\r\n this.$l.lightDir = that.calculateLightDirection(this, type, this.worldPos, posRange, dirCutoff);\r\n this.$l.NoL = pb.clamp(pb.dot(this.normal, this.lightDir), 0, 1);\r\n this.$l.lightColor = pb.mul(colorIntensity.rgb, colorIntensity.a, this.lightAtten, this.NoL);\r\n if (shadow) {\r\n this.lightColor = pb.mul(\r\n this.lightColor,\r\n that.calculateShadow(this, this.worldPos, this.NoL)\r\n );\r\n }\r\n that.directLighting(\r\n this,\r\n this.lightDir,\r\n this.lightColor,\r\n this.normal,\r\n this.viewVec,\r\n this.pbrData,\r\n this.diffuseScale,\r\n this.specularScale,\r\n this.sourceRadiusFactor,\r\n this.lightingColor\r\n );\r\n });\r\n });\r\n this.$return(pb.add(this.lightingColor, this.emissiveColor));\r\n }\r\n );\r\n return (\r\n outRoughness\r\n ? pb.getGlobalScope()[funcName](worldPos, normal, TBN, viewVec, albedo, outRoughness)\r\n : pb.getGlobalScope()[funcName](worldPos, normal, TBN, viewVec, albedo)\r\n ) as PBShaderExp;\r\n }\r\n vertexShader(scope: PBFunctionScope) {\r\n super.vertexShader(scope);\r\n if (this.needFragmentColor() && this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING) {\r\n scope.$outputs.zMetallic = this.getInstancedUniform(scope, METALLIC_UNIFORM);\r\n scope.$outputs.zRoughness = this.getInstancedUniform(scope, ROUGHNESS_UNIFORM);\r\n scope.$outputs.zSpecularFactor = this.getInstancedUniform(scope, SPECULAR_FACTOR_UNFORM);\r\n }\r\n }\r\n fragmentShader(scope: PBFunctionScope) {\r\n super.fragmentShader(scope);\r\n if (this.needFragmentColor()) {\r\n const pb = scope.$builder;\r\n if (!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING)) {\r\n scope.zMetallic = pb.float().uniform(2);\r\n scope.zRoughness = pb.float().uniform(2);\r\n scope.zSpecularFactor = pb.vec4().uniform(2);\r\n }\r\n scope.zReflectionMode = pb.float().uniform(2);\r\n scope.zAnisotropy = pb.float().uniform(2);\r\n scope.zAnisotropyDirection = pb.float().uniform(2);\r\n scope.zAnisotropyDirectionScaleBias = pb.vec2().uniform(2);\r\n }\r\n }\r\n applyUniformValues(bindGroup: BindGroup, ctx: DrawContext, pass: number) {\r\n super.applyUniformValues(bindGroup, ctx, pass);\r\n if (this.needFragmentColor(ctx)) {\r\n if (!(ctx.materialFlags & MaterialVaryingFlags.INSTANCING)) {\r\n bindGroup.setValue('zMetallic', this._metallic);\r\n bindGroup.setValue('zRoughness', this._roughness);\r\n bindGroup.setValue('zSpecularFactor', this._specularFactor);\r\n bindGroup.setValue('zReflectionMode', PBR_REFLECTION_MODE[this._reflectionMode]);\r\n bindGroup.setValue('zAnisotropy', this._anisotropy);\r\n bindGroup.setValue('zAnisotropyDirection', this._anisotropyDirection);\r\n bindGroup.setValue('zAnisotropyDirectionScaleBias', this._anisotropyDirectionScaleBias);\r\n }\r\n }\r\n }\r\n calculateMetallic(scope: PBInsideFunctionScope, _albedo: PBShaderExp, _normal: PBShaderExp) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zMetallic : scope.zMetallic) as PBShaderExp;\r\n }\r\n calculateRoughness(scope: PBInsideFunctionScope, _albedo: PBShaderExp, _normal: PBShaderExp) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zRoughness : scope.zRoughness) as PBShaderExp;\r\n }\r\n calculateSpecularFactor(scope: PBInsideFunctionScope, _albedo: PBShaderExp, _normal: PBShaderExp) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zSpecularFactor : scope.zSpecularFactor) as PBShaderExp;\r\n }\r\n calculateCommonData(\r\n scope: PBInsideFunctionScope,\r\n albedo: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n TBN: PBShaderExp,\r\n data: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n const metallic = this.calculateMetallic(scope, albedo, normal);\r\n const roughness = this.calculateRoughness(scope, albedo, normal);\r\n const specularFactor = this.calculateSpecularFactor(scope, albedo, normal);\r\n const reflectionMode = this.calculateReflectionMode(scope) as PBShaderExp;\r\n if (this.metallicRoughnessTexture) {\r\n scope.$l.metallicRoughnessSample = this.sampleMetallicRoughnessTexture(scope);\r\n data.metallic = pb.mul(metallic, scope.metallicRoughnessSample.z);\r\n data.roughness = pb.mul(roughness, scope.metallicRoughnessSample.y);\r\n } else {\r\n data.metallic = metallic;\r\n data.roughness = roughness;\r\n }\r\n data.roughness = pb.mul(data.roughness, ShaderHelper.getCameraRoughnessFactor(scope));\r\n if (this.specularColorTexture) {\r\n scope.$l.specularColor = pb.mul(specularFactor.rgb, this.sampleSpecularColorTexture(scope).rgb);\r\n } else {\r\n scope.$l.specularColor = specularFactor.rgb;\r\n }\r\n if (this.specularTexture) {\r\n data.specularWeight = pb.mul(specularFactor.a, this.sampleSpecularTexture(scope).a);\r\n } else {\r\n data.specularWeight = specularFactor.a;\r\n }\r\n data.specularWeight = pb.mul(\r\n data.specularWeight,\r\n pb.float(pb.notEqual(reflectionMode, PBR_REFLECTION_MODE.none))\r\n );\r\n data.f0 = pb.vec4(\r\n pb.mix(\r\n pb.min(pb.mul(this.getF0(scope).rgb, scope.specularColor), pb.vec3(1)),\r\n albedo.rgb,\r\n data.metallic\r\n ),\r\n this.getF0(scope).a\r\n );\r\n data.f90 = pb.vec3(1);\r\n data.diffuse = pb.vec4(pb.mix(albedo.rgb, pb.vec3(0), data.metallic), albedo.a);\r\n super.calculateCommonData(scope, albedo, normal, viewVec, TBN, data);\r\n }\r\n calculateReflectionMode(scope: PBInsideFunctionScope) {\r\n return scope.zReflectionMode as PBShaderExp;\r\n }\r\n calculateAnisotropy(scope: PBInsideFunctionScope) {\r\n return scope.zAnisotropy as PBShaderExp;\r\n }\r\n calculateAnisotropyDirection(scope: PBInsideFunctionScope) {\r\n return scope.zAnisotropyDirection as PBShaderExp;\r\n }\r\n } as unknown as T & { new (...args: any[]): IMixinPBRMetallicRoughness };\r\n}\r\n"],"names":["PBR_REFLECTION_MODE","none","ggx","anisotropic","glint","mixinPBRMetallicRoughness","BaseCls","pbrMetallicRoughnessMixed","S","applyMaterialMixins","mixinPBRCommon","mixinLight","mixinTextureProps","METALLIC_UNIFORM","defineInstanceUniform","ROUGHNESS_UNIFORM","SPECULAR_FACTOR_UNFORM","_metallic","_roughness","_specularFactor","_reflectionMode","_anisotropy","_anisotropyDirection","_anisotropyDirectionScaleBias","Vector4","one","Vector2","copyFrom","other","metallic","roughness","specularFactor","reflectionMode","anisotropy","anisotropyDirection","anisotropyDirectionScaleBias","val","uniformChanged","equalsTo","set","directLighting","scope","lightDir","lightColor","normal","viewVec","commonData","diffuseScale","specularScale","sourceRadiusFactor","outColor","pb","$builder","that","funcName","func","vec3","getCommonDatasStruct","float","inout","$l","zReflectionMode","zAnisotropy","zAnisotropyDirection","zAnisotropyDirectionScaleBias","H","normalize","add","L","NoH","clamp","dot","NoL","NoV","$if","greaterThan","VoH","schlickFresnel","fresnelSchlick","data","f0","rgb","f90","iridescence","F","mix","iridescenceFresnel","iridescenceFactor","x","specularRoughness","alphaRoughness","mul","Dggx","distributionGGX","D","equal","dirAngle","Math","PI","anisotropyDirectionTexture","dirSample","sampleAnisotropyDirectionTexture","r","y","anisoAngle","up","t0","cross","lessThan","length","b0","tangent","cos","sin","bitangent","ToH","BoH","at","max","ab","sub","anisoDenom","pow","div","$elseif","glintNoise","fract","glintMask","smoothStep","V","visGGX","specular","specularWeight","sheen","sheenAlbedoScaling","iridescenceFresnelMax","g","b","diffuseBRDF","diffuse","transmission","drawContext","renderPass","type","RENDER_PASS_TYPE_LIGHT","transmissionRay","getVolumeTransmissionRay","thicknessFactor","a","pointToLight","transmittedLight","getPunctualRadianceTransmission","applyVolumeAttenuation","attenuationColor","attenuationDistance","transmissionFactor","sheenD","D_Charlie","sheenRoughness","sheenV","V_Ashikhmin","sheenColor","clearcoat","ccFactor","ccNormal","ccF0","ccNoV","$g","clamped","min","calculateAnisotropyDirectionScaleBias","PBRLight","worldPos","albedo","TBN","outRoughness","mat3","vec4","out","pbrData","getCommonData","lightingColor","emissiveColor","calculateEmissiveColor","indirectLighting","forEachLight","posRange","dirCutoff","colorIntensity","extra","shadow","LIGHT_TYPE_RECT","directRectLight","$else","LIGHT_TYPE_POINT","z","distance","xyz","lightAtten","calculateLightAttenuation","calculateLightDirection","calculateShadow","$return","getGlobalScope","vertexShader","needFragmentColor","materialFlags","MaterialVaryingFlags","INSTANCING","$outputs","zMetallic","getInstancedUniform","zRoughness","zSpecularFactor","fragmentShader","uniform","vec2","applyUniformValues","bindGroup","ctx","pass","setValue","calculateMetallic","_albedo","_normal","instancing","$inputs","calculateRoughness","calculateSpecularFactor","calculateCommonData","calculateReflectionMode","metallicRoughnessTexture","metallicRoughnessSample","sampleMetallicRoughnessTexture","ShaderHelper","getCameraRoughnessFactor","specularColorTexture","specularColor","sampleSpecularColorTexture","specularTexture","sampleSpecularTexture","notEqual","getF0","calculateAnisotropy","calculateAnisotropyDirection"],"mappings":";;;;;;;;AAsBA,MAAMA,mBAAyD,GAAA;IAC7DC,IAAM,EAAA,CAAA;IACNC,GAAK,EAAA,CAAA;IACLC,WAAa,EAAA,CAAA;IACbC,KAAO,EAAA;AACT,CAAA;AA4CA;;;;;IAMO,SAASC,yBAAAA,CAAyDC,OAAU,EAAA;IACjF,IAAKA,OAAgBC,CAAAA,yBAAyB,EAAE;QAC9C,OAAOD,OAAAA;AACT;IACA,MAAME,CAAAA,GAAIC,mBACRH,CAAAA,OAAAA,EACAI,cACAC,EAAAA,UAAAA,EACAC,iBAAkB,CAAA,mBAAA,CAAA,EAClBA,iBAAkB,CAAA,UAAA,CAAA,EAClBA,iBAAkB,CAAA,eAAA,CAAA,EAClBA,iBAAkB,CAAA,qBAAA,CAAA,CAAA;AAEpB,IAAA,MAAMC,gBAAmBL,GAAAA,CAAAA,CAAEM,qBAAqB,CAAC,YAAY,OAAS,EAAA,UAAA,CAAA;AACtE,IAAA,MAAMC,iBAAoBP,GAAAA,CAAAA,CAAEM,qBAAqB,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AAKC,EAAE,GAAG7B,EAAAA,CAAG8H,IAAI,CACf9H,GAAGkC,GAAG,CACJlC,EAAGsH,CAAAA,GAAG,CAACtH,EAAGwC,CAAAA,GAAG,CAAC,IAAI,CAACuJ,KAAK,CAACzM,KAAAA,CAAAA,CAAOwC,GAAG,EAAExC,MAAMoM,aAAa,CAAA,EAAG1L,GAAGK,IAAI,CAAC,KACnEqH,MAAO5F,CAAAA,GAAG,EACVF,IAAAA,CAAKlD,QAAQ,CAEf,EAAA,IAAI,CAACqN,KAAK,CAACzM,OAAO2G,CAAC,CAAA;AAErBrE,YAAAA,IAAAA,CAAKG,GAAG,GAAG/B,EAAGK,CAAAA,IAAI,CAAC,CAAA,CAAA;AACnBuB,YAAAA,IAAAA,CAAK4D,OAAO,GAAGxF,EAAAA,CAAG8H,IAAI,CAAC9H,EAAAA,CAAGkC,GAAG,CAACwF,MAAAA,CAAO5F,GAAG,EAAE9B,EAAAA,CAAGK,IAAI,CAAC,CAAA,CAAA,EAAIuB,KAAKlD,QAAQ,CAAA,EAAGgJ,OAAOzB,CAAC,CAAA;AAC9E,YAAA,KAAK,CAACiF,mBAAoB5L,CAAAA,KAAAA,EAAOoI,MAAQjI,EAAAA,MAAAA,EAAQC,SAASiI,GAAK/F,EAAAA,IAAAA,CAAAA;AACjE;AACAuJ,QAAAA,uBAAAA,CAAwB7L,KAA4B,EAAE;AACpD,YAAA,OAAOA,MAAMoB,eAAe;AAC9B;AACAsL,QAAAA,mBAAAA,CAAoB1M,KAA4B,EAAE;AAChD,YAAA,OAAOA,MAAMqB,WAAW;AAC1B;AACAsL,QAAAA,4BAAAA,CAA6B3M,KAA4B,EAAE;AACzD,YAAA,OAAOA,MAAMsB,oBAAoB;AACnC;AACF,KAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"pbrmetallicroughness.js","sources":["../../../../src/material/mixins/lightmodel/pbrmetallicroughness.ts"],"sourcesContent":["import type { BindGroup, PBFunctionScope, PBInsideFunctionScope, PBShaderExp } from '@zephyr3d/device';\r\nimport type { MeshMaterial } from '../../meshmaterial';\r\nimport { applyMaterialMixins } from '../../meshmaterial';\r\nimport type { TextureMixinInstanceTypes } from '../texture';\r\nimport { mixinTextureProps } from '../texture';\r\nimport type { IMixinPBRCommon } from '../pbr/common';\r\nimport { mixinPBRCommon } from '../pbr/common';\r\nimport type { DrawContext } from '../../../render';\r\nimport type { Immutable } from '@zephyr3d/base';\r\nimport { Vector2, Vector4 } from '@zephyr3d/base';\r\nimport type { IMixinLight } from '../lit';\r\nimport { mixinLight } from '../lit';\r\nimport { ShaderHelper } from '../../shader/helper';\r\nimport {\r\n LIGHT_TYPE_POINT,\r\n LIGHT_TYPE_RECT,\r\n MaterialVaryingFlags,\r\n RENDER_PASS_TYPE_LIGHT\r\n} from '../../../values';\r\n\r\n/**\r\n * Reflection model used by the PBR metallic-roughness material.\r\n *\r\n * @public\r\n */\r\nexport type PBRReflectionMode = 'none' | 'ggx' | 'anisotropic' | 'glint';\r\n\r\nconst PBR_REFLECTION_MODE: Record<PBRReflectionMode, number> = {\r\n none: 0,\r\n ggx: 1,\r\n anisotropic: 2,\r\n glint: 3\r\n};\r\n\r\n/**\r\n * Interface for PBRMetallicRoughness lighting model mixin\r\n * @public\r\n */\r\nexport type IMixinPBRMetallicRoughness = {\r\n metallic: number;\r\n roughness: number;\r\n specularFactor: Vector4;\r\n reflectionMode: PBRReflectionMode;\r\n anisotropy: number;\r\n anisotropyDirection: number;\r\n anisotropyDirectionScaleBias: Vector2;\r\n PBRLight(\r\n scope: PBInsideFunctionScope,\r\n worldPos: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n albedo: PBShaderExp,\r\n TBN: PBShaderExp,\r\n outRoughness?: PBShaderExp\r\n ): PBShaderExp;\r\n calculateMetallic(scope: PBInsideFunctionScope, albedo: PBShaderExp, normal: PBShaderExp): PBShaderExp;\r\n calculateRoughness(scope: PBInsideFunctionScope, albedo: PBShaderExp, normal: PBShaderExp): PBShaderExp;\r\n calculateSpecularFactor(\r\n scope: PBInsideFunctionScope,\r\n albedo: PBShaderExp,\r\n normal: PBShaderExp\r\n ): PBShaderExp;\r\n calculateCommonData(\r\n scope: PBInsideFunctionScope,\r\n albedo: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n TBN: PBShaderExp,\r\n data: PBShaderExp\r\n ): void;\r\n} & IMixinPBRCommon &\r\n IMixinLight &\r\n TextureMixinInstanceTypes<\r\n ['metallicRoughness', 'occlusion', 'specular', 'specularColor', 'anisotropyDirection']\r\n >;\r\n\r\n/**\r\n * PBRMetallicRoughness lighting model mixin\r\n * @param BaseCls - Class to mix in\r\n * @returns Mixed class\r\n * @public\r\n */\r\nexport function mixinPBRMetallicRoughness<T extends typeof MeshMaterial>(BaseCls: T) {\r\n if ((BaseCls as any).pbrMetallicRoughnessMixed) {\r\n return BaseCls as T & { new (...args: any[]): IMixinPBRMetallicRoughness };\r\n }\r\n const S = applyMaterialMixins(\r\n BaseCls,\r\n mixinPBRCommon,\r\n mixinLight,\r\n mixinTextureProps('metallicRoughness'),\r\n mixinTextureProps('specular'),\r\n mixinTextureProps('specularColor'),\r\n mixinTextureProps('anisotropyDirection')\r\n );\r\n const METALLIC_UNIFORM = S.defineInstanceUniform('metallic', 'float', 'Metallic');\r\n const ROUGHNESS_UNIFORM = S.defineInstanceUniform('roughness', 'float', 'Roughness');\r\n const SPECULAR_FACTOR_UNFORM = S.defineInstanceUniform('specularFactor', 'rgba', 'SpecularFactor');\r\n\r\n return class extends S {\r\n static readonly pbrMetallicRoughnessMixed = true;\r\n private _metallic: number;\r\n private _roughness: number;\r\n private readonly _specularFactor: Vector4;\r\n private _reflectionMode: PBRReflectionMode;\r\n private _anisotropy: number;\r\n private _anisotropyDirection: number;\r\n private readonly _anisotropyDirectionScaleBias: Vector2;\r\n constructor() {\r\n super();\r\n this._metallic = 1;\r\n this._roughness = 1;\r\n this._specularFactor = Vector4.one();\r\n this._reflectionMode = 'ggx';\r\n this._anisotropy = 0.75;\r\n this._anisotropyDirection = 0;\r\n this._anisotropyDirectionScaleBias = new Vector2(1, 0);\r\n }\r\n copyFrom(other: this) {\r\n super.copyFrom(other);\r\n this.metallic = other.metallic;\r\n this.roughness = other.roughness;\r\n this.specularFactor = other.specularFactor;\r\n this.reflectionMode = other.reflectionMode;\r\n this.anisotropy = other.anisotropy;\r\n this.anisotropyDirection = other.anisotropyDirection;\r\n this.anisotropyDirectionScaleBias = other.anisotropyDirectionScaleBias;\r\n }\r\n get metallic() {\r\n return this._metallic;\r\n }\r\n set metallic(val) {\r\n if (val !== this._metallic) {\r\n this._metallic = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get roughness() {\r\n return this._roughness;\r\n }\r\n set roughness(val) {\r\n if (val !== this._roughness) {\r\n this._roughness = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get specularFactor(): Immutable<Vector4> {\r\n return this._specularFactor;\r\n }\r\n set specularFactor(val: Immutable<Vector4>) {\r\n if (!val.equalsTo(this._specularFactor)) {\r\n this._specularFactor.set(val);\r\n this.uniformChanged();\r\n }\r\n }\r\n directLighting(\r\n scope: PBInsideFunctionScope,\r\n lightDir: PBShaderExp,\r\n lightColor: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n commonData: PBShaderExp,\r\n diffuseScale: PBShaderExp,\r\n specularScale: PBShaderExp,\r\n sourceRadiusFactor: PBShaderExp,\r\n outColor: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n const that = this as any;\r\n const funcName = 'Z_PBRMR_DirectLighting';\r\n pb.func(\r\n funcName,\r\n [\r\n pb.vec3('L'),\r\n pb.vec3('lightColor'),\r\n pb.vec3('normal'),\r\n pb.vec3('viewVec'),\r\n that.getCommonDatasStruct(scope)('data'),\r\n pb.float('diffuseScale'),\r\n pb.float('specularScale'),\r\n pb.float('sourceRadiusFactor'),\r\n pb.vec3('outColor').inout()\r\n ],\r\n function () {\r\n this.$l.reflectionMode = this.zReflectionMode;\r\n this.$l.anisotropy = this.zAnisotropy;\r\n this.$l.anisotropyDirection = this.zAnisotropyDirection;\r\n this.$l.anisotropyDirectionScaleBias = this.zAnisotropyDirectionScaleBias;\r\n this.$l.H = pb.normalize(pb.add(this.viewVec, this.L));\r\n this.$l.NoH = pb.clamp(pb.dot(this.normal, this.H), 0, 1);\r\n this.$l.NoL = pb.clamp(pb.dot(this.normal, this.L), 0, 1);\r\n this.$l.NoV = pb.clamp(pb.dot(this.normal, this.viewVec), 0, 1);\r\n this.$if(pb.greaterThan(this.NoL, 0), function () {\r\n this.$l.VoH = pb.clamp(pb.dot(this.viewVec, this.H), 0, 1);\r\n this.$l.schlickFresnel = that.fresnelSchlick(this, this.VoH, this.data.f0.rgb, this.data.f90);\r\n if (that.iridescence) {\r\n this.$l.F = pb.mix(\r\n this.schlickFresnel,\r\n this.data.iridescenceFresnel,\r\n this.data.iridescenceFactor.x\r\n );\r\n } else {\r\n this.$l.F = this.schlickFresnel;\r\n }\r\n this.$l.specularRoughness = pb.clamp(pb.add(this.data.roughness, this.sourceRadiusFactor), 0, 1);\r\n this.$l.alphaRoughness = pb.mul(this.specularRoughness, this.specularRoughness);\r\n this.$l.Dggx = that.distributionGGX(this, this.NoH, this.alphaRoughness);\r\n this.$l.D = this.Dggx;\r\n this.$if(pb.equal(this.reflectionMode, PBR_REFLECTION_MODE.anisotropic), function () {\r\n this.$l.dirAngle = pb.mul(this.anisotropyDirection, Math.PI / 180);\r\n if (that.anisotropyDirectionTexture) {\r\n this.$l.dirSample = that.sampleAnisotropyDirectionTexture(this);\r\n this.$l.dirAngle = pb.mul(\r\n pb.add(\r\n pb.mul(this.dirSample.r, this.anisotropyDirectionScaleBias.x),\r\n this.anisotropyDirectionScaleBias.y\r\n ),\r\n Math.PI / 180\r\n );\r\n }\r\n this.$l.anisoAngle = this.dirAngle;\r\n this.$l.up = pb.vec3(0, 1, 0);\r\n this.$l.t0 = pb.normalize(pb.cross(this.up, this.normal));\r\n this.$if(pb.lessThan(pb.length(this.t0), 0.001), function () {\r\n this.t0 = pb.normalize(pb.cross(pb.vec3(1, 0, 0), this.normal));\r\n });\r\n this.$l.b0 = pb.normalize(pb.cross(this.normal, this.t0));\r\n this.$l.tangent = pb.normalize(\r\n pb.add(pb.mul(this.t0, pb.cos(this.anisoAngle)), pb.mul(this.b0, pb.sin(this.anisoAngle)))\r\n );\r\n this.$l.bitangent = pb.normalize(pb.cross(this.normal, this.tangent));\r\n this.$l.ToH = pb.dot(this.tangent, this.H);\r\n this.$l.BoH = pb.dot(this.bitangent, this.H);\r\n this.$l.at = pb.max(pb.mul(this.alphaRoughness, pb.add(1, this.anisotropy)), 0.0001);\r\n this.$l.ab = pb.max(pb.mul(this.alphaRoughness, pb.sub(1, this.anisotropy)), 0.0001);\r\n this.$l.anisoDenom = pb.mul(\r\n Math.PI,\r\n this.at,\r\n this.ab,\r\n pb.pow(\r\n pb.add(\r\n pb.div(pb.mul(this.ToH, this.ToH), pb.mul(this.at, this.at)),\r\n pb.div(pb.mul(this.BoH, this.BoH), pb.mul(this.ab, this.ab)),\r\n pb.mul(this.NoH, this.NoH)\r\n ),\r\n 2\r\n )\r\n );\r\n this.D = pb.div(1, pb.max(this.anisoDenom, 0.0001));\r\n }).$elseif(pb.equal(this.reflectionMode, PBR_REFLECTION_MODE.glint), function () {\r\n this.$l.glintNoise = pb.fract(\r\n pb.mul(\r\n pb.sin(pb.add(pb.dot(this.H, pb.vec3(127.1, 311.7, 74.7)), pb.mul(this.NoH, 43.1))),\r\n 43758.5453\r\n )\r\n );\r\n this.$l.glintMask = pb.smoothStep(0.97, 1, this.glintNoise);\r\n this.D = pb.mul(this.Dggx, pb.add(1, pb.mul(this.glintMask, 8)));\r\n });\r\n this.$l.V = that.visGGX(this, this.NoV, this.NoL, this.alphaRoughness);\r\n this.$l.specular = pb.mul(\r\n this.lightColor,\r\n this.D,\r\n this.V,\r\n this.F,\r\n this.data.specularWeight,\r\n this.specularScale\r\n );\r\n if (that.sheen) {\r\n this.specular = pb.mul(this.specular, this.data.sheenAlbedoScaling);\r\n }\r\n this.$if(pb.equal(this.reflectionMode, PBR_REFLECTION_MODE.none), function () {\r\n this.specular = pb.vec3(0);\r\n });\r\n this.outColor = pb.add(this.outColor, this.specular);\r\n if (that.iridescence) {\r\n this.$l.iridescenceFresnelMax = pb.vec3(\r\n pb.max(\r\n pb.max(this.data.iridescenceFresnel.r, this.data.iridescenceFresnel.g),\r\n this.data.iridescenceFresnel.b\r\n )\r\n );\r\n this.F = pb.mix(this.schlickFresnel, this.iridescenceFresnelMax, this.data.iridescenceFactor.x);\r\n }\r\n this.$l.diffuseBRDF = pb.mul(\r\n pb.sub(pb.vec3(1), pb.mul(this.F, this.data.specularWeight)),\r\n pb.div(this.data.diffuse.rgb, Math.PI)\r\n );\r\n this.$l.diffuse = pb.mul(\r\n this.lightColor,\r\n pb.max(this.diffuseBRDF, pb.vec3(0)),\r\n this.diffuseScale\r\n );\r\n if (that.transmission && that.drawContext.renderPass!.type === RENDER_PASS_TYPE_LIGHT) {\r\n this.$l.transmissionRay = that.getVolumeTransmissionRay(\r\n this,\r\n this.normal,\r\n this.viewVec,\r\n this.data.thicknessFactor,\r\n this.data.f0.a\r\n );\r\n this.$l.pointToLight = pb.normalize(pb.sub(this.L, this.transmissionRay));\r\n this.$l.transmittedLight = pb.mul(\r\n this.lightColor,\r\n that.getPunctualRadianceTransmission(\r\n this,\r\n this.normal,\r\n this.viewVec,\r\n this.pointToLight,\r\n this.alphaRoughness,\r\n this.data.f0.rgb,\r\n this.data.f90.rgb,\r\n this.data.diffuse.rgb,\r\n this.data.f0.a\r\n )\r\n );\r\n this.transmittedLight = that.applyVolumeAttenuation(\r\n this,\r\n this.transmittedLight,\r\n pb.length(this.transmissionRay),\r\n this.data.attenuationColor,\r\n this.data.attenuationDistance\r\n );\r\n this.diffuse = pb.mix(this.diffuse, this.transmittedLight, this.data.transmissionFactor);\r\n }\r\n if (that.sheen) {\r\n this.diffuse = pb.mul(this.diffuse, this.data.sheenAlbedoScaling);\r\n }\r\n this.outColor = pb.add(this.outColor, this.diffuse);\r\n if (that.sheen) {\r\n this.$l.sheenD = that.D_Charlie(this, this.NoH, this.data.sheenRoughness);\r\n this.$l.sheenV = that.V_Ashikhmin(this, this.NoL, this.NoV);\r\n this.outColor = pb.add(\r\n this.outColor,\r\n pb.mul(this.lightColor, this.data.sheenColor, this.sheenD, this.sheenV)\r\n );\r\n }\r\n if (that.clearcoat) {\r\n this.alphaRoughness = pb.mul(this.data.ccFactor.y, this.data.ccFactor.y);\r\n this.NoH = pb.clamp(pb.dot(this.data.ccNormal, this.H), 0, 1);\r\n this.NoL = pb.clamp(pb.dot(this.data.ccNormal, this.L), 0, 1);\r\n this.ccF0 = pb.vec3(pb.pow(pb.div(pb.sub(this.data.f0.a, 1), pb.add(this.data.f0.a, 1)), 2));\r\n this.F = that.fresnelSchlick(this, this.VoH, this.ccF0, pb.vec3(1));\r\n this.D = that.distributionGGX(this, this.NoH, this.alphaRoughness);\r\n this.V = that.visGGX(this, this.data.ccNoV, this.NoL, this.alphaRoughness);\r\n this.outColor = pb.add(this.outColor, pb.mul(this.D, this.V, this.F, this.data.ccFactor.x));\r\n }\r\n });\r\n }\r\n );\r\n scope.$g[funcName](\r\n lightDir,\r\n lightColor,\r\n normal,\r\n viewVec,\r\n commonData,\r\n diffuseScale,\r\n specularScale,\r\n sourceRadiusFactor,\r\n outColor\r\n );\r\n }\r\n get reflectionMode() {\r\n return this._reflectionMode;\r\n }\r\n set reflectionMode(val: PBRReflectionMode) {\r\n if (val !== this._reflectionMode) {\r\n this._reflectionMode = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get anisotropy() {\r\n return this._anisotropy;\r\n }\r\n set anisotropy(val) {\r\n const clamped = Math.max(-0.95, Math.min(0.95, val));\r\n if (clamped !== this._anisotropy) {\r\n this._anisotropy = clamped;\r\n this.uniformChanged();\r\n }\r\n }\r\n get anisotropyDirection() {\r\n return this._anisotropyDirection;\r\n }\r\n set anisotropyDirection(val) {\r\n if (val !== this._anisotropyDirection) {\r\n this._anisotropyDirection = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get anisotropyDirectionScaleBias(): Immutable<Vector2> {\r\n return this._anisotropyDirectionScaleBias;\r\n }\r\n set anisotropyDirectionScaleBias(val: Immutable<Vector2>) {\r\n if (!val.equalsTo(this._anisotropyDirectionScaleBias)) {\r\n this._anisotropyDirectionScaleBias.set(val);\r\n this.uniformChanged();\r\n }\r\n }\r\n calculateAnisotropyDirectionScaleBias(scope: PBInsideFunctionScope) {\r\n return scope.zAnisotropyDirectionScaleBias as PBShaderExp;\r\n }\r\n PBRLight(\r\n scope: PBInsideFunctionScope,\r\n worldPos: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n albedo: PBShaderExp,\r\n TBN: PBShaderExp,\r\n outRoughness?: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n const funcName = 'Z_PBRMetallicRoughnessLight';\r\n const that = this;\r\n pb.func(\r\n funcName,\r\n [\r\n pb.vec3('worldPos'),\r\n pb.vec3('normal'),\r\n pb.mat3('TBN'),\r\n pb.vec3('viewVec'),\r\n pb.vec4('albedo'),\r\n ...(outRoughness ? [pb.vec4('outRoughness').out()] : [])\r\n ],\r\n function () {\r\n this.$l.pbrData = that.getCommonData(this, this.albedo, this.normal, this.viewVec, this.TBN);\r\n this.$l.lightingColor = pb.vec3(0);\r\n this.$l.emissiveColor = that.calculateEmissiveColor(this);\r\n if (outRoughness) {\r\n that.indirectLighting(\r\n this,\r\n this.normal,\r\n this.viewVec,\r\n this.pbrData,\r\n this.lightingColor,\r\n this.outRoughness\r\n );\r\n } else {\r\n that.indirectLighting(this, this.normal, this.viewVec, this.pbrData, this.lightingColor);\r\n }\r\n that.forEachLight(this, function (type, posRange, dirCutoff, colorIntensity, extra, shadow) {\r\n this.$if(pb.equal(type, LIGHT_TYPE_RECT), function () {\r\n that.directRectLight(\r\n this,\r\n this.worldPos,\r\n this.normal,\r\n this.viewVec,\r\n this.pbrData,\r\n posRange,\r\n dirCutoff,\r\n extra,\r\n colorIntensity,\r\n this.lightingColor\r\n );\r\n }).$else(function () {\r\n this.$l.diffuse = pb.vec3();\r\n this.$l.specular = pb.vec3();\r\n this.$l.diffuseScale = pb.float(1);\r\n this.$l.specularScale = pb.float(1);\r\n this.$l.sourceRadiusFactor = pb.float(0);\r\n this.$if(pb.equal(type, LIGHT_TYPE_POINT), function () {\r\n this.diffuseScale = extra.x;\r\n this.specularScale = extra.y;\r\n this.sourceRadiusFactor = pb.div(\r\n extra.z,\r\n pb.max(pb.distance(posRange.xyz, this.worldPos), 0.0001)\r\n );\r\n });\r\n this.$l.lightAtten = that.calculateLightAttenuation(\r\n this,\r\n type,\r\n this.worldPos,\r\n posRange,\r\n dirCutoff\r\n );\r\n this.$l.lightDir = that.calculateLightDirection(this, type, this.worldPos, posRange, dirCutoff);\r\n this.$l.NoL = pb.clamp(pb.dot(this.normal, this.lightDir), 0, 1);\r\n this.$l.lightColor = pb.mul(colorIntensity.rgb, colorIntensity.a, this.lightAtten, this.NoL);\r\n if (shadow) {\r\n this.lightColor = pb.mul(\r\n this.lightColor,\r\n that.calculateShadow(this, this.worldPos, this.NoL)\r\n );\r\n }\r\n that.directLighting(\r\n this,\r\n this.lightDir,\r\n this.lightColor,\r\n this.normal,\r\n this.viewVec,\r\n this.pbrData,\r\n this.diffuseScale,\r\n this.specularScale,\r\n this.sourceRadiusFactor,\r\n this.lightingColor\r\n );\r\n });\r\n });\r\n this.$return(pb.add(this.lightingColor, this.emissiveColor));\r\n }\r\n );\r\n return (\r\n outRoughness\r\n ? pb.getGlobalScope()[funcName](worldPos, normal, TBN, viewVec, albedo, outRoughness)\r\n : pb.getGlobalScope()[funcName](worldPos, normal, TBN, viewVec, albedo)\r\n ) as PBShaderExp;\r\n }\r\n vertexShader(scope: PBFunctionScope) {\r\n super.vertexShader(scope);\r\n if (this.needFragmentColor() && this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING) {\r\n scope.$outputs.zMetallic = this.getInstancedUniform(scope, METALLIC_UNIFORM);\r\n scope.$outputs.zRoughness = this.getInstancedUniform(scope, ROUGHNESS_UNIFORM);\r\n scope.$outputs.zSpecularFactor = this.getInstancedUniform(scope, SPECULAR_FACTOR_UNFORM);\r\n }\r\n }\r\n fragmentShader(scope: PBFunctionScope) {\r\n super.fragmentShader(scope);\r\n if (this.needFragmentColor()) {\r\n const pb = scope.$builder;\r\n if (!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING)) {\r\n scope.zMetallic = pb.float().uniform(2);\r\n scope.zRoughness = pb.float().uniform(2);\r\n scope.zSpecularFactor = pb.vec4().uniform(2);\r\n }\r\n scope.zReflectionMode = pb.float().uniform(2);\r\n scope.zAnisotropy = pb.float().uniform(2);\r\n scope.zAnisotropyDirection = pb.float().uniform(2);\r\n scope.zAnisotropyDirectionScaleBias = pb.vec2().uniform(2);\r\n }\r\n }\r\n applyUniformValues(bindGroup: BindGroup, ctx: DrawContext, pass: number) {\r\n super.applyUniformValues(bindGroup, ctx, pass);\r\n if (this.needFragmentColor(ctx)) {\r\n if (!(ctx.materialFlags & MaterialVaryingFlags.INSTANCING)) {\r\n bindGroup.setValue('zMetallic', this._metallic);\r\n bindGroup.setValue('zRoughness', this._roughness);\r\n bindGroup.setValue('zSpecularFactor', this._specularFactor);\r\n bindGroup.setValue('zReflectionMode', PBR_REFLECTION_MODE[this._reflectionMode]);\r\n bindGroup.setValue('zAnisotropy', this._anisotropy);\r\n bindGroup.setValue('zAnisotropyDirection', this._anisotropyDirection);\r\n bindGroup.setValue('zAnisotropyDirectionScaleBias', this._anisotropyDirectionScaleBias);\r\n }\r\n }\r\n }\r\n calculateMetallic(scope: PBInsideFunctionScope, _albedo: PBShaderExp, _normal: PBShaderExp) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zMetallic : scope.zMetallic) as PBShaderExp;\r\n }\r\n calculateRoughness(scope: PBInsideFunctionScope, _albedo: PBShaderExp, _normal: PBShaderExp) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zRoughness : scope.zRoughness) as PBShaderExp;\r\n }\r\n calculateSpecularFactor(scope: PBInsideFunctionScope, _albedo: PBShaderExp, _normal: PBShaderExp) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zSpecularFactor : scope.zSpecularFactor) as PBShaderExp;\r\n }\r\n calculateCommonData(\r\n scope: PBInsideFunctionScope,\r\n albedo: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n TBN: PBShaderExp,\r\n data: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n const metallic = this.calculateMetallic(scope, albedo, normal);\r\n const roughness = this.calculateRoughness(scope, albedo, normal);\r\n const specularFactor = this.calculateSpecularFactor(scope, albedo, normal);\r\n const reflectionMode = this.calculateReflectionMode(scope) as PBShaderExp;\r\n if (this.metallicRoughnessTexture) {\r\n scope.$l.metallicRoughnessSample = this.sampleMetallicRoughnessTexture(scope);\r\n data.metallic = pb.mul(metallic, scope.metallicRoughnessSample.z);\r\n data.roughness = pb.mul(roughness, scope.metallicRoughnessSample.y);\r\n } else {\r\n data.metallic = metallic;\r\n data.roughness = roughness;\r\n }\r\n data.roughness = pb.mul(data.roughness, ShaderHelper.getCameraRoughnessFactor(scope));\r\n if (this.specularColorTexture) {\r\n scope.$l.specularColor = pb.mul(specularFactor.rgb, this.sampleSpecularColorTexture(scope).rgb);\r\n } else {\r\n scope.$l.specularColor = specularFactor.rgb;\r\n }\r\n if (this.specularTexture) {\r\n data.specularWeight = pb.mul(specularFactor.a, this.sampleSpecularTexture(scope).a);\r\n } else {\r\n data.specularWeight = specularFactor.a;\r\n }\r\n data.specularWeight = pb.mul(\r\n data.specularWeight,\r\n pb.float(pb.notEqual(reflectionMode, PBR_REFLECTION_MODE.none))\r\n );\r\n data.f0 = pb.vec4(\r\n pb.mix(\r\n pb.min(pb.mul(this.getF0(scope).rgb, scope.specularColor), pb.vec3(1)),\r\n albedo.rgb,\r\n data.metallic\r\n ),\r\n this.getF0(scope).a\r\n );\r\n data.f90 = pb.vec3(1);\r\n data.diffuse = pb.vec4(pb.mix(albedo.rgb, pb.vec3(0), data.metallic), albedo.a);\r\n super.calculateCommonData(scope, albedo, normal, viewVec, TBN, data);\r\n }\r\n calculateReflectionMode(scope: PBInsideFunctionScope) {\r\n return scope.zReflectionMode as PBShaderExp;\r\n }\r\n calculateAnisotropy(scope: PBInsideFunctionScope) {\r\n return scope.zAnisotropy as PBShaderExp;\r\n }\r\n calculateAnisotropyDirection(scope: PBInsideFunctionScope) {\r\n return scope.zAnisotropyDirection as PBShaderExp;\r\n }\r\n } as unknown as T & { new (...args: any[]): IMixinPBRMetallicRoughness };\r\n}\r\n"],"names":["PBR_REFLECTION_MODE","none","ggx","anisotropic","glint","mixinPBRMetallicRoughness","BaseCls","pbrMetallicRoughnessMixed","S","applyMaterialMixins","mixinPBRCommon","mixinLight","mixinTextureProps","METALLIC_UNIFORM","defineInstanceUniform","ROUGHNESS_UNIFORM","SPECULAR_FACTOR_UNFORM","_metallic","_roughness","_specularFactor","_reflectionMode","_anisotropy","_anisotropyDirection","_anisotropyDirectionScaleBias","Vector4","one","Vector2","copyFrom","other","metallic","roughness","specularFactor","reflectionMode","anisotropy","anisotropyDirection","anisotropyDirectionScaleBias","val","uniformChanged","equalsTo","set","directLighting","scope","lightDir","lightColor","normal","viewVec","commonData","diffuseScale","specularScale","sourceRadiusFactor","outColor","pb","$builder","that","funcName","func","vec3","getCommonDatasStruct","float","inout","$l","zReflectionMode","zAnisotropy","zAnisotropyDirection","zAnisotropyDirectionScaleBias","H","normalize","add","L","NoH","clamp","dot","NoL","NoV","$if","greaterThan","VoH","schlickFresnel","fresnelSchlick","data","f0","rgb","f90","iridescence","F","mix","iridescenceFresnel","iridescenceFactor","x","specularRoughness","alphaRoughness","mul","Dggx","distributionGGX","D","equal","dirAngle","Math","PI","anisotropyDirectionTexture","dirSample","sampleAnisotropyDirectionTexture","r","y","anisoAngle","up","t0","cross","lessThan","length","b0","tangent","cos","sin","bitangent","ToH","BoH","at","max","ab","sub","anisoDenom","pow","div","$elseif","glintNoise","fract","glintMask","smoothStep","V","visGGX","specular","specularWeight","sheen","sheenAlbedoScaling","iridescenceFresnelMax","g","b","diffuseBRDF","diffuse","transmission","drawContext","renderPass","type","RENDER_PASS_TYPE_LIGHT","transmissionRay","getVolumeTransmissionRay","thicknessFactor","a","pointToLight","transmittedLight","getPunctualRadianceTransmission","applyVolumeAttenuation","attenuationColor","attenuationDistance","transmissionFactor","sheenD","D_Charlie","sheenRoughness","sheenV","V_Ashikhmin","sheenColor","clearcoat","ccFactor","ccNormal","ccF0","ccNoV","$g","clamped","min","calculateAnisotropyDirectionScaleBias","PBRLight","worldPos","albedo","TBN","outRoughness","mat3","vec4","out","pbrData","getCommonData","lightingColor","emissiveColor","calculateEmissiveColor","indirectLighting","forEachLight","posRange","dirCutoff","colorIntensity","extra","shadow","LIGHT_TYPE_RECT","directRectLight","$else","LIGHT_TYPE_POINT","z","distance","xyz","lightAtten","calculateLightAttenuation","calculateLightDirection","calculateShadow","$return","getGlobalScope","vertexShader","needFragmentColor","materialFlags","MaterialVaryingFlags","INSTANCING","$outputs","zMetallic","getInstancedUniform","zRoughness","zSpecularFactor","fragmentShader","uniform","vec2","applyUniformValues","bindGroup","ctx","pass","setValue","calculateMetallic","_albedo","_normal","instancing","$inputs","calculateRoughness","calculateSpecularFactor","calculateCommonData","calculateReflectionMode","metallicRoughnessTexture","metallicRoughnessSample","sampleMetallicRoughnessTexture","ShaderHelper","getCameraRoughnessFactor","specularColorTexture","specularColor","sampleSpecularColorTexture","specularTexture","sampleSpecularTexture","notEqual","getF0","calculateAnisotropy","calculateAnisotropyDirection"],"mappings":";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AC,CAAA,CAAA,EAAIuB,KAAKlD,QAAQ,CAAA,EAAGgJ,OAAOzB,CAAC,CAAA;AAC9E,YAAA,KAAK,CAACiF,mBAAoB5L,CAAAA,KAAAA,EAAOoI,MAAQjI,EAAAA,MAAAA,EAAQC,SAASiI,GAAK/F,EAAAA,IAAAA,CAAAA;AACjE;AACAuJ,QAAAA,uBAAAA,CAAwB7L,KAA4B,EAAE;AACpD,YAAA,OAAOA,MAAMoB,eAAe;AAC9B;AACAsL,QAAAA,mBAAAA,CAAoB1M,KAA4B,EAAE;AAChD,YAAA,OAAOA,MAAMqB,WAAW;AAC1B;AACAsL,QAAAA,4BAAAA,CAA6B3M,KAA4B,EAAE;AACzD,YAAA,OAAOA,MAAMsB,oBAAoB;AACnC;AACF,KAAA;AACF;;;;"}
|
package/dist/material/sprite.js
CHANGED
|
@@ -11,9 +11,9 @@ import { Vector4 } from '@zephyr3d/base';
|
|
|
11
11
|
* using UV information and an anchor point to control how the sprite
|
|
12
12
|
* is positioned and textured.
|
|
13
13
|
*
|
|
14
|
-
* Derived classes can override
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* Derived classes can override `internalSetupUniforms()`,
|
|
15
|
+
* `internalApplyUniforms()`, and
|
|
16
|
+
* `calcFragmentColor()` to provide custom
|
|
17
17
|
* uniforms and shading logic (e.g. sampling a texture).
|
|
18
18
|
*
|
|
19
19
|
* @public
|
|
@@ -210,9 +210,9 @@ import { Vector4 } from '@zephyr3d/base';
|
|
|
210
210
|
* @remarks
|
|
211
211
|
* This method:
|
|
212
212
|
* - Calls the base implementation.
|
|
213
|
-
* - Invokes
|
|
213
|
+
* - Invokes `internalSetupUniforms()` for
|
|
214
214
|
* fragment-stage specific uniform declarations.
|
|
215
|
-
* - Computes fragment color by calling
|
|
215
|
+
* - Computes fragment color by calling `calcFragmentColor()`
|
|
216
216
|
* if fragment color is needed.
|
|
217
217
|
* - Outputs the final fragment color via {@link MeshMaterial.outputFragmentColor}.
|
|
218
218
|
*
|
|
@@ -238,7 +238,7 @@ import { Vector4 } from '@zephyr3d/base';
|
|
|
238
238
|
* for non-instanced rendering. For instanced rendering, these values
|
|
239
239
|
* are expected to be provided as per-instance uniforms instead.
|
|
240
240
|
*
|
|
241
|
-
* It also calls
|
|
241
|
+
* It also calls `internalApplyUniforms()` to allow
|
|
242
242
|
* derived classes to bind additional resources (e.g. textures).
|
|
243
243
|
*
|
|
244
244
|
* @param bindGroup - The bind group to which uniforms and resources are bound.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sprite.js","sources":["../../src/material/sprite.ts"],"sourcesContent":["import { MeshMaterial } from './meshmaterial';\r\nimport type { BindGroup, PBFunctionScope, PBInsideFunctionScope } from '@zephyr3d/device';\r\nimport { ShaderHelper } from './shader/helper';\r\nimport { MaterialVaryingFlags } from '../values';\r\nimport type { Clonable, Immutable, Vector2 } from '@zephyr3d/base';\r\nimport { Vector4 } from '@zephyr3d/base';\r\nimport type { DrawContext } from '../render';\r\n\r\n/**\r\n * Sprite material base class.\r\n *\r\n * @remarks\r\n * This material renders a camera-facing quad (billboard) in 3D space,\r\n * using UV information and an anchor point to control how the sprite\r\n * is positioned and textured.\r\n *\r\n * Derived classes can override {@link internalSetupUniforms},\r\n * {@link internalApplyUniforms} and\r\n * {@link calcFragmentColor} to provide custom\r\n * uniforms and shading logic (e.g. sampling a texture).\r\n *\r\n * @public\r\n */\r\nexport class SpriteMaterial extends MeshMaterial implements Clonable<SpriteMaterial> {\r\n static UVINFO = this.defineInstanceUniform('uvinfo', 'vec4');\r\n static ANCHOR_ROTATION = this.defineInstanceUniform('anchorRotation', 'vec4');\r\n private _uvinfo: Vector4;\r\n private _anchorRotation: Vector4;\r\n /**\r\n * Creates a new {@link SpriteMaterial} instance.\r\n *\r\n * @remarks\r\n * - Default UV rectangle is the full texture [0, 0, 1, 1].\r\n * - Default anchor is the center [0.5, 0.5].\r\n * - Face culling is disabled (`cullMode = 'none'`) so the sprite\r\n * is visible from both sides.\r\n */\r\n constructor() {\r\n super();\r\n this._uvinfo = new Vector4(0, 0, 1, 1);\r\n this._anchorRotation = new Vector4(0.5, 0.5, 0, 0);\r\n this.cullMode = 'none';\r\n }\r\n /**\r\n * Gets the UV rectangle of the sprite in the texture.\r\n *\r\n * @returns A Vector4 storing \\([u0, v0, u1, v1]\\).\r\n */\r\n get uvinfo(): Immutable<Vector4> {\r\n return this._uvinfo;\r\n }\r\n set uvinfo(value: Immutable<Vector4>) {\r\n if (!value.equalsTo(this.uvinfo)) {\r\n this._uvinfo.set(value);\r\n this.uniformChanged();\r\n }\r\n }\r\n /**\r\n * Convenience method to set the UV rectangle via individual components.\r\n *\r\n * @param uvx0 - Left (U) coordinate.\r\n * @param uvy0 - Bottom (V) coordinate.\r\n * @param uvx1 - Right (U) coordinate.\r\n * @param uvy1 - Top (V) coordinate.\r\n */\r\n setUVInfo(uvx0: number, uvy0: number, uvx1: number, uvy1: number) {\r\n this.uvinfo = new Vector4(uvx0, uvy0, uvx1, uvy1);\r\n }\r\n /**\r\n * Gets the sprite anchor-rotation.\r\n *\r\n * @returns The current anchor-rotation.\r\n */\r\n get anchorRotation(): Immutable<Vector4> {\r\n return this._anchorRotation;\r\n }\r\n set anchorRotation(value: Immutable<Vector4>) {\r\n if (!value.equalsTo(this._anchorRotation)) {\r\n this._anchorRotation.set(value);\r\n this.uniformChanged();\r\n }\r\n }\r\n /**\r\n * Gets the sprite anchor point in normalized quad space.\r\n *\r\n * @returns The current anchor as a Vector2.\r\n */\r\n get anchor(): Immutable<Vector2> {\r\n return this._anchorRotation.xy();\r\n }\r\n set anchor(value: Immutable<Vector2>) {\r\n if (value.x !== this._anchorRotation.x || value.y !== this._anchorRotation.y) {\r\n this.anchorRotation = new Vector4(value.x, value.y, this._anchorRotation.z, this._anchorRotation.w);\r\n }\r\n }\r\n /**\r\n * Gets the sprite rotation around the Z axis.\r\n *\r\n * @returns The sprite rotation.\r\n */\r\n get rotation() {\r\n return this._anchorRotation.z;\r\n }\r\n set rotation(value) {\r\n if (value !== this._anchorRotation.z) {\r\n this.anchorRotation = new Vector4(\r\n this._anchorRotation.x,\r\n this._anchorRotation.y,\r\n value,\r\n this._anchorRotation.w\r\n );\r\n }\r\n }\r\n /**\r\n * Gets the X component of the sprite anchor.\r\n */\r\n get anchorX() {\r\n return this._anchorRotation.x;\r\n }\r\n set anchorX(value) {\r\n if (this._anchorRotation.x !== value) {\r\n this.anchorRotation = new Vector4(\r\n value,\r\n this._anchorRotation.y,\r\n this._anchorRotation.z,\r\n this._anchorRotation.w\r\n );\r\n }\r\n }\r\n /**\r\n * Gets the Y component of the sprite anchor.\r\n */\r\n get anchorY() {\r\n return this._anchorRotation.y;\r\n }\r\n set anchorY(value) {\r\n if (this._anchorRotation.y !== value) {\r\n this.anchorRotation = new Vector4(\r\n this._anchorRotation.x,\r\n value,\r\n this._anchorRotation.z,\r\n this._anchorRotation.w\r\n );\r\n }\r\n }\r\n /**\r\n * Convenience method to set both anchor components at once.\r\n *\r\n * @param anchorX - X coordinate of the anchor.\r\n * @param anchorY - Y coordinate of the anchor.\r\n */\r\n setAnchor(anchorX: number, anchorY: number) {\r\n if (this._anchorRotation.x !== anchorX || this._anchorRotation.y !== anchorY) {\r\n this.anchorRotation = new Vector4(anchorX, anchorY, this._anchorRotation.z, this._anchorRotation.w);\r\n }\r\n }\r\n /**\r\n * Creates a deep copy of this material.\r\n *\r\n * @returns A new {@link SpriteMaterial} instance with the same properties.\r\n */\r\n clone() {\r\n const other = new SpriteMaterial();\r\n other.copyFrom(this);\r\n return other;\r\n }\r\n /**\r\n * Copies all relevant state from another {@link SpriteMaterial}.\r\n *\r\n * @param other - The source material to copy from.\r\n */\r\n copyFrom(other: this) {\r\n super.copyFrom(other);\r\n this.uvinfo = other.uvinfo;\r\n this.anchorRotation = other.anchorRotation;\r\n }\r\n /**\r\n * Builds the vertex shader for this material.\r\n *\r\n * @remarks\r\n * This method:\r\n * - Calls the base implementation.\r\n * - Computes per-vertex positions for a camera-facing quad (billboard)\r\n * based on the sprite's world transform, size, and anchor.\r\n * - Selects the correct UV coordinates for each quad corner using\r\n * the `vertexId` attribute.\r\n * - Outputs world-space position (`zWorldPos`) and UVs (`zVertexUV`)\r\n * for use in the fragment shader.\r\n *\r\n * @param scope - The current programmable builder function scope.\r\n */\r\n vertexShader(scope: PBFunctionScope) {\r\n super.vertexShader(scope);\r\n const pb = scope.$builder;\r\n scope.$inputs.vertexId = pb.float().attrib('position');\r\n if (this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING) {\r\n scope.$l.uvinfo = this.getInstancedUniform(scope, SpriteMaterial.UVINFO);\r\n scope.$l.anchorRotation = this.getInstancedUniform(scope, SpriteMaterial.ANCHOR_ROTATION);\r\n } else {\r\n scope.uvinfo = pb.vec4().uniform(2);\r\n scope.anchorRotation = pb.vec4().uniform(2);\r\n }\r\n this.internalSetupUniforms(scope);\r\n scope.$l.worldPos = ShaderHelper.getWorldMatrix(scope)[3].xyz;\r\n scope.$l.width = pb.sqrt(\r\n pb.dot(ShaderHelper.getWorldMatrix(scope)[0].xyz, ShaderHelper.getWorldMatrix(scope)[0].xyz)\r\n );\r\n scope.$l.height = pb.sqrt(\r\n pb.dot(ShaderHelper.getWorldMatrix(scope)[1].xyz, ShaderHelper.getWorldMatrix(scope)[1].xyz)\r\n );\r\n const viewMatrix = ShaderHelper.getViewMatrix(scope);\r\n scope.$l.forward = pb.vec3(viewMatrix[0].z, viewMatrix[1].z, viewMatrix[2].z);\r\n scope.$l.axis = scope.$choice(\r\n pb.lessThan(pb.abs(scope.forward.y), 0.999),\r\n pb.vec3(0, 1, 0),\r\n pb.vec3(1, 0, 0)\r\n );\r\n scope.$l.right = pb.normalize(pb.cross(scope.axis, scope.forward));\r\n scope.$l.up = pb.normalize(pb.cross(scope.forward, scope.right));\r\n scope.$l.rotateAngle = scope.anchorRotation.z;\r\n scope.$l.c = pb.cos(scope.rotateAngle);\r\n scope.$l.s = pb.sin(scope.rotateAngle);\r\n scope.$l.rightRot = pb.add(pb.mul(scope.up, scope.s), pb.mul(scope.right, scope.c));\r\n scope.$l.upRot = pb.sub(pb.mul(scope.up, scope.c), pb.mul(scope.right, scope.s));\r\n scope.$l.v = pb.vec2();\r\n scope.$l.uv = pb.vec2();\r\n scope.$l.anchor = scope.anchorRotation.xy;\r\n scope\r\n .$if(pb.equal(scope.$inputs.vertexId, 0), function () {\r\n scope.v = pb.neg(scope.anchor);\r\n scope.uv = pb.vec2(scope.uvinfo.x, pb.sub(1, scope.uvinfo.y));\r\n })\r\n .$elseif(pb.equal(scope.$inputs.vertexId, 1), function () {\r\n scope.v = pb.sub(pb.vec2(1, 0), scope.anchor);\r\n scope.uv = pb.vec2(scope.uvinfo.z, pb.sub(1, scope.uvinfo.y));\r\n })\r\n .$elseif(pb.equal(scope.$inputs.vertexId, 2), function () {\r\n scope.v = pb.sub(pb.vec2(0, 1), scope.anchor);\r\n scope.uv = pb.vec2(scope.uvinfo.x, pb.sub(1, scope.uvinfo.w));\r\n })\r\n .$else(function () {\r\n scope.v = pb.sub(pb.vec2(1), scope.anchor);\r\n scope.uv = pb.vec2(scope.uvinfo.z, pb.sub(1, scope.uvinfo.w));\r\n });\r\n scope.v = pb.mul(scope.v, pb.vec2(scope.width, scope.height));\r\n scope.$outputs.zWorldPos = pb.add(\r\n scope.worldPos,\r\n pb.mul(scope.rightRot, scope.v.x),\r\n pb.mul(scope.upRot, scope.v.y)\r\n );\r\n scope.$outputs.zVertexUV = scope.uv;\r\n ShaderHelper.setClipSpacePosition(\r\n scope,\r\n pb.mul(ShaderHelper.getViewProjectionMatrix(scope), pb.vec4(scope.$outputs.zWorldPos, 1))\r\n );\r\n }\r\n /**\r\n * Builds the fragment shader for this material.\r\n *\r\n * @remarks\r\n * This method:\r\n * - Calls the base implementation.\r\n * - Invokes {@link SpriteMaterial.internalSetupUniforms} for\r\n * fragment-stage specific uniform declarations.\r\n * - Computes fragment color by calling {@link SpriteMaterial.calcFragmentColor}\r\n * if fragment color is needed.\r\n * - Outputs the final fragment color via {@link MeshMaterial.outputFragmentColor}.\r\n *\r\n * @param scope - The current programmable builder function scope.\r\n */\r\n fragmentShader(scope: PBFunctionScope) {\r\n super.fragmentShader(scope);\r\n this.internalSetupUniforms(scope);\r\n if (this.needFragmentColor()) {\r\n scope.$l.color = this.calcFragmentColor(scope);\r\n this.outputFragmentColor(scope, scope.$inputs.zWorldPos, scope.color);\r\n } else {\r\n this.outputFragmentColor(scope, scope.$inputs.zWorldPos, null);\r\n }\r\n }\r\n /**\r\n * Applies runtime uniform values to the given bind group before drawing.\r\n *\r\n * @remarks\r\n * This binds:\r\n * - UV information (`uvinfo`)\r\n * - Anchor (`anchor`)\r\n *\r\n * for non-instanced rendering. For instanced rendering, these values\r\n * are expected to be provided as per-instance uniforms instead.\r\n *\r\n * It also calls {@link SpriteMaterial.internalApplyUniforms} to allow\r\n * derived classes to bind additional resources (e.g. textures).\r\n *\r\n * @param bindGroup - The bind group to which uniforms and resources are bound.\r\n * @param ctx - The current draw context providing rendering state.\r\n * @param pass - Index of the active render pass.\r\n */\r\n applyUniformValues(bindGroup: BindGroup, ctx: DrawContext, pass: number) {\r\n super.applyUniformValues(bindGroup, ctx, pass);\r\n if (!(ctx.materialFlags & MaterialVaryingFlags.INSTANCING)) {\r\n bindGroup.setValue('uvinfo', this._uvinfo);\r\n bindGroup.setValue('anchorRotation', this._anchorRotation);\r\n }\r\n this.internalApplyUniforms(bindGroup, ctx, pass);\r\n }\r\n /**\r\n * Hook for derived classes to declare additional uniforms.\r\n *\r\n * @remarks\r\n * This is invoked in both the vertex and fragment shader construction\r\n * phases, allowing subclasses to register extra uniforms or resources\r\n * needed by their custom shading logic.\r\n *\r\n * The base implementation does nothing.\r\n *\r\n * @param _scope - The current shader function scope.\r\n */\r\n protected internalSetupUniforms(_scope: PBInsideFunctionScope) {}\r\n /**\r\n * Hook for derived classes to bind additional uniform values or resources.\r\n *\r\n * @remarks\r\n * This is called from {@link SpriteMaterial.applyUniformValues} and is\r\n * intended for subclasses to bind their own textures, samplers, or\r\n * other GPU resources.\r\n *\r\n * The base implementation does nothing.\r\n *\r\n * @param _bindGroup - The bind group used for binding uniforms and resources.\r\n * @param _ctx - The current draw context.\r\n * @param _pass - Index of the active render pass.\r\n */\r\n protected internalApplyUniforms(_bindGroup: BindGroup, _ctx: DrawContext, _pass: number) {}\r\n /**\r\n * Computes the fragment color expression for this material.\r\n *\r\n * @remarks\r\n * The default implementation simply outputs the interpolated UV\r\n * coordinates as color \\([u, v, 0, 1]\\), which is mainly useful\r\n * for debugging.\r\n *\r\n * Derived classes are expected to override this method to implement\r\n * actual shading, such as sampling a texture.\r\n *\r\n * @param scope - The current shader function scope.\r\n * @returns A shader expression representing the fragment color.\r\n\r\n */\r\n protected calcFragmentColor(scope: PBInsideFunctionScope) {\r\n return scope.$builder.vec4(scope.$inputs.zVertexUV, 0, 1);\r\n }\r\n}\r\n"],"names":["SpriteMaterial","MeshMaterial","UVINFO","defineInstanceUniform","ANCHOR_ROTATION","_uvinfo","_anchorRotation","Vector4","cullMode","uvinfo","value","equalsTo","set","uniformChanged","setUVInfo","uvx0","uvy0","uvx1","uvy1","anchorRotation","anchor","xy","x","y","z","w","rotation","anchorX","anchorY","setAnchor","clone","other","copyFrom","vertexShader","scope","pb","$builder","$inputs","vertexId","float","attrib","drawContext","materialFlags","MaterialVaryingFlags","INSTANCING","$l","getInstancedUniform","vec4","uniform","internalSetupUniforms","worldPos","ShaderHelper","getWorldMatrix","xyz","width","sqrt","dot","height","viewMatrix","getViewMatrix","forward","vec3","axis","$choice","lessThan","abs","right","normalize","cross","up","rotateAngle","c","cos","s","sin","rightRot","add","mul","upRot","sub","v","vec2","uv","$if","equal","neg","$elseif","$else","$outputs","zWorldPos","zVertexUV","setClipSpacePosition","getViewProjectionMatrix","fragmentShader","needFragmentColor","color","calcFragmentColor","outputFragmentColor","applyUniformValues","bindGroup","ctx","pass","setValue","internalApplyUniforms","_scope","_bindGroup","_ctx","_pass"],"mappings":";;;;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EAAE,CAAG,EAAA,CAAA,CAAA;AACzD;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"sprite.js","sources":["../../src/material/sprite.ts"],"sourcesContent":["import { MeshMaterial } from './meshmaterial';\r\nimport type { BindGroup, PBFunctionScope, PBInsideFunctionScope } from '@zephyr3d/device';\r\nimport { ShaderHelper } from './shader/helper';\r\nimport { MaterialVaryingFlags } from '../values';\r\nimport type { Clonable, Immutable, Vector2 } from '@zephyr3d/base';\r\nimport { Vector4 } from '@zephyr3d/base';\r\nimport type { DrawContext } from '../render';\r\n\r\n/**\r\n * Sprite material base class.\r\n *\r\n * @remarks\r\n * This material renders a camera-facing quad (billboard) in 3D space,\r\n * using UV information and an anchor point to control how the sprite\r\n * is positioned and textured.\r\n *\r\n * Derived classes can override `internalSetupUniforms()`,\r\n * `internalApplyUniforms()`, and\r\n * `calcFragmentColor()` to provide custom\r\n * uniforms and shading logic (e.g. sampling a texture).\r\n *\r\n * @public\r\n */\r\nexport class SpriteMaterial extends MeshMaterial implements Clonable<SpriteMaterial> {\r\n static UVINFO = this.defineInstanceUniform('uvinfo', 'vec4');\r\n static ANCHOR_ROTATION = this.defineInstanceUniform('anchorRotation', 'vec4');\r\n private _uvinfo: Vector4;\r\n private _anchorRotation: Vector4;\r\n /**\r\n * Creates a new {@link SpriteMaterial} instance.\r\n *\r\n * @remarks\r\n * - Default UV rectangle is the full texture [0, 0, 1, 1].\r\n * - Default anchor is the center [0.5, 0.5].\r\n * - Face culling is disabled (`cullMode = 'none'`) so the sprite\r\n * is visible from both sides.\r\n */\r\n constructor() {\r\n super();\r\n this._uvinfo = new Vector4(0, 0, 1, 1);\r\n this._anchorRotation = new Vector4(0.5, 0.5, 0, 0);\r\n this.cullMode = 'none';\r\n }\r\n /**\r\n * Gets the UV rectangle of the sprite in the texture.\r\n *\r\n * @returns A Vector4 storing \\([u0, v0, u1, v1]\\).\r\n */\r\n get uvinfo(): Immutable<Vector4> {\r\n return this._uvinfo;\r\n }\r\n set uvinfo(value: Immutable<Vector4>) {\r\n if (!value.equalsTo(this.uvinfo)) {\r\n this._uvinfo.set(value);\r\n this.uniformChanged();\r\n }\r\n }\r\n /**\r\n * Convenience method to set the UV rectangle via individual components.\r\n *\r\n * @param uvx0 - Left (U) coordinate.\r\n * @param uvy0 - Bottom (V) coordinate.\r\n * @param uvx1 - Right (U) coordinate.\r\n * @param uvy1 - Top (V) coordinate.\r\n */\r\n setUVInfo(uvx0: number, uvy0: number, uvx1: number, uvy1: number) {\r\n this.uvinfo = new Vector4(uvx0, uvy0, uvx1, uvy1);\r\n }\r\n /**\r\n * Gets the sprite anchor-rotation.\r\n *\r\n * @returns The current anchor-rotation.\r\n */\r\n get anchorRotation(): Immutable<Vector4> {\r\n return this._anchorRotation;\r\n }\r\n set anchorRotation(value: Immutable<Vector4>) {\r\n if (!value.equalsTo(this._anchorRotation)) {\r\n this._anchorRotation.set(value);\r\n this.uniformChanged();\r\n }\r\n }\r\n /**\r\n * Gets the sprite anchor point in normalized quad space.\r\n *\r\n * @returns The current anchor as a Vector2.\r\n */\r\n get anchor(): Immutable<Vector2> {\r\n return this._anchorRotation.xy();\r\n }\r\n set anchor(value: Immutable<Vector2>) {\r\n if (value.x !== this._anchorRotation.x || value.y !== this._anchorRotation.y) {\r\n this.anchorRotation = new Vector4(value.x, value.y, this._anchorRotation.z, this._anchorRotation.w);\r\n }\r\n }\r\n /**\r\n * Gets the sprite rotation around the Z axis.\r\n *\r\n * @returns The sprite rotation.\r\n */\r\n get rotation() {\r\n return this._anchorRotation.z;\r\n }\r\n set rotation(value) {\r\n if (value !== this._anchorRotation.z) {\r\n this.anchorRotation = new Vector4(\r\n this._anchorRotation.x,\r\n this._anchorRotation.y,\r\n value,\r\n this._anchorRotation.w\r\n );\r\n }\r\n }\r\n /**\r\n * Gets the X component of the sprite anchor.\r\n */\r\n get anchorX() {\r\n return this._anchorRotation.x;\r\n }\r\n set anchorX(value) {\r\n if (this._anchorRotation.x !== value) {\r\n this.anchorRotation = new Vector4(\r\n value,\r\n this._anchorRotation.y,\r\n this._anchorRotation.z,\r\n this._anchorRotation.w\r\n );\r\n }\r\n }\r\n /**\r\n * Gets the Y component of the sprite anchor.\r\n */\r\n get anchorY() {\r\n return this._anchorRotation.y;\r\n }\r\n set anchorY(value) {\r\n if (this._anchorRotation.y !== value) {\r\n this.anchorRotation = new Vector4(\r\n this._anchorRotation.x,\r\n value,\r\n this._anchorRotation.z,\r\n this._anchorRotation.w\r\n );\r\n }\r\n }\r\n /**\r\n * Convenience method to set both anchor components at once.\r\n *\r\n * @param anchorX - X coordinate of the anchor.\r\n * @param anchorY - Y coordinate of the anchor.\r\n */\r\n setAnchor(anchorX: number, anchorY: number) {\r\n if (this._anchorRotation.x !== anchorX || this._anchorRotation.y !== anchorY) {\r\n this.anchorRotation = new Vector4(anchorX, anchorY, this._anchorRotation.z, this._anchorRotation.w);\r\n }\r\n }\r\n /**\r\n * Creates a deep copy of this material.\r\n *\r\n * @returns A new {@link SpriteMaterial} instance with the same properties.\r\n */\r\n clone() {\r\n const other = new SpriteMaterial();\r\n other.copyFrom(this);\r\n return other;\r\n }\r\n /**\r\n * Copies all relevant state from another {@link SpriteMaterial}.\r\n *\r\n * @param other - The source material to copy from.\r\n */\r\n copyFrom(other: this) {\r\n super.copyFrom(other);\r\n this.uvinfo = other.uvinfo;\r\n this.anchorRotation = other.anchorRotation;\r\n }\r\n /**\r\n * Builds the vertex shader for this material.\r\n *\r\n * @remarks\r\n * This method:\r\n * - Calls the base implementation.\r\n * - Computes per-vertex positions for a camera-facing quad (billboard)\r\n * based on the sprite's world transform, size, and anchor.\r\n * - Selects the correct UV coordinates for each quad corner using\r\n * the `vertexId` attribute.\r\n * - Outputs world-space position (`zWorldPos`) and UVs (`zVertexUV`)\r\n * for use in the fragment shader.\r\n *\r\n * @param scope - The current programmable builder function scope.\r\n */\r\n vertexShader(scope: PBFunctionScope) {\r\n super.vertexShader(scope);\r\n const pb = scope.$builder;\r\n scope.$inputs.vertexId = pb.float().attrib('position');\r\n if (this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING) {\r\n scope.$l.uvinfo = this.getInstancedUniform(scope, SpriteMaterial.UVINFO);\r\n scope.$l.anchorRotation = this.getInstancedUniform(scope, SpriteMaterial.ANCHOR_ROTATION);\r\n } else {\r\n scope.uvinfo = pb.vec4().uniform(2);\r\n scope.anchorRotation = pb.vec4().uniform(2);\r\n }\r\n this.internalSetupUniforms(scope);\r\n scope.$l.worldPos = ShaderHelper.getWorldMatrix(scope)[3].xyz;\r\n scope.$l.width = pb.sqrt(\r\n pb.dot(ShaderHelper.getWorldMatrix(scope)[0].xyz, ShaderHelper.getWorldMatrix(scope)[0].xyz)\r\n );\r\n scope.$l.height = pb.sqrt(\r\n pb.dot(ShaderHelper.getWorldMatrix(scope)[1].xyz, ShaderHelper.getWorldMatrix(scope)[1].xyz)\r\n );\r\n const viewMatrix = ShaderHelper.getViewMatrix(scope);\r\n scope.$l.forward = pb.vec3(viewMatrix[0].z, viewMatrix[1].z, viewMatrix[2].z);\r\n scope.$l.axis = scope.$choice(\r\n pb.lessThan(pb.abs(scope.forward.y), 0.999),\r\n pb.vec3(0, 1, 0),\r\n pb.vec3(1, 0, 0)\r\n );\r\n scope.$l.right = pb.normalize(pb.cross(scope.axis, scope.forward));\r\n scope.$l.up = pb.normalize(pb.cross(scope.forward, scope.right));\r\n scope.$l.rotateAngle = scope.anchorRotation.z;\r\n scope.$l.c = pb.cos(scope.rotateAngle);\r\n scope.$l.s = pb.sin(scope.rotateAngle);\r\n scope.$l.rightRot = pb.add(pb.mul(scope.up, scope.s), pb.mul(scope.right, scope.c));\r\n scope.$l.upRot = pb.sub(pb.mul(scope.up, scope.c), pb.mul(scope.right, scope.s));\r\n scope.$l.v = pb.vec2();\r\n scope.$l.uv = pb.vec2();\r\n scope.$l.anchor = scope.anchorRotation.xy;\r\n scope\r\n .$if(pb.equal(scope.$inputs.vertexId, 0), function () {\r\n scope.v = pb.neg(scope.anchor);\r\n scope.uv = pb.vec2(scope.uvinfo.x, pb.sub(1, scope.uvinfo.y));\r\n })\r\n .$elseif(pb.equal(scope.$inputs.vertexId, 1), function () {\r\n scope.v = pb.sub(pb.vec2(1, 0), scope.anchor);\r\n scope.uv = pb.vec2(scope.uvinfo.z, pb.sub(1, scope.uvinfo.y));\r\n })\r\n .$elseif(pb.equal(scope.$inputs.vertexId, 2), function () {\r\n scope.v = pb.sub(pb.vec2(0, 1), scope.anchor);\r\n scope.uv = pb.vec2(scope.uvinfo.x, pb.sub(1, scope.uvinfo.w));\r\n })\r\n .$else(function () {\r\n scope.v = pb.sub(pb.vec2(1), scope.anchor);\r\n scope.uv = pb.vec2(scope.uvinfo.z, pb.sub(1, scope.uvinfo.w));\r\n });\r\n scope.v = pb.mul(scope.v, pb.vec2(scope.width, scope.height));\r\n scope.$outputs.zWorldPos = pb.add(\r\n scope.worldPos,\r\n pb.mul(scope.rightRot, scope.v.x),\r\n pb.mul(scope.upRot, scope.v.y)\r\n );\r\n scope.$outputs.zVertexUV = scope.uv;\r\n ShaderHelper.setClipSpacePosition(\r\n scope,\r\n pb.mul(ShaderHelper.getViewProjectionMatrix(scope), pb.vec4(scope.$outputs.zWorldPos, 1))\r\n );\r\n }\r\n /**\r\n * Builds the fragment shader for this material.\r\n *\r\n * @remarks\r\n * This method:\r\n * - Calls the base implementation.\r\n * - Invokes `internalSetupUniforms()` for\r\n * fragment-stage specific uniform declarations.\r\n * - Computes fragment color by calling `calcFragmentColor()`\r\n * if fragment color is needed.\r\n * - Outputs the final fragment color via {@link MeshMaterial.outputFragmentColor}.\r\n *\r\n * @param scope - The current programmable builder function scope.\r\n */\r\n fragmentShader(scope: PBFunctionScope) {\r\n super.fragmentShader(scope);\r\n this.internalSetupUniforms(scope);\r\n if (this.needFragmentColor()) {\r\n scope.$l.color = this.calcFragmentColor(scope);\r\n this.outputFragmentColor(scope, scope.$inputs.zWorldPos, scope.color);\r\n } else {\r\n this.outputFragmentColor(scope, scope.$inputs.zWorldPos, null);\r\n }\r\n }\r\n /**\r\n * Applies runtime uniform values to the given bind group before drawing.\r\n *\r\n * @remarks\r\n * This binds:\r\n * - UV information (`uvinfo`)\r\n * - Anchor (`anchor`)\r\n *\r\n * for non-instanced rendering. For instanced rendering, these values\r\n * are expected to be provided as per-instance uniforms instead.\r\n *\r\n * It also calls `internalApplyUniforms()` to allow\r\n * derived classes to bind additional resources (e.g. textures).\r\n *\r\n * @param bindGroup - The bind group to which uniforms and resources are bound.\r\n * @param ctx - The current draw context providing rendering state.\r\n * @param pass - Index of the active render pass.\r\n */\r\n applyUniformValues(bindGroup: BindGroup, ctx: DrawContext, pass: number) {\r\n super.applyUniformValues(bindGroup, ctx, pass);\r\n if (!(ctx.materialFlags & MaterialVaryingFlags.INSTANCING)) {\r\n bindGroup.setValue('uvinfo', this._uvinfo);\r\n bindGroup.setValue('anchorRotation', this._anchorRotation);\r\n }\r\n this.internalApplyUniforms(bindGroup, ctx, pass);\r\n }\r\n /**\r\n * Hook for derived classes to declare additional uniforms.\r\n *\r\n * @remarks\r\n * This is invoked in both the vertex and fragment shader construction\r\n * phases, allowing subclasses to register extra uniforms or resources\r\n * needed by their custom shading logic.\r\n *\r\n * The base implementation does nothing.\r\n *\r\n * @param _scope - The current shader function scope.\r\n */\r\n protected internalSetupUniforms(_scope: PBInsideFunctionScope) {}\r\n /**\r\n * Hook for derived classes to bind additional uniform values or resources.\r\n *\r\n * @remarks\r\n * This is called from {@link SpriteMaterial.applyUniformValues} and is\r\n * intended for subclasses to bind their own textures, samplers, or\r\n * other GPU resources.\r\n *\r\n * The base implementation does nothing.\r\n *\r\n * @param _bindGroup - The bind group used for binding uniforms and resources.\r\n * @param _ctx - The current draw context.\r\n * @param _pass - Index of the active render pass.\r\n */\r\n protected internalApplyUniforms(_bindGroup: BindGroup, _ctx: DrawContext, _pass: number) {}\r\n /**\r\n * Computes the fragment color expression for this material.\r\n *\r\n * @remarks\r\n * The default implementation simply outputs the interpolated UV\r\n * coordinates as color \\([u, v, 0, 1]\\), which is mainly useful\r\n * for debugging.\r\n *\r\n * Derived classes are expected to override this method to implement\r\n * actual shading, such as sampling a texture.\r\n *\r\n * @param scope - The current shader function scope.\r\n * @returns A shader expression representing the fragment color.\r\n\r\n */\r\n protected calcFragmentColor(scope: PBInsideFunctionScope) {\r\n return scope.$builder.vec4(scope.$inputs.zVertexUV, 0, 1);\r\n }\r\n}\r\n"],"names":["SpriteMaterial","MeshMaterial","UVINFO","defineInstanceUniform","ANCHOR_ROTATION","_uvinfo","_anchorRotation","Vector4","cullMode","uvinfo","value","equalsTo","set","uniformChanged","setUVInfo","uvx0","uvy0","uvx1","uvy1","anchorRotation","anchor","xy","x","y","z","w","rotation","anchorX","anchorY","setAnchor","clone","other","copyFrom","vertexShader","scope","pb","$builder","$inputs","vertexId","float","attrib","drawContext","materialFlags","MaterialVaryingFlags","INSTANCING","$l","getInstancedUniform","vec4","uniform","internalSetupUniforms","worldPos","ShaderHelper","getWorldMatrix","xyz","width","sqrt","dot","height","viewMatrix","getViewMatrix","forward","vec3","axis","$choice","lessThan","abs","right","normalize","cross","up","rotateAngle","c","cos","s","sin","rightRot","add","mul","upRot","sub","v","vec2","uv","$if","equal","neg","$elseif","$else","$outputs","zWorldPos","zVertexUV","setClipSpacePosition","getViewProjectionMatrix","fragmentShader","needFragmentColor","color","calcFragmentColor","outputFragmentColor","applyUniformValues","bindGroup","ctx","pass","setValue","internalApplyUniforms","_scope","_bindGroup","_ctx","_pass"],"mappings":";;;;;AAQA;;;;;;;;;;;;;;IAeO,MAAMA,cAAuBC,SAAAA,YAAAA,CAAAA;AAClC,IAAA,OAAOC,SAAS,IAAI,CAACC,qBAAqB,CAAC,UAAU,MAAQ,CAAA;AAC7D,IAAA,OAAOC,kBAAkB,IAAI,CAACD,qBAAqB,CAAC,kBAAkB,MAAQ,CAAA;IACtEE,OAAiB;IACjBC,eAAyB;AACjC;;;;;;;;AAQC,MACD,WAAc,EAAA;QACZ,KAAK,EAAA;AACL,QAAA,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M6D,KAAK,CAAA;SAC/D,MAAA;YACL,IAAI,CAACE,mBAAmB,CAAC/D,KAAAA,EAAOA,MAAMG,OAAO,CAACoD,SAAS,EAAE,IAAA,CAAA;AAC3D;AACF;AACA;;;;;;;;;;;;;;;;;AAiBC,MACDS,mBAAmBC,SAAoB,EAAEC,GAAgB,EAAEC,IAAY,EAAE;QACvE,KAAK,CAACH,kBAAmBC,CAAAA,SAAAA,EAAWC,GAAKC,EAAAA,IAAAA,CAAAA;QACzC,IAAI,EAAED,GAAI1D,CAAAA,aAAa,GAAGC,oBAAqBC,CAAAA,UAAU,CAAG,EAAA;AAC1DuD,YAAAA,SAAAA,CAAUG,QAAQ,CAAC,QAAU,EAAA,IAAI,CAACjG,OAAO,CAAA;AACzC8F,YAAAA,SAAAA,CAAUG,QAAQ,CAAC,gBAAkB,EAAA,IAAI,CAAChG,eAAe,CAAA;AAC3D;AACA,QAAA,IAAI,CAACiG,qBAAqB,CAACJ,SAAAA,EAAWC,GAAKC,EAAAA,IAAAA,CAAAA;AAC7C;AACA;;;;;;;;;;;AAWC,MACD,qBAAUpD,CAAsBuD,MAA6B,EAAE;AAC/D;;;;;;;;;;;;;MAcUD,sBAAsBE,UAAqB,EAAEC,IAAiB,EAAEC,KAAa,EAAE;AACzF;;;;;;;;;;;;;;MAeUX,iBAAkB9D,CAAAA,KAA4B,EAAE;QACxD,OAAOA,KAAAA,CAAME,QAAQ,CAACW,IAAI,CAACb,MAAMG,OAAO,CAACqD,SAAS,EAAE,CAAG,EAAA,CAAA,CAAA;AACzD;AACF;;;;"}
|
|
@@ -63,7 +63,7 @@ const MAX_DETAIL_MAPS = 8;
|
|
|
63
63
|
/** @internal */ get region() {
|
|
64
64
|
return this._region;
|
|
65
65
|
}
|
|
66
|
-
set region(val) {
|
|
66
|
+
/** @internal */ set region(val) {
|
|
67
67
|
if (!val.equalsTo(this._region)) {
|
|
68
68
|
this._region.set(val);
|
|
69
69
|
this.uniformChanged();
|
|
@@ -78,7 +78,7 @@ const MAX_DETAIL_MAPS = 8;
|
|
|
78
78
|
/** @internal */ get terrainScale() {
|
|
79
79
|
return this._terrainScale;
|
|
80
80
|
}
|
|
81
|
-
set terrainScale(val) {
|
|
81
|
+
/** @internal */ set terrainScale(val) {
|
|
82
82
|
if (!this._terrainScale.equalsTo(val)) {
|
|
83
83
|
this._terrainScale.set(val);
|
|
84
84
|
this.uniformChanged();
|