@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,486 @@
|
|
|
1
|
+
import { b0 as e } from "./index-CS3Icp_r.js";
|
|
2
|
+
import "./defaultUboDeclaration-DSXACgip.js";
|
|
3
|
+
import "./oitFragment-DH3h3T6x.js";
|
|
4
|
+
import "./logDepthDeclaration-Bwm-3KyB.js";
|
|
5
|
+
import "./helperFunctions-Bt7Zfkrp.js";
|
|
6
|
+
import "./clipPlaneFragment-DJwQynjA.js";
|
|
7
|
+
import "./bumpFragment-Dd-ojPA1.js";
|
|
8
|
+
import "./lightFragment-DCqtGMp_.js";
|
|
9
|
+
const i = "lightsFragmentFunctions", t = `struct lightingInfo
|
|
10
|
+
{diffuse: vec3f,
|
|
11
|
+
#ifdef SPECULARTERM
|
|
12
|
+
specular: vec3f,
|
|
13
|
+
#endif
|
|
14
|
+
#ifdef NDOTL
|
|
15
|
+
ndl: f32,
|
|
16
|
+
#endif
|
|
17
|
+
};fn computeLighting(viewDirectionW: vec3f,vNormal: vec3f,lightData: vec4f,diffuseColor: vec3f,specularColor: vec3f,range: f32,glossiness: f32)->lightingInfo {var result: lightingInfo;var lightVectorW: vec3f;var attenuation: f32=1.0;if (lightData.w==0.)
|
|
18
|
+
{var direction: vec3f=lightData.xyz-fragmentInputs.vPositionW;attenuation=max(0.,1.0-length(direction)/range);lightVectorW=normalize(direction);}
|
|
19
|
+
else
|
|
20
|
+
{lightVectorW=normalize(-lightData.xyz);}
|
|
21
|
+
var ndl: f32=max(0.,dot(vNormal,lightVectorW));
|
|
22
|
+
#ifdef NDOTL
|
|
23
|
+
result.ndl=ndl;
|
|
24
|
+
#endif
|
|
25
|
+
result.diffuse=ndl*diffuseColor*attenuation;
|
|
26
|
+
#ifdef SPECULARTERM
|
|
27
|
+
var angleW: vec3f=normalize(viewDirectionW+lightVectorW);var specComp: f32=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation;
|
|
28
|
+
#endif
|
|
29
|
+
return result;}
|
|
30
|
+
fn getAttenuation(cosAngle: f32,exponent: f32)->f32 {return max(0.,pow(cosAngle,exponent));}
|
|
31
|
+
fn getIESAttenuation(cosAngle: f32,iesLightTexture: texture_2d<f32>,iesLightTextureSampler: sampler)->f32 {var angle=acos(cosAngle)/PI;return textureSampleLevel(iesLightTexture,iesLightTextureSampler,vec2f(angle,0),0.).r;}
|
|
32
|
+
fn computeBasicSpotLighting(viewDirectionW: vec3f,lightVectorW: vec3f,vNormal: vec3f,attenuation: f32,diffuseColor: vec3f,specularColor: vec3f,glossiness: f32)->lightingInfo {var result: lightingInfo;var ndl: f32=max(0.,dot(vNormal,lightVectorW));
|
|
33
|
+
#ifdef NDOTL
|
|
34
|
+
result.ndl=ndl;
|
|
35
|
+
#endif
|
|
36
|
+
result.diffuse=ndl*diffuseColor*attenuation;
|
|
37
|
+
#ifdef SPECULARTERM
|
|
38
|
+
var angleW: vec3f=normalize(viewDirectionW+lightVectorW);var specComp: f32=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation;
|
|
39
|
+
#endif
|
|
40
|
+
return result;}
|
|
41
|
+
fn computeIESSpotLighting(viewDirectionW: vec3f,vNormal: vec3f,lightData: vec4f,lightDirection: vec4f,diffuseColor: vec3f,specularColor: vec3f,range: f32,glossiness: f32,iesLightTexture: texture_2d<f32>,iesLightTextureSampler: sampler)->lightingInfo {var direction: vec3f=lightData.xyz-fragmentInputs.vPositionW;var lightVectorW: vec3f=normalize(direction);var attenuation: f32=max(0.,1.0-length(direction)/range);var dotProduct=dot(lightDirection.xyz,-lightVectorW);var cosAngle: f32=max(0.,dotProduct);if (cosAngle>=lightDirection.w)
|
|
42
|
+
{attenuation*=getIESAttenuation(dotProduct,iesLightTexture,iesLightTextureSampler);return computeBasicSpotLighting(viewDirectionW,lightVectorW,vNormal,attenuation,diffuseColor,specularColor,glossiness);}
|
|
43
|
+
var result: lightingInfo;result.diffuse=vec3f(0.);
|
|
44
|
+
#ifdef SPECULARTERM
|
|
45
|
+
result.specular=vec3f(0.);
|
|
46
|
+
#endif
|
|
47
|
+
#ifdef NDOTL
|
|
48
|
+
result.ndl=0.;
|
|
49
|
+
#endif
|
|
50
|
+
return result;}
|
|
51
|
+
fn computeSpotLighting(viewDirectionW: vec3f,vNormal: vec3f ,lightData: vec4f,lightDirection: vec4f,diffuseColor: vec3f,specularColor: vec3f,range: f32,glossiness: f32)->lightingInfo {var direction: vec3f=lightData.xyz-fragmentInputs.vPositionW;var lightVectorW: vec3f=normalize(direction);var attenuation: f32=max(0.,1.0-length(direction)/range);var cosAngle: f32=max(0.,dot(lightDirection.xyz,-lightVectorW));if (cosAngle>=lightDirection.w)
|
|
52
|
+
{attenuation*=getAttenuation(cosAngle,lightData.w);return computeBasicSpotLighting(viewDirectionW,lightVectorW,vNormal,attenuation,diffuseColor,specularColor,glossiness);}
|
|
53
|
+
var result: lightingInfo;result.diffuse=vec3f(0.);
|
|
54
|
+
#ifdef SPECULARTERM
|
|
55
|
+
result.specular=vec3f(0.);
|
|
56
|
+
#endif
|
|
57
|
+
#ifdef NDOTL
|
|
58
|
+
result.ndl=0.;
|
|
59
|
+
#endif
|
|
60
|
+
return result;}
|
|
61
|
+
fn computeHemisphericLighting(viewDirectionW: vec3f,vNormal: vec3f,lightData: vec4f,diffuseColor: vec3f,specularColor: vec3f,groundColor: vec3f,glossiness: f32)->lightingInfo {var result: lightingInfo;var ndl: f32=dot(vNormal,lightData.xyz)*0.5+0.5;
|
|
62
|
+
#ifdef NDOTL
|
|
63
|
+
result.ndl=ndl;
|
|
64
|
+
#endif
|
|
65
|
+
result.diffuse=mix(groundColor,diffuseColor,ndl);
|
|
66
|
+
#ifdef SPECULARTERM
|
|
67
|
+
var angleW: vec3f=normalize(viewDirectionW+lightData.xyz);var specComp: f32=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor;
|
|
68
|
+
#endif
|
|
69
|
+
return result;}
|
|
70
|
+
fn computeProjectionTextureDiffuseLighting(projectionLightTexture: texture_2d<f32>,projectionLightSampler: sampler,textureProjectionMatrix: mat4x4f,posW: vec3f)->vec3f {var strq: vec4f=textureProjectionMatrix*vec4f(posW,1.0);strq/=strq.w;var textureColor: vec3f=textureSample(projectionLightTexture,projectionLightSampler,strq.xy).rgb;return textureColor;}
|
|
71
|
+
#if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)
|
|
72
|
+
#include<ltcHelperFunctions>
|
|
73
|
+
var areaLightsLTC1SamplerSampler: sampler;var areaLightsLTC1Sampler: texture_2d<f32>;var areaLightsLTC2SamplerSampler: sampler;var areaLightsLTC2Sampler: texture_2d<f32>;fn computeAreaLighting(ltc1: texture_2d<f32>,ltc1Sampler:sampler,ltc2:texture_2d<f32>,ltc2Sampler:sampler,viewDirectionW: vec3f,vNormal:vec3f,vPosition:vec3f,lightPosition:vec3f,halfWidth:vec3f, halfHeight:vec3f,diffuseColor:vec3f,specularColor:vec3f,roughness:f32 )->lightingInfo
|
|
74
|
+
{var result: lightingInfo;var data: areaLightData=computeAreaLightSpecularDiffuseFresnel(ltc1,ltc1Sampler,ltc2,ltc2Sampler,viewDirectionW,vNormal,vPosition,lightPosition,halfWidth,halfHeight,roughness);
|
|
75
|
+
#ifdef SPECULARTERM
|
|
76
|
+
var fresnel:vec3f=( specularColor*data.Fresnel.x+( vec3f( 1.0 )-specularColor )*data.Fresnel.y );result.specular+=specularColor*fresnel*data.Specular;
|
|
77
|
+
#endif
|
|
78
|
+
result.diffuse+=diffuseColor*data.Diffuse;return result;}
|
|
79
|
+
fn computeAreaLightingWithTexture(ltc1: texture_2d<f32>,ltc1Sampler:sampler,ltc2:texture_2d<f32>,ltc2Sampler:sampler,emissionTexture: texture_2d<f32>,emissionTextureSampler:sampler,viewDirectionW: vec3f,vNormal:vec3f,vPosition:vec3f,lightPosition:vec3f,halfWidth:vec3f, halfHeight:vec3f,diffuseColor:vec3f,specularColor:vec3f,roughness:f32 )->lightingInfo
|
|
80
|
+
{var result: lightingInfo;var data: areaLightData=computeAreaLightSpecularDiffuseFresnelWithEmission(ltc1,ltc1Sampler,ltc2,ltc2Sampler,emissionTexture,emissionTextureSampler,viewDirectionW,vNormal,vPosition,lightPosition,halfWidth,halfHeight,roughness);
|
|
81
|
+
#ifdef SPECULARTERM
|
|
82
|
+
var fresnel: vec3f=( specularColor*data.Fresnel.x+( vec3f( 1.0 )-specularColor )*data.Fresnel.y );result.specular+=specularColor*fresnel*data.Specular;
|
|
83
|
+
#endif
|
|
84
|
+
result.diffuse+=diffuseColor*data.Diffuse;return result;}
|
|
85
|
+
#endif
|
|
86
|
+
#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0
|
|
87
|
+
#include<clusteredLightingFunctions>
|
|
88
|
+
fn computeClusteredLighting(
|
|
89
|
+
lightDataTexture: texture_2d<f32>,
|
|
90
|
+
tileMaskBuffer: ptr<storage,array<u32>>,
|
|
91
|
+
viewDirectionW: vec3f,
|
|
92
|
+
vNormal: vec3f,
|
|
93
|
+
lightData: vec4f,
|
|
94
|
+
sliceRange: vec2u,
|
|
95
|
+
glossiness: f32
|
|
96
|
+
)->lightingInfo {var result: lightingInfo;let tilePosition=vec2u(fragmentInputs.position.xy*lightData.xy);let maskResolution=vec2u(lightData.zw);var tileIndex=(tilePosition.x*maskResolution.x+tilePosition.y)*maskResolution.y;let batchRange=sliceRange/CLUSTLIGHT_BATCH;var batchOffset=batchRange.x*CLUSTLIGHT_BATCH;tileIndex+=batchRange.x;for (var i=batchRange.x; i<=batchRange.y; i+=1) {var mask=tileMaskBuffer[tileIndex];tileIndex+=1;let maskOffset=max(sliceRange.x,batchOffset)-batchOffset;
|
|
97
|
+
let maskWidth=min(sliceRange.y-batchOffset+1,CLUSTLIGHT_BATCH);mask=extractBits(mask,maskOffset,maskWidth);while mask != 0 {let trailing=firstTrailingBit(mask);mask ^= 1u<<trailing;let light=getClusteredLight(lightDataTexture,batchOffset+maskOffset+trailing);var info: lightingInfo;if light.vLightDirection.w<0.0 {info=computeLighting(viewDirectionW,vNormal,light.vLightData,light.vLightDiffuse.rgb,light.vLightSpecular.rgb,light.vLightDiffuse.a,glossiness);} else {info=computeSpotLighting(viewDirectionW,vNormal,light.vLightData,light.vLightDirection,light.vLightDiffuse.rgb,light.vLightSpecular.rgb,light.vLightDiffuse.a,glossiness);}
|
|
98
|
+
result.diffuse+=info.diffuse;
|
|
99
|
+
#ifdef SPECULARTERM
|
|
100
|
+
result.specular+=info.specular;
|
|
101
|
+
#endif
|
|
102
|
+
}
|
|
103
|
+
batchOffset+=CLUSTLIGHT_BATCH;}
|
|
104
|
+
return result;}
|
|
105
|
+
#endif
|
|
106
|
+
`;
|
|
107
|
+
e.IncludesShadersStoreWGSL[i] || (e.IncludesShadersStoreWGSL[i] = t);
|
|
108
|
+
const f = "fresnelFunction", a = `#ifdef FRESNEL
|
|
109
|
+
fn computeFresnelTerm(viewDirection: vec3f,worldNormal: vec3f,bias: f32,power: f32)->f32
|
|
110
|
+
{let fresnelTerm: f32=pow(bias+abs(dot(viewDirection,worldNormal)),power);return clamp(fresnelTerm,0.,1.);}
|
|
111
|
+
#endif
|
|
112
|
+
`;
|
|
113
|
+
e.IncludesShadersStoreWGSL[f] || (e.IncludesShadersStoreWGSL[f] = a);
|
|
114
|
+
const r = "defaultPixelShader", o = `#include<defaultUboDeclaration>
|
|
115
|
+
#include<prePassDeclaration>[SCENE_MRT_COUNT]
|
|
116
|
+
#include<oitDeclaration>
|
|
117
|
+
#define CUSTOM_FRAGMENT_BEGIN
|
|
118
|
+
varying vPositionW: vec3f;
|
|
119
|
+
#ifdef NORMAL
|
|
120
|
+
varying vNormalW: vec3f;
|
|
121
|
+
#endif
|
|
122
|
+
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
|
123
|
+
varying vColor: vec4f;
|
|
124
|
+
#endif
|
|
125
|
+
#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0
|
|
126
|
+
varying vViewDepth: f32;
|
|
127
|
+
#endif
|
|
128
|
+
#include<mainUVVaryingDeclaration>[1..7]
|
|
129
|
+
#include<helperFunctions>
|
|
130
|
+
#include<lightUboDeclaration>[0..maxSimultaneousLights]
|
|
131
|
+
#include<lightsFragmentFunctions>
|
|
132
|
+
#include<shadowsFragmentFunctions>
|
|
133
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_SAMPLERNAME_,diffuse)
|
|
134
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient)
|
|
135
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity)
|
|
136
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive)
|
|
137
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)
|
|
138
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal)
|
|
139
|
+
#ifdef REFRACTION
|
|
140
|
+
#ifdef REFRACTIONMAP_3D
|
|
141
|
+
var refractionCubeSamplerSampler: sampler;var refractionCubeSampler: texture_cube<f32>;
|
|
142
|
+
#else
|
|
143
|
+
var refraction2DSamplerSampler: sampler;var refraction2DSampler: texture_2d<f32>;
|
|
144
|
+
#endif
|
|
145
|
+
#endif
|
|
146
|
+
#if defined(SPECULARTERM)
|
|
147
|
+
#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_SAMPLERNAME_,specular)
|
|
148
|
+
#endif
|
|
149
|
+
#include<fresnelFunction>
|
|
150
|
+
#ifdef REFLECTION
|
|
151
|
+
#ifdef REFLECTIONMAP_3D
|
|
152
|
+
var reflectionCubeSamplerSampler: sampler;var reflectionCubeSampler: texture_cube<f32>;
|
|
153
|
+
#else
|
|
154
|
+
var reflection2DSamplerSampler: sampler;var reflection2DSampler: texture_2d<f32>;
|
|
155
|
+
#endif
|
|
156
|
+
#ifdef REFLECTIONMAP_SKYBOX
|
|
157
|
+
varying vPositionUVW: vec3f;
|
|
158
|
+
#else
|
|
159
|
+
#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
|
|
160
|
+
varying vDirectionW: vec3f;
|
|
161
|
+
#endif
|
|
162
|
+
#endif
|
|
163
|
+
#include<reflectionFunction>
|
|
164
|
+
#endif
|
|
165
|
+
#include<imageProcessingDeclaration>
|
|
166
|
+
#include<imageProcessingFunctions>
|
|
167
|
+
#include<textureRepetitionFunctions>
|
|
168
|
+
#include<bumpFragmentMainFunctions>
|
|
169
|
+
#include<bumpFragmentFunctions>
|
|
170
|
+
#include<clipPlaneFragmentDeclaration>
|
|
171
|
+
#include<logDepthDeclaration>
|
|
172
|
+
#include<fogFragmentDeclaration>
|
|
173
|
+
#define CUSTOM_FRAGMENT_DEFINITIONS
|
|
174
|
+
@fragment
|
|
175
|
+
fn main(input: FragmentInputs)->FragmentOutputs {
|
|
176
|
+
#define CUSTOM_FRAGMENT_MAIN_BEGIN
|
|
177
|
+
#include<clipPlaneFragment>
|
|
178
|
+
var viewDirectionW: vec3f=normalize(scene.vEyePosition.xyz-fragmentInputs.vPositionW);var baseColor: vec4f= vec4f(1.,1.,1.,1.);var diffuseColor: vec3f=uniforms.vDiffuseColor.rgb;var alpha: f32=uniforms.vDiffuseColor.a;
|
|
179
|
+
#ifdef NORMAL
|
|
180
|
+
var normalW: vec3f=normalize(fragmentInputs.vNormalW);
|
|
181
|
+
#else
|
|
182
|
+
var normalW: vec3f=normalize(cross(dpdx(fragmentInputs.vPositionW),dpdy(fragmentInputs.vPositionW)))* scene.vEyePosition.w;
|
|
183
|
+
#endif
|
|
184
|
+
#include<bumpFragment>
|
|
185
|
+
#ifdef TWOSIDEDLIGHTING
|
|
186
|
+
normalW=select(-normalW,normalW,fragmentInputs.frontFacing);
|
|
187
|
+
#endif
|
|
188
|
+
#ifdef DIFFUSE
|
|
189
|
+
baseColor=TEXRD(diffuseSampler,diffuseSamplerSampler,fragmentInputs.vDiffuseUV+uvOffset);
|
|
190
|
+
#if defined(ALPHATEST) && !defined(ALPHATEST_AFTERALLALPHACOMPUTATIONS)
|
|
191
|
+
if (baseColor.a<uniforms.alphaCutOff) {discard;}
|
|
192
|
+
#endif
|
|
193
|
+
#ifdef ALPHAFROMDIFFUSE
|
|
194
|
+
alpha*=baseColor.a;
|
|
195
|
+
#endif
|
|
196
|
+
#define CUSTOM_FRAGMENT_UPDATE_ALPHA
|
|
197
|
+
baseColor=vec4f(baseColor.rgb*uniforms.vDiffuseInfos.y,baseColor.a);
|
|
198
|
+
#endif
|
|
199
|
+
#if defined(DECAL) && !defined(DECAL_AFTER_DETAIL)
|
|
200
|
+
var decalColor: vec4f=textureSample(decalSampler,decalSamplerSampler,fragmentInputs.vDecalUV+uvOffset);
|
|
201
|
+
#include<decalFragment>(surfaceAlbedo,baseColor,GAMMADECAL,_GAMMADECAL_NOTUSED_)
|
|
202
|
+
#endif
|
|
203
|
+
#include<depthPrePass>
|
|
204
|
+
#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
|
205
|
+
baseColor=vec4f(baseColor.rgb*fragmentInputs.vColor.rgb,baseColor.a);
|
|
206
|
+
#endif
|
|
207
|
+
#ifdef DETAIL
|
|
208
|
+
baseColor=vec4f(baseColor.rgb*2.0*mix(0.5,detailColor.r,uniforms.vDetailInfos.y),baseColor.a);
|
|
209
|
+
#endif
|
|
210
|
+
#if defined(DECAL) && defined(DECAL_AFTER_DETAIL)
|
|
211
|
+
var decalColor: vec4f=textureSample(decalSampler,decalSamplerSampler,fragmentInputs.vDecalUV+uvOffset);
|
|
212
|
+
#include<decalFragment>(surfaceAlbedo,baseColor,GAMMADECAL,_GAMMADECAL_NOTUSED_)
|
|
213
|
+
#endif
|
|
214
|
+
#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE
|
|
215
|
+
var baseAmbientColor: vec3f= vec3f(1.,1.,1.);
|
|
216
|
+
#ifdef AMBIENT
|
|
217
|
+
baseAmbientColor=TEXRD(ambientSampler,ambientSamplerSampler,fragmentInputs.vAmbientUV+uvOffset).rgb*uniforms.vAmbientInfos.y;
|
|
218
|
+
#endif
|
|
219
|
+
#define CUSTOM_FRAGMENT_BEFORE_LIGHTS
|
|
220
|
+
var glossiness: f32=uniforms.vSpecularColor.a;var specularColor: vec3f=uniforms.vSpecularColor.rgb;
|
|
221
|
+
#ifdef SPECULARTERM
|
|
222
|
+
#ifdef SPECULAR
|
|
223
|
+
var specularMapColor: vec4f=TEXRD(specularSampler,specularSamplerSampler,fragmentInputs.vSpecularUV+uvOffset);specularColor=specularMapColor.rgb;
|
|
224
|
+
#ifdef GLOSSINESS
|
|
225
|
+
glossiness=glossiness*specularMapColor.a;
|
|
226
|
+
#endif
|
|
227
|
+
#endif
|
|
228
|
+
#endif
|
|
229
|
+
var diffuseBase: vec3f= vec3f(0.,0.,0.);var info: lightingInfo;
|
|
230
|
+
#ifdef SPECULARTERM
|
|
231
|
+
var specularBase: vec3f= vec3f(0.,0.,0.);
|
|
232
|
+
#endif
|
|
233
|
+
var shadow: f32=1.;var aggShadow: f32=0.;var numLights: f32=0.;
|
|
234
|
+
#ifdef LIGHTMAP
|
|
235
|
+
var lightmapColor: vec4f=TEXRD(lightmapSampler,lightmapSamplerSampler,fragmentInputs.vLightmapUV+uvOffset);
|
|
236
|
+
#ifdef RGBDLIGHTMAP
|
|
237
|
+
lightmapColor=vec4f(fromRGBD(lightmapColor),lightmapColor.a);
|
|
238
|
+
#endif
|
|
239
|
+
lightmapColor=vec4f(lightmapColor.rgb*uniforms.vLightmapInfos.y,lightmapColor.a);
|
|
240
|
+
#endif
|
|
241
|
+
#include<lightFragment>[0..maxSimultaneousLights]
|
|
242
|
+
aggShadow=aggShadow/numLights;var refractionColor: vec4f= vec4f(0.,0.,0.,1.);
|
|
243
|
+
#ifdef REFRACTION
|
|
244
|
+
var refractionVector: vec3f=normalize(refract(-viewDirectionW,normalW,uniforms.vRefractionInfos.y));
|
|
245
|
+
#ifdef REFRACTIONMAP_3D
|
|
246
|
+
#ifdef USE_LOCAL_REFRACTIONMAP_CUBIC
|
|
247
|
+
refractionVector=parallaxCorrectNormal(fragmentInputs.vPositionW,refractionVector,uniforms.vRefractionSize,uniforms.vRefractionPosition);
|
|
248
|
+
#endif
|
|
249
|
+
refractionVector.y=refractionVector.y*uniforms.vRefractionInfos.w;var refractionLookup: vec4f=textureSample(refractionCubeSampler,refractionCubeSamplerSampler,refractionVector);if (dot(refractionVector,viewDirectionW)<1.0) {refractionColor=refractionLookup;}
|
|
250
|
+
#else
|
|
251
|
+
var vRefractionUVW: vec3f= (uniforms.refractionMatrix*(scene.view* vec4f(fragmentInputs.vPositionW+refractionVector*uniforms.vRefractionInfos.z,1.0))).xyz;var refractionCoords: vec2f=vRefractionUVW.xy/vRefractionUVW.z;refractionCoords.y=1.0-refractionCoords.y;refractionColor=textureSample(refraction2DSampler,refraction2DSamplerSampler,refractionCoords);
|
|
252
|
+
#endif
|
|
253
|
+
#ifdef RGBDREFRACTION
|
|
254
|
+
refractionColor=vec4f(fromRGBD(refractionColor),refractionColor.a);
|
|
255
|
+
#endif
|
|
256
|
+
#ifdef IS_REFRACTION_LINEAR
|
|
257
|
+
refractionColor=vec4f(toGammaSpaceVec3(refractionColor.rgb),refractionColor.a);
|
|
258
|
+
#endif
|
|
259
|
+
refractionColor=vec4f(refractionColor.rgb*uniforms.vRefractionInfos.x,refractionColor.a);
|
|
260
|
+
#endif
|
|
261
|
+
var reflectionColor: vec4f= vec4f(0.,0.,0.,1.);
|
|
262
|
+
#ifdef REFLECTION
|
|
263
|
+
var vReflectionUVW: vec3f=computeReflectionCoords( vec4f(fragmentInputs.vPositionW,1.0),normalW);
|
|
264
|
+
#ifdef REFLECTIONMAP_OPPOSITEZ
|
|
265
|
+
vReflectionUVW=vec3f(vReflectionUVW.x,vReflectionUVW.y,vReflectionUVW.z*-1.0);
|
|
266
|
+
#endif
|
|
267
|
+
#ifdef REFLECTIONMAP_3D
|
|
268
|
+
#ifdef ROUGHNESS
|
|
269
|
+
var bias: f32=uniforms.vReflectionInfos.y;
|
|
270
|
+
#ifdef SPECULARTERM
|
|
271
|
+
#ifdef SPECULAR
|
|
272
|
+
#ifdef GLOSSINESS
|
|
273
|
+
bias*=(1.0-specularMapColor.a);
|
|
274
|
+
#endif
|
|
275
|
+
#endif
|
|
276
|
+
#endif
|
|
277
|
+
reflectionColor=textureSampleLevel(reflectionCubeSampler,reflectionCubeSamplerSampler,vReflectionUVW,bias);
|
|
278
|
+
#else
|
|
279
|
+
reflectionColor=textureSample(reflectionCubeSampler,reflectionCubeSamplerSampler,vReflectionUVW);
|
|
280
|
+
#endif
|
|
281
|
+
#else
|
|
282
|
+
var coords: vec2f=vReflectionUVW.xy;
|
|
283
|
+
#ifdef REFLECTIONMAP_PROJECTION
|
|
284
|
+
coords/=vReflectionUVW.z;
|
|
285
|
+
#endif
|
|
286
|
+
coords.y=1.0-coords.y;reflectionColor=textureSample(reflection2DSampler,reflection2DSamplerSampler,coords);
|
|
287
|
+
#endif
|
|
288
|
+
#ifdef RGBDREFLECTION
|
|
289
|
+
reflectionColor=vec4f(fromRGBD(reflectionColor),reflectionColor.a);
|
|
290
|
+
#endif
|
|
291
|
+
#ifdef IS_REFLECTION_LINEAR
|
|
292
|
+
reflectionColor=vec4f(toGammaSpaceVec3(reflectionColor.rgb),reflectionColor.a);
|
|
293
|
+
#endif
|
|
294
|
+
reflectionColor=vec4f(reflectionColor.rgb*uniforms.vReflectionInfos.x,reflectionColor.a);
|
|
295
|
+
#ifdef REFLECTIONFRESNEL
|
|
296
|
+
var reflectionFresnelTerm: f32=computeFresnelTerm(viewDirectionW,normalW,uniforms.reflectionRightColor.a,uniforms.reflectionLeftColor.a);
|
|
297
|
+
#ifdef REFLECTIONFRESNELFROMSPECULAR
|
|
298
|
+
#ifdef SPECULARTERM
|
|
299
|
+
reflectionColor=vec4f(reflectionColor.rgb*specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*uniforms.reflectionRightColor.rgb,reflectionColor.a);
|
|
300
|
+
#else
|
|
301
|
+
reflectionColor=vec4f(reflectionColor.rgb*uniforms.reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*uniforms.reflectionRightColor.rgb,reflectionColor.a);
|
|
302
|
+
#endif
|
|
303
|
+
#else
|
|
304
|
+
reflectionColor=vec4f(reflectionColor.rgb*uniforms.reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*uniforms.reflectionRightColor.rgb,reflectionColor.a);
|
|
305
|
+
#endif
|
|
306
|
+
#endif
|
|
307
|
+
#endif
|
|
308
|
+
#ifdef REFRACTIONFRESNEL
|
|
309
|
+
var refractionFresnelTerm: f32=computeFresnelTerm(viewDirectionW,normalW,uniforms.refractionRightColor.a,uniforms.refractionLeftColor.a);refractionColor=vec4f(refractionColor.rgb*uniforms.refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*uniforms.refractionRightColor.rgb,refractionColor.a);
|
|
310
|
+
#endif
|
|
311
|
+
#ifdef OPACITY
|
|
312
|
+
var opacityMap: vec4f=TEXRD(opacitySampler,opacitySamplerSampler,fragmentInputs.vOpacityUV+uvOffset);
|
|
313
|
+
#ifdef OPACITYRGB
|
|
314
|
+
opacityMap=vec4f(opacityMap.rgb* vec3f(0.3,0.59,0.11),opacityMap.a);alpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* uniforms.vOpacityInfos.y;
|
|
315
|
+
#else
|
|
316
|
+
alpha*=opacityMap.a*uniforms.vOpacityInfos.y;
|
|
317
|
+
#endif
|
|
318
|
+
#endif
|
|
319
|
+
#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)
|
|
320
|
+
alpha*=fragmentInputs.vColor.a;
|
|
321
|
+
#endif
|
|
322
|
+
#ifdef OPACITYFRESNEL
|
|
323
|
+
var opacityFresnelTerm: f32=computeFresnelTerm(viewDirectionW,normalW,uniforms.opacityParts.z,uniforms.opacityParts.w);alpha+=uniforms.opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*uniforms.opacityParts.y;
|
|
324
|
+
#endif
|
|
325
|
+
#ifdef ALPHATEST
|
|
326
|
+
#ifdef ALPHATEST_AFTERALLALPHACOMPUTATIONS
|
|
327
|
+
if (alpha<uniforms.alphaCutOff) {discard;}
|
|
328
|
+
#endif
|
|
329
|
+
#ifndef ALPHABLEND
|
|
330
|
+
alpha=1.0;
|
|
331
|
+
#endif
|
|
332
|
+
#endif
|
|
333
|
+
var emissiveColor: vec3f=uniforms.vEmissiveColor;
|
|
334
|
+
#ifdef EMISSIVE
|
|
335
|
+
emissiveColor+=TEXRD(emissiveSampler,emissiveSamplerSampler,fragmentInputs.vEmissiveUV+uvOffset).rgb*uniforms.vEmissiveInfos.y;
|
|
336
|
+
#endif
|
|
337
|
+
#ifdef EMISSIVEFRESNEL
|
|
338
|
+
var emissiveFresnelTerm: f32=computeFresnelTerm(viewDirectionW,normalW,uniforms.emissiveRightColor.a,uniforms.emissiveLeftColor.a);emissiveColor*=uniforms.emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*uniforms.emissiveRightColor.rgb;
|
|
339
|
+
#endif
|
|
340
|
+
#ifdef DIFFUSEFRESNEL
|
|
341
|
+
var diffuseFresnelTerm: f32=computeFresnelTerm(viewDirectionW,normalW,uniforms.diffuseRightColor.a,uniforms.diffuseLeftColor.a);diffuseBase*=uniforms.diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*uniforms.diffuseRightColor.rgb;
|
|
342
|
+
#endif
|
|
343
|
+
#ifdef EMISSIVEASILLUMINATION
|
|
344
|
+
var finalDiffuse: vec3f=clamp(diffuseBase*diffuseColor+uniforms.vAmbientColor,vec3f(0.0),vec3f(1.0))*baseColor.rgb;
|
|
345
|
+
#else
|
|
346
|
+
#ifdef LINKEMISSIVEWITHDIFFUSE
|
|
347
|
+
var finalDiffuse: vec3f=clamp((diffuseBase+emissiveColor)*diffuseColor+uniforms.vAmbientColor,vec3f(0.0),vec3f(1.0))*baseColor.rgb;
|
|
348
|
+
#else
|
|
349
|
+
var finalDiffuse: vec3f=clamp(diffuseBase*diffuseColor+emissiveColor+uniforms.vAmbientColor,vec3f(0.0),vec3f(1.0))*baseColor.rgb;
|
|
350
|
+
#endif
|
|
351
|
+
#endif
|
|
352
|
+
#ifdef SPECULARTERM
|
|
353
|
+
var finalSpecular: vec3f=specularBase*specularColor;
|
|
354
|
+
#ifdef SPECULAROVERALPHA
|
|
355
|
+
alpha=clamp(alpha+dot(finalSpecular, vec3f(0.3,0.59,0.11)),0.0,1.0);
|
|
356
|
+
#endif
|
|
357
|
+
#else
|
|
358
|
+
var finalSpecular: vec3f= vec3f(0.0);
|
|
359
|
+
#endif
|
|
360
|
+
#ifdef REFLECTIONOVERALPHA
|
|
361
|
+
alpha=clamp(alpha+dot(reflectionColor.rgb, vec3f(0.3,0.59,0.11)),0.0,1.0);
|
|
362
|
+
#endif
|
|
363
|
+
#ifdef EMISSIVEASILLUMINATION
|
|
364
|
+
var color: vec4f= vec4f(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+emissiveColor+refractionColor.rgb,vec3f(0.0),vec3f(1.0)),alpha);
|
|
365
|
+
#else
|
|
366
|
+
var color: vec4f= vec4f(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+refractionColor.rgb,alpha);
|
|
367
|
+
#endif
|
|
368
|
+
#ifdef LIGHTMAP
|
|
369
|
+
#ifndef LIGHTMAPEXCLUDED
|
|
370
|
+
#ifdef USELIGHTMAPASSHADOWMAP
|
|
371
|
+
color=vec4f(color.rgb*lightmapColor.rgb,color.a);
|
|
372
|
+
#else
|
|
373
|
+
color=vec4f(color.rgb+lightmapColor.rgb,color.a);
|
|
374
|
+
#endif
|
|
375
|
+
#endif
|
|
376
|
+
#endif
|
|
377
|
+
#define CUSTOM_FRAGMENT_BEFORE_FOG
|
|
378
|
+
color=vec4f(max(color.rgb,vec3f(0.)),color.a);
|
|
379
|
+
#include<logDepthFragment>
|
|
380
|
+
#include<fogFragment>
|
|
381
|
+
#ifdef IMAGEPROCESSINGPOSTPROCESS
|
|
382
|
+
color=vec4f(toLinearSpaceVec3(color.rgb),color.a);
|
|
383
|
+
#else
|
|
384
|
+
#ifdef IMAGEPROCESSING
|
|
385
|
+
color=vec4f(toLinearSpaceVec3(color.rgb),color.a);color=applyImageProcessing(color);
|
|
386
|
+
#endif
|
|
387
|
+
#endif
|
|
388
|
+
color=vec4f(color.rgb,color.a*mesh.visibility);
|
|
389
|
+
#ifdef PREMULTIPLYALPHA
|
|
390
|
+
color=vec4f(color.rgb*color.a, color.a);
|
|
391
|
+
#endif
|
|
392
|
+
#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR
|
|
393
|
+
#ifdef PREPASS
|
|
394
|
+
#if SCENE_MRT_COUNT>0
|
|
395
|
+
var writeGeometryInfo: f32=select(0.0,1.0,color.a>0.4);var fragData: array<vec4<f32>,SCENE_MRT_COUNT>;
|
|
396
|
+
#ifdef PREPASS_COLOR
|
|
397
|
+
fragData[PREPASS_COLOR_INDEX]=color;
|
|
398
|
+
#endif
|
|
399
|
+
#ifdef PREPASS_POSITION
|
|
400
|
+
fragData[PREPASS_POSITION_INDEX]=vec4f(fragmentInputs.vPositionW,writeGeometryInfo);
|
|
401
|
+
#endif
|
|
402
|
+
#ifdef PREPASS_LOCAL_POSITION
|
|
403
|
+
fragData[PREPASS_LOCAL_POSITION_INDEX]=vec4f(fragmentInputs.vPosition,writeGeometryInfo);
|
|
404
|
+
#endif
|
|
405
|
+
#ifdef PREPASS_VELOCITY
|
|
406
|
+
var a: vec2f=(fragmentInputs.vCurrentPosition.xy/fragmentInputs.vCurrentPosition.w)*0.5+0.5;var b: vec2f=(fragmentInputs.vPreviousPosition.xy/fragmentInputs.vPreviousPosition.w)*0.5+0.5;var velocity: vec2f=abs(a-b);velocity= vec2f(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;fragData[PREPASS_VELOCITY_INDEX]= vec4f(velocity,0.0,writeGeometryInfo);
|
|
407
|
+
#elif defined(PREPASS_VELOCITY_LINEAR)
|
|
408
|
+
var velocity : vec2f=vec2f(0.5)*((fragmentInputs.vPreviousPosition.xy/fragmentInputs.vPreviousPosition.w) -
|
|
409
|
+
(fragmentInputs.vCurrentPosition.xy/fragmentInputs.vCurrentPosition.w));fragData[PREPASS_VELOCITY_LINEAR_INDEX]=vec4f(velocity,0.0,writeGeometryInfo);
|
|
410
|
+
#endif
|
|
411
|
+
#ifdef PREPASS_IRRADIANCE
|
|
412
|
+
fragData[PREPASS_IRRADIANCE_INDEX]=vec4f(0.0,0.0,0.0,writeGeometryInfo);
|
|
413
|
+
#endif
|
|
414
|
+
#ifdef PREPASS_DEPTH
|
|
415
|
+
fragData[PREPASS_DEPTH_INDEX]=vec4f(fragmentInputs.vViewPos.z,0.0,0.0,writeGeometryInfo);
|
|
416
|
+
#endif
|
|
417
|
+
#ifdef PREPASS_SCREENSPACE_DEPTH
|
|
418
|
+
fragData[PREPASS_SCREENSPACE_DEPTH_INDEX]=vec4f(fragmentInputs.position.z,0.0,0.0,writeGeometryInfo);
|
|
419
|
+
#endif
|
|
420
|
+
#ifdef PREPASS_NORMALIZED_VIEW_DEPTH
|
|
421
|
+
fragData[PREPASS_NORMALIZED_VIEW_DEPTH_INDEX]=vec4f(fragmentInputs.vNormViewDepth,0.0,0.0,writeGeometryInfo);
|
|
422
|
+
#endif
|
|
423
|
+
#ifdef PREPASS_NORMAL
|
|
424
|
+
#ifdef PREPASS_NORMAL_WORLDSPACE
|
|
425
|
+
fragData[PREPASS_NORMAL_INDEX]=vec4f(normalW,writeGeometryInfo);
|
|
426
|
+
#else
|
|
427
|
+
fragData[PREPASS_NORMAL_INDEX]=vec4f(normalize((scene.view*vec4f(normalW,0.0)).rgb),writeGeometryInfo);
|
|
428
|
+
#endif
|
|
429
|
+
#endif
|
|
430
|
+
#ifdef PREPASS_WORLD_NORMAL
|
|
431
|
+
fragData[PREPASS_WORLD_NORMAL_INDEX]=vec4f(normalW*0.5+0.5,writeGeometryInfo);
|
|
432
|
+
#endif
|
|
433
|
+
#ifdef PREPASS_ALBEDO
|
|
434
|
+
fragData[PREPASS_ALBEDO_INDEX]=vec4f(baseColor.rgb,writeGeometryInfo);
|
|
435
|
+
#endif
|
|
436
|
+
#ifdef PREPASS_ALBEDO_SQRT
|
|
437
|
+
fragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4f(sqrt(baseColor.rgb),writeGeometryInfo);
|
|
438
|
+
#endif
|
|
439
|
+
#ifdef PREPASS_REFLECTIVITY
|
|
440
|
+
#if defined(SPECULAR)
|
|
441
|
+
fragData[PREPASS_REFLECTIVITY_INDEX]=vec4f(toLinearSpaceVec4(specularMapColor))*writeGeometryInfo;
|
|
442
|
+
#else
|
|
443
|
+
fragData[PREPASS_REFLECTIVITY_INDEX]=vec4f(toLinearSpaceVec3(specularColor),1.0)*writeGeometryInfo;
|
|
444
|
+
#endif
|
|
445
|
+
#endif
|
|
446
|
+
#if SCENE_MRT_COUNT>0
|
|
447
|
+
fragmentOutputs.fragData0=fragData[0];
|
|
448
|
+
#endif
|
|
449
|
+
#if SCENE_MRT_COUNT>1
|
|
450
|
+
fragmentOutputs.fragData1=fragData[1];
|
|
451
|
+
#endif
|
|
452
|
+
#if SCENE_MRT_COUNT>2
|
|
453
|
+
fragmentOutputs.fragData2=fragData[2];
|
|
454
|
+
#endif
|
|
455
|
+
#if SCENE_MRT_COUNT>3
|
|
456
|
+
fragmentOutputs.fragData3=fragData[3];
|
|
457
|
+
#endif
|
|
458
|
+
#if SCENE_MRT_COUNT>4
|
|
459
|
+
fragmentOutputs.fragData4=fragData[4];
|
|
460
|
+
#endif
|
|
461
|
+
#if SCENE_MRT_COUNT>5
|
|
462
|
+
fragmentOutputs.fragData5=fragData[5];
|
|
463
|
+
#endif
|
|
464
|
+
#if SCENE_MRT_COUNT>6
|
|
465
|
+
fragmentOutputs.fragData6=fragData[6];
|
|
466
|
+
#endif
|
|
467
|
+
#if SCENE_MRT_COUNT>7
|
|
468
|
+
fragmentOutputs.fragData7=fragData[7];
|
|
469
|
+
#endif
|
|
470
|
+
#endif
|
|
471
|
+
#endif
|
|
472
|
+
#if !defined(PREPASS) && !defined(ORDER_INDEPENDENT_TRANSPARENCY)
|
|
473
|
+
fragmentOutputs.color=color;
|
|
474
|
+
#endif
|
|
475
|
+
#include<oitFragment>
|
|
476
|
+
#if ORDER_INDEPENDENT_TRANSPARENCY
|
|
477
|
+
if (fragDepth==nearestDepth) {fragmentOutputs.frontColor=vec4f(fragmentOutputs.frontColor.rgb+color.rgb*color.a*alphaMultiplier,1.0-alphaMultiplier*(1.0-color.a));} else {fragmentOutputs.backColor+=color;}
|
|
478
|
+
#endif
|
|
479
|
+
#define CUSTOM_FRAGMENT_MAIN_END
|
|
480
|
+
}
|
|
481
|
+
`;
|
|
482
|
+
e.ShadersStoreWGSL[r] || (e.ShadersStoreWGSL[r] = o);
|
|
483
|
+
const g = { name: r, shader: o };
|
|
484
|
+
export {
|
|
485
|
+
g as defaultPixelShaderWGSL
|
|
486
|
+
};
|