sky should not be using model_sampler

This commit is contained in:
Quaternions 2023-09-28 18:28:10 -07:00
parent 822c9d6d5f
commit c32d3ebd98
2 changed files with 19 additions and 11 deletions

View File

@ -594,11 +594,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, label: None,
bind_group_layouts: &[ bind_group_layouts: &[
&camera_bind_group_layout, &camera_bind_group_layout,
&skybox_texture_bind_group_layout,
&model_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, &skybox_texture_bind_group_layout,
], ],
push_constant_ranges: &[], push_constant_ranges: &[],
@ -607,7 +615,7 @@ impl framework::Example for GraphicsData {
// Create the render pipelines // Create the render pipelines
let sky_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { let sky_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: Some("Sky Pipeline"), label: Some("Sky Pipeline"),
layout: Some(&pipeline_layout), layout: Some(&sky_pipeline_layout),
vertex: wgpu::VertexState { vertex: wgpu::VertexState {
module: &shader, module: &shader,
entry_point: "vs_sky", entry_point: "vs_sky",
@ -634,7 +642,7 @@ impl framework::Example for GraphicsData {
}); });
let model_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { let model_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: Some("Model Pipeline"), label: Some("Model Pipeline"),
layout: Some(&pipeline_layout), layout: Some(&model_pipeline_layout),
vertex: wgpu::VertexState { vertex: wgpu::VertexState {
module: &shader, module: &shader,
entry_point: "vs_entity_texture", entry_point: "vs_entity_texture",
@ -932,11 +940,11 @@ impl framework::Example for GraphicsData {
}); });
rpass.set_bind_group(0, &self.bind_groups.camera, &[]); 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); rpass.set_pipeline(&self.pipelines.model);
for model in self.models.iter() { 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(..)); rpass.set_vertex_buffer(0, model.vertex_buf.slice(..));
for entity in model.entities.iter() { for entity in model.entities.iter() {

View File

@ -49,13 +49,13 @@ struct ModelInstance{
//the texture transform then maps the texture coordinates to the location of the specific texture //the texture transform then maps the texture coordinates to the location of the specific texture
//group 1 is the model //group 1 is the model
const MAX_MODEL_INSTANCES=4096; const MAX_MODEL_INSTANCES=4096;
@group(1) @group(2)
@binding(0) @binding(0)
var<uniform> model_instances: array<ModelInstance, MAX_MODEL_INSTANCES>; var<uniform> model_instances: array<ModelInstance, MAX_MODEL_INSTANCES>;
@group(1) @group(2)
@binding(1) @binding(1)
var model_texture: texture_2d<f32>; var model_texture: texture_2d<f32>;
@group(1) @group(2)
@binding(2) @binding(2)
var model_sampler: sampler; var model_sampler: sampler;
@ -85,16 +85,16 @@ fn vs_entity_texture(
} }
//group 2 is the skybox texture //group 2 is the skybox texture
@group(2) @group(1)
@binding(0) @binding(0)
var cube_texture: texture_cube<f32>; var cube_texture: texture_cube<f32>;
@group(2) @group(1)
@binding(1) @binding(1)
var cube_sampler: sampler; var cube_sampler: sampler;
@fragment @fragment
fn fs_sky(vertex: SkyOutput) -> @location(0) vec4<f32> { fn fs_sky(vertex: SkyOutput) -> @location(0) vec4<f32> {
return textureSample(cube_texture, model_sampler, vertex.sampledir); return textureSample(cube_texture, cube_sampler, vertex.sampledir);
} }
@fragment @fragment