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

Consider adding a VertexFormat::Mat3 as well #396

Open
EriKWDev opened this issue Jul 27, 2023 · 0 comments
Open

Consider adding a VertexFormat::Mat3 as well #396

EriKWDev opened this issue Jul 27, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@EriKWDev
Copy link

EriKWDev commented Jul 27, 2023

Heyope :)

It would be nice to also be able to have mat3 as vertex attributes which would require a VertexFormat::Mat3

I use the transpose of the inverse of a model matrix for correcting normal orientations per instance and it's nice to not have to compute it in the shader since it's a bit expensive and also without wasting space with a Mat4, and it would look nicer than my current setup:

attribute mediump vec3 instance_normal_0;
attribute mediump vec3 instance_normal_1;
attribute mediump vec3 instance_normal_2;

with attributes and layout as so:

            miniquad::BufferLayout {
                step_func: miniquad::VertexStep::PerInstance,
                stride: std::mem::size_of::<[[f32; 3]; 3]>() as _,
                ..Default::default()
            },

// ...
            miniquad::VertexAttribute::with_buffer("instance_normal_0", miniquad::VertexFormat::Float3, 3),
            miniquad::VertexAttribute::with_buffer("instance_normal_1", miniquad::VertexFormat::Float3, 3),
            miniquad::VertexAttribute::with_buffer("instance_normal_2", miniquad::VertexFormat::Float3, 3),

To my understanding, it seems that it would only require changing in new_pipeline_with_params with an added case that sets attributes_len and attributes_count to 3 for a VertexFormat::Mat3.

Possibly also apply_uniforms_from_bytes If we're also adding a UniformType::Mat3 while we're at it.

Anything I'm missing about GL ES compatability or would that suffice and work?

@not-fl3 not-fl3 added the enhancement New feature or request label Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants