OSL shader language question


Patrick Hodoul
 

Hi,

OCIOv2 now generates an OSL shader program. But I face some irritating syntax changes to accommodate OSL when generating the shader code. To simplify the generation of the code, I would like to write something like:
vector4 res;
color4 color = res;


The idea is to perform some computations with the vector4 'res' variable and another color4 variable representing the input color, and finally store it in the color4 variable (representing the output color) which is passed to the next step in the computation pipeline. Note that the input and output color variables are in fact the same. The example above oversimplifies the code to better highlight the need. I use vector4 by default because of the 'uniform' access to the values i.e. res[x] or res.r, etc and it's close to the GLSL/HLSL syntax.

To make this work, the code recreates the color4 like below. But it will simplify the code to write "color = res;"

color = color4(vector(res.x, res.y, res.z), res.w);
or
color.rgb = color(res.x, res.y, res.z);
color.a = res.w;

Following the really helpful 'operator overloading' idea (that I use a lot) I was wondering if there is a way to implement "color = res;" and also "res = color;"

--
Patrick