Jump to content

Fragment shader gl_FragColor.a doesn't work in plugin.


0x8888
 Share

Recommended Posts

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]);
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...