0x8888 Posted November 2, 2018 Share Posted November 2, 2018 I've made a demo on my Github page, and it is almost copied and built from the plugin example. The problem is when I modify the fragment shader into a simple example: varying vec2 vTextureCoord; varying vec4 vColor; uniform sampler2D uSampler; uniform vec4 uTextureClamp; uniform vec4 uColor; void main(void) { gl_FragColor = vec4(1.0, 1.0, 0.0, 0.0); } The expected effect is the sprite becoming transparent, however the actual result is the sprite become yellow. And I tried to modify the gl_FragColor.a for several values between 0.0 and 1.0, none of these value works as expected. Can anyone help to solve this problem. Note: I can change the alpha of the sprite for this simple demo (or even discard for every fragment), but some effects requires some pixel‘s alpha value being calculated, so I need to find out how to change the alpha value of a pixel. Update: I guess the problem is premultipliedAlpha, adding the code below before drawElements and set base.premultipliedAlpha false will work. however I need to know if this has some side-effect. this.renderer.state.setBlendMode(PIXI.utils.premultiplyBlendMode[Number(base.premultipliedAlpha)][sprite.blendMode]); Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted November 2, 2018 Share Posted November 2, 2018 All colors are premultiplied. "gl_FragColor = vec4(a,a,a,a)" should work. Its required for linear filtering. We use non-premuiltiplied alpha only in compressed-textures plugin. Basically, instead of (R,G,B,a) textures and output stores (Ra,Ga,Ba,a) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.