Creating negative lights
by Jacob Dankovchik · in Torque 3D Professional · 12/16/2012 (4:42 pm) · 12 replies
So for my current project, there's an effect I want to make and to do the effect, it would involve using "lights" that actually REMOVE light instead of adding it, a sort of black light. Wasn't sure how to do about doing this, so I started checking it out last night.
Turns out it was way, way easier than I could've expected. So I thought I'd include the changes here (this is for advanced lighting, btw):
In advancedLightBinManager.cpp, @ line 325, change
to simply
Yup... Just comment out the exception for brightness.


Even works with shadows! But obviously to an opposite effect. :)

Sunlight too! The sun has a brightness of -1, so it takes a +2 light just to shine through:

Also though this creates some nifty effects. Here's a regular +2 brightness pure red light:

But when shifted to negative light, as you can imagine it now blocks red instead:

But if we make it pass red and block green/blue:

It's all kind of obvious, but it's just fun to play with I guess. Surprising that it's such a simple change that opens up that area, I thought for sure it'd be more involved than that...
Should I even bother making a resource of this? It's so insanely simple, although I wouldn't be surprised of others out there would like to make this effect. Would especially be fun for a fantasy setting, a user of Dark Magic for instance. Instead of bright flares and sparkles, their magic consumes all light.
Turns out it was way, way easier than I could've expected. So I thought I'd include the changes here (this is for advanced lighting, btw):
In advancedLightBinManager.cpp, @ line 325, change
if ( !curLightMat || curLightInfo->getBrightness() <= 0.001f )
to simply
if ( !curLightMat)
Yup... Just comment out the exception for brightness.


Even works with shadows! But obviously to an opposite effect. :)

Sunlight too! The sun has a brightness of -1, so it takes a +2 light just to shine through:

Also though this creates some nifty effects. Here's a regular +2 brightness pure red light:

But when shifted to negative light, as you can imagine it now blocks red instead:

But if we make it pass red and block green/blue:

It's all kind of obvious, but it's just fun to play with I guess. Surprising that it's such a simple change that opens up that area, I thought for sure it'd be more involved than that...
Should I even bother making a resource of this? It's so insanely simple, although I wouldn't be surprised of others out there would like to make this effect. Would especially be fun for a fantasy setting, a user of Dark Magic for instance. Instead of bright flares and sparkles, their magic consumes all light.
#2
Thanks for sharing your exploration.
12/16/2012 (4:50 pm)
That first negative light scares me! This is so awesome!Thanks for sharing your exploration.
#3
The Station mesh, in the tower. The tip is closed off and should be a bit blocked off from ambient light under certain circumstances. However the space is too open for AO to catch it. Depending on how you use the asset, you may want it to be fully dynamic instead of assigning pre-made lighting. In that case...

To

Wouldn't hurt to maybe do it a little lighter than that, but you get the idea. With lights being as cheap as the are in T3D, something like this is great for adding dark spots, black pits, and scary caves.
12/16/2012 (5:13 pm)
And in case anyone is wondering about a practical use for this outside of odd effects:The Station mesh, in the tower. The tip is closed off and should be a bit blocked off from ambient light under certain circumstances. However the space is too open for AO to catch it. Depending on how you use the asset, you may want it to be fully dynamic instead of assigning pre-made lighting. In that case...

To

Wouldn't hurt to maybe do it a little lighter than that, but you get the idea. With lights being as cheap as the are in T3D, something like this is great for adding dark spots, black pits, and scary caves.
#4
12/16/2012 (5:26 pm)
That's a nice little find!
#5
12/17/2012 (1:49 am)
neat :-)
#6
Also another use for this is creating awesome effects (spells etc), since it can block out red and blue, you can make only the red channel of an object shine through (need to test this to find out how that would look!)
12/17/2012 (5:29 am)
Wow cool!Also another use for this is creating awesome effects (spells etc), since it can block out red and blue, you can make only the red channel of an object shine through (need to test this to find out how that would look!)
#7
12/17/2012 (6:47 am)
That's pretty sweet. You're right, there are loads of applications for this in effects and general ambience use.
#8
12/19/2012 (10:05 am)
Nice. Might come in handy. Thanks.
#9
12/20/2012 (4:35 pm)
That is some really cool stuff. :)
#10
03/18/2013 (10:00 pm)
Just decided to pull-request this and see if we can get it added to trunk. However, does this work in Basic Lighting?
#11
03/19/2013 (12:52 am)
Haven't actually tested that. And I think I've already deleted that build of the engine, hahah. I make and delete stuff all the time. I'll maybe rebuild for the negative lighting tomorrow and test it.
#12
EDIT: branch.
03/19/2013 (2:17 am)
Hmm, I think I got it working with another tweak. In lightQuery.cpp:void LightQuery::getLights( LightInfo** outLights, U32 maxLights )
{
...
// Copy them over.
for ( U32 i = 0; i < lightCount; i++ )
{
outLights[i] = mLights[i];
}Doesn't seem to mess stuff up, just means lights don't stop being considered when their score (into which brightness is multiplies) passes below 0.EDIT: branch.
Torque Owner Daniel Buckmaster
T3D Steering Committee