combine quads

This commit is contained in:
zomseffen 2025-02-27 13:34:08 +01:00
parent 457d3e2d6b
commit 5bd181adc9
8 changed files with 181 additions and 116 deletions

Binary file not shown.

Binary file not shown.

View file

@ -1,6 +1,6 @@
#version 450
layout(location = 0) flat in uvec2 fragRasterPos;
layout(location = 0) in vec2 fragRasterPos;
layout(location = 1) flat in uint fragVolumeStart;
layout(location = 2) in vec3 origPosition;
layout(location = 3) flat in uint facing;
@ -109,6 +109,10 @@ uint sample_neighbor_from_scene_info(uint volume_start, uvec2 raster_pos, uint f
return value;
}
uint sample_neighbor_from_scene_info(uint volume_start, vec2 raster_pos, uint f) {
return sample_neighbor_from_scene_info(volume_start, uvec2(uint(floor(raster_pos.x)), uint(floor(raster_pos.y))), f);
}
uvec4 sample_color_from_scene_info(uint volume_start, uvec2 raster_pos, uint f) {
uint array_descr_start = volume_start + 6 + max_num_lights;
uint color_array_start = array_descr_start + 24;
@ -148,6 +152,10 @@ uvec4 sample_color_from_scene_info(uint volume_start, uvec2 raster_pos, uint f)
return unpack_color(value);
}
uvec4 sample_color_from_scene_info(uint volume_start, vec2 raster_pos, uint f) {
return sample_color_from_scene_info(volume_start, uvec2(uint(floor(raster_pos.x)), uint(floor(raster_pos.y))), f);
}
vec3 get_light_position(uint light_index) {
return vec3(uintBitsToFloat(scene_info.infos[light_index + 1]), uintBitsToFloat(scene_info.infos[light_index + 2]), uintBitsToFloat(scene_info.infos[light_index + 3]));
}
@ -333,7 +341,7 @@ Tracing trace_ray(uint volume_start, vec3 starting_pos, vec3 start_direction, fl
vec3 visibility_after_reflection = refltective_color_mul * reflectivity;
//break;
//max(visibility_after_reflection.x, max(visibility_after_reflection.y, visibility_after_reflection.z)) >= 0.1 &&
if (allow_reflect) {
if (max(visibility_after_reflection.x, max(visibility_after_reflection.y, visibility_after_reflection.z)) >= 0.1 && allow_reflect) {
// do reflect
direction = reflect_vector(direction, hit_facing);
pos = intersection_pos;
@ -440,6 +448,10 @@ vec3 diffuse_tracing(uint volume_start, uvec2 raster_pos, vec3 pos, uint f) {
return color_sum;
}
vec3 diffuse_tracing(uint volume_start, vec2 raster_pos, vec3 pos, uint f) {
return diffuse_tracing(volume_start, uvec2(uint(floor(raster_pos.x)), uint(floor(raster_pos.y))), pos, f);
}
vec3 clamp_to_volume(uint volume_start, vec3 position) {
uint volume_pos_x = scene_info.infos[volume_start + 0];
uint volume_pos_y = scene_info.infos[volume_start + 1];
@ -501,4 +513,5 @@ void main() {
}
outColor = vec4(color_sum, 1.0);
//outColor = vec4(orig_color_sample, 1.0);
}

View file

@ -15,7 +15,7 @@ layout(location = 1) in uvec2 inRasterPos;
layout(location = 2) in uint inVolumeStart;
layout(location = 3) in uint inFacing;
layout(location = 0) flat out uvec2 rasterPos;
layout(location = 0) out vec2 rasterPos;
layout(location = 1) flat out uint volumeStart;
layout(location = 2) out vec3 origPosition;
layout(location = 3) flat out uint facing;

View file

@ -224,7 +224,7 @@ impl App {
image::create_texture_sampler(&device, &mut data)?;
//let cur_pos = generators::generate_test_scene(&mut scene_handler, &mut data)?;
let cur_pos = generators::generate_test_scene2(&mut scene_handler, &mut data, 3, 3,1, 2)?;
let cur_pos = generators::generate_test_scene2(&mut scene_handler, &mut data, 21, 21,1, 5)?;
scene_handler.prepare_data(&instance, &device, &mut data)?;
buffer::create_uniform_buffers(&instance, &device, &mut data)?;

View file

@ -1,5 +1,5 @@
use vulkanalia::prelude::v1_0::*;
use cgmath::vec3;
use cgmath::{vec3, ElementWise, Vector2};
use crate::vertex::{self, Facing};
use crate::scene::Scene;
use crate::primitives::drawable::Drawable;
@ -11,6 +11,7 @@ pub struct Quad{
pub pos3: vertex::Vec3,
pub pos4: vertex::Vec3,
pub raster_pos: cgmath::Vector2<u32>,
pub size: cgmath::Vector2<u32>,
pub volume_index: u32,
pub facing: Facing,
}
@ -21,40 +22,50 @@ impl Drawable for Quad {
// 0 top left far
scene.rt_vertices.push(vertex::RTVertex::new(
vec3(self.pos1.x as f32, self.pos1.y as f32, self.pos1.z as f32),
self.raster_pos,
self.raster_pos + self.size.mul_element_wise(cgmath::Vector2 {x: 0, y: 0}),
self.volume_index,
self.facing
));
// 1 top right far
scene.rt_vertices.push(vertex::RTVertex::new(
vec3(self.pos2.x as f32, self.pos2.y as f32, self.pos2.z as f32),
self.raster_pos,
self.raster_pos + self.size.mul_element_wise(cgmath::Vector2 {x: 0, y: 1}),
self.volume_index,
self.facing
));
// 2 top left near
scene.rt_vertices.push(vertex::RTVertex::new(
vec3(self.pos3.x as f32, self.pos3.y as f32, self.pos3.z as f32),
self.raster_pos,
self.raster_pos + self.size.mul_element_wise(cgmath::Vector2 {x: 1, y: 1}),
self.volume_index,
self.facing
));
// 3 top right near
scene.rt_vertices.push(vertex::RTVertex::new(
vec3(self.pos4.x as f32, self.pos4.y as f32, self.pos4.z as f32),
self.raster_pos,
self.raster_pos + self.size.mul_element_wise(cgmath::Vector2 {x: 1, y: 0}),
self.volume_index,
self.facing
));
// top
scene.indices_rt.push(start_index as u32 + 2);
scene.indices_rt.push(start_index as u32 + 1);
scene.indices_rt.push(start_index as u32 + 0);
// change node order while preserving texture coordinates
if [Facing::Top].contains(&self.facing) {
scene.indices_rt.push(start_index as u32 + 0);
scene.indices_rt.push(start_index as u32 + 1);
scene.indices_rt.push(start_index as u32 + 2);
scene.indices_rt.push(start_index as u32 + 0);
scene.indices_rt.push(start_index as u32 + 3);
scene.indices_rt.push(start_index as u32 + 2);
scene.indices_rt.push(start_index as u32 + 2);
scene.indices_rt.push(start_index as u32 + 3);
scene.indices_rt.push(start_index as u32 + 0);
} else {
scene.indices_rt.push(start_index as u32 + 2);
scene.indices_rt.push(start_index as u32 + 1);
scene.indices_rt.push(start_index as u32 + 0);
scene.indices_rt.push(start_index as u32 + 0);
scene.indices_rt.push(start_index as u32 + 3);
scene.indices_rt.push(start_index as u32 + 2);
}
}
}
}

View file

@ -718,37 +718,79 @@ impl EmptyVolume {
println!("volume creation took {} s", start_time.elapsed().as_millis() as f32 / 1000.0);
(volumes, neighbors)
}
fn check_quad_index(u: usize, v: usize, vsize: usize, size1: usize, size2: usize, colors: &Vec<Vector3<u8>>, neighbors: &Vec<Option<Rc<RefCell<EmptyVolume>>>>) -> bool {
let index = (u + size1) * vsize + (v + size2);
if colors.len() <= index {
return false;
}
if neighbors.len() > index || neighbors.len() == 1 {
if let Some(_) = neighbors[index.min(neighbors.len() - 1)] {
if colors[index] == (Vector3 {x: 0, y: 0, z: 0}) {
return false;
}
}
}
return true
}
fn grow_quad(u: usize, v: usize, size_u: usize, size_v: usize, colors: &Vec<Vector3<u8>>, neighbors: &Vec<Option<Rc<RefCell<EmptyVolume>>>>) -> (usize, usize) {
let mut size_1 = 0;
let mut size_2 = 0;
let mut grow = true;
let mut v_size_check = 0;
while grow {
for u_size_check in 0..size_u - u {
if EmptyVolume::check_quad_index(u, v, size_v, u_size_check, v_size_check, colors, neighbors) {
size_1 = size_1.max(u_size_check);
} else {
grow = false;
break;
}
}
if grow {
size_2 = v_size_check;
}
v_size_check += 1;
}
(size_1, size_2)
}
// MARK: To Quads
pub fn to_quads(&self) -> Vec<Quad> {
let mut quads = vec![];
let float_pos = Vector3 {x: (self.tree_offset.x * self.tree_size + self.position.x) as f32, y: (self.tree_offset.y * self.tree_size + self.position.y) as f32, z: (self.tree_offset.z * self.tree_size + self.position.z) as f32};
//bottom sides of the volumes, top side of the block
let mut done = vec![];
for x in 0..self.size_x {
for y in 0..self.size_y {
let index = x * self.size_y + y;
if self.color_bottom.len() <= index {
if done.contains(&(x, y)) {
continue;
}
if self.neighbor_bottom.len() > index || self.neighbor_bottom.len() == 1 {
if let Some(_) = self.neighbor_bottom[index.min(self.neighbor_bottom.len() - 1)] {
if self.color_bottom[index] == (Vector3 {x: 0, y: 0, z: 0}) {
continue;
}
}
}
if self.color_bottom[index] == (Vector3 {x: 0, y: 0, z: 0}) {
println!("No neighbor reference, but no color! x: {}, y: {}, z: {}", self.position.x + x, self.position.y + y, self.position.z);
if self.neighbor_bottom.len() == 1 {
println!("neighbor length is one!");
if !EmptyVolume::check_quad_index(x, y, self.size_y, 0, 0, &self.color_bottom, &self.neighbor_bottom) {
continue;
}
let (size_1, size_2) = EmptyVolume::grow_quad(x, y, self.size_x, self.size_y, &self.color_bottom, &self.neighbor_bottom);
done.push((x, y));
for done_x in 0..size_1 + 1 {
for done_y in 0..size_2 + 1 {
done.push((x + done_x, y + done_y));
}
}
let quad = Quad {
pos1: float_pos + Vector3 { x: -0.5 + x as f32, y: -0.5 + y as f32, z: -0.5 },
pos4: float_pos + Vector3 { x: 0.5 + x as f32, y: -0.5 + y as f32, z: -0.5 },
pos3: float_pos + Vector3 { x: 0.5 + x as f32, y: 0.5 + y as f32, z: -0.5 },
pos2: float_pos + Vector3 { x: -0.5 + x as f32, y: 0.5 + y as f32, z: -0.5 },
pos4: float_pos + Vector3 { x: 0.5 + (x + size_1) as f32, y: -0.5 + y as f32, z: -0.5 },
pos3: float_pos + Vector3 { x: 0.5 + (x + size_1) as f32, y: 0.5 + (y + size_2) as f32, z: -0.5 },
pos2: float_pos + Vector3 { x: -0.5 + x as f32, y: 0.5 + (y + size_2) as f32, z: -0.5 },
raster_pos: cgmath::Vector2 { x: x as u32, y: y as u32 },
size: cgmath::Vector2 { x: (size_1 + 1) as u32, y: (size_2 + 1) as u32 },
volume_index: self.memory_start as u32,
facing: vertex::Facing::Bottom
};
@ -756,33 +798,32 @@ impl EmptyVolume {
}
}
//top sides of the volumes, bottom side of the block
let mut done = vec![];
for x in 0..self.size_x {
for y in 0..self.size_y {
let index = x * self.size_y + y;
if self.color_top.len() <= 0 {
if done.contains(&(x, y)) {
continue;
}
if self.neighbor_top.len() > index || self.neighbor_top.len() == 1 {
if let Some(_) = self.neighbor_top[index.min(self.neighbor_top.len() - 1)] {
if self.color_top[index] == (Vector3 {x: 0, y: 0, z: 0}) {
continue;
}
}
if !EmptyVolume::check_quad_index(x, y, self.size_y, 0, 0, &self.color_top, &self.neighbor_top) {
continue;
}
let (size_1, size_2) = EmptyVolume::grow_quad(x, y, self.size_x, self.size_y, &self.color_top, &self.neighbor_top);
if self.color_top[index] == (Vector3 {x: 0, y: 0, z: 0}) {
println!("No neighbor reference, but no color! x: {}, y: {}, z: {}", self.position.x + x, self.position.y + y, self.position.z + self.size_z);
if self.neighbor_top.len() == 1 {
println!("neighbor length is one!");
done.push((x, y));
for done_x in 0..size_1 + 1 {
for done_y in 0..size_2 + 1 {
done.push((x + done_x, y + done_y));
}
}
let quad = Quad {
pos4: float_pos + Vector3 { x: -0.5 + x as f32, y: -0.5 + y as f32, z: self.size_z as f32 - 0.5 },
pos1: float_pos + Vector3 { x: 0.5 + x as f32, y: -0.5 + y as f32, z: self.size_z as f32 - 0.5 },
pos2: float_pos + Vector3 { x: 0.5 + x as f32, y: 0.5 + y as f32, z: self.size_z as f32 - 0.5 },
pos3: float_pos + Vector3 { x: -0.5 + x as f32, y: 0.5 + y as f32, z: self.size_z as f32 - 0.5 },
pos1: float_pos + Vector3 { x: -0.5 + x as f32, y: -0.5 + y as f32, z: self.size_z as f32 - 0.5 },
pos4: float_pos + Vector3 { x: 0.5 + (x + size_1) as f32, y: -0.5 + y as f32, z: self.size_z as f32 - 0.5 },
pos3: float_pos + Vector3 { x: 0.5 + (x + size_1) as f32, y: 0.5 + (y + size_2) as f32, z: self.size_z as f32 - 0.5 },
pos2: float_pos + Vector3 { x: -0.5 + x as f32, y: 0.5 + (y + size_2) as f32, z: self.size_z as f32 - 0.5 },
raster_pos: cgmath::Vector2 { x: x as u32, y: y as u32 },
size: cgmath::Vector2 { x: (size_1 + 1) as u32, y: (size_2 + 1) as u32 },
volume_index: self.memory_start as u32,
facing: vertex::Facing::Top
};
@ -791,32 +832,32 @@ impl EmptyVolume {
}
//front sides of the volumes, back side of the block
let mut done = vec![];
for x in 0..self.size_x {
for z in 0..self.size_z {
let index = x * self.size_z + z;
if self.color_front.len() <= 0 {
if done.contains(&(x, z)) {
continue;
}
if self.neighbor_front.len() > index || self.neighbor_front.len() == 1 {
if let Some(_) = self.neighbor_front[index.min(self.neighbor_front.len() - 1)] {
if self.color_front[index] == (Vector3 {x: 0, y: 0, z: 0}) {
continue;
}
}
if !EmptyVolume::check_quad_index(x, z, self.size_z, 0, 0, &self.color_front, &self.neighbor_front) {
continue;
}
let (size_1, size_2) = EmptyVolume::grow_quad(x, z, self.size_x, self.size_z, &self.color_front, &self.neighbor_front);
if self.color_front[index] == (Vector3 {x: 0, y: 0, z: 0}) {
println!("No neighbor reference, but no color! x: {}, y: {}, z: {}", self.position.x + x, self.position.y, self.position.z + z);
if self.neighbor_front.len() == 1 {
println!("neighbor length is one!");
done.push((x, z));
for done_x in 0..size_1 + 1 {
for done_z in 0..size_2 + 1 {
done.push((x + done_x, z + done_z));
}
}
let quad = Quad {
pos1: float_pos + Vector3 { x: -0.5 + x as f32, y: -0.5 + 0 as f32, z: z as f32 - 0.5 },
pos4: float_pos + Vector3 { x: -0.5 + x as f32, y: -0.5 + 0 as f32, z: z as f32 + 0.5 },
pos3: float_pos + Vector3 { x: 0.5 + x as f32, y: -0.5 + 0 as f32, z: z as f32 + 0.5 },
pos2: float_pos + Vector3 { x: 0.5 + x as f32, y: -0.5 + 0 as f32, z: z as f32 - 0.5 },
pos2: float_pos + Vector3 { x: -0.5 + x as f32, y: -0.5 + 0 as f32, z: z as f32 - 0.5 },
pos1: float_pos + Vector3 { x: -0.5 + x as f32, y: -0.5 + 0 as f32, z: (z + size_2) as f32 + 0.5 },
pos4: float_pos + Vector3 { x: 0.5 + (x + size_1) as f32, y: -0.5 + 0 as f32, z: (z + size_2) as f32 + 0.5 },
pos3: float_pos + Vector3 { x: 0.5 + (x + size_1) as f32, y: -0.5 + 0 as f32, z: z as f32 - 0.5 },
raster_pos: cgmath::Vector2 { x: x as u32, y: z as u32 },
size: cgmath::Vector2 { x: (size_1 + 1) as u32, y: (size_2 + 1) as u32 },
volume_index: self.memory_start as u32,
facing: vertex::Facing::Front
};
@ -825,32 +866,32 @@ impl EmptyVolume {
}
//back sides of the volumes, front side of the block
let mut done = vec![];
for x in 0..self.size_x {
for z in 0..self.size_z {
let index = x * self.size_z + z;
if self.color_back.len() <= 0 {
if done.contains(&(x, z)) {
continue;
}
if self.neighbor_back.len() > index || self.neighbor_back.len() == 1 {
if let Some(_) = self.neighbor_back[index.min(self.neighbor_back.len() - 1)] {
if self.color_back[index] == (Vector3 {x: 0, y: 0, z: 0}) {
continue;
}
}
if !EmptyVolume::check_quad_index(x, z, self.size_z, 0, 0, &self.color_back, &self.neighbor_back) {
continue;
}
let (size_1, size_2) = EmptyVolume::grow_quad(x, z, self.size_x, self.size_z, &self.color_back, &self.neighbor_back);
if self.color_back[index] == (Vector3 {x: 0, y: 0, z: 0}) {
println!("No neighbor reference, but no color! x: {}, y: {}, z: {}", self.position.x + x, self.position.y + self.size_y, self.position.z + z);
if self.neighbor_back.len() == 1 {
println!("neighbor length is one!");
done.push((x, z));
for done_x in 0..size_1 + 1 {
for done_z in 0..size_2 + 1 {
done.push((x + done_x, z + done_z));
}
}
let quad = Quad {
pos4: float_pos + Vector3 { x: -0.5 + x as f32, y: -0.5 + self.size_y as f32, z: z as f32 - 0.5 },
pos1: float_pos + Vector3 { x: -0.5 + x as f32, y: -0.5 + self.size_y as f32, z: z as f32 + 0.5 },
pos2: float_pos + Vector3 { x: 0.5 + x as f32, y: -0.5 + self.size_y as f32, z: z as f32 + 0.5 },
pos3: float_pos + Vector3 { x: 0.5 + x as f32, y: -0.5 + self.size_y as f32, z: z as f32 - 0.5 },
pos1: float_pos + Vector3 { x: -0.5 + x as f32, y: -0.5 + self.size_y as f32, z: z as f32 - 0.5 },
pos2: float_pos + Vector3 { x: -0.5 + x as f32, y: -0.5 + self.size_y as f32, z: (z + size_2) as f32 + 0.5 },
pos3: float_pos + Vector3 { x: 0.5 + (x + size_1) as f32, y: -0.5 + self.size_y as f32, z: (z + size_2) as f32 + 0.5 },
pos4: float_pos + Vector3 { x: 0.5 + (x + size_1) as f32, y: -0.5 + self.size_y as f32, z: z as f32 - 0.5 },
raster_pos: cgmath::Vector2 { x: x as u32, y: z as u32 },
size: cgmath::Vector2 { x: (size_1 + 1) as u32, y: (size_2 + 1) as u32 },
volume_index: self.memory_start as u32,
facing: vertex::Facing::Back
};
@ -859,32 +900,32 @@ impl EmptyVolume {
}
//left sides of the volumes, right side of the block
let mut done = vec![];
for y in 0..self.size_y {
for z in 0..self.size_z {
let index = y * self.size_z + z;
if self.color_left.len() <= 0 {
if done.contains(&(y, z)) {
continue;
}
if self.neighbor_left.len() > index || self.neighbor_left.len() == 1 {
if let Some(_) = self.neighbor_left[index.min(self.neighbor_left.len() - 1)] {
if self.color_left[index] == (Vector3 {x: 0, y: 0, z: 0}) {
continue;
}
}
if !EmptyVolume::check_quad_index(y, z, self.size_z, 0, 0, &self.color_left, &self.neighbor_left) {
continue;
}
let (size_1, size_2) = EmptyVolume::grow_quad(y, z, self.size_y, self.size_z, &self.color_left, &self.neighbor_left);
if self.color_left[index] == (Vector3 {x: 0, y: 0, z: 0}) {
println!("No neighbor reference, but no color! x: {}, y: {}, z: {}", self.position.x, self.position.y + y, self.position.z + z);
if self.neighbor_left.len() == 1 {
println!("neighbor length is one!");
done.push((y, z));
for done_y in 0..size_1 + 1 {
for done_z in 0..size_2 + 1 {
done.push((y + done_y, z + done_z));
}
}
let quad = Quad {
pos4: float_pos + Vector3 { x: -0.5 + 0.0 as f32, y: y as f32 - 0.5, z: z as f32 - 0.5 },
pos1: float_pos + Vector3 { x: -0.5 + 0.0 as f32, y: y as f32 - 0.5, z: z as f32 + 0.5 },
pos2: float_pos + Vector3 { x: -0.5 + 0.0 as f32, y: y as f32 + 0.5, z: z as f32 + 0.5 },
pos3: float_pos + Vector3 { x: -0.5 + 0.0 as f32, y: y as f32 + 0.5, z: z as f32 - 0.5 },
pos1: float_pos + Vector3 { x: -0.5 + 0.0 as f32, y: y as f32 - 0.5, z: z as f32 - 0.5 },
pos2: float_pos + Vector3 { x: -0.5 + 0.0 as f32, y: y as f32 - 0.5, z: (z + size_2) as f32 + 0.5 },
pos3: float_pos + Vector3 { x: -0.5 + 0.0 as f32, y: (y + size_1) as f32 + 0.5, z: (z + size_2) as f32 + 0.5 },
pos4: float_pos + Vector3 { x: -0.5 + 0.0 as f32, y: (y + size_1) as f32 + 0.5, z: z as f32 - 0.5 },
raster_pos: cgmath::Vector2 { x: y as u32, y: z as u32 },
size: cgmath::Vector2 { x: (size_1 + 1) as u32, y: (size_2 + 1) as u32 },
volume_index: self.memory_start as u32,
facing: vertex::Facing::Left
};
@ -893,32 +934,32 @@ impl EmptyVolume {
}
//right sides of the volumes, left side of the block
let mut done = vec![];
for y in 0..self.size_y {
for z in 0..self.size_z {
let index = y * self.size_z + z;
if self.color_right.len() <= 0 {
if done.contains(&(y, z)) {
continue;
}
if self.neighbor_right.len() > index || self.neighbor_right.len() == 1 {
if let Some(_) = self.neighbor_right[index.min(self.neighbor_right.len() - 1)] {
if self.color_right[index] == (Vector3 {x: 0, y: 0, z: 0}) {
continue;
}
}
if !EmptyVolume::check_quad_index(y, z, self.size_z, 0, 0, &self.color_right, &self.neighbor_right) {
continue;
}
let (size_1, size_2) = EmptyVolume::grow_quad(y, z, self.size_y, self.size_z, &self.color_right, &self.neighbor_right);
if self.color_right[index] == (Vector3 {x: 0, y: 0, z: 0}) {
println!("No neighbor reference, but no color! x: {}, y: {}, z: {}", self.position.x + self.size_x, self.position.y + y, self.position.z + z);
if self.neighbor_right.len() == 1 {
println!("neighbor length is one!");
done.push((y, z));
for done_y in 0..size_1 + 1 {
for done_z in 0..size_2 + 1 {
done.push((y + done_y, z + done_z));
}
}
let quad = Quad {
pos1: float_pos + Vector3 { x: -0.5 + self.size_x as f32, y: y as f32 - 0.5, z: z as f32 - 0.5 },
pos4: float_pos + Vector3 { x: -0.5 + self.size_x as f32, y: y as f32 - 0.5, z: z as f32 + 0.5 },
pos3: float_pos + Vector3 { x: -0.5 + self.size_x as f32, y: y as f32 + 0.5, z: z as f32 + 0.5 },
pos2: float_pos + Vector3 { x: -0.5 + self.size_x as f32, y: y as f32 + 0.5, z: z as f32 - 0.5 },
pos2: float_pos + Vector3 { x: -0.5 + self.size_x as f32, y: y as f32 - 0.5, z: z as f32 - 0.5 },
pos1: float_pos + Vector3 { x: -0.5 + self.size_x as f32, y: y as f32 - 0.5, z: (z + size_2) as f32 + 0.5 },
pos4: float_pos + Vector3 { x: -0.5 + self.size_x as f32, y: (y + size_1) as f32 + 0.5, z: (z + size_2) as f32 + 0.5 },
pos3: float_pos + Vector3 { x: -0.5 + self.size_x as f32, y: (y + size_1) as f32 + 0.5, z: z as f32 - 0.5 },
raster_pos: cgmath::Vector2 { x: y as u32, y: z as u32 },
size: cgmath::Vector2 { x: (size_1 + 1) as u32, y: (size_2 + 1) as u32 },
volume_index: self.memory_start as u32,
facing: vertex::Facing::Right
};

View file

@ -113,7 +113,7 @@ pub fn generate_test_scene(scene: &mut Scene, data: &mut AppData) -> Result<(Poi
let tree_ref_one = Rc::new(RefCell::new(oct_tree1.clone()));
let tree_ref_two = Rc::new(RefCell::new(oct_tree2.clone()));
scene.oct_trees = vec![vec![vec![tree_ref_one.clone(), tree_ref_two.clone()], vec![tree_ref_two.clone(), tree_ref_two.clone()]], vec![vec![tree_ref_one.clone(), tree_ref_two.clone()], vec![tree_ref_two.clone(), tree_ref_two.clone()]]];
scene.oct_trees = vec![vec![vec![tree_ref_two.clone(), tree_ref_two.clone(), tree_ref_two.clone()], vec![tree_ref_two.clone(), tree_ref_one.clone(), tree_ref_two.clone()], vec![tree_ref_two.clone(), tree_ref_two.clone(), tree_ref_two.clone()]], vec![vec![tree_ref_two.clone(), tree_ref_two.clone(), tree_ref_two.clone()], vec![tree_ref_two.clone(), tree_ref_one.clone(), tree_ref_two.clone()], vec![tree_ref_two.clone(), tree_ref_two.clone(), tree_ref_two.clone()]]];
Ok((cgmath::point3(5.0, 5.0, 10.0)))
}
@ -131,7 +131,7 @@ pub fn generate_test_scene2(scene: &mut Scene, data: &mut AppData, chunk_num_x:
let mut height_map = vec![vec![0.0; max_y]; max_x];
for i in 0..num_gaussians {
let height = rng.gen_range(16..max_z / 2) as f32;
let height = rng.gen_range(1..max_z / 2) as f32;
let center_x = rng.gen_range(0..max_x) as f32;
let center_y = rng.gen_range(0..max_y) as f32;
@ -189,7 +189,7 @@ pub fn generate_test_scene2(scene: &mut Scene, data: &mut AppData, chunk_num_x:
roughness: 255,
};
//oct_trees[((pillar_height as f32) / (grid_size as f32)).floor() as usize][((y as f32) / (grid_size as f32)).floor() as usize][((x as f32) / (grid_size as f32)).floor() as usize].borrow_mut().set_cube(cube.clone());
oct_trees[((pillar_height as f32) / (grid_size as f32)).floor() as usize][((y as f32) / (grid_size as f32)).floor() as usize][((x as f32) / (grid_size as f32)).floor() as usize].borrow_mut().set_cube(cube.clone());
}
}