add lightmaps

This commit is contained in:
shr 2023-10-02 21:05:13 +09:00 committed by Cameron Taylor
parent bc20b81723
commit dc8dfeb336
5 changed files with 48 additions and 2 deletions

View file

@ -1,5 +1,6 @@
package funkin.graphics.framebuffer;
import flixel.FlxSprite;
import flixel.FlxCamera;
import flixel.util.FlxColor;
import openfl.Lib;
@ -118,4 +119,14 @@ class FrameBuffer
{
spriteCopies.push(spriteCopy);
}
/**
* Adds the sprite to the frame buffer. The sprite will only be seen from
* the frame buffer.
* @param sprite the sprite
*/
public function moveSprite(sprite:FlxSprite):Void
{
sprite.cameras = [camera];
}
}

View file

@ -51,11 +51,21 @@ class FrameBufferManager
* @param color if this is not `null`, the sprite will be filled with the color.
* if this is `null`, the sprite will keep its original color.
*/
public function addSpriteCopyTo(name:String, sprite:FlxSprite, color:Null<FlxColor> = null):Void
public function copySpriteTo(name:String, sprite:FlxSprite, color:Null<FlxColor> = null):Void
{
frameBufferMap[name].addSpriteCopy(new SpriteCopy(sprite, color));
}
/**
* Adds the sprite to the frame buffer. The sprite will only be seen from the frame buffer.
* @param name the name of the frame buffer
* @param sprite the sprite
*/
public function moveSpriteTo(name:String, sprite:FlxSprite):Void
{
frameBufferMap[name].moveSprite(sprite);
}
/**
* Call this before drawing anything.
*/

View file

@ -10,7 +10,7 @@ import flixel.util.FlxColor;
class SpriteCopy
{
final sprite:FlxSprite;
var color:Null<FlxColor>;
final color:Null<FlxColor>;
public function new(sprite:FlxSprite, color:Null<FlxColor>)
{

View file

@ -86,6 +86,14 @@ class RuntimeRainShader extends RuntimePostEffectShader
return mask = value;
}
public var lightMap(default, set):BitmapData;
function set_lightMap(value:BitmapData):BitmapData
{
this.setBitmapData('uLightMap', value);
return lightMap = value;
}
public var numLights(default, set):Int = 0;
function set_numLights(value:Int):Int

View file

@ -1,5 +1,6 @@
package funkin.play.stage;
import openfl.display.BlendMode;
import funkin.graphics.framebuffer.FrameBufferManager;
import flixel.util.FlxColor;
import funkin.graphics.framebuffer.SpriteCopy;
@ -800,6 +801,22 @@ class Stage extends FlxSpriteGroup implements IPlayStateScriptedClass
}
}
/**
* FIXME: Polymod hack
*/
function stringEndsWith(a:String, b:String):Bool
{
return a.endsWith(b);
}
/**
* FIXME: Polymod hack
*/
function setBlendAdd(sprite:FlxSprite, blend:BlendMode):Void
{
sprite.blend = blend;
}
public function onScriptEvent(event:ScriptEvent) {}
public function onPause(event:PauseScriptEvent) {}