4
$\begingroup$

The Open Shading Language spec says

Color variables may also have their components referenced using “named components” that look like accessing structure fields named r, g, and b, as synonyms for [0], [1], and [2], respectively:

float green = C.g; // get the green component  
C.r = 0.5;         // set the red component

It says the same thing about points and x, y, z components. This is not working for me in Blender 2.8. I get errors like:

error: type 'point' does not have a member 'x'

Is this not implemented in Blender?

$\endgroup$
1
  • $\begingroup$ I'm not trying to use another OSL shader; I'm learning the language so I can write my own. It's not a show-stopper to write p[0], p[1], etc. I just find p.x, p.y to be clearer to read. Maybe I should just report it in the Blender bug tracker and see what they say. $\endgroup$ – Rob N May 10 '20 at 16:57
4
$\begingroup$

The syntax was introduced in version 1.11 of the Open Shading Language (OSL) specification.

OSL Language and oslc compiler:

  • New syntax to reference color and point/vector/normal components as named struct components, such as C.r, C.g, C.b, or P.x, P.y, P.z. #1049 (1.11.0)

Blender 2.83 is using OSL 1.10.9 and thus doesn't support this syntax yet.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.