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

Konrad Fedorczyk • 1 year 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 • 1 year ago

Great, thanks for sharing!

Andrew McOlash • 1 year 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);
gl_FragColor = vec4(vec3(gray), color.a);

Jérôme Rx • 1 year ago

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

josh milstead • 9 months 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 • 9 months 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 • 1 year 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 • 1 year 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 • 1 year 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.