Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Shader Metadata Handling and Improve Readability. #442

Merged
merged 8 commits into from
Sep 3, 2024

Conversation

MAJigsaw77
Copy link
Contributor

  • Added FlxRuntimeShaderMacro to dynamically retrieve shader metadata values, removing the need to manually copy strings from the original classes.
  • Implemented a toString function in FlxRuntimeShader for easier debugging.
  • Renamed several elements within FlxRuntimeShader methods for improved clarity and readability.

@Geokureli
Copy link
Member

@EliteMasterEric can you take a look at this?

Copy link

@EliteMasterEric EliteMasterEric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good with this PR except for the one issue I mentioned.

flixel/addons/display/FlxRuntimeShader.hx Outdated Show resolved Hide resolved
@Geokureli
Copy link
Member

Thanks!

@Geokureli Geokureli merged commit 8649eb6 into HaxeFlixel:dev Sep 3, 2024
10 checks passed
@Geokureli
Copy link
Member

Oh hey, @MAJigsaw77 can I get a basic example of what a simple FlxRuntimeShader extending class will look like, after this change?

@MAJigsaw77 MAJigsaw77 deleted the runtime-shader-fixes branch September 3, 2024 16:40
@MAJigsaw77
Copy link
Contributor Author

Oh hey, @MAJigsaw77 can I get a basic example of what a simple FlxRuntimeShader extending class will look like, after this change?

package;

import flixel.addons.display.FlxRuntimeShader;

class Chrome extends FlxRuntimeShader
{
	@:glFragmentSource('
		#pragma header

		uniform float rOffset;
		uniform float gOffset;
		uniform float bOffset;

		void main(void)
		{
			vec4 toUse = flixel_texture2D(bitmap, openfl_TextureCoordv);
			toUse.r = flixel_texture2D(bitmap, openfl_TextureCoordv.st - vec2(rOffset, 0.0)).r;
			toUse.g = flixel_texture2D(bitmap, openfl_TextureCoordv.st - vec2(gOffset, 0.0)).g;
			toUse.b = flixel_texture2D(bitmap, openfl_TextureCoordv.st - vec2(bOffset, 0.0)).b;
			gl_FragColor = toUse;
		}')
	public function new():Void
	{
		super();
	}
}

There isn't much of a difference except the fact that I'll use @:glFragmentSource from the extended class as the default values.

@MAJigsaw77
Copy link
Contributor Author

It should work like extending FlxGraphicShader in a way.

@Geokureli
Copy link
Member

Geokureli commented Sep 3, 2024

Thanks, again!

I assume the old version would require more gl tags?

@MAJigsaw77
Copy link
Contributor Author

Thanks, again!

I assume the old version would require more gl tags?

Before this pr, it couldn't work like extending FlxGraphicShader but now it will as shown in example.

@Geokureli Geokureli added this to the 3.3.0 milestone Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants