How to apply a shader on cameras (i.e. camHUD
) in Hscript?
#3994
-
Doing either // imports
class VignettePlayState extends Module {
var vignetteShader:FlxRuntimeShader;
override function onSongLoaded(e) {
super.onSongLoaded(e);
vignetteShader = ScriptedFlxRuntimeShader.init('VignetteShader');
if (PlayState.instance != null) {
PlayState.instance.camHUD.shader = vignetteShader;
vignetteShader.setIntensity(1.0);
vignetteShader.setReach(1.0);
}
}
override function onUpdate(elapsed:Float) {
super.onUpdate(elapsed);
var shaderInput:Float = elapsed * 2;
if (vignetteShader != null) vignetteShader.scriptCall('update', [shaderInput]);
}
} The shader haxe code if it's necessary // imports
class VignetteShader extends FlxRuntimeShader
{
public var intensity:Float = 0.0;
public var reach:Float = 0.0;
public function new()
{
var fragText:String = Assets.getText(Paths.frag('vignette'));
super(fragText);
}
public function setIntensity(value:Float):Void {
this.intensity = value;
this.setFloat('uIntensity', this.intensity);
}
public function setReach(value:Float):Void {
this.reach = value;
this.setFloat('uReach', this.reach);
}
public function update(elapsed:Float):Void
{
setIntensity(this.intensity + elapsed);
setReach(this.reach + elapsed);
}
public function reset()
{
setIntensity(0.0);
setReach(0.0);
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
KadePleaseHelpMe
Jan 14, 2025
Replies: 1 comment 8 replies
-
Don't believe this is possible in base flixel. I know that Codename Engine uses a custom version of Flixel which allows for camera shaders, but again that's their own custom version of flixel. |
Beta Was this translation helpful? Give feedback.
8 replies
Answer selected by
MAZ12211
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Don't believe this is possible in base flixel. I know that Codename Engine uses a custom version of Flixel which allows for camera shaders, but again that's their own custom version of flixel.