UNPKG

@babylonjs/materials

Version:

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

126 lines 4.73 kB
// Do not edit. import { ShaderStore } from "@babylonjs/core/Engines/shaderStore.js"; import "@babylonjs/core/Shaders/ShadersInclude/bonesDeclaration.js"; import "@babylonjs/core/Shaders/ShadersInclude/bakedVertexAnimationDeclaration.js"; import "@babylonjs/core/Shaders/ShadersInclude/instancesDeclaration.js"; import "@babylonjs/core/Shaders/ShadersInclude/clipPlaneVertexDeclaration.js"; import "@babylonjs/core/Shaders/ShadersInclude/logDepthDeclaration.js"; import "@babylonjs/core/Shaders/ShadersInclude/fogVertexDeclaration.js"; import "@babylonjs/core/Shaders/ShadersInclude/lightFragmentDeclaration.js"; import "@babylonjs/core/Shaders/ShadersInclude/lightUboDeclaration.js"; import "@babylonjs/core/Shaders/ShadersInclude/instancesVertex.js"; import "@babylonjs/core/Shaders/ShadersInclude/bonesVertex.js"; import "@babylonjs/core/Shaders/ShadersInclude/bakedVertexAnimation.js"; import "@babylonjs/core/Shaders/ShadersInclude/clipPlaneVertex.js"; import "@babylonjs/core/Shaders/ShadersInclude/logDepthVertex.js"; import "@babylonjs/core/Shaders/ShadersInclude/fogVertex.js"; import "@babylonjs/core/Shaders/ShadersInclude/shadowsVertex.js"; import "@babylonjs/core/Shaders/ShadersInclude/vertexColorMixing.js"; const name = "furVertexShader"; const shader = `precision highp float;attribute vec3 position;attribute vec3 normal; #ifdef UV1 attribute vec2 uv; #endif #ifdef UV2 attribute vec2 uv2; #endif #ifdef VERTEXCOLOR attribute vec4 color; #endif #include<bonesDeclaration> #include<bakedVertexAnimationDeclaration> uniform float furLength;uniform float furAngle; #ifdef HIGHLEVEL uniform float furOffset;uniform vec3 furGravity;uniform float furTime;uniform float furSpacing;uniform float furDensity; #endif #ifdef HEIGHTMAP uniform sampler2D heightTexture; #endif #ifdef HIGHLEVEL varying vec2 vFurUV; #endif #include<instancesDeclaration> uniform mat4 view;uniform mat4 viewProjection; #ifdef DIFFUSE varying vec2 vDiffuseUV;uniform mat4 diffuseMatrix;uniform vec2 vDiffuseInfos; #endif #ifdef POINTSIZE uniform float pointSize; #endif varying vec3 vPositionW; #ifdef NORMAL varying vec3 vNormalW; #endif varying float vfur_length; #ifdef VERTEXCOLOR varying vec4 vColor; #endif #include<clipPlaneVertexDeclaration> #include<logDepthDeclaration> #include<fogVertexDeclaration> #include<__decl__lightFragment>[0..maxSimultaneousLights] float Rand(vec3 rv) {float x=dot(rv,vec3(12.9898,78.233,24.65487));return fract(sin(x)*43758.5453);} #define CUSTOM_VERTEX_DEFINITIONS void main(void) { #define CUSTOM_VERTEX_MAIN_BEGIN #ifdef VERTEXCOLOR vec4 colorUpdated=color; #endif #include<instancesVertex> #include<bonesVertex> #include<bakedVertexAnimation> float r=Rand(position); #ifdef HEIGHTMAP #if __VERSION__>100 vfur_length=furLength*texture(heightTexture,uv).x; #else vfur_length=furLength*texture2D(heightTexture,uv).r; #endif #else vfur_length=(furLength*r); #endif vec3 tangent1=vec3(normal.y,-normal.x,0);vec3 tangent2=vec3(-normal.z,0,normal.x);r=Rand(tangent1*r);float J=(2.0+4.0*r);r=Rand(tangent2*r);float K=(2.0+2.0*r);tangent1=tangent1*J+tangent2*K;tangent1=normalize(tangent1);vec3 newPosition=position+normal*vfur_length*cos(furAngle)+tangent1*vfur_length*sin(furAngle); #ifdef HIGHLEVEL vec3 forceDirection=vec3(0.0,0.0,0.0);forceDirection.x=sin(furTime+position.x*0.05)*0.2;forceDirection.y=cos(furTime*0.7+position.y*0.04)*0.2;forceDirection.z=sin(furTime*0.7+position.z*0.04)*0.2;vec3 displacement=vec3(0.0,0.0,0.0);displacement=furGravity+forceDirection;float displacementFactor=pow(furOffset,3.0);vec3 aNormal=normal;aNormal.xyz+=displacement*displacementFactor;newPosition=vec3(newPosition.x,newPosition.y,newPosition.z)+(normalize(aNormal)*furOffset*furSpacing); #endif #ifdef NORMAL vNormalW=normalize(vec3(finalWorld*vec4(normal,0.0))); #endif gl_Position=viewProjection*finalWorld*vec4(newPosition,1.0);vec4 worldPos=finalWorld*vec4(newPosition,1.0);vPositionW=vec3(worldPos); #ifndef UV1 vec2 uv=vec2(0.,0.); #endif #ifndef UV2 vec2 uv2=vec2(0.,0.); #endif #ifdef DIFFUSE if (vDiffuseInfos.x==0.) {vDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));} else {vDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));} #ifdef HIGHLEVEL vFurUV=vDiffuseUV*furDensity; #endif #else #ifdef HIGHLEVEL vFurUV=uv*furDensity; #endif #endif #include<clipPlaneVertex> #include<logDepthVertex> #include<fogVertex> #include<shadowsVertex>[0..maxSimultaneousLights] #include<vertexColorMixing> #if defined(POINTSIZE) && !defined(WEBGPU) gl_PointSize=pointSize; #endif #define CUSTOM_VERTEX_MAIN_END } `; // Sideeffect if (!ShaderStore.ShadersStore[name]) { ShaderStore.ShadersStore[name] = shader; } /** @internal */ export const furVertexShader = { name, shader }; //# sourceMappingURL=fur.vertex.js.map