Page 1 of 1

Colored lighting

Posted: Wed Oct 15, 2003 2:33 pm
by Anonymous
Two quick questions (maybe not with quick answers.)

1) How do I put colored lighting in a sector?

2) Is it possible to make the colored lighting under a fake floor different than the lighting above it? Basically, could I make swimmable water that tints the screen blue when the character goes underwater, but doesn't tint the screen blue when the character's eyes are above water?

Posted: Wed Oct 15, 2003 2:56 pm
by Hirogen2
For general coloring, i.e. in the real sector and in any fake floors, the ACS function Set_SectorColor() can be used, as well as the 190:Static_Init() linedef special:
Graf Zahl wrote: 190(tag, 1, -, -, -)
Sets light or fog colour in a sector. Place a hex number on the upper sidedef of the line to represent the colour of the lighting required (RRGGBB). FF0000 (as used in the example) is red. Place a hex number on the lower sidedef of the line to represent the colour of the fog you want (AARRGGBB - where AA =
alpha or "fogginess"). 80FF0000 (as used in the example) is a foggy red. (334 in Doom style maps)
http://forum.zdoom.org/viewtopic.php?t= ... staticinit

For underwater only, place the AARRGGBB (or a colormap name) on the lower texture on the 209:TransferHeights() line in the control sector.

Posted: Wed Oct 15, 2003 4:33 pm
by The Ultimate DooMer
I think a tutorial is in order, as it can be quite complex to get the hang of.

Posted: Wed Oct 15, 2003 9:15 pm
by HotWax
You can also color the control sector for the TransferHeights special to set the color while underwater. In fact, you can add fog and other effects (like sector-based damage) and they will copy over too.

Posted: Thu Oct 16, 2003 1:44 am
by Graf Zahl
Hirogen2 wrote:For general coloring, i.e. in the real sector and in any fake floors, the ACS function Set_SectorColor() can be used, as well as the 190:Static_Init() linedef special:
Graf Zahl wrote: 190(tag, 1, -, -, -)
Sets light or fog colour in a sector. Place a hex number on the upper sidedef of the line to represent the colour of the lighting required (RRGGBB). FF0000 (as used in the example) is red. Place a hex number on the lower sidedef of the line to represent the colour of the fog you want (AARRGGBB - where AA =
alpha or "fogginess"). 80FF0000 (as used in the example) is a foggy red. (334 in Doom style maps)
http://forum.zdoom.org/viewtopic.php?t= ... staticinit

For underwater only, place the AARRGGBB (or a colormap name) on the lower texture on the 209:TransferHeights() line in the control sector.

This won't set the color of the sector but a blending value for the player's view. This is something completely different:

Setting a color means: Display=Pixel*Color
Setting a blending value means: Display=Pixel*(1-BlendAlpha)+Blend*BlendAlpha.


You can even combine both of those in the same sector.

Posted: Thu Oct 16, 2003 7:18 am
by Kappes Buur
.
HotWax wrote:You can also color the control sector for the TransferHeights special to set the color while underwater. In fact, you can add fog and other effects (like sector-based damage) and they will copy over too.
Do you happen to have an example pwad for this? Or could someone whip one up, please?
Graf Zahl wrote:...
Setting a blending value means: Display=Pixel*(1-BlendAlpha)+Blend*BlendAlpha.
...
What does that mean, in layman's terms?
.

