Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 20 additions & 26 deletions .github/workflows/build-and-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
- closed
branches:
- master
- workflow_debug

jobs:
Build-and-Release:
Expand All @@ -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: |
Expand Down Expand Up @@ -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 }}."
16 changes: 9 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ struct App {
gpu: wgpu_handler::GpuHandler,

// scene
player: Arc<RwLock<object::Player>>,
objects: Arc<Vec<Box<dyn object::Renderable + Send + Sync>>>,
player: RwLock<object::Player>,
objects: Vec<Box<dyn object::Renderable + Send + Sync>>,

// input
keyboard: HashMap<KeyCode, bool>,
Expand All @@ -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<Box<dyn object::Renderable + Send + Sync>>) {
self.objects = Arc::new(objects);
self.objects = objects;
}

pub fn handle_movement(&mut self) {
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -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))),
];
Expand Down
4 changes: 1 addition & 3 deletions src/object/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,4 @@ impl Player {
pub fn update_outputs(&mut self) {
self.camera.update_outputs();
}
}

unsafe impl Sync for Player {}
}
14 changes: 13 additions & 1 deletion src/shaders/material.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var<workgroup> callstack: array<array<Call, 7>, 64>;

fn ray_color(ray_pos: vec3<f32>, ray_dir: vec3<f32>, tid: u32) -> u32 {
var callstack_len = 1;
let light_dir = vec3<f32>(0.57735,0.57735,0);

callstack[tid][0].caller = -1;
callstack[tid][0].ray_pos = ray_pos;
Expand Down Expand Up @@ -92,9 +93,20 @@ fn ray_color(ray_pos: vec3<f32>, ray_dir: vec3<f32>, 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<f32>(
((lit_color.x + 64.0*light)/2),
((lit_color.y + 64.0*light)/2),
((lit_color.z + 64.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 {
Expand Down
Loading