mirror of
https://codeberg.org/icewind/vbspview.git
synced 2026-06-03 10:14:10 +02:00
remove some settings
This commit is contained in:
parent
421836fccf
commit
4eaba16417
1 changed files with 54 additions and 112 deletions
104
src/main.rs
104
src/main.rs
|
|
@ -22,12 +22,6 @@ enum Error {
|
||||||
Other(&'static str),
|
Other(&'static str),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
|
||||||
enum Pipeline {
|
|
||||||
Forward,
|
|
||||||
Deferred,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() -> Result<(), Error> {
|
fn main() -> Result<(), Error> {
|
||||||
miette::set_panic_hook();
|
miette::set_panic_hook();
|
||||||
|
|
||||||
|
|
@ -56,14 +50,13 @@ fn main() -> Result<(), Error> {
|
||||||
let mut cpu_mesh = model_to_mesh(world_model);
|
let mut cpu_mesh = model_to_mesh(world_model);
|
||||||
cpu_mesh.compute_normals();
|
cpu_mesh.compute_normals();
|
||||||
let forward_pipeline = ForwardPipeline::new(&context).unwrap();
|
let forward_pipeline = ForwardPipeline::new(&context).unwrap();
|
||||||
let mut deferred_pipeline = DeferredPipeline::new(&context).unwrap();
|
|
||||||
let mut camera = Camera::new_perspective(
|
let mut camera = Camera::new_perspective(
|
||||||
&context,
|
&context,
|
||||||
window.viewport().unwrap(),
|
window.viewport().unwrap(),
|
||||||
vec3(2.0, 2.0, 5.0),
|
vec3(2.0, 2.0, 5.0),
|
||||||
vec3(0.0, 0.0, 0.0),
|
vec3(0.0, 0.0, 0.0),
|
||||||
vec3(0.0, 1.0, 0.0),
|
vec3(0.0, 1.0, 0.0),
|
||||||
degrees(45.0),
|
degrees(90.0),
|
||||||
0.1,
|
0.1,
|
||||||
30.0,
|
30.0,
|
||||||
)
|
)
|
||||||
|
|
@ -99,8 +92,9 @@ fn main() -> Result<(), Error> {
|
||||||
// main loop
|
// main loop
|
||||||
let mut shadows_enabled = false;
|
let mut shadows_enabled = false;
|
||||||
let mut directional_intensity = lights.directional[0].intensity();
|
let mut directional_intensity = lights.directional[0].intensity();
|
||||||
|
let mut depth_max = 30.0;
|
||||||
let mut current_pipeline = Pipeline::Forward;
|
let mut fov = 60.0;
|
||||||
|
let mut debug_type = DebugType::NONE;
|
||||||
|
|
||||||
window.render_loop(move |mut frame_input| {
|
window.render_loop(move |mut frame_input| {
|
||||||
let mut change = frame_input.first_frame;
|
let mut change = frame_input.first_frame;
|
||||||
|
|
@ -129,53 +123,17 @@ fn main() -> Result<(), Error> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.label("Lighting model");
|
|
||||||
ui.radio_value(&mut lights.lighting_model, LightingModel::Phong, "Phong");
|
|
||||||
ui.radio_value(&mut lights.lighting_model, LightingModel::Blinn, "Blinn");
|
|
||||||
ui.radio_value(
|
|
||||||
&mut lights.lighting_model,
|
|
||||||
LightingModel::Cook(
|
|
||||||
NormalDistributionFunction::Blinn,
|
|
||||||
GeometryFunction::SmithSchlickGGX,
|
|
||||||
),
|
|
||||||
"Cook (Blinn)",
|
|
||||||
);
|
|
||||||
ui.radio_value(
|
|
||||||
&mut lights.lighting_model,
|
|
||||||
LightingModel::Cook(
|
|
||||||
NormalDistributionFunction::Beckmann,
|
|
||||||
GeometryFunction::SmithSchlickGGX,
|
|
||||||
),
|
|
||||||
"Cook (Beckmann)",
|
|
||||||
);
|
|
||||||
ui.radio_value(
|
|
||||||
&mut lights.lighting_model,
|
|
||||||
LightingModel::Cook(
|
|
||||||
NormalDistributionFunction::TrowbridgeReitzGGX,
|
|
||||||
GeometryFunction::SmithSchlickGGX,
|
|
||||||
),
|
|
||||||
"Cook (Trowbridge-Reitz GGX)",
|
|
||||||
);
|
|
||||||
|
|
||||||
ui.label("Pipeline");
|
|
||||||
ui.radio_value(&mut current_pipeline, Pipeline::Forward, "Forward");
|
|
||||||
ui.radio_value(&mut current_pipeline, Pipeline::Deferred, "Deferred");
|
|
||||||
ui.label("Debug options");
|
ui.label("Debug options");
|
||||||
ui.radio_value(&mut deferred_pipeline.debug_type, DebugType::NONE, "None");
|
ui.radio_value(&mut debug_type, DebugType::NONE, "None");
|
||||||
ui.radio_value(
|
ui.radio_value(&mut debug_type, DebugType::POSITION, "Position");
|
||||||
&mut deferred_pipeline.debug_type,
|
ui.radio_value(&mut debug_type, DebugType::NORMAL, "Normal");
|
||||||
DebugType::POSITION,
|
ui.radio_value(&mut debug_type, DebugType::COLOR, "Color");
|
||||||
"Position",
|
ui.radio_value(&mut debug_type, DebugType::DEPTH, "Depth");
|
||||||
);
|
ui.radio_value(&mut debug_type, DebugType::ORM, "ORM");
|
||||||
ui.radio_value(
|
|
||||||
&mut deferred_pipeline.debug_type,
|
ui.label("View options");
|
||||||
DebugType::NORMAL,
|
ui.add(Slider::new(&mut depth_max, 1.0..=30.0).text("Depth max"));
|
||||||
"Normal",
|
ui.add(Slider::new(&mut fov, 45.0..=90.0).text("FOV"));
|
||||||
);
|
|
||||||
ui.radio_value(&mut deferred_pipeline.debug_type, DebugType::COLOR, "Color");
|
|
||||||
ui.radio_value(&mut deferred_pipeline.debug_type, DebugType::UV, "UV");
|
|
||||||
ui.radio_value(&mut deferred_pipeline.debug_type, DebugType::DEPTH, "Depth");
|
|
||||||
ui.radio_value(&mut deferred_pipeline.debug_type, DebugType::ORM, "ORM");
|
|
||||||
});
|
});
|
||||||
panel_width = gui_context.used_size().x as u32;
|
panel_width = gui_context.used_size().x as u32;
|
||||||
})
|
})
|
||||||
|
|
@ -194,6 +152,9 @@ fn main() -> Result<(), Error> {
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
{
|
{
|
||||||
|
camera
|
||||||
|
.set_perspective_projection(degrees(fov), 0.1, 30.0)
|
||||||
|
.unwrap();
|
||||||
if shadows_enabled {
|
if shadows_enabled {
|
||||||
lights.directional[0]
|
lights.directional[0]
|
||||||
.generate_shadow_map(4.0, 1024, 1024, &[&model])
|
.generate_shadow_map(4.0, 1024, 1024, &[&model])
|
||||||
|
|
@ -203,24 +164,9 @@ fn main() -> Result<(), Error> {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Geometry pass
|
|
||||||
if change && current_pipeline == Pipeline::Deferred {
|
|
||||||
deferred_pipeline
|
|
||||||
.render_pass(
|
|
||||||
&camera,
|
|
||||||
&[(
|
|
||||||
&model,
|
|
||||||
DeferredPhysicalMaterial::from_physical_material(&model.material),
|
|
||||||
)],
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Light pass
|
// Light pass
|
||||||
Screen::write(&context, ClearState::default(), || {
|
Screen::write(&context, ClearState::default(), || {
|
||||||
match current_pipeline {
|
match debug_type {
|
||||||
Pipeline::Forward => {
|
|
||||||
match deferred_pipeline.debug_type {
|
|
||||||
DebugType::NORMAL => {
|
DebugType::NORMAL => {
|
||||||
model.render_with_material(
|
model.render_with_material(
|
||||||
&NormalMaterial::from_physical_material(&model.material),
|
&NormalMaterial::from_physical_material(&model.material),
|
||||||
|
|
@ -229,7 +175,8 @@ fn main() -> Result<(), Error> {
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
DebugType::DEPTH => {
|
DebugType::DEPTH => {
|
||||||
let depth_material = DepthMaterial::default();
|
let mut depth_material = DepthMaterial::default();
|
||||||
|
depth_material.max_distance = Some(depth_max);
|
||||||
model.render_with_material(&depth_material, &camera, &lights)?;
|
model.render_with_material(&depth_material, &camera, &lights)?;
|
||||||
}
|
}
|
||||||
DebugType::ORM => {
|
DebugType::ORM => {
|
||||||
|
|
@ -254,21 +201,16 @@ fn main() -> Result<(), Error> {
|
||||||
&lights,
|
&lights,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
DebugType::NONE => {
|
DebugType::NONE => forward_pipeline.render_pass(&camera, &[&model], &lights)?,
|
||||||
forward_pipeline.render_pass(&camera, &[&model], &lights)?
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
|
||||||
Pipeline::Deferred => {
|
|
||||||
deferred_pipeline.lighting_pass(&camera, &lights)?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
gui.render()?;
|
gui.render()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let _ = change;
|
||||||
|
|
||||||
FrameOutput::default()
|
FrameOutput::default()
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue