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),
|
||||
}
|
||||
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
enum Pipeline {
|
||||
Forward,
|
||||
Deferred,
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Error> {
|
||||
miette::set_panic_hook();
|
||||
|
||||
|
|
@ -56,14 +50,13 @@ fn main() -> Result<(), Error> {
|
|||
let mut cpu_mesh = model_to_mesh(world_model);
|
||||
cpu_mesh.compute_normals();
|
||||
let forward_pipeline = ForwardPipeline::new(&context).unwrap();
|
||||
let mut deferred_pipeline = DeferredPipeline::new(&context).unwrap();
|
||||
let mut camera = Camera::new_perspective(
|
||||
&context,
|
||||
window.viewport().unwrap(),
|
||||
vec3(2.0, 2.0, 5.0),
|
||||
vec3(0.0, 0.0, 0.0),
|
||||
vec3(0.0, 1.0, 0.0),
|
||||
degrees(45.0),
|
||||
degrees(90.0),
|
||||
0.1,
|
||||
30.0,
|
||||
)
|
||||
|
|
@ -99,8 +92,9 @@ fn main() -> Result<(), Error> {
|
|||
// main loop
|
||||
let mut shadows_enabled = false;
|
||||
let mut directional_intensity = lights.directional[0].intensity();
|
||||
|
||||
let mut current_pipeline = Pipeline::Forward;
|
||||
let mut depth_max = 30.0;
|
||||
let mut fov = 60.0;
|
||||
let mut debug_type = DebugType::NONE;
|
||||
|
||||
window.render_loop(move |mut frame_input| {
|
||||
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.radio_value(&mut deferred_pipeline.debug_type, DebugType::NONE, "None");
|
||||
ui.radio_value(
|
||||
&mut deferred_pipeline.debug_type,
|
||||
DebugType::POSITION,
|
||||
"Position",
|
||||
);
|
||||
ui.radio_value(
|
||||
&mut deferred_pipeline.debug_type,
|
||||
DebugType::NORMAL,
|
||||
"Normal",
|
||||
);
|
||||
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");
|
||||
ui.radio_value(&mut debug_type, DebugType::NONE, "None");
|
||||
ui.radio_value(&mut debug_type, DebugType::POSITION, "Position");
|
||||
ui.radio_value(&mut debug_type, DebugType::NORMAL, "Normal");
|
||||
ui.radio_value(&mut debug_type, DebugType::COLOR, "Color");
|
||||
ui.radio_value(&mut debug_type, DebugType::DEPTH, "Depth");
|
||||
ui.radio_value(&mut debug_type, DebugType::ORM, "ORM");
|
||||
|
||||
ui.label("View options");
|
||||
ui.add(Slider::new(&mut depth_max, 1.0..=30.0).text("Depth max"));
|
||||
ui.add(Slider::new(&mut fov, 45.0..=90.0).text("FOV"));
|
||||
});
|
||||
panel_width = gui_context.used_size().x as u32;
|
||||
})
|
||||
|
|
@ -194,6 +152,9 @@ fn main() -> Result<(), Error> {
|
|||
|
||||
// Draw
|
||||
{
|
||||
camera
|
||||
.set_perspective_projection(degrees(fov), 0.1, 30.0)
|
||||
.unwrap();
|
||||
if shadows_enabled {
|
||||
lights.directional[0]
|
||||
.generate_shadow_map(4.0, 1024, 1024, &[&model])
|
||||
|
|
@ -203,24 +164,9 @@ fn main() -> Result<(), Error> {
|
|||
.unwrap();
|
||||
}
|
||||
|
||||
// Geometry pass
|
||||
if change && current_pipeline == Pipeline::Deferred {
|
||||
deferred_pipeline
|
||||
.render_pass(
|
||||
&camera,
|
||||
&[(
|
||||
&model,
|
||||
DeferredPhysicalMaterial::from_physical_material(&model.material),
|
||||
)],
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
// Light pass
|
||||
Screen::write(&context, ClearState::default(), || {
|
||||
match current_pipeline {
|
||||
Pipeline::Forward => {
|
||||
match deferred_pipeline.debug_type {
|
||||
match debug_type {
|
||||
DebugType::NORMAL => {
|
||||
model.render_with_material(
|
||||
&NormalMaterial::from_physical_material(&model.material),
|
||||
|
|
@ -229,7 +175,8 @@ fn main() -> Result<(), Error> {
|
|||
)?;
|
||||
}
|
||||
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)?;
|
||||
}
|
||||
DebugType::ORM => {
|
||||
|
|
@ -254,21 +201,16 @@ fn main() -> Result<(), Error> {
|
|||
&lights,
|
||||
)?;
|
||||
}
|
||||
DebugType::NONE => {
|
||||
forward_pipeline.render_pass(&camera, &[&model], &lights)?
|
||||
}
|
||||
DebugType::NONE => forward_pipeline.render_pass(&camera, &[&model], &lights)?,
|
||||
};
|
||||
}
|
||||
Pipeline::Deferred => {
|
||||
deferred_pipeline.lighting_pass(&camera, &lights)?;
|
||||
}
|
||||
}
|
||||
gui.render()?;
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
let _ = change;
|
||||
|
||||
FrameOutput::default()
|
||||
})?;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue