diff --git a/src/main.rs b/src/main.rs index 337a4aa..4c85b37 100644 --- a/src/main.rs +++ b/src/main.rs @@ -525,11 +525,19 @@ impl framework::Example for GraphicsData { }) }; - let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { + let model_pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { label: None, bind_group_layouts: &[ &camera_bind_group_layout, + &skybox_texture_bind_group_layout, &model_bind_group_layout, + ], + push_constant_ranges: &[], + }); + let sky_pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { + label: None, + bind_group_layouts: &[ + &camera_bind_group_layout, &skybox_texture_bind_group_layout, ], push_constant_ranges: &[], @@ -538,7 +546,7 @@ impl framework::Example for GraphicsData { // Create the render pipelines let sky_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { label: Some("Sky Pipeline"), - layout: Some(&pipeline_layout), + layout: Some(&sky_pipeline_layout), vertex: wgpu::VertexState { module: &shader, entry_point: "vs_sky", @@ -565,7 +573,7 @@ impl framework::Example for GraphicsData { }); let model_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { label: Some("Model Pipeline"), - layout: Some(&pipeline_layout), + layout: Some(&model_pipeline_layout), vertex: wgpu::VertexState { module: &shader, entry_point: "vs_entity_texture", @@ -859,11 +867,11 @@ impl framework::Example for GraphicsData { }); rpass.set_bind_group(0, &self.bind_groups.camera, &[]); - rpass.set_bind_group(2, &self.bind_groups.skybox_texture, &[]); + rpass.set_bind_group(1, &self.bind_groups.skybox_texture, &[]); rpass.set_pipeline(&self.pipelines.model); for model in self.models.iter() { - rpass.set_bind_group(1, &model.bind_group, &[]); + rpass.set_bind_group(2, &model.bind_group, &[]); rpass.set_vertex_buffer(0, model.vertex_buf.slice(..)); for entity in model.entities.iter() { diff --git a/src/shader.wgsl b/src/shader.wgsl index 69774fb..7e8c5ca 100644 --- a/src/shader.wgsl +++ b/src/shader.wgsl @@ -49,13 +49,13 @@ struct ModelInstance{ //the texture transform then maps the texture coordinates to the location of the specific texture //group 1 is the model const MAX_MODEL_INSTANCES=4096; -@group(1) +@group(2) @binding(0) var model_instances: array; -@group(1) +@group(2) @binding(1) var model_texture: texture_2d; -@group(1) +@group(2) @binding(2) var model_sampler: sampler; @@ -85,16 +85,16 @@ fn vs_entity_texture( } //group 2 is the skybox texture -@group(2) +@group(1) @binding(0) var cube_texture: texture_cube; -@group(2) +@group(1) @binding(1) var cube_sampler: sampler; @fragment fn fs_sky(vertex: SkyOutput) -> @location(0) vec4 { - return textureSample(cube_texture, model_sampler, vertex.sampledir); + return textureSample(cube_texture, cube_sampler, vertex.sampledir); } @fragment