<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Dynamic 2D Shadows</title>
	<atom:link href="http://www.catalinzima.com/samples/12-months-12-samples-2008/dynamic-2d-shadows/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.catalinzima.com</link>
	<description>XNA Tutorials, Samples and Thoughts</description>
	<lastBuildDate>Fri, 20 Aug 2010 07:16:20 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Jeff On Games &#187; Posted Without (Too Much) Comment</title>
		<link>http://www.catalinzima.com/samples/12-months-12-samples-2008/dynamic-2d-shadows/comment-page-1/#comment-30595</link>
		<dc:creator>Jeff On Games &#187; Posted Without (Too Much) Comment</dc:creator>
		<pubDate>Fri, 30 Jul 2010 01:35:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.catalinzima.com/?page_id=313#comment-30595</guid>
		<description>[...] post about how I got 2D soft shadows working in XNA using the GameDev article in combination with Catalin&#039;s implementation and Christian&#039;s implementation in D. However, trying to write the post, I wasn&#039;t sure if I could [...]</description>
		<content:encoded><![CDATA[<p>[...] post about how I got 2D soft shadows working in XNA using the GameDev article in combination with Catalin&#039;s implementation and Christian&#039;s implementation in D. However, trying to write the post, I wasn&#039;t sure if I could [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: FlySoft</title>
		<link>http://www.catalinzima.com/samples/12-months-12-samples-2008/dynamic-2d-shadows/comment-page-1/#comment-30392</link>
		<dc:creator>FlySoft</dc:creator>
		<pubDate>Wed, 14 Jul 2010 12:58:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.catalinzima.com/?page_id=313#comment-30392</guid>
		<description>Wow, thats real awsome! You also can use this for tile Based games (32x32 tiles, 800x600), and it&#039;s still very fast!

Thank you very much!
FlySoft</description>
		<content:encoded><![CDATA[<p>Wow, thats real awsome! You also can use this for tile Based games (32&#215;32 tiles, 800&#215;600), and it&#8217;s still very fast!</p>
<p>Thank you very much!<br />
FlySoft</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Hampson</title>
		<link>http://www.catalinzima.com/samples/12-months-12-samples-2008/dynamic-2d-shadows/comment-page-1/#comment-29431</link>
		<dc:creator>John Hampson</dc:creator>
		<pubDate>Fri, 11 Jun 2010 16:06:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.catalinzima.com/?page_id=313#comment-29431</guid>
		<description>Hi Catalin,

Awesome sample and thanks for sharing.  I&#039;m going to take a look at it and try to incorperate it into one of my mini 2d projects.

-John</description>
		<content:encoded><![CDATA[<p>Hi Catalin,</p>
<p>Awesome sample and thanks for sharing.  I&#8217;m going to take a look at it and try to incorperate it into one of my mini 2d projects.</p>
<p>-John</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christopher Harris</title>
		<link>http://www.catalinzima.com/samples/12-months-12-samples-2008/dynamic-2d-shadows/comment-page-1/#comment-28391</link>
		<dc:creator>Christopher Harris</dc:creator>
		<pubDate>Mon, 26 Apr 2010 07:53:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.catalinzima.com/?page_id=313#comment-28391</guid>
		<description>Is anyone interested in a GPU based shadowing method?</description>
		<content:encoded><![CDATA[<p>Is anyone interested in a GPU based shadowing method?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stan</title>
		<link>http://www.catalinzima.com/samples/12-months-12-samples-2008/dynamic-2d-shadows/comment-page-1/#comment-28228</link>
		<dc:creator>Stan</dc:creator>
		<pubDate>Tue, 20 Apr 2010 09:14:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.catalinzima.com/?page_id=313#comment-28228</guid>
		<description>I&#039;m trying to get this to work with a camera and all is well except that the shadows will only draw correctly if the convex hull position is at (0,0).  Any suggestions?  Thanks.</description>
		<content:encoded><![CDATA[<p>I&#8217;m trying to get this to work with a camera and all is well except that the shadows will only draw correctly if the convex hull position is at (0,0).  Any suggestions?  Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Blind &#171; AwkwardGames &#8211; Quote: &#34;AwkwardGames ftw!&#34;</title>
		<link>http://www.catalinzima.com/samples/12-months-12-samples-2008/dynamic-2d-shadows/comment-page-1/#comment-27618</link>
		<dc:creator>Blind &#171; AwkwardGames &#8211; Quote: &#34;AwkwardGames ftw!&#34;</dc:creator>
		<pubDate>Sun, 21 Mar 2010 22:11:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.catalinzima.com/?page_id=313#comment-27618</guid>
		<description>[...] and XNA 3.1. The sfx used can be found on FreeSound.org Thanks go to Catalin Zima for his 2D dynamic lighting sample. Inspiration source: Experimental Gameplay Project. The game itself is under the Creative Commons [...]</description>
		<content:encoded><![CDATA[<p>[...] and XNA 3.1. The sfx used can be found on FreeSound.org Thanks go to Catalin Zima for his 2D dynamic lighting sample. Inspiration source: Experimental Gameplay Project. The game itself is under the Creative Commons [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pnikosis</title>
		<link>http://www.catalinzima.com/samples/12-months-12-samples-2008/dynamic-2d-shadows/comment-page-1/#comment-27020</link>
		<dc:creator>Pnikosis</dc:creator>
		<pubDate>Thu, 25 Feb 2010 16:23:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.catalinzima.com/?page_id=313#comment-27020</guid>
		<description>Sorry, me again :P

What I want to do is only draw the cached &quot;cutted&quot; static lights (by cutted, I mean, the light source and removing the parts that are shadowed), as the shadows are already in the dynamic shadows&#039; RenderTarget2D.</description>
		<content:encoded><![CDATA[<p>Sorry, me again <img src='http://www.catalinzima.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>What I want to do is only draw the cached &#8220;cutted&#8221; static lights (by cutted, I mean, the light source and removing the parts that are shadowed), as the shadows are already in the dynamic shadows&#8217; RenderTarget2D.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pnikosis</title>
		<link>http://www.catalinzima.com/samples/12-months-12-samples-2008/dynamic-2d-shadows/comment-page-1/#comment-27018</link>
		<dc:creator>Pnikosis</dc:creator>
		<pubDate>Thu, 25 Feb 2010 16:14:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.catalinzima.com/?page_id=313#comment-27018</guid>
		<description>Hi Catalin, I&#039;m stuck with something and I though maybe you can help me out (please). I&#039;m using your dynamic 2D shadows code (can I mention you in the credits in the game by the way?), and everything&#039;s working fine. I&#039;ve made some optimizations and it&#039;s looking quite good.

But now I&#039;m trying to add some static shadows to my game, and for that I&#039;m trying to calculate all the static shadows during the level loading period, and then just draw a texture with the static lights and shadows. The problem is that I&#039;m not very good at graphics programming, and although I&#039;m storing all the precalculated shadows in a big texture (with RenderTarget2D.GetTexture()) my problem is when my camera scrolls. RenderTarget2D gives me a texture with the viewport&#039;s size, so when I move around and the camera moves, the rectangle containing the shadows stays in place :S What I need (I guess) is a bigger RenderTarget2D, with the size of the whole level, but I don&#039;t know how to do this (gives me error when I try this. Any ideas?

With dynamic shadows I have no problem, as it calculates on each frame the lights and shadows position related to the camera position.

Thanks, sorry for the huge question.</description>
		<content:encoded><![CDATA[<p>Hi Catalin, I&#8217;m stuck with something and I though maybe you can help me out (please). I&#8217;m using your dynamic 2D shadows code (can I mention you in the credits in the game by the way?), and everything&#8217;s working fine. I&#8217;ve made some optimizations and it&#8217;s looking quite good.</p>
<p>But now I&#8217;m trying to add some static shadows to my game, and for that I&#8217;m trying to calculate all the static shadows during the level loading period, and then just draw a texture with the static lights and shadows. The problem is that I&#8217;m not very good at graphics programming, and although I&#8217;m storing all the precalculated shadows in a big texture (with RenderTarget2D.GetTexture()) my problem is when my camera scrolls. RenderTarget2D gives me a texture with the viewport&#8217;s size, so when I move around and the camera moves, the rectangle containing the shadows stays in place :S What I need (I guess) is a bigger RenderTarget2D, with the size of the whole level, but I don&#8217;t know how to do this (gives me error when I try this. Any ideas?</p>
<p>With dynamic shadows I have no problem, as it calculates on each frame the lights and shadows position related to the camera position.</p>
<p>Thanks, sorry for the huge question.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: william bechard</title>
		<link>http://www.catalinzima.com/samples/12-months-12-samples-2008/dynamic-2d-shadows/comment-page-1/#comment-25463</link>
		<dc:creator>william bechard</dc:creator>
		<pubDate>Fri, 18 Dec 2009 23:28:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.catalinzima.com/?page_id=313#comment-25463</guid>
		<description>hmm well i figured it out.

within the DrawLightmap method
 
I moved the

                       foreach (ConvexHull hull in World1.Worldobjects)
                        {
                            hull.Draw(gT, World1.cam.get_transformation(GraphicsDevice));
                        }

right after the

 foreach (ConvexHull ch in World1.Worldobjects)
                        {
                            //draw shadow
                            if (ch != null)
                            {

                                ch.DrawShadows(light, World1.cam.get_transformation(GraphicsDevice));
                                
                            }
                        }

so to recap in  DrawLightmap method it should look like the following:

 foreach (LightSource light in lights)
                {
                    //clear alpha to 1
                    ClearAlphaToOne();

                    //draw all shadows
                    //write only to the alpha channel, which sets alpha to 0
                    GraphicsDevice.RenderState.ColorWriteChannels = ColorWriteChannels.Alpha;
                    GraphicsDevice.RenderState.CullMode = CullMode.None;
                    GraphicsDevice.RenderState.AlphaBlendEnable = true;
                    GraphicsDevice.RenderState.DestinationBlend = Blend.Zero;
                    GraphicsDevice.RenderState.SourceBlend = Blend.One;
                    
 
       
                        foreach (ConvexHull ch in World1.Worldobjects)
                        {
                            //draw shadow
                            if (ch != null)
                            {

                                ch.DrawShadows(light, World1.cam.get_transformation(GraphicsDevice));
                                
                            }
                        }
                        foreach (ConvexHull hull in World1.Worldobjects)
                        {
                            hull.Draw(gT, World1.cam.get_transformation(GraphicsDevice));
                        }
                        
                    GraphicsDevice.RenderState.ColorWriteChannels = ColorWriteChannels.All;

                    //draw the light shape
                    //where Alpha is 0, nothing will be written
                    //This is the light
                    spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.SaveState, World1.cam.get_transformation(GraphicsDevice));
                    GraphicsDevice.RenderState.DestinationBlend = Blend.One;
                    GraphicsDevice.RenderState.SourceBlend = Blend.DestinationAlpha;
                    GraphicsDevice.RenderState.BlendFunction = BlendFunction.Add;
                    GraphicsDevice.RenderState.SeparateAlphaBlendEnabled = true;
                    light.Draw(spriteBatch);
                    spriteBatch.End();




                }

Now this will have the hulls lit up (fully) when light touches it

If you would prefer them without light then make sure your color value is passed with an alpha of 0.

this is my line to create the object (hull)

 objects = new ConvexHull(game2, Points, new Color(0,0,0,0), new Vector2(X, Y));


Well this seems to have worked for me anyway.</description>
		<content:encoded><![CDATA[<p>hmm well i figured it out.</p>
<p>within the DrawLightmap method</p>
<p>I moved the</p>
<p>                       foreach (ConvexHull hull in World1.Worldobjects)<br />
                        {<br />
                            hull.Draw(gT, World1.cam.get_transformation(GraphicsDevice));<br />
                        }</p>
<p>right after the</p>
<p> foreach (ConvexHull ch in World1.Worldobjects)<br />
                        {<br />
                            //draw shadow<br />
                            if (ch != null)<br />
                            {</p>
<p>                                ch.DrawShadows(light, World1.cam.get_transformation(GraphicsDevice));</p>
<p>                            }<br />
                        }</p>
<p>so to recap in  DrawLightmap method it should look like the following:</p>
<p> foreach (LightSource light in lights)<br />
                {<br />
                    //clear alpha to 1<br />
                    ClearAlphaToOne();</p>
<p>                    //draw all shadows<br />
                    //write only to the alpha channel, which sets alpha to 0<br />
                    GraphicsDevice.RenderState.ColorWriteChannels = ColorWriteChannels.Alpha;<br />
                    GraphicsDevice.RenderState.CullMode = CullMode.None;<br />
                    GraphicsDevice.RenderState.AlphaBlendEnable = true;<br />
                    GraphicsDevice.RenderState.DestinationBlend = Blend.Zero;<br />
                    GraphicsDevice.RenderState.SourceBlend = Blend.One;</p>
<p>                        foreach (ConvexHull ch in World1.Worldobjects)<br />
                        {<br />
                            //draw shadow<br />
                            if (ch != null)<br />
                            {</p>
<p>                                ch.DrawShadows(light, World1.cam.get_transformation(GraphicsDevice));</p>
<p>                            }<br />
                        }<br />
                        foreach (ConvexHull hull in World1.Worldobjects)<br />
                        {<br />
                            hull.Draw(gT, World1.cam.get_transformation(GraphicsDevice));<br />
                        }</p>
<p>                    GraphicsDevice.RenderState.ColorWriteChannels = ColorWriteChannels.All;</p>
<p>                    //draw the light shape<br />
                    //where Alpha is 0, nothing will be written<br />
                    //This is the light<br />
                    spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.SaveState, World1.cam.get_transformation(GraphicsDevice));<br />
                    GraphicsDevice.RenderState.DestinationBlend = Blend.One;<br />
                    GraphicsDevice.RenderState.SourceBlend = Blend.DestinationAlpha;<br />
                    GraphicsDevice.RenderState.BlendFunction = BlendFunction.Add;<br />
                    GraphicsDevice.RenderState.SeparateAlphaBlendEnabled = true;<br />
                    light.Draw(spriteBatch);<br />
                    spriteBatch.End();</p>
<p>                }</p>
<p>Now this will have the hulls lit up (fully) when light touches it</p>
<p>If you would prefer them without light then make sure your color value is passed with an alpha of 0.</p>
<p>this is my line to create the object (hull)</p>
<p> objects = new ConvexHull(game2, Points, new Color(0,0,0,0), new Vector2(X, Y));</p>
<p>Well this seems to have worked for me anyway.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: william bechard</title>
		<link>http://www.catalinzima.com/samples/12-months-12-samples-2008/dynamic-2d-shadows/comment-page-1/#comment-25449</link>
		<dc:creator>william bechard</dc:creator>
		<pubDate>Fri, 18 Dec 2009 03:04:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.catalinzima.com/?page_id=313#comment-25449</guid>
		<description>I do have a question though. With black the shadows dont cross past their hulls. However if i set the color to anythign else shadows show on the hulls. Is there a way to prevent this.</description>
		<content:encoded><![CDATA[<p>I do have a question though. With black the shadows dont cross past their hulls. However if i set the color to anythign else shadows show on the hulls. Is there a way to prevent this.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
