stk-code_catmod/data/shaders/objectref_pass1.frag

27 lines
446 B
GLSL
Raw Normal View History

2014-01-18 19:32:08 -05:00
uniform sampler2D tex;
#if __VERSION__ >= 130
in vec3 nor;
2014-01-18 19:32:08 -05:00
in vec2 uv;
out vec2 EncodedNormal;
#else
varying vec3 nor;
varying vec2 uv;
#define EncodedNormal gl_FragColor.xy
#endif
// from Crytek "a bit more deferred CryEngine"
vec2 EncodeNormal(vec3 n)
{
return normalize(n.xy) * sqrt(n.z * 0.5 + 0.5);
}
2014-01-18 19:32:08 -05:00
void main() {
vec4 col = texture(tex, uv);
2014-01-18 19:32:08 -05:00
if (col.a < 0.5)
discard;
EncodedNormal = 0.5 * EncodeNormal(normalize(nor)) + 0.5;
2014-01-18 19:32:08 -05:00
}