User:Digiku/2.2/Fade features

From SRB2 Wiki
Jump to navigation Jump to search

FOF, PolyObject, and Colormap fading!

  • 420 Light Fade: Added ability to specify fade duration in tics, rather than speed increment
  • 447 Change Colormap: Instantly set a target sector's colormap, including relative adding of the current color
  • 452 Change FOF Translucency: Instantly set a target FOF's alpha value
  • 453 Fade FOF Translucency: Fade FOF's alpha along with collision and lighting
  • 454 Stop Fading FOF
  • 455 Fade Colormap: Fade target sector's colormap, including relative adding of the current color
  • 456 Stop Fading Colormap
  • 492 Fade PolyObject: Fade PolyObject's alpha along with collision

YouTube

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 logic
  • ML_TFERLINE - Use exact light values for OpenGL. Else by default, lighting is snapped to the 32 Software levels. removed, no reason to have this
  • ML_DONTPEGBOTTOM - Use alternate inputs. Else by default, use the old sector brightness and line length inputs.
    • Front X Offset: Brightness level to fade to
    • Front Y Offset: x/tic speed, or if ML_EFFECT4, then duration in tics.

Example

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 R
    • ML_NOCLIMB: Subtract G
    • ML_EFFECT2: Subtract B
  • ML_DONTPEGBOTTOM: Specify base alpha by Front X Offset and fade/dark alpha by Front 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 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 tag
  • Front Y offset: FOF control sector tag
  • Back X offset: Alpha target, 1-256
    • ML_EFFECT3: Alpha target is relative to current FOF alpha. Negative value subtracts.
  • ML_NOCLIMB: Do not handle FF_TRANSLUCENT and appropriate culling flags like FF_CUTLEVEL

Type 453: Fade FOF

  • Front X offset: FOF target sector tag
  • Front Y offset: FOF control sector tag
  • Back X offset: Alpha target, 1-256
    • ML_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 Offset refers to tic duration)
  • ML_BLOCKMONSTERS: Do not handle FF_EXISTS
  • ML_NOCLIMB: Do not handle FF_TRANSLUCENT and appropriate culling flags like FF_CUTLEVEL
  • ML_BOUNCY: Do not handle collision flags like FF_SOLID or FF_SWIMMABLE
  • ML_EFFECT1: No collision during fading ("ghost fade")
  • ML_EFFECT2: Do not handle lighting or colormaps
  • ML_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, force FF_EXISTS. Else, remove the flag.
  • Handle FF_TRANSLUCENT: If alpha < 256, force FF_TRANSLUCENT. Else, remove the flag and make opaque.
  • Handle collision flags: During the fade routine, set such flags as FF_SOLID and FF_SWIMMABLE if 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.

Example

  • File:Test fadefof.wad - MAP01 thru MAP10. Test fading FOFs into existence and out of existence for every type of FOF.

Type 454: Stop Fading FOF

  • Front X offset: FOF target sector tag
  • Front Y offset: FOF control sector tag
  • ML_BLOCKMONSTERS: Do not finalize fading collision flags; default is to do so.

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 R
    • ML_NOCLIMB: Subtract G
    • ML_EFFECT2: Subtract B
  • ML_DONTPEGBOTTOM: Specify base alpha by Front X Offset and fade/dark alpha by Front 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 start fading
  • ML_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 Offset or Back Y Offset: Fade speed increment, out of 256 (unless ML_DONTPEGBOTTOM is set, then this must be Back Y Offset)
    • ML_EFFECT4: Specify fade duration in tics instead.

Example

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 Offset OR Front Floor Height: 1000-based alpha value to fade to, like Type 491
    • ML_DONTPEGBOTTOM: Specify raw translucency value instead
    • ML_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 flags
  • ML_EFFECT1: No collision during fading ("ghost fade")

Example

491: Set PolyObject Translucency Spec

  • Front X Offset OR Front Floor Height: 1000-based alpha value to fade to, like Type 491
    • ML_DONTPEGBOTTOM: Specify raw translucency value instead
    • ML_EFFECT3: Calculate relative to current PolyObject alpha