Please sign in to comment.
Allow aggregate component access with .[xyzrgb] (#1049)
Spatial geometry triples (point, vector, normal) now support A.x, A.y, A.z as synonyms for A, A, A, respectively. It's not the notation I prefer (obviously, or I would have done it 25 years ago), but other people really dig it, so fine by me. Colors now support A.r, A.g, A.b as synonyms for A, A, A, respectively. To be honest, this worries me a little because I fear we will regret it if we ever shift to supporting spectral rendering (and the components will not necessarily represent red, green, and blue, and may have arbitrary number). But again, people really seem to like this, so fine, but don't come complaining to me in a few years when your shaders all need rewriting for your new spectral renderer. In both cases, it's for direct reference to lvalues (variables, including references passed as arguments to functions): val = P.x; // yes P.y = val; // yes function_with_float_param (P.z); // yes But you can't use this notations on arbitrary expressions: val = function_returning_color().r; // no val = (P + N).y; // no, double ick We are also NOT supporting "swizzling." Note that this is strictly an oslc-side change, underneath C.r compiles to the same ops as C always did, so newly compiled shader using this new syntax can be executed with old renderers/shading engines.
- Loading branch information...
Showing with 421 additions and 75 deletions.
- +3 −0 CHANGES.md
- +2 −0 CMakeLists.txt
- +29 −2 src/doc/languagespec.tex
- +5 −0 src/include/osl_pvt.h
- +79 −46 src/liboslcomp/ast.cpp
- +21 −12 src/liboslcomp/ast.h
- +29 −5 src/liboslcomp/codegen.cpp
- +9 −7 src/liboslcomp/typecheck.cpp
- +7 −0 testsuite/color/ref/out.txt
- +19 −1 testsuite/color/test.osl
- +34 −0 testsuite/named-components/ref/out.txt
- +3 −0 testsuite/named-components/run.py
- +34 −0 testsuite/named-components/test.osl
- +63 −0 testsuite/named-components/test_named_comp.h
- +1 −0 testsuite/oslc-err-named-components/NOOPTIMIZE
- +1 −0 testsuite/oslc-err-named-components/NOOPTIX
- +6 −0 testsuite/oslc-err-named-components/ref/out.txt
- +5 −0 testsuite/oslc-err-named-components/run.py
- +22 −0 testsuite/oslc-err-named-components/test.osl
- +10 −0 testsuite/vector/ref/out-alt.txt
- +10 −0 testsuite/vector/ref/out.txt
- +29 −2 testsuite/vector/test.osl
Oops, something went wrong.