Lighting in YG

YG has nodes for creating point lights, directional lights, and spot lights. They're pretty straightforward, but not exactly intuitive to use. There are two nodes for lighting: the light() node , and the spotlight () node. The light() node is used for both point and directional lights.

Directional Lighting

the simplest way to create a light is just:

light ()

This creates a downward-pointing directional light. Most of the scene will appear very dark; only the tops of objects are illuminated. Using the position message, we can change which direction the light is facing. To recap what the 3 coordinates mean:

position (X Y Z)

X: left / right

Y: forward / backwards

Z: up / down

So you can position the light like this:

light ( position( 1 0 0 )) // pointing to the left
light ( position( -1 0 0 )) // pointing to the right
light ( position( 0 0 1 )) // pointing down (the default)
light ( position( 0 -1 0 )) // pointing forward

The direction is determined by pointing the light from its position towards the origin. Everywhere you move the light, it rotates to face the center; so if you move it to the right, it turns and faces left. If you move if behind you, it rotates to face forwards. You can angle the light by moving it on all axes:

light ( position (1 -1 1))

This light is positioned to the right, behind you, and up; so it points forward, down and to the left.

Remember that the light is Directional, so it has no actual source position. What that means is that these two lines are equivalent:

light (position ( 1 0 0 ))

light (position ( 50 0 0 ))

 


(c) Ben Chang