Fade FOF Test - mazmazz/SRB2 GitHub Wiki
This demo contains the following branches:
- public-lightfade-ticbased - Add tic duration timing to LD 420 Fade Lighting
- public-colormap-overhaul - Colormap rewrite to support new features
- public-colormap-overhaul-change-ldef - LD 447 Change Colormap by MonsterIestyn with adding colormaps together
- public-colormap-fade - Fade colormaps
- public-le-fadefof - Fade FOF translucency
- public-polyobj-fade - Fade PolyObject translucency
- public-fof-fix-movingplat - Fix bug that snaps player Z when disappearing moving platform
YouTube
Download Demo
- 9/20/2018: SRB2-Public-FadeFOF-Sept2018b
Linedef Exec 420: Fade Lighting add duration timing
Type 420 Fade Lighting took an input x/tic to change the lightlevel x times per tic.
I added the ability to specify how long the fade should last in tics. Per frame:
- I take the (percentage of duration that elapsed)
- I apply that percent to (endlightlevel - startlightlevel)
- Then I add that to the startlightlevel.
I added these flags to the special:
ML_EFFECT4- Enable tic-based logicremoved, no reason to have thisML_TFERLINE- Use exact light values for OpenGL. Else by default, lighting is snapped to the 32 Software levels.ML_DONTPEGBOTTOM- Use alternate inputs. Else by default, use the old sector brightness and line length inputs.Front X Offset: Brightness level to fade toFront Y Offset: x/tic speed, or ifML_EFFECT4, then duration in tics.
Colormap code overhaul
To support fading colormap features, I overhauled the colormap generation code to support an arbitrary # of extracolormap_ts and some other stuff for ease of use.
Based on MonsterIestyn's code cleanup.
Changes
The core changes are:
- Clean up
extracolormap_tto have only metadata variables like RGBA, fadestart, fadeend, and fog; and the lighttable itself. - Remove the
MAXCOLORMAPSlimit andextra_colormaps[]table and replace with a next/prev struct chain - New property
side_t->colormap_datafor storage during setup.sector_t->extra_colormapis for rendered colormaps only.- This means multiple colormap lines can take the same control sector without conflicting. Also, colormap changes work for tag 65535
- Split
R_CreateColormap()intoR_CreateLightTable(), so that any code can create an arbitraryextracolormap_tand generate a colormap table for it - Smarter colormap string parsing, so that a map author can specify just alpha (
#A) or just red (#RR) or just red and green (#RRGG) or nothing at all. Unspecified values have defaults. - Utility functions, such as:
- Checking colormap equality
- Checking if colormap is equivalent to default (no colormap)
- Adding two colormaps together.
- #ifdef'd out colormap lump code because it's unused anywhere else; but it's updated to fit the new code.
Other areas updated:
- Netsync support for colormaps: compare sector's current colormap to its spawn colormap
- Make sector
lightlist_tauto-update to colormap changes like it does to lightlevel, for FOFs.- This is done by storing a reference to a sector's
extra_colormap(which is itself a pointer). The renderer code is updated for this as well.
- This is done by storing a reference to a sector's
Linedef Exec 447: Change Colormap relative value calc
This rebases Linedef Exec 447 Change Colormap on !189 Colormap code overhaul and adds the following features:
ML_EFFECT3: Calculate change relative to the target sector's current colormap (i.e., this line's RGBA values are added onto the current colormap's RGBA values)ML_EFFECT1: Subtract RML_NOCLIMB: Subtract GML_EFFECT2: Subtract B
ML_DONTPEGBOTTOM: Specify base alpha byFront X Offsetand fade/dark alpha byFront Y Offset. Set negatives here to subtract alpha if `ML_EFFECT3 is set.ML_TFERLINE: Use the back sidedef's colormap instead of the target sector's current colormap to calculate relative change
Linedef Exec 455 Fade Colormap, 456 Stop Fading Colormap
Fade colors!

455 Fade Colormap Spec
ML_EFFECT3: Calculate change relative to the target sector's current colormap (i.e., this line's RGBA values are added onto the current colormap's RGBA values)ML_EFFECT1: Subtract RML_NOCLIMB: Subtract GML_EFFECT2: Subtract B
ML_DONTPEGBOTTOM: Specify base alpha byFront X Offsetand fade/dark alpha byFront Y Offset. Set negatives here to subtract alpha ifML_EFFECT3is set.ML_TFERLINE: Use the back sidedef's colormap instead of the target sector's current colormap to start fadingML_BOUNCY: Disable behavior where fading from no colormap overrides the target sector's RGB colormap value (because by default, it's #000000, so the behavior is to initialize that to the destination colormap's RGB value but not the alpha)Front Y OffsetorBack Y Offset: Fade speed increment, out of 256 (unlessML_DONTPEGBOTTOMis set, then this must beBack Y Offset)ML_EFFECT4: Specify fade duration in tics instead.
456 Stop Fading Colormap Spec
- Nothing! (Tagged sector stops the fade thinker)
Linedef Exec 492: Fade PolyObject
Add translucency fading for PolyObjects.
No Stop Fade special this time, because the other specials also do not have a stop mechanism.
Other tasks I performed:
- I fixed Linedef Exec 490 Set PolyObject Visible to set the correct render flags according to spawnflags.
- I added a couple flags for Linedef Exec 491 Set PolyObject Translucency
492: Fade PolyObject Spec
Front X OffsetORFront Floor Height: 1000-based alpha value to fade to, like Type 491ML_DONTPEGBOTTOM: Specify raw translucency value insteadML_EFFECT3: Calculate relative to current PolyObject alpha
Front Y Offset: x/tic increment speed, out of 256.ML_EFFECT4: Specify tic-based duration instead
ML_BOUNCY: Do not handle collision flagsML_EFFECT1: No collision during fading ("ghost fade")
491: Set PolyObject Translucency Spec
Front X OffsetORFront Floor Height: 1000-based alpha value to fade to, like Type 491ML_DONTPEGBOTTOM: Specify raw translucency value insteadML_EFFECT3: Calculate relative to current PolyObject alpha
Linedef Exec Action: Fade FOF
Introduces Linedef Exec Action 452 Set FOF Translucency, 453 Fade FOF, 454 Stop Fade FOF.
By default, this affects the alpha level; and, as appropriate, toggles FF_EXISTS, FF_TRANSLUCENT, and collision flags like FF_SOLID. Toggles exist to disable these behaviors.

Type 452: Set FOF Translucency
Front X offset: FOF target sector tagFront Y offset: FOF control sector tagBack X offset: Alpha target, 1-256ML_EFFECT3: Alpha target is relative to current FOF alpha. Negative value subtracts.
ML_NOCLIMB: Do not handleFF_TRANSLUCENTand appropriate culling flags likeFF_CUTLEVEL
Type 453: Fade FOF
Front X offset: FOF target sector tagFront Y offset: FOF control sector tagBack X offset: Alpha target, 1-256ML_EFFECT3: Alpha target is relative to current FOF alpha. Negative value subtracts.
Back Y offset: Speed, x/tic, 1+. If 0, then set immediately without fade.ML_EFFECT4: Timing is tic-based (Back Y Offsetrefers to tic duration)
ML_BLOCKMONSTERS: Do not handleFF_EXISTSML_NOCLIMB: Do not handleFF_TRANSLUCENTand appropriate culling flags likeFF_CUTLEVELML_BOUNCY: Do not handle collision flags likeFF_SOLIDorFF_SWIMMABLEML_EFFECT1: No collision during fading ("ghost fade")ML_EFFECT2: Do not handle lighting or colormapsML_TFERLINE: Use exact alpha values in OpenGL instead of the 9 alpha levels from Software
Default behavior is to:
- Handle
FF_EXISTS: If alpha > 0, forceFF_EXISTS. Else, remove the flag. - Handle
FF_TRANSLUCENT: If alpha < 256, forceFF_TRANSLUCENT. Else, remove the flag and make opaque. - Handle collision flags: During the fade routine, set such flags as
FF_SOLIDandFF_SWIMMABLEif they were set on spawn. They are unset when reaching the destvalue on a fade out. - Handle lighting and colormap: They fade out along with the FOF.
- Collision is always set during the fade routine. But, if ghost fade is enabled (
ML_EFFECT1), collision is turned off during the fade routine. If fading in, it is turned on at end of fade. If fading out, it remains off.
Type 454: Stop Fading FOF
Front X offset: FOF target sector tagFront Y offset: FOF control sector tagML_BLOCKMONSTERS: Do not finalize fading collision flags; default is to do so.
Moving platform fix: Player snaps to floor when setting ~FF_EXISTS
When setting ~FF_EXISTS on a moving platform while player stands on it, player immediately snaps to the floor below.
Fixing this required snagging a reference to the FOF that tmfloorz refers to -- that's the hard part. Once the reference is collected, just check it for FF_EXISTS before adjusting player's Z in P_ThingHeightClip.
Works in reverse gravity. Intangibles (water, goop, quicksand) are not affected by this bug.
Before:

After:
