Shining Sphere as spotLight (like the sun)

edited February 2016 in How To...

Hey guys, I'm creating a model of our solar system. Everthing works fine except for the sun. I want the sun to be a spot light so it shines in all direction. But when I do so the sun itself is dark because the spotlight is at the same position as the sun sphere. I've tried all the other types of light sources but nothing is working well. Do you have an idea how to achieve this? I want the sun to emit light or at least be bright without affecting all the other planets.

On the picture you can see what it looks like using a spotlight in the center of the sun.

Hope you can help me. I really didn't find anything on the web. Thanks in advance!

Solar System 3D


  • You've left us nothing to work with. To even start helping you, we'd need to code up a 3D sketch with spheres that move around and work out the lighting settings to even reproduce what you have so far.

    That's a lot of work. And we have to do it before we can even start helping you work on your actual issue.

    So, post your code. Read the sticky thread so you can format it properly too.

  • Answer ✓

    I want the sun to be a spot light so it shines in all direction

    be careful of the terminology here. a spotlight has a colour, position and a direction

    whereas a pointlight has a colour and a position and will shine in all directions

    but i'm not entirely sure that'll help you because all your sun's polygons are facing away from the light origin so will be in the shade. try it.

    maybe a bit of ambientLight()?

    if only we could see some code...

  • hey guys, thanks for the quick response. I don't know if my code would really help you... Of course I mean a pointLight(). I always mix those two in my head :D

    Just to clarify my goal: I have a sphere with a pointLight in it's center and I want the outside surface to be bright. The problem is that the pointLight only hits the inside of the sphere and the outside surface is dark.

    here are some excerpts from my code:

    void setup() {
      fullScreen(P3D, 2);
      //perspective(field-of-view angle, aspect ratio, zNear, zFar);
      perspective(30*2*PI/360, width/height, ((height/2.0) / tan(PI*100.0/360.0))/10, ((height/2.0) / tan(PI*100.0/360.0))*10);
      imgStars = loadImage("Stars.jpg");
      imgSun = loadImage("Sun.jpg");  
    void draw() {  
      float[] positionSun = drawSun(sizeSun, rotationAngleSun);
    void createLights() {
      ambientLight(50, 50, 50);
      pointLight(255, 255, 255, 0, 0, 0);
    float[] drawSun(float size, float rotAngle) {
      float[] position = {0, 0, 0};
      fill(255, 255, 0);
      translate(0, 0, 0);
      textureSphere(size, size, size, imgSun);
      rotationAngleSun = rotAngle + rotationSun;
      return position;

    Hope this will help you guys. Let me know if you need some more code since I left out most of the code for the other planets, controls, camera etc.

    Thanks in advance :)

  • edited February 2016

    Hey guys, I just wanted to let you know that I figured it out. It was as simple as creating an ambientLight with position and lightFallOff so it acts like a pointLight that ignores which direction the surfaces are facing.

    void createLights() {
      pointLight(255, 255, 255, 0, 0, 0); //for the normal behaviour of the sun light
      lightFalloff(0, 0, 0.01); //light falls off right behind the surface of the sun
      ambientLight(255, 255, 255, 0, 0, 0); //ambientLight in the center of the sun

    Thanks anyways for your help :)

  • could you show how you texture the planets please?

Sign In or Register to comment.