From e72952958a2ff86768070ef3ff7e0411e34a7574 Mon Sep 17 00:00:00 2001 From: prushton2 Date: Mon, 6 Apr 2026 09:27:54 -0400 Subject: [PATCH 1/4] New workflow --- .github/workflows/build-and-release.yaml | 46 +++++++++++------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build-and-release.yaml b/.github/workflows/build-and-release.yaml index 07f6862..fc52ced 100644 --- a/.github/workflows/build-and-release.yaml +++ b/.github/workflows/build-and-release.yaml @@ -6,7 +6,6 @@ on: - closed branches: - master - - workflow_debug jobs: Build-and-Release: @@ -16,37 +15,32 @@ jobs: - name: Check out repository code uses: actions/checkout@v5 - - name: Get next version id: version + env: + LABELS_JSON: ${{ toJson(github.event.pull_request.labels) }} + GH_TOKEN: ${{ github.token }} run: | - COMMIT_MSG=$(git log -1 --pretty=%B) - echo "Commit message: $COMMIT_MSG" - - # Check for explicit version e.g. "version: 1.2.0" - EXPLICIT=$(echo "$COMMIT_MSG" | grep -oP 'version:\s*\K[0-9]+\.[0-9]+\.[0-9]+') + LABELS=$(echo "$LABELS_JSON" | jq .[].name) + echo "LABELS: \n$LABELS" + LATEST=$(gh release view --json tagName --jq '.tagName') + echo "Latest release: $LATEST" + + MAJOR=$(echo $LATEST | cut -d. -f1 | tr -d v) + MINOR=$(echo $LATEST | cut -d. -f2) + PATCH=$(echo $LATEST | cut -d. -f3) - if [ -n "$EXPLICIT" ]; then - NEW_TAG="v$EXPLICIT" - else - LATEST=$(git tag --sort=-v:refname | head -n1) - LATEST=${LATEST:-v0.0.0} - MAJOR=$(echo $LATEST | cut -d. -f1 | tr -d v) - MINOR=$(echo $LATEST | cut -d. -f2) - PATCH=$(echo $LATEST | cut -d. -f3) - - if echo "$COMMIT_MSG" | grep -q "#major"; then - NEW_TAG="v$((MAJOR + 1)).0.0" - elif echo "$COMMIT_MSG" | grep -q "#minor"; then - NEW_TAG="v$MAJOR.$((MINOR + 1)).0" - else - NEW_TAG="v$MAJOR.$MINOR.$((PATCH + 1))" - fi + if echo "$LABELS" | grep -q "major"; then + NEW_TAG="v$((MAJOR + 1)).0.0" + elif echo "$LABELS" | grep -q "minor"; then + NEW_TAG="v$MAJOR.$((MINOR + 1)).0" + elif echo "$LABELS" | grep -q "patch"; then + NEW_TAG="v$MAJOR.$MINOR.$((PATCH + 1))" fi - echo "Version: $NEW_TAG" + echo "New Release: $NEW_TAG" echo "tag=$NEW_TAG" >> $GITHUB_OUTPUT - + - name: Install dependencies run: | @@ -74,4 +68,4 @@ jobs: ./RenderEngine-linux ./RenderEngine-windows.exe - - run: echo "This job's status is ${{ job.status }}." + - run: echo "This job's status is ${{ job.status }}." \ No newline at end of file From 4a55546fae55c29deb77c16c504b9dae5594da2f Mon Sep 17 00:00:00 2001 From: prushton2 Date: Mon, 6 Apr 2026 10:17:16 -0400 Subject: [PATCH 2/4] Cleaned up code from cpu multithreading --- src/main.rs | 16 +++++++++------- src/object/player.rs | 4 +--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main.rs b/src/main.rs index fa47567..805a9b4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,8 +27,8 @@ struct App { gpu: wgpu_handler::GpuHandler, // scene - player: Arc>, - objects: Arc>>, + player: RwLock, + objects: Vec>, // input keyboard: HashMap, @@ -45,11 +45,11 @@ struct App { impl App { pub fn consume_player(&mut self, player: object::Player) { - self.player = Arc::new(RwLock::new(player)); + self.player = RwLock::new(player); } pub fn consume_objects(&mut self, objects: Vec>) { - self.objects = Arc::new(objects); + self.objects = objects; } pub fn handle_movement(&mut self) { @@ -179,8 +179,8 @@ impl Default for App { window: None, gpu: wgpu_handler::GpuHandler::default(), - player: Arc::new(RwLock::new(object::Player::new(object::Camera::zero()))), - objects: Arc::new(vec![]), + player: RwLock::new(object::Player::new(object::Camera::zero())), + objects: vec![], keyboard: HashMap::new(), mouse_delta: (0.0, 0.0), @@ -271,7 +271,8 @@ impl ApplicationHandler for App { print!("\x1B[2J\x1B[1;1H"); println!(" FPS: {}\n\n Time between frames: {}ms\n\n Camera position: {:?}\n Player Rotation: {:?}", self.fps_stat, self.deltatime_stat, player.get_camera().pos(), player.get_rotation()); - // this makes the deltatime not crash out when the fps gets too high + // this makes the deltatime not crash out when the fps gets too high, + // but caps the fps at 1000 if self.deltatime < 1.0 { std::thread::sleep(std::time::Duration::from_millis(1)); } @@ -362,6 +363,7 @@ fn main() { Box::new(object::Sphere::new(&ds::Vector3::new(-4.0, 1.0, 6.0), 0.49, GpuMaterial::new(0x00000000, 0, 50))), Box::new(object::Sphere::new(&ds::Vector3::new(-4.0, 2.0, 6.0), 0.49, GpuMaterial::new(0x00FF0000, 0, 0))), + // mirror sphere Box::new(object::Sphere::new(&ds::Vector3::new(4.0, 0.0, 3.0), 2.0, GpuMaterial::new(0x00AAAAAA, 90, 0))), Box::new(object::Sphere::new(&ds::Vector3::new(4.0, 0.3, 3.0), 0.25, GpuMaterial::new(0x000000FF, 0, 0))), ]; diff --git a/src/object/player.rs b/src/object/player.rs index e9b2b86..0a01543 100644 --- a/src/object/player.rs +++ b/src/object/player.rs @@ -59,6 +59,4 @@ impl Player { pub fn update_outputs(&mut self) { self.camera.update_outputs(); } -} - -unsafe impl Sync for Player {} \ No newline at end of file +} \ No newline at end of file From 732290f79429ada0defd1dcafff0c1e021201cd7 Mon Sep 17 00:00:00 2001 From: prushton2 Date: Mon, 6 Apr 2026 10:38:26 -0400 Subject: [PATCH 3/4] Added lighting with a fixed direction --- src/shaders/material.wgsl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/shaders/material.wgsl b/src/shaders/material.wgsl index af961ea..6ddcee3 100644 --- a/src/shaders/material.wgsl +++ b/src/shaders/material.wgsl @@ -11,6 +11,7 @@ var callstack: array, 64>; fn ray_color(ray_pos: vec3, ray_dir: vec3, tid: u32) -> u32 { var callstack_len = 1; + let light_dir = vec3(0.57735,0.57735,0); callstack[tid][0].caller = -1; callstack[tid][0].ray_pos = ray_pos; @@ -92,9 +93,20 @@ fn ray_color(ray_pos: vec3, ray_dir: vec3, tid: u32) -> u32 { pushed_to_stack = true; } + var lit_color = material.color; + + if material.reflect + material.translucent < 100 { + let light = max(dot(record.normal, light_dir), 0.0); + lit_color = vec3( + ((lit_color.x + 128.0*light)/2), + ((lit_color.y + 128.0*light)/2), + ((lit_color.z + 128.0*light)/2), + ); + } + if !pushed_to_stack { call = callstack[tid][index]; - var color = f32(material.translucent) * call.outputs[0] + f32(material.reflect) * call.outputs[1] + f32(100 - material.translucent - material.reflect) * material.color; + var color = f32(material.translucent) * call.outputs[0] + f32(material.reflect) * call.outputs[1] + f32(100 - material.translucent - material.reflect) * lit_color; color = color / 100.0; if call.caller != -1 { From 1aa96885fbbe084ddc9874ad619a8e2804d946b4 Mon Sep 17 00:00:00 2001 From: prushton2 Date: Mon, 6 Apr 2026 10:39:39 -0400 Subject: [PATCH 4/4] lighting is more subtle --- src/shaders/material.wgsl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/shaders/material.wgsl b/src/shaders/material.wgsl index 6ddcee3..48506ec 100644 --- a/src/shaders/material.wgsl +++ b/src/shaders/material.wgsl @@ -98,9 +98,9 @@ fn ray_color(ray_pos: vec3, ray_dir: vec3, tid: u32) -> u32 { if material.reflect + material.translucent < 100 { let light = max(dot(record.normal, light_dir), 0.0); lit_color = vec3( - ((lit_color.x + 128.0*light)/2), - ((lit_color.y + 128.0*light)/2), - ((lit_color.z + 128.0*light)/2), + ((lit_color.x + 64.0*light)/2), + ((lit_color.y + 64.0*light)/2), + ((lit_color.z + 64.0*light)/2), ); }