playcanvas 2.24.0-beta.32 → 2.24.0-beta.33
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/build/playcanvas/src/core/core.js +2 -2
- package/build/playcanvas/src/extras/input/controllers/orbit-controller.d.ts +9 -0
- package/build/playcanvas/src/extras/input/controllers/orbit-controller.js +8 -2
- package/build/playcanvas/src/framework/components/particle-system/component.d.ts +5 -5
- package/build/playcanvas/src/scene/materials/lit-material-options-builder.js +0 -2
- package/build/playcanvas/src/scene/materials/lit-material.js +5 -0
- package/build/playcanvas/src/scene/materials/material-property.d.ts +9 -0
- package/build/playcanvas/src/scene/materials/material-property.js +4 -0
- package/build/playcanvas/src/scene/materials/standard-material-options-builder.js +1 -3
- package/build/playcanvas/src/scene/materials/standard-material.js +19 -4
- package/build/playcanvas/src/scene/shader-lib/glsl/chunks/lit/frag/pass-forward/litForwardBackend.d.ts +1 -1
- package/build/playcanvas/src/scene/shader-lib/glsl/chunks/lit/frag/pass-forward/litForwardBackend.js +2 -6
- package/build/playcanvas/src/scene/shader-lib/glsl/chunks/lit/frag/pass-forward/litForwardDeclaration.d.ts +1 -1
- package/build/playcanvas/src/scene/shader-lib/glsl/chunks/lit/frag/pass-forward/litForwardDeclaration.js +6 -0
- package/build/playcanvas/src/scene/shader-lib/glsl/chunks/lit/frag/pass-forward/litForwardMain.d.ts +1 -1
- package/build/playcanvas/src/scene/shader-lib/glsl/chunks/lit/frag/pass-forward/litForwardMain.js +2 -2
- package/build/playcanvas/src/scene/shader-lib/glsl/chunks/lit/frag/pass-forward/litForwardPreCode.d.ts +1 -1
- package/build/playcanvas/src/scene/shader-lib/glsl/chunks/lit/frag/pass-forward/litForwardPreCode.js +1 -1
- package/build/playcanvas/src/scene/shader-lib/programs/lit-shader-options.d.ts +0 -8
- package/build/playcanvas/src/scene/shader-lib/programs/lit-shader-options.js +0 -2
- package/build/playcanvas/src/scene/shader-lib/programs/lit-shader.js +0 -2
- package/build/playcanvas/src/scene/shader-lib/wgsl/chunks/lit/frag/pass-forward/litForwardBackend.d.ts +1 -1
- package/build/playcanvas/src/scene/shader-lib/wgsl/chunks/lit/frag/pass-forward/litForwardBackend.js +2 -6
- package/build/playcanvas/src/scene/shader-lib/wgsl/chunks/lit/frag/pass-forward/litForwardDeclaration.d.ts +1 -1
- package/build/playcanvas/src/scene/shader-lib/wgsl/chunks/lit/frag/pass-forward/litForwardDeclaration.js +6 -0
- package/build/playcanvas/src/scene/shader-lib/wgsl/chunks/lit/frag/pass-forward/litForwardMain.d.ts +1 -1
- package/build/playcanvas/src/scene/shader-lib/wgsl/chunks/lit/frag/pass-forward/litForwardMain.js +2 -2
- package/build/playcanvas/src/scene/shader-lib/wgsl/chunks/lit/frag/pass-forward/litForwardPreCode.d.ts +1 -1
- package/build/playcanvas/src/scene/shader-lib/wgsl/chunks/lit/frag/pass-forward/litForwardPreCode.js +1 -1
- package/build/playcanvas/src/scene/shader-lib/wgsl/chunks/particle/vert/particleAnimFrameClamp.d.ts +1 -1
- package/build/playcanvas/src/scene/shader-lib/wgsl/chunks/particle/vert/particleAnimFrameClamp.js +1 -1
- package/build/playcanvas.d.ts +14 -13
- package/build/playcanvas.dbg/src/core/core.js +2 -2
- package/build/playcanvas.dbg/src/extras/input/controllers/orbit-controller.js +14 -2
- package/build/playcanvas.dbg/src/scene/materials/lit-material-options-builder.js +0 -2
- package/build/playcanvas.dbg/src/scene/materials/lit-material.js +6 -0
- package/build/playcanvas.dbg/src/scene/materials/material-property.js +4 -0
- package/build/playcanvas.dbg/src/scene/materials/standard-material-options-builder.js +1 -3
- package/build/playcanvas.dbg/src/scene/materials/standard-material.js +19 -4
- package/build/playcanvas.dbg/src/scene/shader-lib/glsl/chunks/lit/frag/pass-forward/litForwardBackend.js +4 -6
- package/build/playcanvas.dbg/src/scene/shader-lib/glsl/chunks/lit/frag/pass-forward/litForwardDeclaration.js +8 -0
- package/build/playcanvas.dbg/src/scene/shader-lib/glsl/chunks/lit/frag/pass-forward/litForwardMain.js +4 -3
- package/build/playcanvas.dbg/src/scene/shader-lib/glsl/chunks/lit/frag/pass-forward/litForwardPreCode.js +1 -1
- package/build/playcanvas.dbg/src/scene/shader-lib/programs/lit-shader-options.js +0 -8
- package/build/playcanvas.dbg/src/scene/shader-lib/programs/lit-shader.js +0 -2
- package/build/playcanvas.dbg/src/scene/shader-lib/wgsl/chunks/lit/frag/pass-forward/litForwardBackend.js +4 -6
- package/build/playcanvas.dbg/src/scene/shader-lib/wgsl/chunks/lit/frag/pass-forward/litForwardDeclaration.js +8 -0
- package/build/playcanvas.dbg/src/scene/shader-lib/wgsl/chunks/lit/frag/pass-forward/litForwardMain.js +4 -3
- package/build/playcanvas.dbg/src/scene/shader-lib/wgsl/chunks/lit/frag/pass-forward/litForwardPreCode.js +1 -1
- package/build/playcanvas.dbg/src/scene/shader-lib/wgsl/chunks/particle/vert/particleAnimFrameClamp.js +1 -1
- package/build/playcanvas.dbg.js +80 -44
- package/build/playcanvas.dbg.mjs +80 -44
- package/build/playcanvas.js +61 -36
- package/build/playcanvas.min.js +729 -725
- package/build/playcanvas.min.mjs +729 -725
- package/build/playcanvas.mjs +61 -36
- package/build/playcanvas.prf/src/core/core.js +2 -2
- package/build/playcanvas.prf/src/extras/input/controllers/orbit-controller.js +8 -2
- package/build/playcanvas.prf/src/scene/materials/lit-material-options-builder.js +0 -2
- package/build/playcanvas.prf/src/scene/materials/lit-material.js +5 -0
- package/build/playcanvas.prf/src/scene/materials/material-property.js +4 -0
- package/build/playcanvas.prf/src/scene/materials/standard-material-options-builder.js +1 -3
- package/build/playcanvas.prf/src/scene/materials/standard-material.js +19 -4
- package/build/playcanvas.prf/src/scene/shader-lib/glsl/chunks/lit/frag/pass-forward/litForwardBackend.js +2 -6
- package/build/playcanvas.prf/src/scene/shader-lib/glsl/chunks/lit/frag/pass-forward/litForwardDeclaration.js +6 -0
- package/build/playcanvas.prf/src/scene/shader-lib/glsl/chunks/lit/frag/pass-forward/litForwardMain.js +2 -2
- package/build/playcanvas.prf/src/scene/shader-lib/glsl/chunks/lit/frag/pass-forward/litForwardPreCode.js +1 -1
- package/build/playcanvas.prf/src/scene/shader-lib/programs/lit-shader-options.js +0 -2
- package/build/playcanvas.prf/src/scene/shader-lib/programs/lit-shader.js +0 -2
- package/build/playcanvas.prf/src/scene/shader-lib/wgsl/chunks/lit/frag/pass-forward/litForwardBackend.js +2 -6
- package/build/playcanvas.prf/src/scene/shader-lib/wgsl/chunks/lit/frag/pass-forward/litForwardDeclaration.js +6 -0
- package/build/playcanvas.prf/src/scene/shader-lib/wgsl/chunks/lit/frag/pass-forward/litForwardMain.js +2 -2
- package/build/playcanvas.prf/src/scene/shader-lib/wgsl/chunks/lit/frag/pass-forward/litForwardPreCode.js +1 -1
- package/build/playcanvas.prf/src/scene/shader-lib/wgsl/chunks/particle/vert/particleAnimFrameClamp.js +1 -1
- package/build/playcanvas.prf.js +61 -36
- package/build/playcanvas.prf.mjs +61 -36
- package/package.json +1 -1
- package/scripts/esm/blurred-planar-reflection.mjs +10 -4
- package/scripts/esm/camera-controls.mjs +283 -13
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* view around the focus within {@link yawRange} and {@link pitchRange}, the first two `move`
|
|
4
4
|
* components pan the focus point, and the third scales the distance within {@link zoomRange}.
|
|
5
5
|
* Motion is smoothed with {@link rotateDamping}, {@link moveDamping} and {@link zoomDamping}.
|
|
6
|
+
* With {@link horizontalPan}, the pan moves the focus point across the ground instead of the
|
|
7
|
+
* plane of the view.
|
|
6
8
|
*
|
|
7
9
|
* @category Input
|
|
8
10
|
* @alpha
|
|
@@ -42,6 +44,13 @@ export class OrbitController extends InputController {
|
|
|
42
44
|
* The zoom damping. A higher value means more damping. A value of 0 means no damping.
|
|
43
45
|
*/
|
|
44
46
|
zoomDamping: number;
|
|
47
|
+
/**
|
|
48
|
+
* Whether the pan moves the focus point across the horizontal plane, as when dragging a map,
|
|
49
|
+
* instead of across the plane of the view. The first two `move` components are then the
|
|
50
|
+
* distances to move the focus point to the right and forward, level with the ground, so the
|
|
51
|
+
* height of the focus point does not change. Default is false.
|
|
52
|
+
*/
|
|
53
|
+
horizontalPan: boolean;
|
|
45
54
|
set pitchRange(range: import("../../../index.js").Vec2);
|
|
46
55
|
get pitchRange(): import("../../../index.js").Vec2;
|
|
47
56
|
set yawRange(range: import("../../../index.js").Vec2);
|
|
@@ -15,6 +15,7 @@ class OrbitController extends InputController {
|
|
|
15
15
|
rotateDamping = 0.98;
|
|
16
16
|
moveDamping = 0.98;
|
|
17
17
|
zoomDamping = 0.98;
|
|
18
|
+
horizontalPan = false;
|
|
18
19
|
set pitchRange(range) {
|
|
19
20
|
this._targetRootPose.pitchRange.copy(range);
|
|
20
21
|
this._rootPose.copy(this._targetRootPose.rotate(Vec3.ZERO));
|
|
@@ -50,8 +51,13 @@ class OrbitController extends InputController {
|
|
|
50
51
|
}
|
|
51
52
|
update(frame, dt) {
|
|
52
53
|
const { move, rotate } = frame.read();
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
if (this.horizontalPan) {
|
|
55
|
+
offset.set(move[0], 0, -move[1]);
|
|
56
|
+
rotation.setFromEulerAngles(0, this._rootPose.angles.y, 0).transformVector(offset, offset);
|
|
57
|
+
} else {
|
|
58
|
+
offset.set(move[0], move[1], 0);
|
|
59
|
+
rotation.setFromEulerAngles(this._rootPose.angles).transformVector(offset, offset);
|
|
60
|
+
}
|
|
55
61
|
this._targetRootPose.move(offset);
|
|
56
62
|
const { z: dist } = this._targetChildPose.position;
|
|
57
63
|
this._targetChildPose.move(offset.set(0, 0, dist * (1 + move[2]) - dist));
|
|
@@ -39,11 +39,11 @@ export const _properties: string[];
|
|
|
39
39
|
*
|
|
40
40
|
* Relevant Engine API examples:
|
|
41
41
|
*
|
|
42
|
-
* - [Particle Animated Index](https://playcanvas.github.io/#/
|
|
43
|
-
* - [Particle Mesh](https://playcanvas.github.io/#/
|
|
44
|
-
* - [Particle Random Sprites](https://playcanvas.github.io/#/
|
|
45
|
-
* - [Particle Snow](https://playcanvas.github.io/#/
|
|
46
|
-
* - [Particle Spark](https://playcanvas.github.io/#/
|
|
42
|
+
* - [Particle Animated Index](https://playcanvas.github.io/#/particles/anim-index)
|
|
43
|
+
* - [Particle Mesh](https://playcanvas.github.io/#/particles/mesh)
|
|
44
|
+
* - [Particle Random Sprites](https://playcanvas.github.io/#/particles/random-sprites)
|
|
45
|
+
* - [Particle Snow](https://playcanvas.github.io/#/particles/snow)
|
|
46
|
+
* - [Particle Spark](https://playcanvas.github.io/#/particles/spark)
|
|
47
47
|
* - [Particles in a user interface](https://playcanvas.github.io/#/user-interface/particle-system)
|
|
48
48
|
*
|
|
49
49
|
* @hideconstructor
|
|
@@ -63,8 +63,6 @@ class LitMaterialOptionsBuilder {
|
|
|
63
63
|
litOptions.separateAmbient = false;
|
|
64
64
|
litOptions.pixelSnap = material.pixelSnap;
|
|
65
65
|
litOptions.ambientSH = material.ambientSH;
|
|
66
|
-
litOptions.twoSidedLighting = material.twoSidedLighting;
|
|
67
|
-
litOptions.occludeDirect = material.occludeDirect;
|
|
68
66
|
litOptions.occludeSpecular = material.occludeSpecular;
|
|
69
67
|
litOptions.occludeSpecularFloat = material.occludeSpecularIntensity !== 1;
|
|
70
68
|
litOptions.useMsdf = false;
|
|
@@ -47,6 +47,11 @@ class LitMaterial extends Material {
|
|
|
47
47
|
hasMetalness = false;
|
|
48
48
|
hasClearCoat = false;
|
|
49
49
|
hasClearCoatNormals = false;
|
|
50
|
+
updateUniforms(device, scene) {
|
|
51
|
+
super.updateUniforms(device, scene);
|
|
52
|
+
this.setParameter("material_occludeDirect", this.occludeDirect ? 1 : 0);
|
|
53
|
+
this.setParameter("material_twoSidedLighting", this.twoSidedLighting ? 1 : 0);
|
|
54
|
+
}
|
|
50
55
|
getShaderVariant(params) {
|
|
51
56
|
options.usedUvs = this.usedUvs.slice();
|
|
52
57
|
options.shaderChunkGLSL = this.shaderChunkGLSL;
|
|
@@ -62,6 +62,15 @@ export class MaterialProperty {
|
|
|
62
62
|
*/
|
|
63
63
|
key: string;
|
|
64
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Writes a boolean to a float uniform value, as 1 or 0.
|
|
67
|
+
*
|
|
68
|
+
* @param {boolean} value - The boolean.
|
|
69
|
+
* @param {Float32Array} storage - The uniform buffer storage.
|
|
70
|
+
* @param {number} offset - The element offset of the uniform in the storage.
|
|
71
|
+
* @ignore
|
|
72
|
+
*/
|
|
73
|
+
export function convertBoolean(value: boolean, storage: Float32Array, offset: number): void;
|
|
65
74
|
/**
|
|
66
75
|
* Converts an sRGB color to a linear RGB uniform value.
|
|
67
76
|
*
|
|
@@ -27,8 +27,12 @@ const convertColorToLinear = (color, storage, offset) => {
|
|
|
27
27
|
const convertFloat = (value, storage, offset) => {
|
|
28
28
|
storage[offset] = value;
|
|
29
29
|
};
|
|
30
|
+
const convertBoolean = (value, storage, offset) => {
|
|
31
|
+
storage[offset] = value ? 1 : 0;
|
|
32
|
+
};
|
|
30
33
|
export {
|
|
31
34
|
MaterialProperty,
|
|
35
|
+
convertBoolean,
|
|
32
36
|
convertColorToLinear,
|
|
33
37
|
convertFloat
|
|
34
38
|
};
|
|
@@ -170,7 +170,7 @@ class StandardMaterialOptionsBuilder {
|
|
|
170
170
|
const isPackedNormalMap = (texture) => texture ? texture.format === PIXELFORMAT_DXT5 || texture.type === TEXTURETYPE_SWIZZLEGGGR : false;
|
|
171
171
|
const { equalish, DEFAULT_REFRACTION_INDEX } = StandardMaterialOptionsBuilder;
|
|
172
172
|
options.specularityFactorTint = specularityFactorTint;
|
|
173
|
-
options.metalnessTint = stdMat.useMetalness
|
|
173
|
+
options.metalnessTint = stdMat.useMetalness;
|
|
174
174
|
options.glossTint = true;
|
|
175
175
|
options.diffuseEncoding = stdMat.diffuseMap?.encoding;
|
|
176
176
|
options.diffuseDetailEncoding = stdMat.diffuseDetailMap?.encoding;
|
|
@@ -200,7 +200,6 @@ class StandardMaterialOptionsBuilder {
|
|
|
200
200
|
options.litOptions.separateAmbient = false;
|
|
201
201
|
options.litOptions.pixelSnap = stdMat.pixelSnap;
|
|
202
202
|
options.litOptions.ambientSH = !!stdMat.ambientSH;
|
|
203
|
-
options.litOptions.twoSidedLighting = stdMat.twoSidedLighting;
|
|
204
203
|
options.litOptions.occludeSpecular = stdMat.occludeSpecular;
|
|
205
204
|
options.litOptions.occludeSpecularFloat = stdMat.occludeSpecularIntensity !== 1;
|
|
206
205
|
options.litOptions.useMsdf = !!stdMat.msdfMap;
|
|
@@ -209,7 +208,6 @@ class StandardMaterialOptionsBuilder {
|
|
|
209
208
|
options.litOptions.opacityFadesSpecular = stdMat.opacityFadesSpecular;
|
|
210
209
|
options.litOptions.opacityDither = stdMat.opacityDither;
|
|
211
210
|
options.litOptions.cubeMapProjection = stdMat.cubeMapProjection;
|
|
212
|
-
options.litOptions.occludeDirect = stdMat.occludeDirect;
|
|
213
211
|
options.litOptions.useSpecular = useSpecular;
|
|
214
212
|
options.litOptions.useSpecularityFactor = (specularityFactorTint || !!stdMat.specularityFactorMap) && stdMat.useMetalnessSpecularColor;
|
|
215
213
|
options.litOptions.enableGGXSpecular = stdMat.enableGGXSpecular;
|
|
@@ -23,7 +23,7 @@ import { EnvLighting } from "../graphics/env-lighting.js";
|
|
|
23
23
|
import { getProgramLibrary } from "../shader-lib/get-program-library.js";
|
|
24
24
|
import { _matTex2D, standard } from "../shader-lib/programs/standard.js";
|
|
25
25
|
import { Material } from "./material.js";
|
|
26
|
-
import { MaterialProperty, convertColorToLinear, convertFloat } from "./material-property.js";
|
|
26
|
+
import { MaterialProperty, convertBoolean, convertColorToLinear, convertFloat } from "./material-property.js";
|
|
27
27
|
import { getMaterialLayout } from "./material-uniform-buffer-layout.js";
|
|
28
28
|
import { getTextureDescriptors, getTextureIdentifiers, getTextureSharing } from "./standard-material-textures.js";
|
|
29
29
|
import { StandardMaterialMapTransforms } from "./standard-material-map-transforms.js";
|
|
@@ -82,6 +82,8 @@ const _properties = {
|
|
|
82
82
|
normalDetailMapBumpiness: new MaterialProperty("normalDetailMapBumpiness", "material_normalDetailMapBumpiness", UNIFORMTYPE_FLOAT, convertFloat),
|
|
83
83
|
reflectivity: new MaterialProperty("reflectivity", "material_reflectivity", UNIFORMTYPE_FLOAT, convertFloat),
|
|
84
84
|
occludeSpecularIntensity: new MaterialProperty("occludeSpecularIntensity", "material_occludeSpecularIntensity", UNIFORMTYPE_FLOAT, convertFloat),
|
|
85
|
+
occludeDirect: new MaterialProperty("occludeDirect", "material_occludeDirect", UNIFORMTYPE_FLOAT, convertBoolean),
|
|
86
|
+
twoSidedLighting: new MaterialProperty("twoSidedLighting", "material_twoSidedLighting", UNIFORMTYPE_FLOAT, convertBoolean),
|
|
85
87
|
refraction: new MaterialProperty("refraction", "material_refraction", UNIFORMTYPE_FLOAT, convertFloat),
|
|
86
88
|
refractionIndex: new MaterialProperty("refractionIndex", "material_refractionIndex", UNIFORMTYPE_FLOAT, convertFloat),
|
|
87
89
|
dispersion: new MaterialProperty("dispersion", "material_dispersion", UNIFORMTYPE_FLOAT, convertFloat),
|
|
@@ -405,7 +407,6 @@ class StandardMaterial extends Material {
|
|
|
405
407
|
}
|
|
406
408
|
set metalness(value) {
|
|
407
409
|
if (this._metalness !== value) {
|
|
408
|
-
this._dirtyShader = this._dirtyShader || dirtyShaderOnZeroOrOne(this._metalness, value);
|
|
409
410
|
this._metalness = value;
|
|
410
411
|
this._markPropertyModified(_properties.metalness);
|
|
411
412
|
}
|
|
@@ -937,7 +938,14 @@ function _defineMaterialProps() {
|
|
|
937
938
|
_defineFlag("useMetalnessSpecularColor", false);
|
|
938
939
|
_defineFlag("useSheen", false);
|
|
939
940
|
_defineFlag("enableGGXSpecular", false);
|
|
940
|
-
|
|
941
|
+
defineProp({
|
|
942
|
+
name: "occludeDirect",
|
|
943
|
+
defaultValue: false,
|
|
944
|
+
dirtyShaderFunc: () => false,
|
|
945
|
+
onSet: function() {
|
|
946
|
+
this._markPropertyModified(_properties.occludeDirect);
|
|
947
|
+
}
|
|
948
|
+
});
|
|
941
949
|
_defineFlag("opacityFadesSpecular", true);
|
|
942
950
|
_defineFlag("occludeSpecular", SPECOCC_AO);
|
|
943
951
|
_defineFlag("fresnelModel", FRESNEL_SCHLICK);
|
|
@@ -949,7 +957,14 @@ function _defineMaterialProps() {
|
|
|
949
957
|
_defineFlag("useSkybox", true);
|
|
950
958
|
_defineFlag("forceUv1", false);
|
|
951
959
|
_defineFlag("pixelSnap", false);
|
|
952
|
-
|
|
960
|
+
defineProp({
|
|
961
|
+
name: "twoSidedLighting",
|
|
962
|
+
defaultValue: false,
|
|
963
|
+
dirtyShaderFunc: () => false,
|
|
964
|
+
onSet: function() {
|
|
965
|
+
this._markPropertyModified(_properties.twoSidedLighting);
|
|
966
|
+
}
|
|
967
|
+
});
|
|
953
968
|
_defineFlag("nineSlicedMode", void 0);
|
|
954
969
|
_defineFlag("msdfTextAttribute", false);
|
|
955
970
|
_defineFlag("useIridescence", false);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "\nvoid evaluateBackend() {\n\n // apply SSAO during lighting\n #ifdef LIT_SSAO\n litArgs_ao *= texture2DLod(ssaoTexture, gl_FragCoord.xy * ssaoTextureSizeInv, 0.0).r;\n #endif\n\n // transform tangent space normals to world space\n #ifdef LIT_NEEDS_NORMAL\n #ifdef LIT_SPECULAR\n getReflDir(litArgs_worldNormal, dViewDirW, litArgs_gloss, dTBN);\n #endif\n\n #ifdef LIT_CLEARCOAT\n ccReflDirW = normalize(-reflect(dViewDirW, litArgs_clearcoat_worldNormal));\n #endif\n #endif\n\n #if defined(LIT_SPECULAR_OR_REFLECTION) || defined(LIT_REFRACTION)\n #ifdef LIT_METALNESS\n float f0 = 1.0 / litArgs_ior;\n f0 = (f0 - 1.0) / (f0 + 1.0);\n f0 *= f0;\n #ifdef LIT_SPECULARITY_FACTOR\n litArgs_specularity = getSpecularModulate(litArgs_specularity, litArgs_albedo, litArgs_metalness, f0, litArgs_specularityFactor);\n #else\n litArgs_specularity = getSpecularModulate(litArgs_specularity, litArgs_albedo, litArgs_metalness, f0, 1.0);\n #endif\n litArgs_albedo = getAlbedoModulate(litArgs_albedo, litArgs_metalness);\n\n // the diffuse transmission is a dielectric lobe, like the diffuse reflection\n #ifdef LIT_DIFFUSE_TRANSMISSION\n litArgs_diffuseTransmission_color = getAlbedoModulate(litArgs_diffuseTransmission_color, litArgs_metalness);\n #endif\n #endif\n\n #ifdef LIT_IRIDESCENCE\n vec3 iridescenceFresnel = getIridescence(saturate(dot(dViewDirW, litArgs_worldNormal)), litArgs_specularity, litArgs_iridescence_thickness);\n #endif\n #endif\n\n // ambient\n #ifdef LIT_ADD_AMBIENT\n\n // the ambient light arriving at the back of the surface, which the diffuse transmission\n // lets through, is added to the diffuse light first and moved out of it\n #ifdef LIT_DIFFUSE_TRANSMISSION\n addAmbient(-litArgs_worldNormal);\n dDiffuseTransmissionLight = dDiffuseLight;\n dDiffuseLight = vec3(0);\n #endif\n\n addAmbient(litArgs_worldNormal);\n\n #ifdef LIT_SPECULAR\n dDiffuseLight = dDiffuseLight * (1.0 - litArgs_specularity);\n\n #ifdef LIT_DIFFUSE_TRANSMISSION\n dDiffuseTransmissionLight *= 1.0 - litArgs_specularity;\n #endif\n #endif\n\n // move ambient color out of diffuse (used by Lightmapper, to multiply ambient color by accumulated AO)\n #ifdef LIT_SEPARATE_AMBIENT\n vec3 dAmbientLight = dDiffuseLight;\n dDiffuseLight = vec3(0);\n #endif\n #endif\n\n dDiffuseLight *= litArgs_ambient;\n\n #ifdef LIT_DIFFUSE_TRANSMISSION\n dDiffuseTransmissionLight *= litArgs_ambient;\n #endif\n\n #ifdef LIT_AO\n
|
|
1
|
+
declare const _default: "\nvoid evaluateBackend() {\n\n // apply SSAO during lighting\n #ifdef LIT_SSAO\n litArgs_ao *= texture2DLod(ssaoTexture, gl_FragCoord.xy * ssaoTextureSizeInv, 0.0).r;\n #endif\n\n // transform tangent space normals to world space\n #ifdef LIT_NEEDS_NORMAL\n #ifdef LIT_SPECULAR\n getReflDir(litArgs_worldNormal, dViewDirW, litArgs_gloss, dTBN);\n #endif\n\n #ifdef LIT_CLEARCOAT\n ccReflDirW = normalize(-reflect(dViewDirW, litArgs_clearcoat_worldNormal));\n #endif\n #endif\n\n #if defined(LIT_SPECULAR_OR_REFLECTION) || defined(LIT_REFRACTION)\n #ifdef LIT_METALNESS\n float f0 = 1.0 / litArgs_ior;\n f0 = (f0 - 1.0) / (f0 + 1.0);\n f0 *= f0;\n #ifdef LIT_SPECULARITY_FACTOR\n litArgs_specularity = getSpecularModulate(litArgs_specularity, litArgs_albedo, litArgs_metalness, f0, litArgs_specularityFactor);\n #else\n litArgs_specularity = getSpecularModulate(litArgs_specularity, litArgs_albedo, litArgs_metalness, f0, 1.0);\n #endif\n litArgs_albedo = getAlbedoModulate(litArgs_albedo, litArgs_metalness);\n\n // the diffuse transmission is a dielectric lobe, like the diffuse reflection\n #ifdef LIT_DIFFUSE_TRANSMISSION\n litArgs_diffuseTransmission_color = getAlbedoModulate(litArgs_diffuseTransmission_color, litArgs_metalness);\n #endif\n #endif\n\n #ifdef LIT_IRIDESCENCE\n vec3 iridescenceFresnel = getIridescence(saturate(dot(dViewDirW, litArgs_worldNormal)), litArgs_specularity, litArgs_iridescence_thickness);\n #endif\n #endif\n\n // ambient\n #ifdef LIT_ADD_AMBIENT\n\n // the ambient light arriving at the back of the surface, which the diffuse transmission\n // lets through, is added to the diffuse light first and moved out of it\n #ifdef LIT_DIFFUSE_TRANSMISSION\n addAmbient(-litArgs_worldNormal);\n dDiffuseTransmissionLight = dDiffuseLight;\n dDiffuseLight = vec3(0);\n #endif\n\n addAmbient(litArgs_worldNormal);\n\n #ifdef LIT_SPECULAR\n dDiffuseLight = dDiffuseLight * (1.0 - litArgs_specularity);\n\n #ifdef LIT_DIFFUSE_TRANSMISSION\n dDiffuseTransmissionLight *= 1.0 - litArgs_specularity;\n #endif\n #endif\n\n // move ambient color out of diffuse (used by Lightmapper, to multiply ambient color by accumulated AO)\n #ifdef LIT_SEPARATE_AMBIENT\n vec3 dAmbientLight = dDiffuseLight;\n dDiffuseLight = vec3(0);\n #endif\n #endif\n\n dDiffuseLight *= litArgs_ambient;\n\n #ifdef LIT_DIFFUSE_TRANSMISSION\n dDiffuseTransmissionLight *= litArgs_ambient;\n #endif\n\n // the ambient occlusion darkens the ambient light here, and with occludeDirect, which is 0 or 1,\n // the direct light as well, once that is added below\n #ifdef LIT_AO\n occludeDiffuse(mix(litArgs_ao, 1.0, material_occludeDirect));\n #endif\n\n #ifdef LIT_LIGHTMAP\n addLightMap(\n litArgs_lightmap, \n litArgs_lightmapDir, \n litArgs_worldNormal, \n dViewDirW, \n dReflDirW, \n litArgs_gloss, \n litArgs_specularity, \n dVertexNormalW,\n dTBN\n #if defined(LIT_IRIDESCENCE)\n , iridescenceFresnel,\n litArgs_iridescence_intensity\n #endif\n );\n #endif\n\n #ifdef LIT_LIGHTING || LIT_REFLECTIONS\n\n #ifdef LIT_REFLECTIONS\n\n #ifdef LIT_CLEARCOAT\n addReflectionCC(ccReflDirW, litArgs_clearcoat_gloss);\n \n #ifdef LIT_SPECULAR_FRESNEL\n ccFresnel = getFresnelCC(dot(dViewDirW, litArgs_clearcoat_worldNormal));\n ccReflection *= ccFresnel;\n #else\n ccFresnel = 0.0;\n #endif\n #endif\n\n #ifdef LIT_SPECULARITY_FACTOR\n ccReflection *= litArgs_specularityFactor;\n #endif\n\n #ifdef LIT_SHEEN\n addReflectionSheen(litArgs_worldNormal, dViewDirW, litArgs_sheen_gloss);\n #endif\n\n // Fresnel has to be applied to reflections\n addReflection(dReflDirW, litArgs_gloss);\n\n #ifdef LIT_FRESNEL_MODEL\n\n dReflection.rgb *= getFresnel(\n dot(dViewDirW, litArgs_worldNormal), \n litArgs_gloss, \n litArgs_specularity\n #if defined(LIT_IRIDESCENCE)\n , iridescenceFresnel,\n litArgs_iridescence_intensity\n #endif\n );\n\n #else\n\n dReflection.rgb *= litArgs_specularity;\n\n #endif\n\n #endif\n\n #ifdef AREA_LIGHTS\n // specular has to be accumulated differently if we want area lights to look correct\n dSpecularLight *= litArgs_specularity;\n\n #ifdef LIT_SPECULAR\n // evaluate material based area lights data, shared by all area lights\n calcLTCLightValues(litArgs_gloss, litArgs_worldNormal, dViewDirW, litArgs_specularity, litArgs_clearcoat_gloss, litArgs_clearcoat_worldNormal, litArgs_clearcoat_specularity);\n #endif\n #endif\n \n // LOOP - evaluate all non-clustered lights\n #ifdef LIGHT_COUNT > 0\n #include \"lightEvaluationPS, LIGHT_COUNT\"\n #endif\n\n // clustered lighting\n #ifdef LIT_CLUSTERED_LIGHTS\n addClusteredLights(litArgs_worldNormal, dViewDirW, dReflDirW,\n #if defined(LIT_CLEARCOAT)\n ccReflDirW,\n #endif\n litArgs_gloss, litArgs_specularity, dVertexNormalW, dTBN, \n #if defined(LIT_IRIDESCENCE)\n iridescenceFresnel,\n #endif\n litArgs_clearcoat_worldNormal, litArgs_clearcoat_gloss, litArgs_sheen_gloss, litArgs_iridescence_intensity\n );\n #endif\n\n #ifdef AREA_LIGHTS\n\n #ifdef LIT_CLEARCOAT\n // specular has to be accumulated differently if we want area lights to look correct\n litArgs_clearcoat_specularity = 1.0;\n #endif\n\n #ifdef LIT_SPECULAR\n litArgs_specularity = vec3(1);\n #endif\n\n #endif\n\n #endif\n\n // the diffuse transmission takes its share of the light entering the surface, and the diffuse\n // reflection the rest\n #ifdef LIT_DIFFUSE_TRANSMISSION\n dDiffuseLight *= 1.0 - litArgs_diffuseTransmission_intensity;\n dDiffuseTransmissionLight *= litArgs_diffuseTransmission_intensity;\n #endif\n\n // refraction is not gated on lighting / reflections, so that it also works without them\n #ifdef LIT_REFRACTION\n addRefraction(\n litArgs_worldNormal,\n dViewDirW,\n litArgs_thickness,\n litArgs_gloss,\n litArgs_specularity,\n litArgs_albedo,\n litArgs_transmission,\n litArgs_ior,\n litArgs_dispersion\n #if defined(LIT_IRIDESCENCE)\n , iridescenceFresnel,\n litArgs_iridescence_intensity\n #endif\n );\n\n // refraction replaces the diffuse transmission as it replaces the diffuse reflection\n #ifdef LIT_DIFFUSE_TRANSMISSION\n dDiffuseTransmissionLight *= 1.0 - litArgs_transmission;\n #endif\n #endif\n\n // apply ambient occlusion\n #ifdef LIT_AO\n occludeDiffuse(mix(1.0, litArgs_ao, material_occludeDirect));\n\n #if LIT_OCCLUDE_SPECULAR != NONE\n occludeSpecular(litArgs_gloss, litArgs_ao, litArgs_worldNormal, dViewDirW);\n #endif\n #endif\n\n #if !defined(LIT_OPACITY_FADES_SPECULAR)\n\n #if LIT_BLEND_TYPE == NORMAL || LIT_BLEND_TYPE == PREMULTIPLIED\n\n float specLum = dot((dSpecularLight + dReflection.rgb * dReflection.a), vec3( 0.2126, 0.7152, 0.0722 ));\n #ifdef LIT_CLEARCOAT\n specLum += dot(ccSpecularLight * litArgs_clearcoat_specularity + ccReflection * litArgs_clearcoat_specularity, vec3( 0.2126, 0.7152, 0.0722 ));\n #endif\n litArgs_opacity = clamp(litArgs_opacity + gammaCorrectInput(specLum), 0.0, 1.0);\n\n #endif\n\n litArgs_opacity *= material_alphaFade;\n\n #endif\n\n // end chunks - when baking lightmap\n #ifdef LIT_LIGHTMAP_BAKING\n #ifdef LIT_LIGHTMAP_BAKING_COLOR\n #include \"bakeLmEndPS\"\n #endif\n #ifdef LIT_LIGHTMAP_BAKING_DIR\n #include \"bakeDirLmEndPS\"\n #endif\n #else\n // end chunks - in all other cases\n #include \"endPS\"\n #include \"outputAlphaPS\"\n #endif\n\n #ifdef LIT_MSDF\n gl_FragColor = applyMsdf(gl_FragColor);\n #endif\n\n #include \"outputPS\"\n #include \"debugOutputPS\"\n\n #ifdef LIT_SHADOW_CATCHER\n // output when the shadow catcher is enabled - accumulated shadows\n gl_FragColor.rgb = vec3(dShadowCatcher);\n #endif\n\n #include \"outlineOutputPS\"\n}\n";
|
|
2
2
|
export default _default;
|
package/build/playcanvas/src/scene/shader-lib/glsl/chunks/lit/frag/pass-forward/litForwardBackend.js
CHANGED
|
@@ -53,9 +53,7 @@ void evaluateBackend() {
|
|
|
53
53
|
dDiffuseTransmissionLight *= litArgs_ambient;
|
|
54
54
|
#endif
|
|
55
55
|
#ifdef LIT_AO
|
|
56
|
-
|
|
57
|
-
occludeDiffuse(litArgs_ao);
|
|
58
|
-
#endif
|
|
56
|
+
occludeDiffuse(mix(litArgs_ao, 1.0, material_occludeDirect));
|
|
59
57
|
#endif
|
|
60
58
|
#ifdef LIT_LIGHTMAP
|
|
61
59
|
addLightMap(
|
|
@@ -163,9 +161,7 @@ void evaluateBackend() {
|
|
|
163
161
|
#endif
|
|
164
162
|
#endif
|
|
165
163
|
#ifdef LIT_AO
|
|
166
|
-
|
|
167
|
-
occludeDiffuse(litArgs_ao);
|
|
168
|
-
#endif
|
|
164
|
+
occludeDiffuse(mix(1.0, litArgs_ao, material_occludeDirect));
|
|
169
165
|
#if LIT_OCCLUDE_SPECULAR != NONE
|
|
170
166
|
occludeSpecular(litArgs_gloss, litArgs_ao, litArgs_worldNormal, dViewDirW);
|
|
171
167
|
#endif
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "\n\n// globals\nvec3 sReflection;\nvec3 dVertexNormalW;\nvec3 dTangentW;\nvec3 dBinormalW;\nvec3 dViewDirW;\nvec3 dReflDirW;\nvec3 ccReflDirW;\n\n// Per-light temporaries\nvec3 dLightDirNormW;\nfloat dAtten;\n\n// Outputs\nmat3 dTBN;\nvec4 dReflection;\nvec3 dDiffuseLight;\nvec3 dSpecularLight;\nfloat ccFresnel;\nvec3 ccReflection;\nvec3 ccSpecularLight;\nfloat ccSpecularityNoFres;\nvec3 sSpecularLight;\n\n#ifdef LIT_DIFFUSE_TRANSMISSION\n // the light arriving at the back of the surface, which the diffuse transmission lets through\n vec3 dDiffuseTransmissionLight = vec3(0.0);\n#endif\n\n// FRAGMENT SHADER INPUTS: UNIFORMS\n\n#ifndef LIT_OPACITY_FADES_SPECULAR\n uniform float material_alphaFade;\n#endif\n\n#ifdef LIT_SSAO\n uniform sampler2D ssaoTexture;\n uniform vec2 ssaoTextureSizeInv;\n#endif\n\n// dynamic refraction\n#ifdef LIT_SCENE_COLOR\n uniform sampler2D uSceneColorMap;\n#endif\n\n#ifdef LIT_SCREEN_SIZE\n uniform vec4 screen_size;\n#endif\n\n#ifdef LIT_TRANSFORMS\n uniform mat4 matrix_viewProjection;\n#endif\n\n// lighting and shadowing declarations\n\n#ifdef LIT_SHADOW_CATCHER\n // a variable to accumulate shadows for shadow catcher materials\n float dShadowCatcher = 1.0;\n#endif\n\n// LOOP - uniform declarations for all non-clustered lights\n#if LIGHT_COUNT > 0\n #include \"lightDeclarationPS, LIGHT_COUNT\"\n#endif\n\n// lightmap baking\n#ifdef STD_LIGHTMAP_DIR\n uniform float bakeDir;\n#endif\n#ifdef LIT_LIGHTMAP_BAKING_ADD_AMBIENT\n uniform float ambientBakeOcclusionContrast;\n uniform float ambientBakeOcclusionBrightness;\n#endif\n";
|
|
1
|
+
declare const _default: "\n\n// globals\nvec3 sReflection;\nvec3 dVertexNormalW;\nvec3 dTangentW;\nvec3 dBinormalW;\nvec3 dViewDirW;\nvec3 dReflDirW;\nvec3 ccReflDirW;\n\n// Per-light temporaries\nvec3 dLightDirNormW;\nfloat dAtten;\n\n// Outputs\nmat3 dTBN;\nvec4 dReflection;\nvec3 dDiffuseLight;\nvec3 dSpecularLight;\nfloat ccFresnel;\nvec3 ccReflection;\nvec3 ccSpecularLight;\nfloat ccSpecularityNoFres;\nvec3 sSpecularLight;\n\n#ifdef LIT_DIFFUSE_TRANSMISSION\n // the light arriving at the back of the surface, which the diffuse transmission lets through\n vec3 dDiffuseTransmissionLight = vec3(0.0);\n#endif\n\n// FRAGMENT SHADER INPUTS: UNIFORMS\n\n#ifndef LIT_OPACITY_FADES_SPECULAR\n uniform float material_alphaFade;\n#endif\n\n#ifdef LIT_AO\n uniform float material_occludeDirect;\n#endif\n\n#ifdef LIT_NEEDS_NORMAL\n uniform float material_twoSidedLighting;\n#endif\n\n#ifdef LIT_SSAO\n uniform sampler2D ssaoTexture;\n uniform vec2 ssaoTextureSizeInv;\n#endif\n\n// dynamic refraction\n#ifdef LIT_SCENE_COLOR\n uniform sampler2D uSceneColorMap;\n#endif\n\n#ifdef LIT_SCREEN_SIZE\n uniform vec4 screen_size;\n#endif\n\n#ifdef LIT_TRANSFORMS\n uniform mat4 matrix_viewProjection;\n#endif\n\n// lighting and shadowing declarations\n\n#ifdef LIT_SHADOW_CATCHER\n // a variable to accumulate shadows for shadow catcher materials\n float dShadowCatcher = 1.0;\n#endif\n\n// LOOP - uniform declarations for all non-clustered lights\n#if LIGHT_COUNT > 0\n #include \"lightDeclarationPS, LIGHT_COUNT\"\n#endif\n\n// lightmap baking\n#ifdef STD_LIGHTMAP_DIR\n uniform float bakeDir;\n#endif\n#ifdef LIT_LIGHTMAP_BAKING_ADD_AMBIENT\n uniform float ambientBakeOcclusionContrast;\n uniform float ambientBakeOcclusionBrightness;\n#endif\n";
|
|
2
2
|
export default _default;
|
|
@@ -23,6 +23,12 @@ vec3 sSpecularLight;
|
|
|
23
23
|
#ifndef LIT_OPACITY_FADES_SPECULAR
|
|
24
24
|
uniform float material_alphaFade;
|
|
25
25
|
#endif
|
|
26
|
+
#ifdef LIT_AO
|
|
27
|
+
uniform float material_occludeDirect;
|
|
28
|
+
#endif
|
|
29
|
+
#ifdef LIT_NEEDS_NORMAL
|
|
30
|
+
uniform float material_twoSidedLighting;
|
|
31
|
+
#endif
|
|
26
32
|
#ifdef LIT_SSAO
|
|
27
33
|
uniform sampler2D ssaoTexture;
|
|
28
34
|
uniform vec2 ssaoTextureSizeInv;
|
package/build/playcanvas/src/scene/shader-lib/glsl/chunks/lit/frag/pass-forward/litForwardMain.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "\n\n#include \"sceneTexturesPS\"\n\nvoid main(void) {\n\n #ifdef CLIP_PLANES\n applyClipPlanes(vPositionW);\n #endif\n\n #include \"litUserMainStartPS\"\n\n dReflection = vec4(0);\n\n #ifdef LIT_CLEARCOAT\n ccSpecularLight = vec3(0);\n ccReflection = vec3(0);\n #endif\n\n #if LIT_NONE_SLICE_MODE == SLICED\n #include \"startNineSlicedPS\"\n #elif LIT_NONE_SLICE_MODE == TILED\n #include \"startNineSlicedTiledPS\"\n #endif\n\n #ifdef LIT_NEEDS_NORMAL\n #ifdef FLAT_SHADING\n dVertexNormalW = getFlatNormal(vPositionW);\n #else\n dVertexNormalW = normalize(vNormalW);\n #endif\n\n #ifdef LIT_TANGENTS\n #if defined(LIT_HEIGHTS) || defined(LIT_USE_NORMALS) || defined(LIT_USE_CLEARCOAT_NORMALS) || defined(LIT_GGX_SPECULAR)\n dTangentW = vTangentW;\n dBinormalW = vBinormalW;\n #endif\n #endif\n\n getViewDir();\n\n #ifdef LIT_TBN\n getTBN(dTangentW, dBinormalW, dVertexNormalW);\n #endif\n\n // after the TBN matrix, which is built from the unflipped normal
|
|
1
|
+
declare const _default: "\n\n#include \"sceneTexturesPS\"\n\nvoid main(void) {\n\n #ifdef CLIP_PLANES\n applyClipPlanes(vPositionW);\n #endif\n\n #include \"litUserMainStartPS\"\n\n dReflection = vec4(0);\n\n #ifdef LIT_CLEARCOAT\n ccSpecularLight = vec3(0);\n ccReflection = vec3(0);\n #endif\n\n #if LIT_NONE_SLICE_MODE == SLICED\n #include \"startNineSlicedPS\"\n #elif LIT_NONE_SLICE_MODE == TILED\n #include \"startNineSlicedTiledPS\"\n #endif\n\n #ifdef LIT_NEEDS_NORMAL\n #ifdef FLAT_SHADING\n dVertexNormalW = getFlatNormal(vPositionW);\n #else\n dVertexNormalW = normalize(vNormalW);\n #endif\n\n #ifdef LIT_TANGENTS\n #if defined(LIT_HEIGHTS) || defined(LIT_USE_NORMALS) || defined(LIT_USE_CLEARCOAT_NORMALS) || defined(LIT_GGX_SPECULAR)\n dTangentW = vTangentW;\n dBinormalW = vBinormalW;\n #endif\n #endif\n\n getViewDir();\n\n #ifdef LIT_TBN\n getTBN(dTangentW, dBinormalW, dVertexNormalW);\n #endif\n\n // after the TBN matrix, which is built from the unflipped normal. twoSidedLighting is 0 or 1,\n // the same for every pixel the material renders.\n if (material_twoSidedLighting != 0.0) {\n handleTwoSidedLighting();\n }\n #endif\n\n // invoke frontend functions\n evaluateFrontend();\n\n #include \"debugProcessFrontendPS\"\n\n evaluateBackend();\n\n // guarded by the same define the write function tests internally, as vLinearDepth is only\n // generated when the depth is written\n #ifdef SCENE_TEXTURE_DEPTH\n writeSceneTextureDepth(vLinearDepth, 1.0);\n #endif\n\n #include \"litUserMainEndPS\"\n}\n";
|
|
2
2
|
export default _default;
|
package/build/playcanvas/src/scene/shader-lib/glsl/chunks/lit/frag/pass-forward/litForwardMain.js
CHANGED
|
@@ -31,9 +31,9 @@ void main(void) {
|
|
|
31
31
|
#ifdef LIT_TBN
|
|
32
32
|
getTBN(dTangentW, dBinormalW, dVertexNormalW);
|
|
33
33
|
#endif
|
|
34
|
-
|
|
34
|
+
if (material_twoSidedLighting != 0.0) {
|
|
35
35
|
handleTwoSidedLighting();
|
|
36
|
-
|
|
36
|
+
}
|
|
37
37
|
#endif
|
|
38
38
|
evaluateFrontend();
|
|
39
39
|
#include "debugProcessFrontendPS"
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "\n\n#include \"basePS\"\n#include \"sphericalPS\"\n#include \"decodePS\"\n#include \"gammaPS\"\n#include \"tonemappingPS\"\n#include \"fogPS\"\n\n// 9-slice support code\n#if LIT_NONE_SLICE_MODE == SLICED\n #include \"baseNineSlicedPS\"\n#elif LIT_NONE_SLICE_MODE == TILED\n #include \"baseNineSlicedTiledPS\"\n#endif\n\n// flat shading\n#ifdef FLAT_SHADING\n #include \"flatNormalPS\"\n#endif\n\n// TBN\n#ifdef LIT_TBN\n #include \"TBNPS\"\n#endif\n\n// two sided lighting\n#
|
|
1
|
+
declare const _default: "\n\n#include \"basePS\"\n#include \"sphericalPS\"\n#include \"decodePS\"\n#include \"gammaPS\"\n#include \"tonemappingPS\"\n#include \"fogPS\"\n\n// 9-slice support code\n#if LIT_NONE_SLICE_MODE == SLICED\n #include \"baseNineSlicedPS\"\n#elif LIT_NONE_SLICE_MODE == TILED\n #include \"baseNineSlicedTiledPS\"\n#endif\n\n// flat shading\n#ifdef FLAT_SHADING\n #include \"flatNormalPS\"\n#endif\n\n// TBN\n#ifdef LIT_TBN\n #include \"TBNPS\"\n#endif\n\n// two sided lighting\n#ifdef LIT_NEEDS_NORMAL\n #include \"twoSidedLightingPS\"\n#endif\n\n";
|
|
2
2
|
export default _default;
|
|
@@ -75,14 +75,6 @@ export class LitShaderOptions {
|
|
|
75
75
|
* Apply SSAO during the lighting.
|
|
76
76
|
*/
|
|
77
77
|
ssao: boolean;
|
|
78
|
-
/**
|
|
79
|
-
* The value of {@link StandardMaterial#twoSidedLighting}.
|
|
80
|
-
*/
|
|
81
|
-
twoSidedLighting: boolean;
|
|
82
|
-
/**
|
|
83
|
-
* The value of {@link StandardMaterial#occludeDirect}.
|
|
84
|
-
*/
|
|
85
|
-
occludeDirect: boolean;
|
|
86
78
|
/**
|
|
87
79
|
* The value of {@link StandardMaterial#occludeSpecular}.
|
|
88
80
|
*/
|
|
@@ -337,7 +337,6 @@ class LitShader {
|
|
|
337
337
|
this.fDefineSet(options.useCubeMapRotation, "CUBEMAP_ROTATION");
|
|
338
338
|
this.fDefineSet(options.occludeSpecularFloat, "LIT_OCCLUDE_SPECULAR_FLOAT");
|
|
339
339
|
this.fDefineSet(options.separateAmbient, "LIT_SEPARATE_AMBIENT");
|
|
340
|
-
this.fDefineSet(options.twoSidedLighting, "LIT_TWO_SIDED_LIGHTING");
|
|
341
340
|
this.fDefineSet(options.lightMapEnabled, "LIT_LIGHTMAP");
|
|
342
341
|
this.fDefineSet(options.dirLightMapEnabled, "LIT_DIR_LIGHTMAP");
|
|
343
342
|
this.fDefineSet(options.skyboxIntensity > 0, "LIT_SKYBOX_INTENSITY");
|
|
@@ -359,7 +358,6 @@ class LitShader {
|
|
|
359
358
|
this.fDefineSet(options.useMsdf, "LIT_MSDF");
|
|
360
359
|
this.fDefineSet(options.ssao, "LIT_SSAO");
|
|
361
360
|
this.fDefineSet(options.useAo, "LIT_AO");
|
|
362
|
-
this.fDefineSet(options.occludeDirect, "LIT_OCCLUDE_DIRECT");
|
|
363
361
|
this.fDefineSet(options.msdfTextAttribute, "LIT_MSDF_TEXT_ATTRIBUTE");
|
|
364
362
|
this.fDefineSet(options.shadowCatcher, "LIT_SHADOW_CATCHER");
|
|
365
363
|
this.fDefineSet(true, "LIT_FRESNEL_MODEL", fresnelNames[options.fresnelModel]);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "\nfn evaluateBackend() -> FragmentOutput {\n\n var output: FragmentOutput;\n\n // apply SSAO during lighting\n #ifdef LIT_SSAO\n litArgs_ao = litArgs_ao * textureSampleLevel(ssaoTexture, ssaoTextureSampler, pcPosition.xy * uniform.ssaoTextureSizeInv, 0.0).r;\n #endif\n\n // transform tangent space normals to world space\n #ifdef LIT_NEEDS_NORMAL\n #ifdef LIT_SPECULAR\n getReflDir(litArgs_worldNormal, dViewDirW, litArgs_gloss, dTBN);\n #endif\n\n #ifdef LIT_CLEARCOAT\n ccReflDirW = normalize(-reflect(dViewDirW, litArgs_clearcoat_worldNormal));\n #endif\n #endif\n\n #if defined(LIT_SPECULAR_OR_REFLECTION) || defined(LIT_REFRACTION)\n #ifdef LIT_METALNESS\n var f0: f32 = 1.0 / litArgs_ior;\n f0 = (f0 - 1.0) / (f0 + 1.0);\n f0 = f0 * f0;\n #ifdef LIT_SPECULARITY_FACTOR\n litArgs_specularity = getSpecularModulate(litArgs_specularity, litArgs_albedo, litArgs_metalness, f0, litArgs_specularityFactor);\n #else\n litArgs_specularity = getSpecularModulate(litArgs_specularity, litArgs_albedo, litArgs_metalness, f0, 1.0);\n #endif\n litArgs_albedo = getAlbedoModulate(litArgs_albedo, litArgs_metalness);\n\n // the diffuse transmission is a dielectric lobe, like the diffuse reflection\n #ifdef LIT_DIFFUSE_TRANSMISSION\n litArgs_diffuseTransmission_color = getAlbedoModulate(litArgs_diffuseTransmission_color, litArgs_metalness);\n #endif\n #endif\n\n #ifdef LIT_IRIDESCENCE\n var iridescenceFresnel: vec3f = getIridescenceDiffraction(saturate(dot(dViewDirW, litArgs_worldNormal)), litArgs_specularity, litArgs_iridescence_thickness);\n #endif\n #endif\n\n // ambient\n #ifdef LIT_ADD_AMBIENT\n\n // the ambient light arriving at the back of the surface, which the diffuse transmission\n // lets through, is added to the diffuse light first and moved out of it\n #ifdef LIT_DIFFUSE_TRANSMISSION\n addAmbient(-litArgs_worldNormal);\n dDiffuseTransmissionLight = dDiffuseLight;\n dDiffuseLight = vec3f(0.0);\n #endif\n\n addAmbient(litArgs_worldNormal);\n\n #ifdef LIT_SPECULAR\n dDiffuseLight = dDiffuseLight * (1.0 - litArgs_specularity);\n\n #ifdef LIT_DIFFUSE_TRANSMISSION\n dDiffuseTransmissionLight = dDiffuseTransmissionLight * (1.0 - litArgs_specularity);\n #endif\n #endif\n\n // move ambient color out of diffuse (used by Lightmapper, to multiply ambient color by accumulated AO)\n #ifdef LIT_SEPARATE_AMBIENT\n var dAmbientLight: vec3f = dDiffuseLight;\n dDiffuseLight = vec3(0.0);\n #endif\n #endif\n\n dDiffuseLight = dDiffuseLight * litArgs_ambient;\n\n #ifdef LIT_DIFFUSE_TRANSMISSION\n dDiffuseTransmissionLight = dDiffuseTransmissionLight * litArgs_ambient;\n #endif\n\n #ifdef LIT_AO\n #ifndef LIT_OCCLUDE_DIRECT\n occludeDiffuse(litArgs_ao);\n #endif\n #endif\n\n #ifdef LIT_LIGHTMAP\n addLightMap(\n litArgs_lightmap, \n litArgs_lightmapDir, \n litArgs_worldNormal, \n dViewDirW, \n dReflDirW, \n litArgs_gloss, \n litArgs_specularity, \n dVertexNormalW,\n dTBN\n #if defined(LIT_IRIDESCENCE)\n , iridescenceFresnel,\n litArgs_iridescence_intensity\n #endif\n );\n #endif\n\n #ifdef LIT_LIGHTING || LIT_REFLECTIONS\n\n #ifdef LIT_REFLECTIONS\n\n #ifdef LIT_CLEARCOAT\n addReflectionCC(ccReflDirW, litArgs_clearcoat_gloss);\n \n #ifdef LIT_SPECULAR_FRESNEL\n ccFresnel = getFresnelCC(dot(dViewDirW, litArgs_clearcoat_worldNormal));\n ccReflection = ccReflection * ccFresnel;\n #else\n ccFresnel = 0.0;\n #endif\n #endif\n\n #ifdef LIT_SPECULARITY_FACTOR\n ccReflection = ccReflection * litArgs_specularityFactor;\n #endif\n\n #ifdef LIT_SHEEN\n addReflectionSheen(litArgs_worldNormal, dViewDirW, litArgs_sheen_gloss);\n #endif\n\n // Fresnel has to be applied to reflections\n addReflection(dReflDirW, litArgs_gloss);\n\n #ifdef LIT_FRESNEL_MODEL\n\n dReflection = vec4f(\n dReflection.rgb * getFresnel(\n dot(dViewDirW, litArgs_worldNormal),\n litArgs_gloss,\n litArgs_specularity\n #if defined(LIT_IRIDESCENCE)\n , iridescenceFresnel,\n litArgs_iridescence_intensity\n #endif\n ),\n dReflection.a\n );\n\n #else\n\n dReflection = vec4f(dReflection.rgb * litArgs_specularity, dReflection.a);\n\n #endif\n\n #endif\n\n #ifdef AREA_LIGHTS\n // specular has to be accumulated differently if we want area lights to look correct\n dSpecularLight = dSpecularLight * litArgs_specularity;\n\n #ifdef LIT_SPECULAR\n // evaluate material based area lights data, shared by all area lights\n calcLTCLightValues(litArgs_gloss, litArgs_worldNormal, dViewDirW, litArgs_specularity, litArgs_clearcoat_gloss, litArgs_clearcoat_worldNormal, litArgs_clearcoat_specularity);\n #endif\n #endif\n \n // LOOP - evaluate all non-clustered lights\n #ifdef LIGHT_COUNT > 0\n #include \"lightEvaluationPS, LIGHT_COUNT\"\n #endif\n\n // clustered lighting\n #ifdef LIT_CLUSTERED_LIGHTS\n addClusteredLights(litArgs_worldNormal, dViewDirW, dReflDirW,\n #if defined(LIT_CLEARCOAT)\n ccReflDirW,\n #endif\n litArgs_gloss, litArgs_specularity, dVertexNormalW, dTBN, \n #if defined(LIT_IRIDESCENCE)\n iridescenceFresnel,\n #endif\n litArgs_clearcoat_worldNormal, litArgs_clearcoat_gloss, litArgs_sheen_gloss, litArgs_iridescence_intensity\n );\n #endif\n\n #ifdef AREA_LIGHTS\n\n #ifdef LIT_CLEARCOAT\n // specular has to be accumulated differently if we want area lights to look correct\n litArgs_clearcoat_specularity = 1.0;\n #endif\n\n #ifdef LIT_SPECULAR\n litArgs_specularity = vec3(1.0);\n #endif\n\n #endif\n\n #endif\n\n // the diffuse transmission takes its share of the light entering the surface, and the diffuse\n // reflection the rest\n #ifdef LIT_DIFFUSE_TRANSMISSION\n dDiffuseLight = dDiffuseLight * (1.0 - litArgs_diffuseTransmission_intensity);\n dDiffuseTransmissionLight = dDiffuseTransmissionLight * litArgs_diffuseTransmission_intensity;\n #endif\n\n // refraction is not gated on lighting / reflections, so that it also works without them\n #ifdef LIT_REFRACTION\n addRefraction(\n litArgs_worldNormal,\n dViewDirW,\n litArgs_thickness,\n litArgs_gloss,\n litArgs_specularity,\n litArgs_albedo,\n litArgs_transmission,\n litArgs_ior,\n litArgs_dispersion\n #if defined(LIT_IRIDESCENCE)\n , iridescenceFresnel,\n litArgs_iridescence_intensity\n #endif\n );\n\n // refraction replaces the diffuse transmission as it replaces the diffuse reflection\n #ifdef LIT_DIFFUSE_TRANSMISSION\n dDiffuseTransmissionLight = dDiffuseTransmissionLight * (1.0 - litArgs_transmission);\n #endif\n #endif\n\n // apply ambient occlusion\n #ifdef LIT_AO\n #ifdef LIT_OCCLUDE_DIRECT\n occludeDiffuse(litArgs_ao);\n #endif\n\n #if LIT_OCCLUDE_SPECULAR != NONE\n occludeSpecular(litArgs_gloss, litArgs_ao, litArgs_worldNormal, dViewDirW);\n #endif\n #endif\n\n #if !defined(LIT_OPACITY_FADES_SPECULAR)\n\n #if LIT_BLEND_TYPE == NORMAL || LIT_BLEND_TYPE == PREMULTIPLIED\n\n var specLum: f32 = dot((dSpecularLight + dReflection.rgb * dReflection.a), vec3f( 0.2126, 0.7152, 0.0722 ));\n #ifdef LIT_CLEARCOAT\n specLum = specLum + dot(ccSpecularLight * litArgs_clearcoat_specularity + ccReflection * litArgs_clearcoat_specularity, vec3f( 0.2126, 0.7152, 0.0722 ));\n #endif\n litArgs_opacity = clamp(litArgs_opacity + gammaCorrectInput(specLum), 0.0, 1.0);\n\n #endif\n\n litArgs_opacity = litArgs_opacity * uniform.material_alphaFade;\n\n #endif\n\n // end chunks - when baking lightmap\n #ifdef LIT_LIGHTMAP_BAKING\n #ifdef LIT_LIGHTMAP_BAKING_COLOR\n #include \"bakeLmEndPS\"\n #endif\n #ifdef LIT_LIGHTMAP_BAKING_DIR\n #include \"bakeDirLmEndPS\"\n #endif\n #else\n // end chunks - in all other cases\n #include \"endPS\"\n #include \"outputAlphaPS\"\n #endif\n\n #ifdef LIT_MSDF\n output.color = applyMsdf(output.color);\n #endif\n\n #include \"outputPS\"\n #include \"debugOutputPS\"\n\n #ifdef LIT_SHADOW_CATCHER\n // output when the shadow catcher is enabled - accumulated shadows\n output.color = vec4f(vec3f(dShadowCatcher), output.color.a);\n #endif\n\n #include \"outlineOutputPS\"\n\n return output;\n}\n";
|
|
1
|
+
declare const _default: "\nfn evaluateBackend() -> FragmentOutput {\n\n var output: FragmentOutput;\n\n // apply SSAO during lighting\n #ifdef LIT_SSAO\n litArgs_ao = litArgs_ao * textureSampleLevel(ssaoTexture, ssaoTextureSampler, pcPosition.xy * uniform.ssaoTextureSizeInv, 0.0).r;\n #endif\n\n // transform tangent space normals to world space\n #ifdef LIT_NEEDS_NORMAL\n #ifdef LIT_SPECULAR\n getReflDir(litArgs_worldNormal, dViewDirW, litArgs_gloss, dTBN);\n #endif\n\n #ifdef LIT_CLEARCOAT\n ccReflDirW = normalize(-reflect(dViewDirW, litArgs_clearcoat_worldNormal));\n #endif\n #endif\n\n #if defined(LIT_SPECULAR_OR_REFLECTION) || defined(LIT_REFRACTION)\n #ifdef LIT_METALNESS\n var f0: f32 = 1.0 / litArgs_ior;\n f0 = (f0 - 1.0) / (f0 + 1.0);\n f0 = f0 * f0;\n #ifdef LIT_SPECULARITY_FACTOR\n litArgs_specularity = getSpecularModulate(litArgs_specularity, litArgs_albedo, litArgs_metalness, f0, litArgs_specularityFactor);\n #else\n litArgs_specularity = getSpecularModulate(litArgs_specularity, litArgs_albedo, litArgs_metalness, f0, 1.0);\n #endif\n litArgs_albedo = getAlbedoModulate(litArgs_albedo, litArgs_metalness);\n\n // the diffuse transmission is a dielectric lobe, like the diffuse reflection\n #ifdef LIT_DIFFUSE_TRANSMISSION\n litArgs_diffuseTransmission_color = getAlbedoModulate(litArgs_diffuseTransmission_color, litArgs_metalness);\n #endif\n #endif\n\n #ifdef LIT_IRIDESCENCE\n var iridescenceFresnel: vec3f = getIridescenceDiffraction(saturate(dot(dViewDirW, litArgs_worldNormal)), litArgs_specularity, litArgs_iridescence_thickness);\n #endif\n #endif\n\n // ambient\n #ifdef LIT_ADD_AMBIENT\n\n // the ambient light arriving at the back of the surface, which the diffuse transmission\n // lets through, is added to the diffuse light first and moved out of it\n #ifdef LIT_DIFFUSE_TRANSMISSION\n addAmbient(-litArgs_worldNormal);\n dDiffuseTransmissionLight = dDiffuseLight;\n dDiffuseLight = vec3f(0.0);\n #endif\n\n addAmbient(litArgs_worldNormal);\n\n #ifdef LIT_SPECULAR\n dDiffuseLight = dDiffuseLight * (1.0 - litArgs_specularity);\n\n #ifdef LIT_DIFFUSE_TRANSMISSION\n dDiffuseTransmissionLight = dDiffuseTransmissionLight * (1.0 - litArgs_specularity);\n #endif\n #endif\n\n // move ambient color out of diffuse (used by Lightmapper, to multiply ambient color by accumulated AO)\n #ifdef LIT_SEPARATE_AMBIENT\n var dAmbientLight: vec3f = dDiffuseLight;\n dDiffuseLight = vec3(0.0);\n #endif\n #endif\n\n dDiffuseLight = dDiffuseLight * litArgs_ambient;\n\n #ifdef LIT_DIFFUSE_TRANSMISSION\n dDiffuseTransmissionLight = dDiffuseTransmissionLight * litArgs_ambient;\n #endif\n\n // the ambient occlusion darkens the ambient light here, and with occludeDirect, which is 0 or 1,\n // the direct light as well, once that is added below\n #ifdef LIT_AO\n occludeDiffuse(mix(litArgs_ao, 1.0, uniform.material_occludeDirect));\n #endif\n\n #ifdef LIT_LIGHTMAP\n addLightMap(\n litArgs_lightmap, \n litArgs_lightmapDir, \n litArgs_worldNormal, \n dViewDirW, \n dReflDirW, \n litArgs_gloss, \n litArgs_specularity, \n dVertexNormalW,\n dTBN\n #if defined(LIT_IRIDESCENCE)\n , iridescenceFresnel,\n litArgs_iridescence_intensity\n #endif\n );\n #endif\n\n #ifdef LIT_LIGHTING || LIT_REFLECTIONS\n\n #ifdef LIT_REFLECTIONS\n\n #ifdef LIT_CLEARCOAT\n addReflectionCC(ccReflDirW, litArgs_clearcoat_gloss);\n \n #ifdef LIT_SPECULAR_FRESNEL\n ccFresnel = getFresnelCC(dot(dViewDirW, litArgs_clearcoat_worldNormal));\n ccReflection = ccReflection * ccFresnel;\n #else\n ccFresnel = 0.0;\n #endif\n #endif\n\n #ifdef LIT_SPECULARITY_FACTOR\n ccReflection = ccReflection * litArgs_specularityFactor;\n #endif\n\n #ifdef LIT_SHEEN\n addReflectionSheen(litArgs_worldNormal, dViewDirW, litArgs_sheen_gloss);\n #endif\n\n // Fresnel has to be applied to reflections\n addReflection(dReflDirW, litArgs_gloss);\n\n #ifdef LIT_FRESNEL_MODEL\n\n dReflection = vec4f(\n dReflection.rgb * getFresnel(\n dot(dViewDirW, litArgs_worldNormal),\n litArgs_gloss,\n litArgs_specularity\n #if defined(LIT_IRIDESCENCE)\n , iridescenceFresnel,\n litArgs_iridescence_intensity\n #endif\n ),\n dReflection.a\n );\n\n #else\n\n dReflection = vec4f(dReflection.rgb * litArgs_specularity, dReflection.a);\n\n #endif\n\n #endif\n\n #ifdef AREA_LIGHTS\n // specular has to be accumulated differently if we want area lights to look correct\n dSpecularLight = dSpecularLight * litArgs_specularity;\n\n #ifdef LIT_SPECULAR\n // evaluate material based area lights data, shared by all area lights\n calcLTCLightValues(litArgs_gloss, litArgs_worldNormal, dViewDirW, litArgs_specularity, litArgs_clearcoat_gloss, litArgs_clearcoat_worldNormal, litArgs_clearcoat_specularity);\n #endif\n #endif\n \n // LOOP - evaluate all non-clustered lights\n #ifdef LIGHT_COUNT > 0\n #include \"lightEvaluationPS, LIGHT_COUNT\"\n #endif\n\n // clustered lighting\n #ifdef LIT_CLUSTERED_LIGHTS\n addClusteredLights(litArgs_worldNormal, dViewDirW, dReflDirW,\n #if defined(LIT_CLEARCOAT)\n ccReflDirW,\n #endif\n litArgs_gloss, litArgs_specularity, dVertexNormalW, dTBN, \n #if defined(LIT_IRIDESCENCE)\n iridescenceFresnel,\n #endif\n litArgs_clearcoat_worldNormal, litArgs_clearcoat_gloss, litArgs_sheen_gloss, litArgs_iridescence_intensity\n );\n #endif\n\n #ifdef AREA_LIGHTS\n\n #ifdef LIT_CLEARCOAT\n // specular has to be accumulated differently if we want area lights to look correct\n litArgs_clearcoat_specularity = 1.0;\n #endif\n\n #ifdef LIT_SPECULAR\n litArgs_specularity = vec3(1.0);\n #endif\n\n #endif\n\n #endif\n\n // the diffuse transmission takes its share of the light entering the surface, and the diffuse\n // reflection the rest\n #ifdef LIT_DIFFUSE_TRANSMISSION\n dDiffuseLight = dDiffuseLight * (1.0 - litArgs_diffuseTransmission_intensity);\n dDiffuseTransmissionLight = dDiffuseTransmissionLight * litArgs_diffuseTransmission_intensity;\n #endif\n\n // refraction is not gated on lighting / reflections, so that it also works without them\n #ifdef LIT_REFRACTION\n addRefraction(\n litArgs_worldNormal,\n dViewDirW,\n litArgs_thickness,\n litArgs_gloss,\n litArgs_specularity,\n litArgs_albedo,\n litArgs_transmission,\n litArgs_ior,\n litArgs_dispersion\n #if defined(LIT_IRIDESCENCE)\n , iridescenceFresnel,\n litArgs_iridescence_intensity\n #endif\n );\n\n // refraction replaces the diffuse transmission as it replaces the diffuse reflection\n #ifdef LIT_DIFFUSE_TRANSMISSION\n dDiffuseTransmissionLight = dDiffuseTransmissionLight * (1.0 - litArgs_transmission);\n #endif\n #endif\n\n // apply ambient occlusion\n #ifdef LIT_AO\n occludeDiffuse(mix(1.0, litArgs_ao, uniform.material_occludeDirect));\n\n #if LIT_OCCLUDE_SPECULAR != NONE\n occludeSpecular(litArgs_gloss, litArgs_ao, litArgs_worldNormal, dViewDirW);\n #endif\n #endif\n\n #if !defined(LIT_OPACITY_FADES_SPECULAR)\n\n #if LIT_BLEND_TYPE == NORMAL || LIT_BLEND_TYPE == PREMULTIPLIED\n\n var specLum: f32 = dot((dSpecularLight + dReflection.rgb * dReflection.a), vec3f( 0.2126, 0.7152, 0.0722 ));\n #ifdef LIT_CLEARCOAT\n specLum = specLum + dot(ccSpecularLight * litArgs_clearcoat_specularity + ccReflection * litArgs_clearcoat_specularity, vec3f( 0.2126, 0.7152, 0.0722 ));\n #endif\n litArgs_opacity = clamp(litArgs_opacity + gammaCorrectInput(specLum), 0.0, 1.0);\n\n #endif\n\n litArgs_opacity = litArgs_opacity * uniform.material_alphaFade;\n\n #endif\n\n // end chunks - when baking lightmap\n #ifdef LIT_LIGHTMAP_BAKING\n #ifdef LIT_LIGHTMAP_BAKING_COLOR\n #include \"bakeLmEndPS\"\n #endif\n #ifdef LIT_LIGHTMAP_BAKING_DIR\n #include \"bakeDirLmEndPS\"\n #endif\n #else\n // end chunks - in all other cases\n #include \"endPS\"\n #include \"outputAlphaPS\"\n #endif\n\n #ifdef LIT_MSDF\n output.color = applyMsdf(output.color);\n #endif\n\n #include \"outputPS\"\n #include \"debugOutputPS\"\n\n #ifdef LIT_SHADOW_CATCHER\n // output when the shadow catcher is enabled - accumulated shadows\n output.color = vec4f(vec3f(dShadowCatcher), output.color.a);\n #endif\n\n #include \"outlineOutputPS\"\n\n return output;\n}\n";
|
|
2
2
|
export default _default;
|
package/build/playcanvas/src/scene/shader-lib/wgsl/chunks/lit/frag/pass-forward/litForwardBackend.js
CHANGED
|
@@ -54,9 +54,7 @@ fn evaluateBackend() -> FragmentOutput {
|
|
|
54
54
|
dDiffuseTransmissionLight = dDiffuseTransmissionLight * litArgs_ambient;
|
|
55
55
|
#endif
|
|
56
56
|
#ifdef LIT_AO
|
|
57
|
-
|
|
58
|
-
occludeDiffuse(litArgs_ao);
|
|
59
|
-
#endif
|
|
57
|
+
occludeDiffuse(mix(litArgs_ao, 1.0, uniform.material_occludeDirect));
|
|
60
58
|
#endif
|
|
61
59
|
#ifdef LIT_LIGHTMAP
|
|
62
60
|
addLightMap(
|
|
@@ -167,9 +165,7 @@ fn evaluateBackend() -> FragmentOutput {
|
|
|
167
165
|
#endif
|
|
168
166
|
#endif
|
|
169
167
|
#ifdef LIT_AO
|
|
170
|
-
|
|
171
|
-
occludeDiffuse(litArgs_ao);
|
|
172
|
-
#endif
|
|
168
|
+
occludeDiffuse(mix(1.0, litArgs_ao, uniform.material_occludeDirect));
|
|
173
169
|
#if LIT_OCCLUDE_SPECULAR != NONE
|
|
174
170
|
occludeSpecular(litArgs_gloss, litArgs_ao, litArgs_worldNormal, dViewDirW);
|
|
175
171
|
#endif
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "\n\n// globals\nvar<private> sReflection: vec3f;\nvar<private> dVertexNormalW: vec3f;\nvar<private> dTangentW: vec3f;\nvar<private> dBinormalW: vec3f;\nvar<private> dViewDirW: vec3f;\nvar<private> dReflDirW: vec3f;\nvar<private> ccReflDirW: vec3f;\n\n// Per-light temporaries\nvar<private> dLightDirNormW: vec3f;\nvar<private> dAtten: f32;\n\n// Outputs\nvar<private> dTBN: mat3x3f;\nvar<private> dReflection: vec4f;\nvar<private> dDiffuseLight: vec3f;\nvar<private> dSpecularLight: vec3f;\nvar<private> ccFresnel: f32;\nvar<private> ccReflection: vec3f;\nvar<private> ccSpecularLight: vec3f;\nvar<private> ccSpecularityNoFres: f32;\nvar<private> sSpecularLight: vec3f;\n\n#ifdef LIT_DIFFUSE_TRANSMISSION\n // the light arriving at the back of the surface, which the diffuse transmission lets through\n var<private> dDiffuseTransmissionLight: vec3f = vec3f(0.0);\n#endif\n\n// FRAGMENT SHADER INPUTS: UNIFORMS\n\n#ifndef LIT_OPACITY_FADES_SPECULAR\n uniform material_alphaFade: f32;\n#endif\n\n#ifdef LIT_SSAO\n var ssaoTexture : texture_2d<f32>;\n var ssaoTextureSampler : sampler;\n uniform ssaoTextureSizeInv: vec2f;\n#endif\n\n// dynamic refraction (matrix_viewProjection comes from the view uniform buffer)\n#ifdef LIT_SCENE_COLOR\n var uSceneColorMap : texture_2d<f32>;\n var uSceneColorMapSampler : sampler;\n#endif\n\n#ifdef LIT_SCREEN_SIZE\n uniform screen_size: vec4f;\n#endif\n\n// lighting and shadowing declarations\n\n#ifdef LIT_SHADOW_CATCHER\n // a variable to accumulate shadows for shadow catcher materials\n var<private> dShadowCatcher: f32 = 1.0;\n#endif\n\n// LOOP - uniform declarations for all non-clustered lights\n#if LIGHT_COUNT > 0\n #include \"lightDeclarationPS, LIGHT_COUNT\"\n#endif\n\n// lightmap baking\n#ifdef STD_LIGHTMAP_DIR\n uniform bakeDir: f32;\n#endif\n#ifdef LIT_LIGHTMAP_BAKING_ADD_AMBIENT\n uniform ambientBakeOcclusionContrast: f32;\n uniform ambientBakeOcclusionBrightness: f32;\n#endif\n";
|
|
1
|
+
declare const _default: "\n\n// globals\nvar<private> sReflection: vec3f;\nvar<private> dVertexNormalW: vec3f;\nvar<private> dTangentW: vec3f;\nvar<private> dBinormalW: vec3f;\nvar<private> dViewDirW: vec3f;\nvar<private> dReflDirW: vec3f;\nvar<private> ccReflDirW: vec3f;\n\n// Per-light temporaries\nvar<private> dLightDirNormW: vec3f;\nvar<private> dAtten: f32;\n\n// Outputs\nvar<private> dTBN: mat3x3f;\nvar<private> dReflection: vec4f;\nvar<private> dDiffuseLight: vec3f;\nvar<private> dSpecularLight: vec3f;\nvar<private> ccFresnel: f32;\nvar<private> ccReflection: vec3f;\nvar<private> ccSpecularLight: vec3f;\nvar<private> ccSpecularityNoFres: f32;\nvar<private> sSpecularLight: vec3f;\n\n#ifdef LIT_DIFFUSE_TRANSMISSION\n // the light arriving at the back of the surface, which the diffuse transmission lets through\n var<private> dDiffuseTransmissionLight: vec3f = vec3f(0.0);\n#endif\n\n// FRAGMENT SHADER INPUTS: UNIFORMS\n\n#ifndef LIT_OPACITY_FADES_SPECULAR\n uniform material_alphaFade: f32;\n#endif\n\n#ifdef LIT_AO\n uniform material_occludeDirect: f32;\n#endif\n\n#ifdef LIT_NEEDS_NORMAL\n uniform material_twoSidedLighting: f32;\n#endif\n\n#ifdef LIT_SSAO\n var ssaoTexture : texture_2d<f32>;\n var ssaoTextureSampler : sampler;\n uniform ssaoTextureSizeInv: vec2f;\n#endif\n\n// dynamic refraction (matrix_viewProjection comes from the view uniform buffer)\n#ifdef LIT_SCENE_COLOR\n var uSceneColorMap : texture_2d<f32>;\n var uSceneColorMapSampler : sampler;\n#endif\n\n#ifdef LIT_SCREEN_SIZE\n uniform screen_size: vec4f;\n#endif\n\n// lighting and shadowing declarations\n\n#ifdef LIT_SHADOW_CATCHER\n // a variable to accumulate shadows for shadow catcher materials\n var<private> dShadowCatcher: f32 = 1.0;\n#endif\n\n// LOOP - uniform declarations for all non-clustered lights\n#if LIGHT_COUNT > 0\n #include \"lightDeclarationPS, LIGHT_COUNT\"\n#endif\n\n// lightmap baking\n#ifdef STD_LIGHTMAP_DIR\n uniform bakeDir: f32;\n#endif\n#ifdef LIT_LIGHTMAP_BAKING_ADD_AMBIENT\n uniform ambientBakeOcclusionContrast: f32;\n uniform ambientBakeOcclusionBrightness: f32;\n#endif\n";
|
|
2
2
|
export default _default;
|
|
@@ -23,6 +23,12 @@ var<private> sSpecularLight: vec3f;
|
|
|
23
23
|
#ifndef LIT_OPACITY_FADES_SPECULAR
|
|
24
24
|
uniform material_alphaFade: f32;
|
|
25
25
|
#endif
|
|
26
|
+
#ifdef LIT_AO
|
|
27
|
+
uniform material_occludeDirect: f32;
|
|
28
|
+
#endif
|
|
29
|
+
#ifdef LIT_NEEDS_NORMAL
|
|
30
|
+
uniform material_twoSidedLighting: f32;
|
|
31
|
+
#endif
|
|
26
32
|
#ifdef LIT_SSAO
|
|
27
33
|
var ssaoTexture : texture_2d<f32>;
|
|
28
34
|
var ssaoTextureSampler : sampler;
|
package/build/playcanvas/src/scene/shader-lib/wgsl/chunks/lit/frag/pass-forward/litForwardMain.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "\n\n#include \"sceneTexturesPS\"\n\n@fragment\nfn fragmentMain(input: FragmentInput) -> FragmentOutput {\n\n #ifdef CLIP_PLANES\n applyClipPlanes(vPositionW);\n #endif\n\n #include \"litUserMainStartPS\"\n\n dReflection = vec4f(0.0);\n\n #ifdef LIT_CLEARCOAT\n ccSpecularLight = vec3f(0.0);\n ccReflection = vec3f(0.0);\n #endif\n\n #if LIT_NONE_SLICE_MODE == SLICED\n #include \"startNineSlicedPS\"\n #elif LIT_NONE_SLICE_MODE == TILED\n #include \"startNineSlicedTiledPS\"\n #endif\n\n #ifdef LIT_NEEDS_NORMAL\n #ifdef FLAT_SHADING\n dVertexNormalW = getFlatNormal(vPositionW);\n #else\n dVertexNormalW = normalize(vNormalW);\n #endif\n\n #ifdef LIT_TANGENTS\n #if defined(LIT_HEIGHTS) || defined(LIT_USE_NORMALS) || defined(LIT_USE_CLEARCOAT_NORMALS) || defined(LIT_GGX_SPECULAR)\n dTangentW = vTangentW;\n dBinormalW = vBinormalW;\n #endif\n #endif\n\n getViewDir();\n\n #ifdef LIT_TBN\n getTBN(dTangentW, dBinormalW, dVertexNormalW);\n #endif\n\n // after the TBN matrix, which is built from the unflipped normal
|
|
1
|
+
declare const _default: "\n\n#include \"sceneTexturesPS\"\n\n@fragment\nfn fragmentMain(input: FragmentInput) -> FragmentOutput {\n\n #ifdef CLIP_PLANES\n applyClipPlanes(vPositionW);\n #endif\n\n #include \"litUserMainStartPS\"\n\n dReflection = vec4f(0.0);\n\n #ifdef LIT_CLEARCOAT\n ccSpecularLight = vec3f(0.0);\n ccReflection = vec3f(0.0);\n #endif\n\n #if LIT_NONE_SLICE_MODE == SLICED\n #include \"startNineSlicedPS\"\n #elif LIT_NONE_SLICE_MODE == TILED\n #include \"startNineSlicedTiledPS\"\n #endif\n\n #ifdef LIT_NEEDS_NORMAL\n #ifdef FLAT_SHADING\n dVertexNormalW = getFlatNormal(vPositionW);\n #else\n dVertexNormalW = normalize(vNormalW);\n #endif\n\n #ifdef LIT_TANGENTS\n #if defined(LIT_HEIGHTS) || defined(LIT_USE_NORMALS) || defined(LIT_USE_CLEARCOAT_NORMALS) || defined(LIT_GGX_SPECULAR)\n dTangentW = vTangentW;\n dBinormalW = vBinormalW;\n #endif\n #endif\n\n getViewDir();\n\n #ifdef LIT_TBN\n getTBN(dTangentW, dBinormalW, dVertexNormalW);\n #endif\n\n // after the TBN matrix, which is built from the unflipped normal. twoSidedLighting is 0 or 1,\n // the same for every pixel the material renders.\n if (uniform.material_twoSidedLighting != 0.0) {\n handleTwoSidedLighting();\n }\n #endif\n\n // invoke frontend functions\n evaluateFrontend();\n\n #include \"debugProcessFrontendPS\"\n\n var output: FragmentOutput = evaluateBackend();\n\n // guarded by the same define the write function tests internally, as vLinearDepth is only\n // generated when the depth is written\n #ifdef SCENE_TEXTURE_DEPTH\n writeSceneTextureDepth(&output, vLinearDepth, 1.0);\n #endif\n\n #include \"litUserMainEndPS\"\n\n return output;\n}\n";
|
|
2
2
|
export default _default;
|
package/build/playcanvas/src/scene/shader-lib/wgsl/chunks/lit/frag/pass-forward/litForwardMain.js
CHANGED
|
@@ -32,9 +32,9 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
|
|
|
32
32
|
#ifdef LIT_TBN
|
|
33
33
|
getTBN(dTangentW, dBinormalW, dVertexNormalW);
|
|
34
34
|
#endif
|
|
35
|
-
|
|
35
|
+
if (uniform.material_twoSidedLighting != 0.0) {
|
|
36
36
|
handleTwoSidedLighting();
|
|
37
|
-
|
|
37
|
+
}
|
|
38
38
|
#endif
|
|
39
39
|
evaluateFrontend();
|
|
40
40
|
#include "debugProcessFrontendPS"
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "\n\n#include \"basePS\"\n#include \"sphericalPS\"\n#include \"decodePS\"\n#include \"gammaPS\"\n#include \"tonemappingPS\"\n#include \"fogPS\"\n\n// 9-slice support code\n#if LIT_NONE_SLICE_MODE == SLICED\n #include \"baseNineSlicedPS\"\n#elif LIT_NONE_SLICE_MODE == TILED\n #include \"baseNineSlicedTiledPS\"\n#endif\n\n// flat shading\n#ifdef FLAT_SHADING\n #include \"flatNormalPS\"\n#endif\n\n// TBN\n#ifdef LIT_TBN\n #include \"TBNPS\"\n#endif\n\n// two sided lighting\n#
|
|
1
|
+
declare const _default: "\n\n#include \"basePS\"\n#include \"sphericalPS\"\n#include \"decodePS\"\n#include \"gammaPS\"\n#include \"tonemappingPS\"\n#include \"fogPS\"\n\n// 9-slice support code\n#if LIT_NONE_SLICE_MODE == SLICED\n #include \"baseNineSlicedPS\"\n#elif LIT_NONE_SLICE_MODE == TILED\n #include \"baseNineSlicedTiledPS\"\n#endif\n\n// flat shading\n#ifdef FLAT_SHADING\n #include \"flatNormalPS\"\n#endif\n\n// TBN\n#ifdef LIT_TBN\n #include \"TBNPS\"\n#endif\n\n// two sided lighting\n#ifdef LIT_NEEDS_NORMAL\n #include \"twoSidedLightingPS\"\n#endif\n\n";
|
|
2
2
|
export default _default;
|
package/build/playcanvas/src/scene/shader-lib/wgsl/chunks/particle/vert/particleAnimFrameClamp.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "\n let animFrame: f32 = min(floor(
|
|
1
|
+
declare const _default: "\n let animFrame: f32 = min(floor(output.texCoordsAlphaLife.w * uniform.animTexParams.y) + uniform.animTexParams.x, uniform.animTexParams.z);\n";
|
|
2
2
|
export default _default;
|
package/build/playcanvas/src/scene/shader-lib/wgsl/chunks/particle/vert/particleAnimFrameClamp.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var particleAnimFrameClamp_default = `
|
|
2
|
-
let animFrame: f32 = min(floor(
|
|
2
|
+
let animFrame: f32 = min(floor(output.texCoordsAlphaLife.w * uniform.animTexParams.y) + uniform.animTexParams.x, uniform.animTexParams.z);
|
|
3
3
|
`;
|
|
4
4
|
export {
|
|
5
5
|
particleAnimFrameClamp_default as default
|
package/build/playcanvas.d.ts
CHANGED
|
@@ -14850,14 +14850,6 @@ declare class LitShaderOptions {
|
|
|
14850
14850
|
* Apply SSAO during the lighting.
|
|
14851
14851
|
*/
|
|
14852
14852
|
ssao: boolean;
|
|
14853
|
-
/**
|
|
14854
|
-
* The value of {@link StandardMaterial#twoSidedLighting}.
|
|
14855
|
-
*/
|
|
14856
|
-
twoSidedLighting: boolean;
|
|
14857
|
-
/**
|
|
14858
|
-
* The value of {@link StandardMaterial#occludeDirect}.
|
|
14859
|
-
*/
|
|
14860
|
-
occludeDirect: boolean;
|
|
14861
14853
|
/**
|
|
14862
14854
|
* The value of {@link StandardMaterial#occludeSpecular}.
|
|
14863
14855
|
*/
|
|
@@ -57254,11 +57246,11 @@ declare class ParticleEmitter {
|
|
|
57254
57246
|
*
|
|
57255
57247
|
* Relevant Engine API examples:
|
|
57256
57248
|
*
|
|
57257
|
-
* - [Particle Animated Index](https://playcanvas.github.io/#/
|
|
57258
|
-
* - [Particle Mesh](https://playcanvas.github.io/#/
|
|
57259
|
-
* - [Particle Random Sprites](https://playcanvas.github.io/#/
|
|
57260
|
-
* - [Particle Snow](https://playcanvas.github.io/#/
|
|
57261
|
-
* - [Particle Spark](https://playcanvas.github.io/#/
|
|
57249
|
+
* - [Particle Animated Index](https://playcanvas.github.io/#/particles/anim-index)
|
|
57250
|
+
* - [Particle Mesh](https://playcanvas.github.io/#/particles/mesh)
|
|
57251
|
+
* - [Particle Random Sprites](https://playcanvas.github.io/#/particles/random-sprites)
|
|
57252
|
+
* - [Particle Snow](https://playcanvas.github.io/#/particles/snow)
|
|
57253
|
+
* - [Particle Spark](https://playcanvas.github.io/#/particles/spark)
|
|
57262
57254
|
* - [Particles in a user interface](https://playcanvas.github.io/#/user-interface/particle-system)
|
|
57263
57255
|
*
|
|
57264
57256
|
* @hideconstructor
|
|
@@ -75160,6 +75152,8 @@ declare class FlyController extends InputController {
|
|
|
75160
75152
|
* view around the focus within {@link yawRange} and {@link pitchRange}, the first two `move`
|
|
75161
75153
|
* components pan the focus point, and the third scales the distance within {@link zoomRange}.
|
|
75162
75154
|
* Motion is smoothed with {@link rotateDamping}, {@link moveDamping} and {@link zoomDamping}.
|
|
75155
|
+
* With {@link horizontalPan}, the pan moves the focus point across the ground instead of the
|
|
75156
|
+
* plane of the view.
|
|
75163
75157
|
*
|
|
75164
75158
|
* @category Input
|
|
75165
75159
|
* @alpha
|
|
@@ -75199,6 +75193,13 @@ declare class OrbitController extends InputController {
|
|
|
75199
75193
|
* The zoom damping. A higher value means more damping. A value of 0 means no damping.
|
|
75200
75194
|
*/
|
|
75201
75195
|
zoomDamping: number;
|
|
75196
|
+
/**
|
|
75197
|
+
* Whether the pan moves the focus point across the horizontal plane, as when dragging a map,
|
|
75198
|
+
* instead of across the plane of the view. The first two `move` components are then the
|
|
75199
|
+
* distances to move the focus point to the right and forward, level with the ground, so the
|
|
75200
|
+
* height of the focus point does not change. Default is false.
|
|
75201
|
+
*/
|
|
75202
|
+
horizontalPan: boolean;
|
|
75202
75203
|
set pitchRange(range: Vec2);
|
|
75203
75204
|
get pitchRange(): Vec2;
|
|
75204
75205
|
set yawRange(range: Vec2);
|