remove some settings

This commit is contained in:
Robin Appelman 2022-02-20 21:57:14 +01:00
commit 4eaba16417

View file

@ -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,72 +164,53 @@ 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 {
DebugType::NORMAL => {
model.render_with_material(
&NormalMaterial::from_physical_material(&model.material),
&camera,
&lights,
)?;
}
DebugType::DEPTH => {
let depth_material = DepthMaterial::default();
model.render_with_material(&depth_material, &camera, &lights)?;
}
DebugType::ORM => {
model.render_with_material(
&ORMMaterial::from_physical_material(&model.material),
&camera,
&lights,
)?;
}
DebugType::POSITION => {
let position_material = PositionMaterial::default();
model.render_with_material(&position_material, &camera, &lights)?;
}
DebugType::UV => {
let uv_material = UVMaterial::default();
model.render_with_material(&uv_material, &camera, &lights)?;
}
DebugType::COLOR => {
model.render_with_material(
&ColorMaterial::from_physical_material(&model.material),
&camera,
&lights,
)?;
}
DebugType::NONE => {
forward_pipeline.render_pass(&camera, &[&model], &lights)?
}
};
match debug_type {
DebugType::NORMAL => {
model.render_with_material(
&NormalMaterial::from_physical_material(&model.material),
&camera,
&lights,
)?;
}
Pipeline::Deferred => {
deferred_pipeline.lighting_pass(&camera, &lights)?;
DebugType::DEPTH => {
let mut depth_material = DepthMaterial::default();
depth_material.max_distance = Some(depth_max);
model.render_with_material(&depth_material, &camera, &lights)?;
}
}
DebugType::ORM => {
model.render_with_material(
&ORMMaterial::from_physical_material(&model.material),
&camera,
&lights,
)?;
}
DebugType::POSITION => {
let position_material = PositionMaterial::default();
model.render_with_material(&position_material, &camera, &lights)?;
}
DebugType::UV => {
let uv_material = UVMaterial::default();
model.render_with_material(&uv_material, &camera, &lights)?;
}
DebugType::COLOR => {
model.render_with_material(
&ColorMaterial::from_physical_material(&model.material),
&camera,
&lights,
)?;
}
DebugType::NONE => forward_pipeline.render_pass(&camera, &[&model], &lights)?,
};
gui.render()?;
Ok(())
})
.unwrap();
}
let _ = change;
FrameOutput::default()
})?;