Skip to content

Hack that fixes software drop shadow crashes (Fixes #159)

Hannu Hanhi requested to merge Hannu_Hanhi/SRB2:sw-dropshadow-patch into next

Uses a special column drawing function for drop shadows that bypasses invalid memory access crashes caused by R_ProjectDropShadow putting wrong values in dc_texturemid and dc_iscale when the shadow is sloped.

Ideally this issue would be fixed by correcting the calculation of dc_texturemid and dc_iscale for sloped drop shadows, but this hack will at least stop the crashing.

The incorrectly set variables cause the column drawing functions to read outside the column and the image, resulting in garbage pixels. However these pixels are very hard to see because the shadows use the darkest light level in the lighting colormap. If the colormap is removed, it will reveal the garbage pixels, like this:

srb20022

srb20027

The column drawer included in this MR should look exactly the same as before in vanilla gameplay. (except without very dim corrupted pixels) However it will effectively turn all opaque pixels in DSHADOW black, instead of reading the actual color from the texture. Though this makes no visible difference currently, since the code already uses the darkest light level and the DSHADOW image is just a black filled circle. (So if support for replacing DSHADOW with a colorful image is wanted, that will require completely fixed code. Also the current broken code would draw them corrupted and distorted anyway.)

Merge request reports