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

how to use custom shaders? #17

Open
anekix opened this issue Jun 16, 2018 · 3 comments
Open

how to use custom shaders? #17

anekix opened this issue Jun 16, 2018 · 3 comments

Comments

@anekix
Copy link

anekix commented Jun 16, 2018

hi how can i use cutom fragment shaders? as far as i can see i can only pass a custom colorMatrix toaddFilter. suppose i want to achieve bloom effect how can i go about it?

@phoboslab
Copy link
Owner

Currently, there's no built in API to define custom shaders from the outside. However, you can easily add a new filter in the source. I.e.:

	filter.bloom = function( bloomSize ) {

		var program = _compileShader(_filter.bloom.SHADER);
		gl.uniform2f(program.uniform.bloomSize, 0, bloomSize);
		_draw();
	};

	_filter.bloom.SHADER = [
		'precision highp float;',
		'uniform float bloomSize',
		...
	];

I'll happily accept pull requests for a bloom shader!

@anekix
Copy link
Author

anekix commented Jun 18, 2018

@phoboslab thankyou, I will work on it and give a PR.

@mreinstein
Copy link
Contributor

being able to declare custom shaders from the outside could introduce another benefit:

we could move the filter implementations out of the main library, and that would mean not needing to pull in every filter when using this library somewhere (i.e., I only use 2 filters in my site/app, I wouldn't need to pull in 250 lines of code that are baked into WebGLImageFilter and never used.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants