class DropShadowShader
package funkin.graphics.shaders
extends FlxGraphicsShader › GraphicsShader › Shader
Available on all platforms
A shader that aims to *mostly recreate how Adobe Animate/Flash handles drop shadows, but its main use here is for rim lighting.
Has options for color, angle, distance, and a threshold to not cast the shadow on parts like outlines. Can also be supplied a secondary mask which can then have an alternate threshold, for when sprites have too many conflicting colors for the drop shadow to look right (e.g. the tankmen on GF's speakers).
Also has an Adjust Color shader in here so they can work together when needed.
Constructor
Variables
altMaskImage:BitmapData
The image for the alternate mask. At the moment, it uses the blue channel to specify what is or isnt going to use the alternate threshold. (its kinda sloppy rn i need to make it work a little nicer) TODO: maybe have a sort of "threshold intensity texture" as well? where higher/lower values indicate threshold strength..
angle:Float
The angle of the drop shadow.
for reference, depending on the angle, the affected side will be: 0 = RIGHT 90 = UP 180 = LEFT 270 = DOWN
antialiasAmt:Float
The amount of antialias samples per-pixel, used to smooth out any hard edges the brightness thresholding creates. Defaults to 2, and 0 will remove any smoothing.
attachedSprite:FunkinSprite
The FunkinSprite that the shader should get the frame data from. Needed to keep the drop shadow shader in the correct bounds and rotation.
distance:Float
The distance or size of the drop shadow, in pixels, relative to the texture itself... NOT the camera.
maskThreshold:Float
An alternate brightness threshold for the drop shadow. Anything below this number will NOT be affected by the drop shadow shader, but ONLY when the pixel is within the mask.
threshold:Float
The brightness threshold for the drop shadow. Anything below this number will NOT be affected by the drop shadow shader. A value of 0 effectively means theres no threshold, and vice versa.
Methods
loadAltMask(path:String):Void
Loads an image for the mask. While you could directly set the value of the mask, this function works for both HTML5 and native targets.
Parameters:
path | The path to the image to load |
|---|
onAttachedFrame(name:String, frameNum:Int, frameIndex:Int):Void
Should be called on the animation.callback of the attached sprite. TODO: figure out why the reference to the attachedSprite breaks on web??
Parameters:
name | The name of the animation |
|---|---|
frameNum | The current frame number |
frameIndex | The current frame index |
setAdjustColor(b:Float, h:Float, c:Float, s:Float):Void
Sets all 4 adjust color values.
Parameters:
b | The brightness value |
|---|---|
h | The hue value |
c | The contrast value |
s | The saturation value |
updateFrameInfo(frame:FlxFrame):Void
Updates the frame bounds and angle offset of the sprite for the shader
Parameters:
frame | The frame to retrieve the information from |
|---|