[Solved] Passing a texture to a fragment shader

Hi, I’ve been trying for a while now to pass a normal map to a camera pipeline.

I’ve used setTexture2D to pass a texture and a unit. The problem is that I cannot edit the uniform sampler2D to reference the texture.

Normally I would get the uniform location, but this is apparently not possible with phaser 3.

Is there something I’m missing? The only solutions I’ve stumbled upon are either about phaser CE’s filters, or vanilla openGL/webGL.

Any help would be appreciated!

I finally found it!

For anyone coming here later, you can access webgl from
Phaser.Renderer.WebGL.WebGLRenderer.gl
Or:
game.renderer.gl
And then from there, you follow the usual steps with setTexture2D, getUniformLocation and uniform1i.

2 Likes

3.17.0 has built-in shader object, it provides a lot of useful built-in uniforms like itme / channelX etc.

btw: pipeline and shader actually are different, cause pipleline is a “global” rendering system for all the object bundle (or whole system) to have batching / common GPU functionalities. and shader, is actually a pass.