We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm trying to wrap my head around lights and materials for a blog post that I am doing, and I can't seem to figure out what exactly is going on when I use fill()
in P3D
mode.
void setup(){
size(800,800,P3D);
smooth(8);
}
void draw(){
noStroke();
background(0);
ambientLight(128, 128, 128);
lightSpecular(128,128,128);
directionalLight(128,128,128, 0, 1, -1);
pushMatrix();
translate(width * 0.5, height * 0.5, 0);
ambient(128,128,128);
specular(255,255,0); // yellow specular light
shininess(10.0);
sphere(width * 0.2);
popMatrix();
}
produces...
If I replace the call to ambient(128,128,128);
with fill(128,128,128);
I get this:
Calling fill
seems to nullify other settings like shininess
. What exactly is going on in P3D
mode when I am calling fill
? Thanks!
Answers
I may not have a complete answer for you but in your case one of the things 'fill(128,128,128)' does is change the polygon fill color. In your example, with no lights enabled, adding the fill command would change your completely white sphere into a gray sphere. Fill will affect how light reacts with your surface as well.
Yes, fill changes the color of the polygons drawn, but it also seems to override specular and shininess settings. Using fill seems to instantiate a completely different shader?
It looks to me like there isn't a switch on/off, whatever is going on. Add this code to line #24 to get a nice gradual fade between fill(255-0)
fill(255*(sin(millis()/500.f)+1)/2);
At fill(255) the output looks exactly like your top screenshot.