Cycles in the shader graph


bbannayan@...
 

Consider the following:

 

Shader A has parameters: diffdiff_tex, and diff_value

Shader B has parameters: valuetex, and output

 

I'd like to connect in this way:

 

A.diffuse -> B.value

A.diffuse_tex -> B.tex

 

B.output -> A.diffuse_value

 

The A parameters are not "outputs" from the shader.  They are merely parameters with values that I'd like carried forward to B so that the output can be calculated and sent back to A.

 

The OSL code of A references only the diff_value parameter so there's no actual cycle when you get down to the final evaluation.

 

Something like this:

surface

A(float diff = 1,

  string diff_tex = "",

  float diff_value = 1)

{

  Ci = diff_value * diffuse(N);

}

 

 

shader

B(float value = 1,

  string tex = "",

  output float out = 1,

  float st[2] = { 0.0, 0.0 })

{

  out = value * texture(tex, st[0], st[1]);

}

 

The idea for me is that I can have the B shader doing some work but I only ever have to interact with the parameters of A when editing my scene (I'm doing this in a renderer that allows modifying the parameters of shaders during a render).  In my particular case A represents a node in my DCC scene and B is a convenience/implementation detail. So when my DCC says "A.diff" has been changed I can change "A.diff" in my render scene without having to figure out if B exists.

 

Join osl-dev@lists.aswf.io to automatically receive all group messages.