I’m experimenting with light sources to see how their attributes affect the light movement and casting on 3D shapes. I set up a spotLight()
above, pointing straight down, a large flat box()
below, and i increment the spotLight()
X value.
- I expect a circle of light of some size going across the surface of the
box()
. - I’m seeing the top surface of the
box()
lit towards the left whilex = 0.0f
, darkness asx
moves along its axis, and then the top surface of thebox()
lit towards the right whilex = width
. - Also, it gets brighter the further away i make the
y
value, which is extra confusing.
// Spotlight X value to be incremented
float x = 0.0f;
void setup()
{
fullScreen(P3D);
}
void draw()
{
background(0);
// Pull camera way back so i can see the whole area
// eyeX eyeY eyeZ centX centY centZ upX upY upZ
camera( width / 2.0f, -height, height * 2.0f, width / 2.0f, height / 2.0f, 0.0f, 0.0f, 1.0f, 0.0f);
float rgb = 255.0f;
// spotLight Coords
float y = -500.0f; // THE FURTHER AWAY, THE BRIGHTER?!?! 0.0f is darker
float z = 0.0f;
float nX = 0.0f;
float nY = 1.0f; // This should point the spotLight down, no?
float nZ = 0.0f;
float ang = PI / 4.0f; // Angle of cone pointing straight down?
float conc = 2.0f; // Anything above 5 makes the light disappear.
// What does "exponent determining the center bias of the cone " actually mean in terms of what i should see?
// Move spotLight along the x axis
x += 10.0f;
// wrap spotlight
if (x > width)
x = 0.0f;
// spotLight Source position marker to see where the spotLight should be
// pointing straight down from, for my own reference
fill(rgb, rgb, rgb);
pushMatrix();
translate( x, y, z);
circle(0, 0, 100);
rect(0, 0, 25, height);
popMatrix();
// the spotLight that's being a jerk
spotLight( rgb, rgb, rgb, x, y, z, nX, nY, nZ, ang, conc);
// giant flat box to see where the spotLight focuses its light
fill(125, 23, 202);
pushMatrix();
translate( width / 2.0f, (height / 2.0f) + 150.0f, 0.0f);
box(width, 150, height * 2.0f);
popMatrix();
}
I assume i’m misunderstanding something about the spotLight
arguments, most likely the nX, nY, nZ
, cone angle, and concentration values.
Any tips?