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

Load a separate file GLSL shader as a string #3654

Closed
SebastienFPRousseau opened this issue Jan 26, 2017 · 3 comments
Closed

Load a separate file GLSL shader as a string #3654

SebastienFPRousseau opened this issue Jan 26, 2017 · 3 comments

Comments

@SebastienFPRousseau
Copy link

SebastienFPRousseau commented Jan 26, 2017

Hello,

I'm working on GLSL shaders with Pix and I would like to write them in separates files and load the contents with Javascript to use them in a Pixi Filter because writing the shader in a Javascript HTML element as some tutorials show isn't pretty at all.

Considering this code:

const frag_shader = document.getElementById( 'frag_shader' ).innerHTML; //Replacing this by reading the GLSL file 

const filter = new PIXI.Filter('', frag_shader);

Is there any way for Pixi.js to load external GLSL files in order to pass their content to PIXI.Filter ?
If not, is it a planned feature or do you use an external tool such as the glslify npm package to do so (https://github.com/stackgl/glslify) ?

There isn't much information for how Pixi v4 handle GLSL files and SO doesn't seem to have the answers, so I open this issue in order to know if this is something you can come up with.

Thanks for your answer.

@trickster721
Copy link

trickster721 commented Jan 28, 2017

Yes, PIXI includes glslify. You could use the loader.

PIXI.loader.add(["vert.txt","frag,txt"]);
PIXI.loader.load(finshed);

function finished()
	{
	var vert = PIXI.loader.resources["vert.txt"].data;
	var frag = PIXI.loader.resources["frag.txt"].data
	var myfilter = new PIXI.Filter(vert, frag);
	}

@SebastienFPRousseau
Copy link
Author

Thanks ! That's what i needed.

@lock
Copy link

lock bot commented Feb 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Feb 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants