UNPKG

@babylonjs/materials

Version:

For usage documentation please visit the [materials library documentation](https://doc.babylonjs.com/toolsAndResources/assetLibraries/materialsLibrary/).

135 lines 5.35 kB
// Do not edit. import { ShaderStore } from "@babylonjs/core/Engines/shaderStore.js"; import { helperFunctions } from "@babylonjs/core/Shaders/ShadersInclude/helperFunctions.js"; import { lightFragmentDeclaration } from "@babylonjs/core/Shaders/ShadersInclude/lightFragmentDeclaration.js"; import { lightUboDeclaration } from "@babylonjs/core/Shaders/ShadersInclude/lightUboDeclaration.js"; import { logDepthDeclaration } from "@babylonjs/core/Shaders/ShadersInclude/logDepthDeclaration.js"; import { lightsFragmentFunctions } from "@babylonjs/core/Shaders/ShadersInclude/lightsFragmentFunctions.js"; import { shadowsFragmentFunctions } from "@babylonjs/core/Shaders/ShadersInclude/shadowsFragmentFunctions.js"; import { clipPlaneFragmentDeclaration } from "@babylonjs/core/Shaders/ShadersInclude/clipPlaneFragmentDeclaration.js"; import { fogFragmentDeclaration } from "@babylonjs/core/Shaders/ShadersInclude/fogFragmentDeclaration.js"; import { clipPlaneFragment } from "@babylonjs/core/Shaders/ShadersInclude/clipPlaneFragment.js"; import { depthPrePass } from "@babylonjs/core/Shaders/ShadersInclude/depthPrePass.js"; import { lightFragment } from "@babylonjs/core/Shaders/ShadersInclude/lightFragment.js"; import { logDepthFragment } from "@babylonjs/core/Shaders/ShadersInclude/logDepthFragment.js"; import { fogFragment } from "@babylonjs/core/Shaders/ShadersInclude/fogFragment.js"; import { imageProcessingCompatibility } from "@babylonjs/core/Shaders/ShadersInclude/imageProcessingCompatibility.js"; const name = "triplanarPixelShader"; const shader = `precision highp float;uniform vec4 vEyePosition;uniform vec4 vDiffuseColor; #ifdef SPECULARTERM uniform vec4 vSpecularColor; #endif varying vec3 vPositionW; #if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) varying vec4 vColor; #endif #include<helperFunctions> #include<__decl__lightFragment>[0..maxSimultaneousLights] #ifdef DIFFUSEX varying vec2 vTextureUVX;uniform sampler2D diffuseSamplerX; #ifdef BUMPX uniform sampler2D normalSamplerX; #endif #endif #ifdef DIFFUSEY varying vec2 vTextureUVY;uniform sampler2D diffuseSamplerY; #ifdef BUMPY uniform sampler2D normalSamplerY; #endif #endif #ifdef DIFFUSEZ varying vec2 vTextureUVZ;uniform sampler2D diffuseSamplerZ; #ifdef BUMPZ uniform sampler2D normalSamplerZ; #endif #endif #ifdef NORMAL varying mat3 tangentSpace; #endif #ifdef LOGARITHMICDEPTH #extension GL_EXT_frag_depth : enable #endif #include<logDepthDeclaration> #include<lightsFragmentFunctions> #include<shadowsFragmentFunctions> #include<clipPlaneFragmentDeclaration> #include<fogFragmentDeclaration> #if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0 varying float vViewDepth; #endif #define CUSTOM_FRAGMENT_DEFINITIONS void main(void) { #define CUSTOM_FRAGMENT_MAIN_BEGIN #include<clipPlaneFragment> vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=vec4(0.,0.,0.,1.);vec3 diffuseColor=vDiffuseColor.rgb;float alpha=vDiffuseColor.a; #ifdef NORMAL vec3 normalW=tangentSpace[2]; #else vec3 normalW=vec3(1.0,1.0,1.0); #endif vec4 baseNormal=vec4(0.0,0.0,0.0,1.0);normalW*=normalW; #ifdef DIFFUSEX baseColor+=texture2D(diffuseSamplerX,vTextureUVX)*normalW.x; #ifdef BUMPX baseNormal+=texture2D(normalSamplerX,vTextureUVX)*normalW.x; #endif #endif #ifdef DIFFUSEY baseColor+=texture2D(diffuseSamplerY,vTextureUVY)*normalW.y; #ifdef BUMPY baseNormal+=texture2D(normalSamplerY,vTextureUVY)*normalW.y; #endif #endif #ifdef DIFFUSEZ baseColor+=texture2D(diffuseSamplerZ,vTextureUVZ)*normalW.z; #ifdef BUMPZ baseNormal+=texture2D(normalSamplerZ,vTextureUVZ)*normalW.z; #endif #endif #ifdef NORMAL normalW=normalize((2.0*baseNormal.xyz-1.0)*tangentSpace); #endif #ifdef ALPHATEST if (baseColor.a<0.4) discard; #endif #include<depthPrePass> #if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) baseColor.rgb*=vColor.rgb; #endif vec3 diffuseBase=vec3(0.,0.,0.);lightingInfo info;float shadow=1.;float aggShadow=0.;float numLights=0.; #ifdef SPECULARTERM float glossiness=vSpecularColor.a;vec3 specularBase=vec3(0.,0.,0.);vec3 specularColor=vSpecularColor.rgb; #else float glossiness=0.; #endif #include<lightFragment>[0..maxSimultaneousLights] #if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES) alpha*=vColor.a; #endif #ifdef SPECULARTERM vec3 finalSpecular=specularBase*specularColor; #else vec3 finalSpecular=vec3(0.0); #endif vec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;vec4 color=vec4(finalDiffuse+finalSpecular,alpha); #include<logDepthFragment> #include<fogFragment> gl_FragColor=color; #include<imageProcessingCompatibility> #define CUSTOM_FRAGMENT_MAIN_END } `; // Sideeffect if (!ShaderStore.ShadersStore[name]) { ShaderStore.ShadersStore[name] = shader; } const includes = [helperFunctions, lightFragmentDeclaration, lightUboDeclaration, logDepthDeclaration, lightsFragmentFunctions, shadowsFragmentFunctions, clipPlaneFragmentDeclaration, fogFragmentDeclaration, clipPlaneFragment, depthPrePass, lightFragment, logDepthFragment, fogFragment, imageProcessingCompatibility]; for (const inc of includes) { if (!ShaderStore.IncludesShadersStore[inc.name]) { ShaderStore.IncludesShadersStore[inc.name] = inc.shader; } } /** @internal */ export const triplanarPixelShader = { name, shader }; //# sourceMappingURL=triplanar.fragment.js.map