@vived/component-abb-6700 1.0.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/.todo.md +13 -0
- package/README.md +122 -0
- package/dist/.gitkeep +0 -0
- package/dist/Adapters/aBB6700PMAdapter.d.ts +10 -0
- package/dist/Adapters/aBB6700PMAdapter.d.ts.map +1 -0
- package/dist/Controllers/createABB6700.d.ts +12 -0
- package/dist/Controllers/createABB6700.d.ts.map +1 -0
- package/dist/Controllers/getPose.d.ts +11 -0
- package/dist/Controllers/getPose.d.ts.map +1 -0
- package/dist/Controllers/setJointAngle.d.ts +12 -0
- package/dist/Controllers/setJointAngle.d.ts.map +1 -0
- package/dist/Controllers/setPose.d.ts +11 -0
- package/dist/Controllers/setPose.d.ts.map +1 -0
- package/dist/Entities/ABB6700Entity.d.ts +35 -0
- package/dist/Entities/ABB6700Entity.d.ts.map +1 -0
- package/dist/Entities/ABB6700Repo.d.ts +32 -0
- package/dist/Entities/ABB6700Repo.d.ts.map +1 -0
- package/dist/Factory/ABB6700FeatureFactory.d.ts +26 -0
- package/dist/Factory/ABB6700FeatureFactory.d.ts.map +1 -0
- package/dist/Mocks/MockABB6700PM.d.ts +11 -0
- package/dist/Mocks/MockABB6700PM.d.ts.map +1 -0
- package/dist/Mocks/MockSetJointAngleUC.d.ts +7 -0
- package/dist/Mocks/MockSetJointAngleUC.d.ts.map +1 -0
- package/dist/Mocks/MockSetPoseUC.d.ts +7 -0
- package/dist/Mocks/MockSetPoseUC.d.ts.map +1 -0
- package/dist/PMs/ABB6700PM.d.ts +32 -0
- package/dist/PMs/ABB6700PM.d.ts.map +1 -0
- package/dist/UCs/CalcStabilizerUC.d.ts +7 -0
- package/dist/UCs/CalcStabilizerUC.d.ts.map +1 -0
- package/dist/UCs/SetJointAngleUC.d.ts +15 -0
- package/dist/UCs/SetJointAngleUC.d.ts.map +1 -0
- package/dist/UCs/SetPoseUC.d.ts +22 -0
- package/dist/UCs/SetPoseUC.d.ts.map +1 -0
- package/dist/Views/ABB6700BabylonView.d.ts +27 -0
- package/dist/Views/ABB6700BabylonView.d.ts.map +1 -0
- package/dist/abb_6700.glb +0 -0
- package/dist/abstractAudioBus-CyBWsmuN.js +14 -0
- package/dist/animationGroup-BhNThqQe.js +1454 -0
- package/dist/basisTextureLoader-BT391BsV.js +310 -0
- package/dist/brdfTextureTools-DUyKBAXf.js +79 -0
- package/dist/bumpFragment-Dd-ojPA1.js +134 -0
- package/dist/bumpFragment-KE1_PuMl.js +287 -0
- package/dist/bumpVertex-BcdvVFVx.js +8 -0
- package/dist/bumpVertexDeclaration-B5Uvs-RS.js +8 -0
- package/dist/bumpVertexDeclaration-ixSg-yGI.js +8 -0
- package/dist/clipPlaneFragment-DJwQynjA.js +136 -0
- package/dist/clipPlaneVertex-D4Wk50XG.js +376 -0
- package/dist/clipPlaneVertex-eQ147Tn2.js +350 -0
- package/dist/component.config.d.ts +17 -0
- package/dist/component.config.d.ts.map +1 -0
- package/dist/ddsTextureLoader-DeoF3iGO.js +331 -0
- package/dist/default.fragment-DKnTR9nY.js +548 -0
- package/dist/default.fragment-rIGWrUS5.js +486 -0
- package/dist/default.vertex-Bt5y1VyA.js +212 -0
- package/dist/default.vertex-Dext1liJ.js +224 -0
- package/dist/defaultUboDeclaration-BwslQZX8.js +11 -0
- package/dist/defaultUboDeclaration-DSXACgip.js +9 -0
- package/dist/easing-BAt0SO-B.js +163 -0
- package/dist/envTextureLoader-CBiW_Q-U.js +40 -0
- package/dist/exrTextureLoader-5SC6PKIA.js +740 -0
- package/dist/flowGraphApplyForceBlock-6e8-wcaw.js +32 -0
- package/dist/flowGraphApplyImpulseBlock-B27EZQow.js +32 -0
- package/dist/flowGraphArrayIndexBlock-DIUn5e4i.js +31 -0
- package/dist/flowGraphBezierCurveEasingBlock-BJmiHk40.js +25 -0
- package/dist/flowGraphBinaryOperationBlock-Bj7TANCc.js +25 -0
- package/dist/flowGraphBranchBlock-7CRvIKWc.js +19 -0
- package/dist/flowGraphCachedOperationBlock-CP1ZiuIB.js +26 -0
- package/dist/flowGraphCancelDelayBlock-DqtgzBGm.js +20 -0
- package/dist/flowGraphCodeExecutionBlock-CaYXCGqo.js +23 -0
- package/dist/flowGraphConditionalDataBlock-DJ7evX8_.js +28 -0
- package/dist/flowGraphConsoleLogBlock-cMkpqLzO.js +68 -0
- package/dist/flowGraphConstantBlock-JWybwT0A.js +28 -0
- package/dist/flowGraphContextBlock-CFDXHcbn.js +19 -0
- package/dist/flowGraphCounterBlock-B0uPkgw9.js +24 -0
- package/dist/flowGraphDataSwitchBlock-B0GSifvJ.js +27 -0
- package/dist/flowGraphDebounceBlock-CSw8zKym.js +24 -0
- package/dist/flowGraphDebugBlock-DiSR6Ahn.js +65 -0
- package/dist/flowGraphDoNBlock-C-48oQ2H.js +24 -0
- package/dist/flowGraphEasingBlock-DKUaE7Rp.js +50 -0
- package/dist/flowGraphFlipFlopBlock-DX5BGhMV.js +20 -0
- package/dist/flowGraphForLoopBlock-Di-Qwg23.js +27 -0
- package/dist/flowGraphFunctionReferenceBlock-D8X5TFsO.js +20 -0
- package/dist/flowGraphGLTFDataProvider-C4j7nPQv.js +16 -0
- package/dist/flowGraphGetAngularVelocityBlock-Cq-yTQ4D.js +31 -0
- package/dist/flowGraphGetAssetBlock-B36eioor.js +21 -0
- package/dist/flowGraphGetLinearVelocityBlock-MdrV0eUD.js +31 -0
- package/dist/flowGraphGetPhysicsMassPropertiesBlock-wXDZP1wM.js +30 -0
- package/dist/flowGraphGetPropertyBlock-eP0badwf.js +46 -0
- package/dist/flowGraphGetSoundVolumeBlock-D3gXGHXa.js +29 -0
- package/dist/flowGraphGetVariableBlock-C7-qZAec.js +31 -0
- package/dist/flowGraphIndexOfBlock-CC5l9n9P.js +31 -0
- package/dist/flowGraphInterpolationBlock-B6922jzt.js +50 -0
- package/dist/flowGraphIsKeyPressedBlock-X_iuiUOX.js +31 -0
- package/dist/flowGraphIsSoundPlayingBlock-DONQX8N8.js +29 -0
- package/dist/flowGraphJsonPointerParserBlock-DBH_gN8I.js +95 -0
- package/dist/flowGraphKeyDownEventBlock-D5T1Uyfv.js +26 -0
- package/dist/flowGraphKeyUpEventBlock-BPY_Kgkm.js +21 -0
- package/dist/flowGraphKeyboardEventBlock-C49fx3TC.js +20 -0
- package/dist/flowGraphMathBlocks-CkvrN3VJ.js +864 -0
- package/dist/flowGraphMathCombineExtractBlocks-QSjGlnoz.js +248 -0
- package/dist/flowGraphMatrixMathBlocks-B3D7Cz9p.js +117 -0
- package/dist/flowGraphMeshPickEventBlock-BBTz-taa.js +35 -0
- package/dist/flowGraphMultiGateBlock-BhY1y5BG.js +50 -0
- package/dist/flowGraphPauseAnimationBlock-CHZZXMbg.js +19 -0
- package/dist/flowGraphPauseSoundBlock-B7hMmJ0c.js +31 -0
- package/dist/flowGraphPhysicsCollisionEventBlock-CxoPpT-q.js +56 -0
- package/dist/flowGraphPlayAnimationBlock-DVAvIFux.js +99 -0
- package/dist/flowGraphPlaySoundBlock-DjHGrqbC.js +32 -0
- package/dist/flowGraphPointerDownEventBlock-qI-H0JST.js +31 -0
- package/dist/flowGraphPointerMoveEventBlock-DAi4VUyy.js +31 -0
- package/dist/flowGraphPointerOutEventBlock-CFtj68aC.js +21 -0
- package/dist/flowGraphPointerOverEventBlock-VxdHhFuu.js +23 -0
- package/dist/flowGraphPointerUpEventBlock-DRR1f07q.js +31 -0
- package/dist/flowGraphReceiveCustomEventBlock-B3bwdB66.js +52 -0
- package/dist/flowGraphSceneReadyEventBlock-Dy6lDT3j.js +23 -0
- package/dist/flowGraphSceneTickEventBlock-Bl9BF_Xw.js +32 -0
- package/dist/flowGraphSendCustomEventBlock-BAR4PGFq.js +35 -0
- package/dist/flowGraphSequenceBlock-veqU32ZZ.js +32 -0
- package/dist/flowGraphSetAngularVelocityBlock-Dj9b-zu6.js +31 -0
- package/dist/flowGraphSetDelayBlock-CMjudtvk.js +131 -0
- package/dist/flowGraphSetLinearVelocityBlock-DVDhhJBd.js +31 -0
- package/dist/flowGraphSetPhysicsMotionTypeBlock-CL3cxNCO.js +36 -0
- package/dist/flowGraphSetPropertyBlock-D3sWL3Ss.js +47 -0
- package/dist/flowGraphSetSoundVolumeBlock-CxVk45yR.js +32 -0
- package/dist/flowGraphSetVariableBlock-D1oJiwLj.js +47 -0
- package/dist/flowGraphSoundEndedEventBlock-CubEwii0.js +47 -0
- package/dist/flowGraphStopAnimationBlock-B9inwIQx.js +48 -0
- package/dist/flowGraphStopSoundBlock-BijIX2jC.js +31 -0
- package/dist/flowGraphSwitchBlock-BMhPb4OX.js +54 -0
- package/dist/flowGraphThrottleBlock-C7vrnkb1.js +37 -0
- package/dist/flowGraphTransformCoordinatesSystemBlock-DoISqaUG.js +29 -0
- package/dist/flowGraphTypeToTypeBlocks-CSML6QWx.js +57 -0
- package/dist/flowGraphUnaryOperationBlock-B0Shf-lJ.js +24 -0
- package/dist/flowGraphVectorMathBlocks-DoTRR_E0.js +178 -0
- package/dist/flowGraphWaitAllBlock-BvmDMc24.js +54 -0
- package/dist/flowGraphWhileLoopBlock-BaIq4-K2.js +27 -0
- package/dist/geometry.fragment-Bsis3UG2.js +275 -0
- package/dist/geometry.vertex-DskQ5b8j.js +222 -0
- package/dist/harmonicsFunctions-CtNrRfir.js +193 -0
- package/dist/harmonicsFunctions-PEz6APC7.js +18 -0
- package/dist/hdrTextureLoader-D9rYxJ9q.js +112 -0
- package/dist/helperFunctions-Bt7Zfkrp.js +89 -0
- package/dist/helperFunctions-CPmRxd37.js +121 -0
- package/dist/iesTextureLoader-BGUFjVhI.js +93 -0
- package/dist/index-CS3Icp_r.js +67657 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/ktxTextureLoader-cUaGg9_L.js +459 -0
- package/dist/lightFragment-BRDibDKG.js +404 -0
- package/dist/lightFragment-DCqtGMp_.js +402 -0
- package/dist/logDepthDeclaration-Bwm-3KyB.js +16 -0
- package/dist/logDepthDeclaration-gUfeSnXX.js +20 -0
- package/dist/logDepthVertex-CKeuJ6ae.js +213 -0
- package/dist/logDepthVertex-CXkmZels.js +459 -0
- package/dist/mesh.vertexData.functions-Bc9lJlrU.js +74 -0
- package/dist/oitFragment-B8zuQigp.js +792 -0
- package/dist/oitFragment-DH3h3T6x.js +657 -0
- package/dist/openpbr.fragment-BglYS6LA.js +1405 -0
- package/dist/openpbr.fragment-DrOTZs4m.js +1553 -0
- package/dist/openpbr.vertex-B-PaLFOR.js +384 -0
- package/dist/openpbr.vertex-DMdFRTnX.js +268 -0
- package/dist/openpbrMaterial-HCU0aOca.js +2880 -0
- package/dist/openpbrMaterialLoadingAdapter-CWRAa-7S.js +1122 -0
- package/dist/openpbrTransmissionLayerData-CfDVObj5.js +352 -0
- package/dist/openpbrUboDeclaration-CA2pvSbt.js +9 -0
- package/dist/openpbrUboDeclaration-xU8VOaib.js +10 -0
- package/dist/pass.fragment-1mMP54bb.js +10 -0
- package/dist/pass.fragment-DzaUp_jk.js +10 -0
- package/dist/passCube.fragment-CQaXS7g3.js +29 -0
- package/dist/passCube.fragment-QJGPwAXI.js +29 -0
- package/dist/pbr.fragment-BnaAAGxb.js +2775 -0
- package/dist/pbr.fragment-CYZk_EGU.js +2619 -0
- package/dist/pbr.vertex-CyvdCw91.js +372 -0
- package/dist/pbr.vertex-DJMAkDxs.js +270 -0
- package/dist/pbrBRDFFunctions-EugoWm6O.js +175 -0
- package/dist/pbrDebug-Bk3sPoEG.js +719 -0
- package/dist/pbrDebug-Cdalzb1I.js +614 -0
- package/dist/pbrIBLFunctions-B0bVAXCF.js +47 -0
- package/dist/pbrIBLFunctions-C06z-ouZ.js +51 -0
- package/dist/pbrMaterial-C4FCKBZQ.js +1660 -0
- package/dist/pbrMaterialLoadingAdapter-BGHlS_ZN.js +1032 -0
- package/dist/pbrUboDeclaration-1lN5_-Bw.js +9 -0
- package/dist/pbrUboDeclaration-BJOUUOZ2.js +10 -0
- package/dist/procedural.vertex-CFPKczKj.js +14 -0
- package/dist/procedural.vertex-DUW7bYZt.js +13 -0
- package/dist/rgbdDecode.fragment-CEGgE4tL.js +8 -0
- package/dist/rgbdDecode.fragment-FT0wkgah.js +8 -0
- package/dist/rgbdEncode.fragment-CLnJJf6E.js +8 -0
- package/dist/rgbdEncode.fragment-CaAcMsY9.js +8 -0
- package/dist/sceneUboDeclaration-B6oxsfcj.js +8 -0
- package/dist/sceneUboDeclaration-JByfVKik.js +13 -0
- package/dist/setupABB6700InstanceFactory.d.ts +7 -0
- package/dist/setupABB6700InstanceFactory.d.ts.map +1 -0
- package/dist/studio.env +0 -0
- package/dist/textureProcessor.fragment-BYPw6SMQ.js +152 -0
- package/dist/textureProcessor.fragment-Ciw9-F3w.js +157 -0
- package/dist/textureTools-Cct_bGgp.js +40 -0
- package/dist/tgaTextureLoader-BJOIdnFr.js +198 -0
- package/dist/thinEngine-Bt9FW4dD.js +2425 -0
- package/dist/webAudioBus-BUzRHSxr.js +88 -0
- package/dist/webAudioMainBus-Dds1TgJG.js +49 -0
- package/package.json +49 -0
|
@@ -0,0 +1,2880 @@
|
|
|
1
|
+
import { a7 as se, a1 as Re, aL as ke, b4 as re, b0 as B, z as ge, bh as G, aa as H, au as De, ar as ze, aH as Xe, aB as Ye, ad as Ze, t as Ke, m as Pe, s as Ue, a8 as k, aD as Be, g as Ve, bz as $e, be as ae, y as K, bg as je, b1 as Qe, b9 as qe, al as Se, aZ as Ae, j as Je, aC as et, b8 as X, ab as ce, l as tt, v as it, u as st, o as rt, p as nt, q as at, n as ot, r as lt, J as ut, Z as ft, ao as ct, ap as ht, aq as dt, an as _t, aF as Tt, _ as he, aE as mt, av as pt, ay as Et, aA as Rt, az as gt, aw as St, ax as At, at as It, as as xt, a0 as vt, aI as Lt, $ as Ct, aG as Mt, ba as bt, a9 as Ot, bC as o, bK as d, c6 as D, bS as P, aK as Nt } from "./index-CS3Icp_r.js";
|
|
2
|
+
import { b as Ft, a as Ie } from "./brdfTextureTools-DUyKBAXf.js";
|
|
3
|
+
import { ThinEngine as J } from "./thinEngine-Bt9FW4dD.js";
|
|
4
|
+
import "./bumpFragment-KE1_PuMl.js";
|
|
5
|
+
import "./helperFunctions-CPmRxd37.js";
|
|
6
|
+
import "./pbrIBLFunctions-C06z-ouZ.js";
|
|
7
|
+
import "./sceneUboDeclaration-B6oxsfcj.js";
|
|
8
|
+
import "./harmonicsFunctions-CtNrRfir.js";
|
|
9
|
+
import "./clipPlaneVertex-eQ147Tn2.js";
|
|
10
|
+
function yt(p) {
|
|
11
|
+
return class extends p {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments), this.REFLECTION = !1, this.REFLECTIONMAP_3D = !1, this.REFLECTIONMAP_SPHERICAL = !1, this.REFLECTIONMAP_PLANAR = !1, this.REFLECTIONMAP_CUBIC = !1, this.USE_LOCAL_REFLECTIONMAP_CUBIC = !1, this.REFLECTIONMAP_PROJECTION = !1, this.REFLECTIONMAP_SKYBOX = !1, this.REFLECTIONMAP_EXPLICIT = !1, this.REFLECTIONMAP_EQUIRECTANGULAR = !1, this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1, this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1, this.INVERTCUBICMAP = !1, this.USESPHERICALFROMREFLECTIONMAP = !1, this.USEIRRADIANCEMAP = !1, this.USE_IRRADIANCE_DOMINANT_DIRECTION = !1, this.USESPHERICALINVERTEX = !1, this.REFLECTIONMAP_OPPOSITEZ = !1, this.LODINREFLECTIONALPHA = !1, this.GAMMAREFLECTION = !1, this.RGBDREFLECTION = !1;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
J.prototype.restoreSingleAttachment = function() {
|
|
18
|
+
const p = this._gl;
|
|
19
|
+
this.bindAttachments([p.BACK]);
|
|
20
|
+
};
|
|
21
|
+
J.prototype.restoreSingleAttachmentForRenderTarget = function() {
|
|
22
|
+
const p = this._gl;
|
|
23
|
+
this.bindAttachments([p.COLOR_ATTACHMENT0]);
|
|
24
|
+
};
|
|
25
|
+
J.prototype.buildTextureLayout = function(p, t = !1) {
|
|
26
|
+
const s = this._gl, e = [];
|
|
27
|
+
if (t)
|
|
28
|
+
e.push(s.BACK);
|
|
29
|
+
else
|
|
30
|
+
for (let i = 0; i < p.length; i++)
|
|
31
|
+
p[i] ? e.push(s["COLOR_ATTACHMENT" + i]) : e.push(s.NONE);
|
|
32
|
+
return e;
|
|
33
|
+
};
|
|
34
|
+
J.prototype.bindAttachments = function(p) {
|
|
35
|
+
this._gl.drawBuffers(p);
|
|
36
|
+
};
|
|
37
|
+
J.prototype.unBindMultiColorAttachmentFramebuffer = function(p, t = !1, s) {
|
|
38
|
+
this._currentRenderTarget = null, p.disableAutomaticMSAAResolve || this.resolveMultiFramebuffer(p), t || this.generateMipMapsMultiFramebuffer(p), s && (p._MSAAFramebuffer && this._bindUnboundFramebuffer(p._framebuffer), s()), this._bindUnboundFramebuffer(null);
|
|
39
|
+
};
|
|
40
|
+
J.prototype.createMultipleRenderTarget = function(p, t, s = !0) {
|
|
41
|
+
let e = !1, i = !0, n = !1, a = !1, f, I = 1, L = 1;
|
|
42
|
+
const h = 0, u = 3, A = !1, N = 5, x = 3553;
|
|
43
|
+
let M = [], R = [], T = [], m = [], F = [], y = [], S = [], c = [], Y = [], Z = !1;
|
|
44
|
+
const U = this._createHardwareRenderTargetWrapper(!0, !1, p);
|
|
45
|
+
t !== void 0 && (e = t.generateMipMaps === void 0 ? !1 : t.generateMipMaps, i = t.generateDepthBuffer === void 0 ? !0 : t.generateDepthBuffer, n = t.generateStencilBuffer === void 0 ? !1 : t.generateStencilBuffer, a = t.generateDepthTexture === void 0 ? !1 : t.generateDepthTexture, I = t.textureCount ?? 1, L = t.samples ?? L, M = t.types || M, R = t.samplingModes || R, T = t.useSRGBBuffers || T, m = t.formats || m, F = t.targetTypes || F, y = t.faceIndex || y, S = t.layerIndex || S, c = t.layerCounts || c, Y = t.labels || Y, Z = t.dontCreateTextures ?? !1, this.webGLVersion > 1 && (t.depthTextureFormat === 13 || t.depthTextureFormat === 17 || t.depthTextureFormat === 16 || t.depthTextureFormat === 14 || t.depthTextureFormat === 18) && (f = t.depthTextureFormat)), f === void 0 && (f = n ? 13 : 14);
|
|
46
|
+
const _ = this._gl, l = this._currentFramebuffer, ee = _.createFramebuffer();
|
|
47
|
+
this._bindUnboundFramebuffer(ee);
|
|
48
|
+
const $ = p.width ?? p, E = p.height ?? p, j = [], g = [], w = this.webGLVersion > 1 && (f === 13 || f === 17 || f === 18);
|
|
49
|
+
U.label = t?.label ?? "MultiRenderTargetWrapper", U._framebuffer = ee, U._generateDepthBuffer = a || i, U._generateStencilBuffer = a ? w : n, U._depthStencilBuffer = this._setupFramebufferDepthAttachments(U._generateStencilBuffer, U._generateDepthBuffer, $, E, 1, f), U._attachments = g;
|
|
50
|
+
for (let b = 0; b < I; b++) {
|
|
51
|
+
let Q = R[b] || u, z = M[b] || h, te = T[b] || A;
|
|
52
|
+
const q = m[b] || N, W = F[b] || x, me = c[b] ?? 1;
|
|
53
|
+
(z === 1 && !this._caps.textureFloatLinearFiltering || z === 2 && !this._caps.textureHalfFloatLinearFiltering) && (Q = 1);
|
|
54
|
+
const pe = this._getSamplingParameters(Q, e);
|
|
55
|
+
z === 1 && !this._caps.textureFloat && (z = 0, se.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")), te = te && this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || this.isWebGPU);
|
|
56
|
+
const Ee = this.webGLVersion > 1, He = _[Ee ? "COLOR_ATTACHMENT" + b : "COLOR_ATTACHMENT" + b + "_WEBGL"];
|
|
57
|
+
if (g.push(He), W === -1 || Z)
|
|
58
|
+
continue;
|
|
59
|
+
const V = new Re(
|
|
60
|
+
this,
|
|
61
|
+
6
|
|
62
|
+
/* InternalTextureSource.MultiRenderTarget */
|
|
63
|
+
);
|
|
64
|
+
j[b] = V, _.activeTexture(_["TEXTURE" + b]), _.bindTexture(W, V._hardwareTexture.underlyingResource), _.texParameteri(W, _.TEXTURE_MAG_FILTER, pe.mag), _.texParameteri(W, _.TEXTURE_MIN_FILTER, pe.min), _.texParameteri(W, _.TEXTURE_WRAP_S, _.CLAMP_TO_EDGE), _.texParameteri(W, _.TEXTURE_WRAP_T, _.CLAMP_TO_EDGE);
|
|
65
|
+
const oe = this._getRGBABufferInternalSizedFormat(z, q, te), le = this._getInternalFormat(q), ue = this._getWebGLTextureType(z);
|
|
66
|
+
if (Ee && (W === 35866 || W === 32879))
|
|
67
|
+
W === 35866 ? V.is2DArray = !0 : V.is3D = !0, V.baseDepth = V.depth = me, _.texImage3D(W, 0, oe, $, E, me, 0, le, ue, null);
|
|
68
|
+
else if (W === 34067) {
|
|
69
|
+
for (let fe = 0; fe < 6; fe++)
|
|
70
|
+
_.texImage2D(_.TEXTURE_CUBE_MAP_POSITIVE_X + fe, 0, oe, $, E, 0, le, ue, null);
|
|
71
|
+
V.isCube = !0;
|
|
72
|
+
} else
|
|
73
|
+
_.texImage2D(_.TEXTURE_2D, 0, oe, $, E, 0, le, ue, null);
|
|
74
|
+
e && _.generateMipmap(W), this._bindTextureDirectly(W, null), V.baseWidth = $, V.baseHeight = E, V.width = $, V.height = E, V.isReady = !0, V.samples = 1, V.generateMipMaps = e, V.samplingMode = Q, V.type = z, V._useSRGBBuffer = te, V.format = q, V.label = Y[b] ?? U.label + "-Texture" + b, this._internalTexturesCache.push(V);
|
|
75
|
+
}
|
|
76
|
+
if (a && this._caps.depthTextureExtension && !Z) {
|
|
77
|
+
const b = new Re(
|
|
78
|
+
this,
|
|
79
|
+
14
|
|
80
|
+
/* InternalTextureSource.Depth */
|
|
81
|
+
);
|
|
82
|
+
let Q = 5, z = _.DEPTH_COMPONENT16, te = _.DEPTH_COMPONENT, q = _.UNSIGNED_SHORT, W = _.DEPTH_ATTACHMENT;
|
|
83
|
+
this.webGLVersion < 2 ? z = _.DEPTH_COMPONENT : f === 14 ? (Q = 1, q = _.FLOAT, z = _.DEPTH_COMPONENT32F) : f === 18 ? (Q = 0, q = _.FLOAT_32_UNSIGNED_INT_24_8_REV, z = _.DEPTH32F_STENCIL8, te = _.DEPTH_STENCIL, W = _.DEPTH_STENCIL_ATTACHMENT) : f === 16 ? (Q = 0, q = _.UNSIGNED_INT, z = _.DEPTH_COMPONENT24, W = _.DEPTH_ATTACHMENT) : (f === 13 || f === 17) && (Q = 12, q = _.UNSIGNED_INT_24_8, z = _.DEPTH24_STENCIL8, te = _.DEPTH_STENCIL, W = _.DEPTH_STENCIL_ATTACHMENT), this._bindTextureDirectly(_.TEXTURE_2D, b, !0), _.texParameteri(_.TEXTURE_2D, _.TEXTURE_MAG_FILTER, _.NEAREST), _.texParameteri(_.TEXTURE_2D, _.TEXTURE_MIN_FILTER, _.NEAREST), _.texParameteri(_.TEXTURE_2D, _.TEXTURE_WRAP_S, _.CLAMP_TO_EDGE), _.texParameteri(_.TEXTURE_2D, _.TEXTURE_WRAP_T, _.CLAMP_TO_EDGE), _.texImage2D(_.TEXTURE_2D, 0, z, $, E, 0, te, q, null), _.framebufferTexture2D(_.FRAMEBUFFER, W, _.TEXTURE_2D, b._hardwareTexture.underlyingResource, 0), this._bindTextureDirectly(_.TEXTURE_2D, null), U._depthStencilTexture = b, U._depthStencilTextureWithStencil = w, b.baseWidth = $, b.baseHeight = E, b.width = $, b.height = E, b.isReady = !0, b.samples = 1, b.generateMipMaps = e, b.samplingMode = 1, b.format = f, b.type = Q, b.label = U.label + "-DepthStencil", j[I] = b, this._internalTexturesCache.push(b);
|
|
84
|
+
}
|
|
85
|
+
if (U.setTextures(j), s && _.drawBuffers(g), this._bindUnboundFramebuffer(l), U.setLayerAndFaceIndices(S, y), this.resetTextureCache(), !Z)
|
|
86
|
+
this.updateMultipleRenderTargetTextureSampleCount(U, L, s);
|
|
87
|
+
else if (L > 1) {
|
|
88
|
+
const b = _.createFramebuffer();
|
|
89
|
+
if (!b)
|
|
90
|
+
throw new Error("Unable to create multi sampled framebuffer");
|
|
91
|
+
U._samples = L, U._MSAAFramebuffer = b, I > 0 && s && (this._bindUnboundFramebuffer(b), _.drawBuffers(g), this._bindUnboundFramebuffer(l));
|
|
92
|
+
}
|
|
93
|
+
return U;
|
|
94
|
+
};
|
|
95
|
+
J.prototype.updateMultipleRenderTargetTextureSampleCount = function(p, t, s = !0) {
|
|
96
|
+
if (this.webGLVersion < 2 || !p)
|
|
97
|
+
return 1;
|
|
98
|
+
if (p.samples === t)
|
|
99
|
+
return t;
|
|
100
|
+
const e = this._gl;
|
|
101
|
+
t = Math.min(t, this.getCaps().maxMSAASamples), p._depthStencilBuffer && (e.deleteRenderbuffer(p._depthStencilBuffer), p._depthStencilBuffer = null), p._MSAAFramebuffer && (e.deleteFramebuffer(p._MSAAFramebuffer), p._MSAAFramebuffer = null);
|
|
102
|
+
const i = p._attachments.length;
|
|
103
|
+
for (let a = 0; a < i; a++)
|
|
104
|
+
p.textures[a]._hardwareTexture?.releaseMSAARenderBuffers();
|
|
105
|
+
if (t > 1 && typeof e.renderbufferStorageMultisample == "function") {
|
|
106
|
+
const a = e.createFramebuffer();
|
|
107
|
+
if (!a)
|
|
108
|
+
throw new Error("Unable to create multi sampled framebuffer");
|
|
109
|
+
p._MSAAFramebuffer = a, this._bindUnboundFramebuffer(a);
|
|
110
|
+
const f = [];
|
|
111
|
+
for (let I = 0; I < i; I++) {
|
|
112
|
+
const L = p.textures[I], h = L._hardwareTexture, u = e[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + I : "COLOR_ATTACHMENT" + I + "_WEBGL"], A = this._createRenderBuffer(L.width, L.height, t, -1, this._getRGBABufferInternalSizedFormat(L.type, L.format, L._useSRGBBuffer), u);
|
|
113
|
+
if (!A)
|
|
114
|
+
throw new Error("Unable to create multi sampled framebuffer");
|
|
115
|
+
h.addMSAARenderBuffer(A), L.samples = t, f.push(u);
|
|
116
|
+
}
|
|
117
|
+
s && e.drawBuffers(f);
|
|
118
|
+
} else
|
|
119
|
+
this._bindUnboundFramebuffer(p._framebuffer);
|
|
120
|
+
const n = p._depthStencilTexture ? p._depthStencilTexture.format : void 0;
|
|
121
|
+
return p._depthStencilBuffer = this._setupFramebufferDepthAttachments(p._generateStencilBuffer, p._generateDepthBuffer, p.width, p.height, t, n), this._bindUnboundFramebuffer(null), p._samples = t, t;
|
|
122
|
+
};
|
|
123
|
+
J.prototype.generateMipMapsMultiFramebuffer = function(p) {
|
|
124
|
+
const t = p, s = this._gl;
|
|
125
|
+
if (t.isMulti)
|
|
126
|
+
for (let e = 0; e < t._attachments.length; e++) {
|
|
127
|
+
const i = t.textures[e];
|
|
128
|
+
i?.generateMipMaps && !i?.isCube && !i?.is3D && (this._bindTextureDirectly(s.TEXTURE_2D, i, !0), s.generateMipmap(s.TEXTURE_2D), this._bindTextureDirectly(s.TEXTURE_2D, null));
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
J.prototype.resolveMultiFramebuffer = function(p) {
|
|
132
|
+
const t = p, s = this._gl;
|
|
133
|
+
if (!t._MSAAFramebuffer || !t.isMulti)
|
|
134
|
+
return;
|
|
135
|
+
let e = t.resolveMSAAColors ? s.COLOR_BUFFER_BIT : 0;
|
|
136
|
+
e |= t._generateDepthBuffer && t.resolveMSAADepth ? s.DEPTH_BUFFER_BIT : 0, e |= t._generateStencilBuffer && t.resolveMSAAStencil ? s.STENCIL_BUFFER_BIT : 0;
|
|
137
|
+
const i = t._attachments, n = i.length;
|
|
138
|
+
s.bindFramebuffer(s.READ_FRAMEBUFFER, t._MSAAFramebuffer), s.bindFramebuffer(s.DRAW_FRAMEBUFFER, t._framebuffer);
|
|
139
|
+
for (let a = 0; a < n; a++) {
|
|
140
|
+
const f = t.textures[a];
|
|
141
|
+
for (let I = 0; I < n; I++)
|
|
142
|
+
i[I] = s.NONE;
|
|
143
|
+
i[a] = s[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + a : "COLOR_ATTACHMENT" + a + "_WEBGL"], s.readBuffer(i[a]), s.drawBuffers(i), s.blitFramebuffer(0, 0, f.width, f.height, 0, 0, f.width, f.height, e, s.NEAREST);
|
|
144
|
+
}
|
|
145
|
+
for (let a = 0; a < n; a++)
|
|
146
|
+
i[a] = s[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + a : "COLOR_ATTACHMENT" + a + "_WEBGL"];
|
|
147
|
+
s.drawBuffers(i), s.bindFramebuffer(this._gl.FRAMEBUFFER, t._MSAAFramebuffer);
|
|
148
|
+
};
|
|
149
|
+
class Dt extends ke {
|
|
150
|
+
/**
|
|
151
|
+
* Get if draw buffers (render textures) are currently supported by the used hardware and browser.
|
|
152
|
+
*/
|
|
153
|
+
get isSupported() {
|
|
154
|
+
return this._engine?.getCaps().drawBuffersExtension ?? !1;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Get the list of textures generated by the multi render target.
|
|
158
|
+
*/
|
|
159
|
+
get textures() {
|
|
160
|
+
return this._textures;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
|
|
164
|
+
*/
|
|
165
|
+
get count() {
|
|
166
|
+
return this._count;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
|
|
170
|
+
*/
|
|
171
|
+
get depthTexture() {
|
|
172
|
+
return this._textures[this._textures.length - 1];
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Set the wrapping mode on U of all the textures we are rendering to.
|
|
176
|
+
* Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
|
|
177
|
+
*/
|
|
178
|
+
set wrapU(t) {
|
|
179
|
+
if (this._textures)
|
|
180
|
+
for (let s = 0; s < this._textures.length; s++)
|
|
181
|
+
this._textures[s].wrapU = t;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Set the wrapping mode on V of all the textures we are rendering to.
|
|
185
|
+
* Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
|
|
186
|
+
*/
|
|
187
|
+
set wrapV(t) {
|
|
188
|
+
if (this._textures)
|
|
189
|
+
for (let s = 0; s < this._textures.length; s++)
|
|
190
|
+
this._textures[s].wrapV = t;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Instantiate a new multi render target texture.
|
|
194
|
+
* A multi render target, like a render target provides the ability to render to a texture.
|
|
195
|
+
* Unlike the render target, it can render to several draw buffers (render textures) in one draw.
|
|
196
|
+
* This is specially interesting in deferred rendering or for any effects requiring more than
|
|
197
|
+
* just one color from a single pass.
|
|
198
|
+
* @param name Define the name of the texture
|
|
199
|
+
* @param size Define the size of the buffers to render to
|
|
200
|
+
* @param count Define the number of target we are rendering into
|
|
201
|
+
* @param scene Define the scene the texture belongs to
|
|
202
|
+
* @param options Define the options used to create the multi render target
|
|
203
|
+
* @param textureNames Define the names to set to the textures (if count \> 0 - optional)
|
|
204
|
+
*/
|
|
205
|
+
constructor(t, s, e, i, n, a) {
|
|
206
|
+
const f = n && n.generateMipMaps ? n.generateMipMaps : !1, I = n && n.generateDepthTexture ? n.generateDepthTexture : !1, L = n && n.depthTextureFormat ? n.depthTextureFormat : 15, h = !n || n.doNotChangeAspectRatio === void 0 ? !0 : n.doNotChangeAspectRatio, u = n && n.drawOnlyOnFirstAttachmentByDefault ? n.drawOnlyOnFirstAttachmentByDefault : !1;
|
|
207
|
+
if (super(t, s, i, f, h, void 0, void 0, void 0, void 0, void 0, void 0, void 0, !0), !this.isSupported) {
|
|
208
|
+
this.dispose();
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
this._textureNames = a;
|
|
212
|
+
const A = [], N = [], x = [], M = [], R = [], T = [], m = [], F = [];
|
|
213
|
+
this._initTypes(e, A, N, x, M, R, T, m, F, n);
|
|
214
|
+
const y = !n || n.generateDepthBuffer === void 0 ? !0 : n.generateDepthBuffer, S = !n || n.generateStencilBuffer === void 0 ? !1 : n.generateStencilBuffer, c = n && n.samples ? n.samples : 1;
|
|
215
|
+
this._multiRenderTargetOptions = {
|
|
216
|
+
samplingModes: N,
|
|
217
|
+
generateMipMaps: f,
|
|
218
|
+
generateDepthBuffer: y,
|
|
219
|
+
generateStencilBuffer: S,
|
|
220
|
+
generateDepthTexture: I,
|
|
221
|
+
depthTextureFormat: L,
|
|
222
|
+
types: A,
|
|
223
|
+
textureCount: e,
|
|
224
|
+
useSRGBBuffers: x,
|
|
225
|
+
samples: c,
|
|
226
|
+
formats: M,
|
|
227
|
+
targetTypes: R,
|
|
228
|
+
faceIndex: T,
|
|
229
|
+
layerIndex: m,
|
|
230
|
+
layerCounts: F,
|
|
231
|
+
labels: a,
|
|
232
|
+
label: t
|
|
233
|
+
}, this._count = e, this._drawOnlyOnFirstAttachmentByDefault = u, e > 0 && (this._createInternalTextures(), this._createTextures(a));
|
|
234
|
+
}
|
|
235
|
+
_initTypes(t, s, e, i, n, a, f, I, L, h) {
|
|
236
|
+
for (let u = 0; u < t; u++)
|
|
237
|
+
h && h.types && h.types[u] !== void 0 ? s.push(h.types[u]) : s.push(h && h.defaultType ? h.defaultType : 0), h && h.samplingModes && h.samplingModes[u] !== void 0 ? e.push(h.samplingModes[u]) : e.push(re.BILINEAR_SAMPLINGMODE), h && h.useSRGBBuffers && h.useSRGBBuffers[u] !== void 0 ? i.push(h.useSRGBBuffers[u]) : i.push(!1), h && h.formats && h.formats[u] !== void 0 ? n.push(h.formats[u]) : n.push(5), h && h.targetTypes && h.targetTypes[u] !== void 0 ? a.push(h.targetTypes[u]) : a.push(3553), h && h.faceIndex && h.faceIndex[u] !== void 0 ? f.push(h.faceIndex[u]) : f.push(0), h && h.layerIndex && h.layerIndex[u] !== void 0 ? I.push(h.layerIndex[u]) : I.push(0), h && h.layerCounts && h.layerCounts[u] !== void 0 ? L.push(h.layerCounts[u]) : L.push(1);
|
|
238
|
+
}
|
|
239
|
+
_createInternaTextureIndexMapping() {
|
|
240
|
+
const t = {}, s = [];
|
|
241
|
+
if (!this._renderTarget)
|
|
242
|
+
return s;
|
|
243
|
+
const e = this._renderTarget.textures;
|
|
244
|
+
for (let i = 0; i < e.length; i++) {
|
|
245
|
+
const n = e[i];
|
|
246
|
+
if (!n)
|
|
247
|
+
continue;
|
|
248
|
+
const a = t[n.uniqueId];
|
|
249
|
+
a !== void 0 ? s[i] = a : t[n.uniqueId] = i;
|
|
250
|
+
}
|
|
251
|
+
return s;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* @internal
|
|
255
|
+
*/
|
|
256
|
+
_rebuild(t = !1, s = !1, e) {
|
|
257
|
+
if (this._count < 1 || t)
|
|
258
|
+
return;
|
|
259
|
+
const i = this._createInternaTextureIndexMapping();
|
|
260
|
+
this.releaseInternalTextures(), this._createInternalTextures(), s && (this._releaseTextures(), this._createTextures(e));
|
|
261
|
+
const n = this._renderTarget.textures;
|
|
262
|
+
for (let a = 0; a < n.length; a++) {
|
|
263
|
+
const f = this._textures[a];
|
|
264
|
+
i[a] !== void 0 && this._renderTarget.setTexture(n[i[a]], a), f._texture = n[a], f._texture && (f._noMipmap = !f._texture.useMipMaps, f._useSRGBBuffer = f._texture._useSRGBBuffer);
|
|
265
|
+
}
|
|
266
|
+
this.samples !== 1 && this._renderTarget.setSamples(this.samples, !this._drawOnlyOnFirstAttachmentByDefault, !0);
|
|
267
|
+
}
|
|
268
|
+
_createInternalTextures() {
|
|
269
|
+
this._renderTarget = this._getEngine().createMultipleRenderTarget(this._size, this._multiRenderTargetOptions, !this._drawOnlyOnFirstAttachmentByDefault), this._texture = this._renderTarget.texture;
|
|
270
|
+
}
|
|
271
|
+
_releaseTextures() {
|
|
272
|
+
if (this._textures)
|
|
273
|
+
for (let t = 0; t < this._textures.length; t++)
|
|
274
|
+
this._textures[t]._texture = null, this._textures[t].dispose();
|
|
275
|
+
}
|
|
276
|
+
_createTextures(t) {
|
|
277
|
+
const s = this._renderTarget.textures;
|
|
278
|
+
this._textures = [];
|
|
279
|
+
for (let e = 0; e < s.length; e++) {
|
|
280
|
+
const i = new re(null, this.getScene());
|
|
281
|
+
t?.[e] && (i.name = t[e]), i._texture = s[e], i._texture && (i._noMipmap = !i._texture.useMipMaps, i._useSRGBBuffer = i._texture._useSRGBBuffer), this._textures.push(i);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Replaces an internal texture within the MRT. Useful to share textures between MultiRenderTarget.
|
|
286
|
+
* @param texture The new texture to set in the MRT
|
|
287
|
+
* @param index The index of the texture to replace
|
|
288
|
+
* @param disposePrevious Set to true if the previous internal texture should be disposed
|
|
289
|
+
*/
|
|
290
|
+
setInternalTexture(t, s, e = !0) {
|
|
291
|
+
if (this.renderTarget && (s === 0 && (this._texture = t), this.renderTarget.setTexture(t, s, e), this.textures[s] || (this.textures[s] = new re(null, this.getScene()), this.textures[s].name = this._textureNames?.[s] ?? this.textures[s].name), this.textures[s]._texture = t, this.textures[s]._noMipmap = !t.useMipMaps, this.textures[s]._useSRGBBuffer = t._useSRGBBuffer, this._count = this.renderTarget.textures ? this.renderTarget.textures.length : 0, this._multiRenderTargetOptions.types && (this._multiRenderTargetOptions.types[s] = t.type), this._multiRenderTargetOptions.samplingModes && (this._multiRenderTargetOptions.samplingModes[s] = t.samplingMode), this._multiRenderTargetOptions.useSRGBBuffers && (this._multiRenderTargetOptions.useSRGBBuffers[s] = t._useSRGBBuffer), this._multiRenderTargetOptions.targetTypes && this._multiRenderTargetOptions.targetTypes[s] !== -1)) {
|
|
292
|
+
let i;
|
|
293
|
+
t.is2DArray ? i = 35866 : t.isCube ? i = 34067 : t.is3D ? i = 32879 : i = 3553, this._multiRenderTargetOptions.targetTypes[s] = i;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Changes an attached texture's face index or layer.
|
|
298
|
+
* @param index The index of the texture to modify the attachment of
|
|
299
|
+
* @param layerIndex The layer index of the texture to be attached to the framebuffer
|
|
300
|
+
* @param faceIndex The face index of the texture to be attached to the framebuffer
|
|
301
|
+
*/
|
|
302
|
+
setLayerAndFaceIndex(t, s = -1, e = -1) {
|
|
303
|
+
!this.textures[t] || !this.renderTarget || (this._multiRenderTargetOptions.layerIndex && (this._multiRenderTargetOptions.layerIndex[t] = s), this._multiRenderTargetOptions.faceIndex && (this._multiRenderTargetOptions.faceIndex[t] = e), this.renderTarget.setLayerAndFaceIndex(t, s, e));
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Changes every attached texture's face index or layer.
|
|
307
|
+
* @param layerIndices The layer indices of the texture to be attached to the framebuffer
|
|
308
|
+
* @param faceIndices The face indices of the texture to be attached to the framebuffer
|
|
309
|
+
*/
|
|
310
|
+
setLayerAndFaceIndices(t, s) {
|
|
311
|
+
this.renderTarget && (this._multiRenderTargetOptions.layerIndex = t, this._multiRenderTargetOptions.faceIndex = s, this.renderTarget.setLayerAndFaceIndices(t, s));
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Define the number of samples used if MSAA is enabled.
|
|
315
|
+
*/
|
|
316
|
+
get samples() {
|
|
317
|
+
return this._samples;
|
|
318
|
+
}
|
|
319
|
+
set samples(t) {
|
|
320
|
+
this._renderTarget ? this._samples = this._renderTarget.setSamples(t) : this._samples = t;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Resize all the textures in the multi render target.
|
|
324
|
+
* Be careful as it will recreate all the data in the new texture.
|
|
325
|
+
* @param size Define the new size
|
|
326
|
+
*/
|
|
327
|
+
resize(t) {
|
|
328
|
+
this._processSizeParameter(t), this._rebuild(!1, void 0, this._textureNames);
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Changes the number of render targets in this MRT
|
|
332
|
+
* Be careful as it will recreate all the data in the new texture.
|
|
333
|
+
* @param count new texture count
|
|
334
|
+
* @param options Specifies texture types and sampling modes for new textures
|
|
335
|
+
* @param textureNames Specifies the names of the textures (optional)
|
|
336
|
+
*/
|
|
337
|
+
updateCount(t, s, e) {
|
|
338
|
+
this._multiRenderTargetOptions.textureCount = t, this._count = t;
|
|
339
|
+
const i = [], n = [], a = [], f = [], I = [], L = [], h = [], u = [];
|
|
340
|
+
this._textureNames = e, this._initTypes(t, i, n, a, f, I, L, h, u, s), this._multiRenderTargetOptions.types = i, this._multiRenderTargetOptions.samplingModes = n, this._multiRenderTargetOptions.useSRGBBuffers = a, this._multiRenderTargetOptions.formats = f, this._multiRenderTargetOptions.targetTypes = I, this._multiRenderTargetOptions.faceIndex = L, this._multiRenderTargetOptions.layerIndex = h, this._multiRenderTargetOptions.layerCounts = u, this._multiRenderTargetOptions.labels = e, this._rebuild(!1, !0, e);
|
|
341
|
+
}
|
|
342
|
+
_unbindFrameBuffer(t, s) {
|
|
343
|
+
this._renderTarget && t.unBindMultiColorAttachmentFramebuffer(this._renderTarget, this.isCube, () => {
|
|
344
|
+
this.onAfterRenderObservable.notifyObservers(s);
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Dispose the render targets and their associated resources
|
|
349
|
+
* @param doNotDisposeInternalTextures if set to true, internal textures won't be disposed (default: false).
|
|
350
|
+
*/
|
|
351
|
+
dispose(t = !1) {
|
|
352
|
+
this._releaseTextures(), t ? this._texture = null : this.releaseInternalTextures(), super.dispose();
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Release all the underlying texture used as draw buffers (render textures).
|
|
356
|
+
*/
|
|
357
|
+
releaseInternalTextures() {
|
|
358
|
+
const t = this._renderTarget?.textures;
|
|
359
|
+
if (t) {
|
|
360
|
+
for (let s = t.length - 1; s >= 0; s--)
|
|
361
|
+
this._textures[s]._texture = null;
|
|
362
|
+
this._renderTarget?.dispose(), this._renderTarget = null;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
const xe = "mrtFragmentDeclaration", Pt = `#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)
|
|
367
|
+
layout(location=0) out vec4 glFragData[{X}];
|
|
368
|
+
#endif
|
|
369
|
+
`;
|
|
370
|
+
B.IncludesShadersStore[xe] || (B.IncludesShadersStore[xe] = Pt);
|
|
371
|
+
const ve = "sceneFragmentDeclaration", Ut = `uniform mat4 viewProjection;
|
|
372
|
+
#ifdef MULTIVIEW
|
|
373
|
+
uniform mat4 viewProjectionR;
|
|
374
|
+
#endif
|
|
375
|
+
uniform mat4 view;uniform mat4 projection;uniform vec4 vEyePosition;uniform mat4 inverseProjection;
|
|
376
|
+
`;
|
|
377
|
+
B.IncludesShadersStore[ve] || (B.IncludesShadersStore[ve] = Ut);
|
|
378
|
+
const Le = "openpbrDielectricReflectance", Bt = `struct ReflectanceParams
|
|
379
|
+
{float F0;float F90;vec3 coloredF0;vec3 coloredF90;};
|
|
380
|
+
#define pbr_inline
|
|
381
|
+
ReflectanceParams dielectricReflectance(
|
|
382
|
+
in float insideIOR,in float outsideIOR,in vec3 specularColor,in float specularWeight
|
|
383
|
+
)
|
|
384
|
+
{ReflectanceParams outParams;float dielectricF0=pow((insideIOR-outsideIOR)/(insideIOR+outsideIOR),2.0);float dielectricF0_NoSpec=pow((1.0-outsideIOR)/(1.0+outsideIOR),2.0);float f90Scale=clamp(2.0*abs(insideIOR-outsideIOR),0.0,1.0);float f90Scale_NoSpec=clamp(2.0*abs(1.0-outsideIOR),0.0,1.0);
|
|
385
|
+
#if (DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_OPENPBR)
|
|
386
|
+
vec3 dielectricColorF90=specularColor.rgb*vec3(f90Scale);vec3 dielectricColorF90_NoSpec=specularColor.rgb*vec3(f90Scale_NoSpec);
|
|
387
|
+
#else
|
|
388
|
+
vec3 dielectricColorF90=vec3(f90Scale);vec3 dielectricColorF90_NoSpec=vec3(f90Scale_NoSpec);
|
|
389
|
+
#endif
|
|
390
|
+
#if DIELECTRIC_SPECULAR_MODEL==DIELECTRIC_SPECULAR_MODEL_GLTF
|
|
391
|
+
float maxF0=max(specularColor.r,max(specularColor.g,specularColor.b));outParams.F0=mix(dielectricF0_NoSpec,dielectricF0,specularWeight)*maxF0;
|
|
392
|
+
#else
|
|
393
|
+
outParams.F0=mix(dielectricF0_NoSpec,dielectricF0,specularWeight);
|
|
394
|
+
#endif
|
|
395
|
+
outParams.F90=mix(f90Scale_NoSpec,f90Scale,specularWeight);outParams.coloredF0=mix(vec3(dielectricF0_NoSpec),vec3(dielectricF0),specularWeight)*specularColor.rgb;outParams.coloredF90=mix(dielectricColorF90_NoSpec,dielectricColorF90,specularWeight);return outParams;}
|
|
396
|
+
`;
|
|
397
|
+
B.IncludesShadersStore[Le] || (B.IncludesShadersStore[Le] = Bt);
|
|
398
|
+
const Ce = "openpbrGeometryInfo", Vt = `struct geometryInfoOutParams
|
|
399
|
+
{float NdotV;float NdotVUnclamped;vec3 environmentBrdf;float horizonOcclusion;};struct geometryInfoAnisoOutParams
|
|
400
|
+
{float NdotV;float NdotVUnclamped;vec3 environmentBrdf;float horizonOcclusion;float anisotropy;vec3 anisotropicTangent;vec3 anisotropicBitangent;mat3 TBN;};
|
|
401
|
+
#define pbr_inline
|
|
402
|
+
geometryInfoOutParams geometryInfo(
|
|
403
|
+
in vec3 normalW,in vec3 viewDirectionW,in float roughness,in vec3 geometricNormalW
|
|
404
|
+
)
|
|
405
|
+
{geometryInfoOutParams outParams;outParams.NdotVUnclamped=dot(normalW,viewDirectionW);outParams.NdotV=absEps(outParams.NdotVUnclamped);
|
|
406
|
+
#if defined(ENVIRONMENTBRDF)
|
|
407
|
+
outParams.environmentBrdf=getBRDFLookup(outParams.NdotV,roughness);
|
|
408
|
+
#else
|
|
409
|
+
outParams.environmentBrdf=vec3(0.0);
|
|
410
|
+
#endif
|
|
411
|
+
outParams.horizonOcclusion=1.0;
|
|
412
|
+
#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
|
|
413
|
+
#ifdef HORIZONOCCLUSION
|
|
414
|
+
#if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL)
|
|
415
|
+
#ifdef REFLECTIONMAP_3D
|
|
416
|
+
outParams.horizonOcclusion=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormalW);
|
|
417
|
+
#endif
|
|
418
|
+
#endif
|
|
419
|
+
#endif
|
|
420
|
+
#endif
|
|
421
|
+
return outParams;}
|
|
422
|
+
#define pbr_inline
|
|
423
|
+
geometryInfoAnisoOutParams geometryInfoAniso(
|
|
424
|
+
in vec3 normalW,in vec3 viewDirectionW,in float roughness,in vec3 geometricNormalW
|
|
425
|
+
,in vec3 vAnisotropy,in mat3 TBN
|
|
426
|
+
)
|
|
427
|
+
{geometryInfoOutParams geoInfo=geometryInfo(normalW,viewDirectionW,roughness,geometricNormalW);geometryInfoAnisoOutParams outParams;outParams.NdotV=geoInfo.NdotV;outParams.NdotVUnclamped=geoInfo.NdotVUnclamped;outParams.environmentBrdf=geoInfo.environmentBrdf;outParams.horizonOcclusion=geoInfo.horizonOcclusion;outParams.anisotropy=vAnisotropy.b;vec3 anisotropyDirection=vec3(vAnisotropy.xy,0.);mat3 anisoTBN=mat3(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));outParams.anisotropicTangent=normalize(anisoTBN*anisotropyDirection);outParams.anisotropicBitangent=normalize(cross(anisoTBN[2],outParams.anisotropicTangent));outParams.TBN=TBN;return outParams;}`;
|
|
428
|
+
B.IncludesShadersStore[Ce] || (B.IncludesShadersStore[Ce] = Vt);
|
|
429
|
+
const Me = "openpbrIblFunctions", Gt = `#ifdef REFLECTION
|
|
430
|
+
vec3 sampleIrradiance(
|
|
431
|
+
in vec3 surfaceNormal
|
|
432
|
+
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
|
|
433
|
+
,in vec3 vEnvironmentIrradianceSH
|
|
434
|
+
#endif
|
|
435
|
+
#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
|
|
436
|
+
,in mat4 iblMatrix
|
|
437
|
+
#endif
|
|
438
|
+
#ifdef USEIRRADIANCEMAP
|
|
439
|
+
#ifdef REFLECTIONMAP_3D
|
|
440
|
+
,in samplerCube irradianceSampler
|
|
441
|
+
#else
|
|
442
|
+
,in sampler2D irradianceSampler
|
|
443
|
+
#endif
|
|
444
|
+
#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
|
|
445
|
+
,in vec3 reflectionDominantDirection
|
|
446
|
+
#endif
|
|
447
|
+
#endif
|
|
448
|
+
#ifdef REALTIME_FILTERING
|
|
449
|
+
,in vec2 vReflectionFilteringInfo
|
|
450
|
+
#ifdef IBL_CDF_FILTERING
|
|
451
|
+
,in sampler2D icdfSampler
|
|
452
|
+
#endif
|
|
453
|
+
#endif
|
|
454
|
+
,in vec2 vReflectionInfos
|
|
455
|
+
,in vec3 viewDirectionW
|
|
456
|
+
,in float diffuseRoughness
|
|
457
|
+
,in vec3 surfaceAlbedo
|
|
458
|
+
) {vec3 environmentIrradiance=vec3(0.,0.,0.);
|
|
459
|
+
#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
|
|
460
|
+
vec3 irradianceVector=(iblMatrix*vec4(surfaceNormal,0)).xyz;vec3 irradianceView=(iblMatrix*vec4(viewDirectionW,0)).xyz;
|
|
461
|
+
#if !defined(USE_IRRADIANCE_DOMINANT_DIRECTION) && !defined(REALTIME_FILTERING)
|
|
462
|
+
#if BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LAMBERT && BASE_DIFFUSE_MODEL != BRDF_DIFFUSE_MODEL_LEGACY
|
|
463
|
+
{float NdotV=max(dot(surfaceNormal,viewDirectionW),0.0);irradianceVector=mix(irradianceVector,irradianceView,(0.5*(1.0-NdotV))*diffuseRoughness);}
|
|
464
|
+
#endif
|
|
465
|
+
#endif
|
|
466
|
+
#ifdef REFLECTIONMAP_OPPOSITEZ
|
|
467
|
+
irradianceVector.z*=-1.0;irradianceView.z*=-1.0;
|
|
468
|
+
#endif
|
|
469
|
+
#ifdef INVERTCUBICMAP
|
|
470
|
+
irradianceVector.y*=-1.0;irradianceView.y*=-1.0;
|
|
471
|
+
#endif
|
|
472
|
+
#endif
|
|
473
|
+
#ifdef USESPHERICALFROMREFLECTIONMAP
|
|
474
|
+
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
|
|
475
|
+
environmentIrradiance=vEnvironmentIrradianceSH;
|
|
476
|
+
#else
|
|
477
|
+
#if defined(REALTIME_FILTERING)
|
|
478
|
+
environmentIrradiance=irradiance(reflectionSampler,irradianceVector,vReflectionFilteringInfo,diffuseRoughness,surfaceAlbedo,irradianceView
|
|
479
|
+
#ifdef IBL_CDF_FILTERING
|
|
480
|
+
,icdfSampler
|
|
481
|
+
#endif
|
|
482
|
+
);
|
|
483
|
+
#else
|
|
484
|
+
environmentIrradiance=computeEnvironmentIrradiance(irradianceVector);
|
|
485
|
+
#endif
|
|
486
|
+
#endif
|
|
487
|
+
#elif defined(USEIRRADIANCEMAP)
|
|
488
|
+
#ifdef REFLECTIONMAP_3D
|
|
489
|
+
vec4 environmentIrradianceFromTexture=sampleReflection(irradianceSampler,irradianceVector);
|
|
490
|
+
#else
|
|
491
|
+
vec4 environmentIrradianceFromTexture=sampleReflection(irradianceSampler,reflectionCoords);
|
|
492
|
+
#endif
|
|
493
|
+
environmentIrradiance=environmentIrradianceFromTexture.rgb;
|
|
494
|
+
#ifdef RGBDREFLECTION
|
|
495
|
+
environmentIrradiance.rgb=fromRGBD(environmentIrradianceFromTexture);
|
|
496
|
+
#endif
|
|
497
|
+
#ifdef GAMMAREFLECTION
|
|
498
|
+
environmentIrradiance.rgb=toLinearSpace(environmentIrradiance.rgb);
|
|
499
|
+
#endif
|
|
500
|
+
#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
|
|
501
|
+
vec3 Ls=normalize(reflectionDominantDirection);float NoL=dot(irradianceVector,Ls);float NoV=dot(irradianceVector,irradianceView);vec3 diffuseRoughnessTerm=vec3(1.0);
|
|
502
|
+
#if BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_EON
|
|
503
|
+
float LoV=dot (Ls,irradianceView);float mag=length(reflectionDominantDirection)*2.0;vec3 clampedAlbedo=clamp(surfaceAlbedo,vec3(0.1),vec3(1.0));diffuseRoughnessTerm=diffuseBRDF_EON(clampedAlbedo,diffuseRoughness,NoL,NoV,LoV)*PI;diffuseRoughnessTerm=diffuseRoughnessTerm/clampedAlbedo;diffuseRoughnessTerm=mix(vec3(1.0),diffuseRoughnessTerm,sqrt(clamp(mag*NoV,0.0,1.0)));
|
|
504
|
+
#elif BASE_DIFFUSE_MODEL==BRDF_DIFFUSE_MODEL_BURLEY
|
|
505
|
+
vec3 H=(irradianceView+Ls)*0.5;float VoH=dot(irradianceView,H);diffuseRoughnessTerm=vec3(diffuseBRDF_Burley(NoL,NoV,VoH,diffuseRoughness)*PI);
|
|
506
|
+
#endif
|
|
507
|
+
environmentIrradiance=environmentIrradiance.rgb*diffuseRoughnessTerm;
|
|
508
|
+
#endif
|
|
509
|
+
#endif
|
|
510
|
+
environmentIrradiance*=vReflectionInfos.x;return environmentIrradiance;}
|
|
511
|
+
#define pbr_inline
|
|
512
|
+
#ifdef REFLECTIONMAP_3D
|
|
513
|
+
vec3 createReflectionCoords(
|
|
514
|
+
#else
|
|
515
|
+
vec2 createReflectionCoords(
|
|
516
|
+
#endif
|
|
517
|
+
in vec3 vPositionW
|
|
518
|
+
,in vec3 normalW
|
|
519
|
+
)
|
|
520
|
+
{vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);
|
|
521
|
+
#ifdef REFLECTIONMAP_OPPOSITEZ
|
|
522
|
+
reflectionVector.z*=-1.0;
|
|
523
|
+
#endif
|
|
524
|
+
#ifdef REFLECTIONMAP_3D
|
|
525
|
+
vec3 reflectionCoords=reflectionVector;
|
|
526
|
+
#else
|
|
527
|
+
vec2 reflectionCoords=reflectionVector.xy;
|
|
528
|
+
#ifdef REFLECTIONMAP_PROJECTION
|
|
529
|
+
reflectionCoords/=reflectionVector.z;
|
|
530
|
+
#endif
|
|
531
|
+
reflectionCoords.y=1.0-reflectionCoords.y;
|
|
532
|
+
#endif
|
|
533
|
+
return reflectionCoords;}
|
|
534
|
+
#define pbr_inline
|
|
535
|
+
#define inline
|
|
536
|
+
vec3 sampleRadiance(
|
|
537
|
+
in float alphaG
|
|
538
|
+
,in vec3 vReflectionMicrosurfaceInfos
|
|
539
|
+
,in vec2 vReflectionInfos
|
|
540
|
+
,in geometryInfoOutParams geoInfo
|
|
541
|
+
#ifdef REFLECTIONMAP_3D
|
|
542
|
+
,in samplerCube reflectionSampler
|
|
543
|
+
,const vec3 reflectionCoords
|
|
544
|
+
#else
|
|
545
|
+
,in sampler2D reflectionSampler
|
|
546
|
+
,const vec2 reflectionCoords
|
|
547
|
+
#endif
|
|
548
|
+
#ifdef REALTIME_FILTERING
|
|
549
|
+
,in vec2 vReflectionFilteringInfo
|
|
550
|
+
#endif
|
|
551
|
+
)
|
|
552
|
+
{vec4 environmentRadiance=vec4(0.,0.,0.,0.);
|
|
553
|
+
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
|
|
554
|
+
float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,geoInfo.NdotVUnclamped);
|
|
555
|
+
#elif defined(LINEARSPECULARREFLECTION)
|
|
556
|
+
float reflectionLOD=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,roughness);
|
|
557
|
+
#else
|
|
558
|
+
float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG);
|
|
559
|
+
#endif
|
|
560
|
+
reflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;
|
|
561
|
+
#ifdef REALTIME_FILTERING
|
|
562
|
+
environmentRadiance=vec4(radiance(alphaG,reflectionSampler,reflectionCoords,vReflectionFilteringInfo),1.0);
|
|
563
|
+
#else
|
|
564
|
+
environmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);
|
|
565
|
+
#endif
|
|
566
|
+
#ifdef RGBDREFLECTION
|
|
567
|
+
environmentRadiance.rgb=fromRGBD(environmentRadiance);
|
|
568
|
+
#endif
|
|
569
|
+
#ifdef GAMMAREFLECTION
|
|
570
|
+
environmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);
|
|
571
|
+
#endif
|
|
572
|
+
environmentRadiance.rgb*=vec3(vReflectionInfos.x);return environmentRadiance.rgb;}
|
|
573
|
+
#if defined(ANISOTROPIC)
|
|
574
|
+
#define pbr_inline
|
|
575
|
+
#define inline
|
|
576
|
+
vec3 sampleRadianceAnisotropic(
|
|
577
|
+
in float alphaG
|
|
578
|
+
,in vec3 vReflectionMicrosurfaceInfos
|
|
579
|
+
,in vec2 vReflectionInfos
|
|
580
|
+
,in geometryInfoAnisoOutParams geoInfo
|
|
581
|
+
,const vec3 normalW
|
|
582
|
+
,const vec3 viewDirectionW
|
|
583
|
+
,const vec3 positionW
|
|
584
|
+
,const vec3 noise
|
|
585
|
+
,bool isRefraction
|
|
586
|
+
,float ior
|
|
587
|
+
#ifdef REFLECTIONMAP_3D
|
|
588
|
+
,in samplerCube reflectionSampler
|
|
589
|
+
#else
|
|
590
|
+
,in sampler2D reflectionSampler
|
|
591
|
+
#endif
|
|
592
|
+
#ifdef REALTIME_FILTERING
|
|
593
|
+
,in vec2 vReflectionFilteringInfo
|
|
594
|
+
#endif
|
|
595
|
+
)
|
|
596
|
+
{vec4 environmentRadiance=vec4(0.,0.,0.,0.);float alphaT=alphaG*sqrt(2.0/(1.0+(1.0-geoInfo.anisotropy)*(1.0-geoInfo.anisotropy)));float alphaB=(1.0-geoInfo.anisotropy)*alphaT;alphaG=alphaB;
|
|
597
|
+
#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
|
|
598
|
+
float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,geoInfo.NdotVUnclamped);
|
|
599
|
+
#elif defined(LINEARSPECULARREFLECTION)
|
|
600
|
+
float reflectionLOD=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,roughness);
|
|
601
|
+
#else
|
|
602
|
+
float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG);
|
|
603
|
+
#endif
|
|
604
|
+
reflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;
|
|
605
|
+
#ifdef REALTIME_FILTERING
|
|
606
|
+
vec3 view=(reflectionMatrix*vec4(viewDirectionW,0.0)).xyz;vec3 tangent=(reflectionMatrix*vec4(geoInfo.anisotropicTangent,0.0)).xyz;vec3 bitangent=(reflectionMatrix*vec4(geoInfo.anisotropicBitangent,0.0)).xyz;vec3 normal=(reflectionMatrix*vec4(normalW,0.0)).xyz;
|
|
607
|
+
#ifdef REFLECTIONMAP_OPPOSITEZ
|
|
608
|
+
view.z*=-1.0;tangent.z*=-1.0;bitangent.z*=-1.0;normal.z*=-1.0;
|
|
609
|
+
#endif
|
|
610
|
+
environmentRadiance =
|
|
611
|
+
vec4(radianceAnisotropic(alphaT,alphaB,reflectionSampler,
|
|
612
|
+
view,tangent,
|
|
613
|
+
bitangent,normal,
|
|
614
|
+
vReflectionFilteringInfo,noise.xy,isRefraction,ior),
|
|
615
|
+
1.0);
|
|
616
|
+
#else
|
|
617
|
+
const int samples=16;vec4 radianceSample=vec4(0.0);vec3 reflectionCoords=vec3(0.0);float sample_weight=0.0;float total_weight=0.0;float step=1.0/float(max(samples-1,1));for (int i=0; i<samples; ++i) {float t=mix(-1.0,1.0,float(i)*step);t+=step*2.0*noise.x;sample_weight=max(1.0-abs(t),0.001);sample_weight*=sample_weight;t*=min(4.0*alphaT*geoInfo.anisotropy,1.0);vec3 bentNormal;if (t<0.0) {float blend=t+1.0;bentNormal=normalize(mix(-geoInfo.anisotropicTangent,normalW,blend));} else if (t>0.0) {float blend=t;bentNormal=normalize(mix(normalW,geoInfo.anisotropicTangent,blend));} else {bentNormal=normalW;}
|
|
618
|
+
if (isRefraction) {reflectionCoords=double_refract(-viewDirectionW,bentNormal,ior);} else {reflectionCoords=reflect(-viewDirectionW,bentNormal);}
|
|
619
|
+
reflectionCoords=vec3(reflectionMatrix*vec4(reflectionCoords,0));
|
|
620
|
+
#ifdef REFLECTIONMAP_OPPOSITEZ
|
|
621
|
+
reflectionCoords.z*=-1.0;
|
|
622
|
+
#endif
|
|
623
|
+
radianceSample=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);
|
|
624
|
+
#ifdef RGBDREFLECTION
|
|
625
|
+
environmentRadiance.rgb+=sample_weight*fromRGBD(radianceSample);
|
|
626
|
+
#elif defined(GAMMAREFLECTION)
|
|
627
|
+
environmentRadiance.rgb+=sample_weight*toLinearSpace(radianceSample.rgb);
|
|
628
|
+
#else
|
|
629
|
+
environmentRadiance.rgb+=sample_weight*radianceSample.rgb;
|
|
630
|
+
#endif
|
|
631
|
+
total_weight+=sample_weight;}
|
|
632
|
+
environmentRadiance=vec4(environmentRadiance.xyz/float(total_weight),1.0);
|
|
633
|
+
#endif
|
|
634
|
+
environmentRadiance.rgb*=vec3(vReflectionInfos.x);return environmentRadiance.rgb;}
|
|
635
|
+
#endif
|
|
636
|
+
#endif
|
|
637
|
+
#if defined(ENVIRONMENTBRDF)
|
|
638
|
+
#define pbr_inline
|
|
639
|
+
float computeDielectricIblFresnel(in ReflectanceParams reflectance,in vec3 environmentBrdf)
|
|
640
|
+
{float dielectricIblFresnel=getReflectanceFromBRDFLookup(vec3(reflectance.F0),vec3(reflectance.F90),environmentBrdf).r;float dielectricECF=1.0+reflectance.F0*(1.0/environmentBrdf.y-1.0);return clamp(dielectricIblFresnel*dielectricECF,0.0,1.0);}
|
|
641
|
+
#define pbr_inline
|
|
642
|
+
vec3 computeConductorIblFresnel(in ReflectanceParams reflectance,in vec3 environmentBrdf)
|
|
643
|
+
{
|
|
644
|
+
#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR) && defined(ENVIRONMENTBRDF)
|
|
645
|
+
vec3 openPBRBrdf=vec3(environmentBrdf.xy,environmentBrdf.z/BRDF_Z_SCALE);vec3 b =getF82B(reflectance.coloredF0,reflectance.coloredF90);vec3 E_F82=getF82DirectionalAlbedo(reflectance.coloredF0,vec3(1.0),b,openPBRBrdf);vec3 F_avg=getF82AverageFresnel(reflectance.coloredF0,b);vec3 ECF =vec3(1.0)+F_avg*(vec3(1.0)/openPBRBrdf.y-vec3(1.0));return clamp(E_F82*ECF,vec3(0.0),vec3(1.0));
|
|
646
|
+
#else
|
|
647
|
+
return getReflectanceFromBRDFLookup(reflectance.coloredF0,reflectance.coloredF90,environmentBrdf);
|
|
648
|
+
#endif
|
|
649
|
+
}
|
|
650
|
+
#endif
|
|
651
|
+
`;
|
|
652
|
+
B.IncludesShadersStore[Me] || (B.IncludesShadersStore[Me] = Gt);
|
|
653
|
+
const be = "openpbrSubsurfaceLayerData", Wt = `float subsurface_weight=vSubsurfaceWeight;vec3 subsurface_color=vSubsurfaceColor.rgb;float subsurface_radius=vSubsurfaceRadius;vec3 subsurface_radius_scale=vSubsurfaceRadiusScale;float subsurface_scatter_anisotropy=clamp(vSubsurfaceScatterAnisotropy,-0.9999,0.9999);
|
|
654
|
+
#ifdef SUBSURFACE_WEIGHT
|
|
655
|
+
vec4 subsurfaceWeightFromTexture=TEXRD(subsurfaceWeightSampler,vSubsurfaceWeightUV+uvOffset);
|
|
656
|
+
#endif
|
|
657
|
+
#ifdef SUBSURFACE_COLOR
|
|
658
|
+
vec4 subsurfaceColorFromTexture=TEXRD(subsurfaceColorSampler,vSubsurfaceColorUV+uvOffset);
|
|
659
|
+
#endif
|
|
660
|
+
#ifdef SUBSURFACE_RADIUS_SCALE
|
|
661
|
+
vec4 subsurfaceRadiusScaleFromTexture=TEXRD(subsurfaceRadiusScaleSampler,vSubsurfaceRadiusScaleUV+uvOffset);
|
|
662
|
+
#endif
|
|
663
|
+
#ifdef SUBSURFACE_WEIGHT
|
|
664
|
+
#ifdef SUBSURFACE_WEIGHT_FROM_TEXTURE_ALPHA
|
|
665
|
+
subsurface_weight*=subsurfaceWeightFromTexture.a;
|
|
666
|
+
#else
|
|
667
|
+
subsurface_weight*=subsurfaceWeightFromTexture.r;
|
|
668
|
+
#endif
|
|
669
|
+
#endif
|
|
670
|
+
#ifdef SUBSURFACE_COLOR
|
|
671
|
+
#ifdef SUBSURFACE_COLOR_GAMMA
|
|
672
|
+
subsurface_color*=toLinearSpace(subsurfaceColorFromTexture.rgb);
|
|
673
|
+
#else
|
|
674
|
+
subsurface_color*=subsurfaceColorFromTexture.rgb;
|
|
675
|
+
#endif
|
|
676
|
+
subsurface_color*=vSubsurfaceColorInfos.y;
|
|
677
|
+
#endif
|
|
678
|
+
#ifdef SUBSURFACE_RADIUS_SCALE
|
|
679
|
+
subsurface_radius_scale*=subsurfaceRadiusScaleFromTexture.rgb;
|
|
680
|
+
#endif
|
|
681
|
+
`;
|
|
682
|
+
B.IncludesShadersStore[be] || (B.IncludesShadersStore[be] = Wt);
|
|
683
|
+
const Oe = "openpbrTransmissionLayerData", wt = `float transmission_weight=vTransmissionWeight;vec3 transmission_color=vTransmissionColor.rgb;float transmission_depth=vTransmissionDepth;vec3 transmission_scatter=vTransmissionScatter.rgb;float transmission_scatter_anisotropy=clamp(vTransmissionScatterAnisotropy,-0.9999,0.9999);float transmission_dispersion_scale=vTransmissionDispersionScale;float transmission_dispersion_abbe_number=vTransmissionDispersionAbbeNumber;
|
|
684
|
+
#ifdef TRANSMISSION_WEIGHT
|
|
685
|
+
vec4 transmissionWeightFromTexture=TEXRD(transmissionWeightSampler,vTransmissionWeightUV+uvOffset);
|
|
686
|
+
#endif
|
|
687
|
+
#ifdef TRANSMISSION_COLOR
|
|
688
|
+
vec4 transmissionColorFromTexture=TEXRD(transmissionColorSampler,vTransmissionColorUV+uvOffset);
|
|
689
|
+
#endif
|
|
690
|
+
#ifdef TRANSMISSION_DEPTH
|
|
691
|
+
vec4 transmissionDepthFromTexture=TEXRD(transmissionDepthSampler,vTransmissionDepthUV+uvOffset);
|
|
692
|
+
#endif
|
|
693
|
+
#ifdef TRANSMISSION_SCATTER
|
|
694
|
+
vec4 transmissionScatterFromTexture=TEXRD(transmissionScatterSampler,vTransmissionScatterUV+uvOffset);
|
|
695
|
+
#endif
|
|
696
|
+
#ifdef TRANSMISSION_DISPERSION_SCALE
|
|
697
|
+
vec4 transmissionDispersionScaleFromTexture=TEXRD(transmissionDispersionScaleSampler,vTransmissionDispersionScaleUV+uvOffset);
|
|
698
|
+
#endif
|
|
699
|
+
#ifdef TRANSMISSION_WEIGHT
|
|
700
|
+
transmission_weight*=transmissionWeightFromTexture.r;
|
|
701
|
+
#endif
|
|
702
|
+
#ifdef TRANSMISSION_COLOR
|
|
703
|
+
#ifdef TRANSMISSION_COLOR_GAMMA
|
|
704
|
+
transmission_color*=toLinearSpace(transmissionColorFromTexture.rgb);
|
|
705
|
+
#else
|
|
706
|
+
transmission_color*=transmissionColorFromTexture.rgb;
|
|
707
|
+
#endif
|
|
708
|
+
transmission_color*=vTransmissionColorInfos.y;
|
|
709
|
+
#endif
|
|
710
|
+
#ifdef TRANSMISSION_DEPTH
|
|
711
|
+
transmission_depth*=transmissionDepthFromTexture.r;
|
|
712
|
+
#endif
|
|
713
|
+
#ifdef TRANSMISSION_SCATTER
|
|
714
|
+
transmission_scatter*=transmissionScatterFromTexture.rgb;
|
|
715
|
+
#endif
|
|
716
|
+
#ifdef TRANSMISSION_DISPERSION_SCALE
|
|
717
|
+
transmission_dispersion_scale*=transmissionDispersionScaleFromTexture.r;
|
|
718
|
+
#endif
|
|
719
|
+
`;
|
|
720
|
+
B.IncludesShadersStore[Oe] || (B.IncludesShadersStore[Oe] = wt);
|
|
721
|
+
const de = "geometryPixelShader", Ge = `#extension GL_EXT_draw_buffers : require
|
|
722
|
+
#if defined(BUMP) || !defined(NORMAL)
|
|
723
|
+
#extension GL_OES_standard_derivatives : enable
|
|
724
|
+
#endif
|
|
725
|
+
precision highp float;
|
|
726
|
+
#ifdef BUMP
|
|
727
|
+
varying mat4 vWorldView;varying vec3 vNormalW;
|
|
728
|
+
#else
|
|
729
|
+
varying vec3 vNormalV;
|
|
730
|
+
#endif
|
|
731
|
+
varying vec4 vViewPos;
|
|
732
|
+
#if defined(POSITION) || defined(BUMP) || defined(IRRADIANCE)
|
|
733
|
+
varying vec3 vPositionW;
|
|
734
|
+
#endif
|
|
735
|
+
#if defined(VELOCITY) || defined(VELOCITY_LINEAR)
|
|
736
|
+
varying vec4 vCurrentPosition;varying vec4 vPreviousPosition;
|
|
737
|
+
#endif
|
|
738
|
+
#ifdef NEED_UV
|
|
739
|
+
varying vec2 vUV;
|
|
740
|
+
#endif
|
|
741
|
+
#ifdef BUMP
|
|
742
|
+
uniform vec3 vBumpInfos;uniform vec2 vTangentSpaceParams;
|
|
743
|
+
#endif
|
|
744
|
+
#if defined(REFLECTIVITY)
|
|
745
|
+
#if defined(ORMTEXTURE) || defined(SPECULARGLOSSINESSTEXTURE) || defined(REFLECTIVITYTEXTURE)
|
|
746
|
+
uniform sampler2D reflectivitySampler;varying vec2 vReflectivityUV;
|
|
747
|
+
#else
|
|
748
|
+
#ifdef METALLIC_TEXTURE
|
|
749
|
+
uniform sampler2D metallicSampler;varying vec2 vMetallicUV;
|
|
750
|
+
#endif
|
|
751
|
+
#ifdef ROUGHNESS_TEXTURE
|
|
752
|
+
uniform sampler2D roughnessSampler;varying vec2 vRoughnessUV;
|
|
753
|
+
#endif
|
|
754
|
+
#endif
|
|
755
|
+
#ifdef ALBEDOTEXTURE
|
|
756
|
+
varying vec2 vAlbedoUV;uniform sampler2D albedoSampler;
|
|
757
|
+
#endif
|
|
758
|
+
#ifdef REFLECTIVITYCOLOR
|
|
759
|
+
uniform vec3 reflectivityColor;
|
|
760
|
+
#endif
|
|
761
|
+
#ifdef ALBEDOCOLOR
|
|
762
|
+
uniform vec3 albedoColor;
|
|
763
|
+
#endif
|
|
764
|
+
#ifdef METALLIC
|
|
765
|
+
uniform float metallic;
|
|
766
|
+
#endif
|
|
767
|
+
#if defined(ROUGHNESS) || defined(GLOSSINESS)
|
|
768
|
+
uniform float glossiness;
|
|
769
|
+
#endif
|
|
770
|
+
#endif
|
|
771
|
+
#if defined(ALPHATEST) && defined(NEED_UV)
|
|
772
|
+
uniform sampler2D diffuseSampler;
|
|
773
|
+
#endif
|
|
774
|
+
#include<clipPlaneFragmentDeclaration>
|
|
775
|
+
#include<mrtFragmentDeclaration>[SCENE_MRT_COUNT]
|
|
776
|
+
#include<bumpFragmentMainFunctions>
|
|
777
|
+
#include<bumpFragmentFunctions>
|
|
778
|
+
#include<helperFunctions>
|
|
779
|
+
#ifdef IRRADIANCE
|
|
780
|
+
#include<pbrFragmentReflectionDeclaration>
|
|
781
|
+
#ifdef REFLECTION
|
|
782
|
+
#ifdef USEIRRADIANCEMAP
|
|
783
|
+
#include<__decl__sceneFragment>
|
|
784
|
+
uniform mat4 reflectionMatrix;uniform vec2 vReflectionInfos;uniform vec3 vReflectionDominantDirection;
|
|
785
|
+
#include<pbrBRDFFunctions>
|
|
786
|
+
#include<openpbrDielectricReflectance>
|
|
787
|
+
#include<pbrIBLFunctions>
|
|
788
|
+
#include<reflectionFunction>
|
|
789
|
+
#include<openpbrGeometryInfo>
|
|
790
|
+
#include<openpbrIblFunctions>
|
|
791
|
+
#elif defined(USESPHERICALFROMREFLECTIONMAP)
|
|
792
|
+
varying vec3 vEnvironmentIrradiance;
|
|
793
|
+
#endif
|
|
794
|
+
#ifdef IBL_SHADOW_TEXTURE
|
|
795
|
+
uniform sampler2D iblShadowSampler;uniform vec2 shadowTextureSize;
|
|
796
|
+
#endif
|
|
797
|
+
#ifdef IRRADIANCE_SCATTER_MASK
|
|
798
|
+
uniform float vSubsurfaceWeight;
|
|
799
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,SUBSURFACE_WEIGHT,_VARYINGNAME_,SubsurfaceWeight,_SAMPLERNAME_,subsurfaceWeight)
|
|
800
|
+
uniform float vSubsurfaceScatterAnisotropy;uniform float vTransmissionWeight;
|
|
801
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,TRANSMISSION_WEIGHT,_VARYINGNAME_,TransmissionWeight,_SAMPLERNAME_,transmissionWeight)
|
|
802
|
+
uniform float vTransmissionScatterAnisotropy;
|
|
803
|
+
#endif
|
|
804
|
+
#endif
|
|
805
|
+
#endif
|
|
806
|
+
void main() {
|
|
807
|
+
#include<clipPlaneFragment>
|
|
808
|
+
#ifdef ALPHATEST
|
|
809
|
+
if (texture2D(diffuseSampler,vUV).a<0.4)
|
|
810
|
+
discard;
|
|
811
|
+
#endif
|
|
812
|
+
vec3 normalOutput;
|
|
813
|
+
#ifdef BUMP
|
|
814
|
+
vec3 normalW=normalize(vNormalW);
|
|
815
|
+
#include<bumpFragment>
|
|
816
|
+
#ifdef NORMAL_WORLDSPACE
|
|
817
|
+
normalOutput=normalW;
|
|
818
|
+
#else
|
|
819
|
+
normalOutput=normalize(vec3(vWorldView*vec4(normalW,0.0)));
|
|
820
|
+
#endif
|
|
821
|
+
#elif defined(HAS_NORMAL_ATTRIBUTE)
|
|
822
|
+
normalOutput=normalize(vNormalV);
|
|
823
|
+
#elif defined(POSITION)
|
|
824
|
+
normalOutput=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));
|
|
825
|
+
#endif
|
|
826
|
+
#ifdef ENCODE_NORMAL
|
|
827
|
+
normalOutput=normalOutput*0.5+0.5;
|
|
828
|
+
#endif
|
|
829
|
+
#ifdef DEPTH
|
|
830
|
+
gl_FragData[DEPTH_INDEX]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);
|
|
831
|
+
#endif
|
|
832
|
+
#ifdef NORMAL
|
|
833
|
+
gl_FragData[NORMAL_INDEX]=vec4(normalOutput,1.0);
|
|
834
|
+
#endif
|
|
835
|
+
#ifdef SCREENSPACE_DEPTH
|
|
836
|
+
gl_FragData[SCREENSPACE_DEPTH_INDEX]=vec4(gl_FragCoord.z,0.0,0.0,1.0);
|
|
837
|
+
#endif
|
|
838
|
+
#ifdef POSITION
|
|
839
|
+
gl_FragData[POSITION_INDEX]=vec4(vPositionW,1.0);
|
|
840
|
+
#endif
|
|
841
|
+
#ifdef VELOCITY
|
|
842
|
+
vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;vec2 velocity=abs(a-b);velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;gl_FragData[VELOCITY_INDEX]=vec4(velocity,0.0,1.0);
|
|
843
|
+
#endif
|
|
844
|
+
#ifdef VELOCITY_LINEAR
|
|
845
|
+
vec2 velocity=vec2(0.5)*((vPreviousPosition.xy/vPreviousPosition.w) -
|
|
846
|
+
(vCurrentPosition.xy/vCurrentPosition.w));gl_FragData[VELOCITY_LINEAR_INDEX]=vec4(velocity,0.0,1.0);
|
|
847
|
+
#endif
|
|
848
|
+
#ifdef REFLECTIVITY
|
|
849
|
+
vec4 reflectivity=vec4(0.0,0.0,0.0,1.0);
|
|
850
|
+
#ifdef METALLICWORKFLOW
|
|
851
|
+
float metal=1.0;float roughness=1.0;
|
|
852
|
+
#ifdef ORMTEXTURE
|
|
853
|
+
metal*=texture2D(reflectivitySampler,vReflectivityUV).b;roughness*=texture2D(reflectivitySampler,vReflectivityUV).g;
|
|
854
|
+
#else
|
|
855
|
+
#ifdef METALLIC_TEXTURE
|
|
856
|
+
metal*=texture2D(metallicSampler,vMetallicUV).r;
|
|
857
|
+
#endif
|
|
858
|
+
#ifdef ROUGHNESS_TEXTURE
|
|
859
|
+
roughness*=texture2D(roughnessSampler,vRoughnessUV).r;
|
|
860
|
+
#endif
|
|
861
|
+
#endif
|
|
862
|
+
#ifdef METALLIC
|
|
863
|
+
metal*=metallic;
|
|
864
|
+
#endif
|
|
865
|
+
#ifdef ROUGHNESS
|
|
866
|
+
roughness*=(1.0-glossiness);
|
|
867
|
+
#endif
|
|
868
|
+
reflectivity.a-=roughness;vec3 color=vec3(1.0);
|
|
869
|
+
#ifdef ALBEDOTEXTURE
|
|
870
|
+
color=texture2D(albedoSampler,vAlbedoUV).rgb;
|
|
871
|
+
#ifdef GAMMAALBEDO
|
|
872
|
+
color=toLinearSpace(color);
|
|
873
|
+
#endif
|
|
874
|
+
#endif
|
|
875
|
+
#ifdef ALBEDOCOLOR
|
|
876
|
+
color*=albedoColor.xyz;
|
|
877
|
+
#endif
|
|
878
|
+
reflectivity.rgb=mix(vec3(0.04),color,metal);
|
|
879
|
+
#else
|
|
880
|
+
#if defined(SPECULARGLOSSINESSTEXTURE) || defined(REFLECTIVITYTEXTURE)
|
|
881
|
+
reflectivity=texture2D(reflectivitySampler,vReflectivityUV);
|
|
882
|
+
#ifdef GAMMAREFLECTIVITYTEXTURE
|
|
883
|
+
reflectivity.rgb=toLinearSpace(reflectivity.rgb);
|
|
884
|
+
#endif
|
|
885
|
+
#else
|
|
886
|
+
#ifdef REFLECTIVITYCOLOR
|
|
887
|
+
reflectivity.rgb=toLinearSpace(reflectivityColor.xyz);reflectivity.a=1.0;
|
|
888
|
+
#endif
|
|
889
|
+
#endif
|
|
890
|
+
#ifdef GLOSSINESSS
|
|
891
|
+
reflectivity.a*=glossiness;
|
|
892
|
+
#endif
|
|
893
|
+
#endif
|
|
894
|
+
gl_FragData[REFLECTIVITY_INDEX]=reflectivity;
|
|
895
|
+
#endif
|
|
896
|
+
#ifdef IRRADIANCE
|
|
897
|
+
vec3 irradiance=vec3(0.0);float irradiance_alpha=1.0;
|
|
898
|
+
#ifdef REFLECTION
|
|
899
|
+
#ifdef IRRADIANCE_SCATTER_MASK
|
|
900
|
+
#ifndef BUMP
|
|
901
|
+
vec2 uvOffset=vec2(0.0);
|
|
902
|
+
#endif
|
|
903
|
+
vec3 vSubsurfaceColor=vec3(1.0);float vSubsurfaceRadius=0.0;vec3 vSubsurfaceRadiusScale=vec3(1.0);
|
|
904
|
+
#include<openpbrSubsurfaceLayerData>
|
|
905
|
+
float vTransmissionDepth=1.0;vec3 vTransmissionColor=vec3(1.0);vec3 vTransmissionScatter=vec3(0.0);float vTransmissionDispersionScale=0.0;float vTransmissionDispersionAbbeNumber=0.0;
|
|
906
|
+
#include<openpbrTransmissionLayerData>
|
|
907
|
+
#endif
|
|
908
|
+
#ifdef IBL_SHADOW_TEXTURE
|
|
909
|
+
#ifdef COLORED_IBL_SHADOWS
|
|
910
|
+
vec3 iblShadowValue=texture(iblShadowSampler,gl_FragCoord.xy/shadowTextureSize).rgb;
|
|
911
|
+
#else
|
|
912
|
+
vec3 iblShadowValue=vec3(texture(iblShadowSampler,gl_FragCoord.xy/shadowTextureSize).r);
|
|
913
|
+
#endif
|
|
914
|
+
#endif
|
|
915
|
+
#if defined(USEIRRADIANCEMAP)
|
|
916
|
+
#ifdef IRRADIANCE_SCATTER_MASK
|
|
917
|
+
float bendAmount=subsurface_weight*-min(subsurface_scatter_anisotropy,0.0);bendAmount=mix(bendAmount,-min(transmission_scatter_anisotropy,0.0),transmission_weight);vec3 viewVector=normalize(vEyePosition.xyz-vPositionW.xyz);vec3 bentNormal=mix(normalOutput,viewVector,bendAmount*dot(normalOutput,viewVector));
|
|
918
|
+
#else
|
|
919
|
+
vec3 bentNormal=normalOutput;
|
|
920
|
+
#endif
|
|
921
|
+
irradiance=sampleIrradiance(
|
|
922
|
+
bentNormal
|
|
923
|
+
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
|
|
924
|
+
,vEnvironmentIrradiance
|
|
925
|
+
#endif
|
|
926
|
+
#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
|
|
927
|
+
,reflectionMatrix
|
|
928
|
+
#endif
|
|
929
|
+
#ifdef USEIRRADIANCEMAP
|
|
930
|
+
,irradianceSampler
|
|
931
|
+
#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
|
|
932
|
+
,vReflectionDominantDirection
|
|
933
|
+
#endif
|
|
934
|
+
#endif
|
|
935
|
+
#ifdef REALTIME_FILTERING
|
|
936
|
+
,vReflectionFilteringInfo
|
|
937
|
+
#ifdef IBL_CDF_FILTERING
|
|
938
|
+
,icdfSampler
|
|
939
|
+
#endif
|
|
940
|
+
#endif
|
|
941
|
+
,vReflectionInfos
|
|
942
|
+
,vViewPos.xyz
|
|
943
|
+
,1.0
|
|
944
|
+
,vec3(1.0)
|
|
945
|
+
);
|
|
946
|
+
#elif defined(USESPHERICALFROMREFLECTIONMAP)
|
|
947
|
+
irradiance=vEnvironmentIrradiance;
|
|
948
|
+
#endif
|
|
949
|
+
#ifdef IBL_SHADOW_TEXTURE
|
|
950
|
+
irradiance*=iblShadowValue;
|
|
951
|
+
#endif
|
|
952
|
+
#ifdef IRRADIANCE_SCATTER_MASK
|
|
953
|
+
irradiance_alpha=min(subsurface_weight+transmission_weight,1.0);
|
|
954
|
+
#endif
|
|
955
|
+
#endif
|
|
956
|
+
gl_FragData[IRRADIANCE_INDEX]=vec4(irradiance,irradiance_alpha);
|
|
957
|
+
#endif
|
|
958
|
+
}
|
|
959
|
+
`;
|
|
960
|
+
B.ShadersStore[de] || (B.ShadersStore[de] = Ge);
|
|
961
|
+
const Ht = { name: de, shader: Ge }, kt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
962
|
+
__proto__: null,
|
|
963
|
+
geometryPixelShader: Ht
|
|
964
|
+
}, Symbol.toStringTag, { value: "Module" })), Ne = "geometryVertexDeclaration", zt = "uniform mat4 viewProjection;uniform mat4 view;";
|
|
965
|
+
B.IncludesShadersStore[Ne] || (B.IncludesShadersStore[Ne] = zt);
|
|
966
|
+
const Fe = "geometryUboDeclaration", Xt = `#include<sceneUboDeclaration>
|
|
967
|
+
`;
|
|
968
|
+
B.IncludesShadersStore[Fe] || (B.IncludesShadersStore[Fe] = Xt);
|
|
969
|
+
const _e = "geometryVertexShader", We = `precision highp float;
|
|
970
|
+
#include<bonesDeclaration>
|
|
971
|
+
#include<bakedVertexAnimationDeclaration>
|
|
972
|
+
#include<morphTargetsVertexGlobalDeclaration>
|
|
973
|
+
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
|
|
974
|
+
#include<instancesDeclaration>
|
|
975
|
+
#include<__decl__geometryVertex>
|
|
976
|
+
#include<clipPlaneVertexDeclaration>
|
|
977
|
+
#ifdef IRRADIANCE
|
|
978
|
+
#ifdef REFLECTION
|
|
979
|
+
uniform mat4 reflectionMatrix;uniform vec2 vReflectionInfos;uniform vec3 vReflectionColor;
|
|
980
|
+
#ifdef USESPHERICALFROMREFLECTIONMAP
|
|
981
|
+
varying vec3 vEnvironmentIrradiance;
|
|
982
|
+
#ifdef SPHERICAL_HARMONICS
|
|
983
|
+
uniform vec3 vSphericalL00;uniform vec3 vSphericalL1_1;uniform vec3 vSphericalL10;uniform vec3 vSphericalL11;uniform vec3 vSphericalL2_2;uniform vec3 vSphericalL2_1;uniform vec3 vSphericalL20;uniform vec3 vSphericalL21;uniform vec3 vSphericalL22;
|
|
984
|
+
#else
|
|
985
|
+
uniform vec3 vSphericalX;uniform vec3 vSphericalY;uniform vec3 vSphericalZ;uniform vec3 vSphericalXX_ZZ;uniform vec3 vSphericalYY_ZZ;uniform vec3 vSphericalZZ;uniform vec3 vSphericalXY;uniform vec3 vSphericalYZ;uniform vec3 vSphericalZX;
|
|
986
|
+
#endif
|
|
987
|
+
#include<harmonicsFunctions>
|
|
988
|
+
#endif
|
|
989
|
+
#endif
|
|
990
|
+
#endif
|
|
991
|
+
attribute vec3 position;
|
|
992
|
+
#ifdef HAS_NORMAL_ATTRIBUTE
|
|
993
|
+
attribute vec3 normal;
|
|
994
|
+
#endif
|
|
995
|
+
#ifdef NEED_UV
|
|
996
|
+
varying vec2 vUV;
|
|
997
|
+
#ifdef ALPHATEST
|
|
998
|
+
uniform mat4 diffuseMatrix;
|
|
999
|
+
#endif
|
|
1000
|
+
#ifdef BUMP
|
|
1001
|
+
uniform mat4 bumpMatrix;varying vec2 vBumpUV;
|
|
1002
|
+
#endif
|
|
1003
|
+
#ifdef REFLECTIVITY
|
|
1004
|
+
uniform mat4 reflectivityMatrix;uniform mat4 albedoMatrix;varying vec2 vReflectivityUV;varying vec2 vAlbedoUV;
|
|
1005
|
+
#endif
|
|
1006
|
+
#ifdef METALLIC_TEXTURE
|
|
1007
|
+
varying vec2 vMetallicUV;uniform mat4 metallicMatrix;
|
|
1008
|
+
#endif
|
|
1009
|
+
#ifdef ROUGHNESS_TEXTURE
|
|
1010
|
+
varying vec2 vRoughnessUV;uniform mat4 roughnessMatrix;
|
|
1011
|
+
#endif
|
|
1012
|
+
#ifdef SUBSURFACE_WEIGHT
|
|
1013
|
+
varying vec2 vSubsurfaceWeightUV;uniform mat4 subsurfaceWeightMatrix;
|
|
1014
|
+
#endif
|
|
1015
|
+
#ifdef TRANSMISSION_WEIGHT
|
|
1016
|
+
varying vec2 vTransmissionWeightUV;uniform mat4 transmissionWeightMatrix;
|
|
1017
|
+
#endif
|
|
1018
|
+
#ifdef UV1
|
|
1019
|
+
attribute vec2 uv;
|
|
1020
|
+
#endif
|
|
1021
|
+
#ifdef UV2
|
|
1022
|
+
attribute vec2 uv2;
|
|
1023
|
+
#endif
|
|
1024
|
+
#endif
|
|
1025
|
+
#ifdef BUMP
|
|
1026
|
+
varying mat4 vWorldView;
|
|
1027
|
+
#endif
|
|
1028
|
+
#ifdef BUMP
|
|
1029
|
+
varying vec3 vNormalW;
|
|
1030
|
+
#else
|
|
1031
|
+
varying vec3 vNormalV;
|
|
1032
|
+
#endif
|
|
1033
|
+
varying vec4 vViewPos;
|
|
1034
|
+
#if defined(POSITION) || defined(BUMP) || defined(IRRADIANCE)
|
|
1035
|
+
varying vec3 vPositionW;
|
|
1036
|
+
#endif
|
|
1037
|
+
#if defined(VELOCITY) || defined(VELOCITY_LINEAR)
|
|
1038
|
+
uniform mat4 previousViewProjection;varying vec4 vCurrentPosition;varying vec4 vPreviousPosition;
|
|
1039
|
+
#endif
|
|
1040
|
+
#define CUSTOM_VERTEX_DEFINITIONS
|
|
1041
|
+
void main(void)
|
|
1042
|
+
{vec3 positionUpdated=position;
|
|
1043
|
+
#ifdef HAS_NORMAL_ATTRIBUTE
|
|
1044
|
+
vec3 normalUpdated=normal;
|
|
1045
|
+
#else
|
|
1046
|
+
vec3 normalUpdated=vec3(0.0,0.0,0.0);
|
|
1047
|
+
#endif
|
|
1048
|
+
#ifdef UV1
|
|
1049
|
+
vec2 uvUpdated=uv;
|
|
1050
|
+
#endif
|
|
1051
|
+
#ifdef UV2
|
|
1052
|
+
vec2 uv2Updated=uv2;
|
|
1053
|
+
#endif
|
|
1054
|
+
#include<morphTargetsVertexGlobal>
|
|
1055
|
+
#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
|
|
1056
|
+
#include<instancesVertex>
|
|
1057
|
+
#if (defined(VELOCITY) || defined(VELOCITY_LINEAR)) && !defined(BONES_VELOCITY_ENABLED)
|
|
1058
|
+
vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);
|
|
1059
|
+
#endif
|
|
1060
|
+
#include<bonesVertex>
|
|
1061
|
+
#include<bakedVertexAnimation>
|
|
1062
|
+
vec4 worldPos=vec4(finalWorld*vec4(positionUpdated,1.0));
|
|
1063
|
+
#ifdef BUMP
|
|
1064
|
+
vWorldView=view*finalWorld;mat3 normalWorld=mat3(finalWorld);vNormalW=normalize(normalWorld*normalUpdated);
|
|
1065
|
+
#else
|
|
1066
|
+
#ifdef NORMAL_WORLDSPACE
|
|
1067
|
+
vNormalV=normalize(vec3(finalWorld*vec4(normalUpdated,0.0)));
|
|
1068
|
+
#else
|
|
1069
|
+
vNormalV=normalize(vec3((view*finalWorld)*vec4(normalUpdated,0.0)));
|
|
1070
|
+
#endif
|
|
1071
|
+
#endif
|
|
1072
|
+
vViewPos=view*worldPos;
|
|
1073
|
+
#if (defined(VELOCITY) || defined(VELOCITY_LINEAR)) && defined(BONES_VELOCITY_ENABLED)
|
|
1074
|
+
vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);
|
|
1075
|
+
#if NUM_BONE_INFLUENCERS>0
|
|
1076
|
+
mat4 previousInfluence;previousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];
|
|
1077
|
+
#if NUM_BONE_INFLUENCERS>1
|
|
1078
|
+
previousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];
|
|
1079
|
+
#endif
|
|
1080
|
+
#if NUM_BONE_INFLUENCERS>2
|
|
1081
|
+
previousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];
|
|
1082
|
+
#endif
|
|
1083
|
+
#if NUM_BONE_INFLUENCERS>3
|
|
1084
|
+
previousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];
|
|
1085
|
+
#endif
|
|
1086
|
+
#if NUM_BONE_INFLUENCERS>4
|
|
1087
|
+
previousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];
|
|
1088
|
+
#endif
|
|
1089
|
+
#if NUM_BONE_INFLUENCERS>5
|
|
1090
|
+
previousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];
|
|
1091
|
+
#endif
|
|
1092
|
+
#if NUM_BONE_INFLUENCERS>6
|
|
1093
|
+
previousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];
|
|
1094
|
+
#endif
|
|
1095
|
+
#if NUM_BONE_INFLUENCERS>7
|
|
1096
|
+
previousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];
|
|
1097
|
+
#endif
|
|
1098
|
+
vPreviousPosition=previousViewProjection*finalPreviousWorld*previousInfluence*vec4(positionUpdated,1.0);
|
|
1099
|
+
#else
|
|
1100
|
+
vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);
|
|
1101
|
+
#endif
|
|
1102
|
+
#endif
|
|
1103
|
+
#if defined(POSITION) || defined(BUMP) || defined(IRRADIANCE)
|
|
1104
|
+
vPositionW=worldPos.xyz/worldPos.w;
|
|
1105
|
+
#endif
|
|
1106
|
+
gl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);
|
|
1107
|
+
#include<clipPlaneVertex>
|
|
1108
|
+
#ifdef NEED_UV
|
|
1109
|
+
#ifdef UV1
|
|
1110
|
+
#if defined(ALPHATEST) && defined(ALPHATEST_UV1)
|
|
1111
|
+
vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
|
|
1112
|
+
#else
|
|
1113
|
+
vUV=uvUpdated;
|
|
1114
|
+
#endif
|
|
1115
|
+
#ifdef BUMP_UV1
|
|
1116
|
+
vBumpUV=vec2(bumpMatrix*vec4(uvUpdated,1.0,0.0));
|
|
1117
|
+
#endif
|
|
1118
|
+
#ifdef REFLECTIVITY_UV1
|
|
1119
|
+
vReflectivityUV=vec2(reflectivityMatrix*vec4(uvUpdated,1.0,0.0));
|
|
1120
|
+
#else
|
|
1121
|
+
#ifdef METALLIC_UV1
|
|
1122
|
+
vMetallicUV=vec2(metallicMatrix*vec4(uvUpdated,1.0,0.0));
|
|
1123
|
+
#endif
|
|
1124
|
+
#ifdef ROUGHNESS_UV1
|
|
1125
|
+
vRoughnessUV=vec2(roughnessMatrix*vec4(uvUpdated,1.0,0.0));
|
|
1126
|
+
#endif
|
|
1127
|
+
#endif
|
|
1128
|
+
#ifdef ALBEDO_UV1
|
|
1129
|
+
vAlbedoUV=vec2(albedoMatrix*vec4(uvUpdated,1.0,0.0));
|
|
1130
|
+
#endif
|
|
1131
|
+
#ifdef SUBSURFACE_COLOR_UV1
|
|
1132
|
+
vSubsurfaceColorUV=vec2(subsurfaceColorMatrix*vec4(uvUpdated,1.0,0.0));
|
|
1133
|
+
#endif
|
|
1134
|
+
#ifdef SUBSURFACE_WEIGHT_UV1
|
|
1135
|
+
vSubsurfaceWeightUV=vec2(subsurfaceWeightMatrix*vec4(uvUpdated,1.0,0.0));
|
|
1136
|
+
#endif
|
|
1137
|
+
#endif
|
|
1138
|
+
#ifdef UV2
|
|
1139
|
+
#if defined(ALPHATEST) && defined(ALPHATEST_UV2)
|
|
1140
|
+
vUV=vec2(diffuseMatrix*vec4(uv2Updated,1.0,0.0));
|
|
1141
|
+
#else
|
|
1142
|
+
vUV=uv2Updated;
|
|
1143
|
+
#endif
|
|
1144
|
+
#ifdef BUMP_UV2
|
|
1145
|
+
vBumpUV=vec2(bumpMatrix*vec4(uv2Updated,1.0,0.0));
|
|
1146
|
+
#endif
|
|
1147
|
+
#ifdef REFLECTIVITY_UV2
|
|
1148
|
+
vReflectivityUV=vec2(reflectivityMatrix*vec4(uv2Updated,1.0,0.0));
|
|
1149
|
+
#else
|
|
1150
|
+
#ifdef METALLIC_UV2
|
|
1151
|
+
vMetallicUV=vec2(metallicMatrix*vec4(uv2Updated,1.0,0.0));
|
|
1152
|
+
#endif
|
|
1153
|
+
#ifdef ROUGHNESS_UV2
|
|
1154
|
+
vRoughnessUV=vec2(roughnessMatrix*vec4(uv2Updated,1.0,0.0));
|
|
1155
|
+
#endif
|
|
1156
|
+
#endif
|
|
1157
|
+
#ifdef ALBEDO_UV2
|
|
1158
|
+
vAlbedoUV=vec2(albedoMatrix*vec4(uv2Updated,1.0,0.0));
|
|
1159
|
+
#endif
|
|
1160
|
+
#ifdef SUBSURFACE_COLOR_UV2
|
|
1161
|
+
vSubsurfaceColorUV=vec2(subsurfaceColorMatrix*vec4(uv2Updated,1.0,0.0));
|
|
1162
|
+
#endif
|
|
1163
|
+
#ifdef SUBSURFACE_WEIGHT_UV2
|
|
1164
|
+
vSubsurfaceWeightUV=vec2(subsurfaceWeightMatrix*vec4(uv2Updated,1.0,0.0));
|
|
1165
|
+
#endif
|
|
1166
|
+
#endif
|
|
1167
|
+
#endif
|
|
1168
|
+
#include<bumpVertex>
|
|
1169
|
+
#ifdef IRRADIANCE
|
|
1170
|
+
#ifdef REFLECTION
|
|
1171
|
+
#ifdef USESPHERICALFROMREFLECTIONMAP
|
|
1172
|
+
vec3 reflectionVector=vec3(reflectionMatrix*vec4(normalUpdated,0.0)).xyz;
|
|
1173
|
+
#ifdef REFLECTIONMAP_OPPOSITEZ
|
|
1174
|
+
reflectionVector.z*=-1.0;
|
|
1175
|
+
#endif
|
|
1176
|
+
vEnvironmentIrradiance=computeEnvironmentIrradiance(reflectionVector)*vReflectionInfos.x;
|
|
1177
|
+
#endif
|
|
1178
|
+
#endif
|
|
1179
|
+
#endif
|
|
1180
|
+
}
|
|
1181
|
+
`;
|
|
1182
|
+
B.ShadersStore[_e] || (B.ShadersStore[_e] = We);
|
|
1183
|
+
const Yt = { name: _e, shader: We }, Zt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1184
|
+
__proto__: null,
|
|
1185
|
+
geometryVertexShader: Yt
|
|
1186
|
+
}, Symbol.toStringTag, { value: "Module" })), we = [
|
|
1187
|
+
"diffuseSampler",
|
|
1188
|
+
"bumpSampler",
|
|
1189
|
+
"reflectivitySampler",
|
|
1190
|
+
"albedoSampler",
|
|
1191
|
+
"morphTargets",
|
|
1192
|
+
"boneSampler",
|
|
1193
|
+
"transmissionWeightSampler",
|
|
1194
|
+
"subsurfaceWeightSampler",
|
|
1195
|
+
"iblShadowSampler"
|
|
1196
|
+
], Te = [
|
|
1197
|
+
"world",
|
|
1198
|
+
"mBones",
|
|
1199
|
+
"viewProjection",
|
|
1200
|
+
"diffuseMatrix",
|
|
1201
|
+
"view",
|
|
1202
|
+
"previousWorld",
|
|
1203
|
+
"previousViewProjection",
|
|
1204
|
+
"mPreviousBones",
|
|
1205
|
+
"bumpMatrix",
|
|
1206
|
+
"reflectivityMatrix",
|
|
1207
|
+
"albedoMatrix",
|
|
1208
|
+
"reflectivityColor",
|
|
1209
|
+
"albedoColor",
|
|
1210
|
+
"reflectionMatrix",
|
|
1211
|
+
"vTransmissionWeight",
|
|
1212
|
+
"vSubsurfaceWeight",
|
|
1213
|
+
"vEyePosition",
|
|
1214
|
+
"vTransmissionScatterAnisotropy",
|
|
1215
|
+
"vSubsurfaceScatterAnisotropy",
|
|
1216
|
+
"shadowTextureSize",
|
|
1217
|
+
"metallic",
|
|
1218
|
+
"glossiness",
|
|
1219
|
+
"vTangentSpaceParams",
|
|
1220
|
+
"vBumpInfos",
|
|
1221
|
+
"morphTargetInfluences",
|
|
1222
|
+
"morphTargetCount",
|
|
1223
|
+
"morphTargetTextureInfo",
|
|
1224
|
+
"morphTargetTextureIndices",
|
|
1225
|
+
"boneTextureInfo"
|
|
1226
|
+
];
|
|
1227
|
+
Be(Te, we, !0);
|
|
1228
|
+
Ve(Te);
|
|
1229
|
+
class C {
|
|
1230
|
+
/**
|
|
1231
|
+
* Gets a boolean indicating if normals are encoded in the [0,1] range in the render target. If true, you should do `normal = normal_rt * 2.0 - 1.0` to get the right normal
|
|
1232
|
+
*/
|
|
1233
|
+
get normalsAreUnsigned() {
|
|
1234
|
+
return this._normalsAreUnsigned;
|
|
1235
|
+
}
|
|
1236
|
+
/**
|
|
1237
|
+
* @internal
|
|
1238
|
+
* Sets up internal structures to share outputs with PrePassRenderer
|
|
1239
|
+
* This method should only be called by the PrePassRenderer itself
|
|
1240
|
+
*/
|
|
1241
|
+
_linkPrePassRenderer(t) {
|
|
1242
|
+
this._linkedWithPrePass = !0, this._prePassRenderer = t, this._multiRenderTarget && (this._multiRenderTarget.onClearObservable.clear(), this._multiRenderTarget.onClearObservable.add(() => {
|
|
1243
|
+
}));
|
|
1244
|
+
}
|
|
1245
|
+
/**
|
|
1246
|
+
* @internal
|
|
1247
|
+
* Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
|
|
1248
|
+
* This method should only be called by the PrePassRenderer itself
|
|
1249
|
+
*/
|
|
1250
|
+
_unlinkPrePassRenderer() {
|
|
1251
|
+
this._linkedWithPrePass = !1, this._createRenderTargets();
|
|
1252
|
+
}
|
|
1253
|
+
/**
|
|
1254
|
+
* @internal
|
|
1255
|
+
* Resets the geometry buffer layout
|
|
1256
|
+
*/
|
|
1257
|
+
_resetLayout() {
|
|
1258
|
+
this._enableDepth = !0, this._enableNormal = !0, this._enablePosition = !1, this._enableReflectivity = !1, this._enableVelocity = !1, this._enableVelocityLinear = !1, this._enableScreenspaceDepth = !1, this._enableIrradiance = !1, this._attachmentsFromPrePass = [];
|
|
1259
|
+
}
|
|
1260
|
+
/**
|
|
1261
|
+
* @internal
|
|
1262
|
+
* Replaces a texture in the geometry buffer renderer
|
|
1263
|
+
* Useful when linking textures of the prepass renderer
|
|
1264
|
+
*/
|
|
1265
|
+
_forceTextureType(t, s) {
|
|
1266
|
+
t === C.POSITION_TEXTURE_TYPE ? (this._positionIndex = s, this._enablePosition = !0) : t === C.VELOCITY_TEXTURE_TYPE ? (this._velocityIndex = s, this._enableVelocity = !0) : t === C.VELOCITY_LINEAR_TEXTURE_TYPE ? (this._velocityLinearIndex = s, this._enableVelocityLinear = !0) : t === C.REFLECTIVITY_TEXTURE_TYPE ? (this._reflectivityIndex = s, this._enableReflectivity = !0) : t === C.DEPTH_TEXTURE_TYPE ? (this._depthIndex = s, this._enableDepth = !0) : t === C.NORMAL_TEXTURE_TYPE ? (this._normalIndex = s, this._enableNormal = !0) : t === C.SCREENSPACE_DEPTH_TEXTURE_TYPE ? (this._screenspaceDepthIndex = s, this._enableScreenspaceDepth = !0) : t === C.IRRADIANCE_TEXTURE_TYPE && (this._irradianceIndex = s, this._enableIrradiance = !0);
|
|
1267
|
+
}
|
|
1268
|
+
/**
|
|
1269
|
+
* @internal
|
|
1270
|
+
* Sets texture attachments
|
|
1271
|
+
* Useful when linking textures of the prepass renderer
|
|
1272
|
+
*/
|
|
1273
|
+
_setAttachments(t) {
|
|
1274
|
+
this._attachmentsFromPrePass = t;
|
|
1275
|
+
}
|
|
1276
|
+
/**
|
|
1277
|
+
* @internal
|
|
1278
|
+
* Replaces the first texture which is hard coded as a depth texture in the geometry buffer
|
|
1279
|
+
* Useful when linking textures of the prepass renderer
|
|
1280
|
+
*/
|
|
1281
|
+
_linkInternalTexture(t) {
|
|
1282
|
+
this._multiRenderTarget.setInternalTexture(t, 0, !1);
|
|
1283
|
+
}
|
|
1284
|
+
/**
|
|
1285
|
+
* Gets the render list (meshes to be rendered) used in the G buffer.
|
|
1286
|
+
*/
|
|
1287
|
+
get renderList() {
|
|
1288
|
+
return this._multiRenderTarget.renderList;
|
|
1289
|
+
}
|
|
1290
|
+
/**
|
|
1291
|
+
* Set the render list (meshes to be rendered) used in the G buffer.
|
|
1292
|
+
*/
|
|
1293
|
+
set renderList(t) {
|
|
1294
|
+
this._multiRenderTarget.renderList = t;
|
|
1295
|
+
}
|
|
1296
|
+
/**
|
|
1297
|
+
* Gets whether or not G buffer are supported by the running hardware.
|
|
1298
|
+
* This requires draw buffer supports
|
|
1299
|
+
*/
|
|
1300
|
+
get isSupported() {
|
|
1301
|
+
return this._multiRenderTarget.isSupported;
|
|
1302
|
+
}
|
|
1303
|
+
/**
|
|
1304
|
+
* Returns the index of the given texture type in the G-Buffer textures array
|
|
1305
|
+
* @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
|
|
1306
|
+
* @returns the index of the given texture type in the G-Buffer textures array
|
|
1307
|
+
*/
|
|
1308
|
+
getTextureIndex(t) {
|
|
1309
|
+
switch (t) {
|
|
1310
|
+
case C.POSITION_TEXTURE_TYPE:
|
|
1311
|
+
return this._positionIndex;
|
|
1312
|
+
case C.VELOCITY_TEXTURE_TYPE:
|
|
1313
|
+
return this._velocityIndex;
|
|
1314
|
+
case C.VELOCITY_LINEAR_TEXTURE_TYPE:
|
|
1315
|
+
return this._velocityLinearIndex;
|
|
1316
|
+
case C.REFLECTIVITY_TEXTURE_TYPE:
|
|
1317
|
+
return this._reflectivityIndex;
|
|
1318
|
+
case C.DEPTH_TEXTURE_TYPE:
|
|
1319
|
+
return this._depthIndex;
|
|
1320
|
+
case C.NORMAL_TEXTURE_TYPE:
|
|
1321
|
+
return this._normalIndex;
|
|
1322
|
+
case C.SCREENSPACE_DEPTH_TEXTURE_TYPE:
|
|
1323
|
+
return this._screenspaceDepthIndex;
|
|
1324
|
+
case C.IRRADIANCE_TEXTURE_TYPE:
|
|
1325
|
+
return this._irradianceIndex;
|
|
1326
|
+
default:
|
|
1327
|
+
return -1;
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
/**
|
|
1331
|
+
* @returns a boolean indicating if object's depths are enabled for the G buffer.
|
|
1332
|
+
*/
|
|
1333
|
+
get enableDepth() {
|
|
1334
|
+
return this._enableDepth;
|
|
1335
|
+
}
|
|
1336
|
+
/**
|
|
1337
|
+
* Sets whether or not object's depths are enabled for the G buffer.
|
|
1338
|
+
*/
|
|
1339
|
+
set enableDepth(t) {
|
|
1340
|
+
this._enableDepth = t, this._linkedWithPrePass || (this.dispose(), this._createRenderTargets());
|
|
1341
|
+
}
|
|
1342
|
+
/**
|
|
1343
|
+
* @returns a boolean indicating if object's normals are enabled for the G buffer.
|
|
1344
|
+
*/
|
|
1345
|
+
get enableNormal() {
|
|
1346
|
+
return this._enableNormal;
|
|
1347
|
+
}
|
|
1348
|
+
/**
|
|
1349
|
+
* Sets whether or not object's normals are enabled for the G buffer.
|
|
1350
|
+
*/
|
|
1351
|
+
set enableNormal(t) {
|
|
1352
|
+
this._enableNormal = t, this._linkedWithPrePass || (this.dispose(), this._createRenderTargets());
|
|
1353
|
+
}
|
|
1354
|
+
/**
|
|
1355
|
+
* @returns a boolean indicating if objects positions are enabled for the G buffer.
|
|
1356
|
+
*/
|
|
1357
|
+
get enablePosition() {
|
|
1358
|
+
return this._enablePosition;
|
|
1359
|
+
}
|
|
1360
|
+
/**
|
|
1361
|
+
* Sets whether or not objects positions are enabled for the G buffer.
|
|
1362
|
+
*/
|
|
1363
|
+
set enablePosition(t) {
|
|
1364
|
+
this._enablePosition = t, this._linkedWithPrePass || (this.dispose(), this._createRenderTargets());
|
|
1365
|
+
}
|
|
1366
|
+
/**
|
|
1367
|
+
* @returns a boolean indicating if objects velocities are enabled for the G buffer.
|
|
1368
|
+
*/
|
|
1369
|
+
get enableVelocity() {
|
|
1370
|
+
return this._enableVelocity;
|
|
1371
|
+
}
|
|
1372
|
+
/**
|
|
1373
|
+
* Sets whether or not objects velocities are enabled for the G buffer.
|
|
1374
|
+
*/
|
|
1375
|
+
set enableVelocity(t) {
|
|
1376
|
+
this._enableVelocity = t, t || (this._previousTransformationMatrices = {}), this._linkedWithPrePass || (this.dispose(), this._createRenderTargets()), this._scene.needsPreviousWorldMatrices = t;
|
|
1377
|
+
}
|
|
1378
|
+
/**
|
|
1379
|
+
* @returns a boolean indicating if object's linear velocities are enabled for the G buffer.
|
|
1380
|
+
*/
|
|
1381
|
+
get enableVelocityLinear() {
|
|
1382
|
+
return this._enableVelocityLinear;
|
|
1383
|
+
}
|
|
1384
|
+
/**
|
|
1385
|
+
* Sets whether or not object's linear velocities are enabled for the G buffer.
|
|
1386
|
+
*/
|
|
1387
|
+
set enableVelocityLinear(t) {
|
|
1388
|
+
this._enableVelocityLinear = t, this._linkedWithPrePass || (this.dispose(), this._createRenderTargets());
|
|
1389
|
+
}
|
|
1390
|
+
/**
|
|
1391
|
+
* Gets a boolean indicating if objects reflectivity are enabled in the G buffer.
|
|
1392
|
+
*/
|
|
1393
|
+
get enableReflectivity() {
|
|
1394
|
+
return this._enableReflectivity;
|
|
1395
|
+
}
|
|
1396
|
+
/**
|
|
1397
|
+
* Sets whether or not objects reflectivity are enabled for the G buffer.
|
|
1398
|
+
* For Metallic-Roughness workflow with ORM texture, we assume that ORM texture is defined according to the default layout:
|
|
1399
|
+
* pbr.useRoughnessFromMetallicTextureAlpha = false;
|
|
1400
|
+
* pbr.useRoughnessFromMetallicTextureGreen = true;
|
|
1401
|
+
* pbr.useMetallnessFromMetallicTextureBlue = true;
|
|
1402
|
+
*/
|
|
1403
|
+
set enableReflectivity(t) {
|
|
1404
|
+
this._enableReflectivity = t, this._linkedWithPrePass || (this.dispose(), this._createRenderTargets());
|
|
1405
|
+
}
|
|
1406
|
+
/**
|
|
1407
|
+
* Sets whether or not objects screenspace depth are enabled for the G buffer.
|
|
1408
|
+
*/
|
|
1409
|
+
get enableScreenspaceDepth() {
|
|
1410
|
+
return this._enableScreenspaceDepth;
|
|
1411
|
+
}
|
|
1412
|
+
set enableScreenspaceDepth(t) {
|
|
1413
|
+
this._enableScreenspaceDepth = t, this._linkedWithPrePass || (this.dispose(), this._createRenderTargets());
|
|
1414
|
+
}
|
|
1415
|
+
/**
|
|
1416
|
+
* Gets a boolean indicating if objects irradiance are enabled in the G buffer.
|
|
1417
|
+
*/
|
|
1418
|
+
get enableIrradiance() {
|
|
1419
|
+
return this._enableIrradiance;
|
|
1420
|
+
}
|
|
1421
|
+
/**
|
|
1422
|
+
* Sets whether or not objects irradiance are enabled for the G buffer.
|
|
1423
|
+
*/
|
|
1424
|
+
set enableIrradiance(t) {
|
|
1425
|
+
this._enableIrradiance = t, this._linkedWithPrePass || (this.dispose(), this._createRenderTargets());
|
|
1426
|
+
}
|
|
1427
|
+
/**
|
|
1428
|
+
* Gets the scene associated with the buffer.
|
|
1429
|
+
*/
|
|
1430
|
+
get scene() {
|
|
1431
|
+
return this._scene;
|
|
1432
|
+
}
|
|
1433
|
+
/**
|
|
1434
|
+
* Gets the ratio used by the buffer during its creation.
|
|
1435
|
+
* How big is the buffer related to the main canvas.
|
|
1436
|
+
*/
|
|
1437
|
+
get ratio() {
|
|
1438
|
+
return typeof this._ratioOrDimensions == "object" ? 1 : this._ratioOrDimensions;
|
|
1439
|
+
}
|
|
1440
|
+
/**
|
|
1441
|
+
* Gets the shader language used in this material.
|
|
1442
|
+
*/
|
|
1443
|
+
get shaderLanguage() {
|
|
1444
|
+
return this._shaderLanguage;
|
|
1445
|
+
}
|
|
1446
|
+
/**
|
|
1447
|
+
* Creates a new G Buffer for the scene
|
|
1448
|
+
* @param scene The scene the buffer belongs to
|
|
1449
|
+
* @param ratioOrDimensions How big is the buffer related to the main canvas (default: 1). You can also directly pass a width and height for the generated textures
|
|
1450
|
+
* @param depthFormat Format of the depth texture (default: 15)
|
|
1451
|
+
* @param textureTypesAndFormats The types, formats and optional sampling modes of textures to create as render targets.
|
|
1452
|
+
* If not provided, all textures will be RGBA and float or half float, depending on the engine capabilities.
|
|
1453
|
+
*/
|
|
1454
|
+
constructor(t, s = 1, e = 15, i) {
|
|
1455
|
+
this._previousTransformationMatrices = {}, this._previousBonesTransformationMatrices = {}, this.excludedSkinnedMeshesFromVelocity = [], this.renderTransparentMeshes = !0, this.generateNormalsInWorldSpace = !1, this._normalsAreUnsigned = !1, this._resizeObserver = null, this._enableDepth = !0, this._enableNormal = !0, this._enablePosition = !1, this._enableVelocity = !1, this._enableVelocityLinear = !1, this._enableReflectivity = !1, this._enableScreenspaceDepth = !1, this._enableIrradiance = !1, this._clearColor = new ge(0, 0, 0, 0), this._clearDepthColor = new ge(0, 0, 0, 1), this._positionIndex = -1, this._velocityIndex = -1, this._velocityLinearIndex = -1, this._reflectivityIndex = -1, this._depthIndex = -1, this._normalIndex = -1, this._screenspaceDepthIndex = -1, this._irradianceIndex = -1, this._linkedWithPrePass = !1, this.generateIrradianceWithScatterMask = !1, this.useSpecificClearForDepthTexture = !1, this._shaderLanguage = 0, this._shadersLoaded = !1, this._scene = t, this._ratioOrDimensions = s, this._useUbo = t.getEngine().supportsUniformBuffers, this._depthFormat = e, this._textureTypesAndFormats = i || {}, this._initShaderSourceAsync(), C._SceneComponentInitialization(this._scene), this._createRenderTargets();
|
|
1456
|
+
}
|
|
1457
|
+
async _initShaderSourceAsync() {
|
|
1458
|
+
this._scene.getEngine().isWebGPU && !C.ForceGLSL ? (this._shaderLanguage = 1, await Promise.all([import("./geometry.vertex-DskQ5b8j.js"), import("./geometry.fragment-Bsis3UG2.js")])) : await Promise.all([Promise.resolve().then(() => Zt), Promise.resolve().then(() => kt)]), this._shadersLoaded = !0;
|
|
1459
|
+
}
|
|
1460
|
+
/**
|
|
1461
|
+
* Checks whether everything is ready to render a submesh to the G buffer.
|
|
1462
|
+
* @param subMesh the submesh to check readiness for
|
|
1463
|
+
* @param useInstances is the mesh drawn using instance or not
|
|
1464
|
+
* @returns true if ready otherwise false
|
|
1465
|
+
*/
|
|
1466
|
+
isReady(t, s) {
|
|
1467
|
+
if (!this._shadersLoaded)
|
|
1468
|
+
return !1;
|
|
1469
|
+
const e = t.getMaterial();
|
|
1470
|
+
if (e && e.disableDepthWrite)
|
|
1471
|
+
return !1;
|
|
1472
|
+
const i = [], n = [G.PositionKind], a = t.getMesh();
|
|
1473
|
+
a.isVerticesDataPresent(G.NormalKind) && (i.push("#define HAS_NORMAL_ATTRIBUTE"), n.push(G.NormalKind));
|
|
1474
|
+
let I = !1, L = !1;
|
|
1475
|
+
const h = !1;
|
|
1476
|
+
if (e) {
|
|
1477
|
+
let R = !1;
|
|
1478
|
+
if (e.needAlphaTestingForMesh(a) && e.getAlphaTestTexture() && (i.push("#define ALPHATEST"), i.push(`#define ALPHATEST_UV${e.getAlphaTestTexture().coordinatesIndex + 1}`), R = !0), (e.bumpTexture || e.normalTexture || e.geometryNormalTexture) && H.BumpTextureEnabled) {
|
|
1479
|
+
const T = e.bumpTexture || e.normalTexture || e.geometryNormalTexture;
|
|
1480
|
+
i.push("#define BUMP"), i.push(`#define BUMP_UV${T.coordinatesIndex + 1}`), R = !0;
|
|
1481
|
+
}
|
|
1482
|
+
if (this._enableReflectivity) {
|
|
1483
|
+
let T = !1;
|
|
1484
|
+
if (e.getClassName() === "PBRMetallicRoughnessMaterial")
|
|
1485
|
+
e.metallicRoughnessTexture && (i.push("#define ORMTEXTURE"), i.push(`#define REFLECTIVITY_UV${e.metallicRoughnessTexture.coordinatesIndex + 1}`), i.push("#define METALLICWORKFLOW"), R = !0, T = !0), e.metallic != null && (i.push("#define METALLIC"), i.push("#define METALLICWORKFLOW"), T = !0), e.roughness != null && (i.push("#define ROUGHNESS"), i.push("#define METALLICWORKFLOW"), T = !0), T && (e.baseTexture && (i.push("#define ALBEDOTEXTURE"), i.push(`#define ALBEDO_UV${e.baseTexture.coordinatesIndex + 1}`), e.baseTexture.gammaSpace && i.push("#define GAMMAALBEDO"), R = !0), e.baseColor && i.push("#define ALBEDOCOLOR"));
|
|
1486
|
+
else if (e.getClassName() === "PBRSpecularGlossinessMaterial")
|
|
1487
|
+
e.specularGlossinessTexture ? (i.push("#define SPECULARGLOSSINESSTEXTURE"), i.push(`#define REFLECTIVITY_UV${e.specularGlossinessTexture.coordinatesIndex + 1}`), R = !0, e.specularGlossinessTexture.gammaSpace && i.push("#define GAMMAREFLECTIVITYTEXTURE")) : e.specularColor && i.push("#define REFLECTIVITYCOLOR"), e.glossiness != null && i.push("#define GLOSSINESS");
|
|
1488
|
+
else if (e.getClassName() === "PBRMaterial")
|
|
1489
|
+
e.metallicTexture && (i.push("#define ORMTEXTURE"), i.push(`#define REFLECTIVITY_UV${e.metallicTexture.coordinatesIndex + 1}`), i.push("#define METALLICWORKFLOW"), R = !0, T = !0), e.metallic != null && (i.push("#define METALLIC"), i.push("#define METALLICWORKFLOW"), T = !0), e.roughness != null && (i.push("#define ROUGHNESS"), i.push("#define METALLICWORKFLOW"), T = !0), T ? (e.albedoTexture && (i.push("#define ALBEDOTEXTURE"), i.push(`#define ALBEDO_UV${e.albedoTexture.coordinatesIndex + 1}`), e.albedoTexture.gammaSpace && i.push("#define GAMMAALBEDO"), R = !0), e.albedoColor && i.push("#define ALBEDOCOLOR")) : (e.reflectivityTexture ? (i.push("#define SPECULARGLOSSINESSTEXTURE"), i.push(`#define REFLECTIVITY_UV${e.reflectivityTexture.coordinatesIndex + 1}`), e.reflectivityTexture.gammaSpace && i.push("#define GAMMAREFLECTIVITYTEXTURE"), R = !0) : e.reflectivityColor && i.push("#define REFLECTIVITYCOLOR"), e.microSurface != null && i.push("#define GLOSSINESS"));
|
|
1490
|
+
else if (e.getClassName() === "StandardMaterial")
|
|
1491
|
+
e.specularTexture && (i.push("#define REFLECTIVITYTEXTURE"), i.push(`#define REFLECTIVITY_UV${e.specularTexture.coordinatesIndex + 1}`), e.specularTexture.gammaSpace && i.push("#define GAMMAREFLECTIVITYTEXTURE"), R = !0), e.specularColor && i.push("#define REFLECTIVITYCOLOR");
|
|
1492
|
+
else if (e.getClassName() === "OpenPBRMaterial") {
|
|
1493
|
+
const m = e;
|
|
1494
|
+
i.push("#define METALLIC"), i.push("#define ROUGHNESS"), m._useRoughnessFromMetallicTextureGreen && m.baseMetalnessTexture ? (i.push("#define ORMTEXTURE"), i.push(`#define REFLECTIVITY_UV${m.baseMetalnessTexture.coordinatesIndex + 1}`), R = !0) : m.baseMetalnessTexture ? (i.push("#define METALLIC_TEXTURE"), i.push(`#define METALLIC_UV${m.baseMetalnessTexture.coordinatesIndex + 1}`), R = !0) : m.specularRoughnessTexture && (i.push("#define ROUGHNESS_TEXTURE"), i.push(`#define ROUGHNESS_UV${m.specularRoughnessTexture.coordinatesIndex + 1}`), R = !0), m.baseColorTexture && (i.push("#define ALBEDOTEXTURE"), i.push(`#define ALBEDO_UV${m.baseColorTexture.coordinatesIndex + 1}`), m.baseColorTexture.gammaSpace && i.push("#define GAMMAALBEDO"), R = !0), m.baseColor && i.push("#define ALBEDOCOLOR");
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
if (this._enableIrradiance && this.generateIrradianceWithScatterMask && (i.push("#define IRRADIANCE_SCATTER_MASK"), e.getClassName() === "OpenPBRMaterial")) {
|
|
1498
|
+
const T = e;
|
|
1499
|
+
T.subsurfaceWeight > 0 && T.subsurfaceWeightTexture && (i.push("#define SUBSURFACE_WEIGHT"), i.push(`#define SUBSURFACEWEIGHT_UV${T.subsurfaceWeightTexture.coordinatesIndex + 1}`), R = !0), T.transmissionWeight > 0 && T.transmissionWeightTexture && (i.push("#define TRANSMISSION_WEIGHT"), i.push(`#define TRANSMISSIONWEIGHT_UV${T.transmissionWeightTexture.coordinatesIndex + 1}`), R = !0);
|
|
1500
|
+
}
|
|
1501
|
+
R && (i.push("#define NEED_UV"), a.isVerticesDataPresent(G.UVKind) && (n.push(G.UVKind), i.push("#define UV1"), I = !0), a.isVerticesDataPresent(G.UV2Kind) && (n.push(G.UV2Kind), i.push("#define UV2"), L = !0));
|
|
1502
|
+
}
|
|
1503
|
+
if (this._enableDepth && (i.push("#define DEPTH"), i.push("#define DEPTH_INDEX " + this._depthIndex)), this._enableNormal && (i.push("#define NORMAL"), i.push("#define NORMAL_INDEX " + this._normalIndex)), this._enablePosition && (i.push("#define POSITION"), i.push("#define POSITION_INDEX " + this._positionIndex)), this._enableVelocity && (i.push("#define VELOCITY"), i.push("#define VELOCITY_INDEX " + this._velocityIndex), this.excludedSkinnedMeshesFromVelocity.indexOf(a) === -1 && i.push("#define BONES_VELOCITY_ENABLED")), this._enableVelocityLinear && (i.push("#define VELOCITY_LINEAR"), i.push("#define VELOCITY_LINEAR_INDEX " + this._velocityLinearIndex), this.excludedSkinnedMeshesFromVelocity.indexOf(a) === -1 && i.push("#define BONES_VELOCITY_ENABLED")), this._enableReflectivity && (i.push("#define REFLECTIVITY"), i.push("#define REFLECTIVITY_INDEX " + this._reflectivityIndex)), this._enableScreenspaceDepth && this._screenspaceDepthIndex !== -1 && (i.push("#define SCREENSPACE_DEPTH_INDEX " + this._screenspaceDepthIndex), i.push("#define SCREENSPACE_DEPTH")), this._enableIrradiance && this._irradianceIndex !== -1) {
|
|
1504
|
+
i.push("#define IRRADIANCE_INDEX " + this._irradianceIndex), i.push("#define IRRADIANCE");
|
|
1505
|
+
const R = this._scene;
|
|
1506
|
+
if (R.environmentTexture) {
|
|
1507
|
+
const T = {};
|
|
1508
|
+
let m = !1, F = 0;
|
|
1509
|
+
(e.getClassName() === "OpenPBRMaterial" || e.getClassName() === "StandardMaterial" || e.getClassName() === "PBRMetallicRoughnessMaterial" || e.getClassName() === "PBRSpecularGlossinessMaterial" || e.getClassName() === "PBRMaterial") && (m = !!e.realtimeFiltering, F = e.realtimeFilteringQuality || 0), De(R, R.environmentTexture, T, m, F, !0);
|
|
1510
|
+
for (const S in T)
|
|
1511
|
+
T[S] && i.push("#define " + S);
|
|
1512
|
+
T.USEIRRADIANCEMAP || i.push("#define SPHERICAL_HARMONICS");
|
|
1513
|
+
const y = R.postProcessRenderPipelineManager.supportedPipelines.find((S) => S.getClassName() === "IBLShadowsRenderPipeline");
|
|
1514
|
+
if (y) {
|
|
1515
|
+
const S = y;
|
|
1516
|
+
S._getAccumulatedTexture() && (i.push("#define IBL_SHADOW_TEXTURE"), S.coloredShadows && i.push("#define COLORED_IBL_SHADOWS"));
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
this.generateNormalsInWorldSpace && i.push("#define NORMAL_WORLDSPACE"), this._normalsAreUnsigned && i.push("#define ENCODE_NORMAL"), a.useBones && a.computeBonesUsingShaders && a.skeleton ? (n.push(G.MatricesIndicesKind), n.push(G.MatricesWeightsKind), a.numBoneInfluencers > 4 && (n.push(G.MatricesIndicesExtraKind), n.push(G.MatricesWeightsExtraKind)), i.push("#define NUM_BONE_INFLUENCERS " + a.numBoneInfluencers), i.push("#define BONETEXTURE " + a.skeleton.isUsingTextureForMatrices), i.push("#define BonesPerMesh " + (a.skeleton.bones.length + 1))) : (i.push("#define NUM_BONE_INFLUENCERS 0"), i.push("#define BONETEXTURE false"), i.push("#define BonesPerMesh 0"));
|
|
1521
|
+
const u = a.morphTargetManager ? ze(
|
|
1522
|
+
a.morphTargetManager,
|
|
1523
|
+
i,
|
|
1524
|
+
n,
|
|
1525
|
+
a,
|
|
1526
|
+
!0,
|
|
1527
|
+
// usePositionMorph
|
|
1528
|
+
!0,
|
|
1529
|
+
// useNormalMorph
|
|
1530
|
+
!1,
|
|
1531
|
+
// useTangentMorph
|
|
1532
|
+
I,
|
|
1533
|
+
// useUVMorph
|
|
1534
|
+
L,
|
|
1535
|
+
// useUV2Morph
|
|
1536
|
+
h
|
|
1537
|
+
// useColorMorph
|
|
1538
|
+
) : 0;
|
|
1539
|
+
s && (i.push("#define INSTANCES"), Xe(n, this._enableVelocity || this._enableVelocityLinear), t.getRenderingMesh().hasThinInstances && i.push("#define THIN_INSTANCES")), this._linkedWithPrePass ? i.push("#define SCENE_MRT_COUNT " + this._attachmentsFromPrePass.length) : i.push("#define SCENE_MRT_COUNT " + this._multiRenderTarget.textures.length), Ye(e, this._scene, i);
|
|
1540
|
+
const A = this._scene.getEngine(), N = t._getDrawWrapper(void 0, !0), x = N.defines, M = i.join(`
|
|
1541
|
+
`);
|
|
1542
|
+
return x !== M && N.setEffect(A.createEffect("geometry", {
|
|
1543
|
+
attributes: n,
|
|
1544
|
+
uniformsNames: Te,
|
|
1545
|
+
samplers: we,
|
|
1546
|
+
defines: M,
|
|
1547
|
+
onCompiled: null,
|
|
1548
|
+
fallbacks: null,
|
|
1549
|
+
onError: null,
|
|
1550
|
+
uniformBuffersNames: ["Scene"],
|
|
1551
|
+
indexParameters: { buffersCount: this._multiRenderTarget.textures.length - 1, maxSimultaneousMorphTargets: u },
|
|
1552
|
+
shaderLanguage: this.shaderLanguage
|
|
1553
|
+
}, A), M), N.effect.isReady();
|
|
1554
|
+
}
|
|
1555
|
+
/**
|
|
1556
|
+
* Gets the current underlying G Buffer.
|
|
1557
|
+
* @returns the buffer
|
|
1558
|
+
*/
|
|
1559
|
+
getGBuffer() {
|
|
1560
|
+
return this._multiRenderTarget;
|
|
1561
|
+
}
|
|
1562
|
+
/**
|
|
1563
|
+
* Gets the number of samples used to render the buffer (anti aliasing).
|
|
1564
|
+
*/
|
|
1565
|
+
get samples() {
|
|
1566
|
+
return this._multiRenderTarget.samples;
|
|
1567
|
+
}
|
|
1568
|
+
/**
|
|
1569
|
+
* Sets the number of samples used to render the buffer (anti aliasing).
|
|
1570
|
+
*/
|
|
1571
|
+
set samples(t) {
|
|
1572
|
+
this._multiRenderTarget.samples = t;
|
|
1573
|
+
}
|
|
1574
|
+
/**
|
|
1575
|
+
* Disposes the renderer and frees up associated resources.
|
|
1576
|
+
*/
|
|
1577
|
+
dispose() {
|
|
1578
|
+
this._resizeObserver && (this._scene.getEngine().onResizeObservable.remove(this._resizeObserver), this._resizeObserver = null), this._multiRenderTarget?.renderTarget && this.scene.getEngine()._currentRenderTarget === this._multiRenderTarget.renderTarget && this.scene.getEngine().unBindFramebuffer(this._multiRenderTarget?.renderTarget), this.getGBuffer().dispose();
|
|
1579
|
+
}
|
|
1580
|
+
_assignRenderTargetIndices() {
|
|
1581
|
+
const t = [], s = [];
|
|
1582
|
+
let e = 0;
|
|
1583
|
+
return this._enableDepth && (this._depthIndex = e, e++, t.push("gBuffer_Depth"), s.push(this._textureTypesAndFormats[C.DEPTH_TEXTURE_TYPE])), this._enableNormal && (this._normalIndex = e, e++, t.push("gBuffer_Normal"), s.push(this._textureTypesAndFormats[C.NORMAL_TEXTURE_TYPE])), this._enablePosition && (this._positionIndex = e, e++, t.push("gBuffer_Position"), s.push(this._textureTypesAndFormats[C.POSITION_TEXTURE_TYPE])), this._enableVelocity && (this._velocityIndex = e, e++, t.push("gBuffer_Velocity"), s.push(this._textureTypesAndFormats[C.VELOCITY_TEXTURE_TYPE])), this._enableVelocityLinear && (this._velocityLinearIndex = e, e++, t.push("gBuffer_VelocityLinear"), s.push(this._textureTypesAndFormats[C.VELOCITY_LINEAR_TEXTURE_TYPE])), this._enableReflectivity && (this._reflectivityIndex = e, e++, t.push("gBuffer_Reflectivity"), s.push(this._textureTypesAndFormats[C.REFLECTIVITY_TEXTURE_TYPE])), this._enableScreenspaceDepth && (this._screenspaceDepthIndex = e, e++, t.push("gBuffer_ScreenspaceDepth"), s.push(this._textureTypesAndFormats[C.SCREENSPACE_DEPTH_TEXTURE_TYPE])), this._enableIrradiance && (this._irradianceIndex = e, e++, t.push("gBuffer_Irradiance"), s.push(this._textureTypesAndFormats[C.IRRADIANCE_TEXTURE_TYPE])), [e, t, s];
|
|
1584
|
+
}
|
|
1585
|
+
_createRenderTargets() {
|
|
1586
|
+
const t = this._scene.getEngine(), [s, e, i] = this._assignRenderTargetIndices();
|
|
1587
|
+
let n = 0;
|
|
1588
|
+
t._caps.textureFloat && t._caps.textureFloatLinearFiltering ? n = 1 : t._caps.textureHalfFloat && t._caps.textureHalfFloatLinearFiltering && (n = 2);
|
|
1589
|
+
const a = this._ratioOrDimensions.width !== void 0 ? this._ratioOrDimensions : { width: t.getRenderWidth() * this._ratioOrDimensions, height: t.getRenderHeight() * this._ratioOrDimensions }, f = [], I = [], L = [];
|
|
1590
|
+
for (const T of i)
|
|
1591
|
+
T ? (f.push(T.textureType), I.push(T.textureFormat), L.push(T.samplingMode ?? 2)) : (f.push(n), I.push(5), L.push(2));
|
|
1592
|
+
if (this._normalsAreUnsigned = f[C.NORMAL_TEXTURE_TYPE] === 11 || f[C.NORMAL_TEXTURE_TYPE] === 13, this._multiRenderTarget = new Dt("gBuffer", a, s, this._scene, { generateMipMaps: !1, generateDepthTexture: !0, types: f, formats: I, samplingModes: L, depthTextureFormat: this._depthFormat }, e.concat("gBuffer_DepthBuffer")), !this.isSupported)
|
|
1593
|
+
return;
|
|
1594
|
+
this._multiRenderTarget.wrapU = re.CLAMP_ADDRESSMODE, this._multiRenderTarget.wrapV = re.CLAMP_ADDRESSMODE, this._multiRenderTarget.refreshRate = 1, this._multiRenderTarget.renderParticles = !1, this._multiRenderTarget.renderList = null;
|
|
1595
|
+
const h = [!0], u = [!1], A = [!0];
|
|
1596
|
+
for (let T = 1; T < s; ++T)
|
|
1597
|
+
h.push(!0), A.push(!1), u.push(!0);
|
|
1598
|
+
const N = t.buildTextureLayout(h), x = t.buildTextureLayout(u), M = t.buildTextureLayout(A);
|
|
1599
|
+
this._multiRenderTarget.onClearObservable.add((T) => {
|
|
1600
|
+
T.bindAttachments(this.useSpecificClearForDepthTexture ? x : N), T.clear(this._clearColor, !0, !0, !0), this.useSpecificClearForDepthTexture && (T.bindAttachments(M), T.clear(this._clearDepthColor, !0, !0, !0)), T.bindAttachments(N);
|
|
1601
|
+
}), this._resizeObserver = t.onResizeObservable.add(() => {
|
|
1602
|
+
if (this._multiRenderTarget) {
|
|
1603
|
+
const T = this._ratioOrDimensions.width !== void 0 ? this._ratioOrDimensions : { width: t.getRenderWidth() * this._ratioOrDimensions, height: t.getRenderHeight() * this._ratioOrDimensions };
|
|
1604
|
+
this._multiRenderTarget.resize(T);
|
|
1605
|
+
}
|
|
1606
|
+
});
|
|
1607
|
+
const R = (T) => {
|
|
1608
|
+
const m = T.getRenderingMesh(), F = T.getEffectiveMesh(), y = this._scene, S = y.getEngine(), c = T.getMaterial();
|
|
1609
|
+
if (!c)
|
|
1610
|
+
return;
|
|
1611
|
+
if (F._internalAbstractMeshDataInfo._isActiveIntermediate = !1, (this._enableVelocity || this._enableVelocityLinear) && !this._previousTransformationMatrices[F.uniqueId] && (this._previousTransformationMatrices[F.uniqueId] = {
|
|
1612
|
+
world: Ze.Identity(),
|
|
1613
|
+
viewProjection: y.getTransformMatrix()
|
|
1614
|
+
}, m.skeleton)) {
|
|
1615
|
+
const _ = m.skeleton.getTransformMatrices(m);
|
|
1616
|
+
this._previousBonesTransformationMatrices[m.uniqueId] = this._copyBonesTransformationMatrices(_, new Float32Array(_.length));
|
|
1617
|
+
}
|
|
1618
|
+
const Y = m._getInstancesRenderList(T._id, !!T.getReplacementMesh());
|
|
1619
|
+
if (Y.mustReturn)
|
|
1620
|
+
return;
|
|
1621
|
+
const Z = S.getCaps().instancedArrays && (Y.visibleInstances[T._id] !== null || m.hasThinInstances), U = F.getWorldMatrix();
|
|
1622
|
+
if (this.isReady(T, Z)) {
|
|
1623
|
+
const _ = T._getDrawWrapper();
|
|
1624
|
+
if (!_)
|
|
1625
|
+
return;
|
|
1626
|
+
const l = _.effect;
|
|
1627
|
+
S.enableEffect(_), Z || m._bind(T, l, c.fillMode), this._useUbo ? (Ke(l, this._scene.getSceneUniformBuffer()), this._scene.finalizeSceneUbo()) : (l.setMatrix("viewProjection", y.getTransformMatrix()), l.setMatrix("view", y.getViewMatrix()), this._scene.bindEyePosition(l, "vEyePosition"));
|
|
1628
|
+
let ee;
|
|
1629
|
+
if (!m._instanceDataStorage.isFrozen && (c.backFaceCulling || c.sideOrientation !== null)) {
|
|
1630
|
+
const E = F._getWorldMatrixDeterminant();
|
|
1631
|
+
ee = c._getEffectiveOrientation(m), E < 0 && (ee = ee === k.ClockWiseSideOrientation ? k.CounterClockWiseSideOrientation : k.ClockWiseSideOrientation);
|
|
1632
|
+
} else
|
|
1633
|
+
ee = m._effectiveSideOrientation;
|
|
1634
|
+
if (c._preBind(_, ee), c.needAlphaTestingForMesh(F)) {
|
|
1635
|
+
const E = c.getAlphaTestTexture();
|
|
1636
|
+
E && (l.setTexture("diffuseSampler", E), l.setMatrix("diffuseMatrix", E.getTextureMatrix()));
|
|
1637
|
+
}
|
|
1638
|
+
if ((c.bumpTexture || c.normalTexture || c.geometryNormalTexture) && y.getEngine().getCaps().standardDerivatives && H.BumpTextureEnabled) {
|
|
1639
|
+
const E = c.bumpTexture || c.normalTexture || c.geometryNormalTexture;
|
|
1640
|
+
l.setFloat3("vBumpInfos", E.coordinatesIndex, 1 / E.level, c.parallaxScaleBias), l.setMatrix("bumpMatrix", E.getTextureMatrix()), l.setTexture("bumpSampler", E), l.setFloat2("vTangentSpaceParams", c.invertNormalMapX ? -1 : 1, c.invertNormalMapY ? -1 : 1);
|
|
1641
|
+
}
|
|
1642
|
+
if (this._enableReflectivity) {
|
|
1643
|
+
if (c.getClassName() === "PBRMetallicRoughnessMaterial")
|
|
1644
|
+
c.metallicRoughnessTexture !== null && (l.setTexture("reflectivitySampler", c.metallicRoughnessTexture), l.setMatrix("reflectivityMatrix", c.metallicRoughnessTexture.getTextureMatrix())), c.metallic !== null && l.setFloat("metallic", c.metallic), c.roughness !== null && l.setFloat("glossiness", 1 - c.roughness), c.baseTexture !== null && (l.setTexture("albedoSampler", c.baseTexture), l.setMatrix("albedoMatrix", c.baseTexture.getTextureMatrix())), c.baseColor !== null && l.setColor3("albedoColor", c.baseColor);
|
|
1645
|
+
else if (c.getClassName() === "PBRSpecularGlossinessMaterial")
|
|
1646
|
+
c.specularGlossinessTexture !== null ? (l.setTexture("reflectivitySampler", c.specularGlossinessTexture), l.setMatrix("reflectivityMatrix", c.specularGlossinessTexture.getTextureMatrix())) : c.specularColor !== null && l.setColor3("reflectivityColor", c.specularColor), c.glossiness !== null && l.setFloat("glossiness", c.glossiness);
|
|
1647
|
+
else if (c.getClassName() === "PBRMaterial")
|
|
1648
|
+
c.metallicTexture !== null && (l.setTexture("reflectivitySampler", c.metallicTexture), l.setMatrix("reflectivityMatrix", c.metallicTexture.getTextureMatrix())), c.metallic !== null && l.setFloat("metallic", c.metallic), c.roughness !== null && l.setFloat("glossiness", 1 - c.roughness), c.roughness !== null || c.metallic !== null || c.metallicTexture !== null ? (c.albedoTexture !== null && (l.setTexture("albedoSampler", c.albedoTexture), l.setMatrix("albedoMatrix", c.albedoTexture.getTextureMatrix())), c.albedoColor !== null && l.setColor3("albedoColor", c.albedoColor)) : (c.reflectivityTexture !== null ? (l.setTexture("reflectivitySampler", c.reflectivityTexture), l.setMatrix("reflectivityMatrix", c.reflectivityTexture.getTextureMatrix())) : c.reflectivityColor !== null && l.setColor3("reflectivityColor", c.reflectivityColor), c.microSurface !== null && l.setFloat("glossiness", c.microSurface));
|
|
1649
|
+
else if (c.getClassName() === "StandardMaterial")
|
|
1650
|
+
c.specularTexture !== null && (l.setTexture("reflectivitySampler", c.specularTexture), l.setMatrix("reflectivityMatrix", c.specularTexture.getTextureMatrix())), c.specularColor !== null && l.setColor3("reflectivityColor", c.specularColor);
|
|
1651
|
+
else if (c.getClassName() === "OpenPBRMaterial") {
|
|
1652
|
+
const E = c;
|
|
1653
|
+
E._useRoughnessFromMetallicTextureGreen && E.baseMetalnessTexture ? (l.setTexture("reflectivitySampler", E.baseMetalnessTexture), l.setMatrix("reflectivityMatrix", E.baseMetalnessTexture.getTextureMatrix())) : E.baseMetalnessTexture ? (l.setTexture("metallicSampler", E.baseMetalnessTexture), l.setMatrix("metallicMatrix", E.baseMetalnessTexture.getTextureMatrix())) : E.specularRoughnessTexture && (l.setTexture("roughnessSampler", E.specularRoughnessTexture), l.setMatrix("roughnessMatrix", E.specularRoughnessTexture.getTextureMatrix())), l.setFloat("metallic", E.baseMetalness), l.setFloat("glossiness", 1 - E.specularRoughness), E.baseColorTexture !== null && (l.setTexture("albedoSampler", E.baseColorTexture), l.setMatrix("albedoMatrix", E.baseColorTexture.getTextureMatrix())), E.baseColor !== null && l.setColor3("albedoColor", E.baseColor);
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
if (this._enableIrradiance && y.environmentTexture) {
|
|
1657
|
+
const E = y.environmentTexture, j = y.postProcessRenderPipelineManager.supportedPipelines.find((g) => g.getClassName() === "IBLShadowsRenderPipeline");
|
|
1658
|
+
if (j) {
|
|
1659
|
+
const w = j._getAccumulatedTexture();
|
|
1660
|
+
w && (l.setTexture("iblShadowSampler", w), l.setFloat2("shadowTextureSize", w.getSize().width, w.getSize().height));
|
|
1661
|
+
}
|
|
1662
|
+
if (l.setMatrix("reflectionMatrix", E.getReflectionTextureMatrix()), l.setFloat2("vReflectionInfos", E.level * y.iblIntensity, 0), l.setTexture("reflectionSampler", E), E.irradianceTexture && (l.setTexture("irradianceSampler", E.irradianceTexture), E.irradianceTexture._dominantDirection && l.setVector3("vReflectionDominantDirection", E.irradianceTexture._dominantDirection)), E.sphericalPolynomial) {
|
|
1663
|
+
const g = E.sphericalPolynomial;
|
|
1664
|
+
if (g.preScaledHarmonics) {
|
|
1665
|
+
const w = g.preScaledHarmonics;
|
|
1666
|
+
l.setVector3("vSphericalL00", w.l00), l.setVector3("vSphericalL1_1", w.l1_1), l.setVector3("vSphericalL10", w.l10), l.setVector3("vSphericalL11", w.l11), l.setVector3("vSphericalL2_2", w.l2_2), l.setVector3("vSphericalL2_1", w.l2_1), l.setVector3("vSphericalL20", w.l20), l.setVector3("vSphericalL21", w.l21), l.setVector3("vSphericalL22", w.l22);
|
|
1667
|
+
} else
|
|
1668
|
+
l.setFloat3("vSphericalX", g.x.x, g.x.y, g.x.z), l.setFloat3("vSphericalY", g.y.x, g.y.y, g.y.z), l.setFloat3("vSphericalZ", g.z.x, g.z.y, g.z.z), l.setFloat3("vSphericalXX_ZZ", g.xx.x - g.zz.x, g.xx.y - g.zz.y, g.xx.z - g.zz.z), l.setFloat3("vSphericalYY_ZZ", g.yy.x - g.zz.x, g.yy.y - g.zz.y, g.yy.z - g.zz.z), l.setFloat3("vSphericalZZ", g.zz.x, g.zz.y, g.zz.z), l.setFloat3("vSphericalXY", g.xy.x, g.xy.y, g.xy.z), l.setFloat3("vSphericalYZ", g.yz.x, g.yz.y, g.yz.z), l.setFloat3("vSphericalZX", g.zx.x, g.zx.y, g.zx.z);
|
|
1669
|
+
}
|
|
1670
|
+
if (this.generateIrradianceWithScatterMask && c.getClassName() === "OpenPBRMaterial") {
|
|
1671
|
+
const g = c;
|
|
1672
|
+
l.setFloat("vSubsurfaceWeight", g.subsurfaceWeight), g.subsurfaceWeightTexture && (l.setTexture("subsurfaceWeightSampler", g.subsurfaceWeightTexture), l.setMatrix("subsurfaceWeightMatrix", g.subsurfaceWeightTexture.getTextureMatrix())), l.setFloat("vTransmissionWeight", g.transmissionWeight), g.transmissionWeightTexture && (l.setTexture("transmissionWeightSampler", g.transmissionWeightTexture), l.setMatrix("transmissionWeightMatrix", g.transmissionWeightTexture.getTextureMatrix())), l.setFloat("vTransmissionScatterAnisotropy", g.transmissionScatterAnisotropy), l.setFloat("vSubsurfaceScatterAnisotropy", g.subsurfaceScatterAnisotropy);
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
if (Pe(l, c, this._scene), m.useBones && m.computeBonesUsingShaders && m.skeleton) {
|
|
1676
|
+
const E = m.skeleton;
|
|
1677
|
+
if (E.isUsingTextureForMatrices && l.getUniformIndex("boneTextureInfo") > -1) {
|
|
1678
|
+
const j = E.getTransformMatrixTexture(m);
|
|
1679
|
+
l.setTexture("boneSampler", j), l.setFloat2("boneTextureInfo", E._textureWidth, E._textureHeight);
|
|
1680
|
+
} else
|
|
1681
|
+
l.setMatrices("mBones", m.skeleton.getTransformMatrices(m));
|
|
1682
|
+
(this._enableVelocity || this._enableVelocityLinear) && l.setMatrices("mPreviousBones", this._previousBonesTransformationMatrices[m.uniqueId]);
|
|
1683
|
+
}
|
|
1684
|
+
Ue(m, l), m.morphTargetManager && m.morphTargetManager.isUsingTextureForTargets && m.morphTargetManager._bind(l), (this._enableVelocity || this._enableVelocityLinear) && (l.setMatrix("previousWorld", this._previousTransformationMatrices[F.uniqueId].world), l.setMatrix("previousViewProjection", this._previousTransformationMatrices[F.uniqueId].viewProjection)), Z && m.hasThinInstances && l.setMatrix("world", U), m._processRendering(F, T, l, c.fillMode, Y, Z, (E, j) => {
|
|
1685
|
+
E || l.setMatrix("world", j);
|
|
1686
|
+
});
|
|
1687
|
+
}
|
|
1688
|
+
(this._enableVelocity || this._enableVelocityLinear) && (this._previousTransformationMatrices[F.uniqueId].world = U.clone(), this._previousTransformationMatrices[F.uniqueId].viewProjection = this._scene.getTransformMatrix().clone(), m.skeleton && this._copyBonesTransformationMatrices(m.skeleton.getTransformMatrices(m), this._previousBonesTransformationMatrices[F.uniqueId]));
|
|
1689
|
+
};
|
|
1690
|
+
this._multiRenderTarget.customIsReadyFunction = (T, m, F) => {
|
|
1691
|
+
if ((F || m === 0) && T.subMeshes)
|
|
1692
|
+
for (let y = 0; y < T.subMeshes.length; ++y) {
|
|
1693
|
+
const S = T.subMeshes[y], c = S.getMaterial(), Y = S.getRenderingMesh();
|
|
1694
|
+
if (!c)
|
|
1695
|
+
continue;
|
|
1696
|
+
const Z = Y._getInstancesRenderList(S._id, !!S.getReplacementMesh()), U = t.getCaps().instancedArrays && (Z.visibleInstances[S._id] !== null || Y.hasThinInstances);
|
|
1697
|
+
if (!this.isReady(S, U))
|
|
1698
|
+
return !1;
|
|
1699
|
+
}
|
|
1700
|
+
return !0;
|
|
1701
|
+
}, this._multiRenderTarget.customRenderFunction = (T, m, F, y) => {
|
|
1702
|
+
let S;
|
|
1703
|
+
if (this._linkedWithPrePass) {
|
|
1704
|
+
if (!this._prePassRenderer.enabled)
|
|
1705
|
+
return;
|
|
1706
|
+
this._scene.getEngine().bindAttachments(this._attachmentsFromPrePass);
|
|
1707
|
+
}
|
|
1708
|
+
if (y.length) {
|
|
1709
|
+
for (t.setColorWrite(!1), S = 0; S < y.length; S++)
|
|
1710
|
+
R(y.data[S]);
|
|
1711
|
+
t.setColorWrite(!0);
|
|
1712
|
+
}
|
|
1713
|
+
for (S = 0; S < T.length; S++)
|
|
1714
|
+
R(T.data[S]);
|
|
1715
|
+
for (t.setDepthWrite(!1), S = 0; S < m.length; S++)
|
|
1716
|
+
R(m.data[S]);
|
|
1717
|
+
if (this.renderTransparentMeshes)
|
|
1718
|
+
for (S = 0; S < F.length; S++)
|
|
1719
|
+
R(F.data[S]);
|
|
1720
|
+
t.setDepthWrite(!0);
|
|
1721
|
+
};
|
|
1722
|
+
}
|
|
1723
|
+
// Copies the bones transformation matrices into the target array and returns the target's reference
|
|
1724
|
+
_copyBonesTransformationMatrices(t, s) {
|
|
1725
|
+
for (let e = 0; e < t.length; e++)
|
|
1726
|
+
s[e] = t[e];
|
|
1727
|
+
return s;
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
C.ForceGLSL = !1;
|
|
1731
|
+
C.DEPTH_TEXTURE_TYPE = 0;
|
|
1732
|
+
C.NORMAL_TEXTURE_TYPE = 1;
|
|
1733
|
+
C.POSITION_TEXTURE_TYPE = 2;
|
|
1734
|
+
C.VELOCITY_TEXTURE_TYPE = 3;
|
|
1735
|
+
C.REFLECTIVITY_TEXTURE_TYPE = 4;
|
|
1736
|
+
C.SCREENSPACE_DEPTH_TEXTURE_TYPE = 5;
|
|
1737
|
+
C.VELOCITY_LINEAR_TEXTURE_TYPE = 6;
|
|
1738
|
+
C.IRRADIANCE_TEXTURE_TYPE = 7;
|
|
1739
|
+
C._SceneComponentInitialization = (p) => {
|
|
1740
|
+
throw $e("GeometryBufferRendererSceneComponent");
|
|
1741
|
+
};
|
|
1742
|
+
const ie = { effect: null, subMesh: null };
|
|
1743
|
+
class ne {
|
|
1744
|
+
populateVectorFromLinkedProperties(t) {
|
|
1745
|
+
const s = t.dimension[0];
|
|
1746
|
+
for (const e in this.linkedProperties) {
|
|
1747
|
+
const i = this.linkedProperties[e], n = i.numComponents;
|
|
1748
|
+
if (s < n || i.targetUniformComponentOffset > s - n) {
|
|
1749
|
+
n == 1 ? se.Error(`Float property ${i.name} has an offset that is too large.`) : se.Error(`Vector${n} property ${i.name} won't fit in Vector${s} or has an offset that is too large.`);
|
|
1750
|
+
return;
|
|
1751
|
+
}
|
|
1752
|
+
typeof i.value == "number" ? ne._tmpArray[i.targetUniformComponentOffset] = i.value : i.value.toArray(ne._tmpArray, i.targetUniformComponentOffset);
|
|
1753
|
+
}
|
|
1754
|
+
t.fromArray(ne._tmpArray);
|
|
1755
|
+
}
|
|
1756
|
+
constructor(t, s) {
|
|
1757
|
+
this.linkedProperties = {}, this.firstLinkedKey = "", this.name = t, this.numComponents = s;
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
ne._tmpArray = [0, 0, 0, 0];
|
|
1761
|
+
class v {
|
|
1762
|
+
/**
|
|
1763
|
+
* Creates a new Property instance.
|
|
1764
|
+
* @param name The name of the property in the shader
|
|
1765
|
+
* @param defaultValue The default value of the property
|
|
1766
|
+
* @param targetUniformName The name of the property in the shader uniform block
|
|
1767
|
+
* @param targetUniformComponentNum The number of components in the target uniform. All properties that are
|
|
1768
|
+
* packed into the same uniform must agree on the size of the target uniform.
|
|
1769
|
+
* @param targetUniformComponentOffset The offset in the uniform where this property will be packed.
|
|
1770
|
+
* @param requiredDefine Optional define name. When provided, the per-frame
|
|
1771
|
+
* bind loop will skip pushing the owning uniform to the UBO unless
|
|
1772
|
+
* `defines[requiredDefine]` is true.
|
|
1773
|
+
*/
|
|
1774
|
+
constructor(t, s, e, i, n = 0, a) {
|
|
1775
|
+
this.targetUniformComponentNum = 4, this.targetUniformComponentOffset = 0, this.name = t, this.targetUniformName = e, this.defaultValue = s, this.value = s, this.targetUniformComponentNum = i, this.targetUniformComponentOffset = n, this.requiredDefine = a;
|
|
1776
|
+
}
|
|
1777
|
+
/**
|
|
1778
|
+
* Returns the number of components of the property based on its default value type.
|
|
1779
|
+
*/
|
|
1780
|
+
get numComponents() {
|
|
1781
|
+
return typeof this.defaultValue == "number" ? 1 : this.defaultValue.dimension[0];
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
class O {
|
|
1785
|
+
/**
|
|
1786
|
+
* The name of the sampler used in the shader.
|
|
1787
|
+
* If this naming changes, we'll also need to change:
|
|
1788
|
+
* - samplerFragmentDeclaration.fx
|
|
1789
|
+
* - openpbr.fragment.fx
|
|
1790
|
+
*/
|
|
1791
|
+
get samplerName() {
|
|
1792
|
+
return this.samplerPrefix + "Sampler";
|
|
1793
|
+
}
|
|
1794
|
+
/**
|
|
1795
|
+
* The name of the sampler info used in the shader.
|
|
1796
|
+
* If this naming changes, we'll also need to change:
|
|
1797
|
+
* - openpbr.vertex.fx
|
|
1798
|
+
* - openpbr.fragment.fx
|
|
1799
|
+
*/
|
|
1800
|
+
get samplerInfoName() {
|
|
1801
|
+
return "v" + this.samplerPrefix.charAt(0).toUpperCase() + this.samplerPrefix.slice(1) + "Infos";
|
|
1802
|
+
}
|
|
1803
|
+
/**
|
|
1804
|
+
* The name of the matrix used for this sampler in the shader.
|
|
1805
|
+
* If this naming changes, we'll also need to change:
|
|
1806
|
+
* - materialHelper.functions.BindTextureMatrix
|
|
1807
|
+
* - samplerVertexImplementation.fx
|
|
1808
|
+
* - openpbr.fragment.fx
|
|
1809
|
+
*/
|
|
1810
|
+
get samplerMatrixName() {
|
|
1811
|
+
return this.samplerPrefix + "Matrix";
|
|
1812
|
+
}
|
|
1813
|
+
/**
|
|
1814
|
+
* Creates a new Sampler instance.
|
|
1815
|
+
* @param name The name of the texture property
|
|
1816
|
+
* @param samplerPrefix The prefix used for the name of the sampler in the shader
|
|
1817
|
+
* @param textureDefine The define used in the shader for this sampler
|
|
1818
|
+
*/
|
|
1819
|
+
constructor(t, s, e) {
|
|
1820
|
+
this.value = null, this.samplerPrefix = "", this.textureDefine = "", this.name = t, this.samplerPrefix = s, this.textureDefine = e;
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
class Kt extends Mt(bt(Ot)) {
|
|
1824
|
+
}
|
|
1825
|
+
class $t extends yt(Kt) {
|
|
1826
|
+
}
|
|
1827
|
+
class ye extends Ct($t) {
|
|
1828
|
+
/**
|
|
1829
|
+
* Initializes the PBR Material defines.
|
|
1830
|
+
* @param externalProperties The external properties
|
|
1831
|
+
*/
|
|
1832
|
+
constructor(t) {
|
|
1833
|
+
super(t), this.NUM_SAMPLES = "0", this.REALTIME_FILTERING = !1, this.IBL_CDF_FILTERING = !1, this.LIGHTCOUNT = 0, this.VERTEXCOLOR = !1, this.BAKED_VERTEX_ANIMATION_TEXTURE = !1, this.VERTEXALPHA = !1, this.ALPHATEST = !1, this.DEPTHPREPASS = !1, this.ALPHABLEND = !1, this.ALPHA_FROM_BASE_COLOR_TEXTURE = !1, this.ALPHATESTVALUE = "0.5", this.PREMULTIPLYALPHA = !1, this.REFLECTIVITY_GAMMA = !1, this.REFLECTIVITYDIRECTUV = 0, this.SPECULARTERM = !1, this.LODBASEDMICROSFURACE = !0, this.SPECULAR_ROUGHNESS_FROM_METALNESS_TEXTURE_GREEN = !1, this.BASE_METALNESS_FROM_METALNESS_TEXTURE_BLUE = !1, this.AOSTOREINMETALMAPRED = !1, this.SPECULAR_WEIGHT_IN_ALPHA = !1, this.SPECULAR_WEIGHT_FROM_SPECULAR_COLOR_TEXTURE = !1, this.SPECULAR_ROUGHNESS_ANISOTROPY_FROM_TANGENT_TEXTURE = !1, this.COAT_ROUGHNESS_FROM_GREEN_CHANNEL = !1, this.COAT_ROUGHNESS_ANISOTROPY_FROM_TANGENT_TEXTURE = !1, this.USE_GLTF_STYLE_ANISOTROPY = !1, this.THIN_FILM_THICKNESS_FROM_THIN_FILM_TEXTURE = !1, this.FUZZ_ROUGHNESS_FROM_TEXTURE_ALPHA = !1, this.SUBSURFACE_WEIGHT_FROM_TEXTURE_ALPHA = !1, this.GEOMETRY_THICKNESS_FROM_GREEN_CHANNEL = !1, this.ENVIRONMENTBRDF = !1, this.ENVIRONMENTBRDF_RGBD = !1, this.FUZZENVIRONMENTBRDF = !1, this.NORMAL = !1, this.TANGENT = !1, this.OBJECTSPACE_NORMALMAP = !1, this.PARALLAX = !1, this.PARALLAX_RHS = !1, this.PARALLAXOCCLUSION = !1, this.NORMALXYSCALE = !0, this.ANISOTROPIC = !1, this.ANISOTROPIC_OPENPBR = !0, this.ANISOTROPIC_BASE = !1, this.ANISOTROPIC_COAT = !1, this.FUZZ_IBL_SAMPLES = 6, this.REFRACTION_HIGH_QUALITY_BLUR = !1, this.FUZZ = !1, this.THIN_FILM = !1, this.IRIDESCENCE = !1, this.DISPERSION = !1, this.SCATTERING = !1, this.USE_IRRADIANCE_TEXTURE_FOR_SCATTERING = !1, this.SSS_SAMPLE_COUNT = 16, this.USE_IRRADIANCE_TEXTURE_FOR_SCATTERING_GBUFFER = !1, this.TRANSMISSION_SLAB = !1, this.TRANSMISSION_SLAB_VOLUME = !1, this.SUBSURFACE_SLAB = !1, this.GEOMETRY_THIN_WALLED = !1, this.REFRACTED_BACKGROUND = !1, this.REFRACTED_LIGHTS = !1, this.REFRACTED_ENVIRONMENT = !1, this.REFRACTED_ENVIRONMENT_OPPOSITEZ = !1, this.REFRACTED_ENVIRONMENT_LOCAL_CUBE = !1, this.RADIANCEOCCLUSION = !1, this.HORIZONOCCLUSION = !1, this.INSTANCES = !1, this.THIN_INSTANCES = !1, this.INSTANCESCOLOR = !1, this.NUM_BONE_INFLUENCERS = 0, this.BonesPerMesh = 0, this.BONETEXTURE = !1, this.BONES_VELOCITY_ENABLED = !1, this.NONUNIFORMSCALING = !1, this.MORPHTARGETS = !1, this.MORPHTARGETS_POSITION = !1, this.MORPHTARGETS_NORMAL = !1, this.MORPHTARGETS_TANGENT = !1, this.MORPHTARGETS_UV = !1, this.MORPHTARGETS_UV2 = !1, this.MORPHTARGETS_COLOR = !1, this.MORPHTARGETTEXTURE_HASPOSITIONS = !1, this.MORPHTARGETTEXTURE_HASNORMALS = !1, this.MORPHTARGETTEXTURE_HASTANGENTS = !1, this.MORPHTARGETTEXTURE_HASUVS = !1, this.MORPHTARGETTEXTURE_HASUV2S = !1, this.MORPHTARGETTEXTURE_HASCOLORS = !1, this.NUM_MORPH_INFLUENCERS = 0, this.MORPHTARGETS_TEXTURE = !1, this.USEPHYSICALLIGHTFALLOFF = !1, this.USEGLTFLIGHTFALLOFF = !1, this.TWOSIDEDLIGHTING = !1, this.MIRRORED = !1, this.SHADOWFLOAT = !1, this.CLIPPLANE = !1, this.CLIPPLANE2 = !1, this.CLIPPLANE3 = !1, this.CLIPPLANE4 = !1, this.CLIPPLANE5 = !1, this.CLIPPLANE6 = !1, this.POINTSIZE = !1, this.FOG = !1, this.LOGARITHMICDEPTH = !1, this.CAMERA_ORTHOGRAPHIC = !1, this.CAMERA_PERSPECTIVE = !1, this.AREALIGHTSUPPORTED = !0, this.FORCENORMALFORWARD = !1, this.SPECULARAA = !1, this.UNLIT = !1, this.DECAL_AFTER_DETAIL = !1, this.TEXTURE_REPETITION_MODE = 0, this.DEBUGMODE = 0, this.USE_VERTEX_PULLING = !1, this.VERTEX_PULLING_USE_INDEX_BUFFER = !1, this.VERTEX_PULLING_INDEX_BUFFER_32BITS = !1, this.RIGHT_HANDED = !1, this.CLUSTLIGHT_SLICES = 0, this.CLUSTLIGHT_BATCH = 0, this.BRDF_V_HEIGHT_CORRELATED = !0, this.MS_BRDF_ENERGY_CONSERVATION = !0, this.SPHERICAL_HARMONICS = !0, this.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION = !0, this.MIX_IBL_RADIANCE_WITH_IRRADIANCE = !0, this.LEGACY_SPECULAR_ENERGY_CONSERVATION = !1, this.BASE_DIFFUSE_MODEL = 0, this.DIELECTRIC_SPECULAR_MODEL = 1, this.CONDUCTOR_SPECULAR_MODEL = 1, this.rebuild();
|
|
1834
|
+
}
|
|
1835
|
+
/**
|
|
1836
|
+
* Resets the PBR Material defines.
|
|
1837
|
+
*/
|
|
1838
|
+
reset() {
|
|
1839
|
+
super.reset(), this.ALPHATESTVALUE = "0.5", this.NORMALXYSCALE = !0;
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
class jt extends vt(Lt) {
|
|
1843
|
+
}
|
|
1844
|
+
class r extends jt {
|
|
1845
|
+
/**
|
|
1846
|
+
* Defines the angle of the tangent of the material's geometry. Used only for anisotropic reflections.
|
|
1847
|
+
* See OpenPBR's specs for geometry_tangent
|
|
1848
|
+
*/
|
|
1849
|
+
get geometryTangentAngle() {
|
|
1850
|
+
return Math.atan2(this.geometryTangent.y, this.geometryTangent.x);
|
|
1851
|
+
}
|
|
1852
|
+
set geometryTangentAngle(t) {
|
|
1853
|
+
this.geometryTangent = new ae(Math.cos(t), Math.sin(t));
|
|
1854
|
+
}
|
|
1855
|
+
/**
|
|
1856
|
+
* Defines the angle of the tangent of the material's coat layer.
|
|
1857
|
+
*/
|
|
1858
|
+
get geometryCoatTangentAngle() {
|
|
1859
|
+
return Math.atan2(this.geometryCoatTangent.y, this.geometryCoatTangent.x);
|
|
1860
|
+
}
|
|
1861
|
+
/**
|
|
1862
|
+
* Defines the angle of the tangent of the material's coat layer.
|
|
1863
|
+
*/
|
|
1864
|
+
set geometryCoatTangentAngle(t) {
|
|
1865
|
+
this.geometryCoatTangent = new ae(Math.cos(t), Math.sin(t));
|
|
1866
|
+
}
|
|
1867
|
+
/**
|
|
1868
|
+
* Controls the sample count of the screen-space SSS convolution kernel.
|
|
1869
|
+
* Use the SSS_QUALITY_LOW / MEDIUM / HIGH constants (8 / 16 / 32 samples).
|
|
1870
|
+
* Higher quality reduces noise at the cost of GPU time. Default: MEDIUM.
|
|
1871
|
+
*/
|
|
1872
|
+
get sssQuality() {
|
|
1873
|
+
return this._sssQuality;
|
|
1874
|
+
}
|
|
1875
|
+
set sssQuality(t) {
|
|
1876
|
+
this._sssQuality !== t && (this._sssQuality = t, this.markAsDirty(1));
|
|
1877
|
+
}
|
|
1878
|
+
/**
|
|
1879
|
+
* Defines the irradiance texture used for subsurface scattering.
|
|
1880
|
+
* If it's not provided, the irradiance will be looked for in the scene.geometryBufferRenderer.
|
|
1881
|
+
* Accepts a {@link ThinTexture} so that an {@link InternalTexture} obtained from a frame graph
|
|
1882
|
+
* handle can be wrapped with `new ThinTexture(internalTexture)` and assigned directly.
|
|
1883
|
+
* Setting this property marks all sub-meshes as textures-dirty so the shader recompiles.
|
|
1884
|
+
*/
|
|
1885
|
+
get sssIrradianceTexture() {
|
|
1886
|
+
return this._sssIrradianceTexture;
|
|
1887
|
+
}
|
|
1888
|
+
set sssIrradianceTexture(t) {
|
|
1889
|
+
this._sssIrradianceTexture !== t && (this._sssIrradianceTexture = t, this._markAllSubMeshesAsTexturesDirty());
|
|
1890
|
+
}
|
|
1891
|
+
/**
|
|
1892
|
+
* Defines the depth texture used for subsurface scattering. This is the depth defined
|
|
1893
|
+
* in screen space. If it's not provided, the depth will be looked for in the scene.geometryBufferRenderer.
|
|
1894
|
+
* Accepts a {@link ThinTexture} so that an {@link InternalTexture} obtained from a frame graph
|
|
1895
|
+
* handle can be wrapped with `new ThinTexture(internalTexture)` and assigned directly.
|
|
1896
|
+
* Setting this property marks all sub-meshes as textures-dirty so the shader recompiles.
|
|
1897
|
+
*/
|
|
1898
|
+
get sssDepthTexture() {
|
|
1899
|
+
return this._sssDepthTexture;
|
|
1900
|
+
}
|
|
1901
|
+
set sssDepthTexture(t) {
|
|
1902
|
+
this._sssDepthTexture !== t && (this._sssDepthTexture = t, this._markAllSubMeshesAsTexturesDirty());
|
|
1903
|
+
}
|
|
1904
|
+
/**
|
|
1905
|
+
* Specifies if we can see through the surface of the material due to subsurface scattering or transmission.
|
|
1906
|
+
*/
|
|
1907
|
+
get hasTransparency() {
|
|
1908
|
+
return this.subsurfaceWeight > 0 || this.transmissionWeight > 0;
|
|
1909
|
+
}
|
|
1910
|
+
/** Specifies if the material has scattering properties such as subsurface scattering or transmission scattering. */
|
|
1911
|
+
get hasScattering() {
|
|
1912
|
+
return this.transmissionWeight > 0 && this.transmissionDepth > 0 && !this.transmissionScatter.equals(K.BlackReadOnly) || this.subsurfaceWeight > 0;
|
|
1913
|
+
}
|
|
1914
|
+
/**
|
|
1915
|
+
* BJS is using an hardcoded light falloff based on a manually sets up range.
|
|
1916
|
+
* In PBR, one way to represents the falloff is to use the inverse squared root algorithm.
|
|
1917
|
+
* This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
|
|
1918
|
+
*/
|
|
1919
|
+
get usePhysicalLightFalloff() {
|
|
1920
|
+
return this._lightFalloff === k.LIGHTFALLOFF_PHYSICAL;
|
|
1921
|
+
}
|
|
1922
|
+
/**
|
|
1923
|
+
* BJS is using an hardcoded light falloff based on a manually sets up range.
|
|
1924
|
+
* In PBR, one way to represents the falloff is to use the inverse squared root algorithm.
|
|
1925
|
+
* This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
|
|
1926
|
+
*/
|
|
1927
|
+
set usePhysicalLightFalloff(t) {
|
|
1928
|
+
t !== this.usePhysicalLightFalloff && (this._markAllSubMeshesAsTexturesDirty(), t ? this._lightFalloff = k.LIGHTFALLOFF_PHYSICAL : this._lightFalloff = k.LIGHTFALLOFF_STANDARD);
|
|
1929
|
+
}
|
|
1930
|
+
/**
|
|
1931
|
+
* In order to support the falloff compatibility with gltf, a special mode has been added
|
|
1932
|
+
* to reproduce the gltf light falloff.
|
|
1933
|
+
*/
|
|
1934
|
+
get useGLTFLightFalloff() {
|
|
1935
|
+
return this._lightFalloff === k.LIGHTFALLOFF_GLTF;
|
|
1936
|
+
}
|
|
1937
|
+
/**
|
|
1938
|
+
* In order to support the falloff compatibility with gltf, a special mode has been added
|
|
1939
|
+
* to reproduce the gltf light falloff.
|
|
1940
|
+
*/
|
|
1941
|
+
set useGLTFLightFalloff(t) {
|
|
1942
|
+
t !== this.useGLTFLightFalloff && (this._markAllSubMeshesAsTexturesDirty(), t ? this._lightFalloff = k.LIGHTFALLOFF_GLTF : this._lightFalloff = k.LIGHTFALLOFF_STANDARD);
|
|
1943
|
+
}
|
|
1944
|
+
/**
|
|
1945
|
+
* Set the texture used for refraction of the background of transparent materials
|
|
1946
|
+
* @internal
|
|
1947
|
+
*/
|
|
1948
|
+
get backgroundRefractionTexture() {
|
|
1949
|
+
return this._backgroundRefractionTexture;
|
|
1950
|
+
}
|
|
1951
|
+
set backgroundRefractionTexture(t) {
|
|
1952
|
+
this._backgroundRefractionTexture = t, this._markAllSubMeshesAsTexturesDirty();
|
|
1953
|
+
}
|
|
1954
|
+
/**
|
|
1955
|
+
* When true, uses a 4-tap rotated-grid kernel for refractive background blur,
|
|
1956
|
+
* eliminating bilinear block artifacts at the cost of 3 extra texture samples.
|
|
1957
|
+
* When false, a single dithered sample is used. Default: true.
|
|
1958
|
+
*/
|
|
1959
|
+
get refractionHighQualityBlur() {
|
|
1960
|
+
return this._refractionHighQualityBlur;
|
|
1961
|
+
}
|
|
1962
|
+
set refractionHighQualityBlur(t) {
|
|
1963
|
+
this._refractionHighQualityBlur !== t && (this._refractionHighQualityBlur = t, this.markAsDirty(1));
|
|
1964
|
+
}
|
|
1965
|
+
/**
|
|
1966
|
+
* Enables realtime filtering on the texture.
|
|
1967
|
+
*/
|
|
1968
|
+
get realTimeFiltering() {
|
|
1969
|
+
return this._realTimeFiltering;
|
|
1970
|
+
}
|
|
1971
|
+
set realTimeFiltering(t) {
|
|
1972
|
+
this._realTimeFiltering = t, this.markAsDirty(1);
|
|
1973
|
+
}
|
|
1974
|
+
/**
|
|
1975
|
+
* Quality switch for realtime filtering
|
|
1976
|
+
*/
|
|
1977
|
+
get realTimeFilteringQuality() {
|
|
1978
|
+
return this._realTimeFilteringQuality;
|
|
1979
|
+
}
|
|
1980
|
+
set realTimeFilteringQuality(t) {
|
|
1981
|
+
this._realTimeFilteringQuality = t, this.markAsDirty(1);
|
|
1982
|
+
}
|
|
1983
|
+
/**
|
|
1984
|
+
* The number of samples used to compute the fuzz IBL lighting.
|
|
1985
|
+
*/
|
|
1986
|
+
get fuzzSampleNumber() {
|
|
1987
|
+
return this._fuzzSampleNumber;
|
|
1988
|
+
}
|
|
1989
|
+
set fuzzSampleNumber(t) {
|
|
1990
|
+
this._fuzzSampleNumber = t, this.markAsDirty(1);
|
|
1991
|
+
}
|
|
1992
|
+
/**
|
|
1993
|
+
* Can this material render to several textures at once
|
|
1994
|
+
*/
|
|
1995
|
+
get canRenderToMRT() {
|
|
1996
|
+
return !0;
|
|
1997
|
+
}
|
|
1998
|
+
/**
|
|
1999
|
+
* Instantiates a new OpenPBRMaterial instance.
|
|
2000
|
+
*
|
|
2001
|
+
* @param name The material name
|
|
2002
|
+
* @param scene The scene the material will be use in.
|
|
2003
|
+
* @param forceGLSL Use the GLSL code generation for the shader (even on WebGPU). Default is false
|
|
2004
|
+
*/
|
|
2005
|
+
constructor(t, s, e = !1) {
|
|
2006
|
+
super(t, s, void 0, e || r.ForceGLSL), this._baseWeight = new v("base_weight", 1, "vBaseWeight", 1), this._baseWeightTexture = new O("base_weight", "baseWeight", "BASE_WEIGHT"), this._baseColor = new v("base_color", K.White(), "vBaseColor", 4), this._baseColorTexture = new O("base_color", "baseColor", "BASE_COLOR"), this._baseDiffuseRoughness = new v("base_diffuse_roughness", 0, "vBaseDiffuseRoughness", 1), this._baseDiffuseRoughnessTexture = new O("base_diffuse_roughness", "baseDiffuseRoughness", "BASE_DIFFUSE_ROUGHNESS"), this._baseMetalness = new v("base_metalness", 0, "vReflectanceInfo", 4, 0), this._baseMetalnessTexture = new O("base_metalness", "baseMetalness", "BASE_METALNESS"), this._specularWeight = new v("specular_weight", 1, "vReflectanceInfo", 4, 3), this._specularWeightTexture = new O("specular_weight", "specularWeight", "SPECULAR_WEIGHT"), this._specularColor = new v("specular_color", K.White(), "vSpecularColor", 4), this._specularColorTexture = new O("specular_color", "specularColor", "SPECULAR_COLOR"), this._specularRoughness = new v("specular_roughness", 0.3, "vReflectanceInfo", 4, 1), this._specularRoughnessTexture = new O("specular_roughness", "specularRoughness", "SPECULAR_ROUGHNESS"), this._specularRoughnessAnisotropy = new v("specular_roughness_anisotropy", 0, "vSpecularAnisotropy", 3, 2), this._specularRoughnessAnisotropyTexture = new O("specular_roughness_anisotropy", "specularRoughnessAnisotropy", "SPECULAR_ROUGHNESS_ANISOTROPY"), this._specularIor = new v("specular_ior", 1.5, "vReflectanceInfo", 4, 2), this._transmissionWeight = new v("transmission_weight", 0, "vTransmissionWeight", 1), this._transmissionWeightTexture = new O("transmission_weight", "transmissionWeight", "TRANSMISSION_WEIGHT"), this._transmissionColor = new v("transmission_color", K.White(), "vTransmissionColor", 3, 0), this._transmissionColorTexture = new O("transmission_color", "transmissionColor", "TRANSMISSION_COLOR"), this._transmissionDepth = new v("transmission_depth", 0, "vTransmissionDepth", 1, 0), this._transmissionDepthTexture = new O("transmission_depth", "transmissionDepth", "TRANSMISSION_DEPTH"), this._transmissionScatter = new v("transmission_scatter", K.Black(), "vTransmissionScatter", 3, 0), this._transmissionScatterTexture = new O("transmission_scatter", "transmissionScatter", "TRANSMISSION_SCATTER"), this._transmissionScatterAnisotropy = new v("transmission_scatter_anisotropy", 0, "vTransmissionScatterAnisotropy", 1, 0), this._transmissionDispersionScale = new v("transmission_dispersion_scale", 0, "vTransmissionDispersionScale", 1, 0), this._transmissionDispersionScaleTexture = new O("transmission_dispersion_scale", "transmissionDispersionScale", "TRANSMISSION_DISPERSION_SCALE"), this._transmissionDispersionAbbeNumber = new v("transmission_dispersion_abbe_number", 20, "vTransmissionDispersionAbbeNumber", 1, 0), this._subsurfaceWeight = new v("subsurface_weight", 0, "vSubsurfaceWeight", 1, 0, "SUBSURFACE_SLAB"), this._subsurfaceWeightTexture = new O("subsurface_weight", "subsurfaceWeight", "SUBSURFACE_WEIGHT"), this._subsurfaceColor = new v("subsurface_color", new K(0.8, 0.8, 0.8), "vSubsurfaceColor", 3, 0, "SUBSURFACE_SLAB"), this._subsurfaceColorTexture = new O("subsurface_color", "subsurfaceColor", "SUBSURFACE_COLOR"), this._subsurfaceRadius = new v("subsurface_radius", 0.1, "vSubsurfaceRadius", 1, 0, "SUBSURFACE_SLAB"), this._subsurfaceRadiusScale = new v("subsurface_radius_scale", new K(1, 0.5, 0.25), "vSubsurfaceRadiusScale", 3, 0, "SUBSURFACE_SLAB"), this._subsurfaceRadiusScaleTexture = new O("subsurface_radius_scale", "subsurfaceRadiusScale", "SUBSURFACE_RADIUS_SCALE"), this._subsurfaceScatterAnisotropy = new v("subsurface_scatter_anisotropy", 0, "vSubsurfaceScatterAnisotropy", 1, 0, "SUBSURFACE_SLAB"), this._coatWeight = new v("coat_weight", 0, "vCoatWeight", 1, 0), this._coatWeightTexture = new O("coat_weight", "coatWeight", "COAT_WEIGHT"), this._coatColor = new v("coat_color", K.White(), "vCoatColor", 3, 0), this._coatColorTexture = new O("coat_color", "coatColor", "COAT_COLOR"), this._coatRoughness = new v("coat_roughness", 0, "vCoatRoughness", 1, 0), this._coatRoughnessTexture = new O("coat_roughness", "coatRoughness", "COAT_ROUGHNESS"), this._coatRoughnessAnisotropy = new v("coat_roughness_anisotropy", 0, "vCoatRoughnessAnisotropy", 1), this._coatRoughnessAnisotropyTexture = new O("coat_roughness_anisotropy", "coatRoughnessAnisotropy", "COAT_ROUGHNESS_ANISOTROPY"), this._coatIor = new v("coat_ior", 1.5, "vCoatIor", 1, 0), this._coatDarkening = new v("coat_darkening", 1, "vCoatDarkening", 1, 0), this._coatDarkeningTexture = new O("coat_darkening", "coatDarkening", "COAT_DARKENING"), this.useCoatRoughnessFromWeightTexture = !1, this._fuzzWeight = new v("fuzz_weight", 0, "vFuzzWeight", 1, 0), this._fuzzWeightTexture = new O("fuzz_weight", "fuzzWeight", "FUZZ_WEIGHT"), this._fuzzColor = new v("fuzz_color", K.White(), "vFuzzColor", 3, 0), this._fuzzColorTexture = new O("fuzz_color", "fuzzColor", "FUZZ_COLOR"), this._fuzzRoughness = new v("fuzz_roughness", 0.5, "vFuzzRoughness", 1, 0), this._fuzzRoughnessTexture = new O("fuzz_roughness", "fuzzRoughness", "FUZZ_ROUGHNESS"), this._geometryThinWalled = new v("geometry_thin_walled", 0, "vGeometryThinWalled", 1, 0), this._geometryNormalTexture = new O("geometry_normal", "geometryNormal", "GEOMETRY_NORMAL"), this._geometryTangent = new v("geometry_tangent", new ae(1, 0), "vSpecularAnisotropy", 3, 0), this._geometryTangentTexture = new O("geometry_tangent", "geometryTangent", "GEOMETRY_TANGENT"), this._geometryCoatNormalTexture = new O("geometry_coat_normal", "geometryCoatNormal", "GEOMETRY_COAT_NORMAL"), this._geometryCoatTangent = new v("geometry_coat_tangent", new ae(1, 0), "vGeometryCoatTangent", 2, 0), this._geometryCoatTangentTexture = new O("geometry_coat_tangent", "geometryCoatTangent", "GEOMETRY_COAT_TANGENT"), this._geometryOpacity = new v("geometry_opacity", 1, "vBaseColor", 4, 3), this._geometryOpacityTexture = new O("geometry_opacity", "geometryOpacity", "GEOMETRY_OPACITY"), this._geometryThickness = new v("geometry_thickness", 0, "vGeometryThickness", 1, 0), this._geometryThicknessTexture = new O("geometry_thickness", "geometryThickness", "GEOMETRY_THICKNESS"), this._emissionLuminance = new v("emission_luminance", 1, "vLightingIntensity", 4, 1), this._emissionColor = new v("emission_color", K.Black(), "vEmissionColor", 3), this._emissionColorTexture = new O("emission_color", "emissionColor", "EMISSION_COLOR"), this._thinFilmWeight = new v("thin_film_weight", 0, "vThinFilmWeight", 1, 0), this._thinFilmWeightTexture = new O("thin_film_weight", "thinFilmWeight", "THIN_FILM_WEIGHT"), this._thinFilmThickness = new v("thin_film_thickness", 0.5, "vThinFilmThickness", 2, 0), this._thinFilmThicknessMin = new v("thin_film_thickness_min", 0, "vThinFilmThickness", 2, 1), this._thinFilmThicknessTexture = new O("thin_film_thickness", "thinFilmThickness", "THIN_FILM_THICKNESS"), this._thinFilmIor = new v("thin_film_ior", 1.4, "vThinFilmIor", 1, 0), this._ambientOcclusionTexture = new O("ambient_occlusion", "ambientOcclusion", "AMBIENT_OCCLUSION"), this._sssQuality = r.SSS_QUALITY_MEDIUM, this._sssIrradianceTexture = null, this._sssDepthTexture = null, this._uniformsList = {}, this._uniformsArray = [], this._samplersList = {}, this._samplerDefines = {}, this.directIntensity = 1, this.environmentIntensity = 1, this.useSpecularWeightFromTextureAlpha = !1, this.forceAlphaTest = !1, this.alphaCutOff = 0.4, this.useAmbientOcclusionFromMetallicTextureRed = !1, this.useAmbientInGrayScale = !1, this.useObjectSpaceNormalMap = !1, this.useParallax = !1, this.useParallaxOcclusion = !1, this.parallaxScaleBias = 0.05, this.disableLighting = !1, this.forceIrradianceInFragment = !1, this.maxSimultaneousLights = 4, this.invertNormalMapX = !1, this.invertNormalMapY = !1, this.twoSidedLighting = !1, this.useAlphaFresnel = !1, this.useLinearAlphaFresnel = !1, this.environmentBRDFTexture = null, this.forceNormalForward = !1, this.enableSpecularAntiAliasing = !1, this.useHorizonOcclusion = !0, this.useRadianceOcclusion = !0, this.unlit = !1, this.applyDecalMapAfterDetailMap = !1, this._lightingInfos = new je(this.directIntensity, 1, this.environmentIntensity, 1), this._radianceTexture = null, this._useSpecularWeightFromAlpha = !1, this._useSpecularWeightFromSpecularColorTexture = !1, this._useSpecularRoughnessAnisotropyFromTangentTexture = !1, this._useCoatRoughnessAnisotropyFromTangentTexture = !1, this._useCoatRoughnessFromGreenChannel = !1, this._useGltfStyleAnisotropy = !1, this._useFuzzRoughnessFromTextureAlpha = !1, this._useSubsurfaceWeightFromTextureAlpha = !1, this._useHorizonOcclusion = !0, this._useRadianceOcclusion = !0, this._useAlphaFromBaseColorTexture = !1, this._useAmbientOcclusionFromMetallicTextureRed = !1, this._useRoughnessFromMetallicTextureGreen = !1, this._useMetallicFromMetallicTextureBlue = !1, this._useThinFilmThicknessFromTextureGreen = !1, this._useGeometryThicknessFromGreenChannel = !1, this._lightFalloff = k.LIGHTFALLOFF_PHYSICAL, this._useObjectSpaceNormalMap = !1, this._useParallax = !1, this._useParallaxOcclusion = !1, this._parallaxScaleBias = 0.05, this._disableLighting = !1, this._maxSimultaneousLights = 4, this._invertNormalMapX = !1, this._invertNormalMapY = !1, this._twoSidedLighting = !1, this._alphaCutOff = 0.4, this._useAlphaFresnel = !1, this._useLinearAlphaFresnel = !1, this._environmentBRDFTexture = null, this._environmentFuzzBRDFTexture = null, this._backgroundRefractionTexture = null, this._refractionHighQualityBlur = !0, this._forceIrradianceInFragment = !1, this._realTimeFiltering = !1, this._realTimeFilteringQuality = 8, this._fuzzSampleNumber = 4, this._forceNormalForward = !1, this._enableSpecularAntiAliasing = !1, this._renderTargets = new Qe(16), this._unlit = !1, this._applyDecalMapAfterDetailMap = !1, this._debugMode = 0, this._shadersLoaded = !1, this._breakShaderLoadedCheck = !1, this._vertexPullingMetadata = null, this.debugMode = 0, this.debugLimit = -1, this.debugFactor = 1, this._cacheHasRenderTargetTextures = !1, this._transparencyMode = k.MATERIAL_OPAQUE, this.getScene() && !this.getScene()?.getEngine().isWebGPU && this.getScene().getEngine().webGLVersion < 2 && se.Error("OpenPBRMaterial: WebGL 2.0 or above is required for this material."), r._noiseTextures[this.getScene().uniqueId] || (r._noiseTextures[this.getScene().uniqueId] = new re(qe.GetAssetUrl("https://assets.babylonjs.com/core/blue_noise/blue_noise_rgb.png"), this.getScene(), !1, !0, 1), this.getScene().onDisposeObservable.addOnce(() => {
|
|
2007
|
+
r._noiseTextures[this.getScene().uniqueId]?.dispose(), delete r._noiseTextures[this.getScene().uniqueId];
|
|
2008
|
+
})), this._attachImageProcessingConfiguration(null), this.getRenderTargetTextures = () => (this._renderTargets.reset(), H.ReflectionTextureEnabled && this._radianceTexture && this._radianceTexture.isRenderTarget && this._renderTargets.push(this._radianceTexture), H.RefractionTextureEnabled && this._backgroundRefractionTexture && this._backgroundRefractionTexture.isRenderTarget && this._renderTargets.push(this._backgroundRefractionTexture), this._eventInfo.renderTargets = this._renderTargets, this._callbackPluginEventFillRenderTargetTextures(this._eventInfo), this._renderTargets), this._environmentBRDFTexture = Ft(this.getScene()), this._environmentFuzzBRDFTexture = Ie(this.getScene()), this.prePassConfiguration = new Se(), this._propertyList = {};
|
|
2009
|
+
for (const n of Object.getOwnPropertyNames(this)) {
|
|
2010
|
+
const a = this[n];
|
|
2011
|
+
a instanceof v && (this._propertyList[n] = a);
|
|
2012
|
+
}
|
|
2013
|
+
Object.keys(this._propertyList).forEach((n) => {
|
|
2014
|
+
const a = this._propertyList[n];
|
|
2015
|
+
let f = this._uniformsList[a.targetUniformName];
|
|
2016
|
+
f ? f.numComponents !== a.targetUniformComponentNum ? se.Error(`Uniform ${a.targetUniformName} already exists of size ${f.numComponents}, but trying to set it to ${a.targetUniformComponentNum}.`) : f.requiredDefine !== a.requiredDefine && (f.requiredDefine = void 0) : (f = new ne(a.targetUniformName, a.targetUniformComponentNum), f.requiredDefine = a.requiredDefine, this._uniformsList[a.targetUniformName] = f), f.firstLinkedKey === "" && (f.firstLinkedKey = a.name), f.linkedProperties[a.name] = a;
|
|
2017
|
+
}), this._uniformsArray = Object.values(this._uniformsList), this._samplersList = {};
|
|
2018
|
+
for (const n of Object.getOwnPropertyNames(this)) {
|
|
2019
|
+
const a = this[n];
|
|
2020
|
+
a instanceof O && (this._samplersList[n] = a);
|
|
2021
|
+
}
|
|
2022
|
+
for (const n in this._samplersList) {
|
|
2023
|
+
const f = this._samplersList[n].textureDefine;
|
|
2024
|
+
this._samplerDefines[f] = { type: "boolean", default: !1 }, this._samplerDefines[f + "DIRECTUV"] = { type: "number", default: 0 }, this._samplerDefines[f + "_GAMMA"] = { type: "boolean", default: !1 };
|
|
2025
|
+
}
|
|
2026
|
+
this._baseWeight, this._baseWeightTexture, this._baseColor, this._baseColorTexture, this._baseDiffuseRoughness, this._baseDiffuseRoughnessTexture, this._baseMetalness, this._baseMetalnessTexture, this._specularWeight, this._specularWeightTexture, this._specularColor, this._specularColorTexture, this._specularRoughness, this._specularIor, this._specularRoughnessTexture, this._specularRoughnessAnisotropy, this._specularRoughnessAnisotropyTexture, this._transmissionWeight, this._transmissionWeightTexture, this._transmissionColor, this._transmissionColorTexture, this._transmissionDepth, this._transmissionDepthTexture, this._transmissionScatter, this._transmissionScatterTexture, this._transmissionScatterAnisotropy, this._transmissionDispersionScale, this._transmissionDispersionScaleTexture, this._transmissionDispersionAbbeNumber, this._subsurfaceWeight, this._subsurfaceWeightTexture, this._subsurfaceColor, this._subsurfaceColorTexture, this._subsurfaceRadius, this._subsurfaceRadiusScale, this._subsurfaceRadiusScaleTexture, this._subsurfaceScatterAnisotropy, this._coatWeight, this._coatWeightTexture, this._coatColor, this._coatColorTexture, this._coatRoughness, this._coatRoughnessTexture, this._coatRoughnessAnisotropy, this._coatRoughnessAnisotropyTexture, this._coatIor, this._coatDarkening, this._coatDarkeningTexture, this._fuzzWeight, this._fuzzWeightTexture, this._fuzzColor, this._fuzzColorTexture, this._fuzzRoughness, this._fuzzRoughnessTexture, this._geometryThinWalled, this._geometryNormalTexture, this._geometryTangent, this._geometryTangentTexture, this._geometryCoatNormalTexture, this._geometryCoatTangent, this._geometryCoatTangentTexture, this._geometryOpacity, this._geometryOpacityTexture, this._geometryThickness, this._geometryThicknessTexture, this._thinFilmWeight, this._thinFilmWeightTexture, this._thinFilmThickness, this._thinFilmThicknessMin, this._thinFilmThicknessTexture, this._thinFilmIor, this._emissionLuminance, this._emissionColor, this._emissionColorTexture, this._ambientOcclusionTexture;
|
|
2027
|
+
}
|
|
2028
|
+
/**
|
|
2029
|
+
* Gets a boolean indicating that current material needs to register RTT
|
|
2030
|
+
*/
|
|
2031
|
+
get hasRenderTargetTextures() {
|
|
2032
|
+
return H.ReflectionTextureEnabled && this._radianceTexture && this._radianceTexture.isRenderTarget || H.RefractionTextureEnabled && this._backgroundRefractionTexture && this._backgroundRefractionTexture.isRenderTarget ? !0 : this._cacheHasRenderTargetTextures;
|
|
2033
|
+
}
|
|
2034
|
+
/**
|
|
2035
|
+
* Can this material render to prepass
|
|
2036
|
+
*/
|
|
2037
|
+
get isPrePassCapable() {
|
|
2038
|
+
return !this.disableDepthWrite;
|
|
2039
|
+
}
|
|
2040
|
+
/**
|
|
2041
|
+
* @returns the name of the material class.
|
|
2042
|
+
*/
|
|
2043
|
+
getClassName() {
|
|
2044
|
+
return "OpenPBRMaterial";
|
|
2045
|
+
}
|
|
2046
|
+
get transparencyMode() {
|
|
2047
|
+
return this._transparencyMode;
|
|
2048
|
+
}
|
|
2049
|
+
set transparencyMode(t) {
|
|
2050
|
+
this._transparencyMode !== t && (this._transparencyMode = t, this._markAllSubMeshesAsTexturesAndMiscDirty());
|
|
2051
|
+
}
|
|
2052
|
+
/**
|
|
2053
|
+
* @returns whether or not the alpha value of the albedo texture should be used for alpha blending.
|
|
2054
|
+
*/
|
|
2055
|
+
_shouldUseAlphaFromBaseColorTexture() {
|
|
2056
|
+
return this._hasAlphaChannel() && this._transparencyMode !== k.MATERIAL_OPAQUE && !this.geometryOpacityTexture;
|
|
2057
|
+
}
|
|
2058
|
+
/**
|
|
2059
|
+
* @returns whether or not there is a usable alpha channel for transparency.
|
|
2060
|
+
*/
|
|
2061
|
+
_hasAlphaChannel() {
|
|
2062
|
+
return this.baseColorTexture != null && this.baseColorTexture.hasAlpha && this._useAlphaFromBaseColorTexture || this.geometryOpacityTexture != null;
|
|
2063
|
+
}
|
|
2064
|
+
/**
|
|
2065
|
+
* Makes a duplicate of the current material.
|
|
2066
|
+
* @param name - name to use for the new material.
|
|
2067
|
+
* @param cloneTexturesOnlyOnce - if a texture is used in more than one channel (e.g baseColor and opacity), only clone it once and reuse it on the other channels. Default false.
|
|
2068
|
+
* @param rootUrl defines the root URL to use to load textures
|
|
2069
|
+
* @returns cloned material instance
|
|
2070
|
+
*/
|
|
2071
|
+
clone(t, s = !0, e = "") {
|
|
2072
|
+
const i = Ae.Clone(() => new r(t, this.getScene()), this, { cloneTexturesOnlyOnce: s });
|
|
2073
|
+
return i.id = t, i.name = t, this.stencil.copyTo(i.stencil), this._clonePlugins(i, e), i;
|
|
2074
|
+
}
|
|
2075
|
+
/**
|
|
2076
|
+
* Serializes this PBR Material.
|
|
2077
|
+
* @returns - An object with the serialized material.
|
|
2078
|
+
*/
|
|
2079
|
+
serialize() {
|
|
2080
|
+
const t = super.serialize();
|
|
2081
|
+
return t.customType = "BABYLON.OpenPBRMaterial", t;
|
|
2082
|
+
}
|
|
2083
|
+
// Statics
|
|
2084
|
+
/**
|
|
2085
|
+
* Parses a PBR Material from a serialized object.
|
|
2086
|
+
* @param source - Serialized object.
|
|
2087
|
+
* @param scene - BJS scene instance.
|
|
2088
|
+
* @param rootUrl - url for the scene object
|
|
2089
|
+
* @returns - OpenPBRMaterial
|
|
2090
|
+
*/
|
|
2091
|
+
static Parse(t, s, e) {
|
|
2092
|
+
const i = Ae.Parse(() => new r(t.name, s), t, s, e);
|
|
2093
|
+
return t.stencil && i.stencil.parse(t.stencil, s, e), k._ParsePlugins(t, i, s, e), i;
|
|
2094
|
+
}
|
|
2095
|
+
/**
|
|
2096
|
+
* Force shader compilation
|
|
2097
|
+
* @param mesh - Define the mesh we want to force the compilation for
|
|
2098
|
+
* @param onCompiled - Define a callback triggered when the compilation completes
|
|
2099
|
+
* @param options - Define the options used to create the compilation
|
|
2100
|
+
*/
|
|
2101
|
+
forceCompilation(t, s, e) {
|
|
2102
|
+
const i = {
|
|
2103
|
+
clipPlane: !1,
|
|
2104
|
+
useInstances: !1,
|
|
2105
|
+
...e
|
|
2106
|
+
};
|
|
2107
|
+
this._uniformBufferLayoutBuilt || this.buildUniformLayout(), this._callbackPluginEventGeneric(4, this._eventInfo), (() => {
|
|
2108
|
+
if (this._breakShaderLoadedCheck)
|
|
2109
|
+
return;
|
|
2110
|
+
const a = new ye({
|
|
2111
|
+
...this._eventInfo.defineNames || {},
|
|
2112
|
+
...this._samplerDefines || {}
|
|
2113
|
+
}), f = this._prepareEffect(t, t, a, void 0, void 0, i.useInstances, i.clipPlane);
|
|
2114
|
+
this._onEffectCreatedObservable && (ie.effect = f, ie.subMesh = null, this._onEffectCreatedObservable.notifyObservers(ie)), f.isReady() ? s && s(this) : f.onCompileObservable.add(() => {
|
|
2115
|
+
s && s(this);
|
|
2116
|
+
});
|
|
2117
|
+
})();
|
|
2118
|
+
}
|
|
2119
|
+
/**
|
|
2120
|
+
* Specifies that the submesh is ready to be used.
|
|
2121
|
+
* @param mesh - BJS mesh.
|
|
2122
|
+
* @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
|
|
2123
|
+
* @param useInstances - Specifies that instances should be used.
|
|
2124
|
+
* @returns - boolean indicating that the submesh is ready or not.
|
|
2125
|
+
*/
|
|
2126
|
+
isReadyForSubMesh(t, s, e) {
|
|
2127
|
+
this._uniformBufferLayoutBuilt || this.buildUniformLayout();
|
|
2128
|
+
const i = s._drawWrapper;
|
|
2129
|
+
if (i.effect && this.isFrozen && i._wasPreviouslyReady && i._wasPreviouslyUsingInstances === e)
|
|
2130
|
+
return !0;
|
|
2131
|
+
s.materialDefines || (this._callbackPluginEventGeneric(4, this._eventInfo), s.materialDefines = new ye({
|
|
2132
|
+
...this._eventInfo.defineNames || {},
|
|
2133
|
+
...this._samplerDefines || {}
|
|
2134
|
+
}));
|
|
2135
|
+
const n = s.materialDefines;
|
|
2136
|
+
if (this._isReadyForSubMesh(s))
|
|
2137
|
+
return !0;
|
|
2138
|
+
const a = this.getScene(), f = a.getEngine();
|
|
2139
|
+
if (n._areTexturesDirty && (this._eventInfo.hasRenderTargetTextures = !1, this._callbackPluginEventHasRenderTargetTextures(this._eventInfo), this._cacheHasRenderTargetTextures = this._eventInfo.hasRenderTargetTextures, a.texturesEnabled)) {
|
|
2140
|
+
for (const N in this._samplersList) {
|
|
2141
|
+
const x = this._samplersList[N];
|
|
2142
|
+
if (x.value && !x.value.isReadyOrNotBlocking())
|
|
2143
|
+
return !1;
|
|
2144
|
+
}
|
|
2145
|
+
const A = this._getRadianceTexture();
|
|
2146
|
+
if (A && H.ReflectionTextureEnabled) {
|
|
2147
|
+
if (!A.isReadyOrNotBlocking())
|
|
2148
|
+
return !1;
|
|
2149
|
+
if (A.irradianceTexture) {
|
|
2150
|
+
if (!A.irradianceTexture.isReadyOrNotBlocking())
|
|
2151
|
+
return !1;
|
|
2152
|
+
} else if (!A.sphericalPolynomial && A.getInternalTexture()?._sphericalPolynomialPromise)
|
|
2153
|
+
return !1;
|
|
2154
|
+
}
|
|
2155
|
+
if (this._environmentBRDFTexture && H.ReflectionTextureEnabled && !this._environmentBRDFTexture.isReady() || this._environmentFuzzBRDFTexture && H.ReflectionTextureEnabled && !this._environmentFuzzBRDFTexture.isReady() || this._backgroundRefractionTexture && H.RefractionTextureEnabled && !this._backgroundRefractionTexture.isReadyOrNotBlocking() || r._noiseTextures[a.uniqueId] && !r._noiseTextures[a.uniqueId].isReady() || this._sssIrradianceTexture && this._sssDepthTexture && (!this._sssIrradianceTexture.isReady() || !this._sssDepthTexture.isReady()))
|
|
2156
|
+
return !1;
|
|
2157
|
+
}
|
|
2158
|
+
if (this._eventInfo.isReadyForSubMesh = !0, this._eventInfo.defines = n, this._eventInfo.subMesh = s, this._callbackPluginEventIsReadyForSubMesh(this._eventInfo), !this._eventInfo.isReadyForSubMesh || n._areImageProcessingDirty && this._imageProcessingConfiguration && !this._imageProcessingConfiguration.isReady())
|
|
2159
|
+
return !1;
|
|
2160
|
+
if (n.AREALIGHTUSED) {
|
|
2161
|
+
for (let A = 0; A < t.lightSources.length; A++)
|
|
2162
|
+
if (!t.lightSources[A]._isReady())
|
|
2163
|
+
return !1;
|
|
2164
|
+
}
|
|
2165
|
+
if (!f.getCaps().standardDerivatives && !t.isVerticesDataPresent(G.NormalKind) && (t.createNormals(!0), se.Warn("OpenPBRMaterial: Normals have been created for the mesh: " + t.name)), !Je(a, t, this._maxSimultaneousLights, this._disableLighting))
|
|
2166
|
+
return !1;
|
|
2167
|
+
const I = s.effect, L = n._areLightsDisposed, h = this._prepareEffect(t, s.getRenderingMesh(), n, this.onCompiled, this.onError, e, null);
|
|
2168
|
+
let u = !1;
|
|
2169
|
+
if (h)
|
|
2170
|
+
if (this._onEffectCreatedObservable && (ie.effect = h, ie.subMesh = s, this._onEffectCreatedObservable.notifyObservers(ie)), this.allowShaderHotSwapping && I && !h.isReady()) {
|
|
2171
|
+
if (n.markAsUnprocessed(), u = this.isFrozen, L)
|
|
2172
|
+
return n._areLightsDisposed = !0, !1;
|
|
2173
|
+
} else
|
|
2174
|
+
a.resetCachedMaterial(), s.setEffect(h, n, this._materialContext);
|
|
2175
|
+
return !s.effect || !s.effect.isReady() ? !1 : (n._renderId = a.getRenderId(), i._wasPreviouslyReady = !u, i._wasPreviouslyUsingInstances = !!e, this._checkScenePerformancePriority(), !0);
|
|
2176
|
+
}
|
|
2177
|
+
/**
|
|
2178
|
+
* Initializes the uniform buffer layout for the shader.
|
|
2179
|
+
*/
|
|
2180
|
+
buildUniformLayout() {
|
|
2181
|
+
const t = this._uniformBuffer;
|
|
2182
|
+
t.addUniform("vTangentSpaceParams", 2), t.addUniform("vLightingIntensity", 4), t.addUniform("pointSize", 1), t.addUniform("vDebugMode", 2), t.addUniform("renderTargetSize", 2), t.addUniform("cameraInfo", 4), t.addUniform("vTextureRepetitionHexTilingParams", 4), t.addUniform("backgroundRefractionMatrix", 16), t.addUniform("vBackgroundRefractionInfos", 3), et(t, !0, !0, !0, !0, !0), Object.values(this._uniformsList).forEach((s) => {
|
|
2183
|
+
t.addUniform(s.name, s.numComponents);
|
|
2184
|
+
}), Object.values(this._samplersList).forEach((s) => {
|
|
2185
|
+
t.addUniform(s.samplerInfoName, 2), t.addUniform(s.samplerMatrixName, 16);
|
|
2186
|
+
}), super.buildUniformLayout();
|
|
2187
|
+
}
|
|
2188
|
+
/**
|
|
2189
|
+
* Binds the material data (this function is called even if mustRebind() returns false)
|
|
2190
|
+
* @param uniformBuffer defines the Uniform buffer to fill in.
|
|
2191
|
+
* @param scene defines the scene the material belongs to.
|
|
2192
|
+
* @param engine defines the engine the material belongs to.
|
|
2193
|
+
* @param subMesh the submesh to bind data for
|
|
2194
|
+
*/
|
|
2195
|
+
bindPropertiesForSubMesh(t, s, e, i) {
|
|
2196
|
+
if (this.geometryThickness === 0)
|
|
2197
|
+
t.updateFloat("vGeometryThickness", 0);
|
|
2198
|
+
else {
|
|
2199
|
+
i.getRenderingMesh().getWorldMatrix().decompose(X.Vector3[0]);
|
|
2200
|
+
const n = Math.max(Math.abs(X.Vector3[0].x), Math.abs(X.Vector3[0].y), Math.abs(X.Vector3[0].z));
|
|
2201
|
+
t.updateFloat("vGeometryThickness", this.geometryThickness * n);
|
|
2202
|
+
}
|
|
2203
|
+
}
|
|
2204
|
+
/**
|
|
2205
|
+
* Binds the submesh data.
|
|
2206
|
+
* @param world - The world matrix.
|
|
2207
|
+
* @param mesh - The BJS mesh.
|
|
2208
|
+
* @param subMesh - A submesh of the BJS mesh.
|
|
2209
|
+
*/
|
|
2210
|
+
bindForSubMesh(t, s, e) {
|
|
2211
|
+
const i = this.getScene(), n = e.materialDefines;
|
|
2212
|
+
if (!n)
|
|
2213
|
+
return;
|
|
2214
|
+
const a = e.effect;
|
|
2215
|
+
if (!a)
|
|
2216
|
+
return;
|
|
2217
|
+
this._activeEffect = a, s.getMeshUniformBuffer().bindToEffect(a, "Mesh"), s.transferToEffect(t);
|
|
2218
|
+
const f = i.getEngine();
|
|
2219
|
+
this._uniformBuffer.bindToEffect(a, "Material"), this.prePassConfiguration.bindForSubMesh(this._activeEffect, i, s, t, this.isFrozen), ce.Bind(f.currentRenderPassId, this._activeEffect, s, t, this);
|
|
2220
|
+
const I = i.activeCamera;
|
|
2221
|
+
I ? this._uniformBuffer.updateFloat4("cameraInfo", I.minZ, I.maxZ, 0, 0) : this._uniformBuffer.updateFloat4("cameraInfo", 0, 0, 0, 0);
|
|
2222
|
+
const L = this.textureRepetitionHexTilingParams;
|
|
2223
|
+
this._uniformBuffer.updateFloat4("vTextureRepetitionHexTilingParams", L[0], L[1], L[2], L[3]), this._eventInfo.subMesh = e, this._callbackPluginEventHardBindForSubMesh(this._eventInfo), n.OBJECTSPACE_NORMALMAP && (t.toNormalMatrix(this._normalMatrix), this.bindOnlyNormalMatrix(this._normalMatrix));
|
|
2224
|
+
const h = this._mustRebind(i, a, e, s.visibility);
|
|
2225
|
+
tt(s, this._activeEffect, this.prePassConfiguration), this._vertexPullingMetadata && it(this._activeEffect, this._vertexPullingMetadata);
|
|
2226
|
+
const u = this._uniformBuffer;
|
|
2227
|
+
if (h) {
|
|
2228
|
+
this.bindViewProjection(a);
|
|
2229
|
+
const A = this._getRadianceTexture();
|
|
2230
|
+
if (!u.useUbo || !this.isFrozen || !u.isSync || e._drawWrapper._forceRebindOnNextCall) {
|
|
2231
|
+
if (i.texturesEnabled) {
|
|
2232
|
+
for (const x in this._samplersList) {
|
|
2233
|
+
const M = this._samplersList[x];
|
|
2234
|
+
M.value && (u.updateFloat2(M.samplerInfoName, M.value.coordinatesIndex, M.value.level), st(M.value, u, M.samplerPrefix));
|
|
2235
|
+
}
|
|
2236
|
+
(this.geometryNormalTexture || this.geometryCoatNormalTexture) && (i._mirroredCameraPosition ? u.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1 : -1, this._invertNormalMapY ? 1 : -1) : u.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1 : 1, this._invertNormalMapY ? -1 : 1)), rt(i, n, u, K.White(), A, this.realTimeFiltering, !0, !0, !0, !0, !0);
|
|
2237
|
+
}
|
|
2238
|
+
this.pointsCloud && u.updateFloat("pointSize", this.pointSize);
|
|
2239
|
+
const N = this._uniformsArray;
|
|
2240
|
+
for (let x = 0, M = N.length; x < M; x++) {
|
|
2241
|
+
const R = N[x];
|
|
2242
|
+
R.requiredDefine !== void 0 && !n[R.requiredDefine] || (R.numComponents === 4 ? (R.populateVectorFromLinkedProperties(X.Vector4[0]), u.updateVector4(R.name, X.Vector4[0])) : R.numComponents === 3 ? (R.populateVectorFromLinkedProperties(X.Vector3[0]), u.updateVector3(R.name, X.Vector3[0])) : R.numComponents === 2 ? (R.populateVectorFromLinkedProperties(X.Vector2[0]), u.updateFloat2(R.name, X.Vector2[0].x, X.Vector2[0].y)) : R.numComponents === 1 && u.updateFloat(R.name, R.linkedProperties[R.firstLinkedKey].value));
|
|
2243
|
+
}
|
|
2244
|
+
this._lightingInfos.x = this.directIntensity, this._lightingInfos.y = this.emissionLuminance, this._lightingInfos.z = this.environmentIntensity * i.environmentIntensity, this._lightingInfos.w = 1, u.updateVector4("vLightingIntensity", this._lightingInfos), u.updateFloat2("vDebugMode", this.debugLimit, this.debugFactor);
|
|
2245
|
+
}
|
|
2246
|
+
if (i.texturesEnabled) {
|
|
2247
|
+
for (const N in this._samplersList) {
|
|
2248
|
+
const x = this._samplersList[N];
|
|
2249
|
+
x.value && u.setTexture(x.samplerName, x.value);
|
|
2250
|
+
}
|
|
2251
|
+
if (nt(i, n, u, A, this.realTimeFiltering), n.ENVIRONMENTBRDF && u.setTexture("environmentBrdfSampler", this._environmentBRDFTexture), n.FUZZENVIRONMENTBRDF && u.setTexture("environmentFuzzBrdfSampler", this._environmentFuzzBRDFTexture), n.REFRACTED_BACKGROUND && (u.setTexture("backgroundRefractionSampler", this._backgroundRefractionTexture), u.updateMatrix("backgroundRefractionMatrix", this._backgroundRefractionTexture.getReflectionTextureMatrix()), X.Vector3[1].set(Math.log2(this._backgroundRefractionTexture.getSize().width), 0, 0), u.updateVector3("vBackgroundRefractionInfos", X.Vector3[1])), (n.ANISOTROPIC || n.FUZZ || n.REFRACTED_BACKGROUND || n.USE_IRRADIANCE_TEXTURE_FOR_SCATTERING) && u.setTexture("blueNoiseSampler", r._noiseTextures[this.getScene().uniqueId]), n.USE_IRRADIANCE_TEXTURE_FOR_SCATTERING && this.sssIrradianceTexture && this.sssDepthTexture) {
|
|
2252
|
+
const N = this.sssIrradianceTexture.getSize().width, x = this.sssIrradianceTexture.getSize().height;
|
|
2253
|
+
u.setTexture("sceneIrradianceSampler", this.sssIrradianceTexture), u.setTexture("sceneDepthSampler", this.sssDepthTexture), u.updateFloat2("renderTargetSize", N, x);
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2256
|
+
this.getScene().useOrderIndependentTransparency && this.needAlphaBlendingForMesh(s) && this.getScene().depthPeelingRenderer.bind(a), this._eventInfo.subMesh = e, this._callbackPluginEventBindForSubMesh(this._eventInfo), Pe(this._activeEffect, this, i), this.bindEyePosition(a);
|
|
2257
|
+
} else i.getEngine()._features.needToAlwaysBindUniformBuffers && (this._needToBindSceneUbo = !0);
|
|
2258
|
+
this.bindPropertiesForSubMesh(this._uniformBuffer, i, i.getEngine(), e), (h || !this.isFrozen) && (i.lightsEnabled && !this._disableLighting && at(i, s, this._activeEffect, n, this._maxSimultaneousLights), this.bindView(a), ot(i, s, this._activeEffect, !0), n.NUM_MORPH_INFLUENCERS && Ue(s, this._activeEffect), n.BAKED_VERTEX_ANIMATION_TEXTURE && s.bakedVertexAnimationManager?.bind(a, n.INSTANCES), this._imageProcessingConfiguration.bind(this._activeEffect), lt(n, this._activeEffect, i)), this._afterBind(s, this._activeEffect, e), u.update();
|
|
2259
|
+
}
|
|
2260
|
+
/**
|
|
2261
|
+
* Returns the animatable textures.
|
|
2262
|
+
* If material have animatable metallic texture, then reflectivity texture will not be returned, even if it has animations.
|
|
2263
|
+
* @returns - Array of animatable textures.
|
|
2264
|
+
*/
|
|
2265
|
+
getAnimatables() {
|
|
2266
|
+
const t = super.getAnimatables();
|
|
2267
|
+
for (const s in this._samplersList) {
|
|
2268
|
+
const e = this._samplersList[s];
|
|
2269
|
+
e.value && e.value.animations && e.value.animations.length > 0 && t.push(e.value);
|
|
2270
|
+
}
|
|
2271
|
+
return this._radianceTexture && this._radianceTexture.animations && this._radianceTexture.animations.length > 0 && t.push(this._radianceTexture), t;
|
|
2272
|
+
}
|
|
2273
|
+
/**
|
|
2274
|
+
* Returns an array of the actively used textures.
|
|
2275
|
+
* @returns - Array of BaseTextures
|
|
2276
|
+
*/
|
|
2277
|
+
getActiveTextures() {
|
|
2278
|
+
const t = super.getActiveTextures();
|
|
2279
|
+
for (const s in this._samplersList) {
|
|
2280
|
+
const e = this._samplersList[s];
|
|
2281
|
+
e.value && t.push(e.value);
|
|
2282
|
+
}
|
|
2283
|
+
return this._radianceTexture && t.push(this._radianceTexture), t;
|
|
2284
|
+
}
|
|
2285
|
+
/**
|
|
2286
|
+
* Checks to see if a texture is used in the material.
|
|
2287
|
+
* @param texture - Base texture to use.
|
|
2288
|
+
* @returns - Boolean specifying if a texture is used in the material.
|
|
2289
|
+
*/
|
|
2290
|
+
hasTexture(t) {
|
|
2291
|
+
if (super.hasTexture(t))
|
|
2292
|
+
return !0;
|
|
2293
|
+
for (const s in this._samplersList)
|
|
2294
|
+
if (this._samplersList[s].value === t)
|
|
2295
|
+
return !0;
|
|
2296
|
+
return this._radianceTexture === t;
|
|
2297
|
+
}
|
|
2298
|
+
/**
|
|
2299
|
+
* Sets the required values to the prepass renderer.
|
|
2300
|
+
* It can't be sets when subsurface scattering of this material is disabled.
|
|
2301
|
+
* When scene have ability to enable subsurface prepass effect, it will enable.
|
|
2302
|
+
* @returns - If prepass is enabled or not.
|
|
2303
|
+
*/
|
|
2304
|
+
setPrePassRenderer() {
|
|
2305
|
+
return !1;
|
|
2306
|
+
}
|
|
2307
|
+
/**
|
|
2308
|
+
* Disposes the resources of the material.
|
|
2309
|
+
* @param forceDisposeEffect - Forces the disposal of effects.
|
|
2310
|
+
* @param forceDisposeTextures - Forces the disposal of all textures.
|
|
2311
|
+
*/
|
|
2312
|
+
dispose(t, s) {
|
|
2313
|
+
if (this._breakShaderLoadedCheck = !0, s) {
|
|
2314
|
+
this._environmentBRDFTexture && this.getScene().openPBREnvironmentBRDFTexture !== this._environmentBRDFTexture && this._environmentBRDFTexture.dispose(), this._environmentFuzzBRDFTexture && this.getScene().environmentFuzzBRDFTexture !== this._environmentFuzzBRDFTexture && this._environmentFuzzBRDFTexture.dispose(), this._backgroundRefractionTexture = null;
|
|
2315
|
+
for (const e in this._samplersList)
|
|
2316
|
+
this._samplersList[e].value?.dispose();
|
|
2317
|
+
this._radianceTexture?.dispose();
|
|
2318
|
+
}
|
|
2319
|
+
this._renderTargets.dispose(), this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver), super.dispose(t, s);
|
|
2320
|
+
}
|
|
2321
|
+
/**
|
|
2322
|
+
* Returns the texture used for reflections.
|
|
2323
|
+
* @returns - Reflection texture if present. Otherwise, returns the environment texture.
|
|
2324
|
+
*/
|
|
2325
|
+
_getRadianceTexture() {
|
|
2326
|
+
return this._radianceTexture ? this._radianceTexture : this.getScene().environmentTexture;
|
|
2327
|
+
}
|
|
2328
|
+
_prepareEffect(t, s, e, i = null, n = null, a = null, f = null) {
|
|
2329
|
+
if (this._prepareDefines(t, s, e, a, f), !e.isDirty)
|
|
2330
|
+
return null;
|
|
2331
|
+
e.markAsProcessed();
|
|
2332
|
+
const L = this.getScene().getEngine(), h = new ut();
|
|
2333
|
+
let u = 0;
|
|
2334
|
+
e.USESPHERICALINVERTEX && h.addFallback(u++, "USESPHERICALINVERTEX"), e.FOG && h.addFallback(u, "FOG"), e.SPECULARAA && h.addFallback(u, "SPECULARAA"), e.POINTSIZE && h.addFallback(u, "POINTSIZE"), e.LOGARITHMICDEPTH && h.addFallback(u, "LOGARITHMICDEPTH"), e.PARALLAX && h.addFallback(u, "PARALLAX"), e.PARALLAX_RHS && h.addFallback(u, "PARALLAX_RHS"), e.PARALLAXOCCLUSION && h.addFallback(u++, "PARALLAXOCCLUSION"), e.ENVIRONMENTBRDF && h.addFallback(u++, "ENVIRONMENTBRDF"), e.TANGENT && h.addFallback(u++, "TANGENT"), u = ft(e, h, this._maxSimultaneousLights, u), e.SPECULARTERM && h.addFallback(u++, "SPECULARTERM"), e.USESPHERICALFROMREFLECTIONMAP && h.addFallback(u++, "USESPHERICALFROMREFLECTIONMAP"), e.USEIRRADIANCEMAP && h.addFallback(u++, "USEIRRADIANCEMAP"), e.NORMAL && h.addFallback(u++, "NORMAL"), e.VERTEXCOLOR && h.addFallback(u++, "VERTEXCOLOR"), e.MORPHTARGETS && h.addFallback(u++, "MORPHTARGETS"), e.MULTIVIEW && h.addFallback(0, "MULTIVIEW");
|
|
2335
|
+
const A = [G.PositionKind];
|
|
2336
|
+
e.NORMAL && A.push(G.NormalKind), e.TANGENT && A.push(G.TangentKind);
|
|
2337
|
+
for (let S = 1; S <= 6; ++S)
|
|
2338
|
+
e["UV" + S] && A.push(`uv${S === 1 ? "" : S}`);
|
|
2339
|
+
e.VERTEXCOLOR && A.push(G.ColorKind), ct(A, t, e, h), ht(A, e), dt(A, t, e), _t(A, t, e);
|
|
2340
|
+
let N = "openpbr";
|
|
2341
|
+
const x = [
|
|
2342
|
+
"world",
|
|
2343
|
+
"view",
|
|
2344
|
+
"viewProjection",
|
|
2345
|
+
"projection",
|
|
2346
|
+
"vEyePosition",
|
|
2347
|
+
"inverseProjection",
|
|
2348
|
+
"renderTargetSize",
|
|
2349
|
+
"vLightsType",
|
|
2350
|
+
"visibility",
|
|
2351
|
+
"vFogInfos",
|
|
2352
|
+
"vFogColor",
|
|
2353
|
+
"pointSize",
|
|
2354
|
+
"mBones",
|
|
2355
|
+
"normalMatrix",
|
|
2356
|
+
"vLightingIntensity",
|
|
2357
|
+
"logarithmicDepthConstant",
|
|
2358
|
+
"vTangentSpaceParams",
|
|
2359
|
+
"boneTextureInfo",
|
|
2360
|
+
"vDebugMode",
|
|
2361
|
+
"morphTargetTextureInfo",
|
|
2362
|
+
"morphTargetTextureIndices",
|
|
2363
|
+
"cameraInfo",
|
|
2364
|
+
"vTextureRepetitionHexTilingParams",
|
|
2365
|
+
"backgroundRefractionMatrix",
|
|
2366
|
+
"vBackgroundRefractionInfos"
|
|
2367
|
+
];
|
|
2368
|
+
for (const S in this._uniformsList)
|
|
2369
|
+
x.push(S);
|
|
2370
|
+
const M = ["environmentBrdfSampler", "boneSampler", "morphTargets", "oitDepthSampler", "oitFrontColorSampler", "areaLightsLTC1Sampler", "areaLightsLTC2Sampler"];
|
|
2371
|
+
e.FUZZENVIRONMENTBRDF && M.push("environmentFuzzBrdfSampler"), e.REFRACTED_BACKGROUND && M.push("backgroundRefractionSampler"), (e.ANISOTROPIC || e.FUZZ || e.REFRACTED_BACKGROUND || e.USE_IRRADIANCE_TEXTURE_FOR_SCATTERING) && M.push("blueNoiseSampler"), e.USE_IRRADIANCE_TEXTURE_FOR_SCATTERING && (M.push("sceneIrradianceSampler"), M.push("sceneDepthSampler"));
|
|
2372
|
+
for (const S in this._samplersList) {
|
|
2373
|
+
const c = this._samplersList[S];
|
|
2374
|
+
M.push(c.samplerName), x.push(c.samplerInfoName), x.push(c.samplerMatrixName);
|
|
2375
|
+
}
|
|
2376
|
+
Be(x, M, !0);
|
|
2377
|
+
const R = ["Material", "Scene", "Mesh"], T = { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: e.NUM_MORPH_INFLUENCERS };
|
|
2378
|
+
if (this._eventInfo.fallbacks = h, this._eventInfo.fallbackRank = u, this._eventInfo.defines = e, this._eventInfo.uniforms = x, this._eventInfo.attributes = A, this._eventInfo.samplers = M, this._eventInfo.uniformBuffersNames = R, this._eventInfo.customCode = void 0, this._eventInfo.mesh = t, this._eventInfo.indexParameters = T, this._callbackPluginEventGeneric(128, this._eventInfo), ce.AddUniformsAndSamplers(x, M), Se.AddUniforms(x), Ve(x), this._useVertexPulling) {
|
|
2379
|
+
const S = s?.geometry;
|
|
2380
|
+
S && (this._vertexPullingMetadata = Tt(S), this._vertexPullingMetadata && this._vertexPullingMetadata.forEach((c, Y) => {
|
|
2381
|
+
x.push(`vp_${Y}_info`);
|
|
2382
|
+
}));
|
|
2383
|
+
} else
|
|
2384
|
+
this._vertexPullingMetadata = null;
|
|
2385
|
+
he && (he.PrepareUniforms(x, e), he.PrepareSamplers(M, e)), mt({
|
|
2386
|
+
uniformsNames: x,
|
|
2387
|
+
uniformBuffersNames: R,
|
|
2388
|
+
samplers: M,
|
|
2389
|
+
defines: e,
|
|
2390
|
+
maxSimultaneousLights: this._maxSimultaneousLights,
|
|
2391
|
+
shaderLanguage: this._shaderLanguage
|
|
2392
|
+
});
|
|
2393
|
+
const m = {};
|
|
2394
|
+
this.customShaderNameResolve && (N = this.customShaderNameResolve(N, x, R, M, e, A, m));
|
|
2395
|
+
const F = e.toString(), y = L.createEffect(N, {
|
|
2396
|
+
attributes: A,
|
|
2397
|
+
uniformsNames: x,
|
|
2398
|
+
uniformBuffersNames: R,
|
|
2399
|
+
samplers: M,
|
|
2400
|
+
defines: F,
|
|
2401
|
+
fallbacks: h,
|
|
2402
|
+
onCompiled: i,
|
|
2403
|
+
onError: n,
|
|
2404
|
+
indexParameters: T,
|
|
2405
|
+
processFinalCode: m.processFinalCode,
|
|
2406
|
+
processCodeAfterIncludes: this._eventInfo.customCode,
|
|
2407
|
+
multiTarget: e.PREPASS,
|
|
2408
|
+
shaderLanguage: this._shaderLanguage,
|
|
2409
|
+
extraInitializationsAsync: this._shadersLoaded ? void 0 : async () => {
|
|
2410
|
+
this.shaderLanguage === 1 ? await Promise.all([import("./openpbr.vertex-DMdFRTnX.js"), import("./openpbr.fragment-BglYS6LA.js")]) : await Promise.all([import("./openpbr.vertex-B-PaLFOR.js"), import("./openpbr.fragment-DrOTZs4m.js")]), this._shadersLoaded = !0;
|
|
2411
|
+
}
|
|
2412
|
+
}, L);
|
|
2413
|
+
return this._eventInfo.customCode = void 0, y;
|
|
2414
|
+
}
|
|
2415
|
+
_prepareDefines(t, s, e, i = null, n = null) {
|
|
2416
|
+
const a = s.hasThinInstances, f = this.getScene(), I = f.getEngine();
|
|
2417
|
+
pt(f, t, e, !0, this._maxSimultaneousLights, this._disableLighting), e._needNormals = !0, Et(f, e);
|
|
2418
|
+
const L = this.needAlphaBlendingForMesh(t) && this.getScene().useOrderIndependentTransparency;
|
|
2419
|
+
if (Rt(f, e, this.canRenderToMRT && !L), gt(f, e, L), ce.PrepareDefines(I.currentRenderPassId, t, e), e._areTexturesDirty) {
|
|
2420
|
+
e._needUVs = !1;
|
|
2421
|
+
for (let u = 1; u <= 6; ++u)
|
|
2422
|
+
e["MAINUV" + u] = !1;
|
|
2423
|
+
if (f.texturesEnabled) {
|
|
2424
|
+
for (const N in this._samplersList) {
|
|
2425
|
+
const x = this._samplersList[N];
|
|
2426
|
+
x.value ? (St(x.value, e, x.textureDefine), e[x.textureDefine + "_GAMMA"] = x.value.gammaSpace) : e[x.textureDefine] = !1;
|
|
2427
|
+
}
|
|
2428
|
+
const u = this._getRadianceTexture(), A = this._forceIrradianceInFragment || this.realTimeFiltering || this._twoSidedLighting || I.getCaps().maxVaryingVectors <= 8 || this._baseDiffuseRoughnessTexture != null;
|
|
2429
|
+
if (De(f, u, e, this.realTimeFiltering, this.realTimeFilteringQuality, !A), this._baseMetalnessTexture && (e.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed), e.SPECULAR_WEIGHT_IN_ALPHA = this._useSpecularWeightFromAlpha, e.SPECULAR_WEIGHT_FROM_SPECULAR_COLOR_TEXTURE = this._useSpecularWeightFromSpecularColorTexture, e.SPECULAR_ROUGHNESS_ANISOTROPY_FROM_TANGENT_TEXTURE = this._useSpecularRoughnessAnisotropyFromTangentTexture, e.COAT_ROUGHNESS_ANISOTROPY_FROM_TANGENT_TEXTURE = this._useCoatRoughnessAnisotropyFromTangentTexture, e.COAT_ROUGHNESS_FROM_GREEN_CHANNEL = this._useCoatRoughnessFromGreenChannel, e.SPECULAR_ROUGHNESS_FROM_METALNESS_TEXTURE_GREEN = this._useRoughnessFromMetallicTextureGreen, e.FUZZ_ROUGHNESS_FROM_TEXTURE_ALPHA = this._useFuzzRoughnessFromTextureAlpha, e.SUBSURFACE_WEIGHT_FROM_TEXTURE_ALPHA = this._useSubsurfaceWeightFromTextureAlpha, e.BASE_METALNESS_FROM_METALNESS_TEXTURE_BLUE = this._useMetallicFromMetallicTextureBlue, e.THIN_FILM_THICKNESS_FROM_THIN_FILM_TEXTURE = this._useThinFilmThicknessFromTextureGreen, e.GEOMETRY_THICKNESS_FROM_GREEN_CHANNEL = this._useGeometryThicknessFromGreenChannel, this.geometryNormalTexture ? (this._useParallax && this.baseColorTexture && H.DiffuseTextureEnabled ? (e.PARALLAX = !0, e.PARALLAX_RHS = f.useRightHandedSystem, e.PARALLAXOCCLUSION = !!this._useParallaxOcclusion) : e.PARALLAX = !1, e.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap) : (e.PARALLAX = !1, e.PARALLAX_RHS = !1, e.PARALLAXOCCLUSION = !1, e.OBJECTSPACE_NORMALMAP = !1), this._environmentBRDFTexture && H.ReflectionTextureEnabled ? (e.ENVIRONMENTBRDF = !0, e.ENVIRONMENTBRDF_RGBD = this._environmentBRDFTexture.isRGBD) : (e.ENVIRONMENTBRDF = !1, e.ENVIRONMENTBRDF_RGBD = !1), this._environmentFuzzBRDFTexture ? e.FUZZENVIRONMENTBRDF = !0 : e.FUZZENVIRONMENTBRDF = !1, this.hasTransparency) {
|
|
2430
|
+
e.REFRACTED_BACKGROUND = !!this._backgroundRefractionTexture && H.RefractionTextureEnabled, e.REFRACTION_HIGH_QUALITY_BLUR = this._refractionHighQualityBlur, e.REFRACTED_LIGHTS = !0;
|
|
2431
|
+
const N = this._getRadianceTexture();
|
|
2432
|
+
N ? (e.REFRACTED_ENVIRONMENT = H.RefractionTextureEnabled, e.REFRACTED_ENVIRONMENT_OPPOSITEZ = this.getScene().useRightHandedSystem ? !N.invertZ : N.invertZ, e.REFRACTED_ENVIRONMENT_LOCAL_CUBE = N.isCube && N.boundingBoxSize) : e.REFRACTED_ENVIRONMENT = !1;
|
|
2433
|
+
} else
|
|
2434
|
+
e.REFRACTED_BACKGROUND = !1, e.REFRACTED_LIGHTS = !1, e.REFRACTED_ENVIRONMENT = !1;
|
|
2435
|
+
this._shouldUseAlphaFromBaseColorTexture() ? e.ALPHA_FROM_BASE_COLOR_TEXTURE = !0 : e.ALPHA_FROM_BASE_COLOR_TEXTURE = !1;
|
|
2436
|
+
}
|
|
2437
|
+
this._lightFalloff === k.LIGHTFALLOFF_STANDARD ? (e.USEPHYSICALLIGHTFALLOFF = !1, e.USEGLTFLIGHTFALLOFF = !1) : this._lightFalloff === k.LIGHTFALLOFF_GLTF ? (e.USEPHYSICALLIGHTFALLOFF = !1, e.USEGLTFLIGHTFALLOFF = !0) : (e.USEPHYSICALLIGHTFALLOFF = !0, e.USEGLTFLIGHTFALLOFF = !1), !this.backFaceCulling && this._twoSidedLighting ? e.TWOSIDEDLIGHTING = !0 : e.TWOSIDEDLIGHTING = !1, e.MIRRORED = !!f._mirroredCameraPosition, e.SPECULARAA = I.getCaps().standardDerivatives && this._enableSpecularAntiAliasing;
|
|
2438
|
+
}
|
|
2439
|
+
(e._areTexturesDirty || e._areMiscDirty) && (e.ALPHATESTVALUE = `${this._alphaCutOff}${this._alphaCutOff % 1 === 0 ? "." : ""}`, e.PREMULTIPLYALPHA = this.alphaMode === 7 || this.alphaMode === 8, e.ALPHABLEND = this.needAlphaBlendingForMesh(t)), e._areTexturesDirty && (e.TEXTURE_REPETITION_MODE = I.version > 1 || I.isWebGPU ? this.textureRepetitionMode : 0), e._areImageProcessingDirty && this._imageProcessingConfiguration && this._imageProcessingConfiguration.prepareDefines(e), e.FORCENORMALFORWARD = this._forceNormalForward, e.RADIANCEOCCLUSION = this._useRadianceOcclusion, e.HORIZONOCCLUSION = this._useHorizonOcclusion, (this.specularRoughnessAnisotropy > 0 || this.coatRoughnessAnisotropy > 0) && r._noiseTextures[f.uniqueId] && H.ReflectionTextureEnabled ? (e.ANISOTROPIC = !0, t.isVerticesDataPresent(G.TangentKind) || (e._needUVs = !0, e.MAINUV1 = !0), this._useGltfStyleAnisotropy && (e.USE_GLTF_STYLE_ANISOTROPY = !0), e.ANISOTROPIC_BASE = this.specularRoughnessAnisotropy > 0, e.ANISOTROPIC_COAT = this.coatRoughnessAnisotropy > 0) : (e.ANISOTROPIC = !1, e.USE_GLTF_STYLE_ANISOTROPY = !1, e.ANISOTROPIC_BASE = !1, e.ANISOTROPIC_COAT = !1), e.THIN_FILM = this.thinFilmWeight > 0, e.IRIDESCENCE = this.thinFilmWeight > 0, e.DISPERSION = this.transmissionDispersionScale > 0, e.SCATTERING = this.hasScattering;
|
|
2440
|
+
const h = [8, 16, 32];
|
|
2441
|
+
if (e.SSS_SAMPLE_COUNT = h[this._sssQuality] ?? 16, e.TRANSMISSION_SLAB = this.transmissionWeight > 0, e.TRANSMISSION_SLAB_VOLUME = this.transmissionWeight > 0 && this.transmissionDepth > 0, e.SUBSURFACE_SLAB = this.subsurfaceWeight > 0, !e.PREPASS && (e.SUBSURFACE_SLAB || e.TRANSMISSION_SLAB_VOLUME)) {
|
|
2442
|
+
let u = !1;
|
|
2443
|
+
if (!this.sssIrradianceTexture && f.geometryBufferRenderer) {
|
|
2444
|
+
const A = f.geometryBufferRenderer.getTextureIndex(C.IRRADIANCE_TEXTURE_TYPE);
|
|
2445
|
+
this.sssIrradianceTexture = f.geometryBufferRenderer.getGBuffer().textures[A], u = !0;
|
|
2446
|
+
}
|
|
2447
|
+
if (!this.sssDepthTexture && f.geometryBufferRenderer) {
|
|
2448
|
+
const A = f.geometryBufferRenderer.getTextureIndex(C.SCREENSPACE_DEPTH_TEXTURE_TYPE);
|
|
2449
|
+
this.sssDepthTexture = f.geometryBufferRenderer.getGBuffer().textures[A], u = !0;
|
|
2450
|
+
}
|
|
2451
|
+
this.sssIrradianceTexture && this.sssDepthTexture && (e.USE_IRRADIANCE_TEXTURE_FOR_SCATTERING = !0, u && (e.USE_IRRADIANCE_TEXTURE_FOR_SCATTERING_GBUFFER = !0));
|
|
2452
|
+
}
|
|
2453
|
+
e.FUZZ = this.fuzzWeight > 0 && H.ReflectionTextureEnabled, e.GEOMETRY_THIN_WALLED = this.geometryThinWalled != 0, e.FUZZ ? (t.isVerticesDataPresent(G.TangentKind) || (e._needUVs = !0, e.MAINUV1 = !0), this._environmentFuzzBRDFTexture = Ie(this.getScene()), e.FUZZ_IBL_SAMPLES = this.fuzzSampleNumber) : (this._environmentFuzzBRDFTexture = null, e.FUZZENVIRONMENTBRDF = !1, e.FUZZ_IBL_SAMPLES = 0), e._areMiscDirty && (At(t, f, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this.needAlphaTestingForMesh(t), e, this._applyDecalMapAfterDetailMap, this._useVertexPulling, s, this._isVertexOutputInvariant), e.UNLIT = this._unlit || (this.pointsCloud || this.wireframe) && !t.isVerticesDataPresent(G.NormalKind), e.DEBUGMODE = this._debugMode), It(f, I, this, e, !!i, n, a), this._eventInfo.defines = e, this._eventInfo.mesh = t, this._callbackPluginEventPrepareDefinesBeforeAttributes(this._eventInfo), xt(t, e, !0, !0, !0, this._transparencyMode !== k.MATERIAL_OPAQUE), this._callbackPluginEventPrepareDefines(this._eventInfo);
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2456
|
+
r.SSS_QUALITY_LOW = 0;
|
|
2457
|
+
r.SSS_QUALITY_MEDIUM = 1;
|
|
2458
|
+
r.SSS_QUALITY_HIGH = 2;
|
|
2459
|
+
r._noiseTextures = {};
|
|
2460
|
+
r.ForceGLSL = !1;
|
|
2461
|
+
o([
|
|
2462
|
+
d("_markAllSubMeshesAsTexturesDirty", "baseWeight")
|
|
2463
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2464
|
+
], r.prototype, "_baseWeight", void 0);
|
|
2465
|
+
o([
|
|
2466
|
+
d("_markAllSubMeshesAsTexturesDirty", "baseWeightTexture")
|
|
2467
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2468
|
+
], r.prototype, "_baseWeightTexture", void 0);
|
|
2469
|
+
o([
|
|
2470
|
+
d("_markAllSubMeshesAsTexturesDirty", "baseColor")
|
|
2471
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2472
|
+
], r.prototype, "_baseColor", void 0);
|
|
2473
|
+
o([
|
|
2474
|
+
d("_markAllSubMeshesAsTexturesDirty", "baseColorTexture")
|
|
2475
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2476
|
+
], r.prototype, "_baseColorTexture", void 0);
|
|
2477
|
+
o([
|
|
2478
|
+
d("_markAllSubMeshesAsTexturesDirty", "baseDiffuseRoughness")
|
|
2479
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2480
|
+
], r.prototype, "_baseDiffuseRoughness", void 0);
|
|
2481
|
+
o([
|
|
2482
|
+
d("_markAllSubMeshesAsTexturesDirty", "baseDiffuseRoughnessTexture")
|
|
2483
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2484
|
+
], r.prototype, "_baseDiffuseRoughnessTexture", void 0);
|
|
2485
|
+
o([
|
|
2486
|
+
d("_markAllSubMeshesAsTexturesDirty", "baseMetalness")
|
|
2487
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2488
|
+
], r.prototype, "_baseMetalness", void 0);
|
|
2489
|
+
o([
|
|
2490
|
+
d("_markAllSubMeshesAsTexturesDirty", "baseMetalnessTexture")
|
|
2491
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2492
|
+
], r.prototype, "_baseMetalnessTexture", void 0);
|
|
2493
|
+
o([
|
|
2494
|
+
d("_markAllSubMeshesAsTexturesDirty", "specularWeight")
|
|
2495
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2496
|
+
], r.prototype, "_specularWeight", void 0);
|
|
2497
|
+
o([
|
|
2498
|
+
d("_markAllSubMeshesAsTexturesDirty", "specularWeightTexture")
|
|
2499
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2500
|
+
], r.prototype, "_specularWeightTexture", void 0);
|
|
2501
|
+
o([
|
|
2502
|
+
d("_markAllSubMeshesAsTexturesDirty", "specularColor")
|
|
2503
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2504
|
+
], r.prototype, "_specularColor", void 0);
|
|
2505
|
+
o([
|
|
2506
|
+
d("_markAllSubMeshesAsTexturesDirty", "specularColorTexture")
|
|
2507
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2508
|
+
], r.prototype, "_specularColorTexture", void 0);
|
|
2509
|
+
o([
|
|
2510
|
+
d("_markAllSubMeshesAsTexturesDirty", "specularRoughness")
|
|
2511
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2512
|
+
], r.prototype, "_specularRoughness", void 0);
|
|
2513
|
+
o([
|
|
2514
|
+
d("_markAllSubMeshesAsTexturesDirty", "specularRoughnessTexture")
|
|
2515
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2516
|
+
], r.prototype, "_specularRoughnessTexture", void 0);
|
|
2517
|
+
o([
|
|
2518
|
+
d("_markAllSubMeshesAsTexturesDirty", "specularRoughnessAnisotropy")
|
|
2519
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2520
|
+
], r.prototype, "_specularRoughnessAnisotropy", void 0);
|
|
2521
|
+
o([
|
|
2522
|
+
d("_markAllSubMeshesAsTexturesDirty", "specularRoughnessAnisotropyTexture")
|
|
2523
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2524
|
+
], r.prototype, "_specularRoughnessAnisotropyTexture", void 0);
|
|
2525
|
+
o([
|
|
2526
|
+
d("_markAllSubMeshesAsTexturesDirty", "specularIor")
|
|
2527
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2528
|
+
], r.prototype, "_specularIor", void 0);
|
|
2529
|
+
o([
|
|
2530
|
+
d("_markAllSubMeshesAsTexturesDirty", "transmissionWeight")
|
|
2531
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2532
|
+
], r.prototype, "_transmissionWeight", void 0);
|
|
2533
|
+
o([
|
|
2534
|
+
d("_markAllSubMeshesAsTexturesDirty", "transmissionWeightTexture")
|
|
2535
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2536
|
+
], r.prototype, "_transmissionWeightTexture", void 0);
|
|
2537
|
+
o([
|
|
2538
|
+
d("_markAllSubMeshesAsTexturesDirty", "transmissionColor")
|
|
2539
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2540
|
+
], r.prototype, "_transmissionColor", void 0);
|
|
2541
|
+
o([
|
|
2542
|
+
d("_markAllSubMeshesAsTexturesDirty", "transmissionColorTexture")
|
|
2543
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2544
|
+
], r.prototype, "_transmissionColorTexture", void 0);
|
|
2545
|
+
o([
|
|
2546
|
+
d("_markAllSubMeshesAsTexturesDirty", "transmissionDepth")
|
|
2547
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2548
|
+
], r.prototype, "_transmissionDepth", void 0);
|
|
2549
|
+
o([
|
|
2550
|
+
d("_markAllSubMeshesAsTexturesDirty", "transmissionDepthTexture")
|
|
2551
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2552
|
+
], r.prototype, "_transmissionDepthTexture", void 0);
|
|
2553
|
+
o([
|
|
2554
|
+
d("_markAllSubMeshesAsTexturesDirty", "transmissionScatter")
|
|
2555
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2556
|
+
], r.prototype, "_transmissionScatter", void 0);
|
|
2557
|
+
o([
|
|
2558
|
+
d("_markAllSubMeshesAsTexturesDirty", "transmissionScatterTexture")
|
|
2559
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2560
|
+
], r.prototype, "_transmissionScatterTexture", void 0);
|
|
2561
|
+
o([
|
|
2562
|
+
d("_markAllSubMeshesAsTexturesDirty", "transmissionScatterAnisotropy")
|
|
2563
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2564
|
+
], r.prototype, "_transmissionScatterAnisotropy", void 0);
|
|
2565
|
+
o([
|
|
2566
|
+
d("_markAllSubMeshesAsTexturesDirty", "transmissionDispersionScale")
|
|
2567
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2568
|
+
], r.prototype, "_transmissionDispersionScale", void 0);
|
|
2569
|
+
o([
|
|
2570
|
+
d("_markAllSubMeshesAsTexturesDirty", "transmissionDispersionScaleTexture")
|
|
2571
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2572
|
+
], r.prototype, "_transmissionDispersionScaleTexture", void 0);
|
|
2573
|
+
o([
|
|
2574
|
+
d("_markAllSubMeshesAsTexturesDirty", "transmissionDispersionAbbeNumber")
|
|
2575
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2576
|
+
], r.prototype, "_transmissionDispersionAbbeNumber", void 0);
|
|
2577
|
+
o([
|
|
2578
|
+
d("_markAllSubMeshesAsTexturesDirty", "subsurfaceWeight")
|
|
2579
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2580
|
+
], r.prototype, "_subsurfaceWeight", void 0);
|
|
2581
|
+
o([
|
|
2582
|
+
d("_markAllSubMeshesAsTexturesDirty", "subsurfaceWeightTexture")
|
|
2583
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2584
|
+
], r.prototype, "_subsurfaceWeightTexture", void 0);
|
|
2585
|
+
o([
|
|
2586
|
+
d("_markAllSubMeshesAsTexturesDirty", "subsurfaceColor")
|
|
2587
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2588
|
+
], r.prototype, "_subsurfaceColor", void 0);
|
|
2589
|
+
o([
|
|
2590
|
+
d("_markAllSubMeshesAsTexturesDirty", "subsurfaceColorTexture")
|
|
2591
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2592
|
+
], r.prototype, "_subsurfaceColorTexture", void 0);
|
|
2593
|
+
o([
|
|
2594
|
+
d("_markAllSubMeshesAsTexturesDirty", "subsurfaceRadius")
|
|
2595
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2596
|
+
], r.prototype, "_subsurfaceRadius", void 0);
|
|
2597
|
+
o([
|
|
2598
|
+
d("_markAllSubMeshesAsTexturesDirty", "subsurfaceRadiusScale")
|
|
2599
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2600
|
+
], r.prototype, "_subsurfaceRadiusScale", void 0);
|
|
2601
|
+
o([
|
|
2602
|
+
d("_markAllSubMeshesAsTexturesDirty", "subsurfaceRadiusScaleTexture")
|
|
2603
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2604
|
+
], r.prototype, "_subsurfaceRadiusScaleTexture", void 0);
|
|
2605
|
+
o([
|
|
2606
|
+
d("_markAllSubMeshesAsTexturesDirty", "subsurfaceScatterAnisotropy")
|
|
2607
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2608
|
+
], r.prototype, "_subsurfaceScatterAnisotropy", void 0);
|
|
2609
|
+
o([
|
|
2610
|
+
d("_markAllSubMeshesAsTexturesDirty", "coatWeight")
|
|
2611
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2612
|
+
], r.prototype, "_coatWeight", void 0);
|
|
2613
|
+
o([
|
|
2614
|
+
d("_markAllSubMeshesAsTexturesDirty", "coatWeightTexture")
|
|
2615
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2616
|
+
], r.prototype, "_coatWeightTexture", void 0);
|
|
2617
|
+
o([
|
|
2618
|
+
d("_markAllSubMeshesAsTexturesDirty", "coatColor")
|
|
2619
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2620
|
+
], r.prototype, "_coatColor", void 0);
|
|
2621
|
+
o([
|
|
2622
|
+
d("_markAllSubMeshesAsTexturesDirty", "coatColorTexture")
|
|
2623
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2624
|
+
], r.prototype, "_coatColorTexture", void 0);
|
|
2625
|
+
o([
|
|
2626
|
+
d("_markAllSubMeshesAsTexturesDirty", "coatRoughness")
|
|
2627
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2628
|
+
], r.prototype, "_coatRoughness", void 0);
|
|
2629
|
+
o([
|
|
2630
|
+
d("_markAllSubMeshesAsTexturesDirty", "coatRoughnessTexture")
|
|
2631
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2632
|
+
], r.prototype, "_coatRoughnessTexture", void 0);
|
|
2633
|
+
o([
|
|
2634
|
+
d("_markAllSubMeshesAsTexturesDirty", "coatRoughnessAnisotropy")
|
|
2635
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2636
|
+
], r.prototype, "_coatRoughnessAnisotropy", void 0);
|
|
2637
|
+
o([
|
|
2638
|
+
d("_markAllSubMeshesAsTexturesDirty", "coatRoughnessAnisotropyTexture")
|
|
2639
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2640
|
+
], r.prototype, "_coatRoughnessAnisotropyTexture", void 0);
|
|
2641
|
+
o([
|
|
2642
|
+
d("_markAllSubMeshesAsTexturesDirty", "coatIor")
|
|
2643
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2644
|
+
], r.prototype, "_coatIor", void 0);
|
|
2645
|
+
o([
|
|
2646
|
+
d("_markAllSubMeshesAsTexturesDirty", "coatDarkening")
|
|
2647
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2648
|
+
], r.prototype, "_coatDarkening", void 0);
|
|
2649
|
+
o([
|
|
2650
|
+
d("_markAllSubMeshesAsTexturesDirty", "coatDarkeningTexture")
|
|
2651
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2652
|
+
], r.prototype, "_coatDarkeningTexture", void 0);
|
|
2653
|
+
o([
|
|
2654
|
+
d("_markAllSubMeshesAsTexturesDirty", "fuzzWeight")
|
|
2655
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2656
|
+
], r.prototype, "_fuzzWeight", void 0);
|
|
2657
|
+
o([
|
|
2658
|
+
d("_markAllSubMeshesAsTexturesDirty", "fuzzWeightTexture")
|
|
2659
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2660
|
+
], r.prototype, "_fuzzWeightTexture", void 0);
|
|
2661
|
+
o([
|
|
2662
|
+
d("_markAllSubMeshesAsTexturesDirty", "fuzzColor")
|
|
2663
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2664
|
+
], r.prototype, "_fuzzColor", void 0);
|
|
2665
|
+
o([
|
|
2666
|
+
d("_markAllSubMeshesAsTexturesDirty", "fuzzColorTexture")
|
|
2667
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2668
|
+
], r.prototype, "_fuzzColorTexture", void 0);
|
|
2669
|
+
o([
|
|
2670
|
+
d("_markAllSubMeshesAsTexturesDirty", "fuzzRoughness")
|
|
2671
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2672
|
+
], r.prototype, "_fuzzRoughness", void 0);
|
|
2673
|
+
o([
|
|
2674
|
+
d("_markAllSubMeshesAsTexturesDirty", "fuzzRoughnessTexture")
|
|
2675
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2676
|
+
], r.prototype, "_fuzzRoughnessTexture", void 0);
|
|
2677
|
+
o([
|
|
2678
|
+
d("_markAllSubMeshesAsTexturesDirty", "geometryThinWalled")
|
|
2679
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2680
|
+
], r.prototype, "_geometryThinWalled", void 0);
|
|
2681
|
+
o([
|
|
2682
|
+
d("_markAllSubMeshesAsTexturesDirty", "geometryNormalTexture")
|
|
2683
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2684
|
+
], r.prototype, "_geometryNormalTexture", void 0);
|
|
2685
|
+
o([
|
|
2686
|
+
d("_markAllSubMeshesAsTexturesDirty", "geometryTangent")
|
|
2687
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2688
|
+
], r.prototype, "_geometryTangent", void 0);
|
|
2689
|
+
o([
|
|
2690
|
+
d("_markAllSubMeshesAsTexturesDirty", "geometryTangentTexture")
|
|
2691
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2692
|
+
], r.prototype, "_geometryTangentTexture", void 0);
|
|
2693
|
+
o([
|
|
2694
|
+
d("_markAllSubMeshesAsTexturesDirty", "geometryCoatNormalTexture")
|
|
2695
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2696
|
+
], r.prototype, "_geometryCoatNormalTexture", void 0);
|
|
2697
|
+
o([
|
|
2698
|
+
d("_markAllSubMeshesAsTexturesDirty", "geometryCoatTangent")
|
|
2699
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2700
|
+
], r.prototype, "_geometryCoatTangent", void 0);
|
|
2701
|
+
o([
|
|
2702
|
+
d("_markAllSubMeshesAsTexturesDirty", "geometryCoatTangentTexture")
|
|
2703
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2704
|
+
], r.prototype, "_geometryCoatTangentTexture", void 0);
|
|
2705
|
+
o([
|
|
2706
|
+
d("_markAllSubMeshesAsTexturesDirty", "geometryOpacity")
|
|
2707
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2708
|
+
], r.prototype, "_geometryOpacity", void 0);
|
|
2709
|
+
o([
|
|
2710
|
+
d("_markAllSubMeshesAsTexturesDirty", "geometryOpacityTexture")
|
|
2711
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2712
|
+
], r.prototype, "_geometryOpacityTexture", void 0);
|
|
2713
|
+
o([
|
|
2714
|
+
d("_markAllSubMeshesAsTexturesDirty", "geometryThickness")
|
|
2715
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2716
|
+
], r.prototype, "_geometryThickness", void 0);
|
|
2717
|
+
o([
|
|
2718
|
+
d("_markAllSubMeshesAsTexturesDirty", "geometryThicknessTexture")
|
|
2719
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2720
|
+
], r.prototype, "_geometryThicknessTexture", void 0);
|
|
2721
|
+
o([
|
|
2722
|
+
d("_markAllSubMeshesAsTexturesDirty", "emissionLuminance")
|
|
2723
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2724
|
+
], r.prototype, "_emissionLuminance", void 0);
|
|
2725
|
+
o([
|
|
2726
|
+
d("_markAllSubMeshesAsTexturesDirty", "emissionColor")
|
|
2727
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2728
|
+
], r.prototype, "_emissionColor", void 0);
|
|
2729
|
+
o([
|
|
2730
|
+
d("_markAllSubMeshesAsTexturesDirty", "emissionColorTexture")
|
|
2731
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2732
|
+
], r.prototype, "_emissionColorTexture", void 0);
|
|
2733
|
+
o([
|
|
2734
|
+
d("_markAllSubMeshesAsTexturesDirty", "thinFilmWeight")
|
|
2735
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2736
|
+
], r.prototype, "_thinFilmWeight", void 0);
|
|
2737
|
+
o([
|
|
2738
|
+
d("_markAllSubMeshesAsTexturesDirty", "thinFilmWeightTexture")
|
|
2739
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2740
|
+
], r.prototype, "_thinFilmWeightTexture", void 0);
|
|
2741
|
+
o([
|
|
2742
|
+
d("_markAllSubMeshesAsTexturesDirty", "thinFilmThickness")
|
|
2743
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2744
|
+
], r.prototype, "_thinFilmThickness", void 0);
|
|
2745
|
+
o([
|
|
2746
|
+
d("_markAllSubMeshesAsTexturesDirty", "thinFilmThicknessMin")
|
|
2747
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2748
|
+
], r.prototype, "_thinFilmThicknessMin", void 0);
|
|
2749
|
+
o([
|
|
2750
|
+
d("_markAllSubMeshesAsTexturesDirty", "thinFilmThicknessTexture")
|
|
2751
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2752
|
+
], r.prototype, "_thinFilmThicknessTexture", void 0);
|
|
2753
|
+
o([
|
|
2754
|
+
d("_markAllSubMeshesAsTexturesDirty", "thinFilmIor")
|
|
2755
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2756
|
+
], r.prototype, "_thinFilmIor", void 0);
|
|
2757
|
+
o([
|
|
2758
|
+
d("_markAllSubMeshesAsTexturesDirty", "ambientOcclusionTexture")
|
|
2759
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2760
|
+
], r.prototype, "_ambientOcclusionTexture", void 0);
|
|
2761
|
+
o([
|
|
2762
|
+
D(),
|
|
2763
|
+
P("_markAllSubMeshesAsTexturesDirty")
|
|
2764
|
+
], r.prototype, "directIntensity", void 0);
|
|
2765
|
+
o([
|
|
2766
|
+
D(),
|
|
2767
|
+
P("_markAllSubMeshesAsTexturesDirty")
|
|
2768
|
+
], r.prototype, "environmentIntensity", void 0);
|
|
2769
|
+
o([
|
|
2770
|
+
D(),
|
|
2771
|
+
P("_markAllSubMeshesAsTexturesDirty")
|
|
2772
|
+
], r.prototype, "useSpecularWeightFromTextureAlpha", void 0);
|
|
2773
|
+
o([
|
|
2774
|
+
D(),
|
|
2775
|
+
P("_markAllSubMeshesAsTexturesAndMiscDirty")
|
|
2776
|
+
], r.prototype, "forceAlphaTest", void 0);
|
|
2777
|
+
o([
|
|
2778
|
+
D(),
|
|
2779
|
+
P("_markAllSubMeshesAsTexturesAndMiscDirty")
|
|
2780
|
+
], r.prototype, "alphaCutOff", void 0);
|
|
2781
|
+
o([
|
|
2782
|
+
D(),
|
|
2783
|
+
P("_markAllSubMeshesAsTexturesDirty")
|
|
2784
|
+
], r.prototype, "useAmbientOcclusionFromMetallicTextureRed", void 0);
|
|
2785
|
+
o([
|
|
2786
|
+
D(),
|
|
2787
|
+
P("_markAllSubMeshesAsTexturesDirty")
|
|
2788
|
+
], r.prototype, "useAmbientInGrayScale", void 0);
|
|
2789
|
+
o([
|
|
2790
|
+
D()
|
|
2791
|
+
], r.prototype, "usePhysicalLightFalloff", null);
|
|
2792
|
+
o([
|
|
2793
|
+
D()
|
|
2794
|
+
], r.prototype, "useGLTFLightFalloff", null);
|
|
2795
|
+
o([
|
|
2796
|
+
D(),
|
|
2797
|
+
P("_markAllSubMeshesAsTexturesDirty")
|
|
2798
|
+
], r.prototype, "useObjectSpaceNormalMap", void 0);
|
|
2799
|
+
o([
|
|
2800
|
+
D(),
|
|
2801
|
+
P("_markAllSubMeshesAsTexturesDirty")
|
|
2802
|
+
], r.prototype, "useParallax", void 0);
|
|
2803
|
+
o([
|
|
2804
|
+
D(),
|
|
2805
|
+
P("_markAllSubMeshesAsTexturesDirty")
|
|
2806
|
+
], r.prototype, "useParallaxOcclusion", void 0);
|
|
2807
|
+
o([
|
|
2808
|
+
D(),
|
|
2809
|
+
P("_markAllSubMeshesAsTexturesDirty")
|
|
2810
|
+
], r.prototype, "parallaxScaleBias", void 0);
|
|
2811
|
+
o([
|
|
2812
|
+
D(),
|
|
2813
|
+
P("_markAllSubMeshesAsLightsDirty")
|
|
2814
|
+
], r.prototype, "disableLighting", void 0);
|
|
2815
|
+
o([
|
|
2816
|
+
D(),
|
|
2817
|
+
P("_markAllSubMeshesAsTexturesDirty")
|
|
2818
|
+
], r.prototype, "forceIrradianceInFragment", void 0);
|
|
2819
|
+
o([
|
|
2820
|
+
D(),
|
|
2821
|
+
P("_markAllSubMeshesAsLightsDirty")
|
|
2822
|
+
], r.prototype, "maxSimultaneousLights", void 0);
|
|
2823
|
+
o([
|
|
2824
|
+
D(),
|
|
2825
|
+
P("_markAllSubMeshesAsTexturesDirty")
|
|
2826
|
+
], r.prototype, "invertNormalMapX", void 0);
|
|
2827
|
+
o([
|
|
2828
|
+
D(),
|
|
2829
|
+
P("_markAllSubMeshesAsTexturesDirty")
|
|
2830
|
+
], r.prototype, "invertNormalMapY", void 0);
|
|
2831
|
+
o([
|
|
2832
|
+
D(),
|
|
2833
|
+
P("_markAllSubMeshesAsTexturesDirty")
|
|
2834
|
+
], r.prototype, "twoSidedLighting", void 0);
|
|
2835
|
+
o([
|
|
2836
|
+
D(),
|
|
2837
|
+
P("_markAllSubMeshesAsTexturesDirty")
|
|
2838
|
+
], r.prototype, "useAlphaFresnel", void 0);
|
|
2839
|
+
o([
|
|
2840
|
+
D(),
|
|
2841
|
+
P("_markAllSubMeshesAsTexturesDirty")
|
|
2842
|
+
], r.prototype, "useLinearAlphaFresnel", void 0);
|
|
2843
|
+
o([
|
|
2844
|
+
P("_markAllSubMeshesAsTexturesDirty")
|
|
2845
|
+
], r.prototype, "environmentBRDFTexture", void 0);
|
|
2846
|
+
o([
|
|
2847
|
+
D(),
|
|
2848
|
+
P("_markAllSubMeshesAsTexturesDirty")
|
|
2849
|
+
], r.prototype, "forceNormalForward", void 0);
|
|
2850
|
+
o([
|
|
2851
|
+
D(),
|
|
2852
|
+
P("_markAllSubMeshesAsTexturesDirty")
|
|
2853
|
+
], r.prototype, "enableSpecularAntiAliasing", void 0);
|
|
2854
|
+
o([
|
|
2855
|
+
D(),
|
|
2856
|
+
P("_markAllSubMeshesAsTexturesDirty")
|
|
2857
|
+
], r.prototype, "useHorizonOcclusion", void 0);
|
|
2858
|
+
o([
|
|
2859
|
+
D(),
|
|
2860
|
+
P("_markAllSubMeshesAsTexturesDirty")
|
|
2861
|
+
], r.prototype, "useRadianceOcclusion", void 0);
|
|
2862
|
+
o([
|
|
2863
|
+
D(),
|
|
2864
|
+
P("_markAllSubMeshesAsMiscDirty")
|
|
2865
|
+
], r.prototype, "unlit", void 0);
|
|
2866
|
+
o([
|
|
2867
|
+
D(),
|
|
2868
|
+
P("_markAllSubMeshesAsMiscDirty")
|
|
2869
|
+
], r.prototype, "applyDecalMapAfterDetailMap", void 0);
|
|
2870
|
+
o([
|
|
2871
|
+
P("_markAllSubMeshesAsMiscDirty")
|
|
2872
|
+
], r.prototype, "debugMode", void 0);
|
|
2873
|
+
o([
|
|
2874
|
+
D()
|
|
2875
|
+
], r.prototype, "transparencyMode", null);
|
|
2876
|
+
Nt("BABYLON.OpenPBRMaterial", r);
|
|
2877
|
+
export {
|
|
2878
|
+
r as OpenPBRMaterial,
|
|
2879
|
+
ye as OpenPBRMaterialDefines
|
|
2880
|
+
};
|