<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.xna.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Direct3D</title><link>http://forums.xna.com/forums/27.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 0.0)</generator><item><title>Re: Alpha blending problem!</title><link>http://forums.xna.com/forums/thread/152874.aspx</link><pubDate>Mon, 23 Mar 2009 21:51:29 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:152874</guid><dc:creator>Scyde</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/152874.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=27&amp;PostID=152874</wfw:commentRss><description>I got it.&lt;div&gt;Render target texture should have &lt;span style="border-collapse:collapse;font-size:11px;"&gt;&lt;span&gt;X8R8G8B8 format&lt;/span&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="border-collapse:collapse;font-size:11px;"&gt;Before rendering to texture i need to clean it with &lt;span&gt;Color.FromARGB(0,0,0,0)&lt;/span&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="border-collapse:collapse;font-size:11px;"&gt;Thats it! You got a transparent render surface;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="border-collapse:collapse;font-size:11px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="border-collapse:collapse;font-size:11px;"&gt;Great tnx to topic: &lt;span style="border-collapse:separate;font-size:13px;"&gt;&lt;a href="http://www.gamedev.net/community/forums/topic.asp?topic_id=502058"&gt;http://www.gamedev.net/community/forums/topic.asp?topic_id=502058&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;</description></item><item><title>Re: Alpha blending problem!</title><link>http://forums.xna.com/forums/thread/152792.aspx</link><pubDate>Mon, 23 Mar 2009 18:54:02 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:152792</guid><dc:creator>Scyde</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/152792.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=27&amp;PostID=152792</wfw:commentRss><description>So i see that new rendertarget texture kills all transparency...&lt;div&gt;No simple way to get previous alpha map?&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;What about BlendFactor? &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Looks like it is all about how to make transparent render target texture...&lt;/div&gt;&lt;div&gt;Found some examples:&lt;/div&gt;&lt;div&gt;&lt;a href="http://www.gamedev.net/community/forums/topic.asp?topic_id=502540"&gt;http://www.gamedev.net/community/forums/topic.asp?topic_id=502540&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://forums.xna.com/forums/p/11389/60299.aspx"&gt;http://forums.xna.com/forums/p/11389/60299.aspx&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;But still cant figure it out :(&lt;/div&gt;</description></item><item><title>Re: Alpha blending problem!</title><link>http://forums.xna.com/forums/thread/152756.aspx</link><pubDate>Mon, 23 Mar 2009 17:17:34 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:152756</guid><dc:creator>PhilTaylor</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/152756.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=27&amp;PostID=152756</wfw:commentRss><description>read the dx9 documentation on &amp;quot;Alpha Blending &amp;quot; and &amp;quot;Texture Alpha&amp;quot; and use the fixed function pipeline texture blending to control this, that might give you more control than framebuffer alpha.&lt;br /&gt;
&lt;br /&gt;
the blendfactor operator might also be useful.&lt;br /&gt;
&lt;br /&gt;
once you get used to this with the FFP, then you can write some shaders to do the same thing.</description></item><item><title>Re: Alpha blending problem!</title><link>http://forums.xna.com/forums/thread/152748.aspx</link><pubDate>Mon, 23 Mar 2009 16:53:36 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:152748</guid><dc:creator>Scyde</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/152748.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=27&amp;PostID=152748</wfw:commentRss><description>I rendered the only one texture, it is a red circle, created in photoshop with transparent layer.&lt;div&gt;How destination image was created: circle is rendered to black-color-cleared surface. So, i have a black suface with a red circle on it. Then i get the texture of this surface and render it.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I want to have a solid part to be red all the time, even if the bg is white, and the black part/transparent one to be invisible.&lt;/div&gt;</description></item><item><title>Re: Alpha blending problem!</title><link>http://forums.xna.com/forums/thread/152629.aspx</link><pubDate>Mon, 23 Mar 2009 11:17:38 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:152629</guid><dc:creator>digitalerr0rDCC</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/152629.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=27&amp;PostID=152629</wfw:commentRss><description>In what order are you rendering the textures?&lt;br /&gt;
Are you rendering the background texture first and then the circle texture?&lt;br /&gt;
&lt;br /&gt;
If you render the background texture first, and then the circle using alpha testing, the circle will remain the same no matter what you do with the background texture.&lt;br /&gt;
&lt;br /&gt;
How is the png created? Do you want to have some parts of the circle invisible at all time, and then the solid parts based on the transparency percentage?</description></item><item><title>Re: Alpha blending problem!</title><link>http://forums.xna.com/forums/thread/152184.aspx</link><pubDate>Sat, 21 Mar 2009 17:47:46 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:152184</guid><dc:creator>Scyde</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/152184.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=27&amp;PostID=152184</wfw:commentRss><description>My goal is to keep red circle&amp;#39;s color red, even if that is drawn with white background.&lt;div&gt;I guess the problem is that i lose any alpha channel after drawing my objects to black surface.&lt;/div&gt;&lt;div&gt;So maybe i need somehow to remap transparency of new resulting texture?&lt;/div&gt;</description></item><item><title>Re: Alpha blending problem!</title><link>http://forums.xna.com/forums/thread/152157.aspx</link><pubDate>Sat, 21 Mar 2009 15:33:48 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:152157</guid><dc:creator>PhilTaylor</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/152157.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=27&amp;PostID=152157</wfw:commentRss><description>what is your goal, eg the desired result?</description></item><item><title>Alpha blending problem!</title><link>http://forums.xna.com/forums/thread/152127.aspx</link><pubDate>Sat, 21 Mar 2009 11:14:29 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:152127</guid><dc:creator>Scyde</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/152127.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=27&amp;PostID=152127</wfw:commentRss><description>Hello everyone, so here is my problem:&lt;br /&gt;I have a png image, which i load to my texture.&lt;br /&gt;&lt;br /&gt;&lt;div style="border-top-width:1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;overflow-x:auto;overflow-y:auto;background-color:white;font-family:&amp;#39;courier new&amp;#39;;font-size:11px;"&gt;&lt;table cellspacing="0" cellpadding="0" style="border-top-width:0px;border-right-width:0px;border-left-width:0px;border-bottom-width:0px;border-bottom-style:solid;margin-top:2px;margin-right:0px;margin-bottom:2px;margin-left:0px;width:99%;border-collapse:collapse;"&gt;                &lt;tr&gt;            &lt;td&gt;&lt;span style="font-size:11px;"&gt;mytex = GraphicsUtility.CreateTexture(dx, &lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;quot;myimage.png&amp;quot;&lt;/span&gt;&lt;span style="font-size:11px;"&gt;, Format.X8R8G8B8); &lt;/span&gt;&lt;/td&gt;        &lt;/tr&gt;    &lt;/table&gt;&lt;/div&gt;&lt;br /&gt;*I guess after this stage i got a&lt;span&gt; &lt;strong&gt;&lt;span&gt;red circle on the black background&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;&lt;span&gt; &lt;/span&gt;&lt;/strong&gt;and it seems that it has no alpha map, right?&lt;br /&gt;After that i draw this to my surface:&lt;br /&gt;&lt;br /&gt;&lt;div style="border-top-width:1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;overflow-x:auto;overflow-y:auto;background-color:white;font-family:&amp;#39;courier new&amp;#39;;font-size:11px;"&gt;&lt;table cellspacing="0" cellpadding="0" style="border-top-width:0px;border-right-width:0px;border-left-width:0px;border-bottom-width:0px;border-bottom-style:solid;margin-top:2px;margin-right:0px;margin-bottom:2px;margin-left:0px;width:99%;border-collapse:collapse;"&gt;                &lt;tr&gt;            &lt;td&gt;&lt;span style="font-size:11px;"&gt;dx.SetRenderTarget(0, rtSurf); &lt;/span&gt;&lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;            &lt;td&gt;dx.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.FromArgb(0,0,0,0), 1.0f, 0); &lt;span style="color:green;"&gt;//Clean it with black color&lt;/span&gt;&lt;span style="font-size:11px;"&gt; &lt;/span&gt;&lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;            &lt;td&gt;&lt;span style="color:blue;"&gt;try&lt;/span&gt;&lt;span style="font-size:11px;"&gt; &lt;/span&gt;&lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;            &lt;td&gt;{ &lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;            &lt;td&gt;    DrawMyCircleTexture(); &lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;            &lt;td&gt;} &lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;            &lt;td&gt;&lt;span style="color:blue;"&gt;finally&lt;/span&gt;&lt;span style="font-size:11px;"&gt; &lt;/span&gt;&lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;            &lt;td&gt;{ &lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;            &lt;td&gt;    dx.SetRenderTarget(0, originalSurface); &lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;            &lt;td&gt;} &lt;/td&gt;        &lt;/tr&gt;    &lt;/table&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Then i set up render states and draw surface&amp;#39;s texture:&lt;br /&gt;&lt;br /&gt;&lt;div style="border-top-width:1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;overflow-x:auto;overflow-y:auto;background-color:white;font-family:&amp;#39;courier new&amp;#39;;font-size:11px;"&gt;&lt;table cellspacing="0" cellpadding="0" style="border-top-width:0px;border-right-width:0px;border-left-width:0px;border-bottom-width:0px;border-bottom-style:solid;margin-top:2px;margin-right:0px;margin-bottom:2px;margin-left:0px;width:99%;border-collapse:collapse;"&gt;                &lt;tr&gt;            &lt;td&gt;&lt;span style="font-size:11px;"&gt;dx.RenderState.CullMode = Cull.None; &lt;/span&gt;&lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;            &lt;td&gt;dx.RenderState.AlphaBlendEnable = &lt;span style="color:blue;"&gt;true&lt;/span&gt;&lt;span style="font-size:11px;"&gt;; &lt;/span&gt;&lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;            &lt;td&gt;dx.RenderState.SourceBlend = Blend.SourceAlpha; &lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;            &lt;td&gt;dx.RenderState.DestinationBlend = Blend.InvSourceAlpha; &lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;            &lt;td&gt;dx.RenderState.BlendOperation = BlendOperation.Add; dx.RenderState.AlphaFunction = (Compare)comboAF.SelectedItem; &lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;            &lt;td&gt;dx.TextureState[0].AlphaOperation = TextureOperation.Modulate; &lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;            &lt;td&gt;dx.SamplerState[0].AddressU = TextureAddress.Mirror;  &lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;            &lt;td&gt;dx.SamplerState[0].AddressV = TextureAddress.Mirror;  &lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;            &lt;td&gt;dx.SamplerState[0].MinFilter = TextureFilter.Anisotropic; &lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;            &lt;td&gt;dx.SamplerState[0].MagFilter = TextureFilter.Anisotropic; &lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;            &lt;td&gt;dx.RenderState.ZBufferEnable = &lt;span style="color:blue;"&gt;false&lt;/span&gt;&lt;span style="font-size:11px;"&gt;; dx.RenderState.ZBufferWriteEnable = &lt;/span&gt;&lt;span style="color:blue;"&gt;false&lt;/span&gt;&lt;span style="font-size:11px;"&gt;; &lt;/span&gt;&lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;            &lt;td&gt;sprite.Begin(SpriteFlags.SortTexture);  &lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;            &lt;td&gt;sprite.Draw2D(mytex, &lt;span style="color:blue;"&gt;new&lt;/span&gt;&lt;span style="font-size:11px;"&gt; Rectangle(), &lt;/span&gt;&lt;span style="color:blue;"&gt;new&lt;/span&gt;&lt;span style="font-size:11px;"&gt; SizeF(), &lt;/span&gt;&lt;span style="color:blue;"&gt;new&lt;/span&gt;&lt;span style="font-size:11px;"&gt; PointF(), Color.White); &lt;/span&gt;&lt;span style="color:green;"&gt;//White color to save image colors &lt;/span&gt;&lt;span style="font-size:11px;"&gt; &lt;/span&gt;&lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;            &lt;td&gt;sprite.End(); &lt;/td&gt;        &lt;/tr&gt;    &lt;/table&gt;&lt;/div&gt;&lt;br /&gt;So here is result images in depence of background color:&lt;br /&gt;&lt;br /&gt;&lt;img src="http://xmages.net/out.php/i151320_mg.jpg" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;Does anyone know why cirlce dissapears? How to keep it&amp;#39;s color? What blend do i need?&lt;br /&gt;&lt;br /&gt;Thanks&lt;br /&gt;</description></item></channel></rss>