Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support uniform arrays #754

Merged
merged 1 commit into from
Jul 9, 2024
Merged

Support uniform arrays #754

merged 1 commit into from
Jul 9, 2024

Conversation

not-fl3
Copy link
Owner

@not-fl3 not-fl3 commented Jul 9, 2024

Before this PR, it was impossible to create macroquad material with an array as an uniform type.

Now it is possible:

    let mat_with_array = load_material(
        ShaderSource::Glsl {
            vertex: VERTEX,
            fragment: FRAGMENT_WITH_ARRAY,
        },
        MaterialParams2 {
            uniforms: vec![UniformDesc::array(
                UniformDesc::new("test_color", UniformType::Float4),
                10,
            )],
            pipeline_params,
            ..Default::default()
        },
    )

To reduce an impact of a braking change, load_material signature changed:

pub fn load_material(
    shader: crate::ShaderSource,
-     params: MaterialParams,
+     impl Into<params: MaterialParams>,
 ) -> Result<Material, Error>;

Most of the old code using load_material should keep working, while now it is possible to use MaterialParams2, the same struct, but with a complete UniformDesc. Complete UniformDesc now allows loading materials with arrays as a uniform.

A custom_material example got updated to show how to use uniform arrays.

@not-fl3 not-fl3 merged commit c8d1755 into master Jul 9, 2024
0 of 12 checks passed
This was referenced Jul 10, 2024
@not-fl3 not-fl3 deleted the uniform_arrays branch August 23, 2024 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant