@zephyr3d/scene 0.9.0 → 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 +165 -144
- 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 +13 -26
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/pbrmr.js +1 -11
- package/dist/material/pbrmr.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":"pbrmr.js","sources":["../../src/material/pbrmr.ts"],"sourcesContent":["import { MeshMaterial, applyMaterialMixins } from './meshmaterial';\r\nimport { mixinVertexColor } from './mixins/vertexcolor';\r\nimport type { BindGroup, PBFunctionScope, PBInsideFunctionScope, PBShaderExp } from '@zephyr3d/device';\r\nimport { mixinPBRMetallicRoughness } from './mixins/lightmodel/pbrmetallicroughness';\r\nimport { mixinTextureProps } from './mixins/texture';\r\nimport { ShaderHelper } from './shader/helper';\r\nimport { MaterialVaryingFlags, RENDER_PASS_TYPE_LIGHT } from '../values';\r\nimport type { Clonable, Immutable } from '@zephyr3d/base';\r\nimport { Vector3 } from '@zephyr3d/base';\r\nimport type { DrawContext } from '../render';\r\n\r\n/**\r\n * PBRMetallicRoughnessMaterial class\r\n * @public\r\n */\r\nexport class PBRMetallicRoughnessMaterial\r\n extends applyMaterialMixins(\r\n MeshMaterial,\r\n mixinPBRMetallicRoughness,\r\n mixinVertexColor,\r\n mixinTextureProps('subsurface')\r\n )\r\n implements Clonable<PBRMetallicRoughnessMaterial>\r\n{\r\n /** @internal */\r\n private static readonly FEATURE_VERTEX_NORMAL = this.defineFeature();\r\n /** @internal */\r\n private static readonly FEATURE_VERTEX_TANGENT = this.defineFeature();\r\n /** @internal */\r\n private static readonly FEATURE_SUBSURFACE_SCATTERING = this.defineFeature();\r\n /** @internal */\r\n private static readonly SUBSURFACE_COLOR_UNIFORM = this.defineInstanceUniform(\r\n 'subsurfaceColor',\r\n 'rgb',\r\n 'SubsurfaceColor'\r\n );\r\n /** @internal */\r\n private static readonly SUBSURFACE_SCALE_UNIFORM = this.defineInstanceUniform(\r\n 'subsurfaceScale',\r\n 'float',\r\n 'SubsurfaceScale'\r\n );\r\n /** @internal */\r\n private static readonly SUBSURFACE_POWER_UNIFORM = this.defineInstanceUniform(\r\n 'subsurfacePower',\r\n 'float',\r\n 'SubsurfacePower'\r\n );\r\n /** @internal */\r\n private static readonly SUBSURFACE_INTENSITY_UNIFORM = this.defineInstanceUniform(\r\n 'subsurfaceIntensity',\r\n 'float',\r\n 'SubsurfaceIntensity'\r\n );\r\n private readonly _subsurfaceColor: Vector3;\r\n private _subsurfaceScale: number;\r\n private _subsurfacePower: number;\r\n private _subsurfaceIntensity: number;\r\n /**\r\n * Creates an instance of PBRMetallicRoughnessMaterial class\r\n */\r\n constructor() {\r\n super();\r\n this._subsurfaceColor = new Vector3(1, 0.3, 0.2);\r\n this._subsurfaceScale = 0.5;\r\n this._subsurfacePower = 1.5;\r\n this._subsurfaceIntensity = 0.5;\r\n this.useFeature(PBRMetallicRoughnessMaterial.FEATURE_VERTEX_NORMAL, true);\r\n this.useFeature(PBRMetallicRoughnessMaterial.FEATURE_SUBSURFACE_SCATTERING, false);\r\n this.transmission = false;\r\n this.transmissionFactor = 0.2;\r\n this.thicknessFactor = 0.35;\r\n this.attenuationColor = new Vector3(1, 0.5, 0.4);\r\n this.attenuationDistance = 0.6;\r\n }\r\n clone() {\r\n const other = new PBRMetallicRoughnessMaterial();\r\n other.copyFrom(this);\r\n return other;\r\n }\r\n copyFrom(other: this) {\r\n super.copyFrom(other);\r\n this.vertexNormal = other.vertexNormal;\r\n this.vertexTangent = other.vertexTangent;\r\n this.subsurfaceScattering = other.subsurfaceScattering;\r\n this.subsurfaceColor = other.subsurfaceColor;\r\n this.subsurfaceScale = other.subsurfaceScale;\r\n this.subsurfacePower = other.subsurfacePower;\r\n this.subsurfaceIntensity = other.subsurfaceIntensity;\r\n }\r\n /** true if vertex normal attribute presents */\r\n get vertexNormal() {\r\n return this.featureUsed<boolean>(PBRMetallicRoughnessMaterial.FEATURE_VERTEX_NORMAL);\r\n }\r\n set vertexNormal(val) {\r\n this.useFeature(PBRMetallicRoughnessMaterial.FEATURE_VERTEX_NORMAL, !!val);\r\n }\r\n /** true if vertex normal attribute presents */\r\n get vertexTangent() {\r\n return this.featureUsed<boolean>(PBRMetallicRoughnessMaterial.FEATURE_VERTEX_TANGENT);\r\n }\r\n set vertexTangent(val) {\r\n this.useFeature(PBRMetallicRoughnessMaterial.FEATURE_VERTEX_TANGENT, !!val);\r\n }\r\n /** true if subsurface scattering is enabled */\r\n get subsurfaceScattering() {\r\n return this.featureUsed<boolean>(PBRMetallicRoughnessMaterial.FEATURE_SUBSURFACE_SCATTERING);\r\n }\r\n set subsurfaceScattering(val) {\r\n this.useFeature(PBRMetallicRoughnessMaterial.FEATURE_SUBSURFACE_SCATTERING, !!val);\r\n }\r\n /** subsurface scattering color tint */\r\n get subsurfaceColor(): Immutable<Vector3> {\r\n return this._subsurfaceColor;\r\n }\r\n set subsurfaceColor(val: Immutable<Vector3>) {\r\n if (!val.equalsTo(this._subsurfaceColor)) {\r\n this._subsurfaceColor.set(val);\r\n this.uniformChanged();\r\n }\r\n }\r\n /** wrap factor for the scattering profile */\r\n get subsurfaceScale() {\r\n return this._subsurfaceScale;\r\n }\r\n set subsurfaceScale(val: number) {\r\n if (val !== this._subsurfaceScale) {\r\n this._subsurfaceScale = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n /** profile exponent for the scattering profile */\r\n get subsurfacePower() {\r\n return this._subsurfacePower;\r\n }\r\n set subsurfacePower(val: number) {\r\n if (val !== this._subsurfacePower) {\r\n this._subsurfacePower = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n /** final intensity of scattering contribution */\r\n get subsurfaceIntensity() {\r\n return this._subsurfaceIntensity;\r\n }\r\n set subsurfaceIntensity(val: number) {\r\n if (val !== this._subsurfaceIntensity) {\r\n this._subsurfaceIntensity = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n private getSubsurfaceColor(scope: PBInsideFunctionScope): PBShaderExp {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zSubsurfaceColor : scope.zSubsurfaceColor) as PBShaderExp;\r\n }\r\n private getSubsurfaceScale(scope: PBInsideFunctionScope): PBShaderExp {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zSubsurfaceScale : scope.zSubsurfaceScale) as PBShaderExp;\r\n }\r\n private getSubsurfacePower(scope: PBInsideFunctionScope): PBShaderExp {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zSubsurfacePower : scope.zSubsurfacePower) as PBShaderExp;\r\n }\r\n private getSubsurfaceIntensity(scope: PBInsideFunctionScope): PBShaderExp {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zSubsurfaceIntensity : scope.zSubsurfaceIntensity) as PBShaderExp;\r\n }\r\n vertexShader(scope: PBFunctionScope) {\r\n super.vertexShader(scope);\r\n const pb = scope.$builder;\r\n const worldMatrix = ShaderHelper.getWorldMatrix(scope);\r\n scope.$l.oPos = ShaderHelper.resolveVertexPosition(scope);\r\n scope.$outputs.worldPos = pb.mul(worldMatrix, pb.vec4(scope.oPos, 1)).xyz;\r\n scope.$l.csPos = pb.mul(ShaderHelper.getViewProjectionMatrix(scope), pb.vec4(scope.$outputs.worldPos, 1));\r\n ShaderHelper.setClipSpacePosition(scope, scope.csPos);\r\n if (this.transmission) {\r\n scope.$outputs.screenUV = pb.add(pb.mul(pb.div(scope.csPos.xy, scope.csPos.w), 0.5), pb.vec2(0.5));\r\n scope.$outputs.modelScale = pb.vec3(\r\n pb.length(worldMatrix[0].xyz),\r\n pb.length(worldMatrix[1].xyz),\r\n pb.length(worldMatrix[2].xyz)\r\n );\r\n }\r\n if (this.vertexNormal) {\r\n scope.$l.oNorm = ShaderHelper.resolveVertexNormal(scope);\r\n scope.$outputs.wNorm = pb.mul(ShaderHelper.getNormalMatrix(scope), pb.vec4(scope.oNorm, 0)).xyz;\r\n if (this.vertexTangent) {\r\n scope.$l.oTangent = ShaderHelper.resolveVertexTangent(scope);\r\n scope.$outputs.wTangent = pb.mul(\r\n ShaderHelper.getNormalMatrix(scope),\r\n pb.vec4(scope.oTangent.xyz, 0)\r\n ).xyz;\r\n scope.$outputs.wBinormal = pb.mul(\r\n pb.cross(scope.$outputs.wNorm, scope.$outputs.wTangent),\r\n scope.oTangent.w\r\n );\r\n }\r\n }\r\n if (\r\n this.subsurfaceScattering &&\r\n this.needFragmentColor() &&\r\n this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING\r\n ) {\r\n scope.$outputs.zSubsurfaceColor = this.getInstancedUniform(\r\n scope,\r\n PBRMetallicRoughnessMaterial.SUBSURFACE_COLOR_UNIFORM\r\n );\r\n scope.$outputs.zSubsurfaceScale = this.getInstancedUniform(\r\n scope,\r\n PBRMetallicRoughnessMaterial.SUBSURFACE_SCALE_UNIFORM\r\n );\r\n scope.$outputs.zSubsurfacePower = this.getInstancedUniform(\r\n scope,\r\n PBRMetallicRoughnessMaterial.SUBSURFACE_POWER_UNIFORM\r\n );\r\n scope.$outputs.zSubsurfaceIntensity = this.getInstancedUniform(\r\n scope,\r\n PBRMetallicRoughnessMaterial.SUBSURFACE_INTENSITY_UNIFORM\r\n );\r\n }\r\n }\r\n fragmentShader(scope: PBFunctionScope) {\r\n super.fragmentShader(scope);\r\n const pb = scope.$builder;\r\n if (\r\n this.subsurfaceScattering &&\r\n this.needFragmentColor() &&\r\n this.drawContext.renderPass!.type === RENDER_PASS_TYPE_LIGHT &&\r\n !(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING)\r\n ) {\r\n scope.zSubsurfaceColor = pb.vec3().uniform(2);\r\n scope.zSubsurfaceScale = pb.float().uniform(2);\r\n scope.zSubsurfacePower = pb.float().uniform(2);\r\n scope.zSubsurfaceIntensity = pb.float().uniform(2);\r\n }\r\n if (this.needFragmentColor()) {\r\n scope.$l.albedo = this.calculateAlbedoColor(scope);\r\n if (this.vertexColor) {\r\n scope.albedo = pb.mul(scope.albedo, this.getVertexColor(scope));\r\n }\r\n if (this.drawContext.renderPass!.type === RENDER_PASS_TYPE_LIGHT) {\r\n scope.$l.normalInfo = this.calculateNormalAndTBN(\r\n scope,\r\n scope.$inputs.worldPos,\r\n scope.$inputs.wNorm,\r\n scope.$inputs.wTangent,\r\n scope.$inputs.wBinormal\r\n );\r\n scope.$l.viewVec = this.calculateViewVector(scope, scope.$inputs.worldPos);\r\n if (this.drawContext.materialFlags & MaterialVaryingFlags.SSR_STORE_ROUGHNESS) {\r\n scope.$l.outRoughness = pb.vec4();\r\n scope.$l.litColor = this.PBRLight(\r\n scope,\r\n scope.$inputs.worldPos,\r\n scope.normalInfo.normal,\r\n scope.viewVec,\r\n scope.albedo,\r\n scope.normalInfo.TBN,\r\n scope.outRoughness\r\n );\r\n if (this.subsurfaceScattering) {\r\n scope.$l.NoV = pb.clamp(pb.dot(scope.normalInfo.normal, scope.viewVec), 0, 1);\r\n scope.$l.wrapNdotV = pb.clamp(\r\n pb.div(\r\n pb.add(pb.sub(1, scope.NoV), this.getSubsurfaceScale(scope)),\r\n pb.add(1, this.getSubsurfaceScale(scope))\r\n ),\r\n 0,\r\n 1\r\n );\r\n scope.$l.sssFactor = pb.mul(\r\n pb.pow(scope.wrapNdotV, this.getSubsurfacePower(scope)),\r\n this.getSubsurfaceIntensity(scope)\r\n );\r\n if (this.subsurfaceTexture) {\r\n scope.sssFactor = pb.mul(scope.sssFactor, this.sampleSubsurfaceTexture(scope).r);\r\n }\r\n scope.litColor = pb.add(\r\n scope.litColor,\r\n pb.mul(scope.albedo.rgb, this.getSubsurfaceColor(scope), scope.sssFactor)\r\n );\r\n }\r\n /*\r\n scope.outRoughness = pb.vec4(\r\n pb.add(pb.mul(scope.normalInfo.normal, 0.5), pb.vec3(0.5)),\r\n scope.outRoughness.a\r\n );\r\n */\r\n this.outputFragmentColor(\r\n scope,\r\n scope.$inputs.worldPos,\r\n pb.vec4(scope.litColor, scope.albedo.a),\r\n scope.outRoughness,\r\n pb.vec4(pb.add(pb.mul(scope.normalInfo.normal, 0.5), pb.vec3(0.5)), 1)\r\n );\r\n } else {\r\n scope.$l.litColor = this.PBRLight(\r\n scope,\r\n scope.$inputs.worldPos,\r\n scope.normalInfo.normal,\r\n scope.viewVec,\r\n scope.albedo,\r\n scope.normalInfo.TBN\r\n );\r\n if (this.subsurfaceScattering) {\r\n scope.$l.NoV = pb.clamp(pb.dot(scope.normalInfo.normal, scope.viewVec), 0, 1);\r\n scope.$l.wrapNdotV = pb.clamp(\r\n pb.div(\r\n pb.add(pb.sub(1, scope.NoV), this.getSubsurfaceScale(scope)),\r\n pb.add(1, this.getSubsurfaceScale(scope))\r\n ),\r\n 0,\r\n 1\r\n );\r\n scope.$l.sssFactor = pb.mul(\r\n pb.pow(scope.wrapNdotV, this.getSubsurfacePower(scope)),\r\n this.getSubsurfaceIntensity(scope)\r\n );\r\n if (this.subsurfaceTexture) {\r\n scope.sssFactor = pb.mul(scope.sssFactor, this.sampleSubsurfaceTexture(scope).r);\r\n }\r\n scope.litColor = pb.add(\r\n scope.litColor,\r\n pb.mul(scope.albedo.rgb, this.getSubsurfaceColor(scope), scope.sssFactor)\r\n );\r\n }\r\n this.outputFragmentColor(scope, scope.$inputs.worldPos, pb.vec4(scope.litColor, scope.albedo.a));\r\n }\r\n } else {\r\n this.outputFragmentColor(scope, scope.$inputs.worldPos, scope.albedo);\r\n }\r\n } else {\r\n this.outputFragmentColor(scope, scope.$inputs.worldPos, null);\r\n }\r\n }\r\n applyUniformValues(bindGroup: BindGroup, ctx: DrawContext, pass: number) {\r\n super.applyUniformValues(bindGroup, ctx, pass);\r\n if (\r\n this.subsurfaceScattering &&\r\n this.needFragmentColor(ctx) &&\r\n ctx.renderPass!.type === RENDER_PASS_TYPE_LIGHT &&\r\n !(ctx.materialFlags & MaterialVaryingFlags.INSTANCING)\r\n ) {\r\n bindGroup.setValue('zSubsurfaceColor', this._subsurfaceColor);\r\n bindGroup.setValue('zSubsurfaceScale', this._subsurfaceScale);\r\n bindGroup.setValue('zSubsurfacePower', this._subsurfacePower);\r\n bindGroup.setValue('zSubsurfaceIntensity', this._subsurfaceIntensity);\r\n }\r\n }\r\n}\r\n"],"names":["PBRMetallicRoughnessMaterial","applyMaterialMixins","MeshMaterial","mixinPBRMetallicRoughness","mixinVertexColor","mixinTextureProps","FEATURE_VERTEX_NORMAL","defineFeature","FEATURE_VERTEX_TANGENT","FEATURE_SUBSURFACE_SCATTERING","SUBSURFACE_COLOR_UNIFORM","defineInstanceUniform","SUBSURFACE_SCALE_UNIFORM","SUBSURFACE_POWER_UNIFORM","SUBSURFACE_INTENSITY_UNIFORM","_subsurfaceColor","_subsurfaceScale","_subsurfacePower","_subsurfaceIntensity","Vector3","useFeature","transmission","transmissionFactor","thicknessFactor","attenuationColor","attenuationDistance","clone","other","copyFrom","vertexNormal","vertexTangent","subsurfaceScattering","subsurfaceColor","subsurfaceScale","subsurfacePower","subsurfaceIntensity","featureUsed","val","equalsTo","set","uniformChanged","getSubsurfaceColor","scope","instancing","drawContext","materialFlags","MaterialVaryingFlags","INSTANCING","$inputs","zSubsurfaceColor","getSubsurfaceScale","zSubsurfaceScale","getSubsurfacePower","zSubsurfacePower","getSubsurfaceIntensity","zSubsurfaceIntensity","vertexShader","pb","$builder","worldMatrix","ShaderHelper","getWorldMatrix","$l","oPos","resolveVertexPosition","$outputs","worldPos","mul","vec4","xyz","csPos","getViewProjectionMatrix","setClipSpacePosition","screenUV","add","div","xy","w","vec2","modelScale","vec3","length","oNorm","resolveVertexNormal","wNorm","getNormalMatrix","oTangent","resolveVertexTangent","wTangent","wBinormal","cross","needFragmentColor","getInstancedUniform","fragmentShader","renderPass","type","RENDER_PASS_TYPE_LIGHT","uniform","float","albedo","calculateAlbedoColor","vertexColor","getVertexColor","normalInfo","calculateNormalAndTBN","viewVec","calculateViewVector","SSR_STORE_ROUGHNESS","outRoughness","litColor","PBRLight","normal","TBN","NoV","clamp","dot","wrapNdotV","sub","sssFactor","pow","subsurfaceTexture","sampleSubsurfaceTexture","r","rgb","outputFragmentColor","a","applyUniformValues","bindGroup","ctx","pass","setValue"],"mappings":";;;;;;;;AAWA;;;AAGC,IACM,MAAMA,4BAAAA,SACHC,oBACNC,YACAC,EAAAA,yBAAAA,EACAC,kBACAC,iBAAkB,CAAA,YAAA,CAAA,CAAA,CAAA;AAIpB,qBACA,OAAwBC,qBAAAA,GAAwB,IAAI,CAACC,aAAa,EAAG;AACrE,qBACA,OAAwBC,sBAAAA,GAAyB,IAAI,CAACD,aAAa,EAAG;AACtE,qBACA,OAAwBE,6BAAAA,GAAgC,IAAI,CAACF,aAAa,EAAG;qBAE7E,OAAwBG,wBAA2B,GAAA,IAAI,CAACC,qBAAqB,CA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AAI,CAAClG,oBAAoB,IACzB,IAAI,CAAC4D,iBAAiB,CAACqC,GAAAA,CAAAA,IACvBA,GAAIlC,CAAAA,UAAU,CAAEC,IAAI,KAAKC,sBACzB,IAAA,EAAEgC,GAAAA,CAAInF,aAAa,GAAGC,oBAAAA,CAAqBC,UAAS,CACpD,EAAA;AACAgF,YAAAA,SAAAA,CAAUG,QAAQ,CAAC,kBAAoB,EAAA,IAAI,CAACnH,gBAAgB,CAAA;AAC5DgH,YAAAA,SAAAA,CAAUG,QAAQ,CAAC,kBAAoB,EAAA,IAAI,CAAClH,gBAAgB,CAAA;AAC5D+G,YAAAA,SAAAA,CAAUG,QAAQ,CAAC,kBAAoB,EAAA,IAAI,CAACjH,gBAAgB,CAAA;AAC5D8G,YAAAA,SAAAA,CAAUG,QAAQ,CAAC,sBAAwB,EAAA,IAAI,CAAChH,oBAAoB,CAAA;AACtE;AACF;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"pbrmr.js","sources":["../../src/material/pbrmr.ts"],"sourcesContent":["import { MeshMaterial, applyMaterialMixins } from './meshmaterial';\r\nimport { mixinVertexColor } from './mixins/vertexcolor';\r\nimport type { BindGroup, PBFunctionScope, PBInsideFunctionScope, PBShaderExp } from '@zephyr3d/device';\r\nimport { mixinPBRMetallicRoughness } from './mixins/lightmodel/pbrmetallicroughness';\r\nimport { mixinTextureProps } from './mixins/texture';\r\nimport { ShaderHelper } from './shader/helper';\r\nimport { MaterialVaryingFlags, RENDER_PASS_TYPE_LIGHT } from '../values';\r\nimport type { Clonable, Immutable } from '@zephyr3d/base';\r\nimport { Vector3 } from '@zephyr3d/base';\r\nimport type { DrawContext } from '../render';\r\n\r\n/**\r\n * PBRMetallicRoughnessMaterial class\r\n * @public\r\n */\r\nexport class PBRMetallicRoughnessMaterial\r\n extends applyMaterialMixins(\r\n MeshMaterial,\r\n mixinPBRMetallicRoughness,\r\n mixinVertexColor,\r\n mixinTextureProps('subsurface')\r\n )\r\n implements Clonable<PBRMetallicRoughnessMaterial>\r\n{\r\n /** @internal */\r\n private static readonly FEATURE_VERTEX_NORMAL = this.defineFeature();\r\n /** @internal */\r\n private static readonly FEATURE_VERTEX_TANGENT = this.defineFeature();\r\n /** @internal */\r\n private static readonly FEATURE_SUBSURFACE_SCATTERING = this.defineFeature();\r\n private readonly _subsurfaceColor: Vector3;\r\n private _subsurfaceScale: number;\r\n private _subsurfacePower: number;\r\n private _subsurfaceIntensity: number;\r\n /**\r\n * Creates an instance of PBRMetallicRoughnessMaterial class\r\n */\r\n constructor() {\r\n super();\r\n this._subsurfaceColor = new Vector3(1, 0.3, 0.2);\r\n this._subsurfaceScale = 0.5;\r\n this._subsurfacePower = 1.5;\r\n this._subsurfaceIntensity = 0.5;\r\n this.useFeature(PBRMetallicRoughnessMaterial.FEATURE_VERTEX_NORMAL, true);\r\n this.useFeature(PBRMetallicRoughnessMaterial.FEATURE_SUBSURFACE_SCATTERING, false);\r\n this.transmission = false;\r\n this.transmissionFactor = 0.2;\r\n this.thicknessFactor = 0.35;\r\n this.attenuationColor = new Vector3(1, 0.5, 0.4);\r\n this.attenuationDistance = 0.6;\r\n }\r\n clone() {\r\n const other = new PBRMetallicRoughnessMaterial();\r\n other.copyFrom(this);\r\n return other;\r\n }\r\n copyFrom(other: this) {\r\n super.copyFrom(other);\r\n this.vertexNormal = other.vertexNormal;\r\n this.vertexTangent = other.vertexTangent;\r\n this.subsurfaceScattering = other.subsurfaceScattering;\r\n this.subsurfaceColor = other.subsurfaceColor;\r\n this.subsurfaceScale = other.subsurfaceScale;\r\n this.subsurfacePower = other.subsurfacePower;\r\n this.subsurfaceIntensity = other.subsurfaceIntensity;\r\n }\r\n /** true if vertex normal attribute presents */\r\n get vertexNormal() {\r\n return this.featureUsed<boolean>(PBRMetallicRoughnessMaterial.FEATURE_VERTEX_NORMAL);\r\n }\r\n set vertexNormal(val) {\r\n this.useFeature(PBRMetallicRoughnessMaterial.FEATURE_VERTEX_NORMAL, !!val);\r\n }\r\n /** true if vertex normal attribute presents */\r\n get vertexTangent() {\r\n return this.featureUsed<boolean>(PBRMetallicRoughnessMaterial.FEATURE_VERTEX_TANGENT);\r\n }\r\n set vertexTangent(val) {\r\n this.useFeature(PBRMetallicRoughnessMaterial.FEATURE_VERTEX_TANGENT, !!val);\r\n }\r\n /** true if subsurface scattering is enabled */\r\n get subsurfaceScattering() {\r\n return this.featureUsed<boolean>(PBRMetallicRoughnessMaterial.FEATURE_SUBSURFACE_SCATTERING);\r\n }\r\n set subsurfaceScattering(val) {\r\n this.useFeature(PBRMetallicRoughnessMaterial.FEATURE_SUBSURFACE_SCATTERING, !!val);\r\n }\r\n /** subsurface scattering color tint */\r\n get subsurfaceColor(): Immutable<Vector3> {\r\n return this._subsurfaceColor;\r\n }\r\n set subsurfaceColor(val: Immutable<Vector3>) {\r\n if (!val.equalsTo(this._subsurfaceColor)) {\r\n this._subsurfaceColor.set(val);\r\n this.uniformChanged();\r\n }\r\n }\r\n /** wrap factor for the scattering profile */\r\n get subsurfaceScale() {\r\n return this._subsurfaceScale;\r\n }\r\n set subsurfaceScale(val: number) {\r\n if (val !== this._subsurfaceScale) {\r\n this._subsurfaceScale = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n /** profile exponent for the scattering profile */\r\n get subsurfacePower() {\r\n return this._subsurfacePower;\r\n }\r\n set subsurfacePower(val: number) {\r\n if (val !== this._subsurfacePower) {\r\n this._subsurfacePower = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n /** final intensity of scattering contribution */\r\n get subsurfaceIntensity() {\r\n return this._subsurfaceIntensity;\r\n }\r\n set subsurfaceIntensity(val: number) {\r\n if (val !== this._subsurfaceIntensity) {\r\n this._subsurfaceIntensity = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n private getSubsurfaceColor(scope: PBInsideFunctionScope): PBShaderExp {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zSubsurfaceColor : scope.zSubsurfaceColor) as PBShaderExp;\r\n }\r\n private getSubsurfaceScale(scope: PBInsideFunctionScope): PBShaderExp {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zSubsurfaceScale : scope.zSubsurfaceScale) as PBShaderExp;\r\n }\r\n private getSubsurfacePower(scope: PBInsideFunctionScope): PBShaderExp {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zSubsurfacePower : scope.zSubsurfacePower) as PBShaderExp;\r\n }\r\n private getSubsurfaceIntensity(scope: PBInsideFunctionScope): PBShaderExp {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zSubsurfaceIntensity : scope.zSubsurfaceIntensity) as PBShaderExp;\r\n }\r\n vertexShader(scope: PBFunctionScope) {\r\n super.vertexShader(scope);\r\n const pb = scope.$builder;\r\n const worldMatrix = ShaderHelper.getWorldMatrix(scope);\r\n scope.$l.oPos = ShaderHelper.resolveVertexPosition(scope);\r\n scope.$outputs.worldPos = pb.mul(worldMatrix, pb.vec4(scope.oPos, 1)).xyz;\r\n scope.$l.csPos = pb.mul(ShaderHelper.getViewProjectionMatrix(scope), pb.vec4(scope.$outputs.worldPos, 1));\r\n ShaderHelper.setClipSpacePosition(scope, scope.csPos);\r\n if (this.transmission) {\r\n scope.$outputs.screenUV = pb.add(pb.mul(pb.div(scope.csPos.xy, scope.csPos.w), 0.5), pb.vec2(0.5));\r\n scope.$outputs.modelScale = pb.vec3(\r\n pb.length(worldMatrix[0].xyz),\r\n pb.length(worldMatrix[1].xyz),\r\n pb.length(worldMatrix[2].xyz)\r\n );\r\n }\r\n if (this.vertexNormal) {\r\n scope.$l.oNorm = ShaderHelper.resolveVertexNormal(scope);\r\n scope.$outputs.wNorm = pb.mul(ShaderHelper.getNormalMatrix(scope), pb.vec4(scope.oNorm, 0)).xyz;\r\n if (this.vertexTangent) {\r\n scope.$l.oTangent = ShaderHelper.resolveVertexTangent(scope);\r\n scope.$outputs.wTangent = pb.mul(\r\n ShaderHelper.getNormalMatrix(scope),\r\n pb.vec4(scope.oTangent.xyz, 0)\r\n ).xyz;\r\n scope.$outputs.wBinormal = pb.mul(\r\n pb.cross(scope.$outputs.wNorm, scope.$outputs.wTangent),\r\n scope.oTangent.w\r\n );\r\n }\r\n }\r\n }\r\n fragmentShader(scope: PBFunctionScope) {\r\n super.fragmentShader(scope);\r\n const pb = scope.$builder;\r\n if (\r\n this.subsurfaceScattering &&\r\n this.needFragmentColor() &&\r\n this.drawContext.renderPass!.type === RENDER_PASS_TYPE_LIGHT\r\n ) {\r\n scope.zSubsurfaceColor = pb.vec3().uniform(2);\r\n scope.zSubsurfaceScale = pb.float().uniform(2);\r\n scope.zSubsurfacePower = pb.float().uniform(2);\r\n scope.zSubsurfaceIntensity = pb.float().uniform(2);\r\n }\r\n if (this.needFragmentColor()) {\r\n scope.$l.albedo = this.calculateAlbedoColor(scope);\r\n if (this.vertexColor) {\r\n scope.albedo = pb.mul(scope.albedo, this.getVertexColor(scope));\r\n }\r\n if (this.drawContext.renderPass!.type === RENDER_PASS_TYPE_LIGHT) {\r\n scope.$l.normalInfo = this.calculateNormalAndTBN(\r\n scope,\r\n scope.$inputs.worldPos,\r\n scope.$inputs.wNorm,\r\n scope.$inputs.wTangent,\r\n scope.$inputs.wBinormal\r\n );\r\n scope.$l.viewVec = this.calculateViewVector(scope, scope.$inputs.worldPos);\r\n if (this.drawContext.materialFlags & MaterialVaryingFlags.SSR_STORE_ROUGHNESS) {\r\n scope.$l.outRoughness = pb.vec4();\r\n scope.$l.litColor = this.PBRLight(\r\n scope,\r\n scope.$inputs.worldPos,\r\n scope.normalInfo.normal,\r\n scope.viewVec,\r\n scope.albedo,\r\n scope.normalInfo.TBN,\r\n scope.outRoughness\r\n );\r\n if (this.subsurfaceScattering) {\r\n scope.$l.NoV = pb.clamp(pb.dot(scope.normalInfo.normal, scope.viewVec), 0, 1);\r\n scope.$l.wrapNdotV = pb.clamp(\r\n pb.div(\r\n pb.add(pb.sub(1, scope.NoV), this.getSubsurfaceScale(scope)),\r\n pb.add(1, this.getSubsurfaceScale(scope))\r\n ),\r\n 0,\r\n 1\r\n );\r\n scope.$l.sssFactor = pb.mul(\r\n pb.pow(scope.wrapNdotV, this.getSubsurfacePower(scope)),\r\n this.getSubsurfaceIntensity(scope)\r\n );\r\n if (this.subsurfaceTexture) {\r\n scope.sssFactor = pb.mul(scope.sssFactor, this.sampleSubsurfaceTexture(scope).r);\r\n }\r\n scope.litColor = pb.add(\r\n scope.litColor,\r\n pb.mul(scope.albedo.rgb, this.getSubsurfaceColor(scope), scope.sssFactor)\r\n );\r\n }\r\n /*\r\n scope.outRoughness = pb.vec4(\r\n pb.add(pb.mul(scope.normalInfo.normal, 0.5), pb.vec3(0.5)),\r\n scope.outRoughness.a\r\n );\r\n */\r\n this.outputFragmentColor(\r\n scope,\r\n scope.$inputs.worldPos,\r\n pb.vec4(scope.litColor, scope.albedo.a),\r\n scope.outRoughness,\r\n pb.vec4(pb.add(pb.mul(scope.normalInfo.normal, 0.5), pb.vec3(0.5)), 1)\r\n );\r\n } else {\r\n scope.$l.litColor = this.PBRLight(\r\n scope,\r\n scope.$inputs.worldPos,\r\n scope.normalInfo.normal,\r\n scope.viewVec,\r\n scope.albedo,\r\n scope.normalInfo.TBN\r\n );\r\n if (this.subsurfaceScattering) {\r\n scope.$l.NoV = pb.clamp(pb.dot(scope.normalInfo.normal, scope.viewVec), 0, 1);\r\n scope.$l.wrapNdotV = pb.clamp(\r\n pb.div(\r\n pb.add(pb.sub(1, scope.NoV), this.getSubsurfaceScale(scope)),\r\n pb.add(1, this.getSubsurfaceScale(scope))\r\n ),\r\n 0,\r\n 1\r\n );\r\n scope.$l.sssFactor = pb.mul(\r\n pb.pow(scope.wrapNdotV, this.getSubsurfacePower(scope)),\r\n this.getSubsurfaceIntensity(scope)\r\n );\r\n if (this.subsurfaceTexture) {\r\n scope.sssFactor = pb.mul(scope.sssFactor, this.sampleSubsurfaceTexture(scope).r);\r\n }\r\n scope.litColor = pb.add(\r\n scope.litColor,\r\n pb.mul(scope.albedo.rgb, this.getSubsurfaceColor(scope), scope.sssFactor)\r\n );\r\n }\r\n this.outputFragmentColor(scope, scope.$inputs.worldPos, pb.vec4(scope.litColor, scope.albedo.a));\r\n }\r\n } else {\r\n this.outputFragmentColor(scope, scope.$inputs.worldPos, scope.albedo);\r\n }\r\n } else {\r\n this.outputFragmentColor(scope, scope.$inputs.worldPos, null);\r\n }\r\n }\r\n applyUniformValues(bindGroup: BindGroup, ctx: DrawContext, pass: number) {\r\n super.applyUniformValues(bindGroup, ctx, pass);\r\n if (\r\n this.subsurfaceScattering &&\r\n this.needFragmentColor(ctx) &&\r\n ctx.renderPass!.type === RENDER_PASS_TYPE_LIGHT &&\r\n !(ctx.materialFlags & MaterialVaryingFlags.INSTANCING)\r\n ) {\r\n bindGroup.setValue('zSubsurfaceColor', this._subsurfaceColor);\r\n bindGroup.setValue('zSubsurfaceScale', this._subsurfaceScale);\r\n bindGroup.setValue('zSubsurfacePower', this._subsurfacePower);\r\n bindGroup.setValue('zSubsurfaceIntensity', this._subsurfaceIntensity);\r\n }\r\n }\r\n}\r\n"],"names":["PBRMetallicRoughnessMaterial","applyMaterialMixins","MeshMaterial","mixinPBRMetallicRoughness","mixinVertexColor","mixinTextureProps","FEATURE_VERTEX_NORMAL","defineFeature","FEATURE_VERTEX_TANGENT","FEATURE_SUBSURFACE_SCATTERING","_subsurfaceColor","_subsurfaceScale","_subsurfacePower","_subsurfaceIntensity","Vector3","useFeature","transmission","transmissionFactor","thicknessFactor","attenuationColor","attenuationDistance","clone","other","copyFrom","vertexNormal","vertexTangent","subsurfaceScattering","subsurfaceColor","subsurfaceScale","subsurfacePower","subsurfaceIntensity","featureUsed","val","equalsTo","set","uniformChanged","getSubsurfaceColor","scope","instancing","drawContext","materialFlags","MaterialVaryingFlags","INSTANCING","$inputs","zSubsurfaceColor","getSubsurfaceScale","zSubsurfaceScale","getSubsurfacePower","zSubsurfacePower","getSubsurfaceIntensity","zSubsurfaceIntensity","vertexShader","pb","$builder","worldMatrix","ShaderHelper","getWorldMatrix","$l","oPos","resolveVertexPosition","$outputs","worldPos","mul","vec4","xyz","csPos","getViewProjectionMatrix","setClipSpacePosition","screenUV","add","div","xy","w","vec2","modelScale","vec3","length","oNorm","resolveVertexNormal","wNorm","getNormalMatrix","oTangent","resolveVertexTangent","wTangent","wBinormal","cross","fragmentShader","needFragmentColor","renderPass","type","RENDER_PASS_TYPE_LIGHT","uniform","float","albedo","calculateAlbedoColor","vertexColor","getVertexColor","normalInfo","calculateNormalAndTBN","viewVec","calculateViewVector","SSR_STORE_ROUGHNESS","outRoughness","litColor","PBRLight","normal","TBN","NoV","clamp","dot","wrapNdotV","sub","sssFactor","pow","subsurfaceTexture","sampleSubsurfaceTexture","r","rgb","outputFragmentColor","a","applyUniformValues","bindGroup","ctx","pass","setValue"],"mappings":";;;;;;;;AAWA;;;AAGC,IACM,MAAMA,4BAAAA,SACHC,oBACNC,YACAC,EAAAA,yBAAAA,EACAC,kBACAC,iBAAkB,CAAA,YAAA,CAAA,CAAA,CAAA;AAIpB,qBACA,OAAwBC,qBAAAA,GAAwB,IAAI,CAACC,aAAa,EAAG;AACrE,qBACA,OAAwBC,sBAAAA,GAAyB,IAAI,CAACD,aAAa,EAAG;AACtE,qBACA,OAAwBE,6BAAAA,GAAgC,IAAI,CAACF,aAAa,EAAG;IAC5DG,gBAA0B;IACnCC,gBAAyB;IACzBC,gBAAyB;IACzBC,oBAA6B;AACrC;;AAEC,MACD,WAAc,EAAA;QACZ,KAAK,EAAA;AACL,QAAA,IAAI,CAACH,gBAAgB,GAAG,IAAII,OAAAA,CAAQ,GAAG,GAAK,EAAA,GAAA,CAAA;QAC5C,IAAI,CAACH,gBAAgB,GAAG,GAAA;QACxB,IAAI,CAACC,gBAAgB,GAAG,GAAA;QACxB,IAAI,CAACC,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AAAA,CAAIlF,aAAa,GAAGC,oBAAAA,CAAqBC,UAAS,CACpD,EAAA;AACA+E,YAAAA,SAAAA,CAAUG,QAAQ,CAAC,kBAAoB,EAAA,IAAI,CAAClH,gBAAgB,CAAA;AAC5D+G,YAAAA,SAAAA,CAAUG,QAAQ,CAAC,kBAAoB,EAAA,IAAI,CAACjH,gBAAgB,CAAA;AAC5D8G,YAAAA,SAAAA,CAAUG,QAAQ,CAAC,kBAAoB,EAAA,IAAI,CAAChH,gBAAgB,CAAA;AAC5D6G,YAAAA,SAAAA,CAAUG,QAAQ,CAAC,sBAAwB,EAAA,IAAI,CAAC/G,oBAAoB,CAAA;AACtE;AACF;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":";;;;;AAQA;;;;;;;;;;;;;;IAeO,MAAMA,cAAuBC,SAAAA,YAAAA,CAAA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":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,IAAI,CAACD,OAAO,GAAG,IAAIE,OAAQ,CAAA,CAAA,EAAG,GAAG,C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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();
|