OpenShadingLanguage: min() is bugged in vector2.h
Problem
The following two functions in the “vector2.h” header are bugged.
- vector2 add(vector2 a, vector2 b)
- vector2 add(vector2 a, float b)
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:
#include "vector2.h"
shader Texture(
output color value = 0,
vector2 a = {1, 0},
vector2 b = {0, 1})
{
vector2 c = min(a, b);
value = color(c.x, c.y, 0.0);
}
Result should be black, not yellow.
Versions
all (I suppose)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 19 (14 by maintainers)
@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.