#Getting UVs without a buffer for UVs.

1 messages · Page 1 of 1 (latest)

pastel condor
#

So I've done an experement where I can render a mesh using integers. See it and its explanation here: #showcase message

So I want to apply textures to the thing. Here I can see how the vertex buffer is supposed to output the UV:
https://github.com/bevyengine/bevy/blob/fc56c686af20f5a91aae436511a634b758d31643/crates/bevy_pbr/src/render/mesh_vertex_output.wgsl#L6

But when I try to use it, it looks to be undefined:

2022-12-02T01:03:23.750006Z ERROR bevy_render::render_resource::pipeline_cache: failed to process shader:
error: invalid field accessor `uv`
    ┌─ wgsl:956:9
    │
956 │     out.uv = vec2(u, v);
    │         ^^ invalid accessor

After digging in engine code, it appears VERTEX_UVS is undefined because I don't have an attribute for it in my mesh: https://github.com/bevyengine/bevy/blob/d44e86507f66d2cbe2472557d2a2abb9c4f80a83/crates/bevy_sprite/src/mesh2d/mesh.rs

Well yeah, all my attributes have been combined into one buffer using bitmasks.
Is it possible to define VERTEX_UVS for the shader without needing to have that vertex buffer on hand?

GitHub

A refreshingly simple data-driven game engine built in Rust - bevy/mesh.rs at d44e86507f66d2cbe2472557d2a2abb9c4f80a83 · bevyengine/bevy

GitHub

A refreshingly simple data-driven game engine built in Rust - bevy/mesh_vertex_output.wgsl at fc56c686af20f5a91aae436511a634b758d31643 · bevyengine/bevy

pastel condor
#

For now I've found a workaround by just tacking my own @location(2) uv: vec2<f32>, into my shader, but I am wondering if maybe there's a way to #define VERTEX_UVS myself. I tried pasting just that into the shader and... well it seems the compiler doesn't understand that as a preprocessor macro.

pastel condor