XNA Creators Club Online
Page 1 of 1 (5 items)
Sort Posts: Previous Next

A Transparent Problem:use color not alpha

Last post 12/24/2009 3:02 AM by showmethemoney. 4 replies.
  • 11/18/2009 9:23 AM

    A Transparent Problem:use color not alpha

    I draw a texture Tex2 cover a texture Tex1.
    Tex2's alpha value is all 1.If Tex2's color R=0,G=0,B=0,use Tex1's color,else use Tex2's color.
    How can I do this?
    I have try stencil and blend,but can't find an exact and effctive way.
    Thank you!
  • 11/18/2009 11:04 AM In reply to

    Re: A Transparent Problem:use color not alpha

    I don't think you'll find a simple render state setting that will get the job done. However, you can probably write a pixel shader that examines the colors in the textures and then outputs whatever color you want.
  • 11/18/2009 2:20 PM In reply to

    Re: A Transparent Problem:use color not alpha

    Thank you for your suggestion,I will try!
  • 11/18/2009 4:49 PM In reply to

    Re: A Transparent Problem:use color not alpha

    If I understand your question correctly, then you want to draw Tex1 first, then draw Tex2 over it, and all pixels in Tex2 which are black (R=0, G=0, B=0) shall be transparent (not drawn) so that you see through Tex1 instead. All non-black pixels of Tex2 shall be drawn normally. Is that what you want?

    If so, then there is a simple solution, that doesn't even require coding:

    In Visual Studio, in the solution explorer, right click on the image file for Tex2. Then select "Properties". In the properties window, open the sub-items for the "Content Processor" (click the little "+" sign in front of the content processor entry). From the entries that open, make sure that the "Color Key Enabled" entry is set to "true" (that's the default, I think). Then open the sub-entries of "Color Key Color" by clicking the little "+" in front of it. Set the "R", "G" and "B" sub-entries to "0" and "A" to 255. This is equivalent to fully opaque black. With these settings, all opaque black pixels in this texture will not be rendered, i.e. will be transparent.

    Doc
    Urgently needed: Reviews in German for Kuchibi and Golden Tangram (No more reviews in English needed :-)

    Twitter - My Game Trailers - www.spyn-doctor.de - Games: Your Doodles Are Bugged! - Kuchibi - Golden Tangram

    Useful for peer reviews and testing your own game: My little "evil" checklist for peer review stress testing
  • 12/24/2009 3:02 AM In reply to

    Re: A Transparent Problem:use color not alpha

    Thank you for your Help.

    First:Your description on my problem is exact.
    2:My texture is extract from some encrypted data(very big..) run-time and I cant rebuild them:)
Page 1 of 1 (5 items) Previous Next