transparency first version

This commit is contained in:
zomseffen 2025-01-30 11:03:30 +01:00
parent f0fa28bdd8
commit 66902df99c
14 changed files with 225 additions and 92 deletions
src/scene

View file

@ -11,7 +11,6 @@ use cgmath::{vec2, vec3, Vector3};
use std::cell::RefCell;
use std::rc::Rc;
use crate::app_data;
use crate::app_data::AppData;
use crate::buffer;
use crate::primitives::rec_cuboid::Cuboid;
@ -68,7 +67,7 @@ impl Scene {
for x_index in 0..grid_size {
for y_index in 0..grid_size {
let shade = (rng.gen_range(0..25) as f32) / 100.0;
let shade = (rng.gen_range(0..50) as f32) / 100.0;
let cube = Cube {
pos: vec3(x_index as f32, y_index as f32, 5.0),
color: vec3(shade, 1.0, shade),
@ -83,17 +82,24 @@ impl Scene {
let shade = (rng.gen_range(0..25) as f32) / 100.0;
let cube = Cube {
pos: vec3(10.0, 10.0, 10.0),
color: vec3(1.0, 1.0, 0.0),
color: vec3(1.0, 0.0, 0.0),
tex_coord: vec2(0.0, 0.0),
transparent: true,
};
oct_tree.set_cube(cube.clone());
let cube = Cube {
pos: vec3(10.0, 10.0, 9.0),
color: vec3(1.0, 0.0, 0.0),
tex_coord: vec2(0.0, 0.0),
transparent: true,
};
oct_tree.set_cube(cube.clone());
self.point_lights.push(PointLight { pos: vec3(11.0, 11.0, 11.0), color: vec3(0.5, 0.5, 0.5), memory_start: 0 });
self.point_lights.push(PointLight { pos: vec3(9.0, 9.0, 11.0), color: vec3(0.5, 0.5, 0.5), memory_start: 0 });
let mut empty_volumes: Vec<Rc<RefCell<EmptyVolume>>>;
let empty_volumes: Vec<Rc<RefCell<EmptyVolume>>>;
(empty_volumes, _) = EmptyVolume::from_oct_tree(&oct_tree);
println!("number of empty volumes is {}", empty_volumes.len());
@ -124,7 +130,7 @@ impl Scene {
let cube = Cuboid {
pos: vec3(11.0, 11.0, 11.0),
color: vec3(shade, 1.0, shade),
color: vec3(1.0, 1.0, 1.0),
tex_coord: vec2(0.0, 0.0),
size: Vector3 {x: 0.5, y: 0.5, z: 0.5}
};
@ -133,7 +139,7 @@ impl Scene {
let cube = Cuboid {
pos: vec3(9.0, 9.0, 11.0),
color: vec3(shade, 1.0, shade),
color: vec3(1.0, 1.0, 1.0),
tex_coord: vec2(0.0, 0.0),
size: Vector3 {x: 0.5, y: 0.5, z: 0.5}
};