@babylonjs/materials
Version:
For usage documentation please visit the [materials library documentation](https://doc.babylonjs.com/toolsAndResources/assetLibraries/materialsLibrary/).
135 lines • 5.35 kB
JavaScript
// 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;
uniform vec4 vSpecularColor;
varying vec3 vPositionW;
varying vec4 vColor;
varying vec2 vTextureUVX;uniform sampler2D diffuseSamplerX;
uniform sampler2D normalSamplerX;
varying vec2 vTextureUVY;uniform sampler2D diffuseSamplerY;
uniform sampler2D normalSamplerY;
varying vec2 vTextureUVZ;uniform sampler2D diffuseSamplerZ;
uniform sampler2D normalSamplerZ;
varying mat3 tangentSpace;
varying float vViewDepth;
void main(void) {
vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=vec4(0.,0.,0.,1.);vec3 diffuseColor=vDiffuseColor.rgb;float alpha=vDiffuseColor.a;
vec3 normalW=tangentSpace[2];
vec3 normalW=vec3(1.0,1.0,1.0);
vec4 baseNormal=vec4(0.0,0.0,0.0,1.0);normalW*=normalW;
baseColor+=texture2D(diffuseSamplerX,vTextureUVX)*normalW.x;
baseNormal+=texture2D(normalSamplerX,vTextureUVX)*normalW.x;
baseColor+=texture2D(diffuseSamplerY,vTextureUVY)*normalW.y;
baseNormal+=texture2D(normalSamplerY,vTextureUVY)*normalW.y;
baseColor+=texture2D(diffuseSamplerZ,vTextureUVZ)*normalW.z;
baseNormal+=texture2D(normalSamplerZ,vTextureUVZ)*normalW.z;
normalW=normalize((2.0*baseNormal.xyz-1.0)*tangentSpace);
if (baseColor.a<0.4)
discard;
baseColor.rgb*=vColor.rgb;
vec3 diffuseBase=vec3(0.,0.,0.);lightingInfo info;float shadow=1.;float aggShadow=0.;float numLights=0.;
float glossiness=vSpecularColor.a;vec3 specularBase=vec3(0.,0.,0.);vec3 specularColor=vSpecularColor.rgb;
float glossiness=0.;
alpha*=vColor.a;
vec3 finalSpecular=specularBase*specularColor;
vec3 finalSpecular=vec3(0.0);
vec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;vec4 color=vec4(finalDiffuse+finalSpecular,alpha);
gl_FragColor=color;
}
`;
// 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