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

Matrix multiply is not commutative #472

Open
Elektraglide opened this issue Nov 18, 2024 · 6 comments
Open

Matrix multiply is not commutative #472

Elektraglide opened this issue Nov 18, 2024 · 6 comments

Comments

@Elektraglide
Copy link

Elektraglide commented Nov 18, 2024

you cannot swap order of multiplies for matrices; it changes the meaning.
I have vec4 v = mat33 * (vec3 * float) which is transformed into:
vec4 v = (vec3 * float) * mat33

Is rewriter.fs:240 the problem?

@laurentlb
Copy link
Owner

Which version of Shader Minifier are you using? I think we fixed some instances of the bug.

Can you share the line of code that triggers the bug?

@eldritchconundrum
Copy link
Collaborator

My guess is, it's this rewrite: x*(y*z) -> y*z*x
How to reproduce:
mat2 f(){ return mat3x2(1) * (mat4x3(1) * mat2x4(1)); }
becomes
mat2 f(){return mat4x3(1)*mat2x4(1)*mat3x2(1);}

@Elektraglide
Copy link
Author

Damn, thats a quick response! I had edited my post having looked atthe source code.
Is rewriter.fs:240 the problem?

@eldritchconundrum
Copy link
Collaborator

No, but commenting out lines 198-200 of rewriter.fs should fix it

@Elektraglide
Copy link
Author

yep, that works. cheers

@laurentlb
Copy link
Owner

Good point, we need a --version flag. :)

The version number is included in (some of) the generated outputs, but you can also run .\shader_minifier.exe --help and look at the first line.

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

No branches or pull requests

3 participants