aboutsummaryrefslogtreecommitdiff
path: root/shadeop.c
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2024-01-30 12:01:01 +0000
committerrodri <rgl@antares-labs.eu>2024-01-30 12:01:01 +0000
commit37da5f0a27740bb43bac67a2eb98f725beca975e (patch)
tree2e403bbd2f477e65c8b82f10e950721b4103c895 /shadeop.c
parentdf792cbb5cf94abf0d286ebfd73bad9714dce509 (diff)
downloadlibgraphics-37da5f0a27740bb43bac67a2eb98f725beca975e.tar.gz
libgraphics-37da5f0a27740bb43bac67a2eb98f725beca975e.tar.bz2
libgraphics-37da5f0a27740bb43bac67a2eb98f725beca975e.zip
import the new renderer and clean things up.
i integrated the renderer i've been developing on the tinyrend repo and got rid of a bunch of stuff that's no longer necessary. also began structuring things to fit the new interface i have in mind. there are still some artifacts with the projection xforms that cause issues with clipping and division by zero.
Diffstat (limited to 'shadeop.c')
-rw-r--r--shadeop.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/shadeop.c b/shadeop.c
new file mode 100644
index 0000000..c1484c3
--- /dev/null
+++ b/shadeop.c
@@ -0,0 +1,26 @@
+#include <u.h>
+#include <libc.h>
+#include <thread.h>
+#include <draw.h>
+#include <memdraw.h>
+#include <geometry.h>
+#include "libobj/obj.h"
+#include "graphics.h"
+#include "internal.h"
+
+double
+step(double edge, double n)
+{
+ if(n < edge)
+ return 0;
+ return 1;
+}
+
+double
+smoothstep(double edge0, double edge1, double n)
+{
+ double t;
+
+ t = fclamp((n-edge0)/(edge1-edge0), 0, 1);
+ return t*t * (3 - 2*t);
+}