@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,1553 @@
|
|
|
1
|
+
import { b0 as e } from "./index-CS3Icp_r.js";
|
|
2
|
+
import "./oitFragment-B8zuQigp.js";
|
|
3
|
+
import "./openpbrMaterial-HCU0aOca.js";
|
|
4
|
+
import "./openpbrUboDeclaration-xU8VOaib.js";
|
|
5
|
+
import "./pbrDebug-Cdalzb1I.js";
|
|
6
|
+
import "./bumpFragment-KE1_PuMl.js";
|
|
7
|
+
import "./pbrIBLFunctions-C06z-ouZ.js";
|
|
8
|
+
import "./logDepthDeclaration-gUfeSnXX.js";
|
|
9
|
+
import "./helperFunctions-CPmRxd37.js";
|
|
10
|
+
import "./harmonicsFunctions-CtNrRfir.js";
|
|
11
|
+
const o = "openpbrFragmentDeclaration", S = `uniform float vBaseWeight;uniform vec4 vBaseColor;uniform float vBaseDiffuseRoughness;uniform vec4 vReflectanceInfo;uniform vec4 vSpecularColor;uniform vec3 vSpecularAnisotropy;uniform float vTransmissionWeight;uniform vec3 vTransmissionColor;uniform float vTransmissionDepth;uniform vec3 vTransmissionScatter;uniform float vTransmissionScatterAnisotropy;uniform float vTransmissionDispersionScale;uniform float vTransmissionDispersionAbbeNumber;uniform float vSubsurfaceWeight;uniform vec3 vSubsurfaceColor;uniform float vSubsurfaceRadius;uniform vec3 vSubsurfaceRadiusScale;uniform float vSubsurfaceScatterAnisotropy;uniform float vCoatWeight;uniform vec3 vCoatColor;uniform float vCoatRoughness;uniform float vCoatRoughnessAnisotropy;uniform float vCoatIor;uniform float vCoatDarkening;uniform float vFuzzWeight;uniform vec3 vFuzzColor;uniform float vFuzzRoughness;uniform vec2 vGeometryCoatTangent;uniform float vGeometryThickness;uniform vec3 vEmissionColor;uniform float vThinFilmWeight;uniform vec2 vThinFilmThickness;uniform float vThinFilmIor;uniform float vGeometryThinWalled;uniform vec4 vLightingIntensity;uniform float visibility;uniform vec2 renderTargetSize;
|
|
12
|
+
#ifdef BASE_COLOR
|
|
13
|
+
uniform vec2 vBaseColorInfos;
|
|
14
|
+
#endif
|
|
15
|
+
#ifdef BASE_WEIGHT
|
|
16
|
+
uniform vec2 vBaseWeightInfos;
|
|
17
|
+
#endif
|
|
18
|
+
#ifdef BASE_METALNESS
|
|
19
|
+
uniform vec2 vBaseMetalnessInfos;
|
|
20
|
+
#endif
|
|
21
|
+
#ifdef BASE_DIFFUSE_ROUGHNESS
|
|
22
|
+
uniform vec2 vBaseDiffuseRoughnessInfos;
|
|
23
|
+
#endif
|
|
24
|
+
#ifdef SPECULAR_WEIGHT
|
|
25
|
+
uniform vec2 vSpecularWeightInfos;
|
|
26
|
+
#endif
|
|
27
|
+
#ifdef SPECULAR_COLOR
|
|
28
|
+
uniform vec2 vSpecularColorInfos;
|
|
29
|
+
#endif
|
|
30
|
+
#ifdef SPECULAR_ROUGHNESS
|
|
31
|
+
uniform vec2 vSpecularRoughnessInfos;
|
|
32
|
+
#endif
|
|
33
|
+
#ifdef SPECULAR_ROUGHNESS_ANISOTROPY
|
|
34
|
+
uniform vec2 vSpecularRoughnessAnisotropyInfos;
|
|
35
|
+
#endif
|
|
36
|
+
#ifdef SPECULAR_IOR
|
|
37
|
+
uniform vec2 vSpecularIorInfos;
|
|
38
|
+
#endif
|
|
39
|
+
#ifdef AMBIENT_OCCLUSION
|
|
40
|
+
uniform vec2 vAmbientOcclusionInfos;
|
|
41
|
+
#endif
|
|
42
|
+
#ifdef GEOMETRY_NORMAL
|
|
43
|
+
uniform vec2 vGeometryNormalInfos;
|
|
44
|
+
#endif
|
|
45
|
+
#ifdef GEOMETRY_TANGENT
|
|
46
|
+
uniform vec2 vGeometryTangentInfos;
|
|
47
|
+
#endif
|
|
48
|
+
#if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL)
|
|
49
|
+
uniform vec2 vTangentSpaceParams;
|
|
50
|
+
#endif
|
|
51
|
+
#ifdef GEOMETRY_COAT_NORMAL
|
|
52
|
+
uniform vec2 vGeometryCoatNormalInfos;
|
|
53
|
+
#endif
|
|
54
|
+
#ifdef GEOMETRY_OPACITY
|
|
55
|
+
uniform vec2 vGeometryOpacityInfos;
|
|
56
|
+
#endif
|
|
57
|
+
#ifdef GEOMETRY_THICKNESS
|
|
58
|
+
uniform vec2 vGeometryThicknessInfos;
|
|
59
|
+
#endif
|
|
60
|
+
#ifdef EMISSION_COLOR
|
|
61
|
+
uniform vec2 vEmissionColorInfos;
|
|
62
|
+
#endif
|
|
63
|
+
#ifdef TRANSMISSION_WEIGHT
|
|
64
|
+
uniform vec2 vTransmissionWeightInfos;
|
|
65
|
+
#endif
|
|
66
|
+
#ifdef TRANSMISSION_COLOR
|
|
67
|
+
uniform vec2 vTransmissionColorInfos;
|
|
68
|
+
#endif
|
|
69
|
+
#ifdef TRANSMISSION_DEPTH
|
|
70
|
+
uniform vec2 vTransmissionDepthInfos;
|
|
71
|
+
#endif
|
|
72
|
+
#ifdef TRANSMISSION_SCATTER
|
|
73
|
+
uniform vec2 vTransmissionScatterInfos;
|
|
74
|
+
#endif
|
|
75
|
+
#ifdef TRANSMISSION_DISPERSION_SCALE
|
|
76
|
+
uniform vec2 vTransmissionDispersionScaleInfos;
|
|
77
|
+
#endif
|
|
78
|
+
#ifdef SUBSURFACE_WEIGHT
|
|
79
|
+
uniform vec2 vSubsurfaceWeightInfos;
|
|
80
|
+
#endif
|
|
81
|
+
#ifdef SUBSURFACE_COLOR
|
|
82
|
+
uniform vec2 vSubsurfaceColorInfos;
|
|
83
|
+
#endif
|
|
84
|
+
#ifdef SUBSURFACE_RADIUS_SCALE
|
|
85
|
+
uniform vec2 vSubsurfaceRadiusScaleInfos;
|
|
86
|
+
#endif
|
|
87
|
+
#ifdef COAT_WEIGHT
|
|
88
|
+
uniform vec2 vCoatWeightInfos;
|
|
89
|
+
#endif
|
|
90
|
+
#ifdef COAT_COLOR
|
|
91
|
+
uniform vec2 vCoatColorInfos;
|
|
92
|
+
#endif
|
|
93
|
+
#ifdef COAT_ROUGHNESS
|
|
94
|
+
uniform vec2 vCoatRoughnessInfos;
|
|
95
|
+
#endif
|
|
96
|
+
#ifdef COAT_ROUGHNESS_ANISOTROPY
|
|
97
|
+
uniform vec2 vCoatRoughnessAnisotropyInfos;
|
|
98
|
+
#endif
|
|
99
|
+
#ifdef COAT_IOR
|
|
100
|
+
uniform vec2 vCoatIorInfos;
|
|
101
|
+
#endif
|
|
102
|
+
#ifdef COAT_DARKENING
|
|
103
|
+
uniform vec2 vCoatDarkeningInfos;
|
|
104
|
+
#endif
|
|
105
|
+
#ifdef FUZZ_WEIGHT
|
|
106
|
+
uniform vec2 vFuzzWeightInfos;
|
|
107
|
+
#endif
|
|
108
|
+
#ifdef FUZZ_COLOR
|
|
109
|
+
uniform vec2 vFuzzColorInfos;
|
|
110
|
+
#endif
|
|
111
|
+
#ifdef FUZZ_ROUGHNESS
|
|
112
|
+
uniform vec2 vFuzzRoughnessInfos;
|
|
113
|
+
#endif
|
|
114
|
+
#ifdef GEOMETRY_COAT_TANGENT
|
|
115
|
+
uniform vec2 vGeometryCoatTangentInfos;
|
|
116
|
+
#endif
|
|
117
|
+
#ifdef THIN_FILM_WEIGHT
|
|
118
|
+
uniform vec2 vThinFilmWeightInfos;
|
|
119
|
+
#endif
|
|
120
|
+
#ifdef THIN_FILM_THICKNESS
|
|
121
|
+
uniform vec2 vThinFilmThicknessInfos;
|
|
122
|
+
#endif
|
|
123
|
+
#include<sceneFragmentDeclaration>
|
|
124
|
+
#ifdef REFLECTION
|
|
125
|
+
uniform vec2 vReflectionInfos;
|
|
126
|
+
#ifdef REALTIME_FILTERING
|
|
127
|
+
uniform vec2 vReflectionFilteringInfo;
|
|
128
|
+
#endif
|
|
129
|
+
uniform mat4 reflectionMatrix;uniform vec3 vReflectionMicrosurfaceInfos;
|
|
130
|
+
#if defined(USEIRRADIANCEMAP) && defined(USE_IRRADIANCE_DOMINANT_DIRECTION)
|
|
131
|
+
uniform vec3 vReflectionDominantDirection;
|
|
132
|
+
#endif
|
|
133
|
+
#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)
|
|
134
|
+
uniform vec3 vReflectionPosition;uniform vec3 vReflectionSize;
|
|
135
|
+
#endif
|
|
136
|
+
#endif
|
|
137
|
+
#ifdef PREPASS
|
|
138
|
+
#ifdef SS_SCATTERING
|
|
139
|
+
uniform float scatteringDiffusionProfile;
|
|
140
|
+
#endif
|
|
141
|
+
#endif
|
|
142
|
+
#if DEBUGMODE>0
|
|
143
|
+
uniform vec2 vDebugMode;
|
|
144
|
+
#endif
|
|
145
|
+
#ifdef DETAIL
|
|
146
|
+
uniform vec4 vDetailInfos;
|
|
147
|
+
#endif
|
|
148
|
+
#include<decalFragmentDeclaration>
|
|
149
|
+
#ifdef USESPHERICALFROMREFLECTIONMAP
|
|
150
|
+
#ifdef SPHERICAL_HARMONICS
|
|
151
|
+
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;
|
|
152
|
+
#else
|
|
153
|
+
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;
|
|
154
|
+
#endif
|
|
155
|
+
#endif
|
|
156
|
+
#ifdef REFRACTED_BACKGROUND
|
|
157
|
+
uniform mat4 backgroundRefractionMatrix;uniform vec3 vBackgroundRefractionInfos;
|
|
158
|
+
#endif
|
|
159
|
+
#if TEXTURE_REPETITION_MODE>0
|
|
160
|
+
uniform vec4 vTextureRepetitionHexTilingParams;
|
|
161
|
+
#endif
|
|
162
|
+
#define ADDITIONAL_FRAGMENT_DECLARATION
|
|
163
|
+
`;
|
|
164
|
+
e.IncludesShadersStore[o] || (e.IncludesShadersStore[o] = S);
|
|
165
|
+
const t = "openpbrFragmentSamplersDeclaration", T = `#include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_COLOR,_VARYINGNAME_,BaseColor,_SAMPLERNAME_,baseColor)
|
|
166
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_WEIGHT,_VARYINGNAME_,BaseWeight,_SAMPLERNAME_,baseWeight)
|
|
167
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_DIFFUSE_ROUGHNESS,_VARYINGNAME_,BaseDiffuseRoughness,_SAMPLERNAME_,baseDiffuseRoughness)
|
|
168
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,BASE_METALNESS,_VARYINGNAME_,BaseMetalness,_SAMPLERNAME_,baseMetalness)
|
|
169
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_WEIGHT,_VARYINGNAME_,SpecularWeight,_SAMPLERNAME_,specularWeight)
|
|
170
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_COLOR,_VARYINGNAME_,SpecularColor,_SAMPLERNAME_,specularColor)
|
|
171
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_ROUGHNESS,_VARYINGNAME_,SpecularRoughness,_SAMPLERNAME_,specularRoughness)
|
|
172
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR_ROUGHNESS_ANISOTROPY,_VARYINGNAME_,SpecularRoughnessAnisotropy,_SAMPLERNAME_,specularRoughnessAnisotropy)
|
|
173
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,TRANSMISSION_WEIGHT,_VARYINGNAME_,TransmissionWeight,_SAMPLERNAME_,transmissionWeight)
|
|
174
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,TRANSMISSION_COLOR,_VARYINGNAME_,TransmissionColor,_SAMPLERNAME_,transmissionColor)
|
|
175
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,TRANSMISSION_DEPTH,_VARYINGNAME_,TransmissionDepth,_SAMPLERNAME_,transmissionDepth)
|
|
176
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,TRANSMISSION_SCATTER,_VARYINGNAME_,TransmissionScatter,_SAMPLERNAME_,transmissionScatter)
|
|
177
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,TRANSMISSION_DISPERSION_SCALE,_VARYINGNAME_,TransmissionDispersionScale,_SAMPLERNAME_,transmissionDispersionScale)
|
|
178
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,SUBSURFACE_WEIGHT,_VARYINGNAME_,SubsurfaceWeight,_SAMPLERNAME_,subsurfaceWeight)
|
|
179
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,SUBSURFACE_COLOR,_VARYINGNAME_,SubsurfaceColor,_SAMPLERNAME_,subsurfaceColor)
|
|
180
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,SUBSURFACE_RADIUS_SCALE,_VARYINGNAME_,SubsurfaceRadiusScale,_SAMPLERNAME_,subsurfaceRadiusScale)
|
|
181
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_WEIGHT,_VARYINGNAME_,CoatWeight,_SAMPLERNAME_,coatWeight)
|
|
182
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_COLOR,_VARYINGNAME_,CoatColor,_SAMPLERNAME_,coatColor)
|
|
183
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_ROUGHNESS,_VARYINGNAME_,CoatRoughness,_SAMPLERNAME_,coatRoughness)
|
|
184
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_ROUGHNESS_ANISOTROPY,_VARYINGNAME_,CoatRoughnessAnisotropy,_SAMPLERNAME_,coatRoughnessAnisotropy)
|
|
185
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,COAT_DARKENING,_VARYINGNAME_,CoatDarkening,_SAMPLERNAME_,coatDarkening)
|
|
186
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,FUZZ_WEIGHT,_VARYINGNAME_,FuzzWeight,_SAMPLERNAME_,fuzzWeight)
|
|
187
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,FUZZ_COLOR,_VARYINGNAME_,FuzzColor,_SAMPLERNAME_,fuzzColor)
|
|
188
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,FUZZ_ROUGHNESS,_VARYINGNAME_,FuzzRoughness,_SAMPLERNAME_,fuzzRoughness)
|
|
189
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_OPACITY,_VARYINGNAME_,GeometryOpacity,_SAMPLERNAME_,geometryOpacity)
|
|
190
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_TANGENT,_VARYINGNAME_,GeometryTangent,_SAMPLERNAME_,geometryTangent)
|
|
191
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_COAT_TANGENT,_VARYINGNAME_,GeometryCoatTangent,_SAMPLERNAME_,geometryCoatTangent)
|
|
192
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_THICKNESS,_VARYINGNAME_,GeometryThickness,_SAMPLERNAME_,geometryThickness)
|
|
193
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSION_COLOR,_VARYINGNAME_,EmissionColor,_SAMPLERNAME_,emissionColor)
|
|
194
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,THIN_FILM_WEIGHT,_VARYINGNAME_,ThinFilmWeight,_SAMPLERNAME_,thinFilmWeight)
|
|
195
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,THIN_FILM_THICKNESS,_VARYINGNAME_,ThinFilmThickness,_SAMPLERNAME_,thinFilmThickness)
|
|
196
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT_OCCLUSION,_VARYINGNAME_,AmbientOcclusion,_SAMPLERNAME_,ambientOcclusion)
|
|
197
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal)
|
|
198
|
+
#include<pbrFragmentReflectionDeclaration>
|
|
199
|
+
#ifdef ENVIRONMENTBRDF
|
|
200
|
+
uniform sampler2D environmentBrdfSampler;
|
|
201
|
+
#endif
|
|
202
|
+
#ifdef FUZZENVIRONMENTBRDF
|
|
203
|
+
uniform sampler2D environmentFuzzBrdfSampler;
|
|
204
|
+
#endif
|
|
205
|
+
#ifdef REFRACTED_BACKGROUND
|
|
206
|
+
uniform sampler2D backgroundRefractionSampler;
|
|
207
|
+
#endif
|
|
208
|
+
#ifdef USE_IRRADIANCE_TEXTURE_FOR_SCATTERING
|
|
209
|
+
uniform sampler2D sceneIrradianceSampler;uniform sampler2D sceneDepthSampler;
|
|
210
|
+
#endif
|
|
211
|
+
#if defined(ANISOTROPIC) || defined(FUZZ) || defined(REFRACTED_BACKGROUND) || defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING)
|
|
212
|
+
uniform sampler2D blueNoiseSampler;
|
|
213
|
+
#endif
|
|
214
|
+
#ifdef IBL_CDF_FILTERING
|
|
215
|
+
uniform sampler2D icdfSampler;
|
|
216
|
+
#endif
|
|
217
|
+
`;
|
|
218
|
+
e.IncludesShadersStore[t] || (e.IncludesShadersStore[t] = T);
|
|
219
|
+
const r = "openpbrNormalMapFragmentMainFunctions", A = `#if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL) || defined(ANISOTROPIC) || defined(FUZZ) || defined(DETAIL)
|
|
220
|
+
#if defined(TANGENT) && defined(NORMAL)
|
|
221
|
+
varying mat3 vTBN;
|
|
222
|
+
#endif
|
|
223
|
+
#ifdef OBJECTSPACE_NORMALMAP
|
|
224
|
+
uniform mat4 normalMatrix;
|
|
225
|
+
#if defined(WEBGL2) || defined(WEBGPU)
|
|
226
|
+
mat4 toNormalMatrix(mat4 wMatrix)
|
|
227
|
+
{mat4 ret=inverse(wMatrix);ret=transpose(ret);ret[0][3]=0.;ret[1][3]=0.;ret[2][3]=0.;ret[3]=vec4(0.,0.,0.,1.);return ret;}
|
|
228
|
+
#else
|
|
229
|
+
mat4 toNormalMatrix(mat4 m)
|
|
230
|
+
{float
|
|
231
|
+
a00=m[0][0],a01=m[0][1],a02=m[0][2],a03=m[0][3],
|
|
232
|
+
a10=m[1][0],a11=m[1][1],a12=m[1][2],a13=m[1][3],
|
|
233
|
+
a20=m[2][0],a21=m[2][1],a22=m[2][2],a23=m[2][3],
|
|
234
|
+
a30=m[3][0],a31=m[3][1],a32=m[3][2],a33=m[3][3],
|
|
235
|
+
b00=a00*a11-a01*a10,
|
|
236
|
+
b01=a00*a12-a02*a10,
|
|
237
|
+
b02=a00*a13-a03*a10,
|
|
238
|
+
b03=a01*a12-a02*a11,
|
|
239
|
+
b04=a01*a13-a03*a11,
|
|
240
|
+
b05=a02*a13-a03*a12,
|
|
241
|
+
b06=a20*a31-a21*a30,
|
|
242
|
+
b07=a20*a32-a22*a30,
|
|
243
|
+
b08=a20*a33-a23*a30,
|
|
244
|
+
b09=a21*a32-a22*a31,
|
|
245
|
+
b10=a21*a33-a23*a31,
|
|
246
|
+
b11=a22*a33-a23*a32,
|
|
247
|
+
det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;mat4 mi=mat4(
|
|
248
|
+
a11*b11-a12*b10+a13*b09,
|
|
249
|
+
a02*b10-a01*b11-a03*b09,
|
|
250
|
+
a31*b05-a32*b04+a33*b03,
|
|
251
|
+
a22*b04-a21*b05-a23*b03,
|
|
252
|
+
a12*b08-a10*b11-a13*b07,
|
|
253
|
+
a00*b11-a02*b08+a03*b07,
|
|
254
|
+
a32*b02-a30*b05-a33*b01,
|
|
255
|
+
a20*b05-a22*b02+a23*b01,
|
|
256
|
+
a10*b10-a11*b08+a13*b06,
|
|
257
|
+
a01*b08-a00*b10-a03*b06,
|
|
258
|
+
a30*b04-a31*b02+a33*b00,
|
|
259
|
+
a21*b02-a20*b04-a23*b00,
|
|
260
|
+
a11*b07-a10*b09-a12*b06,
|
|
261
|
+
a00*b09-a01*b07+a02*b06,
|
|
262
|
+
a31*b01-a30*b03-a32*b00,
|
|
263
|
+
a20*b03-a21*b01+a22*b00)/det;return mat4(mi[0][0],mi[1][0],mi[2][0],mi[3][0],
|
|
264
|
+
mi[0][1],mi[1][1],mi[2][1],mi[3][1],
|
|
265
|
+
mi[0][2],mi[1][2],mi[2][2],mi[3][2],
|
|
266
|
+
mi[0][3],mi[1][3],mi[2][3],mi[3][3]);}
|
|
267
|
+
#endif
|
|
268
|
+
#endif
|
|
269
|
+
vec3 perturbNormalBase(mat3 cotangentFrame,vec3 normal,float scale)
|
|
270
|
+
{
|
|
271
|
+
#ifdef NORMALXYSCALE
|
|
272
|
+
normal=normalize(normal*vec3(scale,scale,1.0));
|
|
273
|
+
#endif
|
|
274
|
+
return normalize(cotangentFrame*normal);}
|
|
275
|
+
vec3 perturbNormal(mat3 cotangentFrame,vec3 textureSample,float scale)
|
|
276
|
+
{return perturbNormalBase(cotangentFrame,textureSample*2.0-1.0,scale);}
|
|
277
|
+
mat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv,vec2 tangentSpaceParams)
|
|
278
|
+
{vec3 dp1=dFdx(p);vec3 dp2=dFdy(p);vec2 duv1=dFdx(uv);vec2 duv2=dFdy(uv);vec3 dp2perp=cross(dp2,normal);vec3 dp1perp=cross(normal,dp1);vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;vec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;tangent*=tangentSpaceParams.x;bitangent*=tangentSpaceParams.y;float det=max(dot(tangent,tangent),dot(bitangent,bitangent));float invmax=det==0.0 ? 0.0 : inversesqrt(det);return mat3(tangent*invmax,bitangent*invmax,normal);}
|
|
279
|
+
#endif
|
|
280
|
+
`;
|
|
281
|
+
e.IncludesShadersStore[r] || (e.IncludesShadersStore[r] = A);
|
|
282
|
+
const a = "openpbrNormalMapFragmentFunctions", N = `#if defined(GEOMETRY_NORMAL)
|
|
283
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_NORMAL,_VARYINGNAME_,GeometryNormal,_SAMPLERNAME_,geometryNormal)
|
|
284
|
+
#endif
|
|
285
|
+
#if defined(GEOMETRY_COAT_NORMAL)
|
|
286
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,GEOMETRY_COAT_NORMAL,_VARYINGNAME_,GeometryCoatNormal,_SAMPLERNAME_,geometryCoatNormal)
|
|
287
|
+
#endif
|
|
288
|
+
#if defined(DETAIL)
|
|
289
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_SAMPLERNAME_,detail)
|
|
290
|
+
#endif
|
|
291
|
+
#if defined(GEOMETRY_NORMAL) && defined(PARALLAX)
|
|
292
|
+
const float minSamples=4.;const float maxSamples=15.;const int iMaxSamples=15;vec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {float parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;parallaxLimit*=parallaxScale;vec2 vOffsetDir=normalize(vViewDirCoT.xy);vec2 vMaxOffset=vOffsetDir*parallaxLimit;float numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));float stepSize=1.0/numSamples;float currRayHeight=1.0;vec2 vCurrOffset=vec2(0,0);vec2 vLastOffset=vec2(0,0);float lastSampledHeight=1.0;float currSampledHeight=1.0;bool keepWorking=true;for (int i=0; i<iMaxSamples; i++)
|
|
293
|
+
{currSampledHeight=texture2D(geometryNormalSampler,texCoord+vCurrOffset).w;if (!keepWorking)
|
|
294
|
+
{}
|
|
295
|
+
else if (currSampledHeight>currRayHeight)
|
|
296
|
+
{float delta1=currSampledHeight-currRayHeight;float delta2=(currRayHeight+stepSize)-lastSampledHeight;float ratio=delta1/(delta1+delta2);vCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;keepWorking=false;}
|
|
297
|
+
else
|
|
298
|
+
{currRayHeight-=stepSize;vLastOffset=vCurrOffset;
|
|
299
|
+
#ifdef PARALLAX_RHS
|
|
300
|
+
vCurrOffset-=stepSize*vMaxOffset;
|
|
301
|
+
#else
|
|
302
|
+
vCurrOffset+=stepSize*vMaxOffset;
|
|
303
|
+
#endif
|
|
304
|
+
lastSampledHeight=currSampledHeight;}}
|
|
305
|
+
return vCurrOffset;}
|
|
306
|
+
vec2 parallaxOffset(vec3 viewDir,float heightScale)
|
|
307
|
+
{float height=texture2D(geometryNormalSampler,vGeometryNormalUV).w;vec2 texCoordOffset=heightScale*viewDir.xy*height;
|
|
308
|
+
#ifdef PARALLAX_RHS
|
|
309
|
+
return texCoordOffset;
|
|
310
|
+
#else
|
|
311
|
+
return -texCoordOffset;
|
|
312
|
+
#endif
|
|
313
|
+
}
|
|
314
|
+
#endif
|
|
315
|
+
`;
|
|
316
|
+
e.IncludesShadersStore[a] || (e.IncludesShadersStore[a] = N);
|
|
317
|
+
const n = "openpbrConductorReflectance", b = `#define pbr_inline
|
|
318
|
+
ReflectanceParams conductorReflectance(in vec3 baseColor,in vec3 specularColor,in float specularWeight)
|
|
319
|
+
{ReflectanceParams outParams;
|
|
320
|
+
#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR)
|
|
321
|
+
outParams.coloredF0=baseColor*specularWeight;outParams.coloredF90=specularColor*specularWeight;
|
|
322
|
+
#else
|
|
323
|
+
outParams.coloredF0=baseColor;outParams.coloredF90=vec3(1.0);
|
|
324
|
+
#endif
|
|
325
|
+
outParams.F0=1.0;outParams.F90=1.0;return outParams;}`;
|
|
326
|
+
e.IncludesShadersStore[n] || (e.IncludesShadersStore[n] = b);
|
|
327
|
+
const s = "openpbrAmbientOcclusionFunctions", L = `float compute_specular_occlusion(const float n_dot_v,const float metallic,const float ambient_occlusion,const float roughness)
|
|
328
|
+
{float specular_occlusion=saturate(pow(n_dot_v+ambient_occlusion,exp2(-16.0*roughness-1.0))-1.0+ambient_occlusion);return mix(specular_occlusion,1.0,metallic*square(1.0-roughness));}
|
|
329
|
+
`;
|
|
330
|
+
e.IncludesShadersStore[s] || (e.IncludesShadersStore[s] = L);
|
|
331
|
+
const c = "openpbrVolumeFunctions", F = `struct OpenPBRHomogeneousVolume {vec3 extinction_coeff;
|
|
332
|
+
vec3 ss_albedo;
|
|
333
|
+
vec3 multi_scatter_color;
|
|
334
|
+
vec3 absorption_coeff;
|
|
335
|
+
vec3 scatter_coeff;
|
|
336
|
+
float anisotropy; };OpenPBRHomogeneousVolume computeOpenPBRTransmissionVolume(
|
|
337
|
+
in vec3 transmission_color,
|
|
338
|
+
in float transmission_depth,
|
|
339
|
+
in vec3 transmission_scatter,
|
|
340
|
+
in float anisotropy
|
|
341
|
+
)
|
|
342
|
+
{OpenPBRHomogeneousVolume volumeParams;volumeParams.absorption_coeff=vec3(0.0);volumeParams.scatter_coeff=vec3(0.0);volumeParams.anisotropy=anisotropy;
|
|
343
|
+
#ifdef GEOMETRY_THIN_WALLED
|
|
344
|
+
volumeParams.scatter_coeff=vec3(1.0);volumeParams.anisotropy=1.0;
|
|
345
|
+
volumeParams.extinction_coeff=volumeParams.absorption_coeff+volumeParams.scatter_coeff;volumeParams.ss_albedo=vec3(1.0);
|
|
346
|
+
#else
|
|
347
|
+
if (transmission_depth>0.0) {vec3 invDepth=vec3(1./maxEps(transmission_depth));volumeParams.extinction_coeff=-log(maxEps(transmission_color.rgb))*invDepth;volumeParams.scatter_coeff=transmission_scatter.rgb*invDepth;volumeParams.absorption_coeff=volumeParams.extinction_coeff-volumeParams.scatter_coeff.rgb;float minCoeff=min3(volumeParams.absorption_coeff);if (minCoeff<0.0) {volumeParams.absorption_coeff-=vec3(minCoeff);}
|
|
348
|
+
volumeParams.extinction_coeff=volumeParams.absorption_coeff+volumeParams.scatter_coeff;volumeParams.ss_albedo=volumeParams.scatter_coeff/(volumeParams.extinction_coeff);} else {volumeParams.extinction_coeff=volumeParams.absorption_coeff+volumeParams.scatter_coeff;volumeParams.ss_albedo=vec3(0.0);}
|
|
349
|
+
#endif
|
|
350
|
+
return volumeParams;}
|
|
351
|
+
OpenPBRHomogeneousVolume computeOpenPBRSubsurfaceVolume(
|
|
352
|
+
in vec3 subsurface_color,
|
|
353
|
+
in float subsurface_radius,
|
|
354
|
+
in vec3 subsurface_radius_scale,
|
|
355
|
+
in float anisotropy
|
|
356
|
+
)
|
|
357
|
+
{OpenPBRHomogeneousVolume volumeParams;volumeParams.absorption_coeff=vec3(0.0);volumeParams.scatter_coeff=vec3(0.0);volumeParams.anisotropy=anisotropy;volumeParams.multi_scatter_color=subsurface_color;vec3 mfp=subsurface_radius_scale*vec3(subsurface_radius);volumeParams.extinction_coeff=vec3(1.0)/maxEps(mfp);volumeParams.ss_albedo=multiScatterToSingleScatterAlbedo(subsurface_color,anisotropy);volumeParams.scatter_coeff=volumeParams.ss_albedo*volumeParams.extinction_coeff;volumeParams.absorption_coeff=volumeParams.extinction_coeff-volumeParams.scatter_coeff.rgb;float minCoeff=min3(volumeParams.absorption_coeff);if (minCoeff<0.0) {volumeParams.absorption_coeff-=vec3(minCoeff);}
|
|
358
|
+
volumeParams.extinction_coeff=volumeParams.absorption_coeff+volumeParams.scatter_coeff;return volumeParams;}
|
|
359
|
+
vec3 sss_pdf(float r,vec3 d)
|
|
360
|
+
{d=max(vec3(1e-4f),d);return (exp(-r/d)+exp(-r/(3.0f*d)))/max(vec3(1e-5f),8.0f*PI*d*r);}
|
|
361
|
+
float sss_samples_pdf(float r,float d)
|
|
362
|
+
{d=max(1e-4f,d);return exp(-r/(3.0f*d))/(6.0f*PI*d*r);}
|
|
363
|
+
float sss_samples_icdf(float x,float d)
|
|
364
|
+
{d=max(1e-4f,d);x=max(1e-4f,x);return -3.0f*log(x)*d;}
|
|
365
|
+
float samples_scale(float x,float d)
|
|
366
|
+
{return 1.0f-exp(-x/(3.0f*d));}
|
|
367
|
+
vec3 sss_get_position(sampler2D depth_texture,vec2 tex_coord,vec2 render_resolution,mat4 inv_proj)
|
|
368
|
+
{vec4 P=vec4(tex_coord,texelFetch(depth_texture,ivec2(tex_coord*render_resolution),0).x,1.0f);P.xy=2.0f*P.xy-1.0f;P=inv_proj*P;return P.xyz/P.w;}
|
|
369
|
+
float sss_filter_scale(float currZ,mat4 proj)
|
|
370
|
+
{return 1.0f/dot(vec2(proj[2].w,proj[3].w),vec2(currZ,1.0f));}
|
|
371
|
+
float projective_to_pixels(float proj_dist,mat4 proj,vec2 resolution)
|
|
372
|
+
{return proj_dist*proj[1][1]*resolution.y;}
|
|
373
|
+
float pixels_to_projective(float pixel_dist,mat4 proj,vec2 resolution)
|
|
374
|
+
{return pixel_dist/(proj[1][1]*resolution.y);}
|
|
375
|
+
vec3 sss_convolve(sampler2D sss_irradiance_texture,sampler2D depth_texture,vec2 render_resolution,vec3 d,mat4 proj,mat4 inv_proj,int sample_count,vec2 noise)
|
|
376
|
+
{vec2 tex_coord=gl_FragCoord.xy/render_resolution;vec3 unconvolved_irradiance=texelFetch(sss_irradiance_texture,ivec2(gl_FragCoord.xy),0).rgb;vec3 curr_pos=sss_get_position(depth_texture,tex_coord,render_resolution,inv_proj);float dmax=max3(d);float max_dmax=0.1*float(sample_count);if (dmax>max_dmax)
|
|
377
|
+
{d.rgb*=max_dmax/dmax;dmax=max_dmax;}
|
|
378
|
+
float dz=dmax*sss_filter_scale(curr_pos.z,proj);mat2 projMat2d=mat2(proj);if (determinant(projMat2d)*dz<1e-4f)
|
|
379
|
+
return unconvolved_irradiance;float overscan_size_in_pixels=max(render_resolution.x,render_resolution.y)*0.1;const float filter_crop_ratio=0.8f;
|
|
380
|
+
float crop_radius=projective_to_pixels(sss_samples_icdf(1.0f-filter_crop_ratio,dz),proj,render_resolution);if (crop_radius>overscan_size_in_pixels)
|
|
381
|
+
{d.rgb*=overscan_size_in_pixels/crop_radius;dz*=overscan_size_in_pixels/crop_radius;}
|
|
382
|
+
float filter_samples_scale=samples_scale(pixels_to_projective(overscan_size_in_pixels,proj,render_resolution),dz);vec3 irradiance_sum=vec3(0.0f);vec3 weight_sum=vec3(0.0f);for (int i=0; i<sample_count; i++)
|
|
383
|
+
{vec2 r=fract(plasticSequence(uint(i))+noise);r.x*=TWO_PI;r.y*=filter_samples_scale;float icdf=sss_samples_icdf(1.0-r.y,dz);vec2 sample_uv=tex_coord+icdf*projMat2d*vec2(cos(r.x),sin(r.x));vec4 sss_irradiance=texelFetch(sss_irradiance_texture,ivec2(sample_uv*render_resolution),0);float dist=distance(curr_pos,sss_get_position(depth_texture,sample_uv,render_resolution,inv_proj));if (dist>0.0f)
|
|
384
|
+
{vec3 weights=sss_irradiance.a/sss_samples_pdf(icdf,dz)*sss_pdf(dist,d.rgb);irradiance_sum+=weights*sss_irradiance.rgb;weight_sum+=weights;}}
|
|
385
|
+
return vec3(weight_sum.r<1e-5f ? unconvolved_irradiance.r : irradiance_sum.r/weight_sum.r,
|
|
386
|
+
weight_sum.g<1e-5f ? unconvolved_irradiance.g : irradiance_sum.g/weight_sum.g,
|
|
387
|
+
weight_sum.b<1e-5f ? unconvolved_irradiance.b : irradiance_sum.b/weight_sum.b);}`;
|
|
388
|
+
e.IncludesShadersStore[c] || (e.IncludesShadersStore[c] = F);
|
|
389
|
+
const f = "openpbrNormalMapFragment", O = `vec2 uvOffset=vec2(0.0,0.0);
|
|
390
|
+
#if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL) || defined(PARALLAX) || defined(DETAIL)
|
|
391
|
+
#ifdef NORMALXYSCALE
|
|
392
|
+
float normalScale=1.0;
|
|
393
|
+
#elif defined(GEOMETRY_NORMAL)
|
|
394
|
+
float normalScale=vGeometryNormalInfos.y;
|
|
395
|
+
#else
|
|
396
|
+
float normalScale=1.0;
|
|
397
|
+
#endif
|
|
398
|
+
#if defined(TANGENT) && defined(NORMAL)
|
|
399
|
+
mat3 TBN=vTBN;
|
|
400
|
+
#elif defined(GEOMETRY_NORMAL)
|
|
401
|
+
vec2 TBNUV=gl_FrontFacing ? vGeometryNormalUV : -vGeometryNormalUV;mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vTangentSpaceParams);
|
|
402
|
+
#elif defined(GEOMETRY_COAT_NORMAL)
|
|
403
|
+
vec2 TBNUV=gl_FrontFacing ? vGeometryCoatNormalUV : -vGeometryCoatNormalUV;mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vTangentSpaceParams);
|
|
404
|
+
#else
|
|
405
|
+
vec2 TBNUV=gl_FrontFacing ? vDetailUV : -vDetailUV;mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vec2(1.,1.));
|
|
406
|
+
#endif
|
|
407
|
+
#elif defined(ANISOTROPIC) || defined(FUZZ)
|
|
408
|
+
#if defined(TANGENT) && defined(NORMAL)
|
|
409
|
+
mat3 TBN=vTBN;
|
|
410
|
+
#else
|
|
411
|
+
vec2 TBNUV=gl_FrontFacing ? vMainUV1 : -vMainUV1;mat3 TBN=cotangent_frame(normalW,vPositionW,TBNUV,vec2(1.,1.));
|
|
412
|
+
#endif
|
|
413
|
+
#endif
|
|
414
|
+
#ifdef PARALLAX
|
|
415
|
+
mat3 invTBN=transposeMat3(TBN);
|
|
416
|
+
#ifdef PARALLAXOCCLUSION
|
|
417
|
+
#else
|
|
418
|
+
#endif
|
|
419
|
+
#endif
|
|
420
|
+
#ifdef DETAIL
|
|
421
|
+
vec4 detailColor=texture2D(detailSampler,vDetailUV+uvOffset);vec2 detailNormalRG=detailColor.wy*2.0-1.0;float detailNormalB=sqrt(1.-saturate(dot(detailNormalRG,detailNormalRG)));vec3 detailNormal=vec3(detailNormalRG,detailNormalB);
|
|
422
|
+
#endif
|
|
423
|
+
#ifdef GEOMETRY_COAT_NORMAL
|
|
424
|
+
coatNormalW=perturbNormal(TBN,TEXRD(geometryCoatNormalSampler,vGeometryCoatNormalUV+uvOffset).xyz,vGeometryCoatNormalInfos.y);
|
|
425
|
+
#endif
|
|
426
|
+
#ifdef GEOMETRY_NORMAL
|
|
427
|
+
#ifdef OBJECTSPACE_NORMALMAP
|
|
428
|
+
#define CUSTOM_FRAGMENT_BUMP_FRAGMENT
|
|
429
|
+
normalW=normalize(TEXRD(geometryNormalSampler,vGeometryNormalUV).xyz *2.0-1.0);normalW=normalize(mat3(normalMatrix)*normalW);
|
|
430
|
+
#elif !defined(DETAIL)
|
|
431
|
+
normalW=perturbNormal(TBN,TEXRD(geometryNormalSampler,vGeometryNormalUV+uvOffset).xyz,vGeometryNormalInfos.y);
|
|
432
|
+
#else
|
|
433
|
+
vec3 sampledNormal=TEXRD(geometryNormalSampler,vGeometryNormalUV+uvOffset).xyz*2.0-1.0;
|
|
434
|
+
#if DETAIL_NORMALBLENDMETHOD==0
|
|
435
|
+
detailNormal.xy*=vDetailInfos.z;vec3 blendedNormal=normalize(vec3(sampledNormal.xy+detailNormal.xy,sampledNormal.z*detailNormal.z));
|
|
436
|
+
#elif DETAIL_NORMALBLENDMETHOD==1
|
|
437
|
+
detailNormal.xy*=vDetailInfos.z;sampledNormal+=vec3(0.0,0.0,1.0);detailNormal*=vec3(-1.0,-1.0,1.0);vec3 blendedNormal=sampledNormal*dot(sampledNormal,detailNormal)/sampledNormal.z-detailNormal;
|
|
438
|
+
#endif
|
|
439
|
+
normalW=perturbNormalBase(TBN,blendedNormal,vGeometryNormalInfos.y);
|
|
440
|
+
#endif
|
|
441
|
+
#elif defined(DETAIL)
|
|
442
|
+
detailNormal.xy*=vDetailInfos.z;normalW=perturbNormalBase(TBN,detailNormal,vDetailInfos.z);
|
|
443
|
+
#endif
|
|
444
|
+
`;
|
|
445
|
+
e.IncludesShadersStore[f] || (e.IncludesShadersStore[f] = O);
|
|
446
|
+
const l = "openpbrBlockNormalFinal", C = `#if defined(FORCENORMALFORWARD) && defined(NORMAL)
|
|
447
|
+
vec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;
|
|
448
|
+
#if defined(TWOSIDEDLIGHTING)
|
|
449
|
+
faceNormal=gl_FrontFacing ? faceNormal : -faceNormal;
|
|
450
|
+
#endif
|
|
451
|
+
normalW*=sign(dot(normalW,faceNormal));coatNormalW*=sign(dot(coatNormalW,faceNormal));
|
|
452
|
+
#endif
|
|
453
|
+
#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
|
|
454
|
+
#if defined(MIRRORED)
|
|
455
|
+
normalW=gl_FrontFacing ? -normalW : normalW;coatNormalW=gl_FrontFacing ? -coatNormalW : coatNormalW;
|
|
456
|
+
#else
|
|
457
|
+
normalW=gl_FrontFacing ? normalW : -normalW;coatNormalW=gl_FrontFacing ? coatNormalW : -coatNormalW;
|
|
458
|
+
#endif
|
|
459
|
+
#endif
|
|
460
|
+
`;
|
|
461
|
+
e.IncludesShadersStore[l] || (e.IncludesShadersStore[l] = C);
|
|
462
|
+
const _ = "openpbrBaseLayerData", D = `vec3 base_color=vec3(0.8);float base_metalness=0.0;float base_diffuse_roughness=0.0;float specular_weight=1.0;float specular_roughness=0.3;vec3 specular_color=vec3(1.0);float specular_roughness_anisotropy=0.0;float specular_ior=1.5;float alpha=1.0;vec2 geometry_tangent=vec2(1.0,0.0);float geometry_thickness=0.0;
|
|
463
|
+
#ifdef BASE_WEIGHT
|
|
464
|
+
vec4 baseWeightFromTexture=TEXRD(baseWeightSampler,vBaseWeightUV+uvOffset);
|
|
465
|
+
#endif
|
|
466
|
+
#ifdef BASE_COLOR
|
|
467
|
+
vec4 baseColorFromTexture=TEXRD(baseColorSampler,vBaseColorUV+uvOffset);
|
|
468
|
+
#endif
|
|
469
|
+
#ifdef BASE_METALNESS
|
|
470
|
+
vec4 metallicFromTexture=TEXRD(baseMetalnessSampler,vBaseMetalnessUV+uvOffset);
|
|
471
|
+
#endif
|
|
472
|
+
#if defined(SPECULAR_ROUGHNESS_FROM_METALNESS_TEXTURE_GREEN) && defined(BASE_METALNESS)
|
|
473
|
+
float roughnessFromTexture=metallicFromTexture.g;
|
|
474
|
+
#elif defined(SPECULAR_ROUGHNESS)
|
|
475
|
+
float roughnessFromTexture=TEXRD(specularRoughnessSampler,vSpecularRoughnessUV+uvOffset).r;
|
|
476
|
+
#endif
|
|
477
|
+
#ifdef GEOMETRY_TANGENT
|
|
478
|
+
vec3 geometryTangentFromTexture=TEXRD(geometryTangentSampler,vGeometryTangentUV+uvOffset).rgb;
|
|
479
|
+
#endif
|
|
480
|
+
#ifdef SPECULAR_ROUGHNESS_ANISOTROPY
|
|
481
|
+
float anisotropyFromTexture=TEXRD(specularRoughnessAnisotropySampler,vSpecularRoughnessAnisotropyUV+uvOffset).r*vSpecularRoughnessAnisotropyInfos.y;
|
|
482
|
+
#endif
|
|
483
|
+
#ifdef BASE_DIFFUSE_ROUGHNESS
|
|
484
|
+
float baseDiffuseRoughnessFromTexture=TEXRD(baseDiffuseRoughnessSampler,vBaseDiffuseRoughnessUV+uvOffset).r;
|
|
485
|
+
#endif
|
|
486
|
+
#ifdef GEOMETRY_OPACITY
|
|
487
|
+
vec4 opacityFromTexture=TEXRD(geometryOpacitySampler,vGeometryOpacityUV+uvOffset);
|
|
488
|
+
#endif
|
|
489
|
+
#ifdef GEOMETRY_THICKNESS
|
|
490
|
+
vec4 thicknessFromTexture=TEXRD(geometryThicknessSampler,vGeometryThicknessUV+uvOffset);
|
|
491
|
+
#endif
|
|
492
|
+
#ifdef DECAL
|
|
493
|
+
vec4 decalFromTexture=texture2D(decalSampler,vDecalUV+uvOffset);
|
|
494
|
+
#endif
|
|
495
|
+
#ifdef SPECULAR_COLOR
|
|
496
|
+
vec4 specularColorFromTexture=TEXRD(specularColorSampler,vSpecularColorUV+uvOffset);
|
|
497
|
+
#endif
|
|
498
|
+
#ifdef SPECULAR_WEIGHT
|
|
499
|
+
#ifdef SPECULAR_WEIGHT_IN_ALPHA
|
|
500
|
+
float specularWeightFromTexture=TEXRD(specularWeightSampler,vSpecularWeightUV+uvOffset).a;
|
|
501
|
+
#else
|
|
502
|
+
float specularWeightFromTexture=TEXRD(specularWeightSampler,vSpecularWeightUV+uvOffset).r;
|
|
503
|
+
#endif
|
|
504
|
+
#endif
|
|
505
|
+
#if defined(ANISOTROPIC) || defined(FUZZ) || defined(REFRACTED_BACKGROUND) || defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING)
|
|
506
|
+
vec3 noise=vec3(2.0)*TEXRD(blueNoiseSampler,gl_FragCoord.xy/256.0).xyz-vec3(1.0);
|
|
507
|
+
#endif
|
|
508
|
+
base_color=vBaseColor.rgb;
|
|
509
|
+
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
|
510
|
+
base_color*=vColor.rgb;
|
|
511
|
+
#endif
|
|
512
|
+
#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
|
513
|
+
alpha*=vColor.a;
|
|
514
|
+
#endif
|
|
515
|
+
base_color*=vec3(vBaseWeight);alpha=vBaseColor.a;base_metalness=vReflectanceInfo.x;base_diffuse_roughness=vBaseDiffuseRoughness;specular_roughness=vReflectanceInfo.y;specular_color=vSpecularColor.rgb;specular_weight=vReflectanceInfo.a;specular_ior=vReflectanceInfo.z;specular_roughness_anisotropy=vSpecularAnisotropy.b;geometry_tangent=vSpecularAnisotropy.rg;geometry_thickness=vGeometryThickness;
|
|
516
|
+
#ifdef BASE_COLOR
|
|
517
|
+
#ifdef BASE_COLOR_GAMMA
|
|
518
|
+
base_color*=toLinearSpace(baseColorFromTexture.rgb);
|
|
519
|
+
#else
|
|
520
|
+
base_color*=baseColorFromTexture.rgb;
|
|
521
|
+
#endif
|
|
522
|
+
base_color*=vBaseColorInfos.y;
|
|
523
|
+
#endif
|
|
524
|
+
#ifdef BASE_WEIGHT
|
|
525
|
+
base_color*=baseWeightFromTexture.r;
|
|
526
|
+
#endif
|
|
527
|
+
#if defined(BASE_COLOR) && defined(ALPHA_FROM_BASE_COLOR_TEXTURE)
|
|
528
|
+
alpha*=baseColorFromTexture.a;
|
|
529
|
+
#elif defined(GEOMETRY_OPACITY)
|
|
530
|
+
alpha*=opacityFromTexture.r;alpha*=vGeometryOpacityInfos.y;
|
|
531
|
+
#endif
|
|
532
|
+
#ifdef GEOMETRY_THICKNESS
|
|
533
|
+
#ifdef GEOMETRY_THICKNESS_FROM_GREEN_CHANNEL
|
|
534
|
+
geometry_thickness*=thicknessFromTexture.g;
|
|
535
|
+
#else
|
|
536
|
+
geometry_thickness*=thicknessFromTexture.r;
|
|
537
|
+
#endif
|
|
538
|
+
geometry_thickness*=vGeometryThicknessInfos.y;
|
|
539
|
+
#endif
|
|
540
|
+
#ifdef ALPHATEST
|
|
541
|
+
#if DEBUGMODE != 88
|
|
542
|
+
if (alpha<ALPHATESTVALUE)
|
|
543
|
+
discard;
|
|
544
|
+
#endif
|
|
545
|
+
#ifndef ALPHABLEND
|
|
546
|
+
alpha=1.0;
|
|
547
|
+
#endif
|
|
548
|
+
#endif
|
|
549
|
+
#ifdef BASE_METALNESS
|
|
550
|
+
#ifdef BASE_METALNESS_FROM_METALNESS_TEXTURE_BLUE
|
|
551
|
+
base_metalness*=metallicFromTexture.b;
|
|
552
|
+
#else
|
|
553
|
+
base_metalness*=metallicFromTexture.r;
|
|
554
|
+
#endif
|
|
555
|
+
#endif
|
|
556
|
+
#ifdef BASE_DIFFUSE_ROUGHNESS
|
|
557
|
+
base_diffuse_roughness*=baseDiffuseRoughnessFromTexture*vBaseDiffuseRoughnessInfos.y;
|
|
558
|
+
#endif
|
|
559
|
+
#ifdef SPECULAR_COLOR
|
|
560
|
+
#ifdef SPECULAR_COLOR_GAMMA
|
|
561
|
+
specular_color*=toLinearSpace(specularColorFromTexture.rgb);
|
|
562
|
+
#else
|
|
563
|
+
specular_color*=specularColorFromTexture.rgb;
|
|
564
|
+
#endif
|
|
565
|
+
#ifdef SPECULAR_WEIGHT_FROM_SPECULAR_COLOR_TEXTURE
|
|
566
|
+
specular_weight*=specularColorFromTexture.a;
|
|
567
|
+
#elif defined(SPECULAR_WEIGHT)
|
|
568
|
+
specular_weight*=specularWeightFromTexture;
|
|
569
|
+
#endif
|
|
570
|
+
#endif
|
|
571
|
+
#if defined(SPECULAR_ROUGHNESS) || (defined(SPECULAR_ROUGHNESS_FROM_METALNESS_TEXTURE_GREEN) && defined(BASE_METALNESS))
|
|
572
|
+
specular_roughness*=roughnessFromTexture;
|
|
573
|
+
#endif
|
|
574
|
+
#ifdef GEOMETRY_TANGENT
|
|
575
|
+
{vec2 tangentFromTexture=normalize(geometryTangentFromTexture.xy*2.0-1.0);float tangent_angle_texture=atan(tangentFromTexture.y,tangentFromTexture.x);float tangent_angle_uniform=atan(geometry_tangent.y,geometry_tangent.x);float tangent_angle=tangent_angle_texture+tangent_angle_uniform;geometry_tangent=vec2(cos(tangent_angle),sin(tangent_angle));}
|
|
576
|
+
#endif
|
|
577
|
+
#if defined(GEOMETRY_TANGENT) && defined(SPECULAR_ROUGHNESS_ANISOTROPY_FROM_TANGENT_TEXTURE)
|
|
578
|
+
specular_roughness_anisotropy*=geometryTangentFromTexture.b;
|
|
579
|
+
#elif defined(SPECULAR_ROUGHNESS_ANISOTROPY)
|
|
580
|
+
specular_roughness_anisotropy*=anisotropyFromTexture;
|
|
581
|
+
#endif
|
|
582
|
+
#ifdef DETAIL
|
|
583
|
+
float detailRoughness=mix(0.5,detailColor.b,vDetailInfos.w);float loLerp=mix(0.,specular_roughness,detailRoughness*2.);float hiLerp=mix(specular_roughness,1.,(detailRoughness-0.5)*2.);specular_roughness=mix(loLerp,hiLerp,step(detailRoughness,0.5));
|
|
584
|
+
#endif
|
|
585
|
+
#ifdef USE_GLTF_STYLE_ANISOTROPY
|
|
586
|
+
float baseAlpha=specular_roughness*specular_roughness;float roughnessT=mix(baseAlpha,1.0,specular_roughness_anisotropy*specular_roughness_anisotropy);float roughnessB=baseAlpha;specular_roughness_anisotropy=1.0-roughnessB/max(roughnessT,0.00001);specular_roughness=sqrt(roughnessT/sqrt(2.0/(1.0+(1.0-specular_roughness_anisotropy)*(1.0-specular_roughness_anisotropy))));
|
|
587
|
+
#endif
|
|
588
|
+
`;
|
|
589
|
+
e.IncludesShadersStore[_] || (e.IncludesShadersStore[_] = D);
|
|
590
|
+
const d = "openpbrCoatLayerData", P = `float coat_weight=0.0;vec3 coat_color=vec3(1.0);float coat_roughness=0.0;float coat_roughness_anisotropy=0.0;float coat_ior=1.6;float coat_darkening=1.0;vec2 geometry_coat_tangent=vec2(1.0,0.0);
|
|
591
|
+
#ifdef COAT_WEIGHT
|
|
592
|
+
vec4 coatWeightFromTexture=TEXRD(coatWeightSampler,vCoatWeightUV+uvOffset);
|
|
593
|
+
#endif
|
|
594
|
+
#ifdef COAT_COLOR
|
|
595
|
+
vec4 coatColorFromTexture=TEXRD(coatColorSampler,vCoatColorUV+uvOffset);
|
|
596
|
+
#endif
|
|
597
|
+
#ifdef COAT_ROUGHNESS
|
|
598
|
+
vec4 coatRoughnessFromTexture=TEXRD(coatRoughnessSampler,vCoatRoughnessUV+uvOffset);
|
|
599
|
+
#endif
|
|
600
|
+
#ifdef COAT_ROUGHNESS_ANISOTROPY
|
|
601
|
+
float coatRoughnessAnisotropyFromTexture=TEXRD(coatRoughnessAnisotropySampler,vCoatRoughnessAnisotropyUV+uvOffset).r;
|
|
602
|
+
#endif
|
|
603
|
+
#ifdef COAT_DARKENING
|
|
604
|
+
vec4 coatDarkeningFromTexture=TEXRD(coatDarkeningSampler,vCoatDarkeningUV+uvOffset);
|
|
605
|
+
#endif
|
|
606
|
+
#ifdef GEOMETRY_COAT_TANGENT
|
|
607
|
+
vec3 geometryCoatTangentFromTexture=TEXRD(geometryCoatTangentSampler,vGeometryCoatTangentUV+uvOffset).rgb;
|
|
608
|
+
#endif
|
|
609
|
+
coat_color=vCoatColor.rgb;coat_weight=vCoatWeight;coat_roughness=vCoatRoughness;coat_roughness_anisotropy=vCoatRoughnessAnisotropy;coat_ior=vCoatIor;coat_darkening=vCoatDarkening;geometry_coat_tangent=vGeometryCoatTangent.rg;
|
|
610
|
+
#ifdef COAT_WEIGHT
|
|
611
|
+
coat_weight*=coatWeightFromTexture.r;
|
|
612
|
+
#endif
|
|
613
|
+
#ifdef COAT_COLOR
|
|
614
|
+
#ifdef COAT_COLOR_GAMMA
|
|
615
|
+
coat_color*=toLinearSpace(coatColorFromTexture.rgb);
|
|
616
|
+
#else
|
|
617
|
+
coat_color*=coatColorFromTexture.rgb;
|
|
618
|
+
#endif
|
|
619
|
+
coat_color*=vCoatColorInfos.y;
|
|
620
|
+
#endif
|
|
621
|
+
#ifdef COAT_ROUGHNESS
|
|
622
|
+
#ifdef COAT_ROUGHNESS_FROM_GREEN_CHANNEL
|
|
623
|
+
coat_roughness*=coatRoughnessFromTexture.g;
|
|
624
|
+
#else
|
|
625
|
+
coat_roughness*=coatRoughnessFromTexture.r;
|
|
626
|
+
#endif
|
|
627
|
+
#endif
|
|
628
|
+
#if defined(GEOMETRY_COAT_TANGENT) && defined(COAT_ROUGHNESS_ANISOTROPY_FROM_TANGENT_TEXTURE)
|
|
629
|
+
coat_roughness_anisotropy*=geometryCoatTangentFromTexture.b;
|
|
630
|
+
#elif defined(COAT_ROUGHNESS_ANISOTROPY)
|
|
631
|
+
coat_roughness_anisotropy*=coatRoughnessAnisotropyFromTexture;
|
|
632
|
+
#endif
|
|
633
|
+
#ifdef COAT_DARKENING
|
|
634
|
+
coat_darkening*=coatDarkeningFromTexture.r;
|
|
635
|
+
#endif
|
|
636
|
+
#ifdef GEOMETRY_COAT_TANGENT
|
|
637
|
+
{vec2 tangentFromTexture=normalize(geometryCoatTangentFromTexture.xy*2.0-1.0);float tangent_angle_texture=atan(tangentFromTexture.y,tangentFromTexture.x);float tangent_angle_uniform=atan(geometry_coat_tangent.y,geometry_coat_tangent.x);float tangent_angle=tangent_angle_texture+tangent_angle_uniform;geometry_coat_tangent=vec2(cos(tangent_angle),sin(tangent_angle));}
|
|
638
|
+
#endif
|
|
639
|
+
#ifdef USE_GLTF_STYLE_ANISOTROPY
|
|
640
|
+
float coatAlpha=coat_roughness*coat_roughness;float coatRoughnessT=mix(coatAlpha,1.0,coat_roughness_anisotropy*coat_roughness_anisotropy);float coatRoughnessB=coatAlpha;coat_roughness_anisotropy=1.0-coatRoughnessB/max(coatRoughnessT,0.00001);coat_roughness=sqrt(coatRoughnessT/sqrt(2.0/(1.0+(1.0-coat_roughness_anisotropy)*(1.0-coat_roughness_anisotropy))));
|
|
641
|
+
#endif
|
|
642
|
+
`;
|
|
643
|
+
e.IncludesShadersStore[d] || (e.IncludesShadersStore[d] = P);
|
|
644
|
+
const m = "openpbrThinFilmLayerData", M = `#ifdef THIN_FILM
|
|
645
|
+
float thin_film_weight=vThinFilmWeight;float thin_film_thickness=vThinFilmThickness.r*1000.0;
|
|
646
|
+
float thin_film_ior=vThinFilmIor;
|
|
647
|
+
#ifdef THIN_FILM_WEIGHT
|
|
648
|
+
float thinFilmWeightFromTexture=TEXRD(thinFilmWeightSampler,vThinFilmWeightUV+uvOffset).r*vThinFilmWeightInfos.y;
|
|
649
|
+
#endif
|
|
650
|
+
#ifdef THIN_FILM_THICKNESS
|
|
651
|
+
float thinFilmThicknessFromTexture=TEXRD(thinFilmThicknessSampler,vThinFilmThicknessUV+uvOffset).g*vThinFilmThicknessInfos.y;
|
|
652
|
+
#endif
|
|
653
|
+
#ifdef THIN_FILM_WEIGHT
|
|
654
|
+
thin_film_weight*=thinFilmWeightFromTexture;
|
|
655
|
+
#endif
|
|
656
|
+
#ifdef THIN_FILM_THICKNESS
|
|
657
|
+
thin_film_thickness*=thinFilmThicknessFromTexture;
|
|
658
|
+
#endif
|
|
659
|
+
float thin_film_ior_scale=clamp(2.0f*abs(thin_film_ior-1.0f),0.0f,1.0f);
|
|
660
|
+
#endif
|
|
661
|
+
`;
|
|
662
|
+
e.IncludesShadersStore[m] || (e.IncludesShadersStore[m] = M);
|
|
663
|
+
const u = "openpbrFuzzLayerData", G = `float fuzz_weight=0.0;vec3 fuzz_color=vec3(1.0);float fuzz_roughness=0.0;
|
|
664
|
+
#ifdef FUZZ
|
|
665
|
+
#ifdef FUZZ_WEIGHT
|
|
666
|
+
vec4 fuzzWeightFromTexture=TEXRD(fuzzWeightSampler,vFuzzWeightUV+uvOffset);
|
|
667
|
+
#endif
|
|
668
|
+
#ifdef FUZZ_COLOR
|
|
669
|
+
vec4 fuzzColorFromTexture=TEXRD(fuzzColorSampler,vFuzzColorUV+uvOffset);
|
|
670
|
+
#endif
|
|
671
|
+
#ifdef FUZZ_ROUGHNESS
|
|
672
|
+
vec4 fuzzRoughnessFromTexture=TEXRD(fuzzRoughnessSampler,vFuzzRoughnessUV+uvOffset);
|
|
673
|
+
#endif
|
|
674
|
+
fuzz_color=vFuzzColor.rgb;fuzz_weight=vFuzzWeight;fuzz_roughness=vFuzzRoughness;
|
|
675
|
+
#ifdef FUZZ_WEIGHT
|
|
676
|
+
fuzz_weight*=fuzzWeightFromTexture.r;
|
|
677
|
+
#endif
|
|
678
|
+
#ifdef FUZZ_COLOR
|
|
679
|
+
#ifdef FUZZ_COLOR_GAMMA
|
|
680
|
+
fuzz_color*=toLinearSpace(fuzzColorFromTexture.rgb);
|
|
681
|
+
#else
|
|
682
|
+
fuzz_color*=fuzzColorFromTexture.rgb;
|
|
683
|
+
#endif
|
|
684
|
+
fuzz_color*=vFuzzColorInfos.y;
|
|
685
|
+
#endif
|
|
686
|
+
#if defined(FUZZ_ROUGHNESS) && defined(FUZZ_ROUGHNESS_FROM_TEXTURE_ALPHA)
|
|
687
|
+
fuzz_roughness*=fuzzRoughnessFromTexture.a;
|
|
688
|
+
#elif defined(FUZZ_ROUGHNESS)
|
|
689
|
+
fuzz_roughness*=fuzzRoughnessFromTexture.r;
|
|
690
|
+
#endif
|
|
691
|
+
#endif
|
|
692
|
+
`;
|
|
693
|
+
e.IncludesShadersStore[u] || (e.IncludesShadersStore[u] = G);
|
|
694
|
+
const g = "openpbrAmbientOcclusionData", x = `vec3 ambient_occlusion=vec3(1.0);float specular_ambient_occlusion=1.0;float coat_specular_ambient_occlusion=1.0;
|
|
695
|
+
#ifdef AMBIENT_OCCLUSION
|
|
696
|
+
vec3 ambientOcclusionFromTexture=TEXRD(ambientOcclusionSampler,vAmbientOcclusionUV+uvOffset).rgb;ambient_occlusion=vec3(ambientOcclusionFromTexture.r*vAmbientOcclusionInfos.y+(1.0-vAmbientOcclusionInfos.y));
|
|
697
|
+
#endif
|
|
698
|
+
`;
|
|
699
|
+
e.IncludesShadersStore[g] || (e.IncludesShadersStore[g] = x);
|
|
700
|
+
const v = "openpbrBackgroundTransmission", y = `vec4 slab_translucent_background=vec4(0.,0.,0.,1.);
|
|
701
|
+
#ifdef REFRACTED_BACKGROUND
|
|
702
|
+
{float refractionLOD=min(transmission_roughness,0.8)*vBackgroundRefractionInfos.x;float lodTexelSize=pow(2.0,refractionLOD-vBackgroundRefractionInfos.x);
|
|
703
|
+
#ifdef DISPERSION
|
|
704
|
+
{
|
|
705
|
+
#ifdef REFRACTION_HIGH_QUALITY_BLUR
|
|
706
|
+
{vec3 dispResult=vec3(0.0);vec3 dispWeight=vec3(0.0);vec2 noiseOffset=noise.xy*(refractionLOD>0.0 ? lodTexelSize : 0.0);for (int k=0; k<6; k++) {float t=(float(k)+noise.y)/6.0;float t_rg=clamp(t*2.0,0.0,1.0);float t_gb=clamp((t-0.5)*2.0,0.0,1.0);vec3 refVec=mix(mix(refractedViewVectors[0],refractedViewVectors[1],t_rg),refractedViewVectors[2],t_gb);vec3 uvw=vec3(backgroundRefractionMatrix*(view*vec4(vPositionW+refVec*geometry_thickness,1.0)));vec2 coords=uvw.xy/uvw.z;coords.y=1.0-coords.y;vec4 s=texture2DLodEXT(backgroundRefractionSampler,coords+noiseOffset,refractionLOD);float rw=max(0.0,1.0-2.0*t);float gw=max(0.0,1.0-abs(2.0*t-1.0));float bw=max(0.0,2.0*t-1.0);vec3 w=vec3(rw,gw,bw);dispResult+=s.rgb*w;dispWeight+=w;}
|
|
707
|
+
slab_translucent_background=vec4(dispResult/max(dispWeight,vec3(1e-6)),1.0);}
|
|
708
|
+
#else
|
|
709
|
+
for (int i=0; i<3; i++) {vec3 refractedViewVector=refractedViewVectors[i];vec3 uvw=vec3(backgroundRefractionMatrix*(view*vec4(vPositionW+refractedViewVector*geometry_thickness,1.0)));vec2 coords=uvw.xy/uvw.z;coords.y=1.0-coords.y;if (refractionLOD>0.0) {vec2 noiseOffset=noise.xy*lodTexelSize;slab_translucent_background[i]=texture2DLodEXT(backgroundRefractionSampler,coords+noiseOffset,refractionLOD)[i];} else {slab_translucent_background[i]=texture2DLodEXT(backgroundRefractionSampler,coords,0.0)[i];}}
|
|
710
|
+
#endif
|
|
711
|
+
}
|
|
712
|
+
#else
|
|
713
|
+
{vec3 refractionUVW=vec3(backgroundRefractionMatrix*(view*vec4(vPositionW+refractedViewVector*geometry_thickness,1.0)));vec2 refractionCoords=refractionUVW.xy/refractionUVW.z;refractionCoords.y=1.0-refractionCoords.y;if (refractionLOD>0.0) {
|
|
714
|
+
#ifdef REFRACTION_HIGH_QUALITY_BLUR
|
|
715
|
+
float cosA=cos(noise.x*PI);float sinA=sin(noise.x*PI);vec2 u=vec2( cosA,sinA)*(0.5*lodTexelSize);vec2 v=vec2(-sinA,cosA)*(0.5*lodTexelSize);slab_translucent_background=0.25*(
|
|
716
|
+
texture2DLodEXT(backgroundRefractionSampler,refractionCoords+u+v,refractionLOD) +
|
|
717
|
+
texture2DLodEXT(backgroundRefractionSampler,refractionCoords-u+v,refractionLOD) +
|
|
718
|
+
texture2DLodEXT(backgroundRefractionSampler,refractionCoords+u-v,refractionLOD) +
|
|
719
|
+
texture2DLodEXT(backgroundRefractionSampler,refractionCoords-u-v,refractionLOD)
|
|
720
|
+
);
|
|
721
|
+
#else
|
|
722
|
+
vec2 noiseOffset=noise.xy*lodTexelSize;slab_translucent_background=texture2DLodEXT(backgroundRefractionSampler,refractionCoords+noiseOffset,refractionLOD);
|
|
723
|
+
#endif
|
|
724
|
+
} else {slab_translucent_background=texture2DLodEXT(backgroundRefractionSampler,refractionCoords,0.0);}}
|
|
725
|
+
#endif
|
|
726
|
+
}
|
|
727
|
+
#endif
|
|
728
|
+
`;
|
|
729
|
+
e.IncludesShadersStore[v] || (e.IncludesShadersStore[v] = y);
|
|
730
|
+
const E = "openpbrEnvironmentLighting", z = `#if defined(REFLECTION) || defined(REFRACTED_BACKGROUND)
|
|
731
|
+
vec3 coatAbsorption=vec3(1.0);float coatIblFresnel=0.0;if (coat_weight>0.0) {coatIblFresnel=computeDielectricIblFresnel(coatReflectance,coatGeoInfo.environmentBrdf);float hemisphere_avg_fresnel=coatReflectance.F0+0.5*(1.0-coatReflectance.F0);float averageReflectance=(coatIblFresnel+hemisphere_avg_fresnel)*0.5;float roughnessFactor=1.0-coat_roughness*0.5;averageReflectance*=roughnessFactor;float darkened_transmission=(1.0-averageReflectance)*(1.0-averageReflectance);darkened_transmission=mix(1.0,darkened_transmission,coat_darkening);float sin2=1.0-coatGeoInfo.NdotV*coatGeoInfo.NdotV;sin2=sin2/(coat_ior*coat_ior)*coat_weight;float cos_t=sqrt(1.0-sin2);float coatPathLength=1.0/cos_t;float effectivePathLength=coatPathLength*coat_weight;vec3 colored_transmission=pow(coat_color,vec3(effectivePathLength));coatAbsorption=colored_transmission*mix(1.0,darkened_transmission,coat_weight);}
|
|
732
|
+
#endif
|
|
733
|
+
#ifdef REFLECTION
|
|
734
|
+
#if defined(FUZZ) && defined(FUZZENVIRONMENTBRDF)
|
|
735
|
+
vec3 environmentFuzzBrdf=getFuzzBRDFLookup(fuzzGeoInfo.NdotV,sqrt(fuzz_roughness));
|
|
736
|
+
#endif
|
|
737
|
+
vec3 baseDiffuseEnvironmentLight=sampleIrradiance(
|
|
738
|
+
normalW
|
|
739
|
+
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
|
|
740
|
+
,vEnvironmentIrradiance
|
|
741
|
+
#endif
|
|
742
|
+
#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
|
|
743
|
+
,reflectionMatrix
|
|
744
|
+
#endif
|
|
745
|
+
#ifdef USEIRRADIANCEMAP
|
|
746
|
+
,irradianceSampler
|
|
747
|
+
#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
|
|
748
|
+
,vReflectionDominantDirection
|
|
749
|
+
#endif
|
|
750
|
+
#endif
|
|
751
|
+
#ifdef REALTIME_FILTERING
|
|
752
|
+
,vReflectionFilteringInfo
|
|
753
|
+
#ifdef IBL_CDF_FILTERING
|
|
754
|
+
,icdfSampler
|
|
755
|
+
#endif
|
|
756
|
+
#endif
|
|
757
|
+
,vReflectionInfos
|
|
758
|
+
,viewDirectionW
|
|
759
|
+
,base_diffuse_roughness
|
|
760
|
+
,base_color
|
|
761
|
+
);
|
|
762
|
+
#ifdef REFLECTIONMAP_3D
|
|
763
|
+
vec3 reflectionCoords=vec3(0.,0.,0.);
|
|
764
|
+
#else
|
|
765
|
+
vec2 reflectionCoords=vec2(0.,0.);
|
|
766
|
+
#endif
|
|
767
|
+
float specularAlphaG=specular_roughness*specular_roughness;
|
|
768
|
+
#ifdef ANISOTROPIC_BASE
|
|
769
|
+
vec3 baseSpecularEnvironmentLight=sampleRadianceAnisotropic(specularAlphaG,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos
|
|
770
|
+
,baseGeoInfo
|
|
771
|
+
,normalW
|
|
772
|
+
,viewDirectionW
|
|
773
|
+
,vPositionW
|
|
774
|
+
,noise
|
|
775
|
+
,false
|
|
776
|
+
,1.0
|
|
777
|
+
,reflectionSampler
|
|
778
|
+
#ifdef REALTIME_FILTERING
|
|
779
|
+
,vReflectionFilteringInfo
|
|
780
|
+
#endif
|
|
781
|
+
);
|
|
782
|
+
#else
|
|
783
|
+
reflectionCoords=createReflectionCoords(vPositionW,normalW);vec3 baseSpecularEnvironmentLight=sampleRadiance(specularAlphaG,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos
|
|
784
|
+
,baseGeoInfo
|
|
785
|
+
,reflectionSampler
|
|
786
|
+
,reflectionCoords
|
|
787
|
+
#ifdef REALTIME_FILTERING
|
|
788
|
+
,vReflectionFilteringInfo
|
|
789
|
+
#endif
|
|
790
|
+
);
|
|
791
|
+
#endif
|
|
792
|
+
#ifdef ANISOTROPIC_BASE
|
|
793
|
+
baseSpecularEnvironmentLight=mix(baseSpecularEnvironmentLight.rgb,baseDiffuseEnvironmentLight,specularAlphaG*specularAlphaG*max(1.0-baseGeoInfo.anisotropy,0.3));
|
|
794
|
+
#else
|
|
795
|
+
baseSpecularEnvironmentLight=mix(baseSpecularEnvironmentLight.rgb,baseDiffuseEnvironmentLight,specularAlphaG);
|
|
796
|
+
#endif
|
|
797
|
+
vec3 coatEnvironmentLight=vec3(0.,0.,0.);if (coat_weight>0.0) {
|
|
798
|
+
#ifdef REFLECTIONMAP_3D
|
|
799
|
+
vec3 reflectionCoords=vec3(0.,0.,0.);
|
|
800
|
+
#else
|
|
801
|
+
vec2 reflectionCoords=vec2(0.,0.);
|
|
802
|
+
#endif
|
|
803
|
+
reflectionCoords=createReflectionCoords(vPositionW,coatNormalW);float coatAlphaG=coat_roughness*coat_roughness;
|
|
804
|
+
#ifdef ANISOTROPIC_COAT
|
|
805
|
+
coatEnvironmentLight=sampleRadianceAnisotropic(coatAlphaG,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos
|
|
806
|
+
,coatGeoInfo
|
|
807
|
+
,coatNormalW
|
|
808
|
+
,viewDirectionW
|
|
809
|
+
,vPositionW
|
|
810
|
+
,noise
|
|
811
|
+
,false
|
|
812
|
+
,1.0
|
|
813
|
+
,reflectionSampler
|
|
814
|
+
#ifdef REALTIME_FILTERING
|
|
815
|
+
,vReflectionFilteringInfo
|
|
816
|
+
#endif
|
|
817
|
+
);
|
|
818
|
+
#else
|
|
819
|
+
coatEnvironmentLight=sampleRadiance(coatAlphaG,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos
|
|
820
|
+
,coatGeoInfo
|
|
821
|
+
,reflectionSampler
|
|
822
|
+
,reflectionCoords
|
|
823
|
+
#ifdef REALTIME_FILTERING
|
|
824
|
+
,vReflectionFilteringInfo
|
|
825
|
+
#endif
|
|
826
|
+
);
|
|
827
|
+
#endif
|
|
828
|
+
}
|
|
829
|
+
#if defined(FUZZ) &&defined(FUZZENVIRONMENTBRDF)
|
|
830
|
+
float modifiedFuzzRoughness=clamp(fuzz_roughness*(1.0-0.5*environmentFuzzBrdf.y),0.0,1.0);vec3 fuzzEnvironmentLight=vec3(0.0);float totalWeight=0.0;float fuzzIblFresnel=sqrt(environmentFuzzBrdf.z);for (int i=0; i<FUZZ_IBL_SAMPLES; ++i) {float angle=(float(i)+noise.x)*(3.141592*2.0/float(FUZZ_IBL_SAMPLES));vec3 fiberCylinderNormal=normalize(cos(angle)*fuzzTangent+sin(angle)*fuzzBitangent);float fiberBend=min(environmentFuzzBrdf.x*environmentFuzzBrdf.x*modifiedFuzzRoughness,1.0);fiberCylinderNormal=normalize(mix(fiberCylinderNormal,fuzzNormalW,fiberBend));float sampleWeight=max(dot(viewDirectionW,fiberCylinderNormal),0.0);vec3 fuzzReflectionCoords=createReflectionCoords(vPositionW,fiberCylinderNormal);vec3 radianceSample=sampleRadiance(modifiedFuzzRoughness,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos
|
|
831
|
+
,fuzzGeoInfo
|
|
832
|
+
,reflectionSampler
|
|
833
|
+
,fuzzReflectionCoords
|
|
834
|
+
#ifdef REALTIME_FILTERING
|
|
835
|
+
,vReflectionFilteringInfo
|
|
836
|
+
#endif
|
|
837
|
+
);fuzzEnvironmentLight+=sampleWeight*mix(radianceSample,baseDiffuseEnvironmentLight,fiberBend);totalWeight+=sampleWeight;}
|
|
838
|
+
fuzzEnvironmentLight/=totalWeight;
|
|
839
|
+
#endif
|
|
840
|
+
float dielectricIblFresnel=computeDielectricIblFresnel(baseDielectricReflectance,baseGeoInfo.environmentBrdf);vec3 dielectricIblColoredFresnel=dielectricIblFresnel*specular_color;
|
|
841
|
+
#ifdef THIN_FILM
|
|
842
|
+
float thin_film_cos_theta=max(baseGeoInfo.NdotV,specularAlphaG);float thin_film_desaturation_scale=(thin_film_ior-1.0)*sqrt(thin_film_thickness*0.001*thin_film_cos_theta);float tf_brdf_x=baseGeoInfo.environmentBrdf.x;float tf_E_ss =baseGeoInfo.environmentBrdf.y;vec3 thinFilmDielectricF0=evalIridescence(thin_film_outside_ior,thin_film_ior,1.0,thin_film_thickness,vec3(baseDielectricReflectance.F0));thinFilmDielectricF0=mix(thinFilmDielectricF0,vec3(dot(thinFilmDielectricF0,vec3(0.3333))),thin_film_desaturation_scale);vec3 thinFilmDielectricDir=evalIridescence(thin_film_outside_ior,thin_film_ior,thin_film_cos_theta,thin_film_thickness,vec3(baseDielectricReflectance.F0));thinFilmDielectricDir=mix(thinFilmDielectricDir,vec3(dot(thinFilmDielectricDir,vec3(0.3333))),thin_film_desaturation_scale);float tf_f0d_avg =dot(thinFilmDielectricF0, vec3(0.3333));float tf_dird_avg=dot(thinFilmDielectricDir,vec3(0.3333));vec3 thinFilmDielectricFresnel=thinFilmDielectricDir*(tf_f0d_avg/max(tf_dird_avg,1e-5));vec3 tf_E_dielectric=(vec3(1.0)-thinFilmDielectricFresnel)*vec3(tf_brdf_x)+thinFilmDielectricFresnel*vec3(tf_E_ss);vec3 tf_F_avg_dielectric=thinFilmDielectricFresnel+(vec3(1.0)-thinFilmDielectricFresnel)/21.0;vec3 tf_ECF_dielectric=vec3(1.0)+tf_F_avg_dielectric*(vec3(1.0)/vec3(tf_E_ss)-vec3(1.0));thinFilmDielectricFresnel=clamp(tf_E_dielectric*tf_ECF_dielectric,vec3(0.0),vec3(1.0));dielectricIblColoredFresnel=mix(dielectricIblColoredFresnel,thinFilmDielectricFresnel*specular_color,thin_film_weight*thin_film_ior_scale);dielectricIblFresnel=max(dielectricIblColoredFresnel.r,max(dielectricIblColoredFresnel.g,dielectricIblColoredFresnel.b));
|
|
843
|
+
#endif
|
|
844
|
+
vec3 conductorIblFresnel=computeConductorIblFresnel(baseConductorReflectance,baseGeoInfo.environmentBrdf);
|
|
845
|
+
#ifdef THIN_FILM
|
|
846
|
+
vec3 thinFilmConductorF0=evalIridescence(thin_film_outside_ior,thin_film_ior,1.0,thin_film_thickness,baseConductorReflectance.coloredF0);thinFilmConductorF0=mix(thinFilmConductorF0,vec3(dot(thinFilmConductorF0,vec3(0.3333))),thin_film_desaturation_scale);vec3 thinFilmConductorDir=evalIridescence(thin_film_outside_ior,thin_film_ior,thin_film_cos_theta,thin_film_thickness,baseConductorReflectance.coloredF0);thinFilmConductorDir=mix(thinFilmConductorDir,vec3(dot(thinFilmConductorDir,vec3(0.3333))),thin_film_desaturation_scale);float tf_f0c_avg =dot(thinFilmConductorF0, vec3(0.3333));float tf_dirc_avg=dot(thinFilmConductorDir,vec3(0.3333));vec3 thinFilmConductorRaw=thinFilmConductorDir*(tf_f0c_avg/max(tf_dirc_avg,1e-5));
|
|
847
|
+
#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR) && defined(ENVIRONMENTBRDF)
|
|
848
|
+
vec3 tf_b=getF82B(baseConductorReflectance.coloredF0,baseConductorReflectance.coloredF90);float tf_brdf_z=baseGeoInfo.environmentBrdf.z/BRDF_Z_SCALE;vec3 tf_E_conductor=(vec3(1.0)-thinFilmConductorRaw)*vec3(tf_brdf_x)+thinFilmConductorRaw*vec3(tf_E_ss)-tf_b*vec3(tf_brdf_z);vec3 tf_F_avg_conductor=thinFilmConductorRaw+(vec3(1.0)-thinFilmConductorRaw)/21.0-tf_b/126.0;
|
|
849
|
+
#else
|
|
850
|
+
vec3 tf_E_conductor=(vec3(1.0)-thinFilmConductorRaw)*vec3(tf_brdf_x)+thinFilmConductorRaw*vec3(tf_E_ss);vec3 tf_F_avg_conductor=thinFilmConductorRaw+(vec3(1.0)-thinFilmConductorRaw)/21.0;
|
|
851
|
+
#endif
|
|
852
|
+
vec3 tf_ECF_conductor=vec3(1.0)+tf_F_avg_conductor*(vec3(1.0)/vec3(tf_E_ss)-vec3(1.0));vec3 thinFilmConductorFresnel=specular_weight*clamp(tf_E_conductor*tf_ECF_conductor,vec3(0.0),vec3(1.0));conductorIblFresnel=mix(conductorIblFresnel,thinFilmConductorFresnel,thin_film_weight*thin_film_ior_scale);
|
|
853
|
+
#endif
|
|
854
|
+
vec3 slab_diffuse_ibl=vec3(0.,0.,0.);vec3 slab_glossy_ibl=vec3(0.,0.,0.);vec3 slab_metal_ibl=vec3(0.,0.,0.);vec3 slab_coat_ibl=vec3(0.,0.,0.);slab_diffuse_ibl=baseDiffuseEnvironmentLight*vLightingIntensity.z;
|
|
855
|
+
#ifdef AMBIENT_OCCLUSION
|
|
856
|
+
specular_ambient_occlusion=compute_specular_occlusion(baseGeoInfo.NdotV,base_metalness,ambient_occlusion.x,specular_roughness);
|
|
857
|
+
#endif
|
|
858
|
+
slab_glossy_ibl=baseSpecularEnvironmentLight*vLightingIntensity.z;slab_metal_ibl=baseSpecularEnvironmentLight*conductorIblFresnel*vLightingIntensity.z;if (coat_weight>0.0) {slab_coat_ibl=coatEnvironmentLight*vLightingIntensity.z;
|
|
859
|
+
#ifdef AMBIENT_OCCLUSION
|
|
860
|
+
coat_specular_ambient_occlusion=compute_specular_occlusion(coatGeoInfo.NdotV,0.0,ambient_occlusion.x,coat_roughness);
|
|
861
|
+
#endif
|
|
862
|
+
}
|
|
863
|
+
#if defined(FUZZ) &&defined(FUZZENVIRONMENTBRDF)
|
|
864
|
+
vec3 slab_fuzz_ibl=fuzzEnvironmentLight*vLightingIntensity.z;
|
|
865
|
+
#endif
|
|
866
|
+
vec3 slab_translucent_base_ibl=vec3(0.0);vec3 slab_subsurface_ibl=vec3(0.,0.,0.);
|
|
867
|
+
#ifdef REFRACTED_ENVIRONMENT
|
|
868
|
+
#ifdef ANISOTROPIC_BASE
|
|
869
|
+
vec3 forwardScatteredEnvironmentLight=sampleRadianceAnisotropic(transmission_roughness_alpha,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos
|
|
870
|
+
,baseGeoInfo
|
|
871
|
+
#ifdef GEOMETRY_THIN_WALLED
|
|
872
|
+
,viewDirectionW
|
|
873
|
+
#else
|
|
874
|
+
,normalW
|
|
875
|
+
#endif
|
|
876
|
+
,viewDirectionW
|
|
877
|
+
,vPositionW
|
|
878
|
+
,noise
|
|
879
|
+
,true
|
|
880
|
+
#ifdef GEOMETRY_THIN_WALLED
|
|
881
|
+
,1.05
|
|
882
|
+
#else
|
|
883
|
+
,specular_ior
|
|
884
|
+
#endif
|
|
885
|
+
,reflectionSampler
|
|
886
|
+
#ifdef REALTIME_FILTERING
|
|
887
|
+
,vReflectionFilteringInfo
|
|
888
|
+
#endif
|
|
889
|
+
);
|
|
890
|
+
#else
|
|
891
|
+
vec3 forwardScatteredEnvironmentLight=vec3(0.,0.,0.);
|
|
892
|
+
#ifdef DISPERSION
|
|
893
|
+
for (int i=0; i<3; i++) {vec3 iblRefractionCoords=refractedViewVectors[i];
|
|
894
|
+
#else
|
|
895
|
+
vec3 iblRefractionCoords=refractedViewVector;
|
|
896
|
+
#endif
|
|
897
|
+
#ifdef REFRACTED_ENVIRONMENT_OPPOSITEZ
|
|
898
|
+
iblRefractionCoords.z*=-1.0;
|
|
899
|
+
#endif
|
|
900
|
+
#ifdef REFRACTED_ENVIRONMENT_LOCAL_CUBE
|
|
901
|
+
iblRefractionCoords=parallaxCorrectNormal(vPositionW,refractedViewVector,refractionSize,refractionPosition);
|
|
902
|
+
#endif
|
|
903
|
+
iblRefractionCoords=vec3(reflectionMatrix*vec4(iblRefractionCoords,0));
|
|
904
|
+
#ifdef DISPERSION
|
|
905
|
+
forwardScatteredEnvironmentLight[i]=sampleRadiance(transmission_roughness_alpha,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos
|
|
906
|
+
,baseGeoInfo
|
|
907
|
+
,reflectionSampler
|
|
908
|
+
,iblRefractionCoords
|
|
909
|
+
#ifdef REALTIME_FILTERING
|
|
910
|
+
,vReflectionFilteringInfo
|
|
911
|
+
#endif
|
|
912
|
+
)[i];
|
|
913
|
+
#else
|
|
914
|
+
forwardScatteredEnvironmentLight=sampleRadiance(transmission_roughness_alpha,vReflectionMicrosurfaceInfos.rgb,vReflectionInfos
|
|
915
|
+
,baseGeoInfo
|
|
916
|
+
,reflectionSampler
|
|
917
|
+
,iblRefractionCoords
|
|
918
|
+
#ifdef REALTIME_FILTERING
|
|
919
|
+
,vReflectionFilteringInfo
|
|
920
|
+
#endif
|
|
921
|
+
);
|
|
922
|
+
#endif
|
|
923
|
+
#ifdef DISPERSION
|
|
924
|
+
}
|
|
925
|
+
#endif
|
|
926
|
+
#endif
|
|
927
|
+
#ifdef REFRACTED_BACKGROUND
|
|
928
|
+
#ifdef GEOMETRY_THIN_WALLED
|
|
929
|
+
forwardScatteredEnvironmentLight=mix(slab_translucent_background.rgb,forwardScatteredEnvironmentLight.rgb,0.2*transmission_roughness_alpha);
|
|
930
|
+
#else
|
|
931
|
+
forwardScatteredEnvironmentLight=max(slab_translucent_background.rgb,mix(slab_translucent_background.rgb,forwardScatteredEnvironmentLight,transmission_roughness_alpha));
|
|
932
|
+
#endif
|
|
933
|
+
#endif
|
|
934
|
+
#ifdef SCATTERING
|
|
935
|
+
#ifdef GEOMETRY_THIN_WALLED
|
|
936
|
+
vec3 scatterVector=normalW;
|
|
937
|
+
#else
|
|
938
|
+
#if defined(USEIRRADIANCEMAP) && defined(USE_IRRADIANCE_DOMINANT_DIRECTION)
|
|
939
|
+
vec3 scatterVector=mix(vReflectionDominantDirection,normalW,max3(iso_scatter_density));
|
|
940
|
+
#else
|
|
941
|
+
vec3 scatterVector=normalW;
|
|
942
|
+
#endif
|
|
943
|
+
scatterVector=mix(viewDirectionW,scatterVector,back_to_iso_scattering_blend);
|
|
944
|
+
#endif
|
|
945
|
+
#if defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING) && !defined(GEOMETRY_THIN_WALLED)
|
|
946
|
+
vec3 scatteredEnvironmentLight=scattered_light_from_irradiance_texture;
|
|
947
|
+
#else
|
|
948
|
+
vec3 scatteredEnvironmentLight=sampleIrradiance(
|
|
949
|
+
scatterVector
|
|
950
|
+
#if defined(NORMAL) && defined(USESPHERICALINVERTEX)
|
|
951
|
+
,vEnvironmentIrradiance
|
|
952
|
+
#endif
|
|
953
|
+
#if (defined(USESPHERICALFROMREFLECTIONMAP) && (!defined(NORMAL) || !defined(USESPHERICALINVERTEX))) || (defined(USEIRRADIANCEMAP) && defined(REFLECTIONMAP_3D))
|
|
954
|
+
,reflectionMatrix
|
|
955
|
+
#endif
|
|
956
|
+
#ifdef USEIRRADIANCEMAP
|
|
957
|
+
,irradianceSampler
|
|
958
|
+
#ifdef USE_IRRADIANCE_DOMINANT_DIRECTION
|
|
959
|
+
,vReflectionDominantDirection
|
|
960
|
+
#endif
|
|
961
|
+
#endif
|
|
962
|
+
#ifdef REALTIME_FILTERING
|
|
963
|
+
,vReflectionFilteringInfo
|
|
964
|
+
#ifdef IBL_CDF_FILTERING
|
|
965
|
+
,icdfSampler
|
|
966
|
+
#endif
|
|
967
|
+
#endif
|
|
968
|
+
,vReflectionInfos
|
|
969
|
+
,viewDirectionW
|
|
970
|
+
#if defined(GEOMETRY_THIN_WALLED)
|
|
971
|
+
,base_diffuse_roughness
|
|
972
|
+
,subsurface_color.rgb
|
|
973
|
+
#else
|
|
974
|
+
,1.0
|
|
975
|
+
,volumeParams.multi_scatter_color
|
|
976
|
+
#endif
|
|
977
|
+
);
|
|
978
|
+
#endif
|
|
979
|
+
#ifdef GEOMETRY_THIN_WALLED
|
|
980
|
+
vec3 forward_scattered_light=forwardScatteredEnvironmentLight*transmission_tint*volumeParams.multi_scatter_color;vec3 back_scattered_light=scatteredEnvironmentLight*volumeParams.multi_scatter_color;slab_translucent_base_ibl=mix(back_scattered_light,forward_scattered_light,0.5+0.5*volumeParams.anisotropy);
|
|
981
|
+
#else
|
|
982
|
+
vec3 forward_scattered_light=forwardScatteredEnvironmentLight*volume_absorption;vec3 back_scattered_light=mix(forward_scattered_light,scatteredEnvironmentLight*backscatter_color,iso_scatter_density);vec3 iso_scattered_light=mix(forward_scattered_light,scatteredEnvironmentLight*volumeParams.multi_scatter_color,iso_scatter_density);slab_translucent_base_ibl=mix(back_scattered_light,iso_scattered_light,back_to_iso_scattering_blend);slab_translucent_base_ibl=mix(slab_translucent_base_ibl,forward_scattered_light,iso_to_forward_scattering_blend)*transmission_tint;
|
|
983
|
+
#endif
|
|
984
|
+
#else
|
|
985
|
+
slab_translucent_base_ibl+=forwardScatteredEnvironmentLight*transmission_tint*volume_absorption;
|
|
986
|
+
#endif
|
|
987
|
+
#endif
|
|
988
|
+
#define CUSTOM_FRAGMENT_BEFORE_IBLLAYERCOMPOSITION
|
|
989
|
+
slab_diffuse_ibl*=ambient_occlusion;slab_metal_ibl*=specular_ambient_occlusion;slab_glossy_ibl*=specular_ambient_occlusion;slab_coat_ibl*=coat_specular_ambient_occlusion;vec3 material_dielectric_base_ibl=mix(slab_diffuse_ibl*base_color.rgb,slab_translucent_base_ibl,surface_translucency_weight);vec3 material_dielectric_gloss_ibl=material_dielectric_base_ibl*(1.0-dielectricIblFresnel)+slab_glossy_ibl*dielectricIblColoredFresnel;vec3 material_base_substrate_ibl=mix(material_dielectric_gloss_ibl,slab_metal_ibl,base_metalness);vec3 material_coated_base_ibl=layer(material_base_substrate_ibl,slab_coat_ibl,coatIblFresnel,coatAbsorption,vec3(1.0));
|
|
990
|
+
#if defined(FUZZ) && defined(FUZZENVIRONMENTBRDF)
|
|
991
|
+
slab_fuzz_ibl*=min(vec3(specular_ambient_occlusion),ambient_occlusion);material_surface_ibl=layer(material_coated_base_ibl,slab_fuzz_ibl,fuzzIblFresnel*fuzz_weight,vec3(1.0),fuzz_color);
|
|
992
|
+
#else
|
|
993
|
+
material_surface_ibl=material_coated_base_ibl;
|
|
994
|
+
#endif
|
|
995
|
+
#elif defined(REFRACTED_BACKGROUND)
|
|
996
|
+
vec3 black=vec3(0.0);vec3 slab_translucent_base_ibl=vec3(0.0);
|
|
997
|
+
#ifdef GEOMETRY_THIN_WALLED
|
|
998
|
+
#ifdef SCATTERING
|
|
999
|
+
vec3 forward_scattered_light=slab_translucent_background.rgb*transmission_tint*volumeParams.multi_scatter_color;slab_translucent_base_ibl=mix(black,forward_scattered_light,0.5+0.5*volumeParams.anisotropy);
|
|
1000
|
+
#else
|
|
1001
|
+
slab_translucent_base_ibl=slab_translucent_background.rgb*transmission_tint;
|
|
1002
|
+
#endif
|
|
1003
|
+
#else
|
|
1004
|
+
#ifdef SCATTERING
|
|
1005
|
+
vec3 forward_scattered_light=slab_translucent_background.rgb*volume_absorption;vec3 iso_scattered_light=(1.0-iso_scatter_density)*forward_scattered_light;slab_translucent_base_ibl=mix(black,iso_scattered_light,back_to_iso_scattering_blend);slab_translucent_base_ibl=mix(slab_translucent_base_ibl,forward_scattered_light,iso_to_forward_scattering_blend)*transmission_tint;
|
|
1006
|
+
#else
|
|
1007
|
+
slab_translucent_base_ibl=slab_translucent_background.rgb*volume_absorption*transmission_tint;
|
|
1008
|
+
#endif
|
|
1009
|
+
#endif
|
|
1010
|
+
vec3 material_dielectric_base_ibl=mix(black,slab_translucent_base_ibl.rgb,surface_translucency_weight);vec3 material_dielectric_gloss_ibl=material_dielectric_base_ibl*(baseGeoInfo.NdotV);vec3 material_base_substrate_ibl=mix(material_dielectric_gloss_ibl,black,base_metalness);vec3 material_coated_base_ibl=layer(material_base_substrate_ibl,black,coatIblFresnel,coatAbsorption,vec3(1.0));material_surface_ibl=material_coated_base_ibl;
|
|
1011
|
+
#endif
|
|
1012
|
+
`;
|
|
1013
|
+
e.IncludesShadersStore[E] || (e.IncludesShadersStore[E] = z);
|
|
1014
|
+
const p = "openpbrDirectLightingInit", U = `#ifdef LIGHT{X}
|
|
1015
|
+
preLightingInfo preInfo{X};preLightingInfo preInfoCoat{X};vec4 lightColor{X}=light{X}.vLightDiffuse;float shadow{X}=1.;
|
|
1016
|
+
#if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})
|
|
1017
|
+
#else
|
|
1018
|
+
#define CUSTOM_LIGHT{X}_COLOR
|
|
1019
|
+
#ifdef SPOTLIGHT{X}
|
|
1020
|
+
preInfo{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,vPositionW);preInfoCoat{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW,vPositionW);
|
|
1021
|
+
#elif defined(POINTLIGHT{X})
|
|
1022
|
+
preInfo{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,vPositionW);preInfoCoat{X}=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW,vPositionW);
|
|
1023
|
+
#elif defined(HEMILIGHT{X})
|
|
1024
|
+
preInfo{X}=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);preInfoCoat{X}=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW);
|
|
1025
|
+
#elif defined(DIRLIGHT{X})
|
|
1026
|
+
preInfo{X}=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);preInfoCoat{X}=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,coatNormalW);
|
|
1027
|
+
#elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
|
|
1028
|
+
preInfo{X}=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,normalW,vPositionW,light{X}.vLightData,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,specular_roughness);preInfoCoat{X}=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,coatNormalW,vPositionW,light{X}.vLightData,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,coat_roughness);
|
|
1029
|
+
#endif
|
|
1030
|
+
preInfo{X}.NdotV=baseGeoInfo.NdotV;preInfoCoat{X}.NdotV=coatGeoInfo.NdotV;
|
|
1031
|
+
#ifdef SPOTLIGHT{X}
|
|
1032
|
+
#ifdef LIGHT_FALLOFF_GLTF{X}
|
|
1033
|
+
preInfo{X}.attenuation=computeDistanceLightFalloff_GLTF(preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.y);
|
|
1034
|
+
#ifdef IESLIGHTTEXTURE{X}
|
|
1035
|
+
preInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});
|
|
1036
|
+
#else
|
|
1037
|
+
preInfo{X}.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
|
|
1038
|
+
#endif
|
|
1039
|
+
#elif defined(LIGHT_FALLOFF_PHYSICAL{X})
|
|
1040
|
+
preInfo{X}.attenuation=computeDistanceLightFalloff_Physical(preInfo{X}.lightDistanceSquared);
|
|
1041
|
+
#ifdef IESLIGHTTEXTURE{X}
|
|
1042
|
+
preInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});
|
|
1043
|
+
#else
|
|
1044
|
+
preInfo{X}.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightDirection.w);
|
|
1045
|
+
#endif
|
|
1046
|
+
#elif defined(LIGHT_FALLOFF_STANDARD{X})
|
|
1047
|
+
preInfo{X}.attenuation=computeDistanceLightFalloff_Standard(preInfo{X}.lightOffset,light{X}.vLightFalloff.x);
|
|
1048
|
+
#ifdef IESLIGHTTEXTURE{X}
|
|
1049
|
+
preInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});
|
|
1050
|
+
#else
|
|
1051
|
+
preInfo{X}.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightDirection.w,light{X}.vLightData.w);
|
|
1052
|
+
#endif
|
|
1053
|
+
#else
|
|
1054
|
+
preInfo{X}.attenuation=computeDistanceLightFalloff(preInfo{X}.lightOffset,preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);
|
|
1055
|
+
#ifdef IESLIGHTTEXTURE{X}
|
|
1056
|
+
preInfo{X}.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo{X}.L,iesLightTexture{X});
|
|
1057
|
+
#else
|
|
1058
|
+
preInfo{X}.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo{X}.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
|
|
1059
|
+
#endif
|
|
1060
|
+
#endif
|
|
1061
|
+
#elif defined(POINTLIGHT{X})
|
|
1062
|
+
#ifdef LIGHT_FALLOFF_GLTF{X}
|
|
1063
|
+
preInfo{X}.attenuation=computeDistanceLightFalloff_GLTF(preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.y);
|
|
1064
|
+
#elif defined(LIGHT_FALLOFF_PHYSICAL{X})
|
|
1065
|
+
preInfo{X}.attenuation=computeDistanceLightFalloff_Physical(preInfo{X}.lightDistanceSquared);
|
|
1066
|
+
#elif defined(LIGHT_FALLOFF_STANDARD{X})
|
|
1067
|
+
preInfo{X}.attenuation=computeDistanceLightFalloff_Standard(preInfo{X}.lightOffset,light{X}.vLightFalloff.x);
|
|
1068
|
+
#else
|
|
1069
|
+
preInfo{X}.attenuation=computeDistanceLightFalloff(preInfo{X}.lightOffset,preInfo{X}.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);
|
|
1070
|
+
#endif
|
|
1071
|
+
#else
|
|
1072
|
+
preInfo{X}.attenuation=1.0;
|
|
1073
|
+
#endif
|
|
1074
|
+
preInfoCoat{X}.attenuation=preInfo{X}.attenuation;
|
|
1075
|
+
#if defined(HEMILIGHT{X})
|
|
1076
|
+
preInfo{X}.roughness=specular_roughness;preInfoCoat{X}.roughness=coat_roughness;
|
|
1077
|
+
#elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
|
|
1078
|
+
preInfo{X}.roughness=specular_roughness;preInfoCoat{X}.roughness=coat_roughness;
|
|
1079
|
+
#else
|
|
1080
|
+
preInfo{X}.roughness=adjustRoughnessFromLightProperties(specular_roughness,light{X}.vLightSpecular.a,preInfo{X}.lightDistance);preInfoCoat{X}.roughness=adjustRoughnessFromLightProperties(coat_roughness,light{X}.vLightSpecular.a,preInfoCoat{X}.lightDistance);
|
|
1081
|
+
#endif
|
|
1082
|
+
preInfo{X}.diffuseRoughness=base_diffuse_roughness;preInfo{X}.surfaceAlbedo=base_color.rgb;
|
|
1083
|
+
#endif
|
|
1084
|
+
#endif
|
|
1085
|
+
`;
|
|
1086
|
+
e.IncludesShadersStore[p] || (e.IncludesShadersStore[p] = U);
|
|
1087
|
+
const h = "openpbrDirectLighting", W = `#ifdef LIGHT{X}
|
|
1088
|
+
{vec3 slab_diffuse=vec3(0.,0.,0.);vec3 slab_translucent=vec3(0.,0.,0.);vec3 slab_glossy=vec3(0.,0.,0.);float specularFresnel=0.0;vec3 specularColoredFresnel=vec3(0.,0.,0.);vec3 slab_metal=vec3(0.,0.,0.);vec3 slab_coat=vec3(0.,0.,0.);float coatFresnel=0.0;vec3 slab_fuzz=vec3(0.,0.,0.);float fuzzFresnel=0.0;
|
|
1089
|
+
#ifdef HEMILIGHT{X}
|
|
1090
|
+
slab_diffuse=computeHemisphericDiffuseLighting(preInfo{X},lightColor{X}.rgb,light{X}.vLightGround);
|
|
1091
|
+
#elif defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
|
|
1092
|
+
slab_diffuse=computeAreaDiffuseLighting(preInfo{X},lightColor{X}.rgb);
|
|
1093
|
+
#else
|
|
1094
|
+
slab_diffuse=computeDiffuseLighting(preInfo{X},lightColor{X}.rgb);
|
|
1095
|
+
#endif
|
|
1096
|
+
#ifdef PROJECTEDLIGHTTEXTURE{X}
|
|
1097
|
+
slab_diffuse*=computeProjectionTextureDiffuseLighting(projectionLightTexture{X},textureProjectionMatrix{X},vPositionW);
|
|
1098
|
+
#endif
|
|
1099
|
+
#ifdef FUZZ
|
|
1100
|
+
float fuzzNdotH=max(dot(fuzzNormalW,preInfo{X}.H),0.0);vec3 fuzzBrdf=getFuzzBRDFLookup(fuzzNdotH,sqrt(fuzz_roughness));
|
|
1101
|
+
#endif
|
|
1102
|
+
#ifdef THIN_FILM
|
|
1103
|
+
float thin_film_desaturation_scale=(thin_film_ior-1.0)*sqrt(thin_film_thickness*0.001);
|
|
1104
|
+
#endif
|
|
1105
|
+
#if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
|
|
1106
|
+
slab_glossy=computeAreaSpecularLighting(preInfo{X},light{X}.vLightSpecular.rgb,baseConductorReflectance.F0,baseConductorReflectance.F90);
|
|
1107
|
+
#else
|
|
1108
|
+
{
|
|
1109
|
+
#ifdef ANISOTROPIC_BASE
|
|
1110
|
+
slab_glossy=computeAnisotropicSpecularLighting(preInfo{X},viewDirectionW,normalW,
|
|
1111
|
+
baseGeoInfo.anisotropicTangent,baseGeoInfo.anisotropicBitangent,baseGeoInfo.anisotropy,
|
|
1112
|
+
0.0,lightColor{X}.rgb);
|
|
1113
|
+
#else
|
|
1114
|
+
slab_glossy=computeSpecularLighting(preInfo{X},normalW,vec3(1.0),vec3(1.0),specular_roughness,lightColor{X}.rgb);
|
|
1115
|
+
#endif
|
|
1116
|
+
specularFresnel=fresnelSchlickGGX(preInfo{X}.VdotH,baseDielectricReflectance.F0,baseDielectricReflectance.F90);specularColoredFresnel=specularFresnel*specular_color;
|
|
1117
|
+
#ifdef THIN_FILM
|
|
1118
|
+
vec3 thinFilmDielectricFresnel=evalIridescence(thin_film_outside_ior,thin_film_ior,preInfo{X}.VdotH,thin_film_thickness,vec3(baseDielectricReflectance.F0));thinFilmDielectricFresnel=mix(thinFilmDielectricFresnel,vec3(dot(thinFilmDielectricFresnel,vec3(0.3333))),thin_film_desaturation_scale);specularColoredFresnel=mix(specularColoredFresnel,thinFilmDielectricFresnel*specular_color,thin_film_weight*thin_film_ior_scale);
|
|
1119
|
+
#endif
|
|
1120
|
+
}
|
|
1121
|
+
#endif
|
|
1122
|
+
#ifdef REFRACTED_LIGHTS
|
|
1123
|
+
vec3 forwardScatteredLight=vec3(0.0);
|
|
1124
|
+
#if AREALIGHT{X}
|
|
1125
|
+
#else
|
|
1126
|
+
{preLightingInfo preInfoTrans=preInfo{X};
|
|
1127
|
+
#ifdef SCATTERING
|
|
1128
|
+
preInfoTrans.roughness=sqrt(sqrt(max(transmission_roughness_alpha,0.05)));
|
|
1129
|
+
#else
|
|
1130
|
+
preInfoTrans.roughness=transmission_roughness;
|
|
1131
|
+
#endif
|
|
1132
|
+
if (preInfoTrans.NdotLUnclamped<=0.0) {specularFresnel=0.0;specularColoredFresnel=specularFresnel*specular_color;}
|
|
1133
|
+
#ifdef GEOMETRY_THIN_WALLED
|
|
1134
|
+
vec3 refractNormalW=viewDirectionW;
|
|
1135
|
+
#else
|
|
1136
|
+
vec3 refractNormalW=normalW;
|
|
1137
|
+
#endif
|
|
1138
|
+
preInfoTrans.NdotL=0.5*max(dot(-refractNormalW,preInfoTrans.L),0.0)+0.5;
|
|
1139
|
+
#if defined(DISPERSION) && !defined(GEOMETRY_THIN_WALLED)
|
|
1140
|
+
float diff=min(dispersion_iors[2]-dispersion_iors[0],max(dispersion_iors[0]-1.0,1.0));dispersion_iors[2]+=diff;dispersion_iors[0]-=diff;for (int i=0; i<3; i++) {float eta=1.0/dispersion_iors[i];
|
|
1141
|
+
#elif defined(GEOMETRY_THIN_WALLED)
|
|
1142
|
+
float eta=1.0;
|
|
1143
|
+
#else
|
|
1144
|
+
float eta=1.0/specular_ior;
|
|
1145
|
+
#endif
|
|
1146
|
+
preInfoTrans.H=preInfoTrans.L+min(eta,0.95)*viewDirectionW;float len2=dot(preInfoTrans.H,preInfoTrans.H);if (len2<1e-6) {preInfoTrans.H=preInfoTrans.L;} else {preInfoTrans.H=preInfoTrans.H*inversesqrt(len2);}
|
|
1147
|
+
#ifdef ANISOTROPIC_BASE
|
|
1148
|
+
preInfoTrans.H=-preInfoTrans.H;
|
|
1149
|
+
#endif
|
|
1150
|
+
preInfoTrans.VdotH=dot(viewDirectionW,preInfoTrans.H);
|
|
1151
|
+
#if defined(DISPERSION) && !defined(GEOMETRY_THIN_WALLED)
|
|
1152
|
+
forwardScatteredLight[i]+=
|
|
1153
|
+
#else
|
|
1154
|
+
forwardScatteredLight+=
|
|
1155
|
+
#endif
|
|
1156
|
+
#if defined(ANISOTROPIC_BASE)
|
|
1157
|
+
computeAnisotropicSpecularLighting(preInfoTrans,viewDirectionW,refractNormalW,
|
|
1158
|
+
baseGeoInfo.anisotropicTangent,baseGeoInfo.anisotropicBitangent,baseGeoInfo.anisotropy,
|
|
1159
|
+
transmission_roughness_alpha,lightColor{X}.rgb
|
|
1160
|
+
#else
|
|
1161
|
+
computeSpecularLighting(preInfoTrans,-refractNormalW,vec3(1.0),vec3(1.0),transmission_roughness_alpha,lightColor{X}.rgb
|
|
1162
|
+
#endif
|
|
1163
|
+
#if defined(DISPERSION) && !defined(GEOMETRY_THIN_WALLED)
|
|
1164
|
+
)[i];}
|
|
1165
|
+
#else
|
|
1166
|
+
);
|
|
1167
|
+
#endif
|
|
1168
|
+
#if !defined(GEOMETRY_THIN_WALLED)
|
|
1169
|
+
forwardScatteredLight=mix(forwardScatteredLight,0.25*preInfoTrans.attenuation*lightColor{X}.rgb,clamp(1.0-pow(baseGeoInfo.NdotV,transmission_roughness_alpha),0.0,1.0));
|
|
1170
|
+
#endif
|
|
1171
|
+
#ifdef REFRACTED_BACKGROUND
|
|
1172
|
+
#ifdef GEOMETRY_THIN_WALLED
|
|
1173
|
+
forwardScatteredLight=mix(vec3(0.0),forwardScatteredLight.rgb,0.2*transmission_roughness_alpha);
|
|
1174
|
+
#else
|
|
1175
|
+
forwardScatteredLight=max(vec3(0.0),mix(vec3(0.0),forwardScatteredLight,transmission_roughness_alpha));
|
|
1176
|
+
#endif
|
|
1177
|
+
#endif
|
|
1178
|
+
#ifdef SCATTERING
|
|
1179
|
+
#if !defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING) || defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING_GBUFFER)
|
|
1180
|
+
preInfoTrans.roughness=1.0;vec3 diffused_forward_scattered_light=computeSpecularLighting(preInfoTrans,normalW,vec3(1.0),vec3(1.0),1.0,lightColor{X}.rgb)*volume_absorption;
|
|
1181
|
+
#endif
|
|
1182
|
+
#ifdef GEOMETRY_THIN_WALLED
|
|
1183
|
+
vec3 forward_scattered_light=forwardScatteredLight*transmission_tint*volumeParams.multi_scatter_color;vec3 back_scattered_light=slab_diffuse*volumeParams.multi_scatter_color;slab_translucent=mix(back_scattered_light,forward_scattered_light,0.5+0.5*volumeParams.anisotropy);
|
|
1184
|
+
#else
|
|
1185
|
+
vec3 back_scattered_normal=normalize(normalW+viewDirectionW);preInfoTrans.NdotL=max(dot(back_scattered_normal,preInfoTrans.L),0.0);preInfoTrans.NdotV=dot(back_scattered_normal,viewDirectionW);preInfoTrans.H=normalize(viewDirectionW+preInfoTrans.L);preInfoTrans.VdotH=clamp(dot(viewDirectionW,preInfoTrans.H),0.0,1.0);preInfoTrans.roughness=0.2;vec3 back_scattered_light=computeSpecularLighting(preInfoTrans,viewDirectionW,vec3(1.0),vec3(0.08),0.0,lightColor{X}.rgb);vec3 forward_scattered_light=(forwardScatteredLight*volume_absorption);vec3 iso_scattered_light=slab_diffuse;vec3 back_scattering=mix(forward_scattered_light,forward_scattered_light+back_scattered_light*backscatter_color,iso_scatter_density);
|
|
1186
|
+
#if defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING) && !defined(USE_IRRADIANCE_TEXTURE_FOR_SCATTERING_GBUFFER)
|
|
1187
|
+
vec3 iso_scattering=mix(forward_scattered_light,scattered_light_from_irradiance_texture*volumeParams.multi_scatter_color,iso_scatter_density);
|
|
1188
|
+
#else
|
|
1189
|
+
vec3 iso_scattering=mix(forward_scattered_light,(diffused_forward_scattered_light+iso_scattered_light)*volumeParams.multi_scatter_color,iso_scatter_density);
|
|
1190
|
+
#endif
|
|
1191
|
+
slab_translucent=mix(back_scattering,iso_scattering,back_to_iso_scattering_blend);slab_translucent=mix(slab_translucent,forward_scattered_light,iso_to_forward_scattering_blend)*transmission_tint;
|
|
1192
|
+
#endif
|
|
1193
|
+
#else
|
|
1194
|
+
slab_translucent=forwardScatteredLight*transmission_tint*volume_absorption;
|
|
1195
|
+
#endif
|
|
1196
|
+
}
|
|
1197
|
+
#endif
|
|
1198
|
+
#endif
|
|
1199
|
+
#if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
|
|
1200
|
+
slab_metal=computeAreaSpecularLighting(preInfo{X},light{X}.vLightSpecular.rgb,baseConductorReflectance.F0,baseConductorReflectance.F90);
|
|
1201
|
+
#else
|
|
1202
|
+
{
|
|
1203
|
+
#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR)
|
|
1204
|
+
vec3 coloredFresnel=getF82Specular(preInfo{X}.VdotH,baseConductorReflectance.coloredF0,baseConductorReflectance.coloredF90,specular_roughness);
|
|
1205
|
+
#else
|
|
1206
|
+
vec3 coloredFresnel=fresnelSchlickGGX(preInfo{X}.VdotH,baseConductorReflectance.coloredF0,baseConductorReflectance.coloredF90);
|
|
1207
|
+
#endif
|
|
1208
|
+
#ifdef THIN_FILM
|
|
1209
|
+
float thinFilmConductorAngle=max(preInfo{X}.VdotH,specular_roughness);vec3 thinFilmConductorFresnel=evalIridescence(thin_film_outside_ior,thin_film_ior,thinFilmConductorAngle,thin_film_thickness,baseConductorReflectance.coloredF0);thinFilmConductorFresnel=mix(thinFilmConductorFresnel,vec3(dot(thinFilmConductorFresnel,vec3(0.3333))),thin_film_desaturation_scale);coloredFresnel=mix(coloredFresnel,specular_weight*thinFilmConductorFresnel,thin_film_weight*thin_film_ior_scale);
|
|
1210
|
+
#endif
|
|
1211
|
+
#ifdef ANISOTROPIC_BASE
|
|
1212
|
+
slab_metal=computeAnisotropicSpecularLighting(preInfo{X},viewDirectionW,normalW,baseGeoInfo.anisotropicTangent,baseGeoInfo.anisotropicBitangent,baseGeoInfo.anisotropy,0.0,lightColor{X}.rgb);
|
|
1213
|
+
#else
|
|
1214
|
+
slab_metal=computeSpecularLighting(preInfo{X},normalW,vec3(1.0),coloredFresnel,specular_roughness,lightColor{X}.rgb);
|
|
1215
|
+
#endif
|
|
1216
|
+
}
|
|
1217
|
+
#endif
|
|
1218
|
+
#if defined(AREALIGHT{X}) && defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
|
|
1219
|
+
slab_coat=computeAreaSpecularLighting(preInfoCoat{X},light{X}.vLightSpecular.rgb,coatReflectance.F0,coatReflectance.F90);
|
|
1220
|
+
#else
|
|
1221
|
+
{
|
|
1222
|
+
#ifdef ANISOTROPIC_COAT
|
|
1223
|
+
slab_coat=computeAnisotropicSpecularLighting(preInfoCoat{X},viewDirectionW,coatNormalW,
|
|
1224
|
+
coatGeoInfo.anisotropicTangent,coatGeoInfo.anisotropicBitangent,coatGeoInfo.anisotropy,
|
|
1225
|
+
0.0,lightColor{X}.rgb);
|
|
1226
|
+
#else
|
|
1227
|
+
slab_coat=computeSpecularLighting(preInfoCoat{X},coatNormalW,vec3(coatReflectance.F0),vec3(1.0),coat_roughness,lightColor{X}.rgb);
|
|
1228
|
+
#endif
|
|
1229
|
+
float NdotH=max(dot(coatNormalW,preInfoCoat{X}.H),0.0);coatFresnel=fresnelSchlickGGX(NdotH,coatReflectance.F0,coatReflectance.F90);}
|
|
1230
|
+
#endif
|
|
1231
|
+
vec3 coatAbsorption=vec3(1.0);if (coat_weight>0.0) {float cosTheta_view=max(preInfoCoat{X}.NdotV,0.001);float cosTheta_light=max(preInfoCoat{X}.NdotL,0.001);float fresnel_view=coatReflectance.F0+(1.0-coatReflectance.F0)*pow(1.0-cosTheta_view,5.0);float fresnel_light=coatReflectance.F0+(1.0-coatReflectance.F0)*pow(1.0-cosTheta_light,5.0);float averageReflectance=(fresnel_view+fresnel_light)*0.5;float darkened_transmission=(1.0-averageReflectance)/(1.0+averageReflectance);darkened_transmission=mix(1.0,darkened_transmission,coat_darkening);float sin2=1.0-cosTheta_view*cosTheta_view;sin2=sin2/(coat_ior*coat_ior)*coat_weight;float cos_t=sqrt(1.0-sin2);float coatPathLength=1.0/cos_t;float effectivePathLength=coatPathLength*coat_weight;vec3 colored_transmission=pow(coat_color,vec3(effectivePathLength));coatAbsorption=colored_transmission*mix(1.0,darkened_transmission,coat_weight);}
|
|
1232
|
+
#ifdef FUZZ
|
|
1233
|
+
fuzzFresnel=fuzzBrdf.z;vec3 fuzzNormalW=mix(normalW,coatNormalW,coat_weight);float fuzzNdotV=max(dot(fuzzNormalW,viewDirectionW.xyz),0.0);float fuzzNdotL=max(dot(fuzzNormalW,preInfo{X}.L),0.0);slab_fuzz=lightColor{X}.rgb*preInfo{X}.attenuation*evalFuzz(preInfo{X}.L,fuzzNdotL,fuzzNdotV,fuzzTangent,fuzzBitangent,fuzzBrdf);
|
|
1234
|
+
#else
|
|
1235
|
+
vec3 fuzz_color=vec3(0.0);
|
|
1236
|
+
#endif
|
|
1237
|
+
#ifdef PREPASS_IRRADIANCE
|
|
1238
|
+
total_direct_diffuse+=slab_diffuse;
|
|
1239
|
+
#endif
|
|
1240
|
+
vec3 material_dielectric_base=mix(slab_diffuse*base_color.rgb,slab_translucent,surface_translucency_weight);vec3 material_dielectric_gloss=material_dielectric_base*(1.0-specularFresnel)+slab_glossy*specularColoredFresnel;vec3 material_base_substrate=mix(material_dielectric_gloss,slab_metal,base_metalness);vec3 material_coated_base=layer(material_base_substrate,slab_coat,coatFresnel,coatAbsorption,vec3(1.0));material_surface_direct+=layer(material_coated_base,slab_fuzz,fuzzFresnel*fuzz_weight,vec3(1.0),fuzz_color);}
|
|
1241
|
+
#endif
|
|
1242
|
+
`;
|
|
1243
|
+
e.IncludesShadersStore[h] || (e.IncludesShadersStore[h] = W);
|
|
1244
|
+
const R = "openpbrBlockPrePass", X = `#if SCENE_MRT_COUNT>0
|
|
1245
|
+
float writeGeometryInfo=finalColor.a>ALPHATESTVALUE ? 1.0 : 0.0;
|
|
1246
|
+
#ifdef PREPASS_POSITION
|
|
1247
|
+
gl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,writeGeometryInfo);
|
|
1248
|
+
#endif
|
|
1249
|
+
#ifdef PREPASS_LOCAL_POSITION
|
|
1250
|
+
gl_FragData[PREPASS_LOCAL_POSITION_INDEX]=vec4(vPosition,writeGeometryInfo);
|
|
1251
|
+
#endif
|
|
1252
|
+
#if defined(PREPASS_VELOCITY)
|
|
1253
|
+
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[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,writeGeometryInfo);
|
|
1254
|
+
#elif defined(PREPASS_VELOCITY_LINEAR)
|
|
1255
|
+
vec2 velocity=vec2(0.5)*((vPreviousPosition.xy/vPreviousPosition.w)-(vCurrentPosition.xy/vCurrentPosition.w));gl_FragData[PREPASS_VELOCITY_LINEAR_INDEX]=vec4(velocity,0.0,writeGeometryInfo);
|
|
1256
|
+
#endif
|
|
1257
|
+
#ifdef PREPASS_ALBEDO
|
|
1258
|
+
gl_FragData[PREPASS_ALBEDO_INDEX]=vec4(base_color,writeGeometryInfo);
|
|
1259
|
+
#endif
|
|
1260
|
+
#ifdef PREPASS_ALBEDO_SQRT
|
|
1261
|
+
vec3 sqAlbedo=sqrt(base_color);
|
|
1262
|
+
#endif
|
|
1263
|
+
#ifdef PREPASS_IRRADIANCE
|
|
1264
|
+
vec3 irradiance=total_direct_diffuse;
|
|
1265
|
+
#ifndef UNLIT
|
|
1266
|
+
#ifdef REFLECTION
|
|
1267
|
+
irradiance+=slab_diffuse_ibl;
|
|
1268
|
+
#endif
|
|
1269
|
+
#endif
|
|
1270
|
+
#ifdef SCATTERING
|
|
1271
|
+
float scatter_mask=min(subsurface_weight+transmission_weight,1.0);
|
|
1272
|
+
#else
|
|
1273
|
+
float scatter_mask=0.0;
|
|
1274
|
+
#endif
|
|
1275
|
+
gl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(irradiance,writeGeometryInfo*scatter_mask);
|
|
1276
|
+
#endif
|
|
1277
|
+
#if defined(PREPASS_COLOR)
|
|
1278
|
+
gl_FragData[PREPASS_COLOR_INDEX]=vec4(finalColor.rgb,finalColor.a);
|
|
1279
|
+
#endif
|
|
1280
|
+
#ifdef PREPASS_DEPTH
|
|
1281
|
+
gl_FragData[PREPASS_DEPTH_INDEX]=vec4(vViewPos.z,0.0,0.0,writeGeometryInfo);
|
|
1282
|
+
#endif
|
|
1283
|
+
#ifdef PREPASS_SCREENSPACE_DEPTH
|
|
1284
|
+
gl_FragData[PREPASS_SCREENSPACE_DEPTH_INDEX]=vec4(gl_FragCoord.z,0.0,0.0,writeGeometryInfo);
|
|
1285
|
+
#endif
|
|
1286
|
+
#ifdef PREPASS_NORMALIZED_VIEW_DEPTH
|
|
1287
|
+
gl_FragData[PREPASS_NORMALIZED_VIEW_DEPTH_INDEX]=vec4(vNormViewDepth,0.0,0.0,writeGeometryInfo);
|
|
1288
|
+
#endif
|
|
1289
|
+
#ifdef PREPASS_NORMAL
|
|
1290
|
+
#ifdef PREPASS_NORMAL_WORLDSPACE
|
|
1291
|
+
gl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalW,writeGeometryInfo);
|
|
1292
|
+
#else
|
|
1293
|
+
gl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalize((view*vec4(normalW,0.0)).rgb),writeGeometryInfo);
|
|
1294
|
+
#endif
|
|
1295
|
+
#endif
|
|
1296
|
+
#ifdef PREPASS_WORLD_NORMAL
|
|
1297
|
+
gl_FragData[PREPASS_WORLD_NORMAL_INDEX]=vec4(normalW*0.5+0.5,writeGeometryInfo);
|
|
1298
|
+
#endif
|
|
1299
|
+
#ifdef PREPASS_ALBEDO_SQRT
|
|
1300
|
+
gl_FragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4(sqAlbedo,writeGeometryInfo);
|
|
1301
|
+
#endif
|
|
1302
|
+
#ifdef PREPASS_REFLECTIVITY
|
|
1303
|
+
#ifndef UNLIT
|
|
1304
|
+
gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(specularEnvironmentR0,microSurface)*writeGeometryInfo;
|
|
1305
|
+
#else
|
|
1306
|
+
gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4( 0.0,0.0,0.0,1.0 )*writeGeometryInfo;
|
|
1307
|
+
#endif
|
|
1308
|
+
#endif
|
|
1309
|
+
#endif
|
|
1310
|
+
`;
|
|
1311
|
+
e.IncludesShadersStore[R] || (e.IncludesShadersStore[R] = X);
|
|
1312
|
+
const i = "openpbrPixelShader", I = `#define OPENPBR_FRAGMENT_SHADER
|
|
1313
|
+
#define CUSTOM_FRAGMENT_EXTENSION
|
|
1314
|
+
#if defined(GEOMETRY_NORMAL) || defined(GEOMETRY_COAT_NORMAL) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA)
|
|
1315
|
+
#extension GL_OES_standard_derivatives : enable
|
|
1316
|
+
#endif
|
|
1317
|
+
#ifdef LODBASEDMICROSFURACE
|
|
1318
|
+
#extension GL_EXT_shader_texture_lod : enable
|
|
1319
|
+
#endif
|
|
1320
|
+
#define CUSTOM_FRAGMENT_BEGIN
|
|
1321
|
+
#ifdef LOGARITHMICDEPTH
|
|
1322
|
+
#extension GL_EXT_frag_depth : enable
|
|
1323
|
+
#endif
|
|
1324
|
+
#include<prePassDeclaration>[SCENE_MRT_COUNT]
|
|
1325
|
+
precision highp float;
|
|
1326
|
+
#include<oitDeclaration>
|
|
1327
|
+
#ifndef FROMLINEARSPACE
|
|
1328
|
+
#define FROMLINEARSPACE
|
|
1329
|
+
#endif
|
|
1330
|
+
#include<__decl__openpbrFragment>
|
|
1331
|
+
#include<pbrFragmentExtraDeclaration>
|
|
1332
|
+
#include<__decl__lightFragment>[0..maxSimultaneousLights]
|
|
1333
|
+
#include<openpbrFragmentSamplersDeclaration>
|
|
1334
|
+
#include<imageProcessingDeclaration>
|
|
1335
|
+
#include<clipPlaneFragmentDeclaration>
|
|
1336
|
+
#include<logDepthDeclaration>
|
|
1337
|
+
#include<fogFragmentDeclaration>
|
|
1338
|
+
#include<textureRepetitionFunctions>
|
|
1339
|
+
#include<helperFunctions>
|
|
1340
|
+
#include<subSurfaceScatteringFunctions>
|
|
1341
|
+
#include<importanceSampling>
|
|
1342
|
+
#include<pbrHelperFunctions>
|
|
1343
|
+
#include<imageProcessingFunctions>
|
|
1344
|
+
#include<shadowsFragmentFunctions>
|
|
1345
|
+
#include<harmonicsFunctions>
|
|
1346
|
+
#include<pbrDirectLightingSetupFunctions>
|
|
1347
|
+
#include<pbrDirectLightingFalloffFunctions>
|
|
1348
|
+
#include<pbrBRDFFunctions>
|
|
1349
|
+
#include<hdrFilteringFunctions>
|
|
1350
|
+
#include<pbrDirectLightingFunctions>
|
|
1351
|
+
#include<pbrIBLFunctions>
|
|
1352
|
+
#include<openpbrNormalMapFragmentMainFunctions>
|
|
1353
|
+
#include<openpbrNormalMapFragmentFunctions>
|
|
1354
|
+
#ifdef REFLECTION
|
|
1355
|
+
#include<reflectionFunction>
|
|
1356
|
+
#endif
|
|
1357
|
+
#define CUSTOM_FRAGMENT_DEFINITIONS
|
|
1358
|
+
#include<openpbrDielectricReflectance>
|
|
1359
|
+
#include<openpbrConductorReflectance>
|
|
1360
|
+
#include<openpbrAmbientOcclusionFunctions>
|
|
1361
|
+
#include<openpbrGeometryInfo>
|
|
1362
|
+
#include<openpbrIblFunctions>
|
|
1363
|
+
#include<openpbrVolumeFunctions>
|
|
1364
|
+
vec3 layer(vec3 slab_bottom,vec3 slab_top,float lerp_factor,vec3 bottom_multiplier,vec3 top_multiplier) {return mix(slab_bottom*bottom_multiplier,slab_top*top_multiplier,lerp_factor);}
|
|
1365
|
+
void main(void) {
|
|
1366
|
+
#ifdef PREPASS_IRRADIANCE
|
|
1367
|
+
vec3 total_direct_diffuse=vec3(0.0);
|
|
1368
|
+
#endif
|
|
1369
|
+
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
|
1370
|
+
#include<clipPlaneFragment>
|
|
1371
|
+
#include<pbrBlockNormalGeometric>
|
|
1372
|
+
vec3 coatNormalW=normalW;
|
|
1373
|
+
#include<openpbrNormalMapFragment>
|
|
1374
|
+
#include<openpbrBlockNormalFinal>
|
|
1375
|
+
#include<openpbrBaseLayerData>
|
|
1376
|
+
#include<openpbrTransmissionLayerData>
|
|
1377
|
+
#include<openpbrSubsurfaceLayerData>
|
|
1378
|
+
#include<openpbrCoatLayerData>
|
|
1379
|
+
#include<openpbrThinFilmLayerData>
|
|
1380
|
+
#include<openpbrFuzzLayerData>
|
|
1381
|
+
#include<openpbrAmbientOcclusionData>
|
|
1382
|
+
#define CUSTOM_FRAGMENT_UPDATE_ALPHA
|
|
1383
|
+
#include<depthPrePass>
|
|
1384
|
+
#define CUSTOM_FRAGMENT_BEFORE_LIGHTS
|
|
1385
|
+
#ifdef ANISOTROPIC_COAT
|
|
1386
|
+
geometryInfoAnisoOutParams coatGeoInfo=geometryInfoAniso(
|
|
1387
|
+
coatNormalW,viewDirectionW.xyz,coat_roughness,geometricNormalW
|
|
1388
|
+
,vec3(geometry_coat_tangent.x,geometry_coat_tangent.y,coat_roughness_anisotropy),TBN
|
|
1389
|
+
);
|
|
1390
|
+
#else
|
|
1391
|
+
geometryInfoOutParams coatGeoInfo=geometryInfo(
|
|
1392
|
+
coatNormalW,viewDirectionW.xyz,coat_roughness,geometricNormalW
|
|
1393
|
+
);
|
|
1394
|
+
#endif
|
|
1395
|
+
specular_roughness=mix(specular_roughness,pow(min(1.0,pow(specular_roughness,4.0)+2.0*pow(coat_roughness,4.0)),0.25),coat_weight);
|
|
1396
|
+
#ifdef ANISOTROPIC_BASE
|
|
1397
|
+
geometryInfoAnisoOutParams baseGeoInfo=geometryInfoAniso(
|
|
1398
|
+
normalW,viewDirectionW.xyz,specular_roughness,geometricNormalW
|
|
1399
|
+
,vec3(geometry_tangent.x,geometry_tangent.y,specular_roughness_anisotropy),TBN
|
|
1400
|
+
);
|
|
1401
|
+
#else
|
|
1402
|
+
geometryInfoOutParams baseGeoInfo=geometryInfo(
|
|
1403
|
+
normalW,viewDirectionW.xyz,specular_roughness,geometricNormalW
|
|
1404
|
+
);
|
|
1405
|
+
#endif
|
|
1406
|
+
#ifdef FUZZ
|
|
1407
|
+
vec3 fuzzNormalW=normalize(mix(normalW,coatNormalW,coat_weight));vec3 fuzzTangent=normalize(TBN[0]);fuzzTangent=normalize(fuzzTangent-dot(fuzzTangent,fuzzNormalW)*fuzzNormalW);vec3 fuzzBitangent=cross(fuzzNormalW,fuzzTangent);geometryInfoOutParams fuzzGeoInfo=geometryInfo(
|
|
1408
|
+
fuzzNormalW,viewDirectionW.xyz,fuzz_roughness,geometricNormalW
|
|
1409
|
+
);
|
|
1410
|
+
#endif
|
|
1411
|
+
ReflectanceParams coatReflectance;coatReflectance=dielectricReflectance(
|
|
1412
|
+
coat_ior
|
|
1413
|
+
,1.0
|
|
1414
|
+
,vec3(1.0)
|
|
1415
|
+
,coat_weight
|
|
1416
|
+
);
|
|
1417
|
+
#ifdef THIN_FILM
|
|
1418
|
+
float thin_film_outside_ior=mix(1.0,coat_ior,coat_weight);
|
|
1419
|
+
#endif
|
|
1420
|
+
ReflectanceParams baseDielectricReflectance;{float effectiveCoatIor=mix(1.0,coat_ior,coat_weight);baseDielectricReflectance=dielectricReflectance(
|
|
1421
|
+
specular_ior
|
|
1422
|
+
,effectiveCoatIor
|
|
1423
|
+
,specular_color
|
|
1424
|
+
,specular_weight
|
|
1425
|
+
);}
|
|
1426
|
+
ReflectanceParams baseConductorReflectance;baseConductorReflectance=conductorReflectance(base_color,specular_color,specular_weight);vec3 volume_absorption=vec3(1.0);vec3 transmission_tint=vec3(1.0);float surface_translucency_weight=0.0;
|
|
1427
|
+
#if defined(REFRACTED_BACKGROUND) || defined(REFRACTED_ENVIRONMENT) || defined(REFRACTED_LIGHTS)
|
|
1428
|
+
#if defined(GEOMETRY_THIN_WALLED)
|
|
1429
|
+
vec3 refractedViewVector=-viewDirectionW;
|
|
1430
|
+
#else
|
|
1431
|
+
#ifdef DISPERSION
|
|
1432
|
+
vec3 refractedViewVectors[3];float iorDispersionSpread=transmission_dispersion_scale/transmission_dispersion_abbe_number*(specular_ior-1.0);vec3 dispersion_iors=vec3(specular_ior-iorDispersionSpread,specular_ior,specular_ior+iorDispersionSpread);for (int i=0; i<3; i++) {refractedViewVectors[i]=double_refract(-viewDirectionW,normalW,dispersion_iors[i]); }
|
|
1433
|
+
#else
|
|
1434
|
+
vec3 refractedViewVector=double_refract(-viewDirectionW,normalW,specular_ior);
|
|
1435
|
+
#endif
|
|
1436
|
+
#endif
|
|
1437
|
+
#ifdef GEOMETRY_THIN_WALLED
|
|
1438
|
+
float transmission_roughness=specular_roughness;
|
|
1439
|
+
#else
|
|
1440
|
+
float transmission_roughness=specular_roughness*clamp(4.0*(specular_ior-1.0),0.001,1.0);
|
|
1441
|
+
#endif
|
|
1442
|
+
#if (defined(TRANSMISSION_SLAB) || defined(SUBSURFACE_SLAB))
|
|
1443
|
+
OpenPBRHomogeneousVolume volumeParams;{
|
|
1444
|
+
#if defined(TRANSMISSION_SLAB)
|
|
1445
|
+
OpenPBRHomogeneousVolume transmissionVolumeParams=computeOpenPBRTransmissionVolume(
|
|
1446
|
+
transmission_color.rgb,
|
|
1447
|
+
transmission_depth,
|
|
1448
|
+
transmission_scatter.rgb,
|
|
1449
|
+
transmission_scatter_anisotropy
|
|
1450
|
+
);
|
|
1451
|
+
#endif
|
|
1452
|
+
#if defined(SUBSURFACE_SLAB)
|
|
1453
|
+
OpenPBRHomogeneousVolume subsurfaceVolumeParams=computeOpenPBRSubsurfaceVolume(
|
|
1454
|
+
subsurface_color.rgb,
|
|
1455
|
+
subsurface_radius,
|
|
1456
|
+
subsurface_radius_scale.rgb,
|
|
1457
|
+
subsurface_scatter_anisotropy
|
|
1458
|
+
);
|
|
1459
|
+
#endif
|
|
1460
|
+
#if !defined(TRANSMISSION_SLAB)
|
|
1461
|
+
volumeParams=subsurfaceVolumeParams;surface_translucency_weight=subsurface_weight;
|
|
1462
|
+
#elif !defined(SUBSURFACE_SLAB)
|
|
1463
|
+
volumeParams=transmissionVolumeParams;
|
|
1464
|
+
#ifdef TRANSMISSION_SLAB_VOLUME
|
|
1465
|
+
volumeParams.multi_scatter_color=singleScatterToMultiScatterAlbedo(volumeParams.ss_albedo);
|
|
1466
|
+
#endif
|
|
1467
|
+
surface_translucency_weight=transmission_weight;
|
|
1468
|
+
#else
|
|
1469
|
+
float subsurface_fraction_of_dielectric=(1.0f-transmission_weight)*subsurface_weight;float subsurface_and_transmission_fraction_of_dielectric=subsurface_fraction_of_dielectric+transmission_weight;float reciprocal_of_subsurface_and_transmission_fraction_of_dielectric =
|
|
1470
|
+
1.0f/maxEps(subsurface_and_transmission_fraction_of_dielectric);float trans_weight=transmission_weight*reciprocal_of_subsurface_and_transmission_fraction_of_dielectric;float subsurf_weight=subsurface_fraction_of_dielectric*reciprocal_of_subsurface_and_transmission_fraction_of_dielectric;volumeParams.scatter_coeff=transmissionVolumeParams.scatter_coeff*trans_weight+subsurfaceVolumeParams.scatter_coeff*subsurf_weight;volumeParams.absorption_coeff=transmissionVolumeParams.absorption_coeff*trans_weight+subsurfaceVolumeParams.absorption_coeff*subsurf_weight;volumeParams.anisotropy=(transmissionVolumeParams.anisotropy*trans_weight+subsurfaceVolumeParams.anisotropy*subsurf_weight)/maxEps(trans_weight+subsurf_weight);volumeParams.extinction_coeff=volumeParams.absorption_coeff+volumeParams.scatter_coeff;volumeParams.ss_albedo=volumeParams.scatter_coeff/maxEps(volumeParams.extinction_coeff);volumeParams.multi_scatter_color=singleScatterToMultiScatterAlbedo(volumeParams.ss_albedo);surface_translucency_weight=subsurface_and_transmission_fraction_of_dielectric;
|
|
1471
|
+
#endif
|
|
1472
|
+
}
|
|
1473
|
+
volume_absorption=exp(-volumeParams.absorption_coeff*geometry_thickness);vec3 backscatter_color=vec3(1.0);{vec3 reduced_scatter=volumeParams.scatter_coeff*vec3(1.0-volumeParams.anisotropy);vec3 reduced_albedo=reduced_scatter/(volumeParams.absorption_coeff+reduced_scatter);vec3 sqrt_term=max(sqrt(1.0-reduced_albedo),0.0001);backscatter_color=(1.0-sqrt_term)/(1.0+sqrt_term);}
|
|
1474
|
+
#elif defined(TRANSMISSION_SLAB)
|
|
1475
|
+
surface_translucency_weight=transmission_weight;
|
|
1476
|
+
#endif
|
|
1477
|
+
#ifdef SCATTERING
|
|
1478
|
+
#ifdef GEOMETRY_THIN_WALLED
|
|
1479
|
+
vec3 iso_scatter_density=vec3(1.0);
|
|
1480
|
+
#else
|
|
1481
|
+
#ifdef USE_IRRADIANCE_TEXTURE_FOR_SCATTERING
|
|
1482
|
+
vec3 mfp=vec3(100.0)/volumeParams.extinction_coeff;vec3 scattered_light_from_irradiance_texture=sss_convolve(sceneIrradianceSampler,sceneDepthSampler,renderTargetSize,mfp,projection,inverseProjection,SSS_SAMPLE_COUNT,noise.xy);float numLights=float(LIGHTCOUNT);
|
|
1483
|
+
#ifdef REFLECTION
|
|
1484
|
+
numLights+=1.0;
|
|
1485
|
+
#endif
|
|
1486
|
+
scattered_light_from_irradiance_texture/=numLights;
|
|
1487
|
+
#else
|
|
1488
|
+
vec3 scattered_light_from_irradiance_texture=vec3(0.0);
|
|
1489
|
+
#endif
|
|
1490
|
+
float back_to_iso_scattering_blend=min(1.0+volumeParams.anisotropy,1.0);float iso_to_forward_scattering_blend=max(volumeParams.anisotropy,0.0);vec3 iso_scatter_transmittance=pow(exp(-volumeParams.scatter_coeff*geometry_thickness),vec3(0.2));vec3 iso_scatter_density=clamp(vec3(1.0)-iso_scatter_transmittance,0.0,1.0);transmission_roughness=min(transmission_roughness+pow((1.0-abs(volumeParams.anisotropy))*max3(iso_scatter_density*iso_scatter_density),3.0),1.0);
|
|
1491
|
+
#endif
|
|
1492
|
+
volumeParams.multi_scatter_color=mix(volumeParams.ss_albedo,volumeParams.multi_scatter_color,max3(iso_scatter_density));
|
|
1493
|
+
#endif
|
|
1494
|
+
#if defined(TRANSMISSION_SLAB) && (!defined(TRANSMISSION_SLAB_VOLUME) || defined(GEOMETRY_THIN_WALLED))
|
|
1495
|
+
transmission_tint*=transmission_color.rgb;
|
|
1496
|
+
#ifdef GEOMETRY_THIN_WALLED
|
|
1497
|
+
float sin2=1.0-baseGeoInfo.NdotV*baseGeoInfo.NdotV;sin2=sin2/(specular_ior*specular_ior);float cos_t=sqrt(1.0-sin2);float pathLength=1.0/cos_t;transmission_tint=pow(transmission_tint,vec3(pathLength));
|
|
1498
|
+
#else
|
|
1499
|
+
transmission_tint*=transmission_color.rgb;
|
|
1500
|
+
#endif
|
|
1501
|
+
#endif
|
|
1502
|
+
#if defined(SUBSURFACE_SLAB) && defined(GEOMETRY_THIN_WALLED)
|
|
1503
|
+
float unweighted_translucency=max(mix(subsurface_weight,1.0f,transmission_weight),0.0001);transmission_tint=mix(vec3(1.0),transmission_tint,transmission_weight/unweighted_translucency);transmission_roughness=mix(1.0,transmission_roughness,transmission_weight/unweighted_translucency);
|
|
1504
|
+
#endif
|
|
1505
|
+
float transmission_roughness_alpha=transmission_roughness*transmission_roughness;
|
|
1506
|
+
#endif
|
|
1507
|
+
#include<openpbrBackgroundTransmission>
|
|
1508
|
+
vec3 material_surface_ibl=vec3(0.,0.,0.);
|
|
1509
|
+
#include<openpbrEnvironmentLighting>
|
|
1510
|
+
vec3 material_surface_direct=vec3(0.,0.,0.);
|
|
1511
|
+
#if defined(LIGHT0)
|
|
1512
|
+
float aggShadow=0.;
|
|
1513
|
+
#include<openpbrDirectLightingInit>[0..maxSimultaneousLights]
|
|
1514
|
+
#include<openpbrDirectLighting>[0..maxSimultaneousLights]
|
|
1515
|
+
#endif
|
|
1516
|
+
vec3 material_surface_emission=vEmissionColor;
|
|
1517
|
+
#ifdef EMISSION_COLOR
|
|
1518
|
+
vec3 emissionColorTex=TEXRD(emissionColorSampler,vEmissionColorUV+uvOffset).rgb;
|
|
1519
|
+
#ifdef EMISSION_COLOR_GAMMA
|
|
1520
|
+
material_surface_emission*=toLinearSpace(emissionColorTex.rgb);
|
|
1521
|
+
#else
|
|
1522
|
+
material_surface_emission*=emissionColorTex.rgb;
|
|
1523
|
+
#endif
|
|
1524
|
+
material_surface_emission*= vEmissionColorInfos.y;
|
|
1525
|
+
#endif
|
|
1526
|
+
material_surface_emission*=vLightingIntensity.y;
|
|
1527
|
+
#define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION
|
|
1528
|
+
vec4 finalColor=vec4(material_surface_ibl+material_surface_direct+material_surface_emission,alpha);
|
|
1529
|
+
#define CUSTOM_FRAGMENT_BEFORE_FOG
|
|
1530
|
+
finalColor=max(finalColor,0.0);
|
|
1531
|
+
#include<logDepthFragment>
|
|
1532
|
+
#include<fogFragment>(color,finalColor)
|
|
1533
|
+
#include<pbrBlockImageProcessing>
|
|
1534
|
+
#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR
|
|
1535
|
+
#ifdef PREPASS
|
|
1536
|
+
#include<openpbrBlockPrePass>
|
|
1537
|
+
#endif
|
|
1538
|
+
#if !defined(PREPASS) || defined(WEBGL2)
|
|
1539
|
+
gl_FragColor=finalColor;
|
|
1540
|
+
#endif
|
|
1541
|
+
#include<oitFragment>
|
|
1542
|
+
#if ORDER_INDEPENDENT_TRANSPARENCY
|
|
1543
|
+
if (fragDepth==nearestDepth) {frontColor.rgb+=finalColor.rgb*finalColor.a*alphaMultiplier;frontColor.a=1.0-alphaMultiplier*(1.0-finalColor.a);} else {backColor+=finalColor;}
|
|
1544
|
+
#endif
|
|
1545
|
+
#include<pbrDebug>
|
|
1546
|
+
#define CUSTOM_FRAGMENT_MAIN_END
|
|
1547
|
+
}
|
|
1548
|
+
`;
|
|
1549
|
+
e.ShadersStore[i] || (e.ShadersStore[i] = I);
|
|
1550
|
+
const K = { name: i, shader: I };
|
|
1551
|
+
export {
|
|
1552
|
+
K as openpbrPixelShader
|
|
1553
|
+
};
|