light direction

Brecht's icon

I was looking through the forum and example patches on the subject of lighting.
What I couldn't find though was how to change the direction of the light? It always seems to point at the center of the scene, but what if I'd like to make a grid of lights and point them straight down?

Brecht's icon

silly me. it's of course coming from the light position and shining
in every direction. So then the question would be, can I make a
spotlight?

On 16 Jun 2008, at 16:19, Brecht wrote:

>
> I was looking through the forum and example patches on the subject
> of lighting.
> What I couldn't find though was how to change the direction of the
> light? It always seems to point at the center of the scene, but
> what if I'd like to make a grid of lights and point them straight
> down?

vade's icon

Id suggest using a shader for that. You can get the light position from within the shader, or override it and supply a vec 3 yourself.

If you want a spotlight, you should be able to run :
http://www.lighthouse3d.com/opengl/glsl/index.php?spotlight

:)

pelado's icon

You've found light_position settings in jit.gl.render then, which sets the
light position all objects in your scene. If the last value of the setting
(w) is non zero then the light source is poitional and shines in all
directions with its location set by the x,y and z coordinates. If the w
value is zero, them the light is directional with xyz informing the
direction.
If you want to have more than one light source you need to use the
glcommands of jit.gl.sketch which gives access to the gllight settings. you
can have multiple lights and the commands that specify material colouring,
light position light model etc can be different for each light, with the
light numbers incrementing through gllight0, gllight1 etc. light positions
are affected by transforms you make to the modelview matrix.

You have much more control over lighting using sketch, and yes you can also
have spotlights.

A simple example patch is below, but you should check the red book for more
about lights.

pelado

Max Patch
Copy patch and select New From Clipboard in Max.

On Mon, Jun 16, 2008 at 4:19 PM, Brecht wrote:

>
> I was looking through the forum and example patches on the subject of
> lighting.
> What I couldn't find though was how to change the direction of the light?
> It always seems to point at the center of the scene, but what if I'd like to
> make a grid of lights and point them straight down?
>

pelado's icon

commands that specify material colouring, light position light model etc can
be different for each light, with the light numbers incrementing through
gllight0, gllight1 etc.

Actually, a quick correction to the above. There's only one light model,
you don't set different ones for each light.

pelado

Dg's icon

Hi Pelado,

Would it be possible to get this patcher for the 4.6/1.6.3 version ?
Thank you.

Kyred.