Optical Flare color sampled from video layer - sampleImage?

Scripting for After Effects

Optical Flare color sampled from video layer - sampleImage?

Postby shanewalker17 on 11/15/2018, 8:27 am

Per a setup for a way to pre-viz an animated LED light grid in a sculptural ceiling. We're aiming to run video into a processor which translates to DMX controls to animate each LED puck's colors...

Step 1) worked out a nice projection mapping of architectural model using Element 3D (see the OT here: viewtopic.php?f=42&t=129682#p391035 ).

Step 2) suggestion by 'star+circle' poster was to build an array of lights, use them to run Optical Flare layer(s)...then sample the video layer (via the "sampleImage" expression), to change the color of each flare based on a sample of the video layer corresponding to where the light is placed. this seems brilliant in that it truly mimics the end setup. The concept seems dead on. I just need some assistance...expression noob and not sure how to address the "flare color" parameter (see attached).

So, this page seemed a good start on the "sampleImage()" expression - http://www.aenhancers.com/viewtopic.php?t=934 ... but as I said, I don't know how to properly set it up to push the color info to the flare color parameter. And verbiage to properly designate it to take the info from the light position vs the 'colorpicker'...unless its as simple as a layer designation.

Also, might post this same query in the plug-ins Forum in case someone Optical Flares-centric stumbles across it there...so apologies on the double-dip.

Thanks!

flareColorUI.png
Attachments
OpticalFlare_fromLight_Snap.png
CeilingTextureMap_wLightGuides_Snap.png
shanewalker17
 
Posts: 30
Joined: 08/11/2012, 10:13 pm

Re: Optical Flare color sampled from video layer - sampleImage?

Postby shanewalker17 on 11/15/2018, 9:56 am

UPDATE: It works!

So, simple adaptation of the 'AEnhancers' expression, placed directly within the color picker 'Color' value, worked! Replaced 1) the position/sampler layer with the Light (that is used/referenced to create the Optical Flare), and 2) the target layer becomes the animated video layer you wish to color pick from.

The only downside, and perhaps someone has a tip/trick to overcome this...is I'll need to make a Light and a separate OF layer for every single one of the 60+ lights in my scene...so that will take some time. But, from there, its a simple matter of replacing/updating the video layer feed to tweak the lighting animation. I can think of 100+ applications for a setup like this, well beyond my pre-viz for a real lighting setup.

Here is the expression:

target = thisComp.layer("PolarDistort_FullScreenEditTst_TextureReshape_PRE_01");
colorpicker = thisComp.layer("Point Light 1_TestOuterLR");
target.sampleImage(target.fromWorld(colorpicker.position), [0.5,0.5], true, time)

See these screen grabs to see the layer relationships...
Attachments
sampleImage_ExpressionTst1_snap.png
Layers_forExpression_snap.png
OpticalFlare_PosSampleFromLight_ColorFromVidLyr_snap.png
shanewalker17
 
Posts: 30
Joined: 08/11/2012, 10:13 pm

Re: Optical Flare color sampled from video layer - sampleImage?

Postby star+circle on 11/15/2018, 10:01 am

Expression for light color would be something like this, source footage being in the same comp:
Code: Select all
L = thisLayer;
pos2d = L.toComp([0,0]);
T = thisComp.layer("Source footage layer name here");
Tcolor = T.sampleImage([pos2d[0],pos2d[1]], [0.5,0.5], true, time);

I haven't actually tried this but I think it should work.
For intensity you could use one of the color channels. Will need to adjust for correct range. Don't recall if it was 0-1 or 0-255 for the color channels, but that would map to 0-100 for the intensity. So the "suitableMultiplier" here would be either 100/255 or 100 depending on which one it is.
Code: Select all
Tcolor[0]*suitableMultiplier
star+circle
 
Posts: 851
Joined: 12/6/2014, 3:07 pm
Location: Finland

Re: Optical Flare color sampled from video layer - sampleImage?

