|
This example allows you to interact with the balance between separate light passes. Rendering an AOV image per light is more involved than it would be ideally because the contributions from each light need to be separated inside the illumination loops. In this example, an unmodified scene is just rendered multiple times with only one light switched on at a time. The hb_plastic.sl shader is a standard plastic shader. Rendering will now create the following four images.
The scene file prepare.rib shows how the lights are switched on by the preprocessor. To interact with these images, we need to write a shader interact.sl to recombine the four AOV image values according to four factors. surface main( varying color Cambient=0; varying color Clight1=0; varying color Clight2=0; varying color Clight3=0;
uniform float intensityA=1; uniform float intensity1=1; uniform float intensity2=1; uniform float intensity3=1;
uniform color lightcolorA=1; uniform color lightcolor1=1; uniform color lightcolor2=1; uniform color lightcolor3=1; ) { Ci=Cambient*intensityA*lightcolorA + Clight1*intensity1*lightcolor1 + Clight2*intensity2*lightcolor2 + Clight3*intensity3*lightcolor3; } The scene interaction is described in interact.rib and is similar to the previous example, except that there are more interaction variables. Attribute "identifier" "string name" ["balancer"]
Surface "interact.sl" "intensityA" [1] "lightcolorA" [0.15 0.15 0.15] "intensity1" [1] "lightcolor1" [1 0.9 0.7] "intensity2" [1] "lightcolor2" [0.4 0.3 0.6] "intensity3" [1.6] "lightcolor3" [0.6 0.0.3 0.0]
Attribute "identifier" "string name" ["geometry"]
Geometry "image" "filename" [ "ambient.tif:Cambient" "light1.tif:Clight1" "light2.tif:Clight2" "light3.tif:Clight3" ] The Makefile show the rather simplistic way of rendering the light passes. include ../Makeinclude
run: all ${INTERACT} interact.rib
all: ambient.tif light1.tif light2.tif light3.tif
ambient.tif: hb_plastic.${SLO} prepare.rib grep -v '^# ' prepare.rib \ | cpp -DLIGHT=1 -DFILENAME=\"ambient.tif\" \ | ${RENDER}
light1.tif: hb_plastic.${SLO} prepare.rib grep -v '^# ' prepare.rib \ | cpp -DLIGHT=2 -DFILENAME=\"light1.tif\" \ | ${RENDER}
light2.tif: hb_plastic.${SLO} prepare.rib grep -v '^# ' prepare.rib \ | cpp -DLIGHT=3 -DFILENAME=\"light2.tif\" \ | ${RENDER}
light3.tif: hb_plastic.${SLO} prepare.rib grep -v '^# ' prepare.rib \ | cpp -DLIGHT=4 -DFILENAME=\"light3.tif\" \ | ${RENDER}
hb_plastic.${SLO}: hb_plastic.sl ${SHADER} hb_plastic.sl As always typing |