Skip to content

Instantly share code, notes, and snippets.

@JayFoxRox
Created July 27, 2015 20:14
Show Gist options
  • Save JayFoxRox/866fdc4799e61f63fd67 to your computer and use it in GitHub Desktop.
Save JayFoxRox/866fdc4799e61f63fd67 to your computer and use it in GitHub Desktop.
LIT
#define LIT(dest, src) dest = _out(dest,_LIT(_in(src)))
vec4 _LIT(vec4 src)
{
vec4 s = src;
float epsilon=1.0/256.0;
s.w = clamp(s.w,-(128.0-epsilon),128.0-epsilon);
s.x = max(s.x,0.0);
s.y = max(s.y,0.0);
vec4 t = vec4(1.0, 0.0, 0.0, 1.0);
t.y = s.x;
t.z = (s.x > 0.0) ? exp2(s.w*log2(s.y)) : 0.0;
return t;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment