Jump to content

Alpha value in shaders


GBagley
 Share

Recommended Posts

Hi,

 

I'm starting to play with shaders (AbstractFilter) in PIXI, but have gotten stuck trying to use the alpha value. It seems that in the vertex shader the attribute aColor.a (the alpha) is always at 1.0, even though in pixi I'm specifying that the alpha on the graphics object is lower. Which alpha value from pixi is being passed to the shader? Example here:

 

http://jsfiddle.net/tLc5c8yd/

 

In this, one box has an alpha of 0.6 and the other has an alpha of 1.0. In the vertex shader, I'm trying to change the emitted color of the vertex based on the alpha (>= 1.0 is red, < 1 is green) but they both come up the same color.

Link to comment
Share on other sites

I think there is a misunderstanding, aColor is for "colorizing" or tinting an object. Your tint is white (by default) so you get vec4(1.0, 1.0, 1.0, 1.0).

aColor is not the color of the object you are drawing it is the tint you are applying (and in some eccentric features can be used for premultiplied alphas).

Link to comment
Share on other sites

I think there is a misunderstanding, aColor is for "colorizing" or tinting an object. Your tint is white (by default) so you get vec4(1.0, 1.0, 1.0, 1.0).

 

 

Oh! I see. I grabbed the default TextureShader sources for some reason... Guessing I want the one of the primitive ones for Graphics objects instead. Could you describe the difference between the default  PrimitiveShader and the ComplexPrimitiveShader, and when pixi uses each? Looks like the difference has something to do with coloring/blending -- complex using a uniform for color rather than an attribute?. 

 

Thanks

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...