diff options
author | chai <chaifix@163.com> | 2020-02-25 23:41:30 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2020-02-25 23:41:30 +0800 |
commit | 1a94259666a0d98e98e6999f19cf07475b618e65 (patch) | |
tree | 502450d9ce77dca2234898badaf22a43ecf89d7e /src/shaders/common.c | |
parent | 87b9482459c1a27b8756514473ae392453db39ec (diff) |
*camera
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 |