@gjsify/example-dom-three-postprocessing-pixel 0.1.13 → 0.2.0
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/browser.js +404 -157
- package/dist/gjs.js +1072 -1561
- package/package.json +12 -12
package/dist/browser.js
CHANGED
|
@@ -433,7 +433,7 @@ var mediaPlaybackStartSymbolic = `<svg height="16px" viewBox="0 0 16 16" width="
|
|
|
433
433
|
</svg>`;
|
|
434
434
|
|
|
435
435
|
// ../../../node_modules/three/build/three.core.js
|
|
436
|
-
var REVISION = "
|
|
436
|
+
var REVISION = "184";
|
|
437
437
|
var MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
|
|
438
438
|
var TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
|
|
439
439
|
var CullFaceNone = 0;
|
|
@@ -1157,6 +1157,9 @@ var MathUtils = {
|
|
|
1157
1157
|
denormalize
|
|
1158
1158
|
};
|
|
1159
1159
|
var Vector2 = class _Vector2 {
|
|
1160
|
+
static {
|
|
1161
|
+
_Vector2.prototype.isVector2 = true;
|
|
1162
|
+
}
|
|
1160
1163
|
/**
|
|
1161
1164
|
* Constructs a new 2D vector.
|
|
1162
1165
|
*
|
|
@@ -1164,7 +1167,6 @@ var Vector2 = class _Vector2 {
|
|
|
1164
1167
|
* @param {number} [y=0] - The y value of this vector.
|
|
1165
1168
|
*/
|
|
1166
1169
|
constructor(x = 0, y = 0) {
|
|
1167
|
-
_Vector2.prototype.isVector2 = true;
|
|
1168
1170
|
this.x = x;
|
|
1169
1171
|
this.y = y;
|
|
1170
1172
|
}
|
|
@@ -2382,6 +2384,9 @@ var Quaternion = class {
|
|
|
2382
2384
|
}
|
|
2383
2385
|
};
|
|
2384
2386
|
var Vector3 = class _Vector3 {
|
|
2387
|
+
static {
|
|
2388
|
+
_Vector3.prototype.isVector3 = true;
|
|
2389
|
+
}
|
|
2385
2390
|
/**
|
|
2386
2391
|
* Constructs a new 3D vector.
|
|
2387
2392
|
*
|
|
@@ -2390,7 +2395,6 @@ var Vector3 = class _Vector3 {
|
|
|
2390
2395
|
* @param {number} [z=0] - The z value of this vector.
|
|
2391
2396
|
*/
|
|
2392
2397
|
constructor(x = 0, y = 0, z = 0) {
|
|
2393
|
-
_Vector3.prototype.isVector3 = true;
|
|
2394
2398
|
this.x = x;
|
|
2395
2399
|
this.y = y;
|
|
2396
2400
|
this.z = z;
|
|
@@ -3288,6 +3292,9 @@ var Vector3 = class _Vector3 {
|
|
|
3288
3292
|
var _vector$c = /* @__PURE__ */ new Vector3();
|
|
3289
3293
|
var _quaternion$5 = /* @__PURE__ */ new Quaternion();
|
|
3290
3294
|
var Matrix3 = class _Matrix3 {
|
|
3295
|
+
static {
|
|
3296
|
+
_Matrix3.prototype.isMatrix3 = true;
|
|
3297
|
+
}
|
|
3291
3298
|
/**
|
|
3292
3299
|
* Constructs a new 3x3 matrix. The arguments are supposed to be
|
|
3293
3300
|
* in row-major order. If no arguments are provided, the constructor
|
|
@@ -3304,7 +3311,6 @@ var Matrix3 = class _Matrix3 {
|
|
|
3304
3311
|
* @param {number} [n33] - 3-3 matrix element.
|
|
3305
3312
|
*/
|
|
3306
3313
|
constructor(n11, n12, n13, n21, n22, n23, n31, n32, n33) {
|
|
3307
|
-
_Matrix3.prototype.isMatrix3 = true;
|
|
3308
3314
|
this.elements = [
|
|
3309
3315
|
1,
|
|
3310
3316
|
0,
|
|
@@ -4004,7 +4010,7 @@ var Source = class {
|
|
|
4004
4010
|
if (typeof HTMLVideoElement !== "undefined" && data instanceof HTMLVideoElement) {
|
|
4005
4011
|
target.set(data.videoWidth, data.videoHeight, 0);
|
|
4006
4012
|
} else if (typeof VideoFrame !== "undefined" && data instanceof VideoFrame) {
|
|
4007
|
-
target.set(data.
|
|
4013
|
+
target.set(data.displayWidth, data.displayHeight, 0);
|
|
4008
4014
|
} else if (data !== null) {
|
|
4009
4015
|
target.set(data.width, data.height, data.depth || 0);
|
|
4010
4016
|
} else {
|
|
@@ -4134,6 +4140,7 @@ var Texture = class _Texture extends EventDispatcher {
|
|
|
4134
4140
|
this.isRenderTargetTexture = false;
|
|
4135
4141
|
this.isArrayTexture = image && image.depth && image.depth > 1 ? true : false;
|
|
4136
4142
|
this.pmremVersion = 0;
|
|
4143
|
+
this.normalized = false;
|
|
4137
4144
|
}
|
|
4138
4145
|
/**
|
|
4139
4146
|
* The width of the texture in pixels.
|
|
@@ -4161,11 +4168,11 @@ var Texture = class _Texture extends EventDispatcher {
|
|
|
4161
4168
|
get image() {
|
|
4162
4169
|
return this.source.data;
|
|
4163
4170
|
}
|
|
4164
|
-
set image(value
|
|
4171
|
+
set image(value) {
|
|
4165
4172
|
this.source.data = value;
|
|
4166
4173
|
}
|
|
4167
4174
|
/**
|
|
4168
|
-
* Updates the texture transformation matrix from the
|
|
4175
|
+
* Updates the texture transformation matrix from the properties {@link Texture#offset},
|
|
4169
4176
|
* {@link Texture#repeat}, {@link Texture#rotation}, and {@link Texture#center}.
|
|
4170
4177
|
*/
|
|
4171
4178
|
updateMatrix() {
|
|
@@ -4214,6 +4221,7 @@ var Texture = class _Texture extends EventDispatcher {
|
|
|
4214
4221
|
this.format = source.format;
|
|
4215
4222
|
this.internalFormat = source.internalFormat;
|
|
4216
4223
|
this.type = source.type;
|
|
4224
|
+
this.normalized = source.normalized;
|
|
4217
4225
|
this.offset.copy(source.offset);
|
|
4218
4226
|
this.repeat.copy(source.repeat);
|
|
4219
4227
|
this.center.copy(source.center);
|
|
@@ -4290,6 +4298,7 @@ var Texture = class _Texture extends EventDispatcher {
|
|
|
4290
4298
|
format: this.format,
|
|
4291
4299
|
internalFormat: this.internalFormat,
|
|
4292
4300
|
type: this.type,
|
|
4301
|
+
normalized: this.normalized,
|
|
4293
4302
|
colorSpace: this.colorSpace,
|
|
4294
4303
|
minFilter: this.minFilter,
|
|
4295
4304
|
magFilter: this.magFilter,
|
|
@@ -4395,6 +4404,9 @@ Texture.DEFAULT_IMAGE = null;
|
|
|
4395
4404
|
Texture.DEFAULT_MAPPING = UVMapping;
|
|
4396
4405
|
Texture.DEFAULT_ANISOTROPY = 1;
|
|
4397
4406
|
var Vector4 = class _Vector4 {
|
|
4407
|
+
static {
|
|
4408
|
+
_Vector4.prototype.isVector4 = true;
|
|
4409
|
+
}
|
|
4398
4410
|
/**
|
|
4399
4411
|
* Constructs a new 4D vector.
|
|
4400
4412
|
*
|
|
@@ -4404,7 +4416,6 @@ var Vector4 = class _Vector4 {
|
|
|
4404
4416
|
* @param {number} [w=1] - The w value of this vector.
|
|
4405
4417
|
*/
|
|
4406
4418
|
constructor(x = 0, y = 0, z = 0, w = 1) {
|
|
4407
|
-
_Vector4.prototype.isVector4 = true;
|
|
4408
4419
|
this.x = x;
|
|
4409
4420
|
this.y = y;
|
|
4410
4421
|
this.z = z;
|
|
@@ -5312,6 +5323,7 @@ var RenderTarget = class extends EventDispatcher {
|
|
|
5312
5323
|
this.resolveStencilBuffer = source.resolveStencilBuffer;
|
|
5313
5324
|
if (source.depthTexture !== null) this.depthTexture = source.depthTexture.clone();
|
|
5314
5325
|
this.samples = source.samples;
|
|
5326
|
+
this.multiview = source.multiview;
|
|
5315
5327
|
return this;
|
|
5316
5328
|
}
|
|
5317
5329
|
/**
|
|
@@ -5399,6 +5411,9 @@ var Data3DTexture = class extends Texture {
|
|
|
5399
5411
|
}
|
|
5400
5412
|
};
|
|
5401
5413
|
var Matrix4 = class _Matrix4 {
|
|
5414
|
+
static {
|
|
5415
|
+
_Matrix4.prototype.isMatrix4 = true;
|
|
5416
|
+
}
|
|
5402
5417
|
/**
|
|
5403
5418
|
* Constructs a new 4x4 matrix. The arguments are supposed to be
|
|
5404
5419
|
* in row-major order. If no arguments are provided, the constructor
|
|
@@ -5422,7 +5437,6 @@ var Matrix4 = class _Matrix4 {
|
|
|
5422
5437
|
* @param {number} [n44] - 4-4 matrix element.
|
|
5423
5438
|
*/
|
|
5424
5439
|
constructor(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) {
|
|
5425
|
-
_Matrix4.prototype.isMatrix4 = true;
|
|
5426
5440
|
this.elements = [
|
|
5427
5441
|
1,
|
|
5428
5442
|
0,
|
|
@@ -7785,9 +7799,7 @@ var Object3D = class _Object3D extends EventDispatcher {
|
|
|
7785
7799
|
this.rotation.order = source.rotation.order;
|
|
7786
7800
|
this.quaternion.copy(source.quaternion);
|
|
7787
7801
|
this.scale.copy(source.scale);
|
|
7788
|
-
|
|
7789
|
-
this.pivot = source.pivot.clone();
|
|
7790
|
-
}
|
|
7802
|
+
this.pivot = source.pivot !== null ? source.pivot.clone() : null;
|
|
7791
7803
|
this.matrix.copy(source.matrix);
|
|
7792
7804
|
this.matrixWorld.copy(source.matrixWorld);
|
|
7793
7805
|
this.matrixAutoUpdate = source.matrixAutoUpdate;
|
|
@@ -7877,6 +7889,7 @@ var WebXRController = class {
|
|
|
7877
7889
|
this._grip.linearVelocity = new Vector3();
|
|
7878
7890
|
this._grip.hasAngularVelocity = false;
|
|
7879
7891
|
this._grip.angularVelocity = new Vector3();
|
|
7892
|
+
this._grip.eventsEnabled = false;
|
|
7880
7893
|
}
|
|
7881
7894
|
return this._grip;
|
|
7882
7895
|
}
|
|
@@ -8006,6 +8019,13 @@ var WebXRController = class {
|
|
|
8006
8019
|
} else {
|
|
8007
8020
|
grip.hasAngularVelocity = false;
|
|
8008
8021
|
}
|
|
8022
|
+
if (grip.eventsEnabled) {
|
|
8023
|
+
grip.dispatchEvent({
|
|
8024
|
+
type: "gripUpdated",
|
|
8025
|
+
data: inputSource,
|
|
8026
|
+
target: this
|
|
8027
|
+
});
|
|
8028
|
+
}
|
|
8009
8029
|
}
|
|
8010
8030
|
}
|
|
8011
8031
|
}
|
|
@@ -9018,7 +9038,7 @@ var Triangle = class _Triangle {
|
|
|
9018
9038
|
static isFrontFacing(a, b, c, direction) {
|
|
9019
9039
|
_v0$2.subVectors(c, b);
|
|
9020
9040
|
_v1$5.subVectors(a, b);
|
|
9021
|
-
return _v0$2.cross(_v1$5).dot(direction) < 0
|
|
9041
|
+
return _v0$2.cross(_v1$5).dot(direction) < 0;
|
|
9022
9042
|
}
|
|
9023
9043
|
/**
|
|
9024
9044
|
* Sets the triangle's vertices by copying the given values.
|
|
@@ -9779,7 +9799,7 @@ function satForAxes(axes, v0, v1, v2, extents) {
|
|
|
9779
9799
|
var _vector$a = /* @__PURE__ */ new Vector3();
|
|
9780
9800
|
var _vector2$1 = /* @__PURE__ */ new Vector2();
|
|
9781
9801
|
var _id$2 = 0;
|
|
9782
|
-
var BufferAttribute = class {
|
|
9802
|
+
var BufferAttribute = class extends EventDispatcher {
|
|
9783
9803
|
/**
|
|
9784
9804
|
* Constructs a new buffer attribute.
|
|
9785
9805
|
*
|
|
@@ -9788,6 +9808,7 @@ var BufferAttribute = class {
|
|
|
9788
9808
|
* @param {boolean} [normalized=false] - Whether the data are normalized or not.
|
|
9789
9809
|
*/
|
|
9790
9810
|
constructor(array, itemSize, normalized = false) {
|
|
9811
|
+
super();
|
|
9791
9812
|
if (Array.isArray(array)) {
|
|
9792
9813
|
throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");
|
|
9793
9814
|
}
|
|
@@ -10184,6 +10205,12 @@ var BufferAttribute = class {
|
|
|
10184
10205
|
if (this.usage !== StaticDrawUsage) data.usage = this.usage;
|
|
10185
10206
|
return data;
|
|
10186
10207
|
}
|
|
10208
|
+
/**
|
|
10209
|
+
* Disposes of the buffer attribute. Available only in {@link WebGPURenderer}.
|
|
10210
|
+
*/
|
|
10211
|
+
dispose() {
|
|
10212
|
+
this.dispatchEvent({ type: "dispose" });
|
|
10213
|
+
}
|
|
10187
10214
|
};
|
|
10188
10215
|
var Uint16BufferAttribute = class extends BufferAttribute {
|
|
10189
10216
|
/**
|
|
@@ -12538,9 +12565,10 @@ var Plane = class {
|
|
|
12538
12565
|
*
|
|
12539
12566
|
* @param {Line3} line - The line to compute the intersection for.
|
|
12540
12567
|
* @param {Vector3} target - The target vector that is used to store the method's result.
|
|
12541
|
-
* @
|
|
12568
|
+
* @param {boolean} [clampToLine=true] - Whether to clamp the intersection to the line segment.
|
|
12569
|
+
* @return {?Vector3} The intersection point. Returns `null` if no intersection is detected.
|
|
12542
12570
|
*/
|
|
12543
|
-
intersectLine(line, target) {
|
|
12571
|
+
intersectLine(line, target, clampToLine = true) {
|
|
12544
12572
|
const direction = line.delta(_vector1);
|
|
12545
12573
|
const denominator = this.normal.dot(direction);
|
|
12546
12574
|
if (denominator === 0) {
|
|
@@ -12550,7 +12578,7 @@ var Plane = class {
|
|
|
12550
12578
|
return null;
|
|
12551
12579
|
}
|
|
12552
12580
|
const t = -(line.start.dot(this.normal) + this.constant) / denominator;
|
|
12553
|
-
if (t < 0 || t > 1) {
|
|
12581
|
+
if (clampToLine === true && (t < 0 || t > 1)) {
|
|
12554
12582
|
return null;
|
|
12555
12583
|
}
|
|
12556
12584
|
return target.copy(line.start).addScaledVector(direction, t);
|
|
@@ -13442,7 +13470,7 @@ function cloneUniforms(src) {
|
|
|
13442
13470
|
dst[u] = {};
|
|
13443
13471
|
for (const p in src[u]) {
|
|
13444
13472
|
const property = src[u][p];
|
|
13445
|
-
if (
|
|
13473
|
+
if (isThreeObject(property)) {
|
|
13446
13474
|
if (property.isRenderTargetTexture) {
|
|
13447
13475
|
warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms().");
|
|
13448
13476
|
dst[u][p] = null;
|
|
@@ -13450,7 +13478,15 @@ function cloneUniforms(src) {
|
|
|
13450
13478
|
dst[u][p] = property.clone();
|
|
13451
13479
|
}
|
|
13452
13480
|
} else if (Array.isArray(property)) {
|
|
13453
|
-
|
|
13481
|
+
if (isThreeObject(property[0])) {
|
|
13482
|
+
const clonedProperty = [];
|
|
13483
|
+
for (let i = 0, l = property.length; i < l; i++) {
|
|
13484
|
+
clonedProperty[i] = property[i].clone();
|
|
13485
|
+
}
|
|
13486
|
+
dst[u][p] = clonedProperty;
|
|
13487
|
+
} else {
|
|
13488
|
+
dst[u][p] = property.slice();
|
|
13489
|
+
}
|
|
13454
13490
|
} else {
|
|
13455
13491
|
dst[u][p] = property;
|
|
13456
13492
|
}
|
|
@@ -13468,6 +13504,9 @@ function mergeUniforms(uniforms) {
|
|
|
13468
13504
|
}
|
|
13469
13505
|
return merged;
|
|
13470
13506
|
}
|
|
13507
|
+
function isThreeObject(property) {
|
|
13508
|
+
return property && (property.isColor || property.isMatrix3 || property.isMatrix4 || property.isVector2 || property.isVector3 || property.isVector4 || property.isTexture || property.isQuaternion);
|
|
13509
|
+
}
|
|
13471
13510
|
function cloneUniformsGroups(src) {
|
|
13472
13511
|
const dst = [];
|
|
13473
13512
|
for (let u = 0; u < src.length; u++) {
|
|
@@ -16540,6 +16579,77 @@ var Spherical = class {
|
|
|
16540
16579
|
return new this.constructor().copy(this);
|
|
16541
16580
|
}
|
|
16542
16581
|
};
|
|
16582
|
+
var Matrix2 = class _Matrix2 {
|
|
16583
|
+
static {
|
|
16584
|
+
_Matrix2.prototype.isMatrix2 = true;
|
|
16585
|
+
}
|
|
16586
|
+
/**
|
|
16587
|
+
* Constructs a new 2x2 matrix. The arguments are supposed to be
|
|
16588
|
+
* in row-major order. If no arguments are provided, the constructor
|
|
16589
|
+
* initializes the matrix as an identity matrix.
|
|
16590
|
+
*
|
|
16591
|
+
* @param {number} [n11] - 1-1 matrix element.
|
|
16592
|
+
* @param {number} [n12] - 1-2 matrix element.
|
|
16593
|
+
* @param {number} [n21] - 2-1 matrix element.
|
|
16594
|
+
* @param {number} [n22] - 2-2 matrix element.
|
|
16595
|
+
*/
|
|
16596
|
+
constructor(n11, n12, n21, n22) {
|
|
16597
|
+
this.elements = [
|
|
16598
|
+
1,
|
|
16599
|
+
0,
|
|
16600
|
+
0,
|
|
16601
|
+
1
|
|
16602
|
+
];
|
|
16603
|
+
if (n11 !== void 0) {
|
|
16604
|
+
this.set(n11, n12, n21, n22);
|
|
16605
|
+
}
|
|
16606
|
+
}
|
|
16607
|
+
/**
|
|
16608
|
+
* Sets this matrix to the 2x2 identity matrix.
|
|
16609
|
+
*
|
|
16610
|
+
* @return {Matrix2} A reference to this matrix.
|
|
16611
|
+
*/
|
|
16612
|
+
identity() {
|
|
16613
|
+
this.set(
|
|
16614
|
+
1,
|
|
16615
|
+
0,
|
|
16616
|
+
0,
|
|
16617
|
+
1
|
|
16618
|
+
);
|
|
16619
|
+
return this;
|
|
16620
|
+
}
|
|
16621
|
+
/**
|
|
16622
|
+
* Sets the elements of the matrix from the given array.
|
|
16623
|
+
*
|
|
16624
|
+
* @param {Array<number>} array - The matrix elements in column-major order.
|
|
16625
|
+
* @param {number} [offset=0] - Index of the first element in the array.
|
|
16626
|
+
* @return {Matrix2} A reference to this matrix.
|
|
16627
|
+
*/
|
|
16628
|
+
fromArray(array, offset = 0) {
|
|
16629
|
+
for (let i = 0; i < 4; i++) {
|
|
16630
|
+
this.elements[i] = array[i + offset];
|
|
16631
|
+
}
|
|
16632
|
+
return this;
|
|
16633
|
+
}
|
|
16634
|
+
/**
|
|
16635
|
+
* Sets the elements of the matrix.The arguments are supposed to be
|
|
16636
|
+
* in row-major order.
|
|
16637
|
+
*
|
|
16638
|
+
* @param {number} n11 - 1-1 matrix element.
|
|
16639
|
+
* @param {number} n12 - 1-2 matrix element.
|
|
16640
|
+
* @param {number} n21 - 2-1 matrix element.
|
|
16641
|
+
* @param {number} n22 - 2-2 matrix element.
|
|
16642
|
+
* @return {Matrix2} A reference to this matrix.
|
|
16643
|
+
*/
|
|
16644
|
+
set(n11, n12, n21, n22) {
|
|
16645
|
+
const te = this.elements;
|
|
16646
|
+
te[0] = n11;
|
|
16647
|
+
te[2] = n12;
|
|
16648
|
+
te[1] = n21;
|
|
16649
|
+
te[3] = n22;
|
|
16650
|
+
return this;
|
|
16651
|
+
}
|
|
16652
|
+
};
|
|
16543
16653
|
var Controls = class extends EventDispatcher {
|
|
16544
16654
|
/**
|
|
16545
16655
|
* Constructs a new controls instance.
|
|
@@ -16730,11 +16840,12 @@ function WebGLAnimation() {
|
|
|
16730
16840
|
start: function() {
|
|
16731
16841
|
if (isAnimating === true) return;
|
|
16732
16842
|
if (animationLoop === null) return;
|
|
16843
|
+
if (context === null) return;
|
|
16733
16844
|
requestId = context.requestAnimationFrame(onAnimationFrame);
|
|
16734
16845
|
isAnimating = true;
|
|
16735
16846
|
},
|
|
16736
16847
|
stop: function() {
|
|
16737
|
-
context.cancelAnimationFrame(requestId);
|
|
16848
|
+
if (context !== null) context.cancelAnimationFrame(requestId);
|
|
16738
16849
|
isAnimating = false;
|
|
16739
16850
|
},
|
|
16740
16851
|
setAnimationLoop: function(callback) {
|
|
@@ -16901,8 +17012,8 @@ var emissivemap_fragment = "#ifdef USE_EMISSIVEMAP\n vec4 emissiveColor = textur
|
|
|
16901
17012
|
var emissivemap_pars_fragment = "#ifdef USE_EMISSIVEMAP\n uniform sampler2D emissiveMap;\n#endif";
|
|
16902
17013
|
var colorspace_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );";
|
|
16903
17014
|
var colorspace_pars_fragment = "vec4 LinearTransferOETF( in vec4 value ) {\n return value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}";
|
|
16904
|
-
var envmap_fragment = "#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vec3 cameraToFrag;\n if ( isOrthographic ) {\n cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToFrag = normalize( vWorldPosition - cameraPosition );\n }\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect( cameraToFrag, worldNormal );\n #else\n vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n #endif\n #else\n vec3 reflectVec = vReflect;\n #endif\n #ifdef ENVMAP_TYPE_CUBE\n vec4 envColor = textureCube( envMap, envMapRotation *
|
|
16905
|
-
var envmap_common_pars_fragment = "#ifdef USE_ENVMAP\n uniform float envMapIntensity;\n uniform
|
|
17015
|
+
var envmap_fragment = "#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vec3 cameraToFrag;\n if ( isOrthographic ) {\n cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToFrag = normalize( vWorldPosition - cameraPosition );\n }\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect( cameraToFrag, worldNormal );\n #else\n vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n #endif\n #else\n vec3 reflectVec = vReflect;\n #endif\n #ifdef ENVMAP_TYPE_CUBE\n vec4 envColor = textureCube( envMap, envMapRotation * reflectVec );\n #ifdef ENVMAP_BLENDING_MULTIPLY\n outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_MIX )\n outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_ADD )\n outgoingLight += envColor.xyz * specularStrength * reflectivity;\n #endif\n #endif\n#endif";
|
|
17016
|
+
var envmap_common_pars_fragment = "#ifdef USE_ENVMAP\n uniform float envMapIntensity;\n uniform mat3 envMapRotation;\n #ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n #else\n uniform sampler2D envMap;\n #endif\n#endif";
|
|
16906
17017
|
var envmap_pars_fragment = "#ifdef USE_ENVMAP\n uniform float reflectivity;\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n varying vec3 vWorldPosition;\n uniform float refractionRatio;\n #else\n varying vec3 vReflect;\n #endif\n#endif";
|
|
16907
17018
|
var envmap_pars_vertex = "#ifdef USE_ENVMAP\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n \n varying vec3 vWorldPosition;\n #else\n varying vec3 vReflect;\n uniform float refractionRatio;\n #endif\n#endif";
|
|
16908
17019
|
var envmap_vertex = "#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vWorldPosition = worldPosition.xyz;\n #else\n vec3 cameraToVertex;\n if ( isOrthographic ) {\n cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n }\n vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vReflect = reflect( cameraToVertex, worldNormal );\n #else\n vReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n #endif\n #endif\n#endif";
|
|
@@ -16914,17 +17025,18 @@ var gradientmap_pars_fragment = "#ifdef USE_GRADIENTMAP\n uniform sampler2D grad
|
|
|
16914
17025
|
var lightmap_pars_fragment = "#ifdef USE_LIGHTMAP\n uniform sampler2D lightMap;\n uniform float lightMapIntensity;\n#endif";
|
|
16915
17026
|
var lights_lambert_fragment = "LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;";
|
|
16916
17027
|
var lights_lambert_pars_fragment = "varying vec3 vViewPosition;\nstruct LambertMaterial {\n vec3 diffuseColor;\n float specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Lambert\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert";
|
|
16917
|
-
var lights_pars_begin = "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n uniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n float x = normal.x, y = normal.y, z = normal.z;\n vec3 result = shCoefficients[ 0 ] * 0.886227;\n result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n return result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n return irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n vec3 irradiance = ambientLightColor;\n return irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n if ( cutoffDistance > 0.0 ) {\n distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n }\n return distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n return smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n };\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n light.color = directionalLight.color;\n light.direction = directionalLight.direction;\n light.visible = true;\n }\n#endif\n#if NUM_POINT_LIGHTS > 0\n struct PointLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n };\n uniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = pointLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float lightDistance = length( lVector );\n light.color = pointLight.color;\n light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 color;\n float distance;\n float decay;\n float coneCos;\n float penumbraCos;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = spotLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float angleCos = dot( light.direction, spotLight.direction );\n float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n if ( spotAttenuation > 0.0 ) {\n float lightDistance = length( lVector );\n light.color = spotLight.color * spotAttenuation;\n light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n } else {\n light.color = vec3( 0.0 );\n light.visible = false;\n }\n }\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n struct RectAreaLight {\n vec3 color;\n vec3 position;\n vec3 halfWidth;\n vec3 halfHeight;\n };\n uniform sampler2D ltc_1; uniform sampler2D ltc_2;\n uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n vec3 groundColor;\n };\n uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n float dotNL = dot( normal, hemiLight.direction );\n float hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n return irradiance;\n }\n#endif";
|
|
17028
|
+
var lights_pars_begin = "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n uniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n float x = normal.x, y = normal.y, z = normal.z;\n vec3 result = shCoefficients[ 0 ] * 0.886227;\n result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n return result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n return irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n vec3 irradiance = ambientLightColor;\n return irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n if ( cutoffDistance > 0.0 ) {\n distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n }\n return distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n return smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n };\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n light.color = directionalLight.color;\n light.direction = directionalLight.direction;\n light.visible = true;\n }\n#endif\n#if NUM_POINT_LIGHTS > 0\n struct PointLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n };\n uniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = pointLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float lightDistance = length( lVector );\n light.color = pointLight.color;\n light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 color;\n float distance;\n float decay;\n float coneCos;\n float penumbraCos;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = spotLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float angleCos = dot( light.direction, spotLight.direction );\n float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n if ( spotAttenuation > 0.0 ) {\n float lightDistance = length( lVector );\n light.color = spotLight.color * spotAttenuation;\n light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n } else {\n light.color = vec3( 0.0 );\n light.visible = false;\n }\n }\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n struct RectAreaLight {\n vec3 color;\n vec3 position;\n vec3 halfWidth;\n vec3 halfHeight;\n };\n uniform sampler2D ltc_1; uniform sampler2D ltc_2;\n uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n vec3 groundColor;\n };\n uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n float dotNL = dot( normal, hemiLight.direction );\n float hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n return irradiance;\n }\n#endif\n#include <lightprobes_pars_fragment>";
|
|
16918
17029
|
var envmap_physical_pars_fragment = "#ifdef USE_ENVMAP\n vec3 getIBLIrradiance( const in vec3 normal ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n return PI * envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 reflectVec = reflect( - viewDir, normal );\n reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );\n reflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n return envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n #ifdef USE_ANISOTROPY\n vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 bentNormal = cross( bitangent, viewDir );\n bentNormal = normalize( cross( bentNormal, bitangent ) );\n bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n return getIBLRadiance( viewDir, bentNormal, roughness );\n #else\n return vec3( 0.0 );\n #endif\n }\n #endif\n#endif";
|
|
16919
17030
|
var lights_toon_fragment = "ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;";
|
|
16920
17031
|
var lights_toon_pars_fragment = "varying vec3 vViewPosition;\nstruct ToonMaterial {\n vec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Toon\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon";
|
|
16921
17032
|
var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;";
|
|
16922
17033
|
var lights_phong_pars_fragment = "varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n vec3 diffuseColor;\n vec3 specularColor;\n float specularShininess;\n float specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_BlinnPhong\n#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong";
|
|
16923
17034
|
var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.metalness = metalnessFactor;\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n material.ior = ior;\n #ifdef USE_SPECULAR\n float specularIntensityFactor = specularIntensity;\n vec3 specularColorFactor = specularColor;\n #ifdef USE_SPECULAR_COLORMAP\n specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n #endif\n #ifdef USE_SPECULAR_INTENSITYMAP\n specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n #endif\n material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n #else\n float specularIntensityFactor = 1.0;\n vec3 specularColorFactor = vec3( 1.0 );\n material.specularF90 = 1.0;\n #endif\n material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;\n material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n#else\n material.specularColor = vec3( 0.04 );\n material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n material.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n material.clearcoat = clearcoat;\n material.clearcoatRoughness = clearcoatRoughness;\n material.clearcoatF0 = vec3( 0.04 );\n material.clearcoatF90 = 1.0;\n #ifdef USE_CLEARCOATMAP\n material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n #endif\n #ifdef USE_CLEARCOAT_ROUGHNESSMAP\n material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n #endif\n material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n material.clearcoatRoughness += geometryRoughness;\n material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n material.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n material.iridescence = iridescence;\n material.iridescenceIOR = iridescenceIOR;\n #ifdef USE_IRIDESCENCEMAP\n material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n #endif\n #ifdef USE_IRIDESCENCE_THICKNESSMAP\n material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n #else\n material.iridescenceThickness = iridescenceThicknessMaximum;\n #endif\n#endif\n#ifdef USE_SHEEN\n material.sheenColor = sheenColor;\n #ifdef USE_SHEEN_COLORMAP\n material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n #endif\n material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );\n #ifdef USE_SHEEN_ROUGHNESSMAP\n material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n #endif\n#endif\n#ifdef USE_ANISOTROPY\n #ifdef USE_ANISOTROPYMAP\n mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n #else\n vec2 anisotropyV = anisotropyVector;\n #endif\n material.anisotropy = length( anisotropyV );\n if( material.anisotropy == 0.0 ) {\n anisotropyV = vec2( 1.0, 0.0 );\n } else {\n anisotropyV /= material.anisotropy;\n material.anisotropy = saturate( material.anisotropy );\n }\n material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif";
|
|
16924
|
-
var lights_physical_pars_fragment = "uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n vec3 diffuseColor;\n vec3 diffuseContribution;\n vec3 specularColor;\n vec3 specularColorBlended;\n float roughness;\n float metalness;\n float specularF90;\n float dispersion;\n #ifdef USE_CLEARCOAT\n float clearcoat;\n float clearcoatRoughness;\n vec3 clearcoatF0;\n float clearcoatF90;\n #endif\n #ifdef USE_IRIDESCENCE\n float iridescence;\n float iridescenceIOR;\n float iridescenceThickness;\n vec3 iridescenceFresnel;\n vec3 iridescenceF0;\n vec3 iridescenceFresnelDielectric;\n vec3 iridescenceFresnelMetallic;\n #endif\n #ifdef USE_SHEEN\n vec3 sheenColor;\n float sheenRoughness;\n #endif\n #ifdef IOR\n float ior;\n #endif\n #ifdef USE_TRANSMISSION\n float transmission;\n float transmissionAlpha;\n float thickness;\n float attenuationDistance;\n vec3 attenuationColor;\n #endif\n #ifdef USE_ANISOTROPY\n float anisotropy;\n float alphaT;\n vec3 anisotropyT;\n vec3 anisotropyB;\n #endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n float a2 = pow2( alpha );\n float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n float a2 = pow2( alpha );\n float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n return RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n float v = 0.5 / ( gv + gl );\n return v;\n }\n float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n float a2 = alphaT * alphaB;\n highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n highp float v2 = dot( v, v );\n float w2 = a2 / v2;\n return RECIPROCAL_PI * a2 * pow2 ( w2 );\n }\n#endif\n#ifdef USE_CLEARCOAT\n vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n vec3 f0 = material.clearcoatF0;\n float f90 = material.clearcoatF90;\n float roughness = material.clearcoatRoughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n return F * ( V * D );\n }\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 f0 = material.specularColorBlended;\n float f90 = material.specularF90;\n float roughness = material.roughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n #ifdef USE_IRIDESCENCE\n F = mix( F, material.iridescenceFresnel, material.iridescence );\n #endif\n #ifdef USE_ANISOTROPY\n float dotTL = dot( material.anisotropyT, lightDir );\n float dotTV = dot( material.anisotropyT, viewDir );\n float dotTH = dot( material.anisotropyT, halfDir );\n float dotBL = dot( material.anisotropyB, lightDir );\n float dotBV = dot( material.anisotropyB, viewDir );\n float dotBH = dot( material.anisotropyB, halfDir );\n float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n #else\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n #endif\n return F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n const float LUT_SIZE = 64.0;\n const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n const float LUT_BIAS = 0.5 / LUT_SIZE;\n float dotNV = saturate( dot( N, V ) );\n vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n uv = uv * LUT_SCALE + LUT_BIAS;\n return uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n float l = length( f );\n return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n float x = dot( v1, v2 );\n float y = abs( x );\n float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n float b = 3.4175940 + ( 4.1616724 + y ) * y;\n float v = a / b;\n float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n return cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n vec3 lightNormal = cross( v1, v2 );\n if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n vec3 T1, T2;\n T1 = normalize( V - N * dot( V, N ) );\n T2 = - cross( N, T1 );\n mat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n vec3 coords[ 4 ];\n coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n coords[ 0 ] = normalize( coords[ 0 ] );\n coords[ 1 ] = normalize( coords[ 1 ] );\n coords[ 2 ] = normalize( coords[ 2 ] );\n coords[ 3 ] = normalize( coords[ 3 ] );\n vec3 vectorFormFactor = vec3( 0.0 );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n float result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n return vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n float alpha = pow2( roughness );\n float invAlpha = 1.0 / alpha;\n float cos2h = dotNH * dotNH;\n float sin2h = max( 1.0 - cos2h, 0.0078125 );\n return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float D = D_Charlie( sheenRoughness, dotNH );\n float V = V_Neubelt( dotNV, dotNL );\n return sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n float r2 = roughness * roughness;\n float rInv = 1.0 / ( roughness + 0.1 );\n float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n float DG = exp( a * dotNV + b );\n return saturate( DG );\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n return specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n #ifdef USE_IRIDESCENCE\n vec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n #else\n vec3 Fr = specularColor;\n #endif\n vec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n float Ess = fab.x + fab.y;\n float Ems = 1.0 - Ess;\n vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n singleScatter += FssEss;\n multiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;\n vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;\n vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;\n vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;\n float Ess_V = dfgV.x + dfgV.y;\n float Ess_L = dfgL.x + dfgL.y;\n float Ems_V = 1.0 - Ess_V;\n float Ems_L = 1.0 - Ess_L;\n vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;\n vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );\n float compensationFactor = Ems_V * Ems_L;\n vec3 multiScatter = Fms * compensationFactor;\n return singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 normal = geometryNormal;\n vec3 viewDir = geometryViewDir;\n vec3 position = geometryPosition;\n vec3 lightPos = rectAreaLight.position;\n vec3 halfWidth = rectAreaLight.halfWidth;\n vec3 halfHeight = rectAreaLight.halfHeight;\n vec3 lightColor = rectAreaLight.color;\n float roughness = material.roughness;\n vec3 rectCoords[ 4 ];\n rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n vec2 uv = LTC_Uv( normal, viewDir, roughness );\n vec4 t1 = texture2D( ltc_1, uv );\n vec4 t2 = texture2D( ltc_2, uv );\n mat3 mInv = mat3(\n vec3( t1.x, 0, t1.y ),\n vec3( 0, 1, 0 ),\n vec3( t1.z, 0, t1.w )\n );\n vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y );\n reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n #ifdef USE_CLEARCOAT\n vec3 Ncc = geometryClearcoatNormal;\n vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness );\n vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat );\n vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat );\n mat3 mInvClearcoat = mat3(\n vec3( t1Clearcoat.x, 0, t1Clearcoat.y ),\n vec3( 0, 1, 0 ),\n vec3( t1Clearcoat.z, 0, t1Clearcoat.w )\n );\n vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y;\n clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords );\n #endif\n }\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n #ifdef USE_CLEARCOAT\n float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n vec3 ccIrradiance = dotNLcc * directLight.color;\n clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n #endif\n #ifdef USE_SHEEN\n \n sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n irradiance *= sheenEnergyComp;\n \n #endif\n reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n diffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectDiffuse += diffuse;\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n #ifdef USE_CLEARCOAT\n clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n #endif\n #ifdef USE_SHEEN\n sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;\n #endif\n vec3 singleScatteringDielectric = vec3( 0.0 );\n vec3 multiScatteringDielectric = vec3( 0.0 );\n vec3 singleScatteringMetallic = vec3( 0.0 );\n vec3 multiScatteringMetallic = vec3( 0.0 );\n #ifdef USE_IRIDESCENCE\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n #else\n computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n #endif\n vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n vec3 indirectSpecular = radiance * singleScattering;\n indirectSpecular += multiScattering * cosineWeightedIrradiance;\n vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n indirectSpecular *= sheenEnergyComp;\n indirectDiffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectSpecular += indirectSpecular;\n reflectedLight.indirectDiffuse += indirectDiffuse;\n}\n#define RE_Direct RE_Direct_Physical\n#define RE_Direct_RectArea RE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular RE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}";
|
|
16925
|
-
var lights_fragment_begin = "\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n geometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n float dotNVi = saturate( dot( normal, geometryViewDir ) );\n if ( material.iridescenceThickness == 0.0 ) {\n material.iridescence = 0.0;\n } else {\n material.iridescence = saturate( material.iridescence );\n }\n if ( material.iridescence > 0.0 ) {\n material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );\n material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n }\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n PointLight pointLight;\n #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n getPointLightInfo( pointLight, geometryPosition, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n pointLightShadow = pointLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n SpotLight spotLight;\n vec4 spotColor;\n vec3 spotLightCoord;\n bool inSpotLightMap;\n #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n getSpotLightInfo( spotLight, geometryPosition, directLight );\n #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n #else\n #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #endif\n #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n #endif\n #undef SPOT_LIGHT_MAP_INDEX\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n spotLightShadow = spotLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n getDirectionalLightInfo( directionalLight, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directionalLightShadow = directionalLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n RectAreaLight rectAreaLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n rectAreaLight = rectAreaLights[ i ];\n RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n vec3 iblIrradiance = vec3( 0.0 );\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n #if defined( USE_LIGHT_PROBES )\n irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n #endif\n #if ( NUM_HEMI_LIGHTS > 0 )\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n }\n #pragma unroll_loop_end\n #endif\n#endif\n#if defined( RE_IndirectSpecular )\n vec3 radiance = vec3( 0.0 );\n vec3 clearcoatRadiance = vec3( 0.0 );\n#endif";
|
|
17035
|
+
var lights_physical_pars_fragment = "uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n vec3 diffuseColor;\n vec3 diffuseContribution;\n vec3 specularColor;\n vec3 specularColorBlended;\n float roughness;\n float metalness;\n float specularF90;\n float dispersion;\n #ifdef USE_CLEARCOAT\n float clearcoat;\n float clearcoatRoughness;\n vec3 clearcoatF0;\n float clearcoatF90;\n #endif\n #ifdef USE_IRIDESCENCE\n float iridescence;\n float iridescenceIOR;\n float iridescenceThickness;\n vec3 iridescenceFresnel;\n vec3 iridescenceF0;\n vec3 iridescenceFresnelDielectric;\n vec3 iridescenceFresnelMetallic;\n #endif\n #ifdef USE_SHEEN\n vec3 sheenColor;\n float sheenRoughness;\n #endif\n #ifdef IOR\n float ior;\n #endif\n #ifdef USE_TRANSMISSION\n float transmission;\n float transmissionAlpha;\n float thickness;\n float attenuationDistance;\n vec3 attenuationColor;\n #endif\n #ifdef USE_ANISOTROPY\n float anisotropy;\n float alphaT;\n vec3 anisotropyT;\n vec3 anisotropyB;\n #endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n float a2 = pow2( alpha );\n float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n float a2 = pow2( alpha );\n float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n return RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n }\n float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n float a2 = alphaT * alphaB;\n highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n highp float v2 = dot( v, v );\n float w2 = a2 / v2;\n return RECIPROCAL_PI * a2 * pow2 ( w2 );\n }\n#endif\n#ifdef USE_CLEARCOAT\n vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n vec3 f0 = material.clearcoatF0;\n float f90 = material.clearcoatF90;\n float roughness = material.clearcoatRoughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n return F * ( V * D );\n }\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 f0 = material.specularColorBlended;\n float f90 = material.specularF90;\n float roughness = material.roughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n #ifdef USE_IRIDESCENCE\n F = mix( F, material.iridescenceFresnel, material.iridescence );\n #endif\n #ifdef USE_ANISOTROPY\n float dotTL = dot( material.anisotropyT, lightDir );\n float dotTV = dot( material.anisotropyT, viewDir );\n float dotTH = dot( material.anisotropyT, halfDir );\n float dotBL = dot( material.anisotropyB, lightDir );\n float dotBV = dot( material.anisotropyB, viewDir );\n float dotBH = dot( material.anisotropyB, halfDir );\n float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n #else\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n #endif\n return F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n const float LUT_SIZE = 64.0;\n const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n const float LUT_BIAS = 0.5 / LUT_SIZE;\n float dotNV = saturate( dot( N, V ) );\n vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n uv = uv * LUT_SCALE + LUT_BIAS;\n return uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n float l = length( f );\n return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n float x = dot( v1, v2 );\n float y = abs( x );\n float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n float b = 3.4175940 + ( 4.1616724 + y ) * y;\n float v = a / b;\n float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n return cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n vec3 lightNormal = cross( v1, v2 );\n if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n vec3 T1, T2;\n T1 = normalize( V - N * dot( V, N ) );\n T2 = - cross( N, T1 );\n mat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n vec3 coords[ 4 ];\n coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n coords[ 0 ] = normalize( coords[ 0 ] );\n coords[ 1 ] = normalize( coords[ 1 ] );\n coords[ 2 ] = normalize( coords[ 2 ] );\n coords[ 3 ] = normalize( coords[ 3 ] );\n vec3 vectorFormFactor = vec3( 0.0 );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n float result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n return vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n float alpha = pow2( roughness );\n float invAlpha = 1.0 / alpha;\n float cos2h = dotNH * dotNH;\n float sin2h = max( 1.0 - cos2h, 0.0078125 );\n return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float D = D_Charlie( sheenRoughness, dotNH );\n float V = V_Neubelt( dotNV, dotNL );\n return sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n float r2 = roughness * roughness;\n float rInv = 1.0 / ( roughness + 0.1 );\n float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n float DG = exp( a * dotNV + b );\n return saturate( DG );\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n return specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n #ifdef USE_IRIDESCENCE\n vec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n #else\n vec3 Fr = specularColor;\n #endif\n vec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n float Ess = fab.x + fab.y;\n float Ems = 1.0 - Ess;\n vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n singleScatter += FssEss;\n multiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;\n vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;\n vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;\n vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;\n float Ess_V = dfgV.x + dfgV.y;\n float Ess_L = dfgL.x + dfgL.y;\n float Ems_V = 1.0 - Ess_V;\n float Ems_L = 1.0 - Ess_L;\n vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;\n vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );\n float compensationFactor = Ems_V * Ems_L;\n vec3 multiScatter = Fms * compensationFactor;\n return singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 normal = geometryNormal;\n vec3 viewDir = geometryViewDir;\n vec3 position = geometryPosition;\n vec3 lightPos = rectAreaLight.position;\n vec3 halfWidth = rectAreaLight.halfWidth;\n vec3 halfHeight = rectAreaLight.halfHeight;\n vec3 lightColor = rectAreaLight.color;\n float roughness = material.roughness;\n vec3 rectCoords[ 4 ];\n rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n vec2 uv = LTC_Uv( normal, viewDir, roughness );\n vec4 t1 = texture2D( ltc_1, uv );\n vec4 t2 = texture2D( ltc_2, uv );\n mat3 mInv = mat3(\n vec3( t1.x, 0, t1.y ),\n vec3( 0, 1, 0 ),\n vec3( t1.z, 0, t1.w )\n );\n vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y );\n reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n #ifdef USE_CLEARCOAT\n vec3 Ncc = geometryClearcoatNormal;\n vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness );\n vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat );\n vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat );\n mat3 mInvClearcoat = mat3(\n vec3( t1Clearcoat.x, 0, t1Clearcoat.y ),\n vec3( 0, 1, 0 ),\n vec3( t1Clearcoat.z, 0, t1Clearcoat.w )\n );\n vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y;\n clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords );\n #endif\n }\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n #ifdef USE_CLEARCOAT\n float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n vec3 ccIrradiance = dotNLcc * directLight.color;\n clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n #endif\n #ifdef USE_SHEEN\n \n sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n irradiance *= sheenEnergyComp;\n \n #endif\n reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n diffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectDiffuse += diffuse;\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n #ifdef USE_CLEARCOAT\n clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n #endif\n #ifdef USE_SHEEN\n sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;\n #endif\n vec3 singleScatteringDielectric = vec3( 0.0 );\n vec3 multiScatteringDielectric = vec3( 0.0 );\n vec3 singleScatteringMetallic = vec3( 0.0 );\n vec3 multiScatteringMetallic = vec3( 0.0 );\n #ifdef USE_IRIDESCENCE\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n #else\n computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n #endif\n vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n vec3 indirectSpecular = radiance * singleScattering;\n indirectSpecular += multiScattering * cosineWeightedIrradiance;\n vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n indirectSpecular *= sheenEnergyComp;\n indirectDiffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectSpecular += indirectSpecular;\n reflectedLight.indirectDiffuse += indirectDiffuse;\n}\n#define RE_Direct RE_Direct_Physical\n#define RE_Direct_RectArea RE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular RE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}";
|
|
17036
|
+
var lights_fragment_begin = "\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n geometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n float dotNVi = saturate( dot( normal, geometryViewDir ) );\n if ( material.iridescenceThickness == 0.0 ) {\n material.iridescence = 0.0;\n } else {\n material.iridescence = saturate( material.iridescence );\n }\n if ( material.iridescence > 0.0 ) {\n material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );\n material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n }\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n PointLight pointLight;\n #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n getPointLightInfo( pointLight, geometryPosition, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n pointLightShadow = pointLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n SpotLight spotLight;\n vec4 spotColor;\n vec3 spotLightCoord;\n bool inSpotLightMap;\n #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n getSpotLightInfo( spotLight, geometryPosition, directLight );\n #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n #else\n #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #endif\n #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n #endif\n #undef SPOT_LIGHT_MAP_INDEX\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n spotLightShadow = spotLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n getDirectionalLightInfo( directionalLight, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directionalLightShadow = directionalLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n RectAreaLight rectAreaLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n rectAreaLight = rectAreaLights[ i ];\n RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n vec3 iblIrradiance = vec3( 0.0 );\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n #if defined( USE_LIGHT_PROBES )\n irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n #endif\n #if ( NUM_HEMI_LIGHTS > 0 )\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n }\n #pragma unroll_loop_end\n #endif\n #ifdef USE_LIGHT_PROBES_GRID\n vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz;\n vec3 probeWorldNormal = inverseTransformDirection( geometryNormal, viewMatrix );\n irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal );\n #endif\n#endif\n#if defined( RE_IndirectSpecular )\n vec3 radiance = vec3( 0.0 );\n vec3 clearcoatRadiance = vec3( 0.0 );\n#endif";
|
|
16926
17037
|
var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n irradiance += lightMapIrradiance;\n #endif\n #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV )\n #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG )\n iblIrradiance += getIBLIrradiance( geometryNormal );\n #endif\n #endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n #ifdef USE_ANISOTROPY\n radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n #else\n radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n #endif\n #ifdef USE_CLEARCOAT\n clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n #endif\n#endif";
|
|
16927
17038
|
var lights_fragment_end = "#if defined( RE_IndirectDiffuse )\n #if defined( LAMBERT ) || defined( PHONG )\n irradiance += iblIrradiance;\n #endif\n RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif";
|
|
17039
|
+
var lightprobes_pars_fragment = "#ifdef USE_LIGHT_PROBES_GRID\nuniform highp sampler3D probesSH;\nuniform vec3 probesMin;\nuniform vec3 probesMax;\nuniform vec3 probesResolution;\nvec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {\n vec3 res = probesResolution;\n vec3 gridRange = probesMax - probesMin;\n vec3 resMinusOne = res - 1.0;\n vec3 probeSpacing = gridRange / resMinusOne;\n vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5;\n vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 );\n uvw = uvw * resMinusOne / res + 0.5 / res;\n float nz = res.z;\n float paddedSlices = nz + 2.0;\n float atlasDepth = 7.0 * paddedSlices;\n float uvZBase = uvw.z * nz + 1.0;\n vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) );\n vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) );\n vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) );\n vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) );\n vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) );\n vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) );\n vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) );\n vec3 c0 = s0.xyz;\n vec3 c1 = vec3( s0.w, s1.xy );\n vec3 c2 = vec3( s1.zw, s2.x );\n vec3 c3 = s2.yzw;\n vec3 c4 = s3.xyz;\n vec3 c5 = vec3( s3.w, s4.xy );\n vec3 c6 = vec3( s4.zw, s5.x );\n vec3 c7 = s5.yzw;\n vec3 c8 = s6.xyz;\n float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z;\n vec3 result = c0 * 0.886227;\n result += c1 * 2.0 * 0.511664 * y;\n result += c2 * 2.0 * 0.511664 * z;\n result += c3 * 2.0 * 0.511664 * x;\n result += c4 * 2.0 * 0.429043 * x * y;\n result += c5 * 2.0 * 0.429043 * y * z;\n result += c6 * ( 0.743125 * z * z - 0.247708 );\n result += c7 * 2.0 * 0.429043 * x * z;\n result += c8 * 0.429043 * ( x * x - y * y );\n return max( result, vec3( 0.0 ) );\n}\n#endif";
|
|
16928
17040
|
var logdepthbuf_fragment = "#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif";
|
|
16929
17041
|
var logdepthbuf_pars_fragment = "#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n uniform float logDepthBufFC;\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif";
|
|
16930
17042
|
var logdepthbuf_pars_vertex = "#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif";
|
|
@@ -16941,7 +17053,7 @@ var morphnormal_vertex = "#ifdef USE_MORPHNORMALS\n objectNormal *= morphTargetB
|
|
|
16941
17053
|
var morphtarget_pars_vertex = "#ifdef USE_MORPHTARGETS\n #ifndef USE_INSTANCING_MORPH\n uniform float morphTargetBaseInfluence;\n uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n #endif\n uniform sampler2DArray morphTargetsTexture;\n uniform ivec2 morphTargetsTextureSize;\n vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n int y = texelIndex / morphTargetsTextureSize.x;\n int x = texelIndex - y * morphTargetsTextureSize.x;\n ivec3 morphUV = ivec3( x, y, morphTargetIndex );\n return texelFetch( morphTargetsTexture, morphUV, 0 );\n }\n#endif";
|
|
16942
17054
|
var morphtarget_vertex = "#ifdef USE_MORPHTARGETS\n transformed *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n }\n#endif";
|
|
16943
17055
|
var normal_fragment_begin = "float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n vec3 fdx = dFdx( vViewPosition );\n vec3 fdy = dFdy( vViewPosition );\n vec3 normal = normalize( cross( fdx, fdy ) );\n#else\n vec3 normal = normalize( vNormal );\n #ifdef DOUBLE_SIDED\n normal *= faceDirection;\n #endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n #ifdef USE_TANGENT\n mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n #else\n mat3 tbn = getTangentFrame( - vViewPosition, normal,\n #if defined( USE_NORMALMAP )\n vNormalMapUv\n #elif defined( USE_CLEARCOAT_NORMALMAP )\n vClearcoatNormalMapUv\n #else\n vUv\n #endif\n );\n #endif\n #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n tbn[0] *= faceDirection;\n tbn[1] *= faceDirection;\n #endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n #ifdef USE_TANGENT\n mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n #else\n mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n #endif\n #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n tbn2[0] *= faceDirection;\n tbn2[1] *= faceDirection;\n #endif\n#endif\nvec3 nonPerturbedNormal = normal;";
|
|
16944
|
-
var normal_fragment_maps = "#ifdef USE_NORMALMAP_OBJECTSPACE\n normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n #ifdef FLIP_SIDED\n normal = - normal;\n #endif\n #ifdef DOUBLE_SIDED\n normal = normal * faceDirection;\n #endif\n normal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n mapN.xy *= normalScale;\n normal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif";
|
|
17056
|
+
var normal_fragment_maps = "#ifdef USE_NORMALMAP_OBJECTSPACE\n normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n #ifdef FLIP_SIDED\n normal = - normal;\n #endif\n #ifdef DOUBLE_SIDED\n normal = normal * faceDirection;\n #endif\n normal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n #if defined( USE_PACKED_NORMALMAP )\n mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) );\n #endif\n mapN.xy *= normalScale;\n normal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif";
|
|
16945
17057
|
var normal_pars_fragment = "#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif";
|
|
16946
17058
|
var normal_pars_vertex = "#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif";
|
|
16947
17059
|
var normal_vertex = "#ifndef FLAT_SHADED\n vNormal = normalize( transformedNormal );\n #ifdef USE_TANGENT\n vTangent = normalize( transformedTangent );\n vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n #endif\n#endif";
|
|
@@ -16960,7 +17072,7 @@ var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUG
|
|
|
16960
17072
|
var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n uniform sampler2D roughnessMap;\n#endif";
|
|
16961
17073
|
var shadowmap_pars_fragment = "#if NUM_SPOT_LIGHT_COORDS > 0\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n #else\n uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n #else\n uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n struct SpotLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n #elif defined( SHADOWMAP_TYPE_BASIC )\n uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n #if defined( SHADOWMAP_TYPE_PCF )\n float interleavedGradientNoise( vec2 position ) {\n return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );\n }\n vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {\n const float goldenAngle = 2.399963229728653;\n float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );\n float theta = float( sampleIndex ) * goldenAngle + phi;\n return vec2( cos( theta ), sin( theta ) ) * r;\n }\n #endif\n #if defined( SHADOWMAP_TYPE_PCF )\n float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float radius = shadowRadius * texelSize.x;\n float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n shadow = (\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )\n ) * 0.2;\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #elif defined( SHADOWMAP_TYPE_VSM )\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadowCoord.z -= shadowBias;\n #else\n shadowCoord.z += shadowBias;\n #endif\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;\n float mean = distribution.x;\n float variance = distribution.y * distribution.y;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n float hard_shadow = step( mean, shadowCoord.z );\n #else\n float hard_shadow = step( shadowCoord.z, mean );\n #endif\n \n if ( hard_shadow == 1.0 ) {\n shadow = 1.0;\n } else {\n variance = max( variance, 0.0000001 );\n float d = shadowCoord.z - mean;\n float p_max = variance / ( variance + d * d );\n p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );\n shadow = max( hard_shadow, p_max );\n }\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #else\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadowCoord.z -= shadowBias;\n #else\n shadowCoord.z += shadowBias;\n #endif\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n float depth = texture2D( shadowMap, shadowCoord.xy ).r;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadow = step( depth, shadowCoord.z );\n #else\n shadow = step( shadowCoord.z, depth );\n #endif\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n float shadow = 1.0;\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 bd3D = normalize( lightToPosition );\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n #ifdef USE_REVERSED_DEPTH_BUFFER\n float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp -= shadowBias;\n #else\n float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp += shadowBias;\n #endif\n float texelSize = shadowRadius / shadowMapSize.x;\n vec3 absDir = abs( bd3D );\n vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );\n tangent = normalize( cross( bd3D, tangent ) );\n vec3 bitangent = cross( bd3D, tangent );\n float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n vec2 sample0 = vogelDiskSample( 0, 5, phi );\n vec2 sample1 = vogelDiskSample( 1, 5, phi );\n vec2 sample2 = vogelDiskSample( 2, 5, phi );\n vec2 sample3 = vogelDiskSample( 3, 5, phi );\n vec2 sample4 = vogelDiskSample( 4, 5, phi );\n shadow = (\n texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) )\n ) * 0.2;\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #elif defined( SHADOWMAP_TYPE_BASIC )\n float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n float shadow = 1.0;\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp += shadowBias;\n vec3 bd3D = normalize( lightToPosition );\n float depth = textureCube( shadowMap, bd3D ).r;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n depth = 1.0 - depth;\n #endif\n shadow = step( dp, depth );\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #endif\n #endif\n#endif";
|
|
16962
17074
|
var shadowmap_pars_vertex = "#if NUM_SPOT_LIGHT_COORDS > 0\n uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n struct SpotLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n#endif";
|
|
16963
|
-
var shadowmap_vertex = "#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n vec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n shadowWorldPosition = worldPosition;\n #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n #endif\n vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n#endif";
|
|
17075
|
+
var shadowmap_vertex = "#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n #ifdef HAS_NORMAL\n vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n #else\n vec3 shadowWorldNormal = vec3( 0.0 );\n #endif\n vec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n shadowWorldPosition = worldPosition;\n #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n #endif\n vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n#endif";
|
|
16964
17076
|
var shadowmask_pars_fragment = "float getShadowMask() {\n float shadow = 1.0;\n #ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n directionalLight = directionalLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n spotLight = spotLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n PointLightShadow pointLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n pointLight = pointLightShadows[ i ];\n shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #endif\n return shadow;\n}";
|
|
16965
17077
|
var skinbase_vertex = "#ifdef USE_SKINNING\n mat4 boneMatX = getBoneMatrix( skinIndex.x );\n mat4 boneMatY = getBoneMatrix( skinIndex.y );\n mat4 boneMatZ = getBoneMatrix( skinIndex.z );\n mat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif";
|
|
16966
17078
|
var skinning_pars_vertex = "#ifdef USE_SKINNING\n uniform mat4 bindMatrix;\n uniform mat4 bindMatrixInverse;\n uniform highp sampler2D boneTexture;\n mat4 getBoneMatrix( const in float i ) {\n int size = textureSize( boneTexture, 0 ).x;\n int j = int( i ) * 4;\n int x = j % size;\n int y = j / size;\n vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n return mat4( v1, v2, v3, v4 );\n }\n#endif";
|
|
@@ -16979,7 +17091,7 @@ var worldpos_vertex = "#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defin
|
|
|
16979
17091
|
var vertex$h = "varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n gl_Position = vec4( position.xy, 1.0, 1.0 );\n}";
|
|
16980
17092
|
var fragment$h = "uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n vec4 texColor = texture2D( t2D, vUv );\n #ifdef DECODE_VIDEO_TEXTURE\n texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n #endif\n texColor.rgb *= backgroundIntensity;\n gl_FragColor = texColor;\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}";
|
|
16981
17093
|
var vertex$g = "varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include <begin_vertex>\n #include <project_vertex>\n gl_Position.z = gl_Position.w;\n}";
|
|
16982
|
-
var fragment$g = "#ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n uniform sampler2D envMap;\n#endif\nuniform float
|
|
17094
|
+
var fragment$g = "#ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n uniform sampler2D envMap;\n#endif\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n #ifdef ENVMAP_TYPE_CUBE\n vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection );\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n #else\n vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n #endif\n texColor.rgb *= backgroundIntensity;\n gl_FragColor = texColor;\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}";
|
|
16983
17095
|
var vertex$f = "varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include <begin_vertex>\n #include <project_vertex>\n gl_Position.z = gl_Position.w;\n}";
|
|
16984
17096
|
var fragment$f = "uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n gl_FragColor = texColor;\n gl_FragColor.a *= opacity;\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}";
|
|
16985
17097
|
var vertex$e = "#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n #include <uv_vertex>\n #include <batching_vertex>\n #include <skinbase_vertex>\n #include <morphinstance_vertex>\n #ifdef USE_DISPLACEMENTMAP\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinnormal_vertex>\n #endif\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vHighPrecisionZW = gl_Position.zw;\n}";
|
|
@@ -17067,6 +17179,7 @@ var ShaderChunk = {
|
|
|
17067
17179
|
lights_fragment_begin,
|
|
17068
17180
|
lights_fragment_maps,
|
|
17069
17181
|
lights_fragment_end,
|
|
17182
|
+
lightprobes_pars_fragment,
|
|
17070
17183
|
logdepthbuf_fragment,
|
|
17071
17184
|
logdepthbuf_pars_fragment,
|
|
17072
17185
|
logdepthbuf_pars_vertex,
|
|
@@ -17170,7 +17283,6 @@ var UniformsLib = {
|
|
|
17170
17283
|
envmap: {
|
|
17171
17284
|
envMap: { value: null },
|
|
17172
17285
|
envMapRotation: { value: /* @__PURE__ */ new Matrix3() },
|
|
17173
|
-
flipEnvMap: { value: -1 },
|
|
17174
17286
|
reflectivity: { value: 1 },
|
|
17175
17287
|
// basic, lambert, phong
|
|
17176
17288
|
ior: { value: 1.5 },
|
|
@@ -17289,7 +17401,11 @@ var UniformsLib = {
|
|
|
17289
17401
|
height: {}
|
|
17290
17402
|
} },
|
|
17291
17403
|
ltc_1: { value: null },
|
|
17292
|
-
ltc_2: { value: null }
|
|
17404
|
+
ltc_2: { value: null },
|
|
17405
|
+
probesSH: { value: null },
|
|
17406
|
+
probesMin: { value: /* @__PURE__ */ new Vector3() },
|
|
17407
|
+
probesMax: { value: /* @__PURE__ */ new Vector3() },
|
|
17408
|
+
probesResolution: { value: /* @__PURE__ */ new Vector3() }
|
|
17293
17409
|
},
|
|
17294
17410
|
points: {
|
|
17295
17411
|
diffuse: { value: /* @__PURE__ */ new Color(16777215) },
|
|
@@ -17490,7 +17606,6 @@ var ShaderLib = {
|
|
|
17490
17606
|
backgroundCube: {
|
|
17491
17607
|
uniforms: {
|
|
17492
17608
|
envMap: { value: null },
|
|
17493
|
-
flipEnvMap: { value: -1 },
|
|
17494
17609
|
backgroundBlurriness: { value: 0 },
|
|
17495
17610
|
backgroundIntensity: { value: 1 },
|
|
17496
17611
|
backgroundRotation: { value: /* @__PURE__ */ new Matrix3() }
|
|
@@ -17594,8 +17709,9 @@ ShaderLib.physical = {
|
|
|
17594
17709
|
fragmentShader: ShaderChunk.meshphysical_frag
|
|
17595
17710
|
};
|
|
17596
17711
|
var _rgb = { r: 0, b: 0, g: 0 };
|
|
17597
|
-
var _e1$1 = /* @__PURE__ */ new Euler();
|
|
17598
17712
|
var _m1$12 = /* @__PURE__ */ new Matrix4();
|
|
17713
|
+
var _m$1 = /* @__PURE__ */ new Matrix3();
|
|
17714
|
+
_m$1.set(-1, 0, 0, 0, 1, 0, 0, 0, 1);
|
|
17599
17715
|
function WebGLBackground(renderer, environments, state, objects, alpha, premultipliedAlpha) {
|
|
17600
17716
|
const clearColor = new Color(0);
|
|
17601
17717
|
let clearAlpha = alpha === true ? 0 : 1;
|
|
@@ -17664,19 +17780,13 @@ function WebGLBackground(renderer, environments, state, objects, alpha, premulti
|
|
|
17664
17780
|
});
|
|
17665
17781
|
objects.update(boxMesh);
|
|
17666
17782
|
}
|
|
17667
|
-
_e1$1.copy(scene.backgroundRotation);
|
|
17668
|
-
_e1$1.x *= -1;
|
|
17669
|
-
_e1$1.y *= -1;
|
|
17670
|
-
_e1$1.z *= -1;
|
|
17671
|
-
if (background.isCubeTexture && background.isRenderTargetTexture === false) {
|
|
17672
|
-
_e1$1.y *= -1;
|
|
17673
|
-
_e1$1.z *= -1;
|
|
17674
|
-
}
|
|
17675
17783
|
boxMesh.material.uniforms.envMap.value = background;
|
|
17676
|
-
boxMesh.material.uniforms.flipEnvMap.value = background.isCubeTexture && background.isRenderTargetTexture === false ? -1 : 1;
|
|
17677
17784
|
boxMesh.material.uniforms.backgroundBlurriness.value = scene.backgroundBlurriness;
|
|
17678
17785
|
boxMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
|
|
17679
|
-
boxMesh.material.uniforms.backgroundRotation.value.setFromMatrix4(_m1$12.makeRotationFromEuler(
|
|
17786
|
+
boxMesh.material.uniforms.backgroundRotation.value.setFromMatrix4(_m1$12.makeRotationFromEuler(scene.backgroundRotation)).transpose();
|
|
17787
|
+
if (background.isCubeTexture && background.isRenderTargetTexture === false) {
|
|
17788
|
+
boxMesh.material.uniforms.backgroundRotation.value.premultiply(_m$1);
|
|
17789
|
+
}
|
|
17680
17790
|
boxMesh.material.toneMapped = ColorManagement.getTransfer(background.colorSpace) !== SRGBTransfer;
|
|
17681
17791
|
if (currentBackground !== background || currentBackgroundVersion !== background.version || currentTonemapping !== renderer.toneMapping) {
|
|
17682
17792
|
boxMesh.material.needsUpdate = true;
|
|
@@ -18152,27 +18262,10 @@ function WebGLBufferRenderer(gl, extensions, info) {
|
|
|
18152
18262
|
}
|
|
18153
18263
|
info.update(elementCount, mode, 1);
|
|
18154
18264
|
}
|
|
18155
|
-
function renderMultiDrawInstances(starts, counts, drawCount, primcount) {
|
|
18156
|
-
if (drawCount === 0) return;
|
|
18157
|
-
const extension = extensions.get("WEBGL_multi_draw");
|
|
18158
|
-
if (extension === null) {
|
|
18159
|
-
for (let i = 0; i < starts.length; i++) {
|
|
18160
|
-
renderInstances(starts[i], counts[i], primcount[i]);
|
|
18161
|
-
}
|
|
18162
|
-
} else {
|
|
18163
|
-
extension.multiDrawArraysInstancedWEBGL(mode, starts, 0, counts, 0, primcount, 0, drawCount);
|
|
18164
|
-
let elementCount = 0;
|
|
18165
|
-
for (let i = 0; i < drawCount; i++) {
|
|
18166
|
-
elementCount += counts[i] * primcount[i];
|
|
18167
|
-
}
|
|
18168
|
-
info.update(elementCount, mode, 1);
|
|
18169
|
-
}
|
|
18170
|
-
}
|
|
18171
18265
|
this.setMode = setMode;
|
|
18172
18266
|
this.render = render;
|
|
18173
18267
|
this.renderInstances = renderInstances;
|
|
18174
18268
|
this.renderMultiDraw = renderMultiDraw;
|
|
18175
|
-
this.renderMultiDrawInstances = renderMultiDrawInstances;
|
|
18176
18269
|
}
|
|
18177
18270
|
function WebGLCapabilities(gl, extensions, parameters, utils) {
|
|
18178
18271
|
let maxAnisotropy;
|
|
@@ -18222,6 +18315,9 @@ function WebGLCapabilities(gl, extensions, parameters, utils) {
|
|
|
18222
18315
|
}
|
|
18223
18316
|
const logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;
|
|
18224
18317
|
const reversedDepthBuffer = parameters.reversedDepthBuffer === true && extensions.has("EXT_clip_control");
|
|
18318
|
+
if (parameters.reversedDepthBuffer === true && reversedDepthBuffer === false) {
|
|
18319
|
+
warn("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");
|
|
18320
|
+
}
|
|
18225
18321
|
const maxTextures = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS);
|
|
18226
18322
|
const maxVertexTextures = gl.getParameter(gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
|
|
18227
18323
|
const maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);
|
|
@@ -19563,28 +19659,11 @@ function WebGLIndexedBufferRenderer(gl, extensions, info) {
|
|
|
19563
19659
|
}
|
|
19564
19660
|
info.update(elementCount, mode, 1);
|
|
19565
19661
|
}
|
|
19566
|
-
function renderMultiDrawInstances(starts, counts, drawCount, primcount) {
|
|
19567
|
-
if (drawCount === 0) return;
|
|
19568
|
-
const extension = extensions.get("WEBGL_multi_draw");
|
|
19569
|
-
if (extension === null) {
|
|
19570
|
-
for (let i = 0; i < starts.length; i++) {
|
|
19571
|
-
renderInstances(starts[i] / bytesPerElement, counts[i], primcount[i]);
|
|
19572
|
-
}
|
|
19573
|
-
} else {
|
|
19574
|
-
extension.multiDrawElementsInstancedWEBGL(mode, counts, 0, type, starts, 0, primcount, 0, drawCount);
|
|
19575
|
-
let elementCount = 0;
|
|
19576
|
-
for (let i = 0; i < drawCount; i++) {
|
|
19577
|
-
elementCount += counts[i] * primcount[i];
|
|
19578
|
-
}
|
|
19579
|
-
info.update(elementCount, mode, 1);
|
|
19580
|
-
}
|
|
19581
|
-
}
|
|
19582
19662
|
this.setMode = setMode;
|
|
19583
19663
|
this.setIndex = setIndex;
|
|
19584
19664
|
this.render = render;
|
|
19585
19665
|
this.renderInstances = renderInstances;
|
|
19586
19666
|
this.renderMultiDraw = renderMultiDraw;
|
|
19587
|
-
this.renderMultiDrawInstances = renderMultiDrawInstances;
|
|
19588
19667
|
}
|
|
19589
19668
|
function WebGLInfo(gl) {
|
|
19590
19669
|
const memory = {
|
|
@@ -19787,7 +19866,8 @@ function WebGLOutput(type, width, height, depth, stencil) {
|
|
|
19787
19866
|
const targetA = new WebGLRenderTarget(width, height, {
|
|
19788
19867
|
type,
|
|
19789
19868
|
depthBuffer: depth,
|
|
19790
|
-
stencilBuffer: stencil
|
|
19869
|
+
stencilBuffer: stencil,
|
|
19870
|
+
depthTexture: depth ? new DepthTexture(width, height) : void 0
|
|
19791
19871
|
});
|
|
19792
19872
|
const targetB = new WebGLRenderTarget(width, height, {
|
|
19793
19873
|
type: HalfFloatType,
|
|
@@ -19940,6 +20020,7 @@ function WebGLOutput(type, width, height, depth, stencil) {
|
|
|
19940
20020
|
return _isCompositing;
|
|
19941
20021
|
};
|
|
19942
20022
|
this.dispose = function() {
|
|
20023
|
+
if (targetA.depthTexture) targetA.depthTexture.dispose();
|
|
19943
20024
|
targetA.dispose();
|
|
19944
20025
|
targetB.dispose();
|
|
19945
20026
|
geometry.dispose();
|
|
@@ -20951,6 +21032,7 @@ function WebGLProgram(renderer, cacheKey, parameters, bindingStates) {
|
|
|
20951
21032
|
parameters.thicknessMapUv ? "#define THICKNESSMAP_UV " + parameters.thicknessMapUv : "",
|
|
20952
21033
|
//
|
|
20953
21034
|
parameters.vertexTangents && parameters.flatShading === false ? "#define USE_TANGENT" : "",
|
|
21035
|
+
parameters.vertexNormals ? "#define HAS_NORMAL" : "",
|
|
20954
21036
|
parameters.vertexColors ? "#define USE_COLOR" : "",
|
|
20955
21037
|
parameters.vertexAlphas ? "#define USE_COLOR_ALPHA" : "",
|
|
20956
21038
|
parameters.vertexUv1s ? "#define USE_UV1" : "",
|
|
@@ -21037,6 +21119,7 @@ function WebGLProgram(renderer, cacheKey, parameters, bindingStates) {
|
|
|
21037
21119
|
parameters.normalMap ? "#define USE_NORMALMAP" : "",
|
|
21038
21120
|
parameters.normalMapObjectSpace ? "#define USE_NORMALMAP_OBJECTSPACE" : "",
|
|
21039
21121
|
parameters.normalMapTangentSpace ? "#define USE_NORMALMAP_TANGENTSPACE" : "",
|
|
21122
|
+
parameters.packedNormalMap ? "#define USE_PACKED_NORMALMAP" : "",
|
|
21040
21123
|
parameters.emissiveMap ? "#define USE_EMISSIVEMAP" : "",
|
|
21041
21124
|
parameters.anisotropy ? "#define USE_ANISOTROPY" : "",
|
|
21042
21125
|
parameters.anisotropyMap ? "#define USE_ANISOTROPYMAP" : "",
|
|
@@ -21077,6 +21160,7 @@ function WebGLProgram(renderer, cacheKey, parameters, bindingStates) {
|
|
|
21077
21160
|
parameters.shadowMapEnabled ? "#define " + shadowMapTypeDefine : "",
|
|
21078
21161
|
parameters.premultipliedAlpha ? "#define PREMULTIPLIED_ALPHA" : "",
|
|
21079
21162
|
parameters.numLightProbes > 0 ? "#define USE_LIGHT_PROBES" : "",
|
|
21163
|
+
parameters.numLightProbeGrids > 0 ? "#define USE_LIGHT_PROBES_GRID" : "",
|
|
21080
21164
|
parameters.decodeVideoTexture ? "#define DECODE_VIDEO_TEXTURE" : "",
|
|
21081
21165
|
parameters.decodeVideoTextureEmissive ? "#define DECODE_VIDEO_TEXTURE_EMISSIVE" : "",
|
|
21082
21166
|
parameters.logarithmicDepthBuffer ? "#define USE_LOGARITHMIC_DEPTH_BUFFER" : "",
|
|
@@ -21291,6 +21375,9 @@ var WebGLShaderStage = class {
|
|
|
21291
21375
|
this.usedTimes = 0;
|
|
21292
21376
|
}
|
|
21293
21377
|
};
|
|
21378
|
+
function isPackedRGFormat(format) {
|
|
21379
|
+
return format === RGFormat || format === RG11_EAC_Format || format === RED_GREEN_RGTC2_Format;
|
|
21380
|
+
}
|
|
21294
21381
|
function WebGLPrograms(renderer, environments, extensions, capabilities, bindingStates, clipping) {
|
|
21295
21382
|
const _programLayers = new Layers();
|
|
21296
21383
|
const _customShaders = new WebGLShaderCache();
|
|
@@ -21321,7 +21408,7 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
|
|
|
21321
21408
|
if (value === 0) return "uv";
|
|
21322
21409
|
return `uv${value}`;
|
|
21323
21410
|
}
|
|
21324
|
-
function getParameters(material, lights, shadows, scene, object) {
|
|
21411
|
+
function getParameters(material, lights, shadows, scene, object, lightProbeGrids) {
|
|
21325
21412
|
const fog = scene.fog;
|
|
21326
21413
|
const geometry = object.geometry;
|
|
21327
21414
|
const environment = material.isMeshStandardMaterial || material.isMeshLambertMaterial || material.isMeshPhongMaterial ? scene.environment : null;
|
|
@@ -21416,7 +21503,7 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
|
|
|
21416
21503
|
instancing: IS_INSTANCEDMESH,
|
|
21417
21504
|
instancingColor: IS_INSTANCEDMESH && object.instanceColor !== null,
|
|
21418
21505
|
instancingMorph: IS_INSTANCEDMESH && object.morphTexture !== null,
|
|
21419
|
-
outputColorSpace: currentRenderTarget === null ? renderer.outputColorSpace : currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.colorSpace :
|
|
21506
|
+
outputColorSpace: currentRenderTarget === null ? renderer.outputColorSpace : currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.colorSpace : ColorManagement.workingColorSpace,
|
|
21420
21507
|
alphaToCoverage: !!material.alphaToCoverage,
|
|
21421
21508
|
map: HAS_MAP,
|
|
21422
21509
|
matcap: HAS_MATCAP,
|
|
@@ -21431,6 +21518,7 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
|
|
|
21431
21518
|
emissiveMap: HAS_EMISSIVEMAP,
|
|
21432
21519
|
normalMapObjectSpace: HAS_NORMALMAP && material.normalMapType === ObjectSpaceNormalMap,
|
|
21433
21520
|
normalMapTangentSpace: HAS_NORMALMAP && material.normalMapType === TangentSpaceNormalMap,
|
|
21521
|
+
packedNormalMap: HAS_NORMALMAP && material.normalMapType === TangentSpaceNormalMap && isPackedRGFormat(material.normalMap.format),
|
|
21434
21522
|
metalnessMap: HAS_METALNESSMAP,
|
|
21435
21523
|
roughnessMap: HAS_ROUGHNESSMAP,
|
|
21436
21524
|
anisotropy: HAS_ANISOTROPY,
|
|
@@ -21484,6 +21572,7 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
|
|
|
21484
21572
|
alphaMapUv: HAS_ALPHAMAP && getChannel(material.alphaMap.channel),
|
|
21485
21573
|
//
|
|
21486
21574
|
vertexTangents: !!geometry.attributes.tangent && (HAS_NORMALMAP || HAS_ANISOTROPY),
|
|
21575
|
+
vertexNormals: !!geometry.attributes.normal,
|
|
21487
21576
|
vertexColors: material.vertexColors,
|
|
21488
21577
|
vertexAlphas: material.vertexColors === true && !!geometry.attributes.color && geometry.attributes.color.itemSize === 4,
|
|
21489
21578
|
pointsUvs: object.isPoints === true && !!geometry.attributes.uv && (HAS_MAP || HAS_ALPHAMAP),
|
|
@@ -21511,6 +21600,7 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
|
|
|
21511
21600
|
numSpotLightShadows: lights.spotShadowMap.length,
|
|
21512
21601
|
numSpotLightShadowsWithMaps: lights.numSpotLightShadowsWithMaps,
|
|
21513
21602
|
numLightProbes: lights.numLightProbes,
|
|
21603
|
+
numLightProbeGrids: lightProbeGrids.length,
|
|
21514
21604
|
numClippingPlanes: clipping.numPlanes,
|
|
21515
21605
|
numClipIntersection: clipping.numIntersection,
|
|
21516
21606
|
dithering: material.dithering,
|
|
@@ -21654,6 +21744,10 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
|
|
|
21654
21744
|
_programLayers.enable(20);
|
|
21655
21745
|
if (parameters.gradientMap)
|
|
21656
21746
|
_programLayers.enable(21);
|
|
21747
|
+
if (parameters.packedNormalMap)
|
|
21748
|
+
_programLayers.enable(22);
|
|
21749
|
+
if (parameters.vertexNormals)
|
|
21750
|
+
_programLayers.enable(23);
|
|
21657
21751
|
array.push(_programLayers.mask);
|
|
21658
21752
|
_programLayers.disableAll();
|
|
21659
21753
|
if (parameters.fog)
|
|
@@ -21700,6 +21794,8 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
|
|
|
21700
21794
|
_programLayers.enable(20);
|
|
21701
21795
|
if (parameters.alphaToCoverage)
|
|
21702
21796
|
_programLayers.enable(21);
|
|
21797
|
+
if (parameters.numLightProbeGrids > 0)
|
|
21798
|
+
_programLayers.enable(22);
|
|
21703
21799
|
array.push(_programLayers.mask);
|
|
21704
21800
|
}
|
|
21705
21801
|
function getUniforms(material) {
|
|
@@ -22299,10 +22395,12 @@ function WebGLRenderState(extensions) {
|
|
|
22299
22395
|
const lights = new WebGLLights(extensions);
|
|
22300
22396
|
const lightsArray = [];
|
|
22301
22397
|
const shadowsArray = [];
|
|
22398
|
+
const lightProbeGridArray = [];
|
|
22302
22399
|
function init(camera) {
|
|
22303
22400
|
state.camera = camera;
|
|
22304
22401
|
lightsArray.length = 0;
|
|
22305
22402
|
shadowsArray.length = 0;
|
|
22403
|
+
lightProbeGridArray.length = 0;
|
|
22306
22404
|
}
|
|
22307
22405
|
function pushLight(light) {
|
|
22308
22406
|
lightsArray.push(light);
|
|
@@ -22310,6 +22408,9 @@ function WebGLRenderState(extensions) {
|
|
|
22310
22408
|
function pushShadow(shadowLight) {
|
|
22311
22409
|
shadowsArray.push(shadowLight);
|
|
22312
22410
|
}
|
|
22411
|
+
function pushLightProbeGrid(volume) {
|
|
22412
|
+
lightProbeGridArray.push(volume);
|
|
22413
|
+
}
|
|
22313
22414
|
function setupLights() {
|
|
22314
22415
|
lights.setup(lightsArray);
|
|
22315
22416
|
}
|
|
@@ -22319,9 +22420,11 @@ function WebGLRenderState(extensions) {
|
|
|
22319
22420
|
const state = {
|
|
22320
22421
|
lightsArray,
|
|
22321
22422
|
shadowsArray,
|
|
22423
|
+
lightProbeGridArray,
|
|
22322
22424
|
camera: null,
|
|
22323
22425
|
lights,
|
|
22324
|
-
transmissionRenderTarget: {}
|
|
22426
|
+
transmissionRenderTarget: {},
|
|
22427
|
+
textureUnits: 0
|
|
22325
22428
|
};
|
|
22326
22429
|
return {
|
|
22327
22430
|
init,
|
|
@@ -22329,7 +22432,8 @@ function WebGLRenderState(extensions) {
|
|
|
22329
22432
|
setupLights,
|
|
22330
22433
|
setupLightsView,
|
|
22331
22434
|
pushLight,
|
|
22332
|
-
pushShadow
|
|
22435
|
+
pushShadow,
|
|
22436
|
+
pushLightProbeGrid
|
|
22333
22437
|
};
|
|
22334
22438
|
}
|
|
22335
22439
|
function WebGLRenderStates(extensions) {
|
|
@@ -22889,6 +22993,7 @@ function WebGLState(gl, extensions) {
|
|
|
22889
22993
|
const uboBindings = /* @__PURE__ */ new WeakMap();
|
|
22890
22994
|
const uboProgramMap = /* @__PURE__ */ new WeakMap();
|
|
22891
22995
|
let enabledCapabilities = {};
|
|
22996
|
+
let parameters = {};
|
|
22892
22997
|
let currentBoundFramebuffers = {};
|
|
22893
22998
|
let currentDrawbuffers = /* @__PURE__ */ new WeakMap();
|
|
22894
22999
|
let defaultDrawbuffers = [];
|
|
@@ -23313,6 +23418,19 @@ function WebGLState(gl, extensions) {
|
|
|
23313
23418
|
error("WebGLState:", e);
|
|
23314
23419
|
}
|
|
23315
23420
|
}
|
|
23421
|
+
function getParameter(name) {
|
|
23422
|
+
if (parameters[name] !== void 0) {
|
|
23423
|
+
return parameters[name];
|
|
23424
|
+
} else {
|
|
23425
|
+
return gl.getParameter(name);
|
|
23426
|
+
}
|
|
23427
|
+
}
|
|
23428
|
+
function pixelStorei(name, value) {
|
|
23429
|
+
if (parameters[name] !== value) {
|
|
23430
|
+
gl.pixelStorei(name, value);
|
|
23431
|
+
parameters[name] = value;
|
|
23432
|
+
}
|
|
23433
|
+
}
|
|
23316
23434
|
function scissor(scissor2) {
|
|
23317
23435
|
if (currentScissor.equals(scissor2) === false) {
|
|
23318
23436
|
gl.scissor(scissor2.x, scissor2.y, scissor2.z, scissor2.w);
|
|
@@ -23378,7 +23496,21 @@ function WebGLState(gl, extensions) {
|
|
|
23378
23496
|
gl.lineWidth(1);
|
|
23379
23497
|
gl.scissor(0, 0, gl.canvas.width, gl.canvas.height);
|
|
23380
23498
|
gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);
|
|
23499
|
+
gl.pixelStorei(gl.PACK_ALIGNMENT, 4);
|
|
23500
|
+
gl.pixelStorei(gl.UNPACK_ALIGNMENT, 4);
|
|
23501
|
+
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
23502
|
+
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
|
|
23503
|
+
gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, gl.BROWSER_DEFAULT_WEBGL);
|
|
23504
|
+
gl.pixelStorei(gl.PACK_ROW_LENGTH, 0);
|
|
23505
|
+
gl.pixelStorei(gl.PACK_SKIP_PIXELS, 0);
|
|
23506
|
+
gl.pixelStorei(gl.PACK_SKIP_ROWS, 0);
|
|
23507
|
+
gl.pixelStorei(gl.UNPACK_ROW_LENGTH, 0);
|
|
23508
|
+
gl.pixelStorei(gl.UNPACK_IMAGE_HEIGHT, 0);
|
|
23509
|
+
gl.pixelStorei(gl.UNPACK_SKIP_PIXELS, 0);
|
|
23510
|
+
gl.pixelStorei(gl.UNPACK_SKIP_ROWS, 0);
|
|
23511
|
+
gl.pixelStorei(gl.UNPACK_SKIP_IMAGES, 0);
|
|
23381
23512
|
enabledCapabilities = {};
|
|
23513
|
+
parameters = {};
|
|
23382
23514
|
currentTextureSlot = null;
|
|
23383
23515
|
currentBoundTextures = {};
|
|
23384
23516
|
currentBoundFramebuffers = {};
|
|
@@ -23432,6 +23564,8 @@ function WebGLState(gl, extensions) {
|
|
|
23432
23564
|
compressedTexImage3D,
|
|
23433
23565
|
texImage2D,
|
|
23434
23566
|
texImage3D,
|
|
23567
|
+
pixelStorei,
|
|
23568
|
+
getParameter,
|
|
23435
23569
|
updateUBOMapping,
|
|
23436
23570
|
uniformBlockBinding,
|
|
23437
23571
|
texStorage2D,
|
|
@@ -23450,6 +23584,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
23450
23584
|
const supportsInvalidateFramebuffer = typeof navigator === "undefined" ? false : /OculusBrowser/g.test(navigator.userAgent);
|
|
23451
23585
|
const _imageDimensions = new Vector2();
|
|
23452
23586
|
const _videoTextures = /* @__PURE__ */ new WeakMap();
|
|
23587
|
+
const _htmlTextures = /* @__PURE__ */ new Set();
|
|
23453
23588
|
let _canvas2;
|
|
23454
23589
|
const _sources = /* @__PURE__ */ new WeakMap();
|
|
23455
23590
|
let useOffscreenCanvas = false;
|
|
@@ -23499,16 +23634,25 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
23499
23634
|
if (texture.isWebGLArrayRenderTarget || texture.isCompressedArrayTexture) return _gl.TEXTURE_2D_ARRAY;
|
|
23500
23635
|
return _gl.TEXTURE_2D;
|
|
23501
23636
|
}
|
|
23502
|
-
function getInternalFormat(internalFormatName, glFormat, glType, colorSpace, forceLinearTransfer = false) {
|
|
23637
|
+
function getInternalFormat(internalFormatName, glFormat, glType, normalized, colorSpace, forceLinearTransfer = false) {
|
|
23503
23638
|
if (internalFormatName !== null) {
|
|
23504
23639
|
if (_gl[internalFormatName] !== void 0) return _gl[internalFormatName];
|
|
23505
23640
|
warn("WebGLRenderer: Attempt to use non-existing WebGL internal format '" + internalFormatName + "'");
|
|
23506
23641
|
}
|
|
23642
|
+
let ext_texture_norm16;
|
|
23643
|
+
if (normalized) {
|
|
23644
|
+
ext_texture_norm16 = extensions.get("EXT_texture_norm16");
|
|
23645
|
+
if (!ext_texture_norm16) {
|
|
23646
|
+
warn("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension");
|
|
23647
|
+
}
|
|
23648
|
+
}
|
|
23507
23649
|
let internalFormat = glFormat;
|
|
23508
23650
|
if (glFormat === _gl.RED) {
|
|
23509
23651
|
if (glType === _gl.FLOAT) internalFormat = _gl.R32F;
|
|
23510
23652
|
if (glType === _gl.HALF_FLOAT) internalFormat = _gl.R16F;
|
|
23511
23653
|
if (glType === _gl.UNSIGNED_BYTE) internalFormat = _gl.R8;
|
|
23654
|
+
if (glType === _gl.UNSIGNED_SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.R16_EXT;
|
|
23655
|
+
if (glType === _gl.SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.R16_SNORM_EXT;
|
|
23512
23656
|
}
|
|
23513
23657
|
if (glFormat === _gl.RED_INTEGER) {
|
|
23514
23658
|
if (glType === _gl.UNSIGNED_BYTE) internalFormat = _gl.R8UI;
|
|
@@ -23522,6 +23666,8 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
23522
23666
|
if (glType === _gl.FLOAT) internalFormat = _gl.RG32F;
|
|
23523
23667
|
if (glType === _gl.HALF_FLOAT) internalFormat = _gl.RG16F;
|
|
23524
23668
|
if (glType === _gl.UNSIGNED_BYTE) internalFormat = _gl.RG8;
|
|
23669
|
+
if (glType === _gl.UNSIGNED_SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.RG16_EXT;
|
|
23670
|
+
if (glType === _gl.SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.RG16_SNORM_EXT;
|
|
23525
23671
|
}
|
|
23526
23672
|
if (glFormat === _gl.RG_INTEGER) {
|
|
23527
23673
|
if (glType === _gl.UNSIGNED_BYTE) internalFormat = _gl.RG8UI;
|
|
@@ -23548,6 +23694,8 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
23548
23694
|
if (glType === _gl.INT) internalFormat = _gl.RGBA32I;
|
|
23549
23695
|
}
|
|
23550
23696
|
if (glFormat === _gl.RGB) {
|
|
23697
|
+
if (glType === _gl.UNSIGNED_SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.RGB16_EXT;
|
|
23698
|
+
if (glType === _gl.SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.RGB16_SNORM_EXT;
|
|
23551
23699
|
if (glType === _gl.UNSIGNED_INT_5_9_9_9_REV) internalFormat = _gl.RGB9_E5;
|
|
23552
23700
|
if (glType === _gl.UNSIGNED_INT_10F_11F_11F_REV) internalFormat = _gl.R11F_G11F_B10F;
|
|
23553
23701
|
}
|
|
@@ -23556,6 +23704,8 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
23556
23704
|
if (glType === _gl.FLOAT) internalFormat = _gl.RGBA32F;
|
|
23557
23705
|
if (glType === _gl.HALF_FLOAT) internalFormat = _gl.RGBA16F;
|
|
23558
23706
|
if (glType === _gl.UNSIGNED_BYTE) internalFormat = transfer === SRGBTransfer ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
|
|
23707
|
+
if (glType === _gl.UNSIGNED_SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.RGBA16_EXT;
|
|
23708
|
+
if (glType === _gl.SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.RGBA16_SNORM_EXT;
|
|
23559
23709
|
if (glType === _gl.UNSIGNED_SHORT_4_4_4_4) internalFormat = _gl.RGBA4;
|
|
23560
23710
|
if (glType === _gl.UNSIGNED_SHORT_5_5_5_1) internalFormat = _gl.RGB5_A1;
|
|
23561
23711
|
}
|
|
@@ -23604,6 +23754,9 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
23604
23754
|
if (texture.isVideoTexture) {
|
|
23605
23755
|
_videoTextures.delete(texture);
|
|
23606
23756
|
}
|
|
23757
|
+
if (texture.isHTMLTexture) {
|
|
23758
|
+
_htmlTextures.delete(texture);
|
|
23759
|
+
}
|
|
23607
23760
|
}
|
|
23608
23761
|
function onRenderTargetDispose(event) {
|
|
23609
23762
|
const renderTarget = event.target;
|
|
@@ -23680,6 +23833,12 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
23680
23833
|
function resetTextureUnits() {
|
|
23681
23834
|
textureUnits = 0;
|
|
23682
23835
|
}
|
|
23836
|
+
function getTextureUnits() {
|
|
23837
|
+
return textureUnits;
|
|
23838
|
+
}
|
|
23839
|
+
function setTextureUnits(value) {
|
|
23840
|
+
textureUnits = value;
|
|
23841
|
+
}
|
|
23683
23842
|
function allocateTextureUnit() {
|
|
23684
23843
|
const textureUnit = textureUnits;
|
|
23685
23844
|
if (textureUnit >= capabilities.maxTextures) {
|
|
@@ -23862,10 +24021,10 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
23862
24021
|
}
|
|
23863
24022
|
}
|
|
23864
24023
|
updateRanges.length = mergeIndex + 1;
|
|
23865
|
-
const currentUnpackRowLen =
|
|
23866
|
-
const currentUnpackSkipPixels =
|
|
23867
|
-
const currentUnpackSkipRows =
|
|
23868
|
-
|
|
24024
|
+
const currentUnpackRowLen = state.getParameter(_gl.UNPACK_ROW_LENGTH);
|
|
24025
|
+
const currentUnpackSkipPixels = state.getParameter(_gl.UNPACK_SKIP_PIXELS);
|
|
24026
|
+
const currentUnpackSkipRows = state.getParameter(_gl.UNPACK_SKIP_ROWS);
|
|
24027
|
+
state.pixelStorei(_gl.UNPACK_ROW_LENGTH, image.width);
|
|
23869
24028
|
for (let i = 0, l = updateRanges.length; i < l; i++) {
|
|
23870
24029
|
const range = updateRanges[i];
|
|
23871
24030
|
const pixelStart = Math.floor(range.start / componentStride);
|
|
@@ -23874,14 +24033,14 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
23874
24033
|
const y = Math.floor(pixelStart / image.width);
|
|
23875
24034
|
const width = pixelCount;
|
|
23876
24035
|
const height = 1;
|
|
23877
|
-
|
|
23878
|
-
|
|
24036
|
+
state.pixelStorei(_gl.UNPACK_SKIP_PIXELS, x);
|
|
24037
|
+
state.pixelStorei(_gl.UNPACK_SKIP_ROWS, y);
|
|
23879
24038
|
state.texSubImage2D(_gl.TEXTURE_2D, 0, x, y, width, height, glFormat, glType, image.data);
|
|
23880
24039
|
}
|
|
23881
24040
|
texture.clearUpdateRanges();
|
|
23882
|
-
|
|
23883
|
-
|
|
23884
|
-
|
|
24041
|
+
state.pixelStorei(_gl.UNPACK_ROW_LENGTH, currentUnpackRowLen);
|
|
24042
|
+
state.pixelStorei(_gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels);
|
|
24043
|
+
state.pixelStorei(_gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows);
|
|
23885
24044
|
}
|
|
23886
24045
|
}
|
|
23887
24046
|
function uploadTexture(textureProperties, texture, slot) {
|
|
@@ -23894,18 +24053,21 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
23894
24053
|
const sourceProperties = properties.get(source);
|
|
23895
24054
|
if (source.version !== sourceProperties.__version || forceUpload === true) {
|
|
23896
24055
|
state.activeTexture(_gl.TEXTURE0 + slot);
|
|
23897
|
-
const
|
|
23898
|
-
|
|
23899
|
-
|
|
23900
|
-
|
|
23901
|
-
|
|
23902
|
-
|
|
23903
|
-
|
|
24056
|
+
const isImageBitmap = typeof ImageBitmap !== "undefined" && texture.image instanceof ImageBitmap;
|
|
24057
|
+
if (isImageBitmap === false) {
|
|
24058
|
+
const workingPrimaries = ColorManagement.getPrimaries(ColorManagement.workingColorSpace);
|
|
24059
|
+
const texturePrimaries = texture.colorSpace === NoColorSpace ? null : ColorManagement.getPrimaries(texture.colorSpace);
|
|
24060
|
+
const unpackConversion = texture.colorSpace === NoColorSpace || workingPrimaries === texturePrimaries ? _gl.NONE : _gl.BROWSER_DEFAULT_WEBGL;
|
|
24061
|
+
state.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, texture.flipY);
|
|
24062
|
+
state.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha);
|
|
24063
|
+
state.pixelStorei(_gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion);
|
|
24064
|
+
}
|
|
24065
|
+
state.pixelStorei(_gl.UNPACK_ALIGNMENT, texture.unpackAlignment);
|
|
23904
24066
|
let image = resizeImage(texture.image, false, capabilities.maxTextureSize);
|
|
23905
24067
|
image = verifyColorSpace(texture, image);
|
|
23906
24068
|
const glFormat = utils.convert(texture.format, texture.colorSpace);
|
|
23907
24069
|
const glType = utils.convert(texture.type);
|
|
23908
|
-
let glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.colorSpace, texture.isVideoTexture);
|
|
24070
|
+
let glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.normalized, texture.colorSpace, texture.isVideoTexture);
|
|
23909
24071
|
setTextureParameters(textureType, texture);
|
|
23910
24072
|
let mipmap;
|
|
23911
24073
|
const mipmaps = texture.mipmaps;
|
|
@@ -24067,6 +24229,35 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
24067
24229
|
}
|
|
24068
24230
|
}
|
|
24069
24231
|
}
|
|
24232
|
+
} else if (texture.isHTMLTexture) {
|
|
24233
|
+
if ("texElementImage2D" in _gl) {
|
|
24234
|
+
const canvas = _gl.canvas;
|
|
24235
|
+
if (!canvas.hasAttribute("layoutsubtree")) {
|
|
24236
|
+
canvas.setAttribute("layoutsubtree", "true");
|
|
24237
|
+
}
|
|
24238
|
+
if (image.parentNode !== canvas) {
|
|
24239
|
+
canvas.appendChild(image);
|
|
24240
|
+
_htmlTextures.add(texture);
|
|
24241
|
+
canvas.onpaint = (event) => {
|
|
24242
|
+
const changed = event.changedElements;
|
|
24243
|
+
for (const t of _htmlTextures) {
|
|
24244
|
+
if (changed.includes(t.image)) {
|
|
24245
|
+
t.needsUpdate = true;
|
|
24246
|
+
}
|
|
24247
|
+
}
|
|
24248
|
+
};
|
|
24249
|
+
canvas.requestPaint();
|
|
24250
|
+
return;
|
|
24251
|
+
}
|
|
24252
|
+
const level = 0;
|
|
24253
|
+
const internalFormat = _gl.RGBA;
|
|
24254
|
+
const srcFormat = _gl.RGBA;
|
|
24255
|
+
const srcType = _gl.UNSIGNED_BYTE;
|
|
24256
|
+
_gl.texElementImage2D(_gl.TEXTURE_2D, level, internalFormat, srcFormat, srcType, image);
|
|
24257
|
+
_gl.texParameteri(_gl.TEXTURE_2D, _gl.TEXTURE_MIN_FILTER, _gl.LINEAR);
|
|
24258
|
+
_gl.texParameteri(_gl.TEXTURE_2D, _gl.TEXTURE_WRAP_S, _gl.CLAMP_TO_EDGE);
|
|
24259
|
+
_gl.texParameteri(_gl.TEXTURE_2D, _gl.TEXTURE_WRAP_T, _gl.CLAMP_TO_EDGE);
|
|
24260
|
+
}
|
|
24070
24261
|
} else {
|
|
24071
24262
|
if (mipmaps.length > 0) {
|
|
24072
24263
|
if (useTexStorage && allocateMemory) {
|
|
@@ -24117,10 +24308,10 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
24117
24308
|
const workingPrimaries = ColorManagement.getPrimaries(ColorManagement.workingColorSpace);
|
|
24118
24309
|
const texturePrimaries = texture.colorSpace === NoColorSpace ? null : ColorManagement.getPrimaries(texture.colorSpace);
|
|
24119
24310
|
const unpackConversion = texture.colorSpace === NoColorSpace || workingPrimaries === texturePrimaries ? _gl.NONE : _gl.BROWSER_DEFAULT_WEBGL;
|
|
24120
|
-
|
|
24121
|
-
|
|
24122
|
-
|
|
24123
|
-
|
|
24311
|
+
state.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, texture.flipY);
|
|
24312
|
+
state.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha);
|
|
24313
|
+
state.pixelStorei(_gl.UNPACK_ALIGNMENT, texture.unpackAlignment);
|
|
24314
|
+
state.pixelStorei(_gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion);
|
|
24124
24315
|
const isCompressed = texture.isCompressedTexture || texture.image[0].isCompressedTexture;
|
|
24125
24316
|
const isDataTexture = texture.image[0] && texture.image[0].isDataTexture;
|
|
24126
24317
|
const cubeImage = [];
|
|
@@ -24132,7 +24323,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
24132
24323
|
}
|
|
24133
24324
|
cubeImage[i] = verifyColorSpace(texture, cubeImage[i]);
|
|
24134
24325
|
}
|
|
24135
|
-
const image = cubeImage[0], glFormat = utils.convert(texture.format, texture.colorSpace), glType = utils.convert(texture.type), glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.colorSpace);
|
|
24326
|
+
const image = cubeImage[0], glFormat = utils.convert(texture.format, texture.colorSpace), glType = utils.convert(texture.type), glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.normalized, texture.colorSpace);
|
|
24136
24327
|
const useTexStorage = texture.isVideoTexture !== true;
|
|
24137
24328
|
const allocateMemory = sourceProperties.__version === void 0 || forceUpload === true;
|
|
24138
24329
|
const dataReady = source.dataReady;
|
|
@@ -24229,7 +24420,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
24229
24420
|
function setupFrameBufferTexture(framebuffer, renderTarget, texture, attachment, textureTarget, level) {
|
|
24230
24421
|
const glFormat = utils.convert(texture.format, texture.colorSpace);
|
|
24231
24422
|
const glType = utils.convert(texture.type);
|
|
24232
|
-
const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.colorSpace);
|
|
24423
|
+
const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.normalized, texture.colorSpace);
|
|
24233
24424
|
const renderTargetProperties = properties.get(renderTarget);
|
|
24234
24425
|
const textureProperties = properties.get(texture);
|
|
24235
24426
|
textureProperties.__renderTarget = renderTarget;
|
|
@@ -24271,7 +24462,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
24271
24462
|
const texture = textures[i];
|
|
24272
24463
|
const glFormat = utils.convert(texture.format, texture.colorSpace);
|
|
24273
24464
|
const glType = utils.convert(texture.type);
|
|
24274
|
-
const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.colorSpace);
|
|
24465
|
+
const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.normalized, texture.colorSpace);
|
|
24275
24466
|
if (useMultisampledRTT(renderTarget)) {
|
|
24276
24467
|
multisampledRTTExt.renderbufferStorageMultisampleEXT(_gl.RENDERBUFFER, getRenderTargetSamples(renderTarget), glInternalFormat, renderTarget.width, renderTarget.height);
|
|
24277
24468
|
} else if (useMultisample) {
|
|
@@ -24471,7 +24662,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
24471
24662
|
_gl.bindRenderbuffer(_gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[i]);
|
|
24472
24663
|
const glFormat = utils.convert(texture2.format, texture2.colorSpace);
|
|
24473
24664
|
const glType = utils.convert(texture2.type);
|
|
24474
|
-
const glInternalFormat = getInternalFormat(texture2.internalFormat, glFormat, glType, texture2.colorSpace, renderTarget.isXRRenderTarget === true);
|
|
24665
|
+
const glInternalFormat = getInternalFormat(texture2.internalFormat, glFormat, glType, texture2.normalized, texture2.colorSpace, renderTarget.isXRRenderTarget === true);
|
|
24475
24666
|
const samples = getRenderTargetSamples(renderTarget);
|
|
24476
24667
|
_gl.renderbufferStorageMultisample(_gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height);
|
|
24477
24668
|
_gl.framebufferRenderbuffer(_gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[i]);
|
|
@@ -24667,6 +24858,8 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
24667
24858
|
}
|
|
24668
24859
|
this.allocateTextureUnit = allocateTextureUnit;
|
|
24669
24860
|
this.resetTextureUnits = resetTextureUnits;
|
|
24861
|
+
this.getTextureUnits = getTextureUnits;
|
|
24862
|
+
this.setTextureUnits = setTextureUnits;
|
|
24670
24863
|
this.setTexture2D = setTexture2D;
|
|
24671
24864
|
this.setTexture2DArray = setTexture2DArray;
|
|
24672
24865
|
this.setTexture3D = setTexture3D;
|
|
@@ -25387,8 +25580,9 @@ var WebXRManager = class extends EventDispatcher {
|
|
|
25387
25580
|
};
|
|
25388
25581
|
}
|
|
25389
25582
|
};
|
|
25390
|
-
var _e1 = /* @__PURE__ */ new Euler();
|
|
25391
25583
|
var _m12 = /* @__PURE__ */ new Matrix4();
|
|
25584
|
+
var _m = /* @__PURE__ */ new Matrix3();
|
|
25585
|
+
_m.set(-1, 0, 0, 0, 1, 0, 0, 0, 1);
|
|
25392
25586
|
function WebGLMaterials(renderer, properties) {
|
|
25393
25587
|
function refreshTransformUniform(map, uniform) {
|
|
25394
25588
|
if (map.matrixAutoUpdate === true) {
|
|
@@ -25406,7 +25600,9 @@ function WebGLMaterials(renderer, properties) {
|
|
|
25406
25600
|
}
|
|
25407
25601
|
}
|
|
25408
25602
|
function refreshMaterialUniforms(uniforms, material, pixelRatio, height, transmissionRenderTarget) {
|
|
25409
|
-
if (material.
|
|
25603
|
+
if (material.isNodeMaterial) {
|
|
25604
|
+
material.uniformsNeedUpdate = false;
|
|
25605
|
+
} else if (material.isMeshBasicMaterial) {
|
|
25410
25606
|
refreshUniformsCommon(uniforms, material);
|
|
25411
25607
|
} else if (material.isMeshLambertMaterial) {
|
|
25412
25608
|
refreshUniformsCommon(uniforms, material);
|
|
@@ -25508,16 +25704,10 @@ function WebGLMaterials(renderer, properties) {
|
|
|
25508
25704
|
const envMapRotation = materialProperties.envMapRotation;
|
|
25509
25705
|
if (envMap) {
|
|
25510
25706
|
uniforms.envMap.value = envMap;
|
|
25511
|
-
|
|
25512
|
-
_e1.x *= -1;
|
|
25513
|
-
_e1.y *= -1;
|
|
25514
|
-
_e1.z *= -1;
|
|
25707
|
+
uniforms.envMapRotation.value.setFromMatrix4(_m12.makeRotationFromEuler(envMapRotation)).transpose();
|
|
25515
25708
|
if (envMap.isCubeTexture && envMap.isRenderTargetTexture === false) {
|
|
25516
|
-
|
|
25517
|
-
_e1.z *= -1;
|
|
25709
|
+
uniforms.envMapRotation.value.premultiply(_m);
|
|
25518
25710
|
}
|
|
25519
|
-
uniforms.envMapRotation.value.setFromMatrix4(_m12.makeRotationFromEuler(_e1));
|
|
25520
|
-
uniforms.flipEnvMap.value = envMap.isCubeTexture && envMap.isRenderTargetTexture === false ? -1 : 1;
|
|
25521
25711
|
uniforms.reflectivity.value = material.reflectivity;
|
|
25522
25712
|
uniforms.ior.value = material.ior;
|
|
25523
25713
|
uniforms.refractionRatio.value = material.refractionRatio;
|
|
@@ -25783,6 +25973,8 @@ function WebGLUniformsGroups(gl, info, capabilities, state) {
|
|
|
25783
25973
|
uniform.__data[9] = value.elements[7];
|
|
25784
25974
|
uniform.__data[10] = value.elements[8];
|
|
25785
25975
|
uniform.__data[11] = 0;
|
|
25976
|
+
} else if (ArrayBuffer.isView(value)) {
|
|
25977
|
+
uniform.__data.set(new value.constructor(value.buffer, value.byteOffset, uniform.__data.length));
|
|
25786
25978
|
} else {
|
|
25787
25979
|
value.toArray(uniform.__data, arrayOffset);
|
|
25788
25980
|
arrayOffset += info2.storage / Float32Array.BYTES_PER_ELEMENT;
|
|
@@ -25800,6 +25992,8 @@ function WebGLUniformsGroups(gl, info, capabilities, state) {
|
|
|
25800
25992
|
if (cache[indexString] === void 0) {
|
|
25801
25993
|
if (typeof value === "number" || typeof value === "boolean") {
|
|
25802
25994
|
cache[indexString] = value;
|
|
25995
|
+
} else if (ArrayBuffer.isView(value)) {
|
|
25996
|
+
cache[indexString] = value.slice();
|
|
25803
25997
|
} else {
|
|
25804
25998
|
cache[indexString] = value.clone();
|
|
25805
25999
|
}
|
|
@@ -25811,6 +26005,8 @@ function WebGLUniformsGroups(gl, info, capabilities, state) {
|
|
|
25811
26005
|
cache[indexString] = value;
|
|
25812
26006
|
return true;
|
|
25813
26007
|
}
|
|
26008
|
+
} else if (ArrayBuffer.isView(value)) {
|
|
26009
|
+
return true;
|
|
25814
26010
|
} else {
|
|
25815
26011
|
if (cachedObject.equals(value) === false) {
|
|
25816
26012
|
cachedObject.copy(value);
|
|
@@ -25878,6 +26074,9 @@ function WebGLUniformsGroups(gl, info, capabilities, state) {
|
|
|
25878
26074
|
info2.storage = 64;
|
|
25879
26075
|
} else if (value.isTexture) {
|
|
25880
26076
|
warn("WebGLRenderer: Texture samplers can not be part of an uniforms group.");
|
|
26077
|
+
} else if (ArrayBuffer.isView(value)) {
|
|
26078
|
+
info2.boundary = 16;
|
|
26079
|
+
info2.storage = value.byteLength;
|
|
25881
26080
|
} else {
|
|
25882
26081
|
warn("WebGLRenderer: Unsupported uniform value type.", value);
|
|
25883
26082
|
}
|
|
@@ -26481,6 +26680,7 @@ var WebGLRenderer = class {
|
|
|
26481
26680
|
]);
|
|
26482
26681
|
const uintClearColor = new Uint32Array(4);
|
|
26483
26682
|
const intClearColor = new Int32Array(4);
|
|
26683
|
+
const objectPosition = new Vector3();
|
|
26484
26684
|
let currentRenderList = null;
|
|
26485
26685
|
let currentRenderState = null;
|
|
26486
26686
|
const renderListStack = [];
|
|
@@ -26511,6 +26711,7 @@ var WebGLRenderer = class {
|
|
|
26511
26711
|
this.transmissionResolutionScale = 1;
|
|
26512
26712
|
const _this = this;
|
|
26513
26713
|
let _isContextLost = false;
|
|
26714
|
+
let _nodesHandler = null;
|
|
26514
26715
|
this._outputColorSpace = SRGBColorSpace;
|
|
26515
26716
|
let _currentActiveCubeFace = 0;
|
|
26516
26717
|
let _currentActiveMipmapLevel = 0;
|
|
@@ -26679,13 +26880,13 @@ var WebGLRenderer = class {
|
|
|
26679
26880
|
};
|
|
26680
26881
|
this.setEffects = function(effects) {
|
|
26681
26882
|
if (_outputBufferType === UnsignedByteType) {
|
|
26682
|
-
|
|
26883
|
+
error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");
|
|
26683
26884
|
return;
|
|
26684
26885
|
}
|
|
26685
26886
|
if (effects) {
|
|
26686
26887
|
for (let i = 0; i < effects.length; i++) {
|
|
26687
26888
|
if (effects[i].isOutputPass === true) {
|
|
26688
|
-
|
|
26889
|
+
warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");
|
|
26689
26890
|
break;
|
|
26690
26891
|
}
|
|
26691
26892
|
}
|
|
@@ -26776,6 +26977,7 @@ var WebGLRenderer = class {
|
|
|
26776
26977
|
}
|
|
26777
26978
|
if (depth2) {
|
|
26778
26979
|
bits |= _gl.DEPTH_BUFFER_BIT;
|
|
26980
|
+
this.state.buffers.depth.setMask(true);
|
|
26779
26981
|
}
|
|
26780
26982
|
if (stencil2) {
|
|
26781
26983
|
bits |= _gl.STENCIL_BUFFER_BIT;
|
|
@@ -26794,6 +26996,10 @@ var WebGLRenderer = class {
|
|
|
26794
26996
|
this.clearStencil = function() {
|
|
26795
26997
|
this.clear(false, false, true);
|
|
26796
26998
|
};
|
|
26999
|
+
this.setNodesHandler = function(nodesHandler) {
|
|
27000
|
+
nodesHandler.setRenderer(this);
|
|
27001
|
+
_nodesHandler = nodesHandler;
|
|
27002
|
+
};
|
|
26797
27003
|
this.dispose = function() {
|
|
26798
27004
|
canvas.removeEventListener("webglcontextlost", onContextLost, false);
|
|
26799
27005
|
canvas.removeEventListener("webglcontextrestored", onContextRestore, false);
|
|
@@ -26916,23 +27122,18 @@ var WebGLRenderer = class {
|
|
|
26916
27122
|
renderer.setMode(_gl.TRIANGLES);
|
|
26917
27123
|
}
|
|
26918
27124
|
if (object.isBatchedMesh) {
|
|
26919
|
-
if (
|
|
26920
|
-
|
|
26921
|
-
|
|
26922
|
-
|
|
26923
|
-
|
|
26924
|
-
|
|
26925
|
-
|
|
26926
|
-
|
|
26927
|
-
|
|
26928
|
-
const uniforms = properties.get(material).currentProgram.getUniforms();
|
|
26929
|
-
for (let i = 0; i < drawCount2; i++) {
|
|
26930
|
-
uniforms.setValue(_gl, "_gl_DrawID", i);
|
|
26931
|
-
renderer.render(starts[i] / bytesPerElement, counts[i]);
|
|
26932
|
-
}
|
|
26933
|
-
} else {
|
|
26934
|
-
renderer.renderMultiDraw(object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount);
|
|
27125
|
+
if (!extensions.get("WEBGL_multi_draw")) {
|
|
27126
|
+
const starts = object._multiDrawStarts;
|
|
27127
|
+
const counts = object._multiDrawCounts;
|
|
27128
|
+
const drawCount2 = object._multiDrawCount;
|
|
27129
|
+
const bytesPerElement = index ? attributes.get(index).bytesPerElement : 1;
|
|
27130
|
+
const uniforms = properties.get(material).currentProgram.getUniforms();
|
|
27131
|
+
for (let i = 0; i < drawCount2; i++) {
|
|
27132
|
+
uniforms.setValue(_gl, "_gl_DrawID", i);
|
|
27133
|
+
renderer.render(starts[i] / bytesPerElement, counts[i]);
|
|
26935
27134
|
}
|
|
27135
|
+
} else {
|
|
27136
|
+
renderer.renderMultiDraw(object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount);
|
|
26936
27137
|
}
|
|
26937
27138
|
} else if (object.isInstancedMesh) {
|
|
26938
27139
|
renderer.renderInstances(drawStart, drawCount, object.count);
|
|
@@ -27053,6 +27254,9 @@ var WebGLRenderer = class {
|
|
|
27053
27254
|
return;
|
|
27054
27255
|
}
|
|
27055
27256
|
if (_isContextLost === true) return;
|
|
27257
|
+
if (_nodesHandler !== null) {
|
|
27258
|
+
_nodesHandler.renderStart(scene, camera);
|
|
27259
|
+
}
|
|
27056
27260
|
const isXRPresenting = xr.enabled === true && xr.isPresenting === true;
|
|
27057
27261
|
const useOutput = output !== null && (_currentRenderTarget === null || isXRPresenting) && output.begin(_this, _currentRenderTarget);
|
|
27058
27262
|
if (scene.matrixWorldAutoUpdate === true) scene.updateMatrixWorld();
|
|
@@ -27064,6 +27268,7 @@ var WebGLRenderer = class {
|
|
|
27064
27268
|
if (scene.isScene === true) scene.onBeforeRender(_this, scene, camera, _currentRenderTarget);
|
|
27065
27269
|
currentRenderState = renderStates.get(scene, renderStateStack.length);
|
|
27066
27270
|
currentRenderState.init(camera);
|
|
27271
|
+
currentRenderState.state.textureUnits = textures.getTextureUnits();
|
|
27067
27272
|
renderStateStack.push(currentRenderState);
|
|
27068
27273
|
_projScreenMatrix3.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
|
|
27069
27274
|
_frustum.setFromProjectionMatrix(_projScreenMatrix3, WebGLCoordinateSystem, camera.reversedDepth);
|
|
@@ -27131,6 +27336,7 @@ var WebGLRenderer = class {
|
|
|
27131
27336
|
renderStateStack.pop();
|
|
27132
27337
|
if (renderStateStack.length > 0) {
|
|
27133
27338
|
currentRenderState = renderStateStack[renderStateStack.length - 1];
|
|
27339
|
+
textures.setTextureUnits(currentRenderState.state.textureUnits);
|
|
27134
27340
|
if (_clippingEnabled === true) clipping.setGlobalState(_this.clippingPlanes, currentRenderState.state.camera);
|
|
27135
27341
|
} else {
|
|
27136
27342
|
currentRenderState = null;
|
|
@@ -27141,6 +27347,9 @@ var WebGLRenderer = class {
|
|
|
27141
27347
|
} else {
|
|
27142
27348
|
currentRenderList = null;
|
|
27143
27349
|
}
|
|
27350
|
+
if (_nodesHandler !== null) {
|
|
27351
|
+
_nodesHandler.renderEnd();
|
|
27352
|
+
}
|
|
27144
27353
|
};
|
|
27145
27354
|
function projectObject(object, camera, groupOrder, sortObjects) {
|
|
27146
27355
|
if (object.visible === false) return;
|
|
@@ -27150,6 +27359,8 @@ var WebGLRenderer = class {
|
|
|
27150
27359
|
groupOrder = object.renderOrder;
|
|
27151
27360
|
} else if (object.isLOD) {
|
|
27152
27361
|
if (object.autoUpdate === true) object.update(camera);
|
|
27362
|
+
} else if (object.isLightProbeGrid) {
|
|
27363
|
+
currentRenderState.pushLightProbeGrid(object);
|
|
27153
27364
|
} else if (object.isLight) {
|
|
27154
27365
|
currentRenderState.pushLight(object);
|
|
27155
27366
|
if (object.castShadow) {
|
|
@@ -27316,7 +27527,7 @@ var WebGLRenderer = class {
|
|
|
27316
27527
|
const lights = currentRenderState.state.lights;
|
|
27317
27528
|
const shadowsArray = currentRenderState.state.shadowsArray;
|
|
27318
27529
|
const lightsStateVersion = lights.state.version;
|
|
27319
|
-
const parameters2 = programCache.getParameters(material, lights.state, shadowsArray, scene, object);
|
|
27530
|
+
const parameters2 = programCache.getParameters(material, lights.state, shadowsArray, scene, object, currentRenderState.state.lightProbeGridArray);
|
|
27320
27531
|
const programCacheKey = programCache.getProgramCacheKey(parameters2);
|
|
27321
27532
|
let programs = materialProperties.programs;
|
|
27322
27533
|
materialProperties.environment = material.isMeshStandardMaterial || material.isMeshLambertMaterial || material.isMeshPhongMaterial ? scene.environment : null;
|
|
@@ -27337,6 +27548,9 @@ var WebGLRenderer = class {
|
|
|
27337
27548
|
}
|
|
27338
27549
|
} else {
|
|
27339
27550
|
parameters2.uniforms = programCache.getUniforms(material);
|
|
27551
|
+
if (_nodesHandler !== null && material.isNodeMaterial) {
|
|
27552
|
+
_nodesHandler.build(material, object, parameters2);
|
|
27553
|
+
}
|
|
27340
27554
|
material.onBeforeCompile(parameters2, _this);
|
|
27341
27555
|
program = programCache.acquireProgram(parameters2, programCacheKey);
|
|
27342
27556
|
programs.set(programCacheKey, program);
|
|
@@ -27367,6 +27581,7 @@ var WebGLRenderer = class {
|
|
|
27367
27581
|
uniforms.spotLightMap.value = lights.state.spotLightMap;
|
|
27368
27582
|
uniforms.pointShadowMatrix.value = lights.state.pointShadowMatrix;
|
|
27369
27583
|
}
|
|
27584
|
+
materialProperties.lightProbeGrid = currentRenderState.state.lightProbeGridArray.length > 0;
|
|
27370
27585
|
materialProperties.currentProgram = program;
|
|
27371
27586
|
materialProperties.uniformsList = null;
|
|
27372
27587
|
return program;
|
|
@@ -27397,12 +27612,24 @@ var WebGLRenderer = class {
|
|
|
27397
27612
|
materialProperties.vertexTangents = parameters2.vertexTangents;
|
|
27398
27613
|
materialProperties.toneMapping = parameters2.toneMapping;
|
|
27399
27614
|
}
|
|
27615
|
+
function findLightProbeGrid(volumes, object) {
|
|
27616
|
+
if (volumes.length === 0) return null;
|
|
27617
|
+
if (volumes.length === 1) {
|
|
27618
|
+
return volumes[0].texture !== null ? volumes[0] : null;
|
|
27619
|
+
}
|
|
27620
|
+
objectPosition.setFromMatrixPosition(object.matrixWorld);
|
|
27621
|
+
for (let i = 0, l = volumes.length; i < l; i++) {
|
|
27622
|
+
const v = volumes[i];
|
|
27623
|
+
if (v.texture !== null && v.boundingBox.containsPoint(objectPosition)) return v;
|
|
27624
|
+
}
|
|
27625
|
+
return null;
|
|
27626
|
+
}
|
|
27400
27627
|
function setProgram(camera, scene, geometry, material, object) {
|
|
27401
27628
|
if (scene.isScene !== true) scene = _emptyScene;
|
|
27402
27629
|
textures.resetTextureUnits();
|
|
27403
27630
|
const fog = scene.fog;
|
|
27404
27631
|
const environment = material.isMeshStandardMaterial || material.isMeshLambertMaterial || material.isMeshPhongMaterial ? scene.environment : null;
|
|
27405
|
-
const colorSpace = _currentRenderTarget === null ? _this.outputColorSpace : _currentRenderTarget.isXRRenderTarget === true ? _currentRenderTarget.texture.colorSpace :
|
|
27632
|
+
const colorSpace = _currentRenderTarget === null ? _this.outputColorSpace : _currentRenderTarget.isXRRenderTarget === true ? _currentRenderTarget.texture.colorSpace : ColorManagement.workingColorSpace;
|
|
27406
27633
|
const usePMREM = material.isMeshStandardMaterial || material.isMeshLambertMaterial && !material.envMap || material.isMeshPhongMaterial && !material.envMap;
|
|
27407
27634
|
const envMap = environments.get(material.envMap || environment, usePMREM);
|
|
27408
27635
|
const vertexAlphas = material.vertexColors === true && !!geometry.attributes.color && geometry.attributes.color.itemSize === 4;
|
|
@@ -27476,6 +27703,8 @@ var WebGLRenderer = class {
|
|
|
27476
27703
|
needsProgramChange = true;
|
|
27477
27704
|
} else if (materialProperties.morphTargetsCount !== morphTargetsCount) {
|
|
27478
27705
|
needsProgramChange = true;
|
|
27706
|
+
} else if (!!materialProperties.lightProbeGrid !== currentRenderState.state.lightProbeGridArray.length > 0) {
|
|
27707
|
+
needsProgramChange = true;
|
|
27479
27708
|
}
|
|
27480
27709
|
} else {
|
|
27481
27710
|
needsProgramChange = true;
|
|
@@ -27484,6 +27713,9 @@ var WebGLRenderer = class {
|
|
|
27484
27713
|
let program = materialProperties.currentProgram;
|
|
27485
27714
|
if (needsProgramChange === true) {
|
|
27486
27715
|
program = getProgram(material, scene, object);
|
|
27716
|
+
if (_nodesHandler && material.isNodeMaterial) {
|
|
27717
|
+
_nodesHandler.onUpdateProgram(material, program, materialProperties);
|
|
27718
|
+
}
|
|
27487
27719
|
}
|
|
27488
27720
|
let refreshProgram = false;
|
|
27489
27721
|
let refreshMaterial = false;
|
|
@@ -27498,6 +27730,13 @@ var WebGLRenderer = class {
|
|
|
27498
27730
|
_currentMaterialId = material.id;
|
|
27499
27731
|
refreshMaterial = true;
|
|
27500
27732
|
}
|
|
27733
|
+
if (materialProperties.needsLights) {
|
|
27734
|
+
const objectVolume = findLightProbeGrid(currentRenderState.state.lightProbeGridArray, object);
|
|
27735
|
+
if (materialProperties.lightProbeGrid !== objectVolume) {
|
|
27736
|
+
materialProperties.lightProbeGrid = objectVolume;
|
|
27737
|
+
refreshMaterial = true;
|
|
27738
|
+
}
|
|
27739
|
+
}
|
|
27501
27740
|
if (refreshProgram || _currentCamera !== camera) {
|
|
27502
27741
|
const reversedDepthBuffer2 = state.buffers.depth.getReversed();
|
|
27503
27742
|
if (reversedDepthBuffer2 && camera.reversedDepth !== true) {
|
|
@@ -27579,6 +27818,13 @@ var WebGLRenderer = class {
|
|
|
27579
27818
|
materials.refreshFogUniforms(m_uniforms, fog);
|
|
27580
27819
|
}
|
|
27581
27820
|
materials.refreshMaterialUniforms(m_uniforms, material, _pixelRatio, _height, currentRenderState.state.transmissionRenderTarget[camera.id]);
|
|
27821
|
+
if (materialProperties.needsLights && materialProperties.lightProbeGrid) {
|
|
27822
|
+
const volume = materialProperties.lightProbeGrid;
|
|
27823
|
+
m_uniforms.probesSH.value = volume.texture;
|
|
27824
|
+
m_uniforms.probesMin.value.copy(volume.boundingBox.min);
|
|
27825
|
+
m_uniforms.probesMax.value.copy(volume.boundingBox.max);
|
|
27826
|
+
m_uniforms.probesResolution.value.copy(volume.resolution);
|
|
27827
|
+
}
|
|
27582
27828
|
WebGLUniforms.upload(_gl, getUniformList(materialProperties), m_uniforms, textures);
|
|
27583
27829
|
}
|
|
27584
27830
|
if (material.isShaderMaterial && material.uniformsNeedUpdate === true) {
|
|
@@ -27591,7 +27837,7 @@ var WebGLRenderer = class {
|
|
|
27591
27837
|
p_uniforms.setValue(_gl, "modelViewMatrix", object.modelViewMatrix);
|
|
27592
27838
|
p_uniforms.setValue(_gl, "normalMatrix", object.normalMatrix);
|
|
27593
27839
|
p_uniforms.setValue(_gl, "modelMatrix", object.matrixWorld);
|
|
27594
|
-
if (material.
|
|
27840
|
+
if (material.uniformsGroups !== void 0) {
|
|
27595
27841
|
const groups = material.uniformsGroups;
|
|
27596
27842
|
for (let i = 0, l = groups.length; i < l; i++) {
|
|
27597
27843
|
const group = groups[i];
|
|
@@ -27860,19 +28106,20 @@ var WebGLRenderer = class {
|
|
|
27860
28106
|
textures.setTexture2D(dstTexture, 0);
|
|
27861
28107
|
glTarget = _gl.TEXTURE_2D;
|
|
27862
28108
|
}
|
|
27863
|
-
|
|
27864
|
-
|
|
27865
|
-
|
|
27866
|
-
|
|
27867
|
-
const
|
|
27868
|
-
const
|
|
27869
|
-
const
|
|
27870
|
-
const
|
|
27871
|
-
|
|
27872
|
-
|
|
27873
|
-
|
|
27874
|
-
|
|
27875
|
-
|
|
28109
|
+
state.activeTexture(_gl.TEXTURE0);
|
|
28110
|
+
state.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY);
|
|
28111
|
+
state.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha);
|
|
28112
|
+
state.pixelStorei(_gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment);
|
|
28113
|
+
const currentUnpackRowLen = state.getParameter(_gl.UNPACK_ROW_LENGTH);
|
|
28114
|
+
const currentUnpackImageHeight = state.getParameter(_gl.UNPACK_IMAGE_HEIGHT);
|
|
28115
|
+
const currentUnpackSkipPixels = state.getParameter(_gl.UNPACK_SKIP_PIXELS);
|
|
28116
|
+
const currentUnpackSkipRows = state.getParameter(_gl.UNPACK_SKIP_ROWS);
|
|
28117
|
+
const currentUnpackSkipImages = state.getParameter(_gl.UNPACK_SKIP_IMAGES);
|
|
28118
|
+
state.pixelStorei(_gl.UNPACK_ROW_LENGTH, image.width);
|
|
28119
|
+
state.pixelStorei(_gl.UNPACK_IMAGE_HEIGHT, image.height);
|
|
28120
|
+
state.pixelStorei(_gl.UNPACK_SKIP_PIXELS, minX);
|
|
28121
|
+
state.pixelStorei(_gl.UNPACK_SKIP_ROWS, minY);
|
|
28122
|
+
state.pixelStorei(_gl.UNPACK_SKIP_IMAGES, minZ);
|
|
27876
28123
|
const isSrc3D = srcTexture.isDataArrayTexture || srcTexture.isData3DTexture;
|
|
27877
28124
|
const isDst3D = dstTexture.isDataArrayTexture || dstTexture.isData3DTexture;
|
|
27878
28125
|
if (srcTexture.isDepthTexture) {
|
|
@@ -27936,11 +28183,11 @@ var WebGLRenderer = class {
|
|
|
27936
28183
|
}
|
|
27937
28184
|
}
|
|
27938
28185
|
}
|
|
27939
|
-
|
|
27940
|
-
|
|
27941
|
-
|
|
27942
|
-
|
|
27943
|
-
|
|
28186
|
+
state.pixelStorei(_gl.UNPACK_ROW_LENGTH, currentUnpackRowLen);
|
|
28187
|
+
state.pixelStorei(_gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight);
|
|
28188
|
+
state.pixelStorei(_gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels);
|
|
28189
|
+
state.pixelStorei(_gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows);
|
|
28190
|
+
state.pixelStorei(_gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages);
|
|
27944
28191
|
if (dstLevel === 0 && dstTexture.generateMipmaps) {
|
|
27945
28192
|
_gl.generateMipmap(glTarget);
|
|
27946
28193
|
}
|
|
@@ -28145,7 +28392,7 @@ var OrbitControls = class extends Controls {
|
|
|
28145
28392
|
this.stopListenToKeyEvents();
|
|
28146
28393
|
const document2 = this.domElement.getRootNode();
|
|
28147
28394
|
document2.removeEventListener("keydown", this._interceptControlDown, { capture: true });
|
|
28148
|
-
this.domElement.style.touchAction = "
|
|
28395
|
+
this.domElement.style.touchAction = "";
|
|
28149
28396
|
}
|
|
28150
28397
|
dispose() {
|
|
28151
28398
|
this.disconnect();
|