summaryrefslogtreecommitdiff
path: root/crates/throwshade
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2025-08-15 04:45:02 -0400
committerLLLL Colonq <llll@colonq>2025-08-15 04:45:02 -0400
commit891a8a79f200413f2b1ac6e158f26163d6c66f64 (patch)
treed2ef73072d2c5c8a9661c5a606a7049e3bf35b8e /crates/throwshade
parente4ded2c09e6c378040f80e80886aa9c087fe14b4 (diff)
Refactor overlay
Diffstat (limited to 'crates/throwshade')
-rw-r--r--crates/throwshade/Cargo.toml20
-rw-r--r--crates/throwshade/index.html24
-rw-r--r--crates/throwshade/src/assets/shaders/throwshade/frag.glsl37
-rw-r--r--crates/throwshade/src/assets/shaders/throwshade/vert.glsl22
-rw-r--r--crates/throwshade/src/lib.rs84
5 files changed, 0 insertions, 187 deletions
diff --git a/crates/throwshade/Cargo.toml b/crates/throwshade/Cargo.toml
deleted file mode 100644
index acf41d7..0000000
--- a/crates/throwshade/Cargo.toml
+++ /dev/null
@@ -1,20 +0,0 @@
-[package]
-name = "newton_throwshade"
-version.workspace = true
-edition.workspace = true
-authors.workspace = true
-
-[lib]
-crate-type = ["cdylib", "rlib"]
-
-[dependencies]
-teleia = { git = "https://github.com/lcolonq/teleia" } # engine
-glam = "*" # linear algebra
-bitflags = "*" # C-style bitwise flags
-rand = "=0.8.5" # rng
-log = "*" # logging
-lazy_static = "*" # global constants
-strum = {version = "*", features = ["derive"]} # utility macros for enums
-wasm-bindgen = "*" # wasm bindings
-wasm-bindgen-futures = "*" # interface with async javascript
-cfg-if = "*" # less verbose cfg \ No newline at end of file
diff --git a/crates/throwshade/index.html b/crates/throwshade/index.html
deleted file mode 100644
index 25b23bc..0000000
--- a/crates/throwshade/index.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!DOCTYPE html>
-<html>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
- <head>
- <meta charset="UTF-8">
- <link data-trunk rel="rust" data-wasm-opt="2" data-target-name="newton_throwshade" />
- <base data-trunk-public-url />
- <meta name="theme-color" media="(prefers-color-scheme: light)" content="white">
- <meta name="theme-color" media="(prefers-color-scheme: dark)" content="#404040">
- <link rel="icon" href="data:;base64,iVBORw0KGgo=">
- <title>teleia</title>
- </head>
- <body>
- <script>
- addEventListener("TrunkApplicationStarted", async (event) => {
- console.log("initialized, starting...");
- window.wasmBindings.main_js();
- window.wasmBindings.set_shader(" vec4 shade(vec2 cs) {return vec4(cs.x, 0.0, 0.0, 1.0);} ");
- });
- </script>
- <div id="teleia-parent"></canvas>
- </body>
-</html>
diff --git a/crates/throwshade/src/assets/shaders/throwshade/frag.glsl b/crates/throwshade/src/assets/shaders/throwshade/frag.glsl
deleted file mode 100644
index 962deac..0000000
--- a/crates/throwshade/src/assets/shaders/throwshade/frag.glsl
+++ /dev/null
@@ -1,37 +0,0 @@
-#version 300 es
-precision highp float;
-
-in vec2 vertex_texcoord;
-out vec4 frag_color;
-
-uniform float opacity;
-
-uniform vec2 resolution;
-
-uniform float time;
-
-uniform float bpm;
-
-uniform vec2 cursor;
-
-uniform float chat_time;
-uniform float chat_biblicality;
-
-uniform float tracking_mouth;
-uniform vec2 tracking_eyes;
-uniform mat4 tracking_neck;
-
-uniform vec2 emacs_cursor;
-uniform vec2 mouse_cursor;
-
-uniform int heartrate;
-
-vec4 shade(vec2);
-
-void main() {
- vec2 inverted = vec2(vertex_texcoord.x, 1.0 - vertex_texcoord.y);
- frag_color = shade(inverted);
- frag_color.a = clamp(frag_color.a * opacity, 0.0, opacity);
-}
-
-// "The Cutoff"
diff --git a/crates/throwshade/src/assets/shaders/throwshade/vert.glsl b/crates/throwshade/src/assets/shaders/throwshade/vert.glsl
deleted file mode 100644
index e05bbb6..0000000
--- a/crates/throwshade/src/assets/shaders/throwshade/vert.glsl
+++ /dev/null
@@ -1,22 +0,0 @@
-#version 300 es
-precision highp float;
-
-out vec2 vertex_texcoord;
-
-void main() {
- const vec2 positions[4] = vec2[](
- vec2(-1, -1),
- vec2(+1, -1),
- vec2(-1, +1),
- vec2(+1, +1)
- );
- const vec2 coords[4] = vec2[](
- vec2(0, 0),
- vec2(1, 0),
- vec2(0, 1),
- vec2(1, 1)
- );
-
- vertex_texcoord = coords[gl_VertexID];
- gl_Position = vec4(positions[gl_VertexID], 0.0, 1.0);
-}
diff --git a/crates/throwshade/src/lib.rs b/crates/throwshade/src/lib.rs
deleted file mode 100644
index ab1c9bf..0000000
--- a/crates/throwshade/src/lib.rs
+++ /dev/null
@@ -1,84 +0,0 @@
-use teleia::*;
-
-const VERT: &'static str = include_str!("assets/shaders/throwshade/vert.glsl");
-const FRAG: &'static str = include_str!("assets/shaders/throwshade/frag.glsl");
-
-pub struct ThrowShade {
- pub tickset: u64,
- pub timeset: f64,
- pub author: String,
- pub shader: Option<shader::Shader>,
-}
-impl ThrowShade {
- pub fn new() -> Self {
- Self {
- tickset: 0,
- timeset: 0.0,
- author: String::new(),
- shader: None,
- }
- }
- pub fn set(&mut self, ctx: &context::Context, st: &state::State, src: &str) -> Result<(), String> {
- let fsrc = format!("{}\n{}\n", FRAG, src);
- self.tickset = st.tick;
- self.timeset = 0.0;
- #[cfg(not(target_arch = "wasm32"))]
- if let Ok(dur) = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH) {
- self.timeset = dur.as_secs_f64();
- }
- if let Some(s) = &mut self.shader {
- s.replace(ctx, VERT, &fsrc)?;
- } else {
- self.shader = Some(shader::Shader::new_helper(ctx, VERT, &fsrc)?);
- }
- Ok(())
- }
-}
-
-cfg_if::cfg_if! {
- if #[cfg(target_arch = "wasm32")] {
- struct Game {
- throwshade: ThrowShade,
- }
- impl Game {
- pub fn new(_ctx: &context::Context) -> Self {
- Self {
- throwshade: ThrowShade::new(),
- }
- }
- }
- impl state::Game for Game {
- fn render(&mut self, ctx: &context::Context, st: &mut state::State) -> Erm<()> {
- if let Some(s) = &self.throwshade.shader {
- ctx.clear_color(glam::Vec4::new(0.0, 0.0, 0.0, 0.0));
- ctx.clear();
- s.bind(ctx);
- s.set_f32(ctx, "opacity", 0.5);
- s.set_vec2(ctx, "resolution", &glam::Vec2::new(ctx.render_width, ctx.render_height));
- let elapsed = (st.tick - self.throwshade.tickset) as f32 / 60.0;
- s.set_f32(ctx, "time", elapsed);
- ctx.render_no_geometry();
- }
- Ok(())
- }
- }
-
- use wasm_bindgen::prelude::*;
- #[wasm_bindgen]
- pub fn main_js() {
- teleia::run(1920, 1080, teleia::Options::NORESIZE, Game::new);
- }
- #[wasm_bindgen]
- pub async fn set_shader(s: &str) -> Result<(), String> {
- contextualize(|ctx, st, g: &mut Game| {
- log::info!("set shader: {}", s);
- if let Err(e) = g.throwshade.set(ctx, st, &s) {
- log::warn!("error compiling shader: {}", e);
- g.throwshade.shader = None;
- return Err(format!("{}", e));
- }
- Ok(())
- })
- }
- }
-}