Postby star+circle on 11/15/2018, 10:02 am

Set Optical Flares to "follow lights" and you will only need one instance of Optical Flares. You'll still need 60 lights, obviously.
star+circle
 
Posts: 851
Joined: 12/6/2014, 3:07 pm
Location: Finland

Re: Optical Flare color sampled from video layer - sampleImage?

Postby shanewalker17 on 11/15/2018, 12:00 pm

I'll investigate your expression alt...but my thought on why there needs to be a separate light and flare is that the expression is looking at a single position to determine color, and applying it to that particular flare.

So..in short, I DON'T want a color applied to all 60+ lights, but particular to each position/sample per light. If there was a color per flare, with each flare given a name, there might be a way to point a light to a specific flare in a single instance of OF, but don't see how that's possible. Is that what your expression for the light color accomplishes? Thx again for your input!
shanewalker17
 
Posts: 30
Joined: 08/11/2012, 10:13 pm

Re: Optical Flare color sampled from video layer - sampleImage?

Postby star+circle on 11/16/2018, 4:44 am

Exactly. It picks the color from the 2D position behind each individual light. So you get the color for every individual light based on where they are in the comp.
star+circle
 
Posts: 851
Joined: 12/6/2014, 3:07 pm
Location: Finland

Re: Optical Flare color sampled from video layer - sampleImage?

Postby shanewalker17 on 11/16/2018, 12:01 pm

Sounds great...I'm still confused a bit about how the light color affects the separate Optical Flares though. Forgive me for being dense. The "light color" you ref...that's the placed point lights. But in OF, you can only bundle them together under track lights and give them the same assigned flare/look. That's why I thought you'd have to have a pairing of light-to-OF layer. How does your expression circumvent that?

Currently, I'm having success w/ the pairing of two layers per light, pulling each into a pre-comp...a bit labor-intensive but rock solid. And since its a pre-comp, I can do a post-effects per light like blur and reshape/repo the cast light shape along the curved architecture. Could do the same with a single layer setup, with some mask trickery, but there is that.

Thx!
shanewalker17
 
Posts: 30
Joined: 08/11/2012, 10:13 pm

Re: Optical Flare color sampled from video layer - sampleImage?

Postby star+circle on 11/17/2018, 2:33 am

In the simplified solution, you can just use the light intensity and have the overlay provide the color. May need to adjust the expression to give a single-value light brightness instead of using light color, which is a three-value array.

But "use the light color" in the OF track light options should work just fine to adjust the color of individual flares for the more complex version.

Here's three colored lights with one instance of Optical Flares.
Attachments
colored flares.jpg
Three colored lights, one instance of Optical Flares
star+circle
 
Posts: 851
Joined: 12/6/2014, 3:07 pm
Location: Finland

Re: Optical Flare color sampled from video layer - sampleImage?

Postby shanewalker17 on 11/27/2018, 12:57 pm

Well, setup worked using your simple sample light color expression. Took me a minute to realize that the script applied to each light...and then I ended up setting up the brightness for each light to sample the resulting 'light color' via pick-whip and 'lightOption.color[0]*100+10' (felt like the intensity was a little low).

Only other change/tweak in approach to yours was using a single OF layer--I grouped each ring with lights named B-to-F and let 5 successive layers of Optical Flares sample those lights. This allows me to blur/affect each ring independently, a good middle-ground as I'm tweaking the simulation of the cast light on the sculpted ceiling panels. The reduction in layers via your method was a great move in efficiency though...ends up there are 106 lights in my ceiling, doing each light as two layers would've been quite the resource hog I think.

Rendering out first test pass now...will take few hours. Fingers crossed! Thanks! (I see this approach/technique being useful for other things btw...hope this helps others on the forum).
Attachments
CeilingOFexpressionRig_PostBlurSnap.jpg
CeilingOFexpressionRig_Snap.jpg
shanewalker17
 
Posts: 30
Joined: 08/11/2012, 10:13 pm


Return to After Effects Expressions