javascriptthree.jsgeometrylight

Three.js - sphere that glows


I have a problem. I want to make a sphere which works like a source of light (sun). I found out that meshPhongMaterial has an option like emissive: color and shininess: intensity but I did not manage to code the sun. Does anyone know how to do it? Thank you for answers!


Solution

  • meshPhong material has parameters 'emissive' and 'shininess' that affect the calculations within material shader, but those won't give you the effect that you want, they are just used for calculating final color.

    You can put spotlight, for example, at the exact position as the sphere, so it would lighten up object around it. However, if you want to achieve the effect of glowing sphere, you would have to write post-processing shader:

    Also, some examples don't use actual post-processing to achieve glowing, but they use trick.

    You render sphere and then render some quad with "glow aura" texture in the back. Visit: http://threegraphs.com/charts/sample/world/ to see how you can maybe simulate glow and create eclipse-like circle around sphere.