instantiating jit.gl.lights with jit.gl.multiple?

gbravetti's icon

Is it possible to instantiate jit.gl.lights with jit.gl.multiple?

If not, is there some way instantiate lights?

Thanks!

Wesley Smith's icon

A light is instantiated by creating a jit.gl.light object. If you create several jit.gl.light objects, you will have several lights in your scene. jit.gl.multiple works by manipulating an existing object and changing its properties repeatedly to effect different visual results. This works for geometry because you can draw the same shape in many places, but for lights, which are operating ont he scene as a whole, it doesn't make sense. For something like this we would probably need a jit.gl.lightmultiple object that was itself a light controlling several lights.

For an example of multiple lights in action, see the Jitter sneak peak video at around 2:12
https://cycling74.com/articles/max-6-sneak-peek-jitter-opengl/

gbravetti's icon

Hi Wesley,

I'm working on an array of colored objects and I want to attach a light to each single object so it will look like each object is producing light, this array is generated procedurally using jit.gl.multiple, it could change dinamically from one object to dozens, so in need a way to create and control multiple lights dynamically as jit.gl.multiple does.

I understand your point about light as a whole on a standard 3d scenario, anyway is there some way to create multiple lights procedurally?

Any idea that doesn't involves Javascript?

May be there is some way of creating a material so an object can "produce" light affecting it's surrounding?

Thanks for your patience :)

Wesley Smith's icon

With the way lights are currently implemented in Max6, you're going to max out at 8 lights. Also, the more lights, the more performance is going to suffer. 8 lights fullscreen can be slow depending on your graphics card. The only way around this problem is with deferred shading, which is not how Jitter is architected right now.

Instead, I think your best bet is to fake it and figure out some way to give the illusion of light emission. Most games do this with a glow effect. Glow effects are essentially selectively applied blurs.

Wesley Smith's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Here's quick stab making a glow effect that actually works pretty well. I've used jit.gl.node to capture geometry to texture and jit.gl.pix to write the different parts of the glow effect:

gbravetti's icon

Got it! terrific example, thanks a lot!

(By the way, cycling74 should change the header and footer of the compressed code from "max5_patcher" to "max6_patcher ;))

gbravetti's icon
Nick Donovan's icon

It would be cool if Rob Ramirez would post his example patches for the sneak peak jitter OpenGL stuff. had a go at creating the lights patch but of course I cant see what's going on in his p viz-light sub patches!

Scott Fitzgerald's icon

Look at the multi.lights.material.maxpat in examples>jitter-examples>render>lights.material for the example

Nick Donovan's icon

Ah, thanks!

Rob Ramirez's icon

yup, that's the one.
if there are any other patches from that video you'd like to see, let me know and i'll try and dig em up.

Nick Donovan's icon

Awesome, thanks Rob