Size the box to the SDF
This commit is contained in:
@@ -6,7 +6,7 @@ layout(location = 0) in vec3 position;
|
||||
layout(location = 0) out vec4 pos;
|
||||
|
||||
void main() {
|
||||
pos = vec4(position, 1.);
|
||||
pos = vec4((position * pc.dimensions) + pc.lowest_corner, 1.);
|
||||
vec4 worldview = camera_uniforms.view * pc.world * pos;
|
||||
gl_Position = camera_uniforms.proj * worldview;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
layout(push_constant)uniform PushConstantData{
|
||||
mat4 world;
|
||||
vec3 dimensions;
|
||||
vec3 lowest_corner;
|
||||
}pc;
|
||||
|
||||
layout(set=0,binding=0)uniform Lights{
|
||||
|
||||
+19
-1
@@ -92,6 +92,7 @@ mod ssa;
|
||||
mod instruction_set;
|
||||
|
||||
mod interpreter;
|
||||
use crate::interpreter::Interpreter;
|
||||
|
||||
fn main() -> Result<(), impl Error> {
|
||||
CombinedLogger::init(vec![
|
||||
@@ -957,7 +958,7 @@ impl App {
|
||||
},
|
||||
);
|
||||
rcx.recreate_pipelines = false;
|
||||
if (rcx.new_object_start.is_some()) {
|
||||
if rcx.new_object_start.is_some() {
|
||||
let end = Instant::now();
|
||||
info!(
|
||||
"Object recreation took {} milliseconds",
|
||||
@@ -1021,6 +1022,8 @@ impl App {
|
||||
|
||||
let pc = implicit_vs::PushConstantData {
|
||||
world: Mat4::IDENTITY.to_cols_array_2d(),
|
||||
dimensions: Vec3::ONE.to_array().into(),
|
||||
lowest_corner: Vec3::ZERO.into(),
|
||||
};
|
||||
|
||||
let uniform_data = implicit_vs::Camera {
|
||||
@@ -1157,6 +1160,21 @@ impl App {
|
||||
)
|
||||
* Mat4::from_scale(csg.scale * 2.0))
|
||||
.to_cols_array_2d();
|
||||
|
||||
let mut interpreter = Interpreter::new(csg);
|
||||
let highest_corner = Vec3::new(
|
||||
10000.0 - interpreter.scene(Vec3::new(10000.0, 0.0, 0.0)),
|
||||
10000.0 - interpreter.scene(Vec3::new(0.0, 10000.0, 0.0)),
|
||||
10000.0 - interpreter.scene(Vec3::new(0.0, 0.0, 10000.0)),
|
||||
);
|
||||
let lowest_corner = Vec3::new(
|
||||
-10000.0 + interpreter.scene(Vec3::new(-10000.0, 0.0, 0.0)),
|
||||
-10000.0 + interpreter.scene(Vec3::new(0.0, -10000.0, 0.0)),
|
||||
-10000.0 + interpreter.scene(Vec3::new(0.0, 0.0, -10000.0)),
|
||||
);
|
||||
|
||||
push_constants.dimensions = (highest_corner - lowest_corner).to_array().into();
|
||||
push_constants.lowest_corner = lowest_corner.into();
|
||||
builder
|
||||
.push_constants(rcx.implicit_pipeline.layout().clone(), 0, push_constants)
|
||||
.unwrap();
|
||||
|
||||
Reference in New Issue
Block a user