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

Picture Transparency Question(Need Help/Suggestions)

Last post 7/20/2009 1:03 AM by LordKtulu. 12 replies.
  • 6/19/2009 1:17 AM

    Picture Transparency Question(Need Help/Suggestions)

    Hey All,

    I've run into a frustrating problem. I have created a couple different frames of a lightning bolt in photoshop, on a black background. Now I can't get rid of the background without ruining the picture to the extent where I would rather not have it in my game at all. I've tried a couple different solutions, "Layer Style -> Blend If", magic wanding and deleting, you get the idea. What I need is something that takes the black background of the image, and deletes/removes it so the image has a transparent background, so that when I put it in my game, my game's background will show through.

    http://i167.photobucket.com/albums/u130/MercilessShadow/StrghtBolt2.png

    Thanks in advance!
    -Merc
  • 6/19/2009 1:37 AM In reply to

    Re: Picture Transparency Question(Need Help/Suggestions)

    When you draw it in your game, try changing the SourceBlend of the RenderState to Blend.One.  That way the dark areas of your texture won't "add" to your scene (or maybe you've already tried that?).
  • 6/19/2009 2:38 AM In reply to

    Re: Picture Transparency Question(Need Help/Suggestions)

    Give this a try.

    In visual studio solution explorer, click on your image file.
    Next, go down to properties (beneath solution explorer).
    Click the + next to Content Processor and set Color Key Color to black (0, 0, 0, 255).
  • 6/19/2009 3:05 AM In reply to

    Re: Picture Transparency Question(Need Help/Suggestions)

    Thank you both for your quick responses! I tried both changing the RenderState, and Color Key, but neither of them seemed to have an effect on the image. Any more ideas?

    Thanks in Advance!
    -Merc
  • 6/19/2009 3:15 AM In reply to

    Re: Picture Transparency Question(Need Help/Suggestions)

    spriteBatch.Begin(SpriteBlendMode.Additive, SpriteSortMode.BackToFront, SaveStateMode.None);

    combined with RGV Rascal's suggestion on setting the color key to black.
    Game hobbyist hell-bent on coding a diabolical Matrix
  • 6/19/2009 3:35 AM In reply to

    Re: Picture Transparency Question(Need Help/Suggestions)

    That is a big step in the right direction, I get this: http://i167.photobucket.com/albums/u130/MercilessShadow/LightningGenProblem.png. I know why my background is like that, its because I'm drawing them both in the same spriteBatch call, but thats unimportant. Is there any way to get it more detailed? I had some really nice colors/hues/etc on the original and now its just 2, white and aqua. It does become transparent how I had hoped though, so if we can get the original quality it will look great! Or is that what it looks like with absolutely no black? In which case I'm S.O.L...

    Thanks in Advance!
    -Merc
  • 6/19/2009 3:43 AM In reply to

    Re: Picture Transparency Question(Need Help/Suggestions)

    spriteBatch.Draw(lightningTexture, position, new Color(Color.White, someAlpha));

    try fiddling with someAlpha, a value from 0 - 255;
    Game hobbyist hell-bent on coding a diabolical Matrix
  • 6/19/2009 3:57 AM In reply to

    Re: Picture Transparency Question(Need Help/Suggestions)

    But it's kind of weird because your 2nd image doesn't look anything like the first image in terms of color. What does it look like if you make your background black in the game?
    Game hobbyist hell-bent on coding a diabolical Matrix
  • 6/19/2009 4:13 AM In reply to

    Re: Picture Transparency Question(Need Help/Suggestions)

    Ah, thanks Craig thats much better! I'm going to leave it like this: http://i167.photobucket.com/albums/u130/MercilessShadow/LightningGenTest1.png for now, and see if maybe I can improve the result by doing some tweaking in Photoshop. If I figure out something magical, I'll post here. 

    spriteBatch.Draw(lightningBolt[i].straightPiece, lightningBolt[i].piecePos,

    new Color(Color.White, 127)); This is gives you the result in the above picture.

    This: http://i167.photobucket.com/albums/u130/MercilessShadow/LightningGenCorrectBgrnd.png, is what it looks like with the correct black background, before changing the Draw() to the above.

    Thanks again!
    -Merc

     

  • 6/20/2009 8:37 AM In reply to

    Re: Picture Transparency Question(Need Help/Suggestions)

    Hi, I'm sorry I can't help you with the transparency, though I know Catalin Zima made a sample about lightning in her site (http://www.catalinzima.com/?page_id=142)
    There you got different kinds of moving lightning, and I don't think it uses any texture for it.
    You speak English, Spanish or French ? You need tutorials in your language ? You can make tutorials in your language ? Check : this site
  • 6/21/2009 12:52 AM In reply to

    Re: Picture Transparency Question(Need Help/Suggestions)

    Are you loading your texture using a contentmanager or Texture2D.FromFile() method?

    Because if you are using the second one set the color key in the content processor is nonsense, you have to use:

    TextureCreationParameters tcp = TextureCreationParameters.Default;

    tcp.ColorKey = yourcolor;
    tcp.Format = SurfaceFormat.Color; // or what you need to use..

    than when you load the texture:
              
    Texture2D.FromFile(your graphicdevice, your path, tcp);


    sorry for the bad english
  • 6/21/2009 3:37 AM In reply to

    Re: Picture Transparency Question(Need Help/Suggestions)

    You have the DirectX SDK installed, right?
    Well, try this:
    In the DirectX texture viewer, open up the image.  Now, select the transparency map as the same image.  Save it and try with the new image.  I did this same thing with a matrix effect, and was suprised to see it work.  Give it a shot.
    -- Sir Cmpwn
  • 7/20/2009 1:03 AM In reply to

    Re: Picture Transparency Question(Need Help/Suggestions)

    It seems like you found a way via coding, but i thought i would post some tips anyways.
    Here is what i use for transparency:
    http://www351.lunapic.com/editor/?action=transparent

    just upload the picture u wanna use, then click the color that you want to be transparent and it will make it transparent.

    The site turns it into a gif, but to switch it to png:
    click the "host" button below the picture and host it on imageshack.us
    copy the direct image url then paste it into this page:
    http://online-image-editor.com/
    make sure you check "convert to png on upload"


    also, you said you wanted it to be realistic, yes?
    http://img386.imageshack.us/img386/2965/51017255.png

    on the lunapic site, you can make a blank image and have any size you want, color the background black using the paint bucket, then click under "effects" the "add lightning effect" and it will put a lightning picture over the picture. you can then use the transparency tool found under "edit".
Page 1 of 1 (13 items) Previous Next