@gjsify/example-dom-three-geometry-teapot 0.1.15 → 0.3.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 +1292 -478
- 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);
|
|
@@ -13121,7 +13149,7 @@ function cloneUniforms(src) {
|
|
|
13121
13149
|
dst[u] = {};
|
|
13122
13150
|
for (const p in src[u]) {
|
|
13123
13151
|
const property = src[u][p];
|
|
13124
|
-
if (
|
|
13152
|
+
if (isThreeObject(property)) {
|
|
13125
13153
|
if (property.isRenderTargetTexture) {
|
|
13126
13154
|
warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms().");
|
|
13127
13155
|
dst[u][p] = null;
|
|
@@ -13129,7 +13157,15 @@ function cloneUniforms(src) {
|
|
|
13129
13157
|
dst[u][p] = property.clone();
|
|
13130
13158
|
}
|
|
13131
13159
|
} else if (Array.isArray(property)) {
|
|
13132
|
-
|
|
13160
|
+
if (isThreeObject(property[0])) {
|
|
13161
|
+
const clonedProperty = [];
|
|
13162
|
+
for (let i = 0, l = property.length; i < l; i++) {
|
|
13163
|
+
clonedProperty[i] = property[i].clone();
|
|
13164
|
+
}
|
|
13165
|
+
dst[u][p] = clonedProperty;
|
|
13166
|
+
} else {
|
|
13167
|
+
dst[u][p] = property.slice();
|
|
13168
|
+
}
|
|
13133
13169
|
} else {
|
|
13134
13170
|
dst[u][p] = property;
|
|
13135
13171
|
}
|
|
@@ -13147,6 +13183,9 @@ function mergeUniforms(uniforms) {
|
|
|
13147
13183
|
}
|
|
13148
13184
|
return merged;
|
|
13149
13185
|
}
|
|
13186
|
+
function isThreeObject(property) {
|
|
13187
|
+
return property && (property.isColor || property.isMatrix3 || property.isMatrix4 || property.isVector2 || property.isVector3 || property.isVector4 || property.isTexture || property.isQuaternion);
|
|
13188
|
+
}
|
|
13150
13189
|
function cloneUniformsGroups(src) {
|
|
13151
13190
|
const dst = [];
|
|
13152
13191
|
for (let u = 0; u < src.length; u++) {
|
|
@@ -16098,6 +16137,77 @@ var Spherical = class {
|
|
|
16098
16137
|
return new this.constructor().copy(this);
|
|
16099
16138
|
}
|
|
16100
16139
|
};
|
|
16140
|
+
var Matrix2 = class _Matrix2 {
|
|
16141
|
+
static {
|
|
16142
|
+
_Matrix2.prototype.isMatrix2 = true;
|
|
16143
|
+
}
|
|
16144
|
+
/**
|
|
16145
|
+
* Constructs a new 2x2 matrix. The arguments are supposed to be
|
|
16146
|
+
* in row-major order. If no arguments are provided, the constructor
|
|
16147
|
+
* initializes the matrix as an identity matrix.
|
|
16148
|
+
*
|
|
16149
|
+
* @param {number} [n11] - 1-1 matrix element.
|
|
16150
|
+
* @param {number} [n12] - 1-2 matrix element.
|
|
16151
|
+
* @param {number} [n21] - 2-1 matrix element.
|
|
16152
|
+
* @param {number} [n22] - 2-2 matrix element.
|
|
16153
|
+
*/
|
|
16154
|
+
constructor(n11, n12, n21, n22) {
|
|
16155
|
+
this.elements = [
|
|
16156
|
+
1,
|
|
16157
|
+
0,
|
|
16158
|
+
0,
|
|
16159
|
+
1
|
|
16160
|
+
];
|
|
16161
|
+
if (n11 !== void 0) {
|
|
16162
|
+
this.set(n11, n12, n21, n22);
|
|
16163
|
+
}
|
|
16164
|
+
}
|
|
16165
|
+
/**
|
|
16166
|
+
* Sets this matrix to the 2x2 identity matrix.
|
|
16167
|
+
*
|
|
16168
|
+
* @return {Matrix2} A reference to this matrix.
|
|
16169
|
+
*/
|
|
16170
|
+
identity() {
|
|
16171
|
+
this.set(
|
|
16172
|
+
1,
|
|
16173
|
+
0,
|
|
16174
|
+
0,
|
|
16175
|
+
1
|
|
16176
|
+
);
|
|
16177
|
+
return this;
|
|
16178
|
+
}
|
|
16179
|
+
/**
|
|
16180
|
+
* Sets the elements of the matrix from the given array.
|
|
16181
|
+
*
|
|
16182
|
+
* @param {Array<number>} array - The matrix elements in column-major order.
|
|
16183
|
+
* @param {number} [offset=0] - Index of the first element in the array.
|
|
16184
|
+
* @return {Matrix2} A reference to this matrix.
|
|
16185
|
+
*/
|
|
16186
|
+
fromArray(array, offset = 0) {
|
|
16187
|
+
for (let i = 0; i < 4; i++) {
|
|
16188
|
+
this.elements[i] = array[i + offset];
|
|
16189
|
+
}
|
|
16190
|
+
return this;
|
|
16191
|
+
}
|
|
16192
|
+
/**
|
|
16193
|
+
* Sets the elements of the matrix.The arguments are supposed to be
|
|
16194
|
+
* in row-major order.
|
|
16195
|
+
*
|
|
16196
|
+
* @param {number} n11 - 1-1 matrix element.
|
|
16197
|
+
* @param {number} n12 - 1-2 matrix element.
|
|
16198
|
+
* @param {number} n21 - 2-1 matrix element.
|
|
16199
|
+
* @param {number} n22 - 2-2 matrix element.
|
|
16200
|
+
* @return {Matrix2} A reference to this matrix.
|
|
16201
|
+
*/
|
|
16202
|
+
set(n11, n12, n21, n22) {
|
|
16203
|
+
const te = this.elements;
|
|
16204
|
+
te[0] = n11;
|
|
16205
|
+
te[2] = n12;
|
|
16206
|
+
te[1] = n21;
|
|
16207
|
+
te[3] = n22;
|
|
16208
|
+
return this;
|
|
16209
|
+
}
|
|
16210
|
+
};
|
|
16101
16211
|
var Controls = class extends EventDispatcher {
|
|
16102
16212
|
/**
|
|
16103
16213
|
* Constructs a new controls instance.
|
|
@@ -16288,11 +16398,12 @@ function WebGLAnimation() {
|
|
|
16288
16398
|
start: function() {
|
|
16289
16399
|
if (isAnimating === true) return;
|
|
16290
16400
|
if (animationLoop === null) return;
|
|
16401
|
+
if (context === null) return;
|
|
16291
16402
|
requestId = context.requestAnimationFrame(onAnimationFrame);
|
|
16292
16403
|
isAnimating = true;
|
|
16293
16404
|
},
|
|
16294
16405
|
stop: function() {
|
|
16295
|
-
context.cancelAnimationFrame(requestId);
|
|
16406
|
+
if (context !== null) context.cancelAnimationFrame(requestId);
|
|
16296
16407
|
isAnimating = false;
|
|
16297
16408
|
},
|
|
16298
16409
|
setAnimationLoop: function(callback) {
|
|
@@ -16459,8 +16570,8 @@ var emissivemap_fragment = "#ifdef USE_EMISSIVEMAP\n vec4 emissiveColor = textur
|
|
|
16459
16570
|
var emissivemap_pars_fragment = "#ifdef USE_EMISSIVEMAP\n uniform sampler2D emissiveMap;\n#endif";
|
|
16460
16571
|
var colorspace_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );";
|
|
16461
16572
|
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}";
|
|
16462
|
-
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 *
|
|
16463
|
-
var envmap_common_pars_fragment = "#ifdef USE_ENVMAP\n uniform float envMapIntensity;\n uniform
|
|
16573
|
+
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";
|
|
16574
|
+
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";
|
|
16464
16575
|
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";
|
|
16465
16576
|
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";
|
|
16466
16577
|
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";
|
|
@@ -16472,17 +16583,18 @@ var gradientmap_pars_fragment = "#ifdef USE_GRADIENTMAP\n uniform sampler2D grad
|
|
|
16472
16583
|
var lightmap_pars_fragment = "#ifdef USE_LIGHTMAP\n uniform sampler2D lightMap;\n uniform float lightMapIntensity;\n#endif";
|
|
16473
16584
|
var lights_lambert_fragment = "LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;";
|
|
16474
16585
|
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";
|
|
16475
|
-
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";
|
|
16586
|
+
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>";
|
|
16476
16587
|
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";
|
|
16477
16588
|
var lights_toon_fragment = "ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;";
|
|
16478
16589
|
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";
|
|
16479
16590
|
var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;";
|
|
16480
16591
|
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";
|
|
16481
16592
|
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";
|
|
16482
|
-
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}";
|
|
16483
|
-
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";
|
|
16593
|
+
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}";
|
|
16594
|
+
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";
|
|
16484
16595
|
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";
|
|
16485
16596
|
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";
|
|
16597
|
+
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";
|
|
16486
16598
|
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";
|
|
16487
16599
|
var logdepthbuf_pars_fragment = "#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n uniform float logDepthBufFC;\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif";
|
|
16488
16600
|
var logdepthbuf_pars_vertex = "#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif";
|
|
@@ -16499,7 +16611,7 @@ var morphnormal_vertex = "#ifdef USE_MORPHNORMALS\n objectNormal *= morphTargetB
|
|
|
16499
16611
|
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";
|
|
16500
16612
|
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";
|
|
16501
16613
|
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;";
|
|
16502
|
-
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";
|
|
16614
|
+
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";
|
|
16503
16615
|
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";
|
|
16504
16616
|
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";
|
|
16505
16617
|
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";
|
|
@@ -16518,7 +16630,7 @@ var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUG
|
|
|
16518
16630
|
var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n uniform sampler2D roughnessMap;\n#endif";
|
|
16519
16631
|
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";
|
|
16520
16632
|
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";
|
|
16521
|
-
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";
|
|
16633
|
+
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";
|
|
16522
16634
|
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}";
|
|
16523
16635
|
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";
|
|
16524
16636
|
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";
|
|
@@ -16537,7 +16649,7 @@ var worldpos_vertex = "#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defin
|
|
|
16537
16649
|
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}";
|
|
16538
16650
|
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}";
|
|
16539
16651
|
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}";
|
|
16540
|
-
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
|
|
16652
|
+
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}";
|
|
16541
16653
|
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}";
|
|
16542
16654
|
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}";
|
|
16543
16655
|
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}";
|
|
@@ -16625,6 +16737,7 @@ var ShaderChunk = {
|
|
|
16625
16737
|
lights_fragment_begin,
|
|
16626
16738
|
lights_fragment_maps,
|
|
16627
16739
|
lights_fragment_end,
|
|
16740
|
+
lightprobes_pars_fragment,
|
|
16628
16741
|
logdepthbuf_fragment,
|
|
16629
16742
|
logdepthbuf_pars_fragment,
|
|
16630
16743
|
logdepthbuf_pars_vertex,
|
|
@@ -16728,7 +16841,6 @@ var UniformsLib = {
|
|
|
16728
16841
|
envmap: {
|
|
16729
16842
|
envMap: { value: null },
|
|
16730
16843
|
envMapRotation: { value: /* @__PURE__ */ new Matrix3() },
|
|
16731
|
-
flipEnvMap: { value: -1 },
|
|
16732
16844
|
reflectivity: { value: 1 },
|
|
16733
16845
|
// basic, lambert, phong
|
|
16734
16846
|
ior: { value: 1.5 },
|
|
@@ -16847,7 +16959,11 @@ var UniformsLib = {
|
|
|
16847
16959
|
height: {}
|
|
16848
16960
|
} },
|
|
16849
16961
|
ltc_1: { value: null },
|
|
16850
|
-
ltc_2: { value: null }
|
|
16962
|
+
ltc_2: { value: null },
|
|
16963
|
+
probesSH: { value: null },
|
|
16964
|
+
probesMin: { value: /* @__PURE__ */ new Vector3() },
|
|
16965
|
+
probesMax: { value: /* @__PURE__ */ new Vector3() },
|
|
16966
|
+
probesResolution: { value: /* @__PURE__ */ new Vector3() }
|
|
16851
16967
|
},
|
|
16852
16968
|
points: {
|
|
16853
16969
|
diffuse: { value: /* @__PURE__ */ new Color(16777215) },
|
|
@@ -17048,7 +17164,6 @@ var ShaderLib = {
|
|
|
17048
17164
|
backgroundCube: {
|
|
17049
17165
|
uniforms: {
|
|
17050
17166
|
envMap: { value: null },
|
|
17051
|
-
flipEnvMap: { value: -1 },
|
|
17052
17167
|
backgroundBlurriness: { value: 0 },
|
|
17053
17168
|
backgroundIntensity: { value: 1 },
|
|
17054
17169
|
backgroundRotation: { value: /* @__PURE__ */ new Matrix3() }
|
|
@@ -17152,8 +17267,9 @@ ShaderLib.physical = {
|
|
|
17152
17267
|
fragmentShader: ShaderChunk.meshphysical_frag
|
|
17153
17268
|
};
|
|
17154
17269
|
var _rgb = { r: 0, b: 0, g: 0 };
|
|
17155
|
-
var _e1$1 = /* @__PURE__ */ new Euler();
|
|
17156
17270
|
var _m1$12 = /* @__PURE__ */ new Matrix4();
|
|
17271
|
+
var _m$1 = /* @__PURE__ */ new Matrix3();
|
|
17272
|
+
_m$1.set(-1, 0, 0, 0, 1, 0, 0, 0, 1);
|
|
17157
17273
|
function WebGLBackground(renderer, environments, state, objects, alpha, premultipliedAlpha) {
|
|
17158
17274
|
const clearColor = new Color(0);
|
|
17159
17275
|
let clearAlpha = alpha === true ? 0 : 1;
|
|
@@ -17222,19 +17338,13 @@ function WebGLBackground(renderer, environments, state, objects, alpha, premulti
|
|
|
17222
17338
|
});
|
|
17223
17339
|
objects.update(boxMesh);
|
|
17224
17340
|
}
|
|
17225
|
-
_e1$1.copy(scene.backgroundRotation);
|
|
17226
|
-
_e1$1.x *= -1;
|
|
17227
|
-
_e1$1.y *= -1;
|
|
17228
|
-
_e1$1.z *= -1;
|
|
17229
|
-
if (background.isCubeTexture && background.isRenderTargetTexture === false) {
|
|
17230
|
-
_e1$1.y *= -1;
|
|
17231
|
-
_e1$1.z *= -1;
|
|
17232
|
-
}
|
|
17233
17341
|
boxMesh.material.uniforms.envMap.value = background;
|
|
17234
|
-
boxMesh.material.uniforms.flipEnvMap.value = background.isCubeTexture && background.isRenderTargetTexture === false ? -1 : 1;
|
|
17235
17342
|
boxMesh.material.uniforms.backgroundBlurriness.value = scene.backgroundBlurriness;
|
|
17236
17343
|
boxMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
|
|
17237
|
-
boxMesh.material.uniforms.backgroundRotation.value.setFromMatrix4(_m1$12.makeRotationFromEuler(
|
|
17344
|
+
boxMesh.material.uniforms.backgroundRotation.value.setFromMatrix4(_m1$12.makeRotationFromEuler(scene.backgroundRotation)).transpose();
|
|
17345
|
+
if (background.isCubeTexture && background.isRenderTargetTexture === false) {
|
|
17346
|
+
boxMesh.material.uniforms.backgroundRotation.value.premultiply(_m$1);
|
|
17347
|
+
}
|
|
17238
17348
|
boxMesh.material.toneMapped = ColorManagement.getTransfer(background.colorSpace) !== SRGBTransfer;
|
|
17239
17349
|
if (currentBackground !== background || currentBackgroundVersion !== background.version || currentTonemapping !== renderer.toneMapping) {
|
|
17240
17350
|
boxMesh.material.needsUpdate = true;
|
|
@@ -17710,27 +17820,10 @@ function WebGLBufferRenderer(gl, extensions, info) {
|
|
|
17710
17820
|
}
|
|
17711
17821
|
info.update(elementCount, mode, 1);
|
|
17712
17822
|
}
|
|
17713
|
-
function renderMultiDrawInstances(starts, counts, drawCount, primcount) {
|
|
17714
|
-
if (drawCount === 0) return;
|
|
17715
|
-
const extension = extensions.get("WEBGL_multi_draw");
|
|
17716
|
-
if (extension === null) {
|
|
17717
|
-
for (let i = 0; i < starts.length; i++) {
|
|
17718
|
-
renderInstances(starts[i], counts[i], primcount[i]);
|
|
17719
|
-
}
|
|
17720
|
-
} else {
|
|
17721
|
-
extension.multiDrawArraysInstancedWEBGL(mode, starts, 0, counts, 0, primcount, 0, drawCount);
|
|
17722
|
-
let elementCount = 0;
|
|
17723
|
-
for (let i = 0; i < drawCount; i++) {
|
|
17724
|
-
elementCount += counts[i] * primcount[i];
|
|
17725
|
-
}
|
|
17726
|
-
info.update(elementCount, mode, 1);
|
|
17727
|
-
}
|
|
17728
|
-
}
|
|
17729
17823
|
this.setMode = setMode;
|
|
17730
17824
|
this.render = render;
|
|
17731
17825
|
this.renderInstances = renderInstances;
|
|
17732
17826
|
this.renderMultiDraw = renderMultiDraw;
|
|
17733
|
-
this.renderMultiDrawInstances = renderMultiDrawInstances;
|
|
17734
17827
|
}
|
|
17735
17828
|
function WebGLCapabilities(gl, extensions, parameters, utils) {
|
|
17736
17829
|
let maxAnisotropy;
|
|
@@ -17780,6 +17873,9 @@ function WebGLCapabilities(gl, extensions, parameters, utils) {
|
|
|
17780
17873
|
}
|
|
17781
17874
|
const logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;
|
|
17782
17875
|
const reversedDepthBuffer = parameters.reversedDepthBuffer === true && extensions.has("EXT_clip_control");
|
|
17876
|
+
if (parameters.reversedDepthBuffer === true && reversedDepthBuffer === false) {
|
|
17877
|
+
warn("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");
|
|
17878
|
+
}
|
|
17783
17879
|
const maxTextures = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS);
|
|
17784
17880
|
const maxVertexTextures = gl.getParameter(gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
|
|
17785
17881
|
const maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);
|
|
@@ -19121,28 +19217,11 @@ function WebGLIndexedBufferRenderer(gl, extensions, info) {
|
|
|
19121
19217
|
}
|
|
19122
19218
|
info.update(elementCount, mode, 1);
|
|
19123
19219
|
}
|
|
19124
|
-
function renderMultiDrawInstances(starts, counts, drawCount, primcount) {
|
|
19125
|
-
if (drawCount === 0) return;
|
|
19126
|
-
const extension = extensions.get("WEBGL_multi_draw");
|
|
19127
|
-
if (extension === null) {
|
|
19128
|
-
for (let i = 0; i < starts.length; i++) {
|
|
19129
|
-
renderInstances(starts[i] / bytesPerElement, counts[i], primcount[i]);
|
|
19130
|
-
}
|
|
19131
|
-
} else {
|
|
19132
|
-
extension.multiDrawElementsInstancedWEBGL(mode, counts, 0, type, starts, 0, primcount, 0, drawCount);
|
|
19133
|
-
let elementCount = 0;
|
|
19134
|
-
for (let i = 0; i < drawCount; i++) {
|
|
19135
|
-
elementCount += counts[i] * primcount[i];
|
|
19136
|
-
}
|
|
19137
|
-
info.update(elementCount, mode, 1);
|
|
19138
|
-
}
|
|
19139
|
-
}
|
|
19140
19220
|
this.setMode = setMode;
|
|
19141
19221
|
this.setIndex = setIndex;
|
|
19142
19222
|
this.render = render;
|
|
19143
19223
|
this.renderInstances = renderInstances;
|
|
19144
19224
|
this.renderMultiDraw = renderMultiDraw;
|
|
19145
|
-
this.renderMultiDrawInstances = renderMultiDrawInstances;
|
|
19146
19225
|
}
|
|
19147
19226
|
function WebGLInfo(gl) {
|
|
19148
19227
|
const memory = {
|
|
@@ -19345,7 +19424,8 @@ function WebGLOutput(type, width, height, depth, stencil) {
|
|
|
19345
19424
|
const targetA = new WebGLRenderTarget(width, height, {
|
|
19346
19425
|
type,
|
|
19347
19426
|
depthBuffer: depth,
|
|
19348
|
-
stencilBuffer: stencil
|
|
19427
|
+
stencilBuffer: stencil,
|
|
19428
|
+
depthTexture: depth ? new DepthTexture(width, height) : void 0
|
|
19349
19429
|
});
|
|
19350
19430
|
const targetB = new WebGLRenderTarget(width, height, {
|
|
19351
19431
|
type: HalfFloatType,
|
|
@@ -19498,6 +19578,7 @@ function WebGLOutput(type, width, height, depth, stencil) {
|
|
|
19498
19578
|
return _isCompositing;
|
|
19499
19579
|
};
|
|
19500
19580
|
this.dispose = function() {
|
|
19581
|
+
if (targetA.depthTexture) targetA.depthTexture.dispose();
|
|
19501
19582
|
targetA.dispose();
|
|
19502
19583
|
targetB.dispose();
|
|
19503
19584
|
geometry.dispose();
|
|
@@ -20509,6 +20590,7 @@ function WebGLProgram(renderer, cacheKey, parameters, bindingStates) {
|
|
|
20509
20590
|
parameters.thicknessMapUv ? "#define THICKNESSMAP_UV " + parameters.thicknessMapUv : "",
|
|
20510
20591
|
//
|
|
20511
20592
|
parameters.vertexTangents && parameters.flatShading === false ? "#define USE_TANGENT" : "",
|
|
20593
|
+
parameters.vertexNormals ? "#define HAS_NORMAL" : "",
|
|
20512
20594
|
parameters.vertexColors ? "#define USE_COLOR" : "",
|
|
20513
20595
|
parameters.vertexAlphas ? "#define USE_COLOR_ALPHA" : "",
|
|
20514
20596
|
parameters.vertexUv1s ? "#define USE_UV1" : "",
|
|
@@ -20595,6 +20677,7 @@ function WebGLProgram(renderer, cacheKey, parameters, bindingStates) {
|
|
|
20595
20677
|
parameters.normalMap ? "#define USE_NORMALMAP" : "",
|
|
20596
20678
|
parameters.normalMapObjectSpace ? "#define USE_NORMALMAP_OBJECTSPACE" : "",
|
|
20597
20679
|
parameters.normalMapTangentSpace ? "#define USE_NORMALMAP_TANGENTSPACE" : "",
|
|
20680
|
+
parameters.packedNormalMap ? "#define USE_PACKED_NORMALMAP" : "",
|
|
20598
20681
|
parameters.emissiveMap ? "#define USE_EMISSIVEMAP" : "",
|
|
20599
20682
|
parameters.anisotropy ? "#define USE_ANISOTROPY" : "",
|
|
20600
20683
|
parameters.anisotropyMap ? "#define USE_ANISOTROPYMAP" : "",
|
|
@@ -20635,6 +20718,7 @@ function WebGLProgram(renderer, cacheKey, parameters, bindingStates) {
|
|
|
20635
20718
|
parameters.shadowMapEnabled ? "#define " + shadowMapTypeDefine : "",
|
|
20636
20719
|
parameters.premultipliedAlpha ? "#define PREMULTIPLIED_ALPHA" : "",
|
|
20637
20720
|
parameters.numLightProbes > 0 ? "#define USE_LIGHT_PROBES" : "",
|
|
20721
|
+
parameters.numLightProbeGrids > 0 ? "#define USE_LIGHT_PROBES_GRID" : "",
|
|
20638
20722
|
parameters.decodeVideoTexture ? "#define DECODE_VIDEO_TEXTURE" : "",
|
|
20639
20723
|
parameters.decodeVideoTextureEmissive ? "#define DECODE_VIDEO_TEXTURE_EMISSIVE" : "",
|
|
20640
20724
|
parameters.logarithmicDepthBuffer ? "#define USE_LOGARITHMIC_DEPTH_BUFFER" : "",
|
|
@@ -20849,6 +20933,9 @@ var WebGLShaderStage = class {
|
|
|
20849
20933
|
this.usedTimes = 0;
|
|
20850
20934
|
}
|
|
20851
20935
|
};
|
|
20936
|
+
function isPackedRGFormat(format) {
|
|
20937
|
+
return format === RGFormat || format === RG11_EAC_Format || format === RED_GREEN_RGTC2_Format;
|
|
20938
|
+
}
|
|
20852
20939
|
function WebGLPrograms(renderer, environments, extensions, capabilities, bindingStates, clipping) {
|
|
20853
20940
|
const _programLayers = new Layers();
|
|
20854
20941
|
const _customShaders = new WebGLShaderCache();
|
|
@@ -20879,7 +20966,7 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
|
|
|
20879
20966
|
if (value === 0) return "uv";
|
|
20880
20967
|
return `uv${value}`;
|
|
20881
20968
|
}
|
|
20882
|
-
function getParameters(material, lights, shadows, scene, object) {
|
|
20969
|
+
function getParameters(material, lights, shadows, scene, object, lightProbeGrids) {
|
|
20883
20970
|
const fog = scene.fog;
|
|
20884
20971
|
const geometry = object.geometry;
|
|
20885
20972
|
const environment = material.isMeshStandardMaterial || material.isMeshLambertMaterial || material.isMeshPhongMaterial ? scene.environment : null;
|
|
@@ -20974,7 +21061,7 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
|
|
|
20974
21061
|
instancing: IS_INSTANCEDMESH,
|
|
20975
21062
|
instancingColor: IS_INSTANCEDMESH && object.instanceColor !== null,
|
|
20976
21063
|
instancingMorph: IS_INSTANCEDMESH && object.morphTexture !== null,
|
|
20977
|
-
outputColorSpace: currentRenderTarget === null ? renderer.outputColorSpace : currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.colorSpace :
|
|
21064
|
+
outputColorSpace: currentRenderTarget === null ? renderer.outputColorSpace : currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.colorSpace : ColorManagement.workingColorSpace,
|
|
20978
21065
|
alphaToCoverage: !!material.alphaToCoverage,
|
|
20979
21066
|
map: HAS_MAP,
|
|
20980
21067
|
matcap: HAS_MATCAP,
|
|
@@ -20989,6 +21076,7 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
|
|
|
20989
21076
|
emissiveMap: HAS_EMISSIVEMAP,
|
|
20990
21077
|
normalMapObjectSpace: HAS_NORMALMAP && material.normalMapType === ObjectSpaceNormalMap,
|
|
20991
21078
|
normalMapTangentSpace: HAS_NORMALMAP && material.normalMapType === TangentSpaceNormalMap,
|
|
21079
|
+
packedNormalMap: HAS_NORMALMAP && material.normalMapType === TangentSpaceNormalMap && isPackedRGFormat(material.normalMap.format),
|
|
20992
21080
|
metalnessMap: HAS_METALNESSMAP,
|
|
20993
21081
|
roughnessMap: HAS_ROUGHNESSMAP,
|
|
20994
21082
|
anisotropy: HAS_ANISOTROPY,
|
|
@@ -21042,6 +21130,7 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
|
|
|
21042
21130
|
alphaMapUv: HAS_ALPHAMAP && getChannel(material.alphaMap.channel),
|
|
21043
21131
|
//
|
|
21044
21132
|
vertexTangents: !!geometry.attributes.tangent && (HAS_NORMALMAP || HAS_ANISOTROPY),
|
|
21133
|
+
vertexNormals: !!geometry.attributes.normal,
|
|
21045
21134
|
vertexColors: material.vertexColors,
|
|
21046
21135
|
vertexAlphas: material.vertexColors === true && !!geometry.attributes.color && geometry.attributes.color.itemSize === 4,
|
|
21047
21136
|
pointsUvs: object.isPoints === true && !!geometry.attributes.uv && (HAS_MAP || HAS_ALPHAMAP),
|
|
@@ -21069,6 +21158,7 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
|
|
|
21069
21158
|
numSpotLightShadows: lights.spotShadowMap.length,
|
|
21070
21159
|
numSpotLightShadowsWithMaps: lights.numSpotLightShadowsWithMaps,
|
|
21071
21160
|
numLightProbes: lights.numLightProbes,
|
|
21161
|
+
numLightProbeGrids: lightProbeGrids.length,
|
|
21072
21162
|
numClippingPlanes: clipping.numPlanes,
|
|
21073
21163
|
numClipIntersection: clipping.numIntersection,
|
|
21074
21164
|
dithering: material.dithering,
|
|
@@ -21212,6 +21302,10 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
|
|
|
21212
21302
|
_programLayers.enable(20);
|
|
21213
21303
|
if (parameters.gradientMap)
|
|
21214
21304
|
_programLayers.enable(21);
|
|
21305
|
+
if (parameters.packedNormalMap)
|
|
21306
|
+
_programLayers.enable(22);
|
|
21307
|
+
if (parameters.vertexNormals)
|
|
21308
|
+
_programLayers.enable(23);
|
|
21215
21309
|
array.push(_programLayers.mask);
|
|
21216
21310
|
_programLayers.disableAll();
|
|
21217
21311
|
if (parameters.fog)
|
|
@@ -21258,6 +21352,8 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
|
|
|
21258
21352
|
_programLayers.enable(20);
|
|
21259
21353
|
if (parameters.alphaToCoverage)
|
|
21260
21354
|
_programLayers.enable(21);
|
|
21355
|
+
if (parameters.numLightProbeGrids > 0)
|
|
21356
|
+
_programLayers.enable(22);
|
|
21261
21357
|
array.push(_programLayers.mask);
|
|
21262
21358
|
}
|
|
21263
21359
|
function getUniforms(material) {
|
|
@@ -21857,10 +21953,12 @@ function WebGLRenderState(extensions) {
|
|
|
21857
21953
|
const lights = new WebGLLights(extensions);
|
|
21858
21954
|
const lightsArray = [];
|
|
21859
21955
|
const shadowsArray = [];
|
|
21956
|
+
const lightProbeGridArray = [];
|
|
21860
21957
|
function init(camera) {
|
|
21861
21958
|
state.camera = camera;
|
|
21862
21959
|
lightsArray.length = 0;
|
|
21863
21960
|
shadowsArray.length = 0;
|
|
21961
|
+
lightProbeGridArray.length = 0;
|
|
21864
21962
|
}
|
|
21865
21963
|
function pushLight(light) {
|
|
21866
21964
|
lightsArray.push(light);
|
|
@@ -21868,6 +21966,9 @@ function WebGLRenderState(extensions) {
|
|
|
21868
21966
|
function pushShadow(shadowLight) {
|
|
21869
21967
|
shadowsArray.push(shadowLight);
|
|
21870
21968
|
}
|
|
21969
|
+
function pushLightProbeGrid(volume) {
|
|
21970
|
+
lightProbeGridArray.push(volume);
|
|
21971
|
+
}
|
|
21871
21972
|
function setupLights() {
|
|
21872
21973
|
lights.setup(lightsArray);
|
|
21873
21974
|
}
|
|
@@ -21877,9 +21978,11 @@ function WebGLRenderState(extensions) {
|
|
|
21877
21978
|
const state = {
|
|
21878
21979
|
lightsArray,
|
|
21879
21980
|
shadowsArray,
|
|
21981
|
+
lightProbeGridArray,
|
|
21880
21982
|
camera: null,
|
|
21881
21983
|
lights,
|
|
21882
|
-
transmissionRenderTarget: {}
|
|
21984
|
+
transmissionRenderTarget: {},
|
|
21985
|
+
textureUnits: 0
|
|
21883
21986
|
};
|
|
21884
21987
|
return {
|
|
21885
21988
|
init,
|
|
@@ -21887,7 +21990,8 @@ function WebGLRenderState(extensions) {
|
|
|
21887
21990
|
setupLights,
|
|
21888
21991
|
setupLightsView,
|
|
21889
21992
|
pushLight,
|
|
21890
|
-
pushShadow
|
|
21993
|
+
pushShadow,
|
|
21994
|
+
pushLightProbeGrid
|
|
21891
21995
|
};
|
|
21892
21996
|
}
|
|
21893
21997
|
function WebGLRenderStates(extensions) {
|
|
@@ -22447,6 +22551,7 @@ function WebGLState(gl, extensions) {
|
|
|
22447
22551
|
const uboBindings = /* @__PURE__ */ new WeakMap();
|
|
22448
22552
|
const uboProgramMap = /* @__PURE__ */ new WeakMap();
|
|
22449
22553
|
let enabledCapabilities = {};
|
|
22554
|
+
let parameters = {};
|
|
22450
22555
|
let currentBoundFramebuffers = {};
|
|
22451
22556
|
let currentDrawbuffers = /* @__PURE__ */ new WeakMap();
|
|
22452
22557
|
let defaultDrawbuffers = [];
|
|
@@ -22871,6 +22976,19 @@ function WebGLState(gl, extensions) {
|
|
|
22871
22976
|
error("WebGLState:", e);
|
|
22872
22977
|
}
|
|
22873
22978
|
}
|
|
22979
|
+
function getParameter(name) {
|
|
22980
|
+
if (parameters[name] !== void 0) {
|
|
22981
|
+
return parameters[name];
|
|
22982
|
+
} else {
|
|
22983
|
+
return gl.getParameter(name);
|
|
22984
|
+
}
|
|
22985
|
+
}
|
|
22986
|
+
function pixelStorei(name, value) {
|
|
22987
|
+
if (parameters[name] !== value) {
|
|
22988
|
+
gl.pixelStorei(name, value);
|
|
22989
|
+
parameters[name] = value;
|
|
22990
|
+
}
|
|
22991
|
+
}
|
|
22874
22992
|
function scissor(scissor2) {
|
|
22875
22993
|
if (currentScissor.equals(scissor2) === false) {
|
|
22876
22994
|
gl.scissor(scissor2.x, scissor2.y, scissor2.z, scissor2.w);
|
|
@@ -22936,7 +23054,21 @@ function WebGLState(gl, extensions) {
|
|
|
22936
23054
|
gl.lineWidth(1);
|
|
22937
23055
|
gl.scissor(0, 0, gl.canvas.width, gl.canvas.height);
|
|
22938
23056
|
gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);
|
|
23057
|
+
gl.pixelStorei(gl.PACK_ALIGNMENT, 4);
|
|
23058
|
+
gl.pixelStorei(gl.UNPACK_ALIGNMENT, 4);
|
|
23059
|
+
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
23060
|
+
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
|
|
23061
|
+
gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, gl.BROWSER_DEFAULT_WEBGL);
|
|
23062
|
+
gl.pixelStorei(gl.PACK_ROW_LENGTH, 0);
|
|
23063
|
+
gl.pixelStorei(gl.PACK_SKIP_PIXELS, 0);
|
|
23064
|
+
gl.pixelStorei(gl.PACK_SKIP_ROWS, 0);
|
|
23065
|
+
gl.pixelStorei(gl.UNPACK_ROW_LENGTH, 0);
|
|
23066
|
+
gl.pixelStorei(gl.UNPACK_IMAGE_HEIGHT, 0);
|
|
23067
|
+
gl.pixelStorei(gl.UNPACK_SKIP_PIXELS, 0);
|
|
23068
|
+
gl.pixelStorei(gl.UNPACK_SKIP_ROWS, 0);
|
|
23069
|
+
gl.pixelStorei(gl.UNPACK_SKIP_IMAGES, 0);
|
|
22939
23070
|
enabledCapabilities = {};
|
|
23071
|
+
parameters = {};
|
|
22940
23072
|
currentTextureSlot = null;
|
|
22941
23073
|
currentBoundTextures = {};
|
|
22942
23074
|
currentBoundFramebuffers = {};
|
|
@@ -22990,6 +23122,8 @@ function WebGLState(gl, extensions) {
|
|
|
22990
23122
|
compressedTexImage3D,
|
|
22991
23123
|
texImage2D,
|
|
22992
23124
|
texImage3D,
|
|
23125
|
+
pixelStorei,
|
|
23126
|
+
getParameter,
|
|
22993
23127
|
updateUBOMapping,
|
|
22994
23128
|
uniformBlockBinding,
|
|
22995
23129
|
texStorage2D,
|
|
@@ -23008,6 +23142,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
23008
23142
|
const supportsInvalidateFramebuffer = typeof navigator === "undefined" ? false : /OculusBrowser/g.test(navigator.userAgent);
|
|
23009
23143
|
const _imageDimensions = new Vector2();
|
|
23010
23144
|
const _videoTextures = /* @__PURE__ */ new WeakMap();
|
|
23145
|
+
const _htmlTextures = /* @__PURE__ */ new Set();
|
|
23011
23146
|
let _canvas2;
|
|
23012
23147
|
const _sources = /* @__PURE__ */ new WeakMap();
|
|
23013
23148
|
let useOffscreenCanvas = false;
|
|
@@ -23057,16 +23192,25 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
23057
23192
|
if (texture.isWebGLArrayRenderTarget || texture.isCompressedArrayTexture) return _gl.TEXTURE_2D_ARRAY;
|
|
23058
23193
|
return _gl.TEXTURE_2D;
|
|
23059
23194
|
}
|
|
23060
|
-
function getInternalFormat(internalFormatName, glFormat, glType, colorSpace, forceLinearTransfer = false) {
|
|
23195
|
+
function getInternalFormat(internalFormatName, glFormat, glType, normalized, colorSpace, forceLinearTransfer = false) {
|
|
23061
23196
|
if (internalFormatName !== null) {
|
|
23062
23197
|
if (_gl[internalFormatName] !== void 0) return _gl[internalFormatName];
|
|
23063
23198
|
warn("WebGLRenderer: Attempt to use non-existing WebGL internal format '" + internalFormatName + "'");
|
|
23064
23199
|
}
|
|
23200
|
+
let ext_texture_norm16;
|
|
23201
|
+
if (normalized) {
|
|
23202
|
+
ext_texture_norm16 = extensions.get("EXT_texture_norm16");
|
|
23203
|
+
if (!ext_texture_norm16) {
|
|
23204
|
+
warn("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension");
|
|
23205
|
+
}
|
|
23206
|
+
}
|
|
23065
23207
|
let internalFormat = glFormat;
|
|
23066
23208
|
if (glFormat === _gl.RED) {
|
|
23067
23209
|
if (glType === _gl.FLOAT) internalFormat = _gl.R32F;
|
|
23068
23210
|
if (glType === _gl.HALF_FLOAT) internalFormat = _gl.R16F;
|
|
23069
23211
|
if (glType === _gl.UNSIGNED_BYTE) internalFormat = _gl.R8;
|
|
23212
|
+
if (glType === _gl.UNSIGNED_SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.R16_EXT;
|
|
23213
|
+
if (glType === _gl.SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.R16_SNORM_EXT;
|
|
23070
23214
|
}
|
|
23071
23215
|
if (glFormat === _gl.RED_INTEGER) {
|
|
23072
23216
|
if (glType === _gl.UNSIGNED_BYTE) internalFormat = _gl.R8UI;
|
|
@@ -23080,6 +23224,8 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
23080
23224
|
if (glType === _gl.FLOAT) internalFormat = _gl.RG32F;
|
|
23081
23225
|
if (glType === _gl.HALF_FLOAT) internalFormat = _gl.RG16F;
|
|
23082
23226
|
if (glType === _gl.UNSIGNED_BYTE) internalFormat = _gl.RG8;
|
|
23227
|
+
if (glType === _gl.UNSIGNED_SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.RG16_EXT;
|
|
23228
|
+
if (glType === _gl.SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.RG16_SNORM_EXT;
|
|
23083
23229
|
}
|
|
23084
23230
|
if (glFormat === _gl.RG_INTEGER) {
|
|
23085
23231
|
if (glType === _gl.UNSIGNED_BYTE) internalFormat = _gl.RG8UI;
|
|
@@ -23106,6 +23252,8 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
23106
23252
|
if (glType === _gl.INT) internalFormat = _gl.RGBA32I;
|
|
23107
23253
|
}
|
|
23108
23254
|
if (glFormat === _gl.RGB) {
|
|
23255
|
+
if (glType === _gl.UNSIGNED_SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.RGB16_EXT;
|
|
23256
|
+
if (glType === _gl.SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.RGB16_SNORM_EXT;
|
|
23109
23257
|
if (glType === _gl.UNSIGNED_INT_5_9_9_9_REV) internalFormat = _gl.RGB9_E5;
|
|
23110
23258
|
if (glType === _gl.UNSIGNED_INT_10F_11F_11F_REV) internalFormat = _gl.R11F_G11F_B10F;
|
|
23111
23259
|
}
|
|
@@ -23114,6 +23262,8 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
23114
23262
|
if (glType === _gl.FLOAT) internalFormat = _gl.RGBA32F;
|
|
23115
23263
|
if (glType === _gl.HALF_FLOAT) internalFormat = _gl.RGBA16F;
|
|
23116
23264
|
if (glType === _gl.UNSIGNED_BYTE) internalFormat = transfer === SRGBTransfer ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
|
|
23265
|
+
if (glType === _gl.UNSIGNED_SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.RGBA16_EXT;
|
|
23266
|
+
if (glType === _gl.SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.RGBA16_SNORM_EXT;
|
|
23117
23267
|
if (glType === _gl.UNSIGNED_SHORT_4_4_4_4) internalFormat = _gl.RGBA4;
|
|
23118
23268
|
if (glType === _gl.UNSIGNED_SHORT_5_5_5_1) internalFormat = _gl.RGB5_A1;
|
|
23119
23269
|
}
|
|
@@ -23162,6 +23312,9 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
23162
23312
|
if (texture.isVideoTexture) {
|
|
23163
23313
|
_videoTextures.delete(texture);
|
|
23164
23314
|
}
|
|
23315
|
+
if (texture.isHTMLTexture) {
|
|
23316
|
+
_htmlTextures.delete(texture);
|
|
23317
|
+
}
|
|
23165
23318
|
}
|
|
23166
23319
|
function onRenderTargetDispose(event) {
|
|
23167
23320
|
const renderTarget = event.target;
|
|
@@ -23238,6 +23391,12 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
23238
23391
|
function resetTextureUnits() {
|
|
23239
23392
|
textureUnits = 0;
|
|
23240
23393
|
}
|
|
23394
|
+
function getTextureUnits() {
|
|
23395
|
+
return textureUnits;
|
|
23396
|
+
}
|
|
23397
|
+
function setTextureUnits(value) {
|
|
23398
|
+
textureUnits = value;
|
|
23399
|
+
}
|
|
23241
23400
|
function allocateTextureUnit() {
|
|
23242
23401
|
const textureUnit = textureUnits;
|
|
23243
23402
|
if (textureUnit >= capabilities.maxTextures) {
|
|
@@ -23420,10 +23579,10 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
23420
23579
|
}
|
|
23421
23580
|
}
|
|
23422
23581
|
updateRanges.length = mergeIndex + 1;
|
|
23423
|
-
const currentUnpackRowLen =
|
|
23424
|
-
const currentUnpackSkipPixels =
|
|
23425
|
-
const currentUnpackSkipRows =
|
|
23426
|
-
|
|
23582
|
+
const currentUnpackRowLen = state.getParameter(_gl.UNPACK_ROW_LENGTH);
|
|
23583
|
+
const currentUnpackSkipPixels = state.getParameter(_gl.UNPACK_SKIP_PIXELS);
|
|
23584
|
+
const currentUnpackSkipRows = state.getParameter(_gl.UNPACK_SKIP_ROWS);
|
|
23585
|
+
state.pixelStorei(_gl.UNPACK_ROW_LENGTH, image.width);
|
|
23427
23586
|
for (let i = 0, l = updateRanges.length; i < l; i++) {
|
|
23428
23587
|
const range = updateRanges[i];
|
|
23429
23588
|
const pixelStart = Math.floor(range.start / componentStride);
|
|
@@ -23432,14 +23591,14 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
23432
23591
|
const y = Math.floor(pixelStart / image.width);
|
|
23433
23592
|
const width = pixelCount;
|
|
23434
23593
|
const height = 1;
|
|
23435
|
-
|
|
23436
|
-
|
|
23594
|
+
state.pixelStorei(_gl.UNPACK_SKIP_PIXELS, x);
|
|
23595
|
+
state.pixelStorei(_gl.UNPACK_SKIP_ROWS, y);
|
|
23437
23596
|
state.texSubImage2D(_gl.TEXTURE_2D, 0, x, y, width, height, glFormat, glType, image.data);
|
|
23438
23597
|
}
|
|
23439
23598
|
texture.clearUpdateRanges();
|
|
23440
|
-
|
|
23441
|
-
|
|
23442
|
-
|
|
23599
|
+
state.pixelStorei(_gl.UNPACK_ROW_LENGTH, currentUnpackRowLen);
|
|
23600
|
+
state.pixelStorei(_gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels);
|
|
23601
|
+
state.pixelStorei(_gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows);
|
|
23443
23602
|
}
|
|
23444
23603
|
}
|
|
23445
23604
|
function uploadTexture(textureProperties, texture, slot) {
|
|
@@ -23452,18 +23611,21 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
23452
23611
|
const sourceProperties = properties.get(source);
|
|
23453
23612
|
if (source.version !== sourceProperties.__version || forceUpload === true) {
|
|
23454
23613
|
state.activeTexture(_gl.TEXTURE0 + slot);
|
|
23455
|
-
const
|
|
23456
|
-
|
|
23457
|
-
|
|
23458
|
-
|
|
23459
|
-
|
|
23460
|
-
|
|
23461
|
-
|
|
23614
|
+
const isImageBitmap = typeof ImageBitmap !== "undefined" && texture.image instanceof ImageBitmap;
|
|
23615
|
+
if (isImageBitmap === false) {
|
|
23616
|
+
const workingPrimaries = ColorManagement.getPrimaries(ColorManagement.workingColorSpace);
|
|
23617
|
+
const texturePrimaries = texture.colorSpace === NoColorSpace ? null : ColorManagement.getPrimaries(texture.colorSpace);
|
|
23618
|
+
const unpackConversion = texture.colorSpace === NoColorSpace || workingPrimaries === texturePrimaries ? _gl.NONE : _gl.BROWSER_DEFAULT_WEBGL;
|
|
23619
|
+
state.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, texture.flipY);
|
|
23620
|
+
state.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha);
|
|
23621
|
+
state.pixelStorei(_gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion);
|
|
23622
|
+
}
|
|
23623
|
+
state.pixelStorei(_gl.UNPACK_ALIGNMENT, texture.unpackAlignment);
|
|
23462
23624
|
let image = resizeImage(texture.image, false, capabilities.maxTextureSize);
|
|
23463
23625
|
image = verifyColorSpace(texture, image);
|
|
23464
23626
|
const glFormat = utils.convert(texture.format, texture.colorSpace);
|
|
23465
23627
|
const glType = utils.convert(texture.type);
|
|
23466
|
-
let glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.colorSpace, texture.isVideoTexture);
|
|
23628
|
+
let glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.normalized, texture.colorSpace, texture.isVideoTexture);
|
|
23467
23629
|
setTextureParameters(textureType, texture);
|
|
23468
23630
|
let mipmap;
|
|
23469
23631
|
const mipmaps = texture.mipmaps;
|
|
@@ -23625,6 +23787,35 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
23625
23787
|
}
|
|
23626
23788
|
}
|
|
23627
23789
|
}
|
|
23790
|
+
} else if (texture.isHTMLTexture) {
|
|
23791
|
+
if ("texElementImage2D" in _gl) {
|
|
23792
|
+
const canvas = _gl.canvas;
|
|
23793
|
+
if (!canvas.hasAttribute("layoutsubtree")) {
|
|
23794
|
+
canvas.setAttribute("layoutsubtree", "true");
|
|
23795
|
+
}
|
|
23796
|
+
if (image.parentNode !== canvas) {
|
|
23797
|
+
canvas.appendChild(image);
|
|
23798
|
+
_htmlTextures.add(texture);
|
|
23799
|
+
canvas.onpaint = (event) => {
|
|
23800
|
+
const changed = event.changedElements;
|
|
23801
|
+
for (const t of _htmlTextures) {
|
|
23802
|
+
if (changed.includes(t.image)) {
|
|
23803
|
+
t.needsUpdate = true;
|
|
23804
|
+
}
|
|
23805
|
+
}
|
|
23806
|
+
};
|
|
23807
|
+
canvas.requestPaint();
|
|
23808
|
+
return;
|
|
23809
|
+
}
|
|
23810
|
+
const level = 0;
|
|
23811
|
+
const internalFormat = _gl.RGBA;
|
|
23812
|
+
const srcFormat = _gl.RGBA;
|
|
23813
|
+
const srcType = _gl.UNSIGNED_BYTE;
|
|
23814
|
+
_gl.texElementImage2D(_gl.TEXTURE_2D, level, internalFormat, srcFormat, srcType, image);
|
|
23815
|
+
_gl.texParameteri(_gl.TEXTURE_2D, _gl.TEXTURE_MIN_FILTER, _gl.LINEAR);
|
|
23816
|
+
_gl.texParameteri(_gl.TEXTURE_2D, _gl.TEXTURE_WRAP_S, _gl.CLAMP_TO_EDGE);
|
|
23817
|
+
_gl.texParameteri(_gl.TEXTURE_2D, _gl.TEXTURE_WRAP_T, _gl.CLAMP_TO_EDGE);
|
|
23818
|
+
}
|
|
23628
23819
|
} else {
|
|
23629
23820
|
if (mipmaps.length > 0) {
|
|
23630
23821
|
if (useTexStorage && allocateMemory) {
|
|
@@ -23675,10 +23866,10 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
23675
23866
|
const workingPrimaries = ColorManagement.getPrimaries(ColorManagement.workingColorSpace);
|
|
23676
23867
|
const texturePrimaries = texture.colorSpace === NoColorSpace ? null : ColorManagement.getPrimaries(texture.colorSpace);
|
|
23677
23868
|
const unpackConversion = texture.colorSpace === NoColorSpace || workingPrimaries === texturePrimaries ? _gl.NONE : _gl.BROWSER_DEFAULT_WEBGL;
|
|
23678
|
-
|
|
23679
|
-
|
|
23680
|
-
|
|
23681
|
-
|
|
23869
|
+
state.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, texture.flipY);
|
|
23870
|
+
state.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha);
|
|
23871
|
+
state.pixelStorei(_gl.UNPACK_ALIGNMENT, texture.unpackAlignment);
|
|
23872
|
+
state.pixelStorei(_gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion);
|
|
23682
23873
|
const isCompressed = texture.isCompressedTexture || texture.image[0].isCompressedTexture;
|
|
23683
23874
|
const isDataTexture = texture.image[0] && texture.image[0].isDataTexture;
|
|
23684
23875
|
const cubeImage = [];
|
|
@@ -23690,7 +23881,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
23690
23881
|
}
|
|
23691
23882
|
cubeImage[i] = verifyColorSpace(texture, cubeImage[i]);
|
|
23692
23883
|
}
|
|
23693
|
-
const image = cubeImage[0], glFormat = utils.convert(texture.format, texture.colorSpace), glType = utils.convert(texture.type), glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.colorSpace);
|
|
23884
|
+
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);
|
|
23694
23885
|
const useTexStorage = texture.isVideoTexture !== true;
|
|
23695
23886
|
const allocateMemory = sourceProperties.__version === void 0 || forceUpload === true;
|
|
23696
23887
|
const dataReady = source.dataReady;
|
|
@@ -23787,7 +23978,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
23787
23978
|
function setupFrameBufferTexture(framebuffer, renderTarget, texture, attachment, textureTarget, level) {
|
|
23788
23979
|
const glFormat = utils.convert(texture.format, texture.colorSpace);
|
|
23789
23980
|
const glType = utils.convert(texture.type);
|
|
23790
|
-
const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.colorSpace);
|
|
23981
|
+
const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.normalized, texture.colorSpace);
|
|
23791
23982
|
const renderTargetProperties = properties.get(renderTarget);
|
|
23792
23983
|
const textureProperties = properties.get(texture);
|
|
23793
23984
|
textureProperties.__renderTarget = renderTarget;
|
|
@@ -23829,7 +24020,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
23829
24020
|
const texture = textures[i];
|
|
23830
24021
|
const glFormat = utils.convert(texture.format, texture.colorSpace);
|
|
23831
24022
|
const glType = utils.convert(texture.type);
|
|
23832
|
-
const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.colorSpace);
|
|
24023
|
+
const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.normalized, texture.colorSpace);
|
|
23833
24024
|
if (useMultisampledRTT(renderTarget)) {
|
|
23834
24025
|
multisampledRTTExt.renderbufferStorageMultisampleEXT(_gl.RENDERBUFFER, getRenderTargetSamples(renderTarget), glInternalFormat, renderTarget.width, renderTarget.height);
|
|
23835
24026
|
} else if (useMultisample) {
|
|
@@ -24029,7 +24220,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
24029
24220
|
_gl.bindRenderbuffer(_gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[i]);
|
|
24030
24221
|
const glFormat = utils.convert(texture2.format, texture2.colorSpace);
|
|
24031
24222
|
const glType = utils.convert(texture2.type);
|
|
24032
|
-
const glInternalFormat = getInternalFormat(texture2.internalFormat, glFormat, glType, texture2.colorSpace, renderTarget.isXRRenderTarget === true);
|
|
24223
|
+
const glInternalFormat = getInternalFormat(texture2.internalFormat, glFormat, glType, texture2.normalized, texture2.colorSpace, renderTarget.isXRRenderTarget === true);
|
|
24033
24224
|
const samples = getRenderTargetSamples(renderTarget);
|
|
24034
24225
|
_gl.renderbufferStorageMultisample(_gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height);
|
|
24035
24226
|
_gl.framebufferRenderbuffer(_gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[i]);
|
|
@@ -24225,6 +24416,8 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
|
|
|
24225
24416
|
}
|
|
24226
24417
|
this.allocateTextureUnit = allocateTextureUnit;
|
|
24227
24418
|
this.resetTextureUnits = resetTextureUnits;
|
|
24419
|
+
this.getTextureUnits = getTextureUnits;
|
|
24420
|
+
this.setTextureUnits = setTextureUnits;
|
|
24228
24421
|
this.setTexture2D = setTexture2D;
|
|
24229
24422
|
this.setTexture2DArray = setTexture2DArray;
|
|
24230
24423
|
this.setTexture3D = setTexture3D;
|
|
@@ -24945,8 +25138,9 @@ var WebXRManager = class extends EventDispatcher {
|
|
|
24945
25138
|
};
|
|
24946
25139
|
}
|
|
24947
25140
|
};
|
|
24948
|
-
var _e1 = /* @__PURE__ */ new Euler();
|
|
24949
25141
|
var _m12 = /* @__PURE__ */ new Matrix4();
|
|
25142
|
+
var _m = /* @__PURE__ */ new Matrix3();
|
|
25143
|
+
_m.set(-1, 0, 0, 0, 1, 0, 0, 0, 1);
|
|
24950
25144
|
function WebGLMaterials(renderer, properties) {
|
|
24951
25145
|
function refreshTransformUniform(map, uniform) {
|
|
24952
25146
|
if (map.matrixAutoUpdate === true) {
|
|
@@ -24964,7 +25158,9 @@ function WebGLMaterials(renderer, properties) {
|
|
|
24964
25158
|
}
|
|
24965
25159
|
}
|
|
24966
25160
|
function refreshMaterialUniforms(uniforms, material, pixelRatio, height, transmissionRenderTarget) {
|
|
24967
|
-
if (material.
|
|
25161
|
+
if (material.isNodeMaterial) {
|
|
25162
|
+
material.uniformsNeedUpdate = false;
|
|
25163
|
+
} else if (material.isMeshBasicMaterial) {
|
|
24968
25164
|
refreshUniformsCommon(uniforms, material);
|
|
24969
25165
|
} else if (material.isMeshLambertMaterial) {
|
|
24970
25166
|
refreshUniformsCommon(uniforms, material);
|
|
@@ -25066,16 +25262,10 @@ function WebGLMaterials(renderer, properties) {
|
|
|
25066
25262
|
const envMapRotation = materialProperties.envMapRotation;
|
|
25067
25263
|
if (envMap) {
|
|
25068
25264
|
uniforms.envMap.value = envMap;
|
|
25069
|
-
|
|
25070
|
-
_e1.x *= -1;
|
|
25071
|
-
_e1.y *= -1;
|
|
25072
|
-
_e1.z *= -1;
|
|
25265
|
+
uniforms.envMapRotation.value.setFromMatrix4(_m12.makeRotationFromEuler(envMapRotation)).transpose();
|
|
25073
25266
|
if (envMap.isCubeTexture && envMap.isRenderTargetTexture === false) {
|
|
25074
|
-
|
|
25075
|
-
_e1.z *= -1;
|
|
25267
|
+
uniforms.envMapRotation.value.premultiply(_m);
|
|
25076
25268
|
}
|
|
25077
|
-
uniforms.envMapRotation.value.setFromMatrix4(_m12.makeRotationFromEuler(_e1));
|
|
25078
|
-
uniforms.flipEnvMap.value = envMap.isCubeTexture && envMap.isRenderTargetTexture === false ? -1 : 1;
|
|
25079
25269
|
uniforms.reflectivity.value = material.reflectivity;
|
|
25080
25270
|
uniforms.ior.value = material.ior;
|
|
25081
25271
|
uniforms.refractionRatio.value = material.refractionRatio;
|
|
@@ -25341,6 +25531,8 @@ function WebGLUniformsGroups(gl, info, capabilities, state) {
|
|
|
25341
25531
|
uniform.__data[9] = value.elements[7];
|
|
25342
25532
|
uniform.__data[10] = value.elements[8];
|
|
25343
25533
|
uniform.__data[11] = 0;
|
|
25534
|
+
} else if (ArrayBuffer.isView(value)) {
|
|
25535
|
+
uniform.__data.set(new value.constructor(value.buffer, value.byteOffset, uniform.__data.length));
|
|
25344
25536
|
} else {
|
|
25345
25537
|
value.toArray(uniform.__data, arrayOffset);
|
|
25346
25538
|
arrayOffset += info2.storage / Float32Array.BYTES_PER_ELEMENT;
|
|
@@ -25358,6 +25550,8 @@ function WebGLUniformsGroups(gl, info, capabilities, state) {
|
|
|
25358
25550
|
if (cache[indexString] === void 0) {
|
|
25359
25551
|
if (typeof value === "number" || typeof value === "boolean") {
|
|
25360
25552
|
cache[indexString] = value;
|
|
25553
|
+
} else if (ArrayBuffer.isView(value)) {
|
|
25554
|
+
cache[indexString] = value.slice();
|
|
25361
25555
|
} else {
|
|
25362
25556
|
cache[indexString] = value.clone();
|
|
25363
25557
|
}
|
|
@@ -25369,6 +25563,8 @@ function WebGLUniformsGroups(gl, info, capabilities, state) {
|
|
|
25369
25563
|
cache[indexString] = value;
|
|
25370
25564
|
return true;
|
|
25371
25565
|
}
|
|
25566
|
+
} else if (ArrayBuffer.isView(value)) {
|
|
25567
|
+
return true;
|
|
25372
25568
|
} else {
|
|
25373
25569
|
if (cachedObject.equals(value) === false) {
|
|
25374
25570
|
cachedObject.copy(value);
|
|
@@ -25436,6 +25632,9 @@ function WebGLUniformsGroups(gl, info, capabilities, state) {
|
|
|
25436
25632
|
info2.storage = 64;
|
|
25437
25633
|
} else if (value.isTexture) {
|
|
25438
25634
|
warn("WebGLRenderer: Texture samplers can not be part of an uniforms group.");
|
|
25635
|
+
} else if (ArrayBuffer.isView(value)) {
|
|
25636
|
+
info2.boundary = 16;
|
|
25637
|
+
info2.storage = value.byteLength;
|
|
25439
25638
|
} else {
|
|
25440
25639
|
warn("WebGLRenderer: Unsupported uniform value type.", value);
|
|
25441
25640
|
}
|
|
@@ -26039,6 +26238,7 @@ var WebGLRenderer = class {
|
|
|
26039
26238
|
]);
|
|
26040
26239
|
const uintClearColor = new Uint32Array(4);
|
|
26041
26240
|
const intClearColor = new Int32Array(4);
|
|
26241
|
+
const objectPosition = new Vector3();
|
|
26042
26242
|
let currentRenderList = null;
|
|
26043
26243
|
let currentRenderState = null;
|
|
26044
26244
|
const renderListStack = [];
|
|
@@ -26069,6 +26269,7 @@ var WebGLRenderer = class {
|
|
|
26069
26269
|
this.transmissionResolutionScale = 1;
|
|
26070
26270
|
const _this = this;
|
|
26071
26271
|
let _isContextLost = false;
|
|
26272
|
+
let _nodesHandler = null;
|
|
26072
26273
|
this._outputColorSpace = SRGBColorSpace;
|
|
26073
26274
|
let _currentActiveCubeFace = 0;
|
|
26074
26275
|
let _currentActiveMipmapLevel = 0;
|
|
@@ -26237,13 +26438,13 @@ var WebGLRenderer = class {
|
|
|
26237
26438
|
};
|
|
26238
26439
|
this.setEffects = function(effects) {
|
|
26239
26440
|
if (_outputBufferType === UnsignedByteType) {
|
|
26240
|
-
|
|
26441
|
+
error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");
|
|
26241
26442
|
return;
|
|
26242
26443
|
}
|
|
26243
26444
|
if (effects) {
|
|
26244
26445
|
for (let i = 0; i < effects.length; i++) {
|
|
26245
26446
|
if (effects[i].isOutputPass === true) {
|
|
26246
|
-
|
|
26447
|
+
warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");
|
|
26247
26448
|
break;
|
|
26248
26449
|
}
|
|
26249
26450
|
}
|
|
@@ -26334,6 +26535,7 @@ var WebGLRenderer = class {
|
|
|
26334
26535
|
}
|
|
26335
26536
|
if (depth2) {
|
|
26336
26537
|
bits |= _gl.DEPTH_BUFFER_BIT;
|
|
26538
|
+
this.state.buffers.depth.setMask(true);
|
|
26337
26539
|
}
|
|
26338
26540
|
if (stencil2) {
|
|
26339
26541
|
bits |= _gl.STENCIL_BUFFER_BIT;
|
|
@@ -26352,6 +26554,10 @@ var WebGLRenderer = class {
|
|
|
26352
26554
|
this.clearStencil = function() {
|
|
26353
26555
|
this.clear(false, false, true);
|
|
26354
26556
|
};
|
|
26557
|
+
this.setNodesHandler = function(nodesHandler) {
|
|
26558
|
+
nodesHandler.setRenderer(this);
|
|
26559
|
+
_nodesHandler = nodesHandler;
|
|
26560
|
+
};
|
|
26355
26561
|
this.dispose = function() {
|
|
26356
26562
|
canvas.removeEventListener("webglcontextlost", onContextLost, false);
|
|
26357
26563
|
canvas.removeEventListener("webglcontextrestored", onContextRestore, false);
|
|
@@ -26474,23 +26680,18 @@ var WebGLRenderer = class {
|
|
|
26474
26680
|
renderer.setMode(_gl.TRIANGLES);
|
|
26475
26681
|
}
|
|
26476
26682
|
if (object.isBatchedMesh) {
|
|
26477
|
-
if (
|
|
26478
|
-
|
|
26479
|
-
|
|
26480
|
-
|
|
26481
|
-
|
|
26482
|
-
|
|
26483
|
-
|
|
26484
|
-
|
|
26485
|
-
|
|
26486
|
-
const uniforms = properties.get(material).currentProgram.getUniforms();
|
|
26487
|
-
for (let i = 0; i < drawCount2; i++) {
|
|
26488
|
-
uniforms.setValue(_gl, "_gl_DrawID", i);
|
|
26489
|
-
renderer.render(starts[i] / bytesPerElement, counts[i]);
|
|
26490
|
-
}
|
|
26491
|
-
} else {
|
|
26492
|
-
renderer.renderMultiDraw(object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount);
|
|
26683
|
+
if (!extensions.get("WEBGL_multi_draw")) {
|
|
26684
|
+
const starts = object._multiDrawStarts;
|
|
26685
|
+
const counts = object._multiDrawCounts;
|
|
26686
|
+
const drawCount2 = object._multiDrawCount;
|
|
26687
|
+
const bytesPerElement = index ? attributes.get(index).bytesPerElement : 1;
|
|
26688
|
+
const uniforms = properties.get(material).currentProgram.getUniforms();
|
|
26689
|
+
for (let i = 0; i < drawCount2; i++) {
|
|
26690
|
+
uniforms.setValue(_gl, "_gl_DrawID", i);
|
|
26691
|
+
renderer.render(starts[i] / bytesPerElement, counts[i]);
|
|
26493
26692
|
}
|
|
26693
|
+
} else {
|
|
26694
|
+
renderer.renderMultiDraw(object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount);
|
|
26494
26695
|
}
|
|
26495
26696
|
} else if (object.isInstancedMesh) {
|
|
26496
26697
|
renderer.renderInstances(drawStart, drawCount, object.count);
|
|
@@ -26611,6 +26812,9 @@ var WebGLRenderer = class {
|
|
|
26611
26812
|
return;
|
|
26612
26813
|
}
|
|
26613
26814
|
if (_isContextLost === true) return;
|
|
26815
|
+
if (_nodesHandler !== null) {
|
|
26816
|
+
_nodesHandler.renderStart(scene, camera);
|
|
26817
|
+
}
|
|
26614
26818
|
const isXRPresenting = xr.enabled === true && xr.isPresenting === true;
|
|
26615
26819
|
const useOutput = output !== null && (_currentRenderTarget === null || isXRPresenting) && output.begin(_this, _currentRenderTarget);
|
|
26616
26820
|
if (scene.matrixWorldAutoUpdate === true) scene.updateMatrixWorld();
|
|
@@ -26622,6 +26826,7 @@ var WebGLRenderer = class {
|
|
|
26622
26826
|
if (scene.isScene === true) scene.onBeforeRender(_this, scene, camera, _currentRenderTarget);
|
|
26623
26827
|
currentRenderState = renderStates.get(scene, renderStateStack.length);
|
|
26624
26828
|
currentRenderState.init(camera);
|
|
26829
|
+
currentRenderState.state.textureUnits = textures.getTextureUnits();
|
|
26625
26830
|
renderStateStack.push(currentRenderState);
|
|
26626
26831
|
_projScreenMatrix3.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
|
|
26627
26832
|
_frustum.setFromProjectionMatrix(_projScreenMatrix3, WebGLCoordinateSystem, camera.reversedDepth);
|
|
@@ -26689,6 +26894,7 @@ var WebGLRenderer = class {
|
|
|
26689
26894
|
renderStateStack.pop();
|
|
26690
26895
|
if (renderStateStack.length > 0) {
|
|
26691
26896
|
currentRenderState = renderStateStack[renderStateStack.length - 1];
|
|
26897
|
+
textures.setTextureUnits(currentRenderState.state.textureUnits);
|
|
26692
26898
|
if (_clippingEnabled === true) clipping.setGlobalState(_this.clippingPlanes, currentRenderState.state.camera);
|
|
26693
26899
|
} else {
|
|
26694
26900
|
currentRenderState = null;
|
|
@@ -26699,6 +26905,9 @@ var WebGLRenderer = class {
|
|
|
26699
26905
|
} else {
|
|
26700
26906
|
currentRenderList = null;
|
|
26701
26907
|
}
|
|
26908
|
+
if (_nodesHandler !== null) {
|
|
26909
|
+
_nodesHandler.renderEnd();
|
|
26910
|
+
}
|
|
26702
26911
|
};
|
|
26703
26912
|
function projectObject(object, camera, groupOrder, sortObjects) {
|
|
26704
26913
|
if (object.visible === false) return;
|
|
@@ -26708,6 +26917,8 @@ var WebGLRenderer = class {
|
|
|
26708
26917
|
groupOrder = object.renderOrder;
|
|
26709
26918
|
} else if (object.isLOD) {
|
|
26710
26919
|
if (object.autoUpdate === true) object.update(camera);
|
|
26920
|
+
} else if (object.isLightProbeGrid) {
|
|
26921
|
+
currentRenderState.pushLightProbeGrid(object);
|
|
26711
26922
|
} else if (object.isLight) {
|
|
26712
26923
|
currentRenderState.pushLight(object);
|
|
26713
26924
|
if (object.castShadow) {
|
|
@@ -26874,7 +27085,7 @@ var WebGLRenderer = class {
|
|
|
26874
27085
|
const lights = currentRenderState.state.lights;
|
|
26875
27086
|
const shadowsArray = currentRenderState.state.shadowsArray;
|
|
26876
27087
|
const lightsStateVersion = lights.state.version;
|
|
26877
|
-
const parameters2 = programCache.getParameters(material, lights.state, shadowsArray, scene, object);
|
|
27088
|
+
const parameters2 = programCache.getParameters(material, lights.state, shadowsArray, scene, object, currentRenderState.state.lightProbeGridArray);
|
|
26878
27089
|
const programCacheKey = programCache.getProgramCacheKey(parameters2);
|
|
26879
27090
|
let programs = materialProperties.programs;
|
|
26880
27091
|
materialProperties.environment = material.isMeshStandardMaterial || material.isMeshLambertMaterial || material.isMeshPhongMaterial ? scene.environment : null;
|
|
@@ -26895,6 +27106,9 @@ var WebGLRenderer = class {
|
|
|
26895
27106
|
}
|
|
26896
27107
|
} else {
|
|
26897
27108
|
parameters2.uniforms = programCache.getUniforms(material);
|
|
27109
|
+
if (_nodesHandler !== null && material.isNodeMaterial) {
|
|
27110
|
+
_nodesHandler.build(material, object, parameters2);
|
|
27111
|
+
}
|
|
26898
27112
|
material.onBeforeCompile(parameters2, _this);
|
|
26899
27113
|
program = programCache.acquireProgram(parameters2, programCacheKey);
|
|
26900
27114
|
programs.set(programCacheKey, program);
|
|
@@ -26925,6 +27139,7 @@ var WebGLRenderer = class {
|
|
|
26925
27139
|
uniforms.spotLightMap.value = lights.state.spotLightMap;
|
|
26926
27140
|
uniforms.pointShadowMatrix.value = lights.state.pointShadowMatrix;
|
|
26927
27141
|
}
|
|
27142
|
+
materialProperties.lightProbeGrid = currentRenderState.state.lightProbeGridArray.length > 0;
|
|
26928
27143
|
materialProperties.currentProgram = program;
|
|
26929
27144
|
materialProperties.uniformsList = null;
|
|
26930
27145
|
return program;
|
|
@@ -26955,12 +27170,24 @@ var WebGLRenderer = class {
|
|
|
26955
27170
|
materialProperties.vertexTangents = parameters2.vertexTangents;
|
|
26956
27171
|
materialProperties.toneMapping = parameters2.toneMapping;
|
|
26957
27172
|
}
|
|
27173
|
+
function findLightProbeGrid(volumes, object) {
|
|
27174
|
+
if (volumes.length === 0) return null;
|
|
27175
|
+
if (volumes.length === 1) {
|
|
27176
|
+
return volumes[0].texture !== null ? volumes[0] : null;
|
|
27177
|
+
}
|
|
27178
|
+
objectPosition.setFromMatrixPosition(object.matrixWorld);
|
|
27179
|
+
for (let i = 0, l = volumes.length; i < l; i++) {
|
|
27180
|
+
const v = volumes[i];
|
|
27181
|
+
if (v.texture !== null && v.boundingBox.containsPoint(objectPosition)) return v;
|
|
27182
|
+
}
|
|
27183
|
+
return null;
|
|
27184
|
+
}
|
|
26958
27185
|
function setProgram(camera, scene, geometry, material, object) {
|
|
26959
27186
|
if (scene.isScene !== true) scene = _emptyScene;
|
|
26960
27187
|
textures.resetTextureUnits();
|
|
26961
27188
|
const fog = scene.fog;
|
|
26962
27189
|
const environment = material.isMeshStandardMaterial || material.isMeshLambertMaterial || material.isMeshPhongMaterial ? scene.environment : null;
|
|
26963
|
-
const colorSpace = _currentRenderTarget === null ? _this.outputColorSpace : _currentRenderTarget.isXRRenderTarget === true ? _currentRenderTarget.texture.colorSpace :
|
|
27190
|
+
const colorSpace = _currentRenderTarget === null ? _this.outputColorSpace : _currentRenderTarget.isXRRenderTarget === true ? _currentRenderTarget.texture.colorSpace : ColorManagement.workingColorSpace;
|
|
26964
27191
|
const usePMREM = material.isMeshStandardMaterial || material.isMeshLambertMaterial && !material.envMap || material.isMeshPhongMaterial && !material.envMap;
|
|
26965
27192
|
const envMap = environments.get(material.envMap || environment, usePMREM);
|
|
26966
27193
|
const vertexAlphas = material.vertexColors === true && !!geometry.attributes.color && geometry.attributes.color.itemSize === 4;
|
|
@@ -27034,6 +27261,8 @@ var WebGLRenderer = class {
|
|
|
27034
27261
|
needsProgramChange = true;
|
|
27035
27262
|
} else if (materialProperties.morphTargetsCount !== morphTargetsCount) {
|
|
27036
27263
|
needsProgramChange = true;
|
|
27264
|
+
} else if (!!materialProperties.lightProbeGrid !== currentRenderState.state.lightProbeGridArray.length > 0) {
|
|
27265
|
+
needsProgramChange = true;
|
|
27037
27266
|
}
|
|
27038
27267
|
} else {
|
|
27039
27268
|
needsProgramChange = true;
|
|
@@ -27042,6 +27271,9 @@ var WebGLRenderer = class {
|
|
|
27042
27271
|
let program = materialProperties.currentProgram;
|
|
27043
27272
|
if (needsProgramChange === true) {
|
|
27044
27273
|
program = getProgram(material, scene, object);
|
|
27274
|
+
if (_nodesHandler && material.isNodeMaterial) {
|
|
27275
|
+
_nodesHandler.onUpdateProgram(material, program, materialProperties);
|
|
27276
|
+
}
|
|
27045
27277
|
}
|
|
27046
27278
|
let refreshProgram = false;
|
|
27047
27279
|
let refreshMaterial = false;
|
|
@@ -27056,6 +27288,13 @@ var WebGLRenderer = class {
|
|
|
27056
27288
|
_currentMaterialId = material.id;
|
|
27057
27289
|
refreshMaterial = true;
|
|
27058
27290
|
}
|
|
27291
|
+
if (materialProperties.needsLights) {
|
|
27292
|
+
const objectVolume = findLightProbeGrid(currentRenderState.state.lightProbeGridArray, object);
|
|
27293
|
+
if (materialProperties.lightProbeGrid !== objectVolume) {
|
|
27294
|
+
materialProperties.lightProbeGrid = objectVolume;
|
|
27295
|
+
refreshMaterial = true;
|
|
27296
|
+
}
|
|
27297
|
+
}
|
|
27059
27298
|
if (refreshProgram || _currentCamera !== camera) {
|
|
27060
27299
|
const reversedDepthBuffer2 = state.buffers.depth.getReversed();
|
|
27061
27300
|
if (reversedDepthBuffer2 && camera.reversedDepth !== true) {
|
|
@@ -27137,6 +27376,13 @@ var WebGLRenderer = class {
|
|
|
27137
27376
|
materials.refreshFogUniforms(m_uniforms, fog);
|
|
27138
27377
|
}
|
|
27139
27378
|
materials.refreshMaterialUniforms(m_uniforms, material, _pixelRatio, _height, currentRenderState.state.transmissionRenderTarget[camera.id]);
|
|
27379
|
+
if (materialProperties.needsLights && materialProperties.lightProbeGrid) {
|
|
27380
|
+
const volume = materialProperties.lightProbeGrid;
|
|
27381
|
+
m_uniforms.probesSH.value = volume.texture;
|
|
27382
|
+
m_uniforms.probesMin.value.copy(volume.boundingBox.min);
|
|
27383
|
+
m_uniforms.probesMax.value.copy(volume.boundingBox.max);
|
|
27384
|
+
m_uniforms.probesResolution.value.copy(volume.resolution);
|
|
27385
|
+
}
|
|
27140
27386
|
WebGLUniforms.upload(_gl, getUniformList(materialProperties), m_uniforms, textures);
|
|
27141
27387
|
}
|
|
27142
27388
|
if (material.isShaderMaterial && material.uniformsNeedUpdate === true) {
|
|
@@ -27149,7 +27395,7 @@ var WebGLRenderer = class {
|
|
|
27149
27395
|
p_uniforms.setValue(_gl, "modelViewMatrix", object.modelViewMatrix);
|
|
27150
27396
|
p_uniforms.setValue(_gl, "normalMatrix", object.normalMatrix);
|
|
27151
27397
|
p_uniforms.setValue(_gl, "modelMatrix", object.matrixWorld);
|
|
27152
|
-
if (material.
|
|
27398
|
+
if (material.uniformsGroups !== void 0) {
|
|
27153
27399
|
const groups = material.uniformsGroups;
|
|
27154
27400
|
for (let i = 0, l = groups.length; i < l; i++) {
|
|
27155
27401
|
const group = groups[i];
|
|
@@ -27418,19 +27664,20 @@ var WebGLRenderer = class {
|
|
|
27418
27664
|
textures.setTexture2D(dstTexture, 0);
|
|
27419
27665
|
glTarget = _gl.TEXTURE_2D;
|
|
27420
27666
|
}
|
|
27421
|
-
|
|
27422
|
-
|
|
27423
|
-
|
|
27424
|
-
|
|
27425
|
-
const
|
|
27426
|
-
const
|
|
27427
|
-
const
|
|
27428
|
-
const
|
|
27429
|
-
|
|
27430
|
-
|
|
27431
|
-
|
|
27432
|
-
|
|
27433
|
-
|
|
27667
|
+
state.activeTexture(_gl.TEXTURE0);
|
|
27668
|
+
state.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY);
|
|
27669
|
+
state.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha);
|
|
27670
|
+
state.pixelStorei(_gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment);
|
|
27671
|
+
const currentUnpackRowLen = state.getParameter(_gl.UNPACK_ROW_LENGTH);
|
|
27672
|
+
const currentUnpackImageHeight = state.getParameter(_gl.UNPACK_IMAGE_HEIGHT);
|
|
27673
|
+
const currentUnpackSkipPixels = state.getParameter(_gl.UNPACK_SKIP_PIXELS);
|
|
27674
|
+
const currentUnpackSkipRows = state.getParameter(_gl.UNPACK_SKIP_ROWS);
|
|
27675
|
+
const currentUnpackSkipImages = state.getParameter(_gl.UNPACK_SKIP_IMAGES);
|
|
27676
|
+
state.pixelStorei(_gl.UNPACK_ROW_LENGTH, image.width);
|
|
27677
|
+
state.pixelStorei(_gl.UNPACK_IMAGE_HEIGHT, image.height);
|
|
27678
|
+
state.pixelStorei(_gl.UNPACK_SKIP_PIXELS, minX);
|
|
27679
|
+
state.pixelStorei(_gl.UNPACK_SKIP_ROWS, minY);
|
|
27680
|
+
state.pixelStorei(_gl.UNPACK_SKIP_IMAGES, minZ);
|
|
27434
27681
|
const isSrc3D = srcTexture.isDataArrayTexture || srcTexture.isData3DTexture;
|
|
27435
27682
|
const isDst3D = dstTexture.isDataArrayTexture || dstTexture.isData3DTexture;
|
|
27436
27683
|
if (srcTexture.isDepthTexture) {
|
|
@@ -27494,11 +27741,11 @@ var WebGLRenderer = class {
|
|
|
27494
27741
|
}
|
|
27495
27742
|
}
|
|
27496
27743
|
}
|
|
27497
|
-
|
|
27498
|
-
|
|
27499
|
-
|
|
27500
|
-
|
|
27501
|
-
|
|
27744
|
+
state.pixelStorei(_gl.UNPACK_ROW_LENGTH, currentUnpackRowLen);
|
|
27745
|
+
state.pixelStorei(_gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight);
|
|
27746
|
+
state.pixelStorei(_gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels);
|
|
27747
|
+
state.pixelStorei(_gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows);
|
|
27748
|
+
state.pixelStorei(_gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages);
|
|
27502
27749
|
if (dstLevel === 0 && dstTexture.generateMipmaps) {
|
|
27503
27750
|
_gl.generateMipmap(glTarget);
|
|
27504
27751
|
}
|
|
@@ -27703,7 +27950,7 @@ var OrbitControls = class extends Controls {
|
|
|
27703
27950
|
this.stopListenToKeyEvents();
|
|
27704
27951
|
const document2 = this.domElement.getRootNode();
|
|
27705
27952
|
document2.removeEventListener("keydown", this._interceptControlDown, { capture: true });
|
|
27706
|
-
this.domElement.style.touchAction = "
|
|
27953
|
+
this.domElement.style.touchAction = "";
|
|
27707
27954
|
}
|
|
27708
27955
|
dispose() {
|
|
27709
27956
|
this.disconnect();
|