I have created a small representation of the solar system and, at the moment, I have an ambient light and directional light in the scene.
However, I would like to have the light emitting from the “Sun” outwards in all directions. How could I go about achieving this? I have included screenshots of my scene and the code below.
You can use noLight() before drawing the sun to use uniform shading in 3D. I also created a pointLight() at the centre of the sun (changed from directionalLight())
Try making these changes:
float angle = 0;
PImage img;
void setup() {
size(640, 360, P3D);
img = loadImage("space background.jpg");
camera(width/2.0, height/2.0, (height/2.0) / tan(PI*30.0 / 180.0), width/2.0, height/2.0, 0, 0, 1, 0);
smooth(8);
}
void draw() {
background(img);
// set up ambient light
ambientLight(102, 102, 102);
// call noLights() before drawing sun for uniform shading
noLights();
//sun
translate(width/2, height/2, 0); // create system from centre of view
noStroke();
fill(255, 200, 50);
sphere(50);
pointLight(255, 255, 255, 0, 0, 0); // create point light at centre of sun
//earth
pushMatrix();
rotateY(angle/2);
translate(150, 0);
fill(50, 200, 255);
sphere(20);
//moon
pushMatrix();
rotateY(-angle*4);
translate(36, 0);
fill(200);
sphere(5);
popMatrix();
popMatrix();
//mercury
pushMatrix();
rotateY(angle/1.5);
translate(75, 0);
fill(255, 50, 50);
sphere(15);
popMatrix();
//venus
pushMatrix();
rotateY(angle/3);
translate(280, 0);
fill(0, 100, 255);
sphere(10);
popMatrix();
angle += 0.01;
}
You could get tricky and draw a rect() at the centre of the scene instead of the sphere and display a fuzzy circle as a texture on it, then use blendMode(ADD) to draw it in a more realistic way. You can also easily make the scene interactive by simply including the PeasyCam library allowing users to move around and inspect. Just some thoughts – it’s nice