aconstlink / natus

[Discontinued] Software Framework for Audio/Visual/Interactive Real-Time Applications
https://aconstlink.de
MIT License
0 stars 0 forks source link

nsl multiplication refactor #294

Closed aconstlink closed 2 years ago

aconstlink commented 2 years ago

At the moment, doing a math multiplication is done by using the tick operator ' and a component-wise multiplication is done using the normal star * operator. This should be the way around. I think it is more intuitive to use the normal * as the default multiplication. The difference is required because the hlsl mul function does not do a component-wise multiplication on tow vectors for example. It would perform a dot product. In glsl, there is no such a thing. The * operator can be used for matrix multiplication as well as component-wise multiplication.

m = ma * mb ;
vec = va * vb ;

will transform to

// hlsl
m = mul( ma, mb ) ;
vec = mul( va, vb ) ;
// glsl 
m = ma * mb ;
vec =  va * vb ;  // does not transform into a dot!

vec = va ' vb

will transform to

// hlsl
vec = va * vb ;
// glsl 
vec = va * vb ;