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

Various mathematical transformations #376

Open
1 of 7 tasks
therontarigo opened this issue May 6, 2024 · 0 comments
Open
1 of 7 tasks

Various mathematical transformations #376

therontarigo opened this issue May 6, 2024 · 0 comments

Comments

@therontarigo
Copy link
Contributor

therontarigo commented May 6, 2024

Generally an improvement:

  • cross(-a,b) or cross(a,-b) or -cross(a,b) -> cross(b,a) (related issue: sign cancellation)
  • Left vs right multiplication:
    transpose(mat)*vec -> vec*mat
    vec*transpose(mat) -> mat*vec
  • transpose(a)*transpose(b) -> transpose(b*a)
  • distance(a,b) -> length(a-b) (completed in 40dae3c)

Only if there's a flag to turn it off (otherwise could hurt compression):

  • sqrt(dot(a,a)) -> length(a)
  • min/max simplification (related issue: sign cancellation)
    min(-a,-b) -> -max(a,b)
    -max(a,-b) -> min(-a,b)
    and so-forth.
  • Common cross-product expansions:
    cross(vec3(1,0,0),a) -> vec3(0,-a.z,a.y)
    cross(vec3(0,1,0),a) -> vec3(a.z,0,-a.x)
    cross(vec3(0,0,1),a) -> vec3(-a.y,a.x,0)
    ( perhaps generalized to cross(vec3(d,0,0),a) -> d*vec3(0,-a.z,a.y) etc. (when d is known to be scalar type), though this doesn't seem common )

Expected impact on precision: none, driver shader compilers typically perform similar transformations anyway.

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

1 participant