Disable fog on wasm
This commit is contained in:
parent
fed16287c5
commit
857e32d994
1 changed files with 52 additions and 36 deletions
|
@ -34,6 +34,7 @@ pub struct State {
|
||||||
queue: wgpu::Queue,
|
queue: wgpu::Queue,
|
||||||
config: wgpu::SurfaceConfiguration,
|
config: wgpu::SurfaceConfiguration,
|
||||||
geometry_pass: RenderPass,
|
geometry_pass: RenderPass,
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
fog_pass: RenderPass,
|
fog_pass: RenderPass,
|
||||||
camera: Camera,
|
camera: Camera,
|
||||||
camera_uniform: CameraUniform,
|
camera_uniform: CameraUniform,
|
||||||
|
@ -42,10 +43,13 @@ pub struct State {
|
||||||
camera_controller: CameraController,
|
camera_controller: CameraController,
|
||||||
geom_instances: Vec<Instance>,
|
geom_instances: Vec<Instance>,
|
||||||
geom_instance_buffer: wgpu::Buffer,
|
geom_instance_buffer: wgpu::Buffer,
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
fog_instances: Vec<Instance>,
|
fog_instances: Vec<Instance>,
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
fog_instance_buffer: wgpu::Buffer,
|
fog_instance_buffer: wgpu::Buffer,
|
||||||
geometry_depth_texture: Texture,
|
geometry_depth_texture: Texture,
|
||||||
geom_model: Model,
|
geom_model: Model,
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
fog_model: Model,
|
fog_model: Model,
|
||||||
light_model: Model,
|
light_model: Model,
|
||||||
light_uniform: LightUniform,
|
light_uniform: LightUniform,
|
||||||
|
@ -368,6 +372,7 @@ impl State {
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
let fog_model = resources::load_model_gltf(
|
let fog_model = resources::load_model_gltf(
|
||||||
"models/Cube.glb",
|
"models/Cube.glb",
|
||||||
&device,
|
&device,
|
||||||
|
@ -399,12 +404,15 @@ impl State {
|
||||||
usage: wgpu::BufferUsages::VERTEX,
|
usage: wgpu::BufferUsages::VERTEX,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
let fog_instances = vec![Instance {
|
let fog_instances = vec![Instance {
|
||||||
position: [0.0, 30.0, 0.0].into(),
|
position: [0.0, 30.0, 0.0].into(),
|
||||||
rotation: cgmath::Quaternion::one(),
|
rotation: cgmath::Quaternion::one(),
|
||||||
scale: [1360.0, 30.0, 600.0].into(),
|
scale: [1360.0, 30.0, 600.0].into(),
|
||||||
}];
|
}];
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
let fog_instance_data = fog_instances.iter().map(Instance::to_raw).collect::<Vec<_>>();
|
let fog_instance_data = fog_instances.iter().map(Instance::to_raw).collect::<Vec<_>>();
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
let fog_instance_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
|
let fog_instance_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
|
||||||
label: Some("Fog Instance Buffer"),
|
label: Some("Fog Instance Buffer"),
|
||||||
contents: bytemuck::cast_slice(&fog_instance_data),
|
contents: bytemuck::cast_slice(&fog_instance_data),
|
||||||
|
@ -462,6 +470,7 @@ impl State {
|
||||||
Some(wgpu::Face::Back),
|
Some(wgpu::Face::Back),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
let fog_pass = RenderPass::new(
|
let fog_pass = RenderPass::new(
|
||||||
&device,
|
&device,
|
||||||
&[
|
&[
|
||||||
|
@ -488,6 +497,7 @@ impl State {
|
||||||
queue,
|
queue,
|
||||||
config,
|
config,
|
||||||
geometry_pass,
|
geometry_pass,
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
fog_pass,
|
fog_pass,
|
||||||
camera,
|
camera,
|
||||||
camera_uniform,
|
camera_uniform,
|
||||||
|
@ -496,10 +506,13 @@ impl State {
|
||||||
camera_controller,
|
camera_controller,
|
||||||
geom_instances,
|
geom_instances,
|
||||||
geom_instance_buffer,
|
geom_instance_buffer,
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
fog_instances,
|
fog_instances,
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
fog_instance_buffer,
|
fog_instance_buffer,
|
||||||
geometry_depth_texture,
|
geometry_depth_texture,
|
||||||
geom_model,
|
geom_model,
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
fog_model,
|
fog_model,
|
||||||
light_model,
|
light_model,
|
||||||
light_uniform,
|
light_uniform,
|
||||||
|
@ -734,6 +747,8 @@ impl State {
|
||||||
|
|
||||||
self.queue.submit(std::iter::once(geometry_encoder.finish()));
|
self.queue.submit(std::iter::once(geometry_encoder.finish()));
|
||||||
|
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
{
|
||||||
let mut fog_encoder = self
|
let mut fog_encoder = self
|
||||||
.device
|
.device
|
||||||
.create_command_encoder(&wgpu::CommandEncoderDescriptor {
|
.create_command_encoder(&wgpu::CommandEncoderDescriptor {
|
||||||
|
@ -773,6 +788,7 @@ impl State {
|
||||||
fog_encoder.pop_debug_group();
|
fog_encoder.pop_debug_group();
|
||||||
|
|
||||||
self.queue.submit(std::iter::once(fog_encoder.finish()));
|
self.queue.submit(std::iter::once(fog_encoder.finish()));
|
||||||
|
}
|
||||||
|
|
||||||
surface_texture.present();
|
surface_texture.present();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue