use crate::test_shader::some_module::Bla;
use glam::{vec4, Vec4};
use spirv_std::spirv;
mod some_module {
use super::*;
pub struct Bla {
pub value: Vec4,
pub value2: Vec4,
pub decider: f32,
}
impl Bla {
pub fn lerp(&self) -> Vec4 {
self.value * (1. - self.decider) + self.value2 * self.decider
}
}
}
#[spirv(vertex)]
pub fn vertex(
#[spirv(vertex_index)] vertex_id: u32,
#[spirv(position)] position: &mut Vec4,
vtx_color: &mut Bla,
) {
let corners = [
vec4(-0.5, -0.5, 0.1, 1.),
vec4(0.5, -0.5, 0.1, 1.),
vec4(0., 0.5, 0.1, 1.),
];
*position = corners[(vertex_id % 3) as usize];
*vtx_color = Bla {
value: vec4(1., 1., 0., 1.),
value2: vec4(0., 1., 1., 1.),
decider: f32::max(vertex_id as f32, 1.),
};
}
#[spirv(fragment)]
pub fn fragment(vtx_color: Bla, f_color: &mut Vec4) {
*f_color = vtx_color.lerp();
}