-
I've got the following render resources that I'm trying to use for a custom tilemap shader: #[derive(RenderResources, Default, TypeUuid)]
#[uuid = "3bf9e364-f29d-4d6c-92cf-93298466c620"]
struct MyMaterial {
pub color: Color,
pub map_info: MapInfo,
pub tileset_info: TilesetInfo,
pub texture: Handle<Texture>,
#[render_resources(buffer)]
pub tiles: Vec<TileInfo>,
}
#[repr(C)]
#[derive(RenderResource, Default, Debug, Clone, Copy)]
struct MapInfo {
width: u32,
height: u32,
}
unsafe impl Byteable for MapInfo {}
#[repr(C)]
#[derive(RenderResource, Default, Debug, Clone, Copy)]
struct TilesetInfo {
grid_size: u32,
width: u32,
height: u32,
}
unsafe impl Byteable for TilesetInfo {}
#[repr(C)]
#[derive(RenderResource, Default, Debug, Clone, Copy)]
struct TileInfo {
tile_index: u32,
flip_x: bool,
flip_y: bool,
}
unsafe impl Byteable for TileInfo {} And here is the fragment shader I'm trying to use the resources in: #version 450
layout(location = 0) in vec3 v_Normal;
layout(location = 1) in vec2 v_Uv;
layout(location = 0) out vec4 o_Target;
layout(set = 2, binding = 0) uniform MyMaterial_color {
vec4 Color;
};
layout(set = 2, binding = 1) uniform MyMaterial_map_info {
uint width;
uint height;
};
layout(set = 2, binding = 2) uniform MyMaterial_tileset_info {
uint tileset_grid_size;
uint tileset_width;
uint tileset_height;
};
layout(set = 2, binding = 3) uniform texture2D MyMaterial_texture;
layout(set = 2, binding = 4) uniform sampler MyMaterial_texture_sampler;
struct TileInfo {
uint tile_index;
bool flip_x;
bool flip_y;
};
// Issue starts here
// layout(set = 2, binding = 5) buffer MyMaterial_tiles {
// TileInfo[] map_tiles;
// };
void main() {
// Ignore this
o_Target = texture(
sampler2D(MyMaterial_texture, MyMaterial_texture_sampler),
v_Uv / vec2(tileset_width, tileset_height) + vec2(0.1)
);
} The issue I'm having is that when I uncomment the layout below "issue starts here" in the shader, the game crashes with the following error:
Is there something I need to do to add the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I'm guessing that you need to change There is some nuance here where we could technically put everything but the buffer type into a dynamic uniform buffer, then put the buffer type in a normal buffer. But right now that level of customization is not supported. |
Beta Was this translation helpful? Give feedback.
I'm guessing that you need to change
AssetRenderResourcesNode<T>::new(true)
tonew(false)
. Buffer/Storage types cannot be dynamic uniforms.There is some nuance here where we could technically put everything but the buffer type into a dynamic uniform buffer, then put the buffer type in a normal buffer. But right now that level of customization is not supported.