-
Notifications
You must be signed in to change notification settings - Fork 359
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
min() is bugged in vector2.h #1889
Comments
src/shaders/vector2.h
which is clearly broken, it should be
More over there should be some tests added to exercise all these operations. |
Code review also shows that dividing by an integer is bugged.
|
Also dividing by integer for vector4 is bugged in the same manner:
|
Even more troubling, code review shows that Color2 * Color2 is broken:
When it should be
|
Dividing by integer for color2 also exhibits same bug, reproducer:
|
Also color2 + color2 is bugged.
Should be:
|
Oof, this is all pretty bad. Does this mean that nobody actually uses these classes? |
int - color2 and is incorrect, reproducer/fix:
float - color2 and is incorrect, reproducer/fix:
|
color2 == color2 is incorrect, reproducer/fix:
|
fmod(color2, color2) is broken, reproducer/fix:
|
color4 / int is broken, reproducer/fix:
|
Noticed that dot for color4 only accepts a color as 2nd argument, ignores color4.a (which might be fine depending on expected behavior).
However dot(color4, color4) is undefined, which again might be OK depending on expected behavior.
will fail to compile:
|
@lgritz I Finished reviewing /src/shaders/*.h files, with the correctness issues noted above in the comments. I guess matrix33.h could use a comment in it explaining is usefulness, which I assume is the function matrix44To33 which introduces compile time constant 0's and 1 into an underlying 4x4 matrix which hopefully will allow the optimizer to remove portions of subsequent matrix operations whose results would always be 0 or idenity. |
Apparently, the reason MaterialX works is that they have vendored these headers on their end and mostly fixed the bugs long ago. That makes this make more sense to me. Probably these have gone undiscovered for so long because using 2- and 4-vectors is not idiomatic OSL, and so there is essentially nobody depending on them outside of their use in MaterialX. But I'll fix here and submit a PR right away. |
If MaterialX codegen already has their own copy, maybe we should deprecate these? |
Looking at the MaterialX copy -- I see the same bug ... |
Yes, the original issue I reported, is also in need of fixing in MaterialX's vendored header. As for dot between a color and color4, I'd say it is ok for it to fail to compile, as dot product should not be well defined between arguments of different dimensions. |
I think |
Problem
The following two functions in the "vector2.h" header are bugged.
The first has the bug, the second uses the first so gets bugged as well.
Looks like a copy/pate bug that just got left in there, trivial to fix (not bothering with a PR)
Expected behavior:
The minimum value between the 2 arguments should be in the result, for both components
Actual behavior:
The result contains just the first component of the first argument, and the second component of the second argument - regardless.
Steps to Reproduce
Write a simple shader like that uses this function from the
vector2.h
header:Result should be black, not yellow.
Versions
all (I suppose)
The text was updated successfully, but these errors were encountered: