UNPKG

@babylonjs/materials

Version:

Babylon.js Materials Library =====================

94 lines 3.84 kB
// Do not edit. import { ShaderStore } from "@babylonjs/core/Engines/shaderStore.js"; import "@babylonjs/core/Shaders/ShadersInclude/helperFunctions.js"; import "@babylonjs/core/Shaders/ShadersInclude/lightFragmentDeclaration.js"; import "@babylonjs/core/Shaders/ShadersInclude/lightUboDeclaration.js"; import "@babylonjs/core/Shaders/ShadersInclude/logDepthDeclaration.js"; import "@babylonjs/core/Shaders/ShadersInclude/lightsFragmentFunctions.js"; import "@babylonjs/core/Shaders/ShadersInclude/shadowsFragmentFunctions.js"; import "@babylonjs/core/Shaders/ShadersInclude/fogFragmentDeclaration.js"; import "@babylonjs/core/Shaders/ShadersInclude/clipPlaneFragmentDeclaration.js"; import "@babylonjs/core/Shaders/ShadersInclude/clipPlaneFragment.js"; import "@babylonjs/core/Shaders/ShadersInclude/depthPrePass.js"; import "@babylonjs/core/Shaders/ShadersInclude/lightFragment.js"; import "@babylonjs/core/Shaders/ShadersInclude/logDepthFragment.js"; import "@babylonjs/core/Shaders/ShadersInclude/fogFragment.js"; import "@babylonjs/core/Shaders/ShadersInclude/imageProcessingCompatibility.js"; const name = "furPixelShader"; const shader = `precision highp float;uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;uniform vec4 furColor;uniform float furLength;varying vec3 vPositionW;varying float vfur_length; #ifdef NORMAL varying vec3 vNormalW; #endif #ifdef VERTEXCOLOR varying vec4 vColor; #endif #include<helperFunctions> #include<__decl__lightFragment>[0..maxSimultaneousLights] #ifdef DIFFUSE varying vec2 vDiffuseUV;uniform sampler2D diffuseSampler;uniform vec2 vDiffuseInfos; #endif #ifdef HIGHLEVEL uniform float furOffset;uniform float furOcclusion;uniform sampler2D furTexture;varying vec2 vFurUV; #endif #ifdef LOGARITHMICDEPTH #extension GL_EXT_frag_depth : enable #endif #include<logDepthDeclaration> #include<lightsFragmentFunctions> #include<shadowsFragmentFunctions> #include<fogFragmentDeclaration> #include<clipPlaneFragmentDeclaration> float Rand(vec3 rv) {float x=dot(rv,vec3(12.9898,78.233,24.65487));return fract(sin(x)*43758.5453);} #define CUSTOM_FRAGMENT_DEFINITIONS void main(void) { #define CUSTOM_FRAGMENT_MAIN_BEGIN #include<clipPlaneFragment> vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=furColor;vec3 diffuseColor=vDiffuseColor.rgb;float alpha=vDiffuseColor.a; #ifdef DIFFUSE baseColor*=texture2D(diffuseSampler,vDiffuseUV); #ifdef ALPHATEST if (baseColor.a<0.4) discard; #endif #include<depthPrePass> baseColor.rgb*=vDiffuseInfos.y; #endif #ifdef VERTEXCOLOR baseColor.rgb*=vColor.rgb; #endif #ifdef NORMAL vec3 normalW=normalize(vNormalW); #else vec3 normalW=vec3(1.0,1.0,1.0); #endif #ifdef HIGHLEVEL vec4 furTextureColor=texture2D(furTexture,vec2(vFurUV.x,vFurUV.y));if (furTextureColor.a<=0.0 || furTextureColor.g<furOffset) {discard;} float occlusion=mix(0.0,furTextureColor.b*1.2,furOffset);baseColor=vec4(baseColor.xyz*max(occlusion,furOcclusion),1.1-furOffset); #endif vec3 diffuseBase=vec3(0.,0.,0.);lightingInfo info;float shadow=1.;float glossiness=0.;float aggShadow=0.;float numLights=0.; #ifdef SPECULARTERM vec3 specularBase=vec3(0.,0.,0.); #endif #include<lightFragment>[0..maxSimultaneousLights] #if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES) alpha*=vColor.a; #endif vec3 finalDiffuse=clamp(diffuseBase.rgb*baseColor.rgb,0.0,1.0); #ifdef HIGHLEVEL vec4 color=vec4(finalDiffuse,alpha); #else float r=vfur_length/furLength*0.5;vec4 color=vec4(finalDiffuse*(0.5+r),alpha); #endif #include<logDepthFragment> #include<fogFragment> gl_FragColor=color; #include<imageProcessingCompatibility> #define CUSTOM_FRAGMENT_MAIN_END }`; // Sideeffect if (!ShaderStore.ShadersStore[name]) { ShaderStore.ShadersStore[name] = shader; } /** @internal */ export const furPixelShader = { name, shader }; //# sourceMappingURL=fur.fragment.js.map