hi everyone, how can I pass a struct as a uniform to a shader in glium?
this is the struct in my rust program and then in my shader:
#[derive(Debug, Copy, Clone)]
pub struct Material {
pub ambient: [f32; 3],
pub diffuse: [f32; 3],
pub specular: [f32; 3],
pub shininess: f32,
}
struct Material {
vec3 ambient;
vec3 diffuse;
vec3 specular;
float shininess;
};
I use a UniformBuffer like this:
let material_buffer = glium::uniforms::UniformBuffer::new(&display, object.renderable.material).unwrap();
let uniforms = uniform! {
...
material: &material_buffer,
}
and it doesn't throw errors nor does it crash, but the material values in the shader are all zeros and make the shapes balck.
I think i have to implement AsUniformValue for Material but I don't know what to put in the as_uniform_value function....