Colored lighting
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Colored lighting
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?
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?
- Hirogen2
- Posts: 2033
- Joined: Sat Jul 19, 2003 6:15 am
- Operating System Version (Optional): Tumbleweed x64
- Graphics Processor: Intel with Vulkan/Metal Support
- Location: Central Germany
- Contact:
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:
For underwater only, place the AARRGGBB (or a colormap name) on the lower texture on the 209:TransferHeights() line in the control sector.
http://forum.zdoom.org/viewtopic.php?t= ... staticinitGraf 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)
For underwater only, place the AARRGGBB (or a colormap name) on the lower texture on the 209:TransferHeights() line in the control sector.
- The Ultimate DooMer
- Posts: 2109
- Joined: Tue Jul 15, 2003 5:29 pm
- Location: Industrial Zone
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49252
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
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:http://forum.zdoom.org/viewtopic.php?t= ... staticinitGraf 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)
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.
- Kappes Buur
-
- Posts: 4197
- Joined: Thu Jul 17, 2003 12:19 am
- Graphics Processor: nVidia (Legacy GZDoom)
- Location: British Columbia, Canada
- Contact:
.
.
Do you happen to have an example pwad for this? Or could someone whip one up, please?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.
What does that mean, in layman's terms?Graf Zahl wrote:...
Setting a blending value means: Display=Pixel*(1-BlendAlpha)+Blend*BlendAlpha.
...
.
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...Kappes Buur wrote:.Do you happen to have an example pwad for this? Or could someone whip one up, please?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.
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:What does that mean, in layman's terms?Graf Zahl wrote:...
Setting a blending value means: Display=Pixel*(1-BlendAlpha)+Blend*BlendAlpha.
...
.
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.
- Hirogen2
- Posts: 2033
- Joined: Sat Jul 19, 2003 6:15 am
- Operating System Version (Optional): Tumbleweed x64
- Graphics Processor: Intel with Vulkan/Metal Support
- Location: Central Germany
- Contact:
Blend grenades, a reactor is exploding... there is lots of stuff one can make with a white sectorHotWax 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...

- Ty Halderman
- ... in rememberance ...
- Posts: 282
- Joined: Thu Jul 17, 2003 9:53 pm
- Location: New Orleans LA
- Contact: