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

**URL:** https://discourse.processing.org/t/is-it-possible-to-have-the-reflect-of-light-of-facet-ball-disco-ball/32532
**Category:** Coding Questions
**Created:** [September 30, 2021, 6:35pm UTC](https://discourse.processing.org/t/is-it-possible-to-have-the-reflect-of-light-of-facet-ball-disco-ball/32532 "2021-09-30T18:35:53Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![bking](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@bking](https://discourse.processing.org/u/bking)
#### Post date: [September 30, 2021, 6:35pm UTC](https://discourse.processing.org/t/is-it-possible-to-have-the-reflect-of-light-of-facet-ball-disco-ball/32532/1 "2021-09-30T18:35:53Z")

</div>

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.

```auto
/**
 * 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); 
}

```

---

<div class="post-metadata">

### Author: ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)
#### Post date: [October 8, 2021, 7:23pm UTC](https://discourse.processing.org/t/is-it-possible-to-have-the-reflect-of-light-of-facet-ball-disco-ball/32532/2 "2021-10-08T19:23:06Z")

</div>

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

[![](https://img.youtube.com/vi/TOEi6T2mtHo/maxresdefault.jpg "Coding Challenge #145: 2D Raycasting") ](https://www.youtube.com/watch?v=TOEi6T2mtHo)

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](https://docs.unity3d.com/Manual/class-ReflectionProbe.html) - but it’s not bouncing off the light, and it’s about rendering the mirror surface.  
[![](https://docs.unity3d.com/uploads/Main/ReflectionProbeScene.jpg) ](https://docs.unity3d.com/uploads/Main/ReflectionProbeScene.jpg)

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 🙂

---

<div class="post-metadata">

### Author: ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)
#### Post date: [October 8, 2021, 8:22pm UTC](https://discourse.processing.org/t/is-it-possible-to-have-the-reflect-of-light-of-facet-ball-disco-ball/32532/3 "2021-10-08T20:22:49Z")

</div>

Hello, Could you please avoid repost?

> [@How to make a mirror ball? like in a nightclub](https://discourse.processing.org/t/how-to-make-a-mirror-ball-like-in-a-nightclub/32667):
>
> Hello everyone, For now in my project, I move spheres like pendulums or metronomes. Now instead of spheres, I would like to have mirror balls. Is it easy to create a mirror ball? Later, I would like to light it with a more or less wide light ray from a place (top left for example) and have the rays reflected by the different mirrors of the mirror ball. If it’s really complicated, I want to pay you for this work, because I have a lot of other things to do in my project. Greetings,
