These are chat archives for pixijs/pixi.js

28th
Jun 2015
Olav Lindekleiv
@oal
Jun 28 2015 17:11
How can I access the renderer's dimensions in a filter fragment shader?
Chad Engler
@englercj
Jun 28 2015 17:14
@oal If you add a uniform that is "vec4 dimensions" then pixi.js will fill it with the values for you
Olav Lindekleiv
@oal
Jun 28 2015 17:15
englercj, great! Why is it a vec4 and not a vec2?
Because z/y is the renderer size, z/w is the size of the quad you are drawing
Olav Lindekleiv
@oal
Jun 28 2015 17:16
Aha, I see
Chad Engler
@englercj
Jun 28 2015 17:18
x/y I mean, not z/y
Olav Lindekleiv
@oal
Jun 28 2015 17:19
I only override the fragment shader. Do I need to add it into the vertex shader as well?
Chad Engler
@englercj
Jun 28 2015 17:22

No you don't, the most important things are to add it to the custom uniforms param:

https://github.com/GoodBoyDigital/pixi.js/blob/master/src/filters/pixelate/PixelateFilter.js#L21

And then just use it in your fragment shader:

https://github.com/GoodBoyDigital/pixi.js/blob/master/src/filters/pixelate/pixelate.frag#L5

The pixelate filter doesn't add it to the frag shader
sorry
it doesn't add it to the vert shader
Olav Lindekleiv
@oal
Jun 28 2015 17:26
hmm
Is there a way to inspect the values of uniforms in the shader? It looks to me like dimensions are 0
Olav Lindekleiv
@oal
Jun 28 2015 17:46
Never mind, I think I got it