Compare commits
No commits in common. "master" and "volumetrics" have entirely different histories.
master
...
volumetric
13 changed files with 49 additions and 33 deletions
2
build.rs
2
build.rs
|
@ -3,7 +3,7 @@ use std::io::{self, Write};
|
|||
use std::path::Path;
|
||||
|
||||
use std::fs::File;
|
||||
use std::io::{BufReader, BufRead};
|
||||
use std::io::{BufReader, BufRead, Error};
|
||||
|
||||
fn insert_place_holders(path: &str) {
|
||||
let input = File::open(path).unwrap();
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -484,9 +484,12 @@ Tracing trace_ray(uint volume_start, vec3 starting_pos, vec3 start_direction, fl
|
|||
vec3 mid_point = oct_tree_pos + float(current_size / 2) * vec3(compound_scale, compound_scale, compound_scale);
|
||||
bool children_open[8] = {true, true, true, true, true, true, true, true};
|
||||
uint oct_tree_address = oct_tree_index;
|
||||
/*if (oct_tree_address == 337042) {
|
||||
result.has_hit = true;
|
||||
}*/
|
||||
// iterate through the oct_tree
|
||||
uint check_it = 0;
|
||||
uint max_check_it = 70;
|
||||
uint max_check_it = 80;
|
||||
uint prev_child = 0;
|
||||
uint prev_prev_child = 0;
|
||||
|
||||
|
|
|
@ -482,9 +482,12 @@ Tracing trace_ray(uint volume_start, vec3 starting_pos, vec3 start_direction, fl
|
|||
vec3 mid_point = oct_tree_pos + float(current_size / 2) * vec3(compound_scale, compound_scale, compound_scale);
|
||||
bool children_open[8] = {true, true, true, true, true, true, true, true};
|
||||
uint oct_tree_address = oct_tree_index;
|
||||
/*if (oct_tree_address == 337042) {
|
||||
result.has_hit = true;
|
||||
}*/
|
||||
// iterate through the oct_tree
|
||||
uint check_it = 0;
|
||||
uint max_check_it = 70;
|
||||
uint max_check_it = 80;
|
||||
uint prev_child = 0;
|
||||
uint prev_prev_child = 0;
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ pub type Mat4 = cgmath::Matrix4<f32>;
|
|||
|
||||
use crate::app_data;
|
||||
use crate::command_buffer;
|
||||
use crate::primitives;
|
||||
use crate::vertex;
|
||||
use crate::vertex::VertexContainer;
|
||||
use crate::scene;
|
||||
|
|
|
@ -22,6 +22,7 @@ use vulkanalia::bytecode::Bytecode;
|
|||
|
||||
use std::collections::HashSet;
|
||||
use std::ffi::CStr;
|
||||
use std::time::{Duration, SystemTime};
|
||||
use std::os::raw::c_void;
|
||||
|
||||
// extension imports
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use cgmath::{ElementWise, InnerSpace, Vector3};
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::cell::{RefCell, Ref};
|
||||
use std::rc::Rc;
|
||||
|
||||
use std::time::Instant;
|
||||
|
@ -11,6 +11,8 @@ use crate::primitives::quad::Quad;
|
|||
use crate::scene::oct_tree::OctTree;
|
||||
|
||||
use super::memorizable::Memorizable;
|
||||
use super::light::LightSource;
|
||||
use super::light::PointLight;
|
||||
use super::volumetrics::ShapeComposition;
|
||||
use super::AppData;
|
||||
use super::LightsIter;
|
||||
|
@ -993,24 +995,24 @@ impl EmptyVolume {
|
|||
pub fn select_lights(&self, lights: LightsIter, light_number: u32, min_light_weight: f32) -> Vec<u32> {
|
||||
let mut weighted_indices = vec![];
|
||||
for light in lights {
|
||||
//let mut has_hitable_side = false;
|
||||
let mut has_hitable_side = false;
|
||||
if self.color_bottom.len() > 0 {
|
||||
let center = self.real_position + Vector3{x: self.size_x as f32 * 0.5, y: self.size_y as f32 * 0.5, z: self.size_z as f32 * 0.0 - 0.5} * self.scale;
|
||||
let normal = Vector3 {x: 0.0, y: 0.0, z: 1.0};
|
||||
|
||||
let dir = light.borrow().get_direction(center);
|
||||
/*if normal.dot(dir) < 0.0 {
|
||||
if normal.dot(dir) < 0.0 {
|
||||
has_hitable_side = true;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
if self.color_top.len() > 0 {
|
||||
let center = self.real_position + Vector3{x: self.size_x as f32 * 0.5, y: self.size_y as f32 * 0.5, z: self.size_z as f32 * 1.0 - 0.5} * self.scale;
|
||||
let normal = Vector3 {x: 0.0, y: 0.0, z: -1.0};
|
||||
|
||||
let dir = light.borrow().get_direction(center);
|
||||
/*if normal.dot(dir) < 0.0 {
|
||||
if normal.dot(dir) < 0.0 {
|
||||
has_hitable_side = true;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
if self.color_front.len() > 0 {
|
||||
|
@ -1018,9 +1020,9 @@ impl EmptyVolume {
|
|||
let normal = Vector3 {x: 0.0, y: 1.0, z: 0.0};
|
||||
|
||||
let dir = light.borrow().get_direction(center);
|
||||
/*if normal.dot(dir) < 0.0 {
|
||||
if normal.dot(dir) < 0.0 {
|
||||
has_hitable_side = true;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
if self.color_back.len() > 0 {
|
||||
|
@ -1028,9 +1030,9 @@ impl EmptyVolume {
|
|||
let normal = Vector3 {x: 0.0, y: -1.0, z: 0.0};
|
||||
|
||||
let dir = light.borrow().get_direction(center);
|
||||
/*if normal.dot(dir) < 0.0 {
|
||||
if normal.dot(dir) < 0.0 {
|
||||
has_hitable_side = true;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
if self.color_left.len() > 0 {
|
||||
|
@ -1038,9 +1040,9 @@ impl EmptyVolume {
|
|||
let normal = Vector3 {x: 1.0, y: 0.0, z: 0.0};
|
||||
|
||||
let dir = light.borrow().get_direction(center);
|
||||
/*if normal.dot(dir) < 0.0 {
|
||||
if normal.dot(dir) < 0.0 {
|
||||
has_hitable_side = true;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
if self.color_right.len() > 0 {
|
||||
|
@ -1048,9 +1050,9 @@ impl EmptyVolume {
|
|||
let normal = Vector3 {x: -1.0, y: 0.0, z: 0.0};
|
||||
|
||||
let dir = light.borrow().get_direction(center);
|
||||
/*if normal.dot(dir) < 0.0 {
|
||||
if normal.dot(dir) < 0.0 {
|
||||
has_hitable_side = true;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
/*if !has_hitable_side {
|
||||
|
@ -1104,8 +1106,8 @@ impl EmptyVolume {
|
|||
}
|
||||
|
||||
pub fn combine_results(first: &Rc<RefCell<OctTree<Cube>>>,first_neighbors: &Rc<OctTree<Rc<RefCell<EmptyVolume>>>>, second: &Rc<RefCell<OctTree<Cube>>>, second_neighbors: &Rc<OctTree<Rc<RefCell<EmptyVolume>>>>, facing: vertex::Facing) {
|
||||
let first_start;
|
||||
let second_start;
|
||||
let mut first_start;
|
||||
let mut second_start;
|
||||
|
||||
let step_one;
|
||||
let step_two;
|
||||
|
@ -1166,7 +1168,7 @@ impl EmptyVolume {
|
|||
if !done_volumes.contains(&volume) {
|
||||
|
||||
let mask = Vector3 {x: 1, y: 1, z: 1} - (step_one + step_two);
|
||||
let negated_mask = step_one + step_two;
|
||||
let negated_mask = (step_one + step_two);
|
||||
|
||||
let volume_start_first = negated_mask.mul_element_wise(volume.borrow().grid_position) + first_pos.mul_element_wise(mask);
|
||||
let volume_start_second = negated_mask.mul_element_wise(volume.borrow().grid_position) + second_pos.mul_element_wise(mask);
|
||||
|
@ -1641,7 +1643,7 @@ impl Memorizable for EmptyVolume {
|
|||
}
|
||||
else {
|
||||
v[mem_index] = 0;
|
||||
//mem_index += 1;
|
||||
mem_index += 1;
|
||||
}
|
||||
|
||||
self.dirty = false;
|
||||
|
|
|
@ -16,10 +16,10 @@ use cgmath::{vec2, vec3, Vector3, Point3};
|
|||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
use super::light::PointLight;
|
||||
use super::light::{DirectionalLight, PointLight};
|
||||
|
||||
|
||||
pub fn generate_test_scene(scene: &mut Scene, data: &mut AppData) -> Result<Point3<f32>> {
|
||||
pub fn generate_test_scene(scene: &mut Scene, data: &mut AppData) -> Result<(Point3<f32>)> {
|
||||
let mut rng = rand::thread_rng();
|
||||
let grid_size = CHUNK_SIZE as i32;
|
||||
|
||||
|
@ -137,11 +137,11 @@ pub fn generate_test_scene(scene: &mut Scene, data: &mut AppData) -> Result<Poin
|
|||
comp.excluded_shapes.push(Rc::new(RefCell::new(Rect::new(Vector3 { x: -5.0 + grid_size as f32, y: 5.0 + grid_size as f32, z: 10.0 }, Vector3 { x: 0.0, y: 0.0, z: 0.0 }, Vector3 { x: 3.0, y: 8.0, z: 2.0 },Vector3 { x: 0, y: 0, z: 255 }, 64, false))));
|
||||
//scene.volumetrics.push(Rc::new(RefCell::new(comp)));
|
||||
|
||||
Ok(cgmath::point3(5.0, 5.0, 10.0))
|
||||
Ok((cgmath::point3(5.0, 5.0, 10.0)))
|
||||
}
|
||||
|
||||
|
||||
pub fn generate_test_scene2(scene: &mut Scene, data: &mut AppData, chunk_num_x: usize, chunk_num_y: usize, chunk_num_z: usize, num_gaussians: usize) -> Result<Point3<f32>> {
|
||||
pub fn generate_test_scene2(scene: &mut Scene, data: &mut AppData, chunk_num_x: usize, chunk_num_y: usize, chunk_num_z: usize, num_gaussians: usize) -> Result<(Point3<f32>)> {
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
let scale = 1.0;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use cgmath::{InnerSpace, Vector3};
|
||||
use cgmath::AbsDiffEq;
|
||||
use cgmath::{InnerSpace, MetricSpace, Vector3};
|
||||
|
||||
use crate::vertex;
|
||||
use super::memorizable::Memorizable;
|
||||
|
@ -114,7 +115,7 @@ impl Light for PointLight {
|
|||
new_diff.z += diff_high.z;
|
||||
}
|
||||
|
||||
if (new_diff.x < new_diff.y || new_diff.y == 0.0) && (new_diff.x < new_diff.z || new_diff.z == 0.0) && new_diff.x != 0.0 {
|
||||
if ((new_diff.x < new_diff.y || new_diff.y == 0.0) && (new_diff.x < new_diff.z || new_diff.z == 0.0) && new_diff.x != 0.0) {
|
||||
offset_vec.x -= new_diff.x;
|
||||
} else {
|
||||
if (new_diff.y < new_diff.z || new_diff.z == 0.0) && new_diff.y != 0.0 {
|
||||
|
@ -222,7 +223,7 @@ mod test {
|
|||
let mem_size = p.get_buffer_mem_size(&data);
|
||||
assert!(mem_size == 7);
|
||||
|
||||
let memory = vec![0; 7];
|
||||
let mut memory = vec![0; 7];
|
||||
assert!(!p.dirty);
|
||||
p.insert_into_memory(memory, &data, &scene);
|
||||
assert!(p.dirty);
|
||||
|
@ -238,7 +239,7 @@ mod test {
|
|||
let mem_size = p.get_buffer_mem_size(&data);
|
||||
assert!(mem_size == 7);
|
||||
|
||||
let memory = vec![0; 6];
|
||||
let mut memory = vec![0; 6];
|
||||
assert!(!p.dirty);
|
||||
p.insert_into_memory(memory, &data, &scene);
|
||||
assert!(p.dirty);
|
||||
|
@ -253,7 +254,7 @@ mod test {
|
|||
let mem_size = p.get_buffer_mem_size(&data);
|
||||
assert!(mem_size == 7);
|
||||
|
||||
let memory = vec![0; 7];
|
||||
let mut memory = vec![0; 7];
|
||||
assert!(!p.dirty);
|
||||
p.insert_into_memory(memory, &data, &scene);
|
||||
assert!(p.dirty);
|
||||
|
@ -269,7 +270,7 @@ mod test {
|
|||
let mem_size = p.get_buffer_mem_size(&data);
|
||||
assert!(mem_size == 7);
|
||||
|
||||
let memory = vec![0; 6];
|
||||
let mut memory = vec![0; 6];
|
||||
assert!(!p.dirty);
|
||||
p.insert_into_memory(memory, &data, &scene);
|
||||
assert!(p.dirty);
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use super::light::LightSource;
|
||||
use super::AppData;
|
||||
use super::Scene;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ use light::{DirectionalLight, LightSource, PointLight};
|
|||
use vulkanalia::prelude::v1_0::*;
|
||||
use anyhow::Result;
|
||||
|
||||
use cgmath::Vector3;
|
||||
use cgmath::{vec2, vec3, Vector3};
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
@ -18,13 +18,15 @@ use std::rc::Rc;
|
|||
use crate::scene::memorizable::{Memorizable, CompoundMemorizable};
|
||||
use crate::app_data::AppData;
|
||||
use crate::buffer;
|
||||
use crate::primitives::rec_cuboid::Cuboid;
|
||||
use crate::vertex;
|
||||
use crate::primitives::cube::Cube;
|
||||
use crate::primitives::drawable::Drawable;
|
||||
use crate::scene::oct_tree::{OctTree, CHUNK_SIZE};
|
||||
use crate::scene::oct_tree::{OctTree, OctTreeIter, CHUNK_SIZE};
|
||||
use crate::scene::empty_volume::EmptyVolume;
|
||||
|
||||
extern crate rand;
|
||||
use rand::Rng;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Debug, Default)]
|
||||
|
|
|
@ -2,6 +2,7 @@ use crate::app_data::AppData;
|
|||
|
||||
use super::{Scene, memorizable::CompoundMemorizable};
|
||||
use cgmath::{InnerSpace, Vector3};
|
||||
use winit::dpi::Size;
|
||||
|
||||
use super::memorizable::Memorizable;
|
||||
use std::cell::RefCell;
|
||||
|
@ -151,6 +152,7 @@ impl Memorizable for ShapeComposition {
|
|||
element_offset += 1;
|
||||
}
|
||||
|
||||
println!("Compound links to volumes:");
|
||||
for volume_start in &self.overlapping_volumes {
|
||||
v[self.memory_start + element_offset] = volume_start.clone();
|
||||
element_offset += 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue