sky should not be using model_sampler

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

View File

@ -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() {

View File

@ -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<uniform> model_instances: array<ModelInstance, MAX_MODEL_INSTANCES>;
@group(1)
@group(2)
@binding(1)
var model_texture: texture_2d<f32>;
@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<f32>;
@group(2)
@group(1)
@binding(1)
var cube_sampler: sampler;
@fragment
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