Is it possible to have the reflect of light of facet ball? (Disco ball)

Hello,
I made a program with two balls which returns the light coming from different place thanks to the mouse.
I would like to change these balls into a mirror ball (like in clubs) and have the rays of light returned by the mirror ball.
Thanks for your ideas.

/**
 * Spot. 
 * 
 * Move the mouse the change the position and concentation
 * of a blue spot light. 
 */
 
int concentration = 600; // Try values 1 -> 10000
float move=0.00001;
float x;
void setup() {
  size(640, 360, P3D);
  noStroke();
    colorMode(RGB, 1);
  fill(0.9);
  sphereDetail(60);
}

void draw() {
  background(0); 
 
  
  // Orange light on the upper-right of the sphere
  spotLight(204, 153, 0, 360, 160, 600, 0, 0, -1, PI/2, 600); 
     float s = mouseX / float(width);
  // Light the bottom of the sphere
  s=0;
  directionalLight(s*51+51, 102, 126, 0, -1, 0);
  
  // Moving spotlight that follows the mouse
  spotLight(102, 153, 204,mouseX , mouseY, 600, 0, 0, -1, PI/2, 600); 
  
  
  float d = mouseX / float(width);
    directionalLight(0.8, 0.8, 0.8, d, 0, -1);
     lightSpecular(1, 1, 1);
  translate(width/2, height/2, 0); 
  move+=0.01;
  x= 100*cos(move);
  print (x);
  
  translate(30+x, 200, -500);
  
  sphere(120); 
  spotLight(102, 153, 204, 300, mouseY, 600, 0, 0, -1, PI/2, 600); 
   translate(30+7*x, -200, 0); 
   
  sphere(120); 
}

Unfortunately, it’s actually very difficult. To get an idea in 2D, Dan made some videos about it

If you want to do it in 3D in real time, you need to work a lot on shaders (GLSL). And just to give you a tip, Unity, for example, has built in support for reflection - but it’s not bouncing off the light, and it’s about rendering the mirror surface.

What I would suggest is to play around with Dan’s example - if you are going for photorealism, surely it’s easier with Unity/Blender/etc but I think the fun part of Processing is to do something “wrong” and make fun stuff :slight_smile:

Hello, Could you please avoid repost?

1 Like