I'm making a voxel engine
here's my shader:
#import bevy_pbr::{
mesh_functions,
view_transformations::position_world_to_clip
}
struct VertexInput {
@builtin(instance_index) instance_index: u32,
@location(0) packed_data: u32,
};
struct VertexOutput {
@builtin(position) pos: vec4<f32>,
};
struct UnpackedData {
pos: vec3<f32>,
face: u32,
};
fn unpack(packed: u32) -> UnpackedData {
let x = f32((packed >> 0) & 0xF);
let z = f32((packed >> 4) & 0xF);
let y = f32((packed >> 8) & 0x1F);
let f = (packed >> 13) & 0x7; // face direction
return UnpackedData(vec3(x, y, z), f);
}
@vertex
fn vs_main(in: VertexInput) -> VertexOutput {
var out: VertexOutput;
let data = unpack(in.packed_data);
var world_from_local = mesh_functions::get_world_from_local(in.instance_index);
let world_position = mesh_functions::mesh_position_local_to_world(world_from_local, vec4(data.pos, 1.0));
out.pos = position_world_to_clip(world_position.xyz);
return out;
}
@fragment
fn fs_main() -> @location(0) vec4<f32> {
return vec4<f32>(0.486, 1.0, 0.564, 1.0);
}
Currently I'm getting this validation error:
In Device::create_render_pipeline, label = 'opaque_mesh_pipeline'
Error matching ShaderStages(VERTEX) shader requirements against the pipeline
Location[0] Uint32 interpolated as Some(Flat) with sampling None is not provided by the previous stage outputs
Input type is not compatible with the provided Float32x3
If I return the same data as the default vertex shader, could I use bevy's PBR fragment shader+?A
Also how could I later implement shadowmaps?