Open davesmith00000 opened 11 months ago
As usual, it's a bit complicated.
The spec calls these "vector relational functions": "<" | "<=" | ">" | ">=" | "==" | "!="
https://registry.khronos.org/OpenGL/specs/es/3.0/GLSL_ES_Specification_3.00.pdf
...and it's easy enough in theory, you just need to make sure the type on the left is the same as the type on the right. However in practice, as soon as you introduce a variable then at the point of comparison, you don't have the type immediately to hand.
I did try doing a "best effort" comparison, knowing the names of the types we care about we can just check, right? Well, no, because the Scala compile things comparing float and double is totally ok, and inlines known values and whole if statements before we can even check them. :smile:
So plan B might be to add it to the program validation step, which is only slightly better than the current behaviour.
This is perfectly ok according to the Scala compiler:
if 1.0f < 0 then ...
but does not compile to GLSL because they both need to be floats, i.e.:if 1.0f < 0.0 then ...
You get a compile error in the browser logs, but it would be nice to catch this at Scala compile time.