32 lines
780 B
GLSL
Raw Normal View History

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