FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   Lighting
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Lighting  (Read 645 times)
JohnG

WWW
Lighting
« on: Jun 8th, 2004, 2:27pm »

I've been trying to sort out lighting for a while in some sketches, and I thought it was about time I tried to get a better grip on how it works, but I'm just getting more and more stumped.
 
I've turned off the general ambient light (g.lightR[0]/G[0]/B[0]) and have set g.light*[1] to eb a fullybright white light that moves on a circular path.
 
But as far as I can tell, ths shading on an object does't bear all that much resemblance to what I'd expect.
 
Here's a test applet: http://www.hardcorepawn.com/light_test
The light *should* be "inside" the red sphere, it's movement is the same as that of the light, yet the cube's lighting is, well, poor. There's no really dark parts, and the shading doesn't seem right most of the time...
 
marcello

WWW Email
Re: Lighting
« Reply #1 on: Jun 15th, 2004, 5:07pm »

Hi JohnG,
 
I thought the problem could be the closeness of the light to the box so I tried to replace in your code the distance that you chose equal to 150 with the bigger value 350 just for the source of light (not for the red sphere)
 
Code:

float r;
 
void setup() {
  size(400,400);
  r=0;
  g.lightR[1]=1.0;
  g.lightG[1]=1.0;
  g.lightB[1]=1.0;
  g.lightR[0]=0;
  g.lightG[0]=0;
  g.lightB[0]=0;
  lights();
}
 
void loop() {
  background(0,0,0);
  g.lightX[1]=width/2+(350*sin(r));
  g.lightY[1]=height/2+(350*cos(r));
  g.lightZ[1]=0;
 
  push();
  noStroke();
  fill(255,0,0);
  translate(width/2+(150*sin(r)),height/2+(150*cos(r)),0);
  sphere(10);
  pop();
 
  fill(255,255,255);
  stroke(0);
  push();
  translate(width/2,height/2,0);
  rotateY(PI/4);
  rotateX(PI/4);
  box(100);
  pop();
  r+=0.05;
}

 
 
Actually now the shadows are more pronounced than before, nevertheless the result is still extremely strange. It seems that the light follows a different trajectory with respect of the sphere. Maybe there is some dirty interaction between the coordinate systems of commands g.lightX/Y/Z and push()/pop().
 
Is this a bug? Is there anybody who knows where is the problem?
 
Best Regards,
Marcello
 
« Last Edit: Jun 15th, 2004, 6:13pm by marcello »  
Pages: 1 

« Previous topic | Next topic »