We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.
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!
Great, thanks for sharing!
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);togl_FragColor = vec4(vec3(gray), color.a);
gl_FragColor = vec4(vec3(gray), 1.0);
gl_FragColor = vec4(vec3(gray), color.a);
Thanks, great tip! When I have the opportunity I'll update the article with it :)
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?
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. :)
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.
Indeed that doesn't seem straightforward; do you maybe have an example of what you want to achieve (from shadertoy or something)?
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.