// Do not edit. import { ShaderStore } from "../Engines/shaderStore.js"; const name = "screenSpaceReflectionPixelShader"; const shader = `uniform sampler2D textureSampler; #ifdef SSR_SUPPORTED uniform sampler2D reflectivitySampler;uniform sampler2D normalSampler;uniform sampler2D positionSampler; #endif uniform mat4 view;uniform mat4 projection;uniform float stepSize;uniform float strength;uniform float threshold;uniform float roughnessFactor;uniform float reflectionSpecularFalloffExponent;varying vec2 vUV; #ifdef SSR_SUPPORTED struct ReflectionInfo {vec3 color;vec4 coords;};/** * According to specular,see https: */ vec3 fresnelSchlick(float cosTheta,vec3 F0) {return F0+(1.0-F0)*pow(1.0-cosTheta,5.0);} /** * Once the pixel's coordinates has been found,let's adjust (smooth) a little bit * by sampling multiple reflection pixels. */ ReflectionInfo smoothReflectionInfo(vec3 dir,vec3 hitCoord) {ReflectionInfo info;info.color=vec3(0.0);vec4 projectedCoord;float sampledDepth;for(int i=0; i0.0) hitCoord-=dir;else hitCoord+=dir;info.color+=texture2D(textureSampler,projectedCoord.xy).rgb;} projectedCoord=projection*vec4(hitCoord,1.0);projectedCoord.xy/=projectedCoord.w;projectedCoord.xy=0.5*projectedCoord.xy+vec2(0.5);info.coords=vec4(projectedCoord.xy,sampledDepth,1.0);info.color+=texture2D(textureSampler,projectedCoord.xy).rgb;info.color/=float(SMOOTH_STEPS+1);return info;} /** * Tests the given world position (hitCoord) according to the given reflection vector (dir) * until it finds a collision (means that depth is enough close to say "it's the pixel to sample!"). */ ReflectionInfo getReflectionInfo(vec3 dir,vec3 hitCoord) {ReflectionInfo info;vec4 projectedCoord;float sampledDepth;dir*=stepSize;for(int i=0; i