stk-code_catmod/data/shaders/IBL.frag

32 lines
786 B
GLSL
Raw Normal View History

2014-03-01 14:08:17 -05:00
uniform sampler2D ntex;
2014-10-05 20:19:21 -04:00
uniform sampler2D dtex;
2014-03-01 14:08:17 -05:00
2016-09-12 15:39:52 -04:00
#ifdef GL_ES
layout (location = 0) out vec4 Diff;
layout (location = 1) out vec4 Spec;
#else
2014-03-01 14:08:17 -05:00
out vec4 Diff;
2014-10-05 20:19:21 -04:00
out vec4 Spec;
2016-09-12 15:39:52 -04:00
#endif
2014-03-01 14:08:17 -05:00
#stk_include "utils/decodeNormal.frag"
#stk_include "utils/getPosFromUVDepth.frag"
#stk_include "utils/DiffuseIBL.frag"
#stk_include "utils/SpecularIBL.frag"
2014-03-01 14:08:17 -05:00
void main(void)
{
vec2 uv = gl_FragCoord.xy / u_screen;
2014-03-01 14:08:17 -05:00
vec3 normal = normalize(DecodeNormal(2. * texture(ntex, uv).xy - 1.));
2014-10-05 20:19:21 -04:00
2014-12-07 13:10:22 -05:00
Diff = vec4(0.25 * DiffuseIBL(normal), 1.);
2014-10-05 20:19:21 -04:00
float z = texture(dtex, uv).x;
vec4 xpos = getPosFromUVDepth(vec3(uv, z), u_inverse_projection_matrix);
2014-10-05 20:19:21 -04:00
vec3 eyedir = -normalize(xpos.xyz);
2014-11-20 20:44:27 -05:00
float specval = texture(ntex, uv).z;
2014-12-07 13:10:22 -05:00
2014-12-08 13:36:23 -05:00
Spec = vec4(.25 * SpecularIBL(normal, eyedir, specval), 1.);
2014-03-01 14:08:17 -05:00
}