@babylonjs/core
Version:
Getting started? Play directly with the Babylon.js API using our [playground](https://playground.babylonjs.com/). It also contains a lot of samples to learn how to use it.
151 lines • 4.43 kB
JavaScript
// Do not edit.
import { ShaderStore } from "../Engines/shaderStore.js";
import "./ShadersInclude/clipPlaneFragmentDeclaration.js";
import "./ShadersInclude/mrtFragmentDeclaration.js";
import "./ShadersInclude/bumpFragmentMainFunctions.js";
import "./ShadersInclude/bumpFragmentFunctions.js";
import "./ShadersInclude/helperFunctions.js";
import "./ShadersInclude/clipPlaneFragment.js";
import "./ShadersInclude/bumpFragment.js";
const name = "geometryPixelShader";
const shader = `
precision highp float;
varying mat4 vWorldView;varying vec3 vNormalW;
varying vec3 vNormalV;
varying vec4 vViewPos;
varying vec3 vPositionW;
varying vec4 vCurrentPosition;varying vec4 vPreviousPosition;
varying vec2 vUV;
uniform vec3 vBumpInfos;uniform vec2 vTangentSpaceParams;
uniform sampler2D reflectivitySampler;varying vec2 vReflectivityUV;
varying vec2 vAlbedoUV;uniform sampler2D albedoSampler;
uniform vec3 reflectivityColor;
uniform vec3 albedoColor;
uniform float metallic;
uniform float glossiness;
uniform sampler2D diffuseSampler;
void main() {
if (texture2D(diffuseSampler,vUV).a<0.4)
discard;
vec3 normalOutput;
vec3 normalW=normalize(vNormalW);
normalOutput=normalW;
normalOutput=normalize(vec3(vWorldView*vec4(normalW,0.0)));
normalOutput=normalize(vNormalV);
normalOutput=normalOutput*0.5+0.5;
gl_FragData[DEPTH_INDEX]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);
gl_FragData[NORMAL_INDEX]=vec4(normalOutput,1.0);
gl_FragData[SCREENSPACE_DEPTH_INDEX]=vec4(gl_FragCoord.z,0.0,0.0,1.0);
gl_FragData[POSITION_INDEX]=vec4(vPositionW,1.0);
vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;vec2 velocity=abs(a-b);velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;gl_FragData[VELOCITY_INDEX]=vec4(velocity,0.0,1.0);
vec2 velocity=vec2(0.5)*((vPreviousPosition.xy/vPreviousPosition.w) -
(vCurrentPosition.xy/vCurrentPosition.w));gl_FragData[VELOCITY_LINEAR_INDEX]=vec4(velocity,0.0,1.0);
vec4 reflectivity=vec4(0.0,0.0,0.0,1.0);
float metal=1.0;float roughness=1.0;
metal*=texture2D(reflectivitySampler,vReflectivityUV).b;roughness*=texture2D(reflectivitySampler,vReflectivityUV).g;
metal*=metallic;
roughness*=(1.0-glossiness);
reflectivity.a-=roughness;vec3 color=vec3(1.0);
color=texture2D(albedoSampler,vAlbedoUV).rgb;
color=toLinearSpace(color);
color*=albedoColor.xyz;
reflectivity.rgb=mix(vec3(0.04),color,metal);
reflectivity=texture2D(reflectivitySampler,vReflectivityUV);
reflectivity.rgb=toLinearSpace(reflectivity.rgb);
reflectivity.rgb=toLinearSpace(reflectivityColor.xyz);reflectivity.a=1.0;
reflectivity.a*=glossiness;
gl_FragData[REFLECTIVITY_INDEX]=reflectivity;
}
`;
// Sideeffect
if (!ShaderStore.ShadersStore[name]) {
ShaderStore.ShadersStore[name] = shader;
}
/** @internal */
export const geometryPixelShader = { name, shader };
//# sourceMappingURL=geometry.fragment.js.map