2014-02-12 16:16:10 -05:00
|
|
|
#version 330
|
2014-01-15 19:08:37 -05:00
|
|
|
noperspective in vec3 nor;
|
2014-01-27 17:29:46 -05:00
|
|
|
out vec2 EncodedNormal;
|
|
|
|
|
|
|
|
// from Crytek "a bit more deferred CryEngine"
|
|
|
|
vec2 EncodeNormal(vec3 n)
|
|
|
|
{
|
|
|
|
return normalize(n.xy) * sqrt(n.z * 0.5 + 0.5);
|
|
|
|
}
|
2014-01-15 19:08:37 -05:00
|
|
|
|
|
|
|
void main(void)
|
|
|
|
{
|
2014-01-27 17:29:46 -05:00
|
|
|
EncodedNormal = 0.5 * EncodeNormal(normalize(nor)) + 0.5;
|
2014-01-15 19:08:37 -05:00
|
|
|
}
|