<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Benny's Blog &#187; planet</title>
	<atom:link href="http://blog.projectnibble.org/tag/planet/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.projectnibble.org</link>
	<description>House Of Code</description>
	<lastBuildDate>Fri, 13 Aug 2010 15:06:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Papervision3D clouded planet Earth tutorial and source</title>
		<link>http://blog.projectnibble.org/2009/06/19/papervision3d-clouded-planet-earth-tutorial-and-source/</link>
		<comments>http://blog.projectnibble.org/2009/06/19/papervision3d-clouded-planet-earth-tutorial-and-source/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 17:00:17 +0000</pubDate>
		<dc:creator>Benny Bottema</dc:creator>
				<category><![CDATA[Papervision3D]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[clouds]]></category>
		<category><![CDATA[earth]]></category>
		<category><![CDATA[game design]]></category>
		<category><![CDATA[perlin noise]]></category>
		<category><![CDATA[planet]]></category>

		<guid isPermaLink="false">http://blog.projectnibble.org/?p=209</guid>
		<description><![CDATA[Here's a simulated Earth in Papervision3D, using realtime maintained clouds and a nice Earth glow.]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a tutorial about a possible way to create planets and indeed Earth. I&#8217;ll briefly explain the main textures used and from then on go through the code step-by-step to explain what I did and why.</p>
<p>I had to tone down the size and fps, and leave out the bumpmap for this demo because my Opera browser was halting when I added the other images and clouds swf demo :P</p>
<p>
<object width="500" height="250">
<param name="movie" value="http://projectnibble.org/dump/blog/papervision3d_earth/Planettutorial.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#000000"></param>
<embed type="application/x-shockwave-flash" width="500" height="250" src="http://projectnibble.org/dump/blog/papervision3d_earth/Planettutorial.swf" quality="high" bgcolor="#000000" wmode="window" menu="false" ></embed>
</object>
<br />
<span style="color:#999999">(notice the dynamic clouds and the glow around the globe)</span></p>
<ul>
<li><a href="http://projectnibble.org/dump/blog/papervision3d_earth/earthtutorial.rar">Download Clouded planet Earth source</a></li>
</ul>
<p>On my core 2 duo laptop I get about 20-25 fps whith a slightly larger stage size and the movie set to 30 fps. Although the planet looks very nice to me, I also realize it isn&#8217;t very practical for games or other realtime simulations. To get better fps, you can remove the bumpmap texture, replace the realtime clouds with a fixed texture, user fewer segments in the spheres, zoom out more, or use lower resolution textures for land- and cloud materials. A combination of two or more of these suggestions should easily get you above 35 fps.</p>
<p><span id="more-209"></span></p>
<h2>Used Ingredients</h2>
<p>I&#8217;ll get into the explanations later, but here are the ingredients used in this example:</p>
<p>- A sphere for geological data (land texture)<br />
- Another sphere for clouds<br />
- two planes that mask a perfect circle for the spheres<br />
- a plane that contains the fresnell glow on top</p>
<p>On the spheres I&#8217;ve used two phongshaded materials of which one has the land texture with a bumpmap for mountains and stuff, and the other contains the clouds texture with a runtime maintained perlin noise map applied to the alpha channel.</p>
<p>On the masking planes I&#8217;ve used a simple gradient circle shaped fill on the alpha channel.</p>
<p>On the glow plane I&#8217;ve used a gradient circle fill with a blue color and alpha channel for nice fading.</p>
<p>There&#8217;s also a pointlight in there that represents the sun (hits earth top-right).</p>
<h2>Main textures</h2>
<h3>Earth surface</h3>
<p>I took the public Earth surface texture (<a href="http://visibleearth.nasa.gov/view_set.php?categoryID=2364">Blue Marble</a>) from NASA, which I used on the sphere. On the rightside you can see it applied to the sphere with phongshader.</p>
<div style="width: 600px;">
<img src="http://projectnibble.org/dump/blog/papervision3d_earth/earth.jpg" alt="NASA's Earth surface texture" style="float:left;"/><img src="http://projectnibble.org/dump/blog/papervision3d_earth/phongshaded_geological_texture.png" alt="Phong shaded earth texture" style="height:188px; float:right"/>
</div>
<div style="clear:both"> </div>
<p>The shown image is about the half of the size I used for the used texture. One thing I&#8217;ve noticed is how large the texture needs to be to get some decent quality when applied to a sphere. Maybe there&#8217;s some room for optimization there&#8230;</p>
<h3>Clouds surface</h3>
<p><img src="http://projectnibble.org/dump/blog/papervision3d_earth/clouds.jpg" alt="NASA's cloud coverage texture"/></p>
<p>For the clouds I initially started with the public clouds texture from NASA, but when I applied the dynamic visibility map it turned out I didn&#8217;t get enough cloud coverage, because in effect now two visibly maps were applied: nature&#8217;s own, hardcoded in the texture, and my own applied in runtime.</p>
<p>So I ended up mirroring the original clouds texture in both dimensions to get much more cloud coverage, so that when I apply my own runtime visibility map I get about as much cloud coverage as in the original image. When applied to the sphere, it is also subject to the Phong shader I&#8217;ve used.</p>
<div style="background-image: url('http://projectnibble.org/dump/blog/papervision3d_earth/earth.jpg'); width: 600px; height: 188px; background-repeat: no-repeat; line-height: 0px;"> <br />
<img src="http://projectnibble.org/dump/blog/papervision3d_earth/clouds2.png" alt="Expanded cloud coverage with alpha channel" style="float:left"/><img src="http://projectnibble.org/dump/blog/papervision3d_earth/phongshaded_clouds_texture.png" alt="Phong shaded cloud coverage" style="height:188px; float:right"/>
</div>
<div style="clear:both"> </div>
<p>I&#8217;ve increased overall brightness to get more out of the less dense clouds, but I&#8217;ve also increased contrast to get the clear shapes of the clouds. Then I&#8217;ve applied the image itself as its own alpha channel and played around with its visibility until it became what you see above.</p>
<p>For the runtime visibility map I&#8217;ve used the ever amazing <a href="http://polygeek.com/1780_flex_explorer-bitmapdata-perlin-noise">perlin noise effect</a>. Since perlin noise works with a phase, I can use that to animate perlin noise and apply the results to the alpha channel of the clouds texture. On a straight texture, it looks like the following example:</p>
<p><a href="http://projectnibble.org/dump/blog/papervision3d_earth/realtimeclouds.html" target="_blank"><img src="http://projectnibble.org/dump/blog/papervision3d_earth/realtime_clouds.png" alt="Realtime clouds texture demo" /></a><br />
<span style="color:#999999">(click to see in action)</span></p>
<p>You can probably imagine how hard this must be to render each frame: a large clouds texture with alpha channel modified each frame by a new perlin noise map, with a phong shader applied. I see how this won&#8217;t work in a game, so I&#8217;ll probably use a fixed clouds texture in the future, but right now I&#8217;m satisfied with the effect.</p>
<h2>Code walkthrough</h2>
<p>Aside from the actual structuring of the code and Papervision3D usage, there are some interesting aspects to this demo. For example, there&#8217;s the Earth&#8217;s light glow, and the use of masking discs to disguise the low quality of the spheres. I&#8217;ve explained everything in details on this on the following page:</p>
<ul>
<li><a href="/papervision3d-clouded-planet-earth-tutorial-and-source-code-walkthrough/">Read the Earth code walkthrough</a></li>
</ul>
<p>If anyone has suggestion on how to improve performance, please let me know!</p>
<p><a href="http://blog.projectnibble.org/2009/06/19/papervision3d-clouded-planet-earth-tutorial-and-source/trackback/">trackback</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.projectnibble.org/2009/06/19/papervision3d-clouded-planet-earth-tutorial-and-source/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
