+#version 300 es
+
// Original Code
// https://github.com/KhronosGroup/glTF-Sample-Viewer/blob/glTF-WebGL-PBR/shaders/pbr-frag.glsl
// Commit dc84b5e374fb3d23153d2248a338ef88173f9eb6
// [4] \"An Inexpensive BRDF Model for Physically based Rendering\" by Christophe Schlick
// https://www.cs.virginia.edu/~jdl/bib/appearance/analytic%20models/schlick94b.pdf
-#version 300 es
-
#ifdef HIGHP
precision highp float;
#else
#endif
//// For IBL
+uniform sampler2D sbrdfLUT;
uniform samplerCube sDiffuseEnvSampler;
uniform samplerCube sSpecularEnvSampler;
-uniform sampler2D sbrdfLUT;
uniform float uIblIntensity;
+uniform vec3 uYDirection;
// For Alpha Mode.
uniform lowp float uOpaque;
mediump vec3 reflection = -normalize(reflect(v, n));
lowp vec3 color = vec3(0.0);
- lowp vec3 diffuseLight = linear(texture(sDiffuseEnvSampler, n).rgb);
- lowp vec3 specularLight = linear(texture(sSpecularEnvSampler, reflection).rgb);
+ lowp vec3 diffuseLight = linear(texture(sDiffuseEnvSampler, n * uYDirection).rgb);
+ lowp vec3 specularLight = linear(texture(sSpecularEnvSampler, reflection * uYDirection).rgb);
// retrieve a scale and bias to F0. See [1], Figure 3
lowp vec3 brdf = linear(texture(sbrdfLUT, vec2(NdotV, 1.0 - perceptualRoughness)).rgb);