We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.

Konrad Fedorczyk • 5 years ago

Hey! I’ve created little tool for converting shaders to fragment src usable by phaser. Maybe it will help someone: https://realhe.ro/fragment-...

BTW great post!

Jérôme Rx • 5 years ago

Great, thanks for sharing!

Andrew McOlash • 5 years ago

For the grayscale shader, I would recommend changing it so it supports alpha. Super easy, just change the line

gl_FragColor = vec4(vec3(gray), 1.0);
to
gl_FragColor = vec4(vec3(gray), color.a);

Jérôme Rx • 5 years ago

Thanks, great tip! When I have the opportunity I'll update the article with it :)

chiposaur • 10 months ago

I've only gotten about 1/3 thru the article, but it looks to be exactly the primer that I needed. thanks!

Scotty Wilson • 3 years ago

Is it possible to set up an additional sampler within a pipeline? For example, to sample a texture asset for use in your shader? I have not been able to figure out how to pass a texture other than the uMainsampler to my pipeline...

josh milstead • 4 years ago

I made a shader and I would like to apply it to all of the objects in my scene except a few. Is there any way to exclude game objects? Like some kind of layer or mask?

Jérôme Rx • 4 years ago

Not as far as I know, for this I would probably use the cameras trick I explain in the article, where you have one camera showing the objects you want to apply the shader to, another camera showing the objects you don't want to apply it to, and then you apply the shader to the first camera.

Alternatively it's also possible to apply a shader to specific objects individually by using `object.setPipeline('<name of="" your="" pipeline="">');`, you can then call this for all the objects you want the shader applied to. Which of these two solutions is the most elegant depends on the situation. :)

row finst • 5 years ago

Hi, thanks for this article. By the way, do you know how to add a second texture to the fragment shader? It doesn't seem possible to access uniform locations from phaser.

Jérôme Rx • 5 years ago

Indeed that doesn't seem straightforward; do you maybe have an example of what you want to achieve (from shadertoy or something)?

row finst • 5 years ago

I figured it out, it's basically just like with webgl vanilla. You can access gl through game.renderer.gl, and then do stuff like getUniformLocation to link the unit with a uniform sampler2D.