diff options
Diffstat (limited to 'src/shaders/common.c')
-rw-r--r-- | src/shaders/common.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/shaders/common.c b/src/shaders/common.c index 3b58524..411c7e4 100644 --- a/src/shaders/common.c +++ b/src/shaders/common.c @@ -1,6 +1,9 @@ #include "common.h" -Vec3 normal_from_color(Color32 c32) { +Vec4 _proj_params; +Vec2 _time; + +Vec3 unpacknormal(Color32 c32) { Vec3 normal = { c32.r * 2 - 1, c32.g * 2 - 1, @@ -25,4 +28,11 @@ Vec2 texsize(Texture* texture) { return size; } +float linear01depth(float depth) { + float n = _proj_params.x, f = _proj_params.y; + return n / ((n-f)*depth + f); +} +float lineareyedepth(float depth) { + return _proj_params.y * linear01depth(depth); +}
\ No newline at end of file |