<?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: Lightning Bolts</title>
	<atom:link href="http://drilian.com/2009/02/25/lightning-bolts/feed/" rel="self" type="application/rss+xml" />
	<link>http://drilian.com/2009/02/25/lightning-bolts/</link>
	<description>Infrequently-updated ramblings about game development projects, ideas, and techniques</description>
	<lastBuildDate>Wed, 01 Sep 2010 08:00:27 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
	<item>
		<title>By: Drilian</title>
		<link>http://drilian.com/2009/02/25/lightning-bolts/comment-page-1/#comment-136</link>
		<dc:creator>Drilian</dc:creator>
		<pubDate>Sun, 27 Jun 2010 22:21:54 +0000</pubDate>
		<guid isPermaLink="false">http://drilian.com/?p=281#comment-136</guid>
		<description>Sure! I figured the names of the functions would give away what they do, but maybe not :)

Average(a, b) - average the two points.
Perpendicular(v) - Return the 2D vector perpendicular to this one (-v.y, v.x)
RandomFloat(min, max) - generate a random floating point value between min and max, inclusively.</description>
		<content:encoded><![CDATA[<p>Sure! I figured the names of the functions would give away what they do, but maybe not <img src='http://drilian.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Average(a, b) &#8211; average the two points.<br />
Perpendicular(v) &#8211; Return the 2D vector perpendicular to this one (-v.y, v.x)<br />
RandomFloat(min, max) &#8211; generate a random floating point value between min and max, inclusively.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tyler</title>
		<link>http://drilian.com/2009/02/25/lightning-bolts/comment-page-1/#comment-135</link>
		<dc:creator>Tyler</dc:creator>
		<pubDate>Fri, 25 Jun 2010 22:37:37 +0000</pubDate>
		<guid isPermaLink="false">http://drilian.com/?p=281#comment-135</guid>
		<description>Could you please elucidate exactly what each function in your pseudocode does please? Its a bit annoying as none of those are &quot;standard&quot; functions.</description>
		<content:encoded><![CDATA[<p>Could you please elucidate exactly what each function in your pseudocode does please? Its a bit annoying as none of those are &#8220;standard&#8221; functions.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Drilian&#8217;s House of Game Development &#187; Blog Archive &#187; Update For The Past N Months</title>
		<link>http://drilian.com/2009/02/25/lightning-bolts/comment-page-1/#comment-99</link>
		<dc:creator>Drilian&#8217;s House of Game Development &#187; Blog Archive &#187; Update For The Past N Months</dc:creator>
		<pubDate>Wed, 06 Jan 2010 03:15:36 +0000</pubDate>
		<guid isPermaLink="false">http://drilian.com/?p=281#comment-99</guid>
		<description>[...] Also, I decided that the Level 1 background (in the first two images in this post) was hideously bland (if such a thing is possible), so I decided to redo it as flying over a red desert canyon (incidentally, the walls of the canyon are generated using the same basic divide-and-offset algorithm as my lightning bolt generator): [...]</description>
		<content:encoded><![CDATA[<p>[...] Also, I decided that the Level 1 background (in the first two images in this post) was hideously bland (if such a thing is possible), so I decided to redo it as flying over a red desert canyon (incidentally, the walls of the canyon are generated using the same basic divide-and-offset algorithm as my lightning bolt generator): [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Drilian</title>
		<link>http://drilian.com/2009/02/25/lightning-bolts/comment-page-1/#comment-97</link>
		<dc:creator>Drilian</dc:creator>
		<pubDate>Mon, 12 Oct 2009 22:31:51 +0000</pubDate>
		<guid isPermaLink="false">http://drilian.com/?p=281#comment-97</guid>
		<description>Thanks :)   I&#039;m just using FRAPS for capture, works great for my purposes!</description>
		<content:encoded><![CDATA[<p>Thanks <img src='http://drilian.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />    I&#8217;m just using FRAPS for capture, works great for my purposes!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mi-ku</title>
		<link>http://drilian.com/2009/02/25/lightning-bolts/comment-page-1/#comment-96</link>
		<dc:creator>mi-ku</dc:creator>
		<pubDate>Mon, 12 Oct 2009 13:41:03 +0000</pubDate>
		<guid isPermaLink="false">http://drilian.com/?p=281#comment-96</guid>
		<description>You achieve really good results, thanks for sharing this simple and great idea :)

Btw. what software are You using for movie capture?</description>
		<content:encoded><![CDATA[<p>You achieve really good results, thanks for sharing this simple and great idea <img src='http://drilian.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Btw. what software are You using for movie capture?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rockabit &#187; Blog Archive &#187; Lightning in AS3</title>
		<link>http://drilian.com/2009/02/25/lightning-bolts/comment-page-1/#comment-82</link>
		<dc:creator>rockabit &#187; Blog Archive &#187; Lightning in AS3</dc:creator>
		<pubDate>Thu, 30 Jul 2009 15:39:27 +0000</pubDate>
		<guid isPermaLink="false">http://drilian.com/?p=281#comment-82</guid>
		<description>[...] the help of this post I created a simple but very effective random lightning generator in ActionScript [...]</description>
		<content:encoded><![CDATA[<p>[...] the help of this post I created a simple but very effective random lightning generator in ActionScript [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tried and failed</title>
		<link>http://drilian.com/2009/02/25/lightning-bolts/comment-page-1/#comment-73</link>
		<dc:creator>tried and failed</dc:creator>
		<pubDate>Thu, 18 Jun 2009 13:38:59 +0000</pubDate>
		<guid isPermaLink="false">http://drilian.com/?p=281#comment-73</guid>
		<description>Well, that&#039;s honestly cool, Drillian!

Incidentally, I started to write a lightning simulation in March (and didn&#039;t know of your work back then). I used the physically-based approach, dielectric breakdown (because I wanted to have the arcs avoid friends and target foes etc.) and thought I could optimize it to real-time. Boy was I wrong. After getting the naive version faster by x200 with considerable data structure-fu, SSE4 and multi-threading, I was still x3 away from real-time. So, now I use L-systems, too! :-)</description>
		<content:encoded><![CDATA[<p>Well, that&#8217;s honestly cool, Drillian!</p>
<p>Incidentally, I started to write a lightning simulation in March (and didn&#8217;t know of your work back then). I used the physically-based approach, dielectric breakdown (because I wanted to have the arcs avoid friends and target foes etc.) and thought I could optimize it to real-time. Boy was I wrong. After getting the naive version faster by x200 with considerable data structure-fu, SSE4 and multi-threading, I was still x3 away from real-time. So, now I use L-systems, too! <img src='http://drilian.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Drilian</title>
		<link>http://drilian.com/2009/02/25/lightning-bolts/comment-page-1/#comment-59</link>
		<dc:creator>Drilian</dc:creator>
		<pubDate>Tue, 19 May 2009 05:11:11 +0000</pubDate>
		<guid isPermaLink="false">http://drilian.com/?p=281#comment-59</guid>
		<description>I don&#039;t actually do it that way, but it&#039;d be a perfectly valid way to do so, so long as you batch the segments together (you want to draw as many segments as possible with each draw*primitive call, see the XNA batching code for some inspiration).

I render each bolt as a single triangle strip (one strip per each &quot;branch&quot; of the bolt), though I do it with a dynamic vertex buffer so the whole system of bolts gets rendered in a single draw call.</description>
		<content:encoded><![CDATA[<p>I don&#8217;t actually do it that way, but it&#8217;d be a perfectly valid way to do so, so long as you batch the segments together (you want to draw as many segments as possible with each draw*primitive call, see the XNA batching code for some inspiration).</p>
<p>I render each bolt as a single triangle strip (one strip per each &#8220;branch&#8221; of the bolt), though I do it with a dynamic vertex buffer so the whole system of bolts gets rendered in a single draw call.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adman</title>
		<link>http://drilian.com/2009/02/25/lightning-bolts/comment-page-1/#comment-58</link>
		<dc:creator>Adman</dc:creator>
		<pubDate>Tue, 19 May 2009 04:19:29 +0000</pubDate>
		<guid isPermaLink="false">http://drilian.com/?p=281#comment-58</guid>
		<description>Thanks for your response!

Stretching only the middle of the texture.  Got it.  I guessed this since posting this morning.

&quot;I changed from rendering each segment of lightning as its own separate rounded-off segment (as explained above) to rendering an entire bolt as a single strip (still using a similar method for rounding the edges).&quot;

So if I understand correctly, you render segments one at a time to an offscreen buffer using the stretched texture.  But because you use the MAX blend function, you don&#039;t get the bright joints.  And then you render the off-screen buffer to the back buffer in one shot.  Is that more or less right?

Adman</description>
		<content:encoded><![CDATA[<p>Thanks for your response!</p>
<p>Stretching only the middle of the texture.  Got it.  I guessed this since posting this morning.</p>
<p>&#8220;I changed from rendering each segment of lightning as its own separate rounded-off segment (as explained above) to rendering an entire bolt as a single strip (still using a similar method for rounding the edges).&#8221;</p>
<p>So if I understand correctly, you render segments one at a time to an offscreen buffer using the stretched texture.  But because you use the MAX blend function, you don&#8217;t get the bright joints.  And then you render the off-screen buffer to the back buffer in one shot.  Is that more or less right?</p>
<p>Adman</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Drilian</title>
		<link>http://drilian.com/2009/02/25/lightning-bolts/comment-page-1/#comment-57</link>
		<dc:creator>Drilian</dc:creator>
		<pubDate>Tue, 19 May 2009 00:39:34 +0000</pubDate>
		<guid isPermaLink="false">http://drilian.com/?p=281#comment-57</guid>
		<description>In the case of the glow texture, it was, at the time,just a gradient based on distance from the center (so it looked like a circle).  The trick was, the segments were rendered as triples of quads.  The middle quad was the line (which stretched the center of the texture out).  That is, from left to right, the U coordinates on the vertices went 0, 0.5, 0.5, 1...repeating the middle is what makes it a beam.  The outer two quads exist to display the rest of the texture to make it appear rounded.  The texture coordinates were basically:

(0, 0)........(0.5, 0)........(0.5, 0)........(1, 0)

(0, 1)........(0.5, 1)........(0.5, 1)........(1, 1)


As to what changes I made between Test 2 and Test 3, there were a few things:

I changed from rendering each segment of lightning as its own separate rounded-off segment (as explained above) to rendering an entire bolt as a single strip (still using a similar method for rounding the edges).  The problem with rendering the rounded segments was that the endpoints overlapped, causing it to render brighter in the center.  If it was dimmer than the super-bright that you see in test 2, you could actually see little circles where the overlaps were, which broke the illusion.

I added some code to jitter the generated points a little bit.  In Test 2, you&#039;ll notice that, once a bolt is on-screen, it&#039;s completely static until it fades out and a new one takes its place.  In Test 3 (and on), I jitter the points around just a little bit, to make it look a little more dynamic.

I also recalculate the splits off of the main bolt more frequently, which makes them jitter around even more, though I do think I eventually pulled that change back out.

Finally, never underestimate the visual power of changing colors!


I think that&#039;s a good list of everything that I changed.  Hope that helps!</description>
		<content:encoded><![CDATA[<p>In the case of the glow texture, it was, at the time,just a gradient based on distance from the center (so it looked like a circle).  The trick was, the segments were rendered as triples of quads.  The middle quad was the line (which stretched the center of the texture out).  That is, from left to right, the U coordinates on the vertices went 0, 0.5, 0.5, 1&#8230;repeating the middle is what makes it a beam.  The outer two quads exist to display the rest of the texture to make it appear rounded.  The texture coordinates were basically:</p>
<p>(0, 0)&#8230;&#8230;..(0.5, 0)&#8230;&#8230;..(0.5, 0)&#8230;&#8230;..(1, 0)</p>
<p>(0, 1)&#8230;&#8230;..(0.5, 1)&#8230;&#8230;..(0.5, 1)&#8230;&#8230;..(1, 1)</p>
<p>As to what changes I made between Test 2 and Test 3, there were a few things:</p>
<p>I changed from rendering each segment of lightning as its own separate rounded-off segment (as explained above) to rendering an entire bolt as a single strip (still using a similar method for rounding the edges).  The problem with rendering the rounded segments was that the endpoints overlapped, causing it to render brighter in the center.  If it was dimmer than the super-bright that you see in test 2, you could actually see little circles where the overlaps were, which broke the illusion.</p>
<p>I added some code to jitter the generated points a little bit.  In Test 2, you&#8217;ll notice that, once a bolt is on-screen, it&#8217;s completely static until it fades out and a new one takes its place.  In Test 3 (and on), I jitter the points around just a little bit, to make it look a little more dynamic.</p>
<p>I also recalculate the splits off of the main bolt more frequently, which makes them jitter around even more, though I do think I eventually pulled that change back out.</p>
<p>Finally, never underestimate the visual power of changing colors!</p>
<p>I think that&#8217;s a good list of everything that I changed.  Hope that helps!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
