Re: How can I store global variables one by one in an array?

Larry Gritz

I'm not sure what you mean by the "coordinate of P" or what you mean by "an array from a global variable." Can you explain in more detail, or maybe show a few lines of code illustrating what you want to do?

The "global variable" P is just the position of the single point that is being shaded by that invocation of the shader.

Do you mean getting at the individual x, y, and z values for that point using an array notation? You can just say P[0] for the x coordinate (this is equivalent to saying P.x), P[1] for the y coordinate (same as P.y), and P[2] for the z coordinate (same as P.z).

On Feb 17, 2022, at 2:53 AM, トマトフライ <tomatofry.illust@...> wrote:

I saw your github and contacted you.
Is this the right place to post my question?
If I'm wrong, please delete it.

I would like to ask the following questions.

I am trying to create a function in an OSL script that will evaluate the Coordinate of one of the "global variables P" and the Coordinate of the other. I have read and checked the OSL specifics, but I could not find any description of how to extract an array from a global variable. If possible, could you please tell me how to call the Coordinate one by one from the "global variable P"?

Also, on a different note, I found that the global variable behaved like a structure with some parameters. Please let me know if there is a site or a way to refer to such parameters.

Thank you. 

Larry Gritz

Join { to automatically receive all group messages.