Jump to content

View more

Image of the Day

The night is still, but the invasion brings chaos. #screenshotsaturday #hanako #indiegame #gameart #ue4 #samurai https://t.co/cgILXuokoS
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Alpha disappearing when I make a texture.

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
4 replies to this topic

#1 KairisCharm   Members   

107
Like
0Likes
Like

Posted 07 August 2014 - 02:51 PM

I have to create a Texture2D during runtime. It needs to maintain a transparent background (the texture is a radar image, and it must be drawn over a map). I'm using a Bitmap object on which I draw the texture, and then I save that bitmap to a MemoryStream, and call Texture2D.FromStream() to create the resulting texture. When I do this, the image loses all transparency. How do I prevent this?



#2 ankhd   Members   

2301
Like
1Likes
Like

Posted 07 August 2014 - 05:26 PM

Hi.
When you write the texture are you using a shader.
If so what you do is set all alpha to 0.0 then when you have a colour pixel set it's alpha to 1.

It's easy to do with a render target by using clear and setting alpha to 0.0 in the colour you pass to clear.

#3 KairisCharm   Members   

107
Like
0Likes
Like

Posted 08 August 2014 - 08:29 AM

I'm not rendering to the texture. I'm rendering to a System.Drawing.Bitmap object. I save that Bitmap into a System.IO.MemoryStream, and then I tell the Texture2D to make itself based on that stream.


Edited by KairisCharm, 08 August 2014 - 08:30 AM.


#4 KairisCharm   Members   

107
Like
1Likes
Like

Posted 08 August 2014 - 08:34 AM

Or perhaps you mean that I should ignore the failure to get transparency at that point, move on the the shader phase, and handle alpha there. Is that what you mean?



#5 KairisCharm   Members   

107
Like
0Likes
Like

Posted 08 August 2014 - 08:47 AM

Evidently that is precisely what you meant. I just tried it, and it worked beautifully. Thank you! You probably saved me a day of beating my head against a wall for no reason.






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.