RSL: Passing values from lights shaders to surface shaders
by TheRiverside on Nov.12, 2009, under Renderman II Final Project
Sometimes there are parameters defined in a surface shader that would ideally be controlled by the lighting artist. It is possible to have variables edited in the light and passed to the surface shader.
The process is pretty straight-forward:
In the light, define the editable variable. For example:
In the light shader:
light
wrapperlight(float intensity = 1;
color lightcolor = 1;
string __category = “wrapper”;
float wrapAngleFromLight = 0){
(body) }
Then, define a variable in the body of the surface shader, and use the “lightsource” function to feed the value from the light shader into the value into the surface shader.
In the body of the surface shader:
float wrapAngleInSurface;
illuminance(”-wrapper”, P, n, PI/2 ){
lightsource(”wrapAngleFromLight”, wrapAngleInSurface);
*rest of illuminance statement*}
In these examples, the lighter can now change “wrapAngleFromLight” in the light itself. The value will be passed to “wrapAngleInSurface” in the surface shader. The surface shader will then use “wrapAngleInSurface” to perform calculations where the value is needed.