How do you make glow change with perspective?

I’m looking to make several objects glow with composition nodes. My problem is, the scene is animated, and when the objects move away from the camera, I need the glow effect to shrink appropriately with perspective.

Think of a lightsaber. let’s say the blade is an inch wide, and that the red glow extends an inch past that outwards in both directions. When the lightsaber is held upright, the glow is an inch at all locations, but point the lightsaber at the camera, and perspective increases the visual size of the sabers tip. What I need is a way of making the glow increase with perspective as well.

Any Ideas are welcome; any help is appreciated.

Thank you for your time.

What immediately comes to my mind is the “curves” node, which in its general purpose allows you to map an input to an output using a curve. Z-depth is an indicator of the subject’s distance from the camera. You might also need to add a “math” and/or “normalize” node to scale an output to match the numeric range of the next input. But basically, it’s a mathematical function mapping camera-distance to amount-of-glow. Since you are using a curve, that function does not have to be linear.

If I have mis-read your question, you still should be able to find some factor that you can use as an input, such as the orientation of the saber. This is a good place also to use “node groups,” in which you can “hide” all the mathematical transformations into a thing that you can insert into your node network (“noodle”) as a single node.

Basically, “do the math,” then figure out the best way to express that in terms of nodes. Nodes can do anything, if you try.

I like it. How do I call the objects Z depth? This is done on compositing, right? The only “curves” node there I see are “RGB curve” and “Vector curve”.

This is exactly the type of thing I was looking for, but I’m not sure how to get an object’s Z value (Relative to the camera) as a value that I can plug into other composition nodes. Did I miss something?

UPDATE: I’m aware of the Z map generated by the render layer, but even with a normalize node, I see no way on how to use that data to dictate amount of glow. There’s no “map input” for say, blurs, or glares, and I see no way to plug raw Z value, normalized or not into the effect as a value. Is anyone familiar with how I can do this?

If you have a better Idea, that works too.

Bear in mind that the way glow works is upon the taking lens front element. Thus it’s not the distance that affects glow width rather the amount of angle across the field of view that the object occupies. Things closer appear larger as the occupy more screen space. Anyway if your still convinced to try it just multiply the z depth by the glow source before you generate glow.

Can you show me how? If you have time. I’m a newb. The Z map generated from the render result is a non pixel value, so I don’t understand how to use it. Also, Glows don’t seem to have any form of input for any data to be used as a seed, map or guideline.

We are talking about achieving this with composition nodes, right? Or are we talking code?

I have discarded the Glare node and made one from the blur node using size driven from the Z Depth. And here’s the blend file.

scaled glare.blend (510 KB)

Attachments


Dude, you took the time to make that for a random person online? props, man. Thanks a lot actually. This is gunna save me a lot of time and work. …And actually the setup is really clever…

Thanks for your time man, you seriously made my day!

No problem, I hope that it works for you. And I get to learn stuff as well :wink:

Don’t forget you can get lots of good help at Blender Stack Exchange as well. Gamified tutorials for everyone!