Skip to content

Commit

Permalink
added hdr flag
Browse files Browse the repository at this point in the history
  • Loading branch information
KeKsBoTer committed Mar 14, 2024
1 parent d887ac3 commit 21a53b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/bin/viewer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ struct Opt {
#[arg(long, default_value_t = false)]
no_vsync: bool,

/// Support HDR rendering
#[arg(long, default_value_t = false)]
hdr: bool,

/// Sky box image
#[arg(long)]
skybox: Option<PathBuf>,
Expand Down Expand Up @@ -53,6 +57,7 @@ async fn main() {
RenderConfig {
no_vsync: opt.no_vsync,
skybox: opt.skybox,
hdr: opt.hdr,
},
Some(opt.input),
opt.scene,
Expand Down
5 changes: 3 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ mod utils;
pub struct RenderConfig {
pub no_vsync: bool,
pub skybox: Option<PathBuf>,
pub hdr: bool,
}

pub struct WGPUContext {
Expand Down Expand Up @@ -193,7 +194,7 @@ impl WindowContext {
.unwrap_or(&surface_caps.formats[0])
.clone();

let render_format = wgpu::TextureFormat::Rgba16Float;
let render_format = if render_config.hdr{ wgpu::TextureFormat::Rgba16Float}else{wgpu::TextureFormat::Rgba8Unorm};

let config = wgpu::SurfaceConfiguration {
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
Expand Down Expand Up @@ -774,7 +775,7 @@ pub async fn run_wasm(pc: Vec<u8>, scene: Option<Vec<u8>>,pc_file:Option<String>
wasm_bindgen_futures::spawn_local(open_window(
pc_reader,
scene_reader,
RenderConfig { no_vsync: false,skybox:None },
RenderConfig { no_vsync: false,skybox:None,hdr:false },
pc_file.and_then(|s|PathBuf::from_str(s.as_str()).ok()),
scene_file.and_then(|s|PathBuf::from_str(s.as_str()).ok()),
));
Expand Down

0 comments on commit 21a53b7

Please sign in to comment.