stk-code_catmod/data/shaders/IBL.frag

32 lines
786 B
GLSL

uniform sampler2D ntex;
uniform sampler2D dtex;
#ifdef GL_ES
layout (location = 0) out vec4 Diff;
layout (location = 1) out vec4 Spec;
#else
out vec4 Diff;
out vec4 Spec;
#endif
#stk_include "utils/decodeNormal.frag"
#stk_include "utils/getPosFromUVDepth.frag"
#stk_include "utils/DiffuseIBL.frag"
#stk_include "utils/SpecularIBL.frag"
void main(void)
{
vec2 uv = gl_FragCoord.xy / u_screen;
vec3 normal = normalize(DecodeNormal(2. * texture(ntex, uv).xy - 1.));
Diff = vec4(0.25 * DiffuseIBL(normal), 1.);
float z = texture(dtex, uv).x;
vec4 xpos = getPosFromUVDepth(vec3(uv, z), u_inverse_projection_matrix);
vec3 eyedir = -normalize(xpos.xyz);
float specval = texture(ntex, uv).z;
Spec = vec4(.25 * SpecularIBL(normal, eyedir, specval), 1.);
}