Posted: Thu Oct 16, 2003 11:40 am
by HotWax
Kappes Buur wrote:.
HotWax wrote:You can also color the control sector for the TransferHeights special to set the color while underwater. In fact, you can add fog and other effects (like sector-based damage) and they will copy over too.
Do you happen to have an example pwad for this? Or could someone whip one up, please?
Not offhand, no... But it should be pretty easy to make one. Just make two sectors, transfer heights to one of them, and set different fog/light values in each and it should work. I'm fairly sure there have been levels that use such effects...
Graf Zahl wrote:...
Setting a blending value means: Display=Pixel*(1-BlendAlpha)+Blend*BlendAlpha.
...
What does that mean, in layman's terms?
.
AFAIK (Correct me if I'm wrong, Graf), Pixel*Color means to use the set sector color (Color) as a mask for each Pixel in the sector. i.e:

Original color: 80 00 FF
Sector color: 40 FF C0 (which becomes 0.25 1.0 0.75 when normalized)
New color: 20 00 C0

(0x80 * 0.25 = 0x20, 0x00 * 1 = 0x00, 0xFF * 0.75 = 0xC0)

So the sector color controls how much of each original color remains without adding any. Blue (00 00 FF) in a purple sector (FF 00 FF) remains blue, because it fits entirely within the mask. Blue in a RED sector (FF 00 00) becomes black, not purple as you might expect; We're not mixing colors, we're masking them. Because the blue gets eradicated completely, there's nothing left and the resulting color is (00 00 00) which is pure black.

On the other hand, the blend, which looks unnecessarily complex...

Display=Pixel*(1-BlendAlpha)+Blend*BlendAlpha

Let's look at this one piece at a time. Pixel = The original color of the non-blended pixel, whether it comes from the floor, ceiling, a wall texture, or a sprite. The BlendAlpha is the AA amount set using the RRGGBBAA method, normalized to a range of 0.0-1.0. The Blend is the color specified in the RRGGBB part of that equation.

Now, if you break the equation down, you'll notice it is made up of two of what we just did. Namely:

Pixel*Something
Blend*Something

So just as before, the "Something" (in this case, BlendAlpha and its inverse) mask the color it is multiplying. The difference is that because we're using the inverse of BlendAlpha and adding it to the original, the result will always give us a full color. (1-BlendAlpha+BlendAlpha = 1) By taking 1-BlendAlpha, we get how much color we're NOT givinig to the Blend, and we put that much of the original color in. We then use Blend*BlendAlpha to determine how much blend color to put in, and then add the two colors together.

Okay, that probably sounded confusing. Maybe some examples will help:

Pixel=00 00 FF (Blue)
Blend=FF 00 00 (Red)
Alpha = 0.5

In this case, the inverse and the Alpha are both 0.5 (1 - 0.5 = 0.5), which means we're mixing equal parts source color and blend color. Multiplying the source by 0.5 we get (00 00 80). Multiplying the blend by 0.5 we get (80 00 00). When we add them together, the result is (80 00 80). Hey look! Purple! Now, if you wanted a weaker red light that wouldn't mix colors so evenly, all you'd do is reduce the alpha, like so:

Pixel = 00 00 FF (Blue)
Blend = FF 00 00 (Red)
Alpha = 0.25

The result in this case would be:

00 00 FF * (1 - 0.25 = 0.75) = 00 00 C0, plus:
FF 00 FF * (0.25) = 40 00 00
= 40 00 C0

Still purple, but now the blue is much stronger because not as much red is mixed in.

If you set the alpha value to one extreme or the other, you'll be saying not to blend any of one color or the other in. For example:

Pixel = 8C 9F 10
Blend = FF FF FF
Alpha = 1.0

Full alpha means that we mix in the full Blend color, which is white in this case, and don't use any of the original color. (Pixel * (1 - 1) = 0) The result is that everything in the sector will be pure white. Not particularly useful perhaps...

The opposite would be an alpha of 0, which would be just as if the sector didn't have a blend. It would use 100% of the source color and none of the blend color when rendering the pixel.

Posted: Thu Oct 16, 2003 1:00 pm
by Anonymous
Thanks for the assistance. Now the players of my levels will know when they're underwater besides the weightlessness, having a water ceiling, and the eventually choking to death. :)

Posted: Thu Oct 16, 2003 1:47 pm
by Hirogen2
HotWax wrote:Full alpha means that we mix in the full Blend color, which is white in this case, and don't use any of the original color. (Pixel * (1 - 1) = 0) The result is that everything in the sector will be pure white. Not particularly useful perhaps...
Blend grenades, a reactor is exploding... there is lots of stuff one can make with a white sector ;)

Posted: Thu Oct 16, 2003 1:56 pm
by GameArena
Dying perhaps :P

Posted: Thu Oct 16, 2003 11:45 pm
by Ty Halderman
Go toward the (Blend=FFFFFF; Alpha 1.0), Carol Anne!