|
@@ -2,7 +2,7 @@ use std::{iter, time::{Duration, Instant}};
|
|
|
|
|
|
|
|
use camera::{camera_buffer, camera_controller, camera_struct::Camera, camera_uniform};
|
|
use camera::{camera_buffer, camera_controller, camera_struct::Camera, camera_uniform};
|
|
|
use compute::SIZE;
|
|
use compute::SIZE;
|
|
|
-use wgpu::{include_wgsl, util::DeviceExt, BlendState, ColorTargetState, ComputePipeline, PipelineLayoutDescriptor, RenderPipeline, RenderPipelineDescriptor, Texture, TextureView};
|
|
|
|
|
|
|
+use wgpu::{include_wgsl, util::DeviceExt, BindGroupLayout, BlendState, ColorTargetState, ComputePipeline, PipelineLayoutDescriptor, RenderPipeline, RenderPipelineDescriptor, Texture, TextureView};
|
|
|
use winit::{
|
|
use winit::{
|
|
|
event::*,
|
|
event::*,
|
|
|
event_loop::EventLoop,
|
|
event_loop::EventLoop,
|
|
@@ -56,6 +56,7 @@ struct State<'a> {
|
|
|
heightmap2_texture: wgpu::Texture,
|
|
heightmap2_texture: wgpu::Texture,
|
|
|
visualisation_texture: Texture,
|
|
visualisation_texture: Texture,
|
|
|
visualisation_texture_view: TextureView,
|
|
visualisation_texture_view: TextureView,
|
|
|
|
|
+ visualisation_texture_bind_group_layout: BindGroupLayout,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
impl<'a> State<'a> {
|
|
impl<'a> State<'a> {
|
|
@@ -280,6 +281,7 @@ impl<'a> State<'a> {
|
|
|
heightmap2_texture: x.3,
|
|
heightmap2_texture: x.3,
|
|
|
visualisation_texture: y.0,
|
|
visualisation_texture: y.0,
|
|
|
visualisation_texture_view: y.1,
|
|
visualisation_texture_view: y.1,
|
|
|
|
|
+ visualisation_texture_bind_group_layout: y.2,
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -343,13 +345,13 @@ impl<'a> State<'a> {
|
|
|
|
|
|
|
|
encoder.copy_texture_to_texture(wgpu::ImageCopyTextureBase{
|
|
encoder.copy_texture_to_texture(wgpu::ImageCopyTextureBase{
|
|
|
texture: &self.heightmap2_texture,
|
|
texture: &self.heightmap2_texture,
|
|
|
- mip_level: 1,
|
|
|
|
|
|
|
+ mip_level: 0,
|
|
|
origin: wgpu::Origin3d::ZERO,
|
|
origin: wgpu::Origin3d::ZERO,
|
|
|
aspect: wgpu::TextureAspect::All
|
|
aspect: wgpu::TextureAspect::All
|
|
|
},
|
|
},
|
|
|
wgpu::ImageCopyTextureBase{
|
|
wgpu::ImageCopyTextureBase{
|
|
|
texture: &self.visualisation_texture,
|
|
texture: &self.visualisation_texture,
|
|
|
- mip_level: 1,
|
|
|
|
|
|
|
+ mip_level: 0,
|
|
|
origin: wgpu::Origin3d::ZERO,
|
|
origin: wgpu::Origin3d::ZERO,
|
|
|
aspect: wgpu::TextureAspect::All
|
|
aspect: wgpu::TextureAspect::All
|
|
|
},
|
|
},
|
|
@@ -360,6 +362,33 @@ impl<'a> State<'a> {
|
|
|
}
|
|
}
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
|
|
+ let visu_view = self.visualisation_texture.create_view(&wgpu::TextureViewDescriptor::default());
|
|
|
|
|
+
|
|
|
|
|
+ let sampler_visu = self.device.create_sampler(&wgpu::SamplerDescriptor {
|
|
|
|
|
+ address_mode_u: wgpu::AddressMode::ClampToEdge,
|
|
|
|
|
+ address_mode_v: wgpu::AddressMode::ClampToEdge,
|
|
|
|
|
+ address_mode_w: wgpu::AddressMode::ClampToEdge,
|
|
|
|
|
+ mag_filter: wgpu::FilterMode::Linear,
|
|
|
|
|
+ min_filter: wgpu::FilterMode::Nearest,
|
|
|
|
|
+ mipmap_filter: wgpu::FilterMode::Nearest,
|
|
|
|
|
+ ..Default::default()
|
|
|
|
|
+ });
|
|
|
|
|
+ let visu_bind_group = self.device.create_bind_group(&wgpu::BindGroupDescriptor{
|
|
|
|
|
+ label: Some("Visu bind group"),
|
|
|
|
|
+ layout: &self.visualisation_texture_bind_group_layout,
|
|
|
|
|
+ entries: &[
|
|
|
|
|
+ wgpu::BindGroupEntry{
|
|
|
|
|
+ binding: 0,
|
|
|
|
|
+ resource: wgpu::BindingResource::TextureView(&visu_view)
|
|
|
|
|
+ },
|
|
|
|
|
+ wgpu::BindGroupEntry{
|
|
|
|
|
+ binding:1,
|
|
|
|
|
+ resource: wgpu::BindingResource::Sampler(&sampler_visu)
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
{
|
|
{
|
|
|
let mut render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
|
let mut render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
|
|
label: Some("Render Pass"),
|
|
label: Some("Render Pass"),
|
|
@@ -394,6 +423,7 @@ impl<'a> State<'a> {
|
|
|
render_pass.set_vertex_buffer(0, self.vertex_buffer.slice(..));
|
|
render_pass.set_vertex_buffer(0, self.vertex_buffer.slice(..));
|
|
|
render_pass.set_bind_group(0, &self.camera_bind_group, &[]);
|
|
render_pass.set_bind_group(0, &self.camera_bind_group, &[]);
|
|
|
render_pass.set_bind_group(1, &self.texture_bind_group, &[]);
|
|
render_pass.set_bind_group(1, &self.texture_bind_group, &[]);
|
|
|
|
|
+ render_pass.set_bind_group(2, &visu_bind_group, &[]);
|
|
|
render_pass.draw(0..self.num_vertices, 0..1);
|
|
render_pass.draw(0..self.num_vertices, 0..1);
|
|
|
//render_pass.draws
|
|
//render_pass.draws
|
|
|
}
|
|
}
|