Scene Settings
Picking up from where we left off, we have the following code:
// Set up the scene, make sure we don't loop
void setup() {
size(510, 300, "hipstersinc.P5Sunflow");
noStroke();
noLoop();
}
// Draw our scene
void draw() {
background(255);
setupCamera();
setupScene();
// Adjust perspective
translate(width/2, height/2, 100);
rotateX(QUARTER_PI);
rotateZ(QUARTER_PI);
translate(-width/2, -height/2);
// Draw some boxes
float boxSize = width / 11;
translate(boxSize, boxSize);
for(int i=0; i<3; i++) {
for(int j=0; j<5; j++) {
pushMatrix();
translate(j*boxSize, j*boxSize);
fill(j * 50);
box(boxSize);
popMatrix();
}
translate(boxSize * 2, 0);
}
}
void setupCamera() {
P5Sunflow sunflow = (P5Sunflow) g;
sunflow.camera.setType(SunflowCamera.THINLENS);
}
void setupScene() {
P5Sunflow sunflow = (P5Sunflow) g;
}
Copy/Paste
You'll see we now have the setupScene() method, which grabs the Sunflow object just like in the camera examples.
Anti-Aliasing
Here's what our scene looks like with no anti-aliasing
void setupScene() {
P5Sunflow sunflow = (P5Sunflow) g;
sunflow.scene.setAaMin(0);
sunflow.scene.setAaMax(0);
sunflow.scene.setAaSamples(1);
sunflow.scene.setFilter(null);
}
Copy/Paste
The breakdown is as follows:
setAaMin(int i)
Minimum levels of anti-aliasing. By default, it is set to 0. Sunflow will pick optimal levels of AA for different parts of your image.
setAaMax(int i)
Similar to above, but the maximum amount of anti-aliasing. A good number for high-quality is 2. By default, it is set to 1.
setAaSamples(int i)
Number samples to take for each pixel. This number can vary wildly. By default, it is set to 1. But, as noted in the depth of field example, you will sometimes have to crank this number up pretty high.
setFilter(String filter)
This determines how we are going to combine the samples, and interpolate between pixels. By default, it is set to SunflowScene.GAUSSIAN. Possible values are:
SunflowScene.GAUSSIANSunflowScene.BLACKMAN_HARRISSunflowScene.SINCSunflowScene.TRIANGLESunflowScene.MITCHELLnull
As an aside, I see the Sunflow people using "mitchell" quite a bit, and they know a lot more than I do. I can't, however, explain the different between most of these.
Ray Tracing
setDiffusionDepth(int i)
The maximum number of times a ray will bounce off a diffuse object. By default, it is set to 1.
setReflectionDepth(int i)
The maximum number of times a ray will reflect off a shiny object. By default, it is set to 4.
setRefractionDepth(int i);
The maximum number of times a ray will be refract through a semi-opaque object. By default, it is set to 4.
Global Illumination
setGlobalIllumination(boolean b)
Determines if the scene should be rendered using global illumination. By default, this is true.
setGiEngine(String s)
Which GI engine to use. By default, this is set to igi.
setIgiSamples(int i)
Number of samples per pixel the IGI engine will use. By default, it is set to 64.
setIgiSets(int i)
Number of sets the IGI engine will use. By default, this is set to 1.
setIgiC(float f)
Adjust bright and dark spots. By default, it is set to 0.0003.
setIgiBias(int i)
Sets the bias of the IGI engine. By default, this is set to 0, or "unbias."
