Jump to content
  • Advertisement
Sign in to follow this  
FirstDouchaEver

Pixel Shader RGB-Alpha problem

This topic is 4581 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, brand new to GameDev, studying a MSc in Games Programming and need some help, any advice appreciated. Basically, I'm creating a program that will paint onto a landscape. The landscape texture is swaped to become a RenderTarget and then I plot a Quad onto the texture via the pixel shader. Here's a link to a picture of the app and the problem - http://homepage.ntlworld.com/doucha/wedding/uni/ Take alook at the FIRST one. In the bottom right is the alpha channel that I'm plotting. Essentially the shader looks at the black and white alpha channel from a pure black 256x256 square .dds texture - thus creating a 'wet edge'. I then supply colours to the shader which will result in a coloured 'circle' plotted. It works like Photoshop's spray can - building up over time until a full RED circle is 'painted' All well and good - however the problem is the alpha - take a look at the picture, to the left shows how wonderful the 'spraying' works - with a light amount of paint applied - the blend is fine. However take a look at the red and blue circles. Here I have held the mouse down for a considerable time -building up the paint as it reaches a full circle the very edge becomes black! - spraying Red over Green (or any colour in fact) I have done the SAME thing and used the same shader principle for 'spraying' textures see the SECOND picture. As you can see this works perfectly, theres a lovely alpha blend going on even though the textures were sprayed until solid. Now I believe that as the problem occurs between 'pure' colours RGB that it may have something to do with the 8 bit channel reaching a limit. So that when is plotted Red and the alpha is High, the decreasing Green and Blue, that is already there, reach 0 - along with the Red being 0 becaue Alpha is 1 - if that all makes sense. I could b completely wrong and am totally new to graphics programming and shaders. Below is the Pixel Shader code - pbRed etc values are passed in - so for plotting a red bursh pbRed will be 255, pbGreen 0 and so on: float4 ReturnCol_ARGB; if (useColourMask == true) { ReturnCol_ARGB = tex2D(BaseTextureSampler, In.MaskCoord_XY); // Use RED channel on B&W texture masks - create the alpha blend ReturnCol_ARGB.r = pbRed/255.0f; //possibly devide by 255 if supplying 0-255 not 0-1 ReturnCol_ARGB.g = pbGreen/255.0f; ReturnCol_ARGB.b = pbBlue/255.0f; ReturnCol_ARGB.a = ReturnCol_ARGB.a*pbOpacity; // For .DDS brush } Sorry for the long post, if anyone has experience or ideas of how to combat this 'effect' I'll appreciate it and your time. P.S. using the texture as solid, reading the RED channel and matching the alpha - which does the same - but produces a slightly thicker black edge than using the alpha channel. Cheers for any help

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
I *think* it might have something to with the way you have setup alpha blending. It looks like you are using SRCALPHA and INVSRCALPHA for src and dest respectively. So by "holding the mouse down" you essentialy keep blending the src images with the background till there's nothing but src image left. This maybe somwhat similar to how PS works except that it blends towards the brush color at the edges instead of black. As Im a bit wasted right now, this make not make any sense!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!