2014-03-21 13:17:21 -04:00
|
|
|
vec3 DecodeNormal(vec2 n)
|
|
|
|
{
|
2024-01-17 12:13:23 -05:00
|
|
|
n = n * 2.0 - 1.0;
|
|
|
|
vec3 ret = vec3(n.x, n.y, 1.0 - abs(n.x) - abs(n.y));
|
|
|
|
float t = max(-ret.z, 0.0);
|
|
|
|
ret.x += ret.x >= 0.0 ? -t : t;
|
|
|
|
ret.y += ret.y >= 0.0 ? -t : t;
|
|
|
|
return normalize(ret);
|
|
|
|
}
|