====== Light Sources ====== Regarding light sources, GroIMP provides a complete set of possible implementations. They all implement the //Light// and //LightBase// interfaces, which makes them easy to handle and exchange. The standard light sources are: //PointLight//, //SpotLight//, and //DirectionalLight//. The following code places the three light sources next to each other starting with a //PointLight// on the left, a //SpotLight// in the middle, and a //DirectionalLight// on the right. protected void init () [ Axiom ==> [ Translate(0.0,0,0) LightNode.(setLight(new PointLight())) M(-0.6) TextLabel("PointLight")] [ Translate(0.75,0,0) LightNode.(setLight(new SpotLight())) M(-0.1) TextLabel("SpotLight")] [ Translate(1.5,0,0) LightNode.(setLight(new DirectionalLight())) M(-0.1) TextLabel("DirectionalLight")] ; ] In the 3D View, they are visualized as a cone for a //SpotLight//, and as a single line for a //DirectionalLight//. The //PointLight// on the left has no visualization. {{ :tutorials:light-light-node1.png?direct&400 |}} All light sources provide the functionality of visualizing the light rays emitted by them. To do so, the visualization just need to be activated. Additionally, the number of visualized light rays and their length can be set. protected void init () [ Axiom ==> LightNode.(setLight(new PointLight().( setVisualize(true), setNumberofrays(400), setRaylength(0.5) ))); ] The output of the light ray visualization of the three light sources is given below. {{ :tutorials:light-light-node2.png?direct&400 |}} ===== PointLight ===== A //PointLight// is emitting light rays equally to all directions. ===== SpotLight ===== As a specialization of a //PointLight//, the //SpotLight// emits only light rays within a define opening angle. ===== DirectionalLight ===== The //DirectionalLight// emits parallel light rays equally over the whole scene. It adapts its size automatically to the size of the scene. In difference to the //PointLight// and //SpotLight//, the //DirectionalLight// does not has a //setPower// function but instead a //setPowerDensity// function to define the power that should be received by each square meter of the the scene. ===== AreaLight ===== An area light can be created using a parallelogram as base and transforming it to a light source. It will cast a diffuse distribution in the positive direction of the local z-axis of the parallelogram. Note, as for now, it does not (yet) support user defined physical light distribution. module AreaLamp extends Parallelogram() { { setLight(new AreaLight().(setPower(100))); setLength(1); // 1m setAxis(0.5f, 0, 0); } } ===== PhysicalLight ===== tbd ===== Power distribution over several light sources ===== The power of all light sources implemented within GroIMP are given/set in Watt. When the light model is executed, the number of light rays is distributed no equally over all light sources, but rather relative to their power! This has the consequence that when a light source with a high power and one with a very low power are together in a scene, the physical power distribution of the light source with the lower power will be very much underrepresented. As an example, a scene with two light sources with a power of 10W and 90W, and a total number of 10.000 rays, the first light will create 1.000 rays, the second one 9.000 rays. {{ :tutorials:light-light-node3.png?direct&400 |}}