<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;CUYBSHo9eyp7ImA9WhBbEUw.&quot;"><id>tag:blogger.com,1999:blog-2884078902485203181</id><updated>2013-05-09T08:25:59.463-07:00</updated><category term="ogre3d" /><category term="graphics" /><category term="resource manager programming c++ stl templates ogre" /><category term="ogre3d terrain texture image pixelbuffer" /><category term="island" /><category term="open source" /><category term="atmosphere shader code ogre fxcomposer nvidia gpu" /><category term="planet mesh ogre 3d c++ quad tree" /><title>PETROCKET</title><subtitle type="html">game and graphics developer journal</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://petrocket.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://petrocket.blogspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>alex peterson</name><uri>http://www.blogger.com/profile/10147348345426496177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://4.bp.blogspot.com/_Tt-WoSrRoOs/SqMaDwSfsqI/AAAAAAAAABM/sdkcPTvVX7s/S220/IMG_0932.JPG" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>50</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/Petrocket" /><feedburner:info uri="petrocket" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;CUYBSHo8eCp7ImA9WhBbEUw.&quot;"><id>tag:blogger.com,1999:blog-2884078902485203181.post-4516961032945743725</id><published>2013-05-09T08:25:00.002-07:00</published><updated>2013-05-09T08:25:59.470-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-09T08:25:59.470-07:00</app:edited><title>Ludum Dare 26</title><content type="html">&lt;h4&gt;
Ludum Dare 26 Entry - Puzzle Cube&lt;/h4&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://www.ludumdare.com/compo/ludum-dare-26/?action=preview&amp;amp;uid=23254" imageanchor="1" style="margin-left: auto; margin-right: auto;" target="_blank"&gt;&lt;img border="0" height="180" src="http://4.bp.blogspot.com/-8YekbfNM_JQ/UYu5HKVrkfI/AAAAAAAAAKc/0UuwJs2qVrM/s320/puzzlecube.jpg" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Ludum Dare 26 - PuzzleCube&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
I decided to enter into the &lt;a href="http://www.ludumdare.com/compo/" target="_blank"&gt;48 compo Ludum Dare 26&lt;/a&gt; challenge where you make a theme-based game in 48 hours. &amp;nbsp;The theme was minimalism, and I was going to apply that to my game by making the game simple and the look simple too - never did get around to audio.&lt;br /&gt;
&lt;br /&gt;
You can download/play the game on Windows or OSX (sorry Linux) here:&lt;br /&gt;
&lt;a href="http://www.ludumdare.com/compo/ludum-dare-26/?action=preview&amp;amp;uid=23254"&gt;http://www.ludumdare.com/compo/ludum-dare-26/?action=preview&amp;amp;uid=23254&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
It's a simple puzzle game where you try to get the ball to the top of the cube by&amp;nbsp;maneuvering&amp;nbsp;it around and through the cube. &amp;nbsp;Also the rows of the cube rotate, though in this version they don't really work as intended and the player does not move with the rotated rows.&lt;br /&gt;
&lt;br /&gt;
The game was built with &lt;a href="http://ogre3d.org/" target="_blank"&gt;Ogre3D&lt;/a&gt; in Visual Studio 2010.&lt;br /&gt;
&lt;br /&gt;
I also live streamed my 5-6 hours of game dev on twitch here:&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #0000ee; font-family: Lucida Grande, Verdana, Arial, sans-serif;"&gt;&lt;span style="font-size: 12px;"&gt;&lt;u&gt;&lt;a href="http://www.twitch.tv/petrocket/videos"&gt;http://www.twitch.tv/petrocket/videos&lt;/a&gt;&lt;/u&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="color: #0000ee; font-family: Lucida Grande, Verdana, Arial, sans-serif;"&gt;&lt;span style="font-size: 12px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="text-align: start;"&gt;Since then I have converted the game to iOS for touch devices and implemented most of the missing features, so that may be released as a free or cheap game soon. &amp;nbsp;Here's a screenshot of the iOS version, still needs lots of luv, but it does have sound, rotating levels, infinite random levels and animations for all the movement.&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="text-align: start;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-dhfJACEmJCE/UYu73HA9XmI/AAAAAAAAAKs/C3HjHoNDEJw/s1600/iOS+Simulator+Screen+shot+May+9,+2013+11.07.12+AM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="213" src="http://3.bp.blogspot.com/-dhfJACEmJCE/UYu73HA9XmI/AAAAAAAAAKs/C3HjHoNDEJw/s320/iOS+Simulator+Screen+shot+May+9,+2013+11.07.12+AM.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;iOS version&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="text-align: start;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4&gt;
&lt;span style="text-align: start;"&gt;OGE &amp;amp; Planet Stuff&lt;/span&gt;&lt;/h4&gt;
&lt;div&gt;
&lt;span style="text-align: start;"&gt;I haven't touched this in a while since becoming frustrated with the stuttering issues. &amp;nbsp;I did make that physics sample that only has grid lines in it and when moving around the stuttering happens even in that minimal program. &amp;nbsp;I haven't been able to solve it yet and got preoccupied with working on our other iOS game and client work.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="text-align: start;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="text-align: start;"&gt;Here's a couple updated screenshots of our iOS game with the new characters and graphics&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="text-align: start;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-sgoRu_xhWC0/UYu-cfSSG2I/AAAAAAAAAK8/U488CHASOf4/s1600/iOS+Simulator+Screen+shot+May+9,+2013+11.14.24+AM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://4.bp.blogspot.com/-sgoRu_xhWC0/UYu-cfSSG2I/AAAAAAAAAK8/U488CHASOf4/s320/iOS+Simulator+Screen+shot+May+9,+2013+11.14.24+AM.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;iPad&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-KLu0Ge9K0Lc/UYu-mw9Ax7I/AAAAAAAAALE/IdQEZ9Id_wU/s1600/iOS+Simulator+Screen+shot+May+9,+2013+11.11.26+AM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="213" src="http://1.bp.blogspot.com/-KLu0Ge9K0Lc/UYu-mw9Ax7I/AAAAAAAAALE/IdQEZ9Id_wU/s320/iOS+Simulator+Screen+shot+May+9,+2013+11.11.26+AM.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;iPhone&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div&gt;
&lt;span style="text-align: start;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="text-align: start;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/Petrocket/~4/r3Z1tdXalMg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://petrocket.blogspot.com/feeds/4516961032945743725/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2884078902485203181&amp;postID=4516961032945743725" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/4516961032945743725?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/4516961032945743725?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Petrocket/~3/r3Z1tdXalMg/ludum-dare-26.html" title="Ludum Dare 26" /><author><name>alex peterson</name><uri>http://www.blogger.com/profile/10147348345426496177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://4.bp.blogspot.com/_Tt-WoSrRoOs/SqMaDwSfsqI/AAAAAAAAABM/sdkcPTvVX7s/S220/IMG_0932.JPG" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-8YekbfNM_JQ/UYu5HKVrkfI/AAAAAAAAAKc/0UuwJs2qVrM/s72-c/puzzlecube.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://petrocket.blogspot.com/2013/05/ludum-dare-26.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkAFQn48fSp7ImA9WhNWE0s.&quot;"><id>tag:blogger.com,1999:blog-2884078902485203181.post-5200646187805865798</id><published>2012-12-12T17:05:00.000-08:00</published><updated>2012-12-12T17:05:13.075-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-12-12T17:05:13.075-08:00</app:edited><title>OGE And Game Updates</title><content type="html">&lt;div class="separator" style="clear: both; text-align: left;"&gt;
Lots of game dev happening this fall, but most of it has been on our 2D port of the fireflies web game we made for the CDN contest last summer. &amp;nbsp;The team at &lt;a href="http://bearhanded.com/" target="_blank"&gt;Bearhanded&lt;/a&gt; (where I work) decided to take our web game and make it a mobile game to be released before Christmas. &amp;nbsp;Needless to say we decided to vastly expand on the original game, adding many more game objects, levels, pizzaz and eye candy yada yada.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-iJ_xIKcNU9Q/UMkidlSAKUI/AAAAAAAAAI4/jWEiM8sUCqk/s1600/fireflies-beta-level0.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="242" src="http://3.bp.blogspot.com/-iJ_xIKcNU9Q/UMkidlSAKUI/AAAAAAAAAI4/jWEiM8sUCqk/s320/fireflies-beta-level0.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Do you recognize the first level from our web version?&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
The graphics got a major overhaul, and as a minor note the characters in these Beta screenshots do not represent the final characters - those are still in progress. &amp;nbsp;We also decided to have 3 trees in the initial release; the first tree has daylight levels in the middle of the day, the second tree levels take place at dusk and the third at night, which means we're going to add a whole new aspect to the game - dynamic shadows and lighting!&lt;/div&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-6Iq_YBNM1Kc/UMkieZISlpI/AAAAAAAAAJA/BFBGSqgcwsI/s1600/fireflies-beta-level22.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="242" src="http://4.bp.blogspot.com/-6Iq_YBNM1Kc/UMkieZISlpI/AAAAAAAAAJA/BFBGSqgcwsI/s320/fireflies-beta-level22.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;This level is ALL developer art, but it shows the colored lights and shadows effects.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
There will also be pulley systems, bounce pads (disguised as red mushrooms), sap that you can sink into, enemy pushers, bombers, moths, worms, tubes, torches, cannons and maybe even more if we don't say "when" soon. &amp;nbsp;We've added so much that we had to push back our release till early 2013.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-KyG6vYFhcXg/UMkihCOr_sI/AAAAAAAAAJI/3yyjxA4mqLE/s1600/fireflies-beta-level5.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="241" src="http://1.bp.blogspot.com/-KyG6vYFhcXg/UMkihCOr_sI/AAAAAAAAAJI/3yyjxA4mqLE/s320/fireflies-beta-level5.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
This will be our companies first iOS game release so we're trying not to get our hopes up and just to make a game we all can be proud of, though recouping our investments would be nice.&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
Ye OGE (Open source Game Engine)&lt;/h4&gt;
&lt;a href="http://sourceforge.net/projects/oge" target="_blank"&gt;ye link&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
While all this 2D stuff has been going on, I've been working with Ralph on upgrading the libraries OGE uses and improving on the CMake build system. &amp;nbsp; At this point, it appears to be working on windows 7 and linux, but not on OSX.&lt;br /&gt;
&lt;br /&gt;
What's been holding back progress on the planet? &amp;nbsp;Well, I've kinda decided to give OGE a real run for the money and see if I can't make it work before giving up and rolling my own, simpler game engine. &amp;nbsp;I've got the latest planet stuff running in OGE, and have been creating sample projects to track down various major bugs like random thread/memory crash bugs and physics stutter bugs. &amp;nbsp;Ain't no fun to play a game that stutters and I've noticed that stuttering seems to be a common problem when working with physics engines. If you're a physics or threading guru I would love for you to take a look at those parts of the OGE code.&lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-oKBKTDL2ZkQ/UMkomnohLMI/AAAAAAAAAJY/QJC3rrXbgC8/s1600/gui_expermients.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="180" src="http://1.bp.blogspot.com/-oKBKTDL2ZkQ/UMkomnohLMI/AAAAAAAAAJY/QJC3rrXbgC8/s320/gui_expermients.jpg" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;This is my temporary MyGUI implementation in my planet test suite with the latest OGE (bogey tracker broken in this build!)&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-toIE1aMWhZs/UMkooJeSdlI/AAAAAAAAAJg/xAAy6DvzXDU/s1600/physics_sample.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="189" src="http://2.bp.blogspot.com/-toIE1aMWhZs/UMkooJeSdlI/AAAAAAAAAJg/xAAy6DvzXDU/s320/physics_sample.jpg" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;This is my little physics sample that I hope will help me nail the stutter bugs.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
I've also added a version of the OGRE profiler to OGE and added optional profiling blocks to all the major systems for now. &amp;nbsp;It doesn't really work like I would like, but it's better than nothing for now.&lt;br /&gt;
&lt;br /&gt;
No fav games of 2012 post because I mostly just play one game - Natural Selection 2! &amp;nbsp;They finally released it and it is super fun. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;img src="http://feeds.feedburner.com/~r/Petrocket/~4/9hdPZZP-ftg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://petrocket.blogspot.com/feeds/5200646187805865798/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2884078902485203181&amp;postID=5200646187805865798" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/5200646187805865798?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/5200646187805865798?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Petrocket/~3/9hdPZZP-ftg/oge-and-game-updates.html" title="OGE And Game Updates" /><author><name>alex peterson</name><uri>http://www.blogger.com/profile/10147348345426496177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://4.bp.blogspot.com/_Tt-WoSrRoOs/SqMaDwSfsqI/AAAAAAAAABM/sdkcPTvVX7s/S220/IMG_0932.JPG" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-iJ_xIKcNU9Q/UMkidlSAKUI/AAAAAAAAAI4/jWEiM8sUCqk/s72-c/fireflies-beta-level0.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://petrocket.blogspot.com/2012/12/oge-and-game-updates.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DE8FQ3k8fyp7ImA9WhJQFUU.&quot;"><id>tag:blogger.com,1999:blog-2884078902485203181.post-122648362519646520</id><published>2012-07-29T11:33:00.001-07:00</published><updated>2012-07-29T11:33:32.777-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-07-29T11:33:32.777-07:00</app:edited><title>CDN 2012 Game "Fireflies" Postmortem</title><content type="html">&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://fireflies.bearhanded.com/" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" target="_blank"&gt;&lt;img alt="Fireflies Game Home Screen" border="0" height="331" src="http://3.bp.blogspot.com/-lR93bVCrRJ0/UBVysYrIGFI/AAAAAAAAAHk/u5-RfC-hPiE/s400/fireflies-home.jpg" title="Fireflies Game" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
This year the whole &lt;a href="http://bearhanded.com/" target="_blank"&gt;Bearhanded &lt;/a&gt;team decided to participate in the &lt;a href="http://speedgame.christiandevs.com/" target="_blank"&gt;Christian Developers Network Speedgame&lt;/a&gt;.&amp;nbsp; We created an online multiplayer game called &lt;a href="http://fireflies.bearhanded.com/" target="_blank"&gt;Fireflies&lt;/a&gt;.&amp;nbsp; The theme this year was "testimony" and we decided we wanted to do a multiplayer game with HTML5 and &lt;a href="http://nodejs.org/" target="_blank"&gt;NodeJS&lt;/a&gt;.&amp;nbsp; What came out of our brainstorming was a simple puzzle game where players control various types of game pieces and use them to get to the exit in each level.&amp;nbsp; To accommodate the testimony aspect of the competition, we chose to show how each person's testimony is influenced by many people and so we created a sort of spiritual family tree in which each level starts out dark and after completing each level it lights up and the next level is unlocked.&amp;nbsp; The idea being that God uses many people in our lives and in their lives to reach us with the gospel.&amp;nbsp; When the whole tree is lit up, then the game is completed and the #parteh begins!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-PVBK5kQWV4c/UBVyttEm-yI/AAAAAAAAAHs/gLRILfkOnLg/s1600/fireflies-level1.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img alt="Fireflies Game Level 1" border="0" height="295" src="http://3.bp.blogspot.com/-PVBK5kQWV4c/UBVyttEm-yI/AAAAAAAAAHs/gLRILfkOnLg/s400/fireflies-level1.jpg" title="Fireflies Game Level 1" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Level 1 is very straight forward no?&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
There are 5 levels, starting with simple puzzles and ending in some rather difficult ones.&amp;nbsp; The final level is very difficult to beat by yourself, and even with three people it can take some time to finish.&lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-fmYdP5E0N-g/UBVyuFvvjNI/AAAAAAAAAH0/ngiM3-LD5MI/s1600/fireflies-level2.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img alt="Fireflies Game Level 2" border="0" height="298" src="http://4.bp.blogspot.com/-fmYdP5E0N-g/UBVyuFvvjNI/AAAAAAAAAH0/ngiM3-LD5MI/s400/fireflies-level2.jpg" title="Fireflies Game Level 2" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Every game needs a jumping puzzle! #lies&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;h3&gt;


Design&lt;/h3&gt;
We took our design cues from games like Lemmings,&amp;nbsp; &lt;a href="http://limbogame.org/" target="_blank"&gt;Limbo&lt;/a&gt;, &lt;a href="http://botanicula.net/" target="_blank"&gt;Botanicula&lt;/a&gt; and whatever was tossing around in our subconscious!&amp;nbsp; Chris was the primary designer and Aaron took his characters and animated them using After Effects.&amp;nbsp; Nate then took the animations and put them in the game.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;


Development&lt;/h3&gt;
Fireflies was built with the following technologies &amp;amp; libraries&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://nodejs.org/" target="_blank"&gt;NodeJS&lt;/a&gt; - server game logic&lt;/li&gt;
&lt;li&gt;&lt;a href="http://nowjs.com/" target="_blank"&gt;NowJS&lt;/a&gt; - server and client networking&lt;/li&gt;
&lt;li&gt;HTML5 - client audio and canvas support&lt;/li&gt;
&lt;li&gt;CSS3 - text glow effects and drop shadows &lt;/li&gt;
&lt;li&gt;&lt;a href="http://box2d.org/" target="_blank"&gt;Box2d&lt;/a&gt; - client physics&lt;/li&gt;
&lt;li&gt;&lt;a href="http://cocos2d-javascript.org/" target="_blank"&gt;Cocos2d-javascript&lt;/a&gt; - canvas drawing&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jquery.com/" target="_blank"&gt;jQuery&lt;/a&gt; - various UI elements&lt;/li&gt;
&lt;/ul&gt;
I did all of the Javascript for the server and client using &lt;a href="http://aptana.com/" target="_blank"&gt;Aptana&lt;/a&gt; as my editor.&amp;nbsp; This editor is free and good looking and the code completion is pretty decent.&amp;nbsp; It's basically another flavor of &lt;a href="http://eclipse.org/" target="_blank"&gt;Eclipse&lt;/a&gt;.&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-KMsl7Xh8d4M/UBV4jHgQbkI/AAAAAAAAAIE/dK8LArUh_LY/s1600/Screen+Shot+2012-07-01+at+7.26.59+PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="321" src="http://3.bp.blogspot.com/-KMsl7Xh8d4M/UBV4jHgQbkI/AAAAAAAAAIE/dK8LArUh_LY/s400/Screen+Shot+2012-07-01+at+7.26.59+PM.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;I love using dark text editor themes - if only it darkened the frame too #sigh&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
 &lt;/div&gt;
Chris used &lt;a href="http://mapeditor.org/" target="_blank"&gt;Tiled&lt;/a&gt; to build our levels and Nate used &lt;a href="http://zwopple.com/zwoptex/" target="_blank"&gt;Zwoptex&lt;/a&gt; to make our sprite sheets for our animations.&amp;nbsp; Both are free and support Cocos2d.&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-9aQsPdqZmw0/UBV5f7PfKvI/AAAAAAAAAIM/INpzoVsc35Q/s1600/fireflies_level_design1.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="261" src="http://4.bp.blogspot.com/-9aQsPdqZmw0/UBV5f7PfKvI/AAAAAAAAAIM/INpzoVsc35Q/s400/fireflies_level_design1.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Simple, but it works and it's free!&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;h3&gt;


Thoughts and ramblings&lt;/h3&gt;
For anyone interested in using any of these technologies you should be aware of several things I discovered:&lt;br /&gt;
- &lt;b&gt;Cocos2d-javascript is still very alpha&lt;/b&gt;, with lots of unimplemented features, many bugs or things that don't work in every browser, few working up-to-date examples and not very optimized.&amp;nbsp; All that being said, it does work for simple things and it performed fairly well for our little game.&amp;nbsp;&amp;nbsp; To integrate box2d physics with cocos2d I had to modify the level import code to support reading polygon objects.&amp;nbsp; Then in my client code I used the polygons to create box2d static shapes.&lt;br /&gt;
&lt;br /&gt;
- &lt;b&gt;NodeJS is really hot these days and can do some amazing things&lt;/b&gt;.&amp;nbsp; No complaints here except that it uses Javascript.&amp;nbsp; All the wonderful things you are used to with object oriented programming are imitated and asynchronous behaviors abound. &lt;br /&gt;
&lt;br /&gt;
- &lt;b&gt;NowJS allows you to easily synchronize variables between server and client and do remote procedure calls&lt;/b&gt;, however I quickly discovered that due to the asynchronous nature of&amp;nbsp; NodeJS, using variable synchronizing would give random bad values and I ended up having to use remote procedure calls for everything.&amp;nbsp; The groups feature is how we contain players in levels and it is super easy to do and useful and awesome.&lt;br /&gt;
&lt;br /&gt;
- &lt;b&gt;Box2d is made for realistic physics, not platformers&lt;/b&gt;.&amp;nbsp; I really had to punch it in the face to get it under any semblance of control and the player input still feels awkward and annoying to me.&amp;nbsp; Physics engines sound like an obvious choice when you're making a puzzle game, but when it comes to platformers you want a certain un-realistic feel for player input 9 times out of 10.&amp;nbsp; So to bring box2d to its knees I had to&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Use a ball for the players physics shape so it wouldn't get stuck and friction wouldn't be such an issue.&amp;nbsp;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;When the player is on the ground and not providing input, set the friction really high and use damping to slow the player down fast.&amp;nbsp; When they move ease up on the friction.&amp;nbsp; &lt;/li&gt;
&lt;li&gt;When in the air, turn off friction and use a different damping or they'll get stuck on vertical walls.&amp;nbsp;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Use impulses and not forces to get the player moving.&amp;nbsp;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Turn off restitution or just use a tiny bit or you'll bounce all crazy.&amp;nbsp;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Make sure your polygon world objects are created with the vertices in counterclockwise fashion or your player will fall through them.&lt;/li&gt;
&lt;li&gt;Make sure the player's foot sensor isn't too wide or they'll be able to wall jump - unless you want this behavior - super meat boy anyone?&lt;/li&gt;
&lt;/ul&gt;
That's it for now - you can play the game at &lt;a href="http://fireflies.bearhanded.com/"&gt;http://fireflies.bearhanded.com&lt;/a&gt; and the source code is available for download via the christiandevs.com website &lt;a href="http://talk.christiandevs.com/viewtopic.php?f=32&amp;amp;t=3784" target="_blank"&gt;here.&amp;nbsp;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
In other news I will post about the latest OGE/planet updates soon and I &lt;a href="http://www.packtpub.com/ogre-3d-1-7-application-development-cookbook/book" target="_blank"&gt;co-authored a book on OGRE&lt;/a&gt;.&amp;nbsp;&lt;img src="http://feeds.feedburner.com/~r/Petrocket/~4/z-WUmJOPYzY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://petrocket.blogspot.com/feeds/122648362519646520/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2884078902485203181&amp;postID=122648362519646520" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/122648362519646520?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/122648362519646520?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Petrocket/~3/z-WUmJOPYzY/cdn-2012-game-fireflies-postmortem.html" title="CDN 2012 Game &quot;Fireflies&quot; Postmortem" /><author><name>alex peterson</name><uri>http://www.blogger.com/profile/10147348345426496177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://4.bp.blogspot.com/_Tt-WoSrRoOs/SqMaDwSfsqI/AAAAAAAAABM/sdkcPTvVX7s/S220/IMG_0932.JPG" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-lR93bVCrRJ0/UBVysYrIGFI/AAAAAAAAAHk/u5-RfC-hPiE/s72-c/fireflies-home.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://petrocket.blogspot.com/2012/07/cdn-2012-game-fireflies-postmortem.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUUHSHg-fip7ImA9WhVRF0o.&quot;"><id>tag:blogger.com,1999:blog-2884078902485203181.post-8002508740962836410</id><published>2012-03-26T07:47:00.001-07:00</published><updated>2012-03-26T07:47:19.656-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-03-26T07:47:19.656-07:00</app:edited><title>Spacescape for OSX, OGE gui and 2011 Games</title><content type="html">Let's hit the "games I played in 2011" first - btw I'm stealing this idea from &lt;a href="http://ntdb.net/" target="_new"&gt;nathan @ ntdb.org&lt;/a&gt;. I think every game developer should be required to do a post on games they played once a year! Brilliant. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://naturalselection2.com/" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" target="_blank"&gt;&lt;img alt="" border="0" src="http://4.bp.blogspot.com/-Bf0zuSE8tPg/T3B-VcDm3AI/AAAAAAAAAGs/Yh3OpqVTWWA/s1600/ns2.png" title="Natural Selection 2" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h4&gt;

Natural Selection 2 - &lt;a href="http://naturalselection2.com/" target="_blank"&gt;naturalselection2.com &lt;/a&gt;&lt;/h4&gt;
This has been my go-to game of late because it just keeps getting better and better with each new Beta release! If you haven't heard of this game, it is a remake of the original which pits alien forces against marines in a FPS&amp;nbsp; &amp;amp; Strategy Game mash-up.&amp;nbsp; Each team has a commander who plays the game from a top down perspective and deals with building, upgrading and collecting resources for the team.&amp;nbsp; The commander on the marine side is also charged with directing, healing and keeping bullets available for his teammates.&amp;nbsp; Each side accumulates resources through the game by building structures on resource nodes throughout the map.&amp;nbsp; Resources can be spent on upgrades, or in the aliens case, for evolving into more sinister life forms.&lt;br /&gt;
&lt;br /&gt;
The only minor downside of this game is that it isn't OSX compatible yet so a bunch of my friends can't play it because they drink the Koolaid!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;img border="0" src="http://4.bp.blogspot.com/-weBMr80m1Es/T3B-Wz-F2-I/AAAAAAAAAHA/VEdJZP4dkXU/s1600/skyrim.png" /&gt;&lt;/div&gt;
&lt;h4&gt;

The Elder Scrolls V: Skyrim - &lt;a href="http://www.elderscrolls.com/skyrim/" target="_blank"&gt;&lt;cite&gt;elderscrolls.com/skyrim&lt;/cite&gt;&lt;/a&gt;&lt;/h4&gt;
This is obvious no? Great graphics, huge expanse with variable gameplay, and I would&amp;nbsp; be playing this a lot more if I weren't playing natural selection all the time.&amp;nbsp; I really like how this game looks and the openness of the gameplay, my only gripe is that every dungeon seems to be the same type of experience: kill bad guys, kill boss, come out alive.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;img border="0" src="http://4.bp.blogspot.com/-_LqTcj6yNpQ/T3B-TnPqtaI/AAAAAAAAAGg/jwEVV9efDAg/s1600/lfd2.png" /&gt;&lt;/div&gt;
&lt;h4&gt;

Left 4 Dead 2 - &lt;a href="http://www.l4d.com/" target="_blank"&gt;l4d.com&lt;/a&gt;&lt;/h4&gt;
I started playing this with friends at work and had a blast!&amp;nbsp; I did enjoy mindlessly killing zombies while drinking a beer after a day of twisting my brain this way and that.&amp;nbsp; Great way to unwind and I keep it in my back pocket in case I don't feel like playing TF2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://minecraft.net/" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" target="_blank"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/-TJAqmUxKGdE/T3B-Ui4jPDI/AAAAAAAAAGk/1qcx9F190e0/s1600/minecraft.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h4&gt;

Minecraft - &lt;a href="http://minecraft.net/" target="_blank"&gt;minecraft.net&lt;/a&gt;&lt;/h4&gt;
There are only two games that my wife and I both get and this is one of them.&amp;nbsp; The creativity in this is addictive and it is the only game I have like this.&amp;nbsp; I want to make a game as creative as this one some day - and I mean one that allows players to create and really use their imagination.&amp;nbsp; Love. It. &amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;img border="0" src="http://4.bp.blogspot.com/--OSFFzxUcVQ/T3B-WErlMBI/AAAAAAAAAG0/atSIt-EuT9k/s1600/portal2.png" /&gt;&lt;/div&gt;
&lt;h4&gt;

Portal 2 - &lt;a href="http://www.thinkwithportals.com/" target="_blank"&gt;thinkwithportals.com&lt;/a&gt;&lt;/h4&gt;
Played this in single mode and then co-op mode and enjoyed every minute.&amp;nbsp; I simply couldn't stop playing it and it was so refreshing to have an action game with humor in it.&amp;nbsp; I think Valve has the corner on the market in pulling together all the gameplay details and story line together, plus I just love puzzle games.&amp;nbsp; Co-op mode was icing on the cake and I wish there were more longer campaigns.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;img border="0" src="http://3.bp.blogspot.com/-U8wux9fw-9w/T3B-SQnMqkI/AAAAAAAAAGY/y_hehVsfUUI/s1600/civ5.png" /&gt;&lt;/div&gt;
&lt;h4&gt;

Civilization V - &lt;a href="http://civilization5.com/" target="_blank"&gt;civilization5.com&lt;/a&gt;&lt;/h4&gt;
Bought this on sale and the graphics look great, but I don't have enough time to play it.&amp;nbsp; My wife loves Civilization but her computer can't run this version as well, so she is sticking with IV for now.&amp;nbsp; The gameplay changes don't bother me, and I actually kind of like them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;img border="0" src="http://1.bp.blogspot.com/-Vw73pN9rgMg/T3B-XhTiswI/AAAAAAAAAHI/4L47EiyNhRc/s1600/tf2.png" /&gt;&lt;/div&gt;
&lt;h4&gt;

Team Fortress 2&amp;nbsp; - &lt;a href="http://tf2.com/" target="_blank"&gt;tf2.com&lt;/a&gt;&lt;/h4&gt;
Always a classic.&amp;nbsp; I play this mostly to unwind in a gore-free environment.&amp;nbsp; Going free-to-play was a good move for Valve - I bet most of their players purchased the game a decade ago anyways.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;b&gt;Honorable mentions...&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;
&lt;h4&gt;

Lord of the Rings Online&lt;/h4&gt;
This was the only MMO that I tried and I did enjoy it but you really have to spend a lot of time to do stuff in these types of games.&amp;nbsp; The graphics are decent for an MMO and there is certainly a big community, especially after they went free-to-play, but when the Star Wars MMO came out, a lot of people went on hiatus to try that.&amp;nbsp; Most of my guild friends did.&amp;nbsp; I quit playing in 2011 and will probably not return until I have significantly more free time.&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;

Tiny Wings&amp;nbsp;&lt;/h4&gt;
My favorite casual game.&amp;nbsp; Simple, carefree and fun.&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;

Sam &amp;amp; Max&lt;/h4&gt;
I play through these with my wife on the TV sometimes when we're bored, the internet is down and the like.&amp;nbsp; These are really fun little games and are fun to play with another person sitting beside you.&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;

Sonic 2 for iOS&amp;nbsp;&lt;/h4&gt;
A classic from when I was a kid and played it on a Sega hand held.&amp;nbsp; I cheat now to get to the higher levels that I couldn't get to when I was younger. &lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;

Counter-Strike: Source&amp;nbsp;&lt;/h4&gt;
I only downloaded this game and played it to see what was going on with the most popular online shooter game.&amp;nbsp; More of the same.&amp;nbsp; Graphics refresh was nice and I like the new maps, but I never really got into the original and stopped playing this one after a little while too.&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;

X3&lt;/h4&gt;
These games are like references for me and full of ideas I want to have at hand in space games that I make.&amp;nbsp; The story lines are teerrrrrriiibbbllleee and the voice acting is equally bad, but the space graphics are pretty amazing.&amp;nbsp; Eve Online also has some great space graphics, but I couldn't stand the gameplay and the MMO aspect was not enough to get me to pay a monthly subscription fee. &lt;br /&gt;
&lt;br /&gt;
So that's it for the games I played - I may have played other games, but those are the ones I remember.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;

OGE GUI Experiments&lt;/h3&gt;
&lt;br /&gt;
In the world of game development I've been doing more work with GUI's in &lt;a href="http://sourceforge.net/projects/oge" target="_blank"&gt;OGE&lt;/a&gt;. I added a console and a simple menu system to explore the ins and outs of the &lt;a href="http://mygui.info/" target="_blank"&gt;MyGUI&lt;/a&gt; library.&amp;nbsp; I suspect it is causing some framerate issues, but I haven't been able to track those down yet.&amp;nbsp; I'll probably post a video of the GUI additions later.&amp;nbsp; I've also spent time trying to better implement input and physics for moving.&amp;nbsp; In fact most of the GUI system I have created so far has been to allow me to tweak input parameters to get it to feel right.&amp;nbsp; It still doesn't.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;

Spacescape on OSX&lt;/h3&gt;
I actually managed to get a version of &lt;a href="http://alexcpeterson.com/portfolio/spacescape" target="_blank"&gt;Spacescape&lt;/a&gt; to compile on OSX and run, but it has some major issues with masks and the whole build process was hell.&amp;nbsp; Since I've been doing a lot of XCode programming with work projects I think I'm going to dispense with the QT framework and trying making a native Cocoa &lt;a href="http://alexcpeterson.com/portfolio/spacescape" target="_blank"&gt;Spacescape&lt;/a&gt; app for OSX and a native Win app for Windows - sorry Linux!&lt;br /&gt;
&lt;br /&gt;
I have learned, through opensourcing the code for &lt;a href="http://sourceforge.net/projects/spacescape" target="_blank"&gt;Spacescape&lt;/a&gt; and trying the donation thing, that besides it being a nice little feather in your hat, the only thing you get out of open sourcing and giving away a small project like Spacescape is a bunch of thank yous and a ton of support requests.&amp;nbsp; I intend to do a full write up with my thoughts on the whole business, but in short, I'm ready to attempt a different model.&amp;nbsp; I think the next iteration of Spacescape will be closed source and I'll use a pay-what-you want model with some minimum to cover fees, support and future development.&lt;img src="http://feeds.feedburner.com/~r/Petrocket/~4/Ige2RQxP-rk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://petrocket.blogspot.com/feeds/8002508740962836410/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2884078902485203181&amp;postID=8002508740962836410" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/8002508740962836410?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/8002508740962836410?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Petrocket/~3/Ige2RQxP-rk/spacescape-for-osx-oge-gui-and-2011.html" title="Spacescape for OSX, OGE gui and 2011 Games" /><author><name>alex peterson</name><uri>http://www.blogger.com/profile/10147348345426496177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://4.bp.blogspot.com/_Tt-WoSrRoOs/SqMaDwSfsqI/AAAAAAAAABM/sdkcPTvVX7s/S220/IMG_0932.JPG" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-Bf0zuSE8tPg/T3B-VcDm3AI/AAAAAAAAAGs/Yh3OpqVTWWA/s72-c/ns2.png" height="72" width="72" /><thr:total>4</thr:total><feedburner:origLink>http://petrocket.blogspot.com/2012/03/spacescape-for-osx-oge-gui-and-2011.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ak8GRHY-fyp7ImA9WhdXFEw.&quot;"><id>tag:blogger.com,1999:blog-2884078902485203181.post-5846506255534427857</id><published>2011-08-26T21:20:00.000-07:00</published><updated>2011-08-26T21:20:25.857-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-26T21:20:25.857-07:00</app:edited><title>CDN SpeedGame Postmortem!</title><content type="html">&lt;p&gt;Would you believe it -&lt;i&gt; I don't even have enough free time to make a little speedgame?!?&lt;/i&gt;  Maybe I was over ambitious but I'll get to that.&lt;/p&gt;

&lt;iframe width="560" height="349" src="http://www.youtube.com/embed/5ySilZEfwB4?hl=en&amp;fs=1" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;

&lt;p&gt;So my entry into the &lt;a href="http://talk.christiandevs.com/viewtopic.php?f=38&amp;amp;t=3365"" target="_new"&gt;Christian Developer Network's 2011 SpeedGame&lt;/a&gt; was going to be a &lt;a href="http://games.adultswim.com/robot-unicorn-attack-twitchy-online-game.html"" target="_new"&gt;Robot-Unicorn&lt;/a&gt; type game but with a cat.  We each had to pick a verse as a theme for our game and I chose &lt;a href="http://www.lolcatbible.com/index.php?title=Proverbs_15#24"&gt;Proverbs 15:24 - the lolcat Bible version&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;&lt;blockquote&gt;Proverbs 15:24 - Smrt kittehs go up, not down to da basement.&lt;/blockquote&gt;&lt;/p&gt;

&lt;p&gt;The basic gist of the verse is wise people are on a path leading upward and they turn away from death/hell beneath.  I made a game about a cat that falls asleep during a thunderstorm and dreams that it is running away from the storm, jumping from platform to platform as the storm gets closer and closer.  Really simple concept - I mean you just have two controls, jump and fire.  Jump to stay on the platforms and fire to deal with obstacles in your way.  The obstacles would slow you down and if your cat doesn't keep ahead of the storm approaching from the left side of the screen it gets soaked and you lose! This post is about the game dev process and the hiccups I had along the way that I'll share my solutions for and hopefully they will be helpful for other Ogre game devs.&lt;/p&gt;

&lt;p&gt;But first - a simple rundown of the tools and libraries I used for the game:&lt;/p&gt;

&lt;p&gt;
- &lt;a href="http://ogre3d.org/"" target="_new"&gt;Ogre 3D graphics engine&lt;/a&gt; (duh)&lt;br /&gt;
- &lt;a href="http://box2d.org/"" target="_new"&gt;Box2D &lt;/a&gt;physics&lt;br /&gt;
- &lt;a href="http://connect.creativelabs.com/openal/default.aspx"" target="_new"&gt;OpenAL &lt;/a&gt;audio&lt;br /&gt;
- &lt;a href="http://www.ogre3d.org/tikiwiki/Gorilla"" target="_new"&gt;Gorilla GUI&lt;/a&gt;&lt;br /&gt;
- &lt;a href="http://sourceforge.net/projects/wgois/"" target="_new"&gt;OIS &lt;/a&gt;for input&lt;br /&gt;
&lt;br /&gt;
- &lt;a href="http://blender.org/"" target="_new"&gt;Blender &lt;/a&gt;3D for models&lt;br /&gt;
- various free model and sound websites for the developer/test content&lt;br /&gt;
&lt;/p&gt;

&lt;p&gt;OK, so in the roughly 20 days we were given to do actual dev work on the project I decided to build a cross platform twitch based game.  That was the first hiccup.  I spent roughly 2/3 days just getting basic Ogre working on Windows, OSX and iOS.  What I did was download the SDK for Windows, OSX and iOS and then I set up this folder structure to house it all.&lt;/p&gt;
&lt;p&gt;
- design &amp;lt;-- all my design files&lt;br /&gt;
- GameiOS &amp;lt;-- iOS specific XCode project&lt;br /&gt;
- GameOSX &amp;lt;-- OSX specific XCode project&lt;br /&gt;
- GameWin &amp;lt;-- Visual Studio 2010 project&lt;br /&gt;
- lib &amp;lt;-- Box2D and OpenAL libs/source&lt;br /&gt;
- media &amp;lt;-- all models, sounds, graphics etc.&lt;br /&gt;
- src &amp;lt;-- all the shared source code&lt;br /&gt;
&lt;/p&gt;

&lt;h3&gt;Cross Platform Luv&lt;/h3&gt;

&lt;p&gt;Windows was cake to setup for just about all the libraries.  iOS was a bit more difficult because you have to compile the libraries for the right architecture to run on the device and different ones to run in the simulator. OSX had issues with just working at all.  I tried to use the XCode 4 templates to create a new project but even when I got it to compile it would &lt;a href="http://www.ogre3d.org/forums/viewtopic.php?f=4&amp;amp;t=64596&amp;amp;start=25#p435268"&gt;crash on startup&lt;/a&gt;.  Eventually I found that if I &lt;a href="http://www.ogre3d.org/forums/viewtopic.php?f=4&amp;amp;t=64596&amp;amp;start=25#p435360"&gt;moved the log manager initialization to a line after Ogre::Root was initialized&lt;/a&gt; then the crash went away and I could proceed. So all that debugging on OSX and the extra iOS configuring took me a couple days of free time.&lt;/p&gt;
&lt;p&gt;Oh, and &lt;a href="http://www.ogre3d.org/forums/viewtopic.php?f=2&amp;amp;t=63874"&gt;OSX fullscreen mode just doesn't seem to work&lt;/a&gt; -- which was annoying because I had to restart my computer to regain control.&lt;/p&gt;

&lt;p&gt;After getting the demo app working cross platform I put it all in a GIT repo (always a good idea to backup your code).&lt;/p&gt;

&lt;h3&gt;Physics Physics Physics&lt;/h3&gt;

&lt;p&gt;The next step was actually implementing the game, so I created prefab boxes in Ogre for the player model, the platforms, the bonuses and walls - everything and tried to hook up the Box2D physics.  It wasn't that hard to create a Box2D hull for all the objects because they were all square initially - however I ran into major issues getting the Box2D step() function to be framerate independant.  In fact, to this day the physics speeds are different on each platform even when I confine the framerate to roughly 60 fps, and this annoys me to no end!  I even got a helpful hint from azrialelf on the Ogre forums that he just created a framelistener and told Box2D to step with the evt.timeSinceLastFrame as the time delta.  This does work OK, but it still doesn't behave the same on all platforms and still seems to be affected by framerate somewhat.&lt;/p&gt;

&lt;p&gt;One other big gotcha with physics on iOS and OSX is that the demo app run the main loop with a timer set at 60fps where as the windows run loop is not timer based and runs as fast as your gfx card can go.  This really brought out the Physics step problems because my windows game would run at like 2000 fps and the physics wouldn't work at all while the iOS version would be really slow and the OSX version would be fast -- even though they used the same physics settings (they shared the same code).  My plan to address this is to just tweak it so it feels OK on each platform and not kill myself trying to figure it out.&lt;/p&gt;

&lt;h3&gt;OpenAL Lacks Decent File Import Capabilities&lt;/h3&gt;

&lt;p&gt;OpenAL was surprisingly easy to set up for all platforms.  The only issue I ran into was that there didn't seem to be builtin support for reading any audio formats - so I just grabbed some &lt;a href="http://enigma-dev.org/forums/index.php?topic=730.0"&gt;code off the internet for reading .wav files without ALUT&lt;/a&gt;.  I did find &lt;a href="http://www.subfurther.com/blog/2011/07/15/alutloadwavfile-or-better-yet-dont/"&gt;solutions that involved using iOS/OSX libraries&lt;/a&gt;, but I wanted something that would work across platform.  Eventually, I plan on adding the ogg vorbis file libraries and using those to load compressed audio files.&lt;/p&gt;

&lt;h3&gt;Blender?  I barely know her!&lt;/h3&gt;

&lt;p&gt;The next step after I got the basic physics working with some silly sounds and keyboard/mouse input, was to create some models in Blender and get them in game.  My idea was simple - create a platform object that had two meshes, one as the actual mesh and one that was the physics mesh.  Sounded simple but was actually pretty crazy. Turns out making an object with two submeshes is actually no big deal.  You just enter into edit mode for the object and select each mesh in turn and assign them to different materials.  I named one material Platform and the other Physics.  Then in my Ogre code after I imported the model I looked for the submesh with the Material name "Physics" and used the vertices from that Submesh for the Box2D Chainloop physics hull - oh yah, you have to use the latest version of Box2D from the repository to get this nifty hull type.  The crazy thing about this process was I had to walk the edges in the Physics mesh to form a closed loop for the Box2D hull. Fun fun.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://alexcpeterson.com/sites/default/files/images/blender-dev-shot.jpg" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/blender-dev-shot.project%20featured.jpg" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The biggest hiccup with Blender was getting the model with the two submeshes into Ogre with all the vertex data intact.  When I used the latest version of Blender and the latest version of the Ogre exporter for Blender the files that were generated used shared vertex data, and when&lt;a href="http://www.ogre3d.org/forums/viewtopic.php?f=2&amp;t=66147"&gt; I tried to read that shared vertex data in Ogre it didn't exist&lt;/a&gt;! Crash-o-la.  Solution? Use the older version of Blender and the older exporter that doesn't use shared vertex data and it works. Boom.&lt;/p&gt;

&lt;h3&gt;Silverback&lt;/h3&gt;

&lt;p&gt;I chose to use the &lt;a href="http://www.ogre3d.org/tikiwiki/Gorilla" target="_new"&gt;Gorilla GUI for Ogre&lt;/a&gt; because it was two files! - and I saw it in action in the Ogre forums and had to try it.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://alexcpeterson.com/sites/default/files/images/smrt_dev_4.jpg" target="_new"&gt;&lt;img src="http://alexcpeterson.com/sites/default/files/images/smrt_dev_4.project%20featured.jpg" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's super basic and you have to do everything, but it is fast and once you get a feel for what it can do it just makes sense.   I also found the demo console app to be really handy.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/GameWin%202011-08-26%2023-47-49-34.png" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/GameWin%202011-08-26%2023-47-49-34.project%20featured.png" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;In the End...&lt;/h3&gt;

&lt;p&gt;I just didn't have enough time to finish.  I wasn't supposed to be working on this alone, but my other teammates had other things come up.  None of the art or animations were made and I never added the background music and ambient sounds that would have really helped it.  Of course, even a legit background would have helped!&lt;/p&gt;
&lt;p&gt;I learned a lot from the experience and did have fun and plan on bringing the game to a releasable state in the future.  Until then I will return to OGE, My First Planet and Spacescape dev work in my free time.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Petrocket/~4/G_NmkdZymKI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://petrocket.blogspot.com/feeds/5846506255534427857/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2884078902485203181&amp;postID=5846506255534427857" title="6 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/5846506255534427857?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/5846506255534427857?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Petrocket/~3/G_NmkdZymKI/cdn-speedgame-postmortem.html" title="CDN SpeedGame Postmortem!" /><author><name>alex peterson</name><uri>http://www.blogger.com/profile/10147348345426496177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://4.bp.blogspot.com/_Tt-WoSrRoOs/SqMaDwSfsqI/AAAAAAAAABM/sdkcPTvVX7s/S220/IMG_0932.JPG" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://img.youtube.com/vi/5ySilZEfwB4/default.jpg" height="72" width="72" /><thr:total>6</thr:total><feedburner:origLink>http://petrocket.blogspot.com/2011/08/cdn-speedgame-postmortem.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CE8EQX87eip7ImA9WhdTEE0.&quot;"><id>tag:blogger.com,1999:blog-2884078902485203181.post-6866053268780074014</id><published>2011-07-06T18:40:00.000-07:00</published><updated>2011-07-06T18:40:00.102-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-06T18:40:00.102-07:00</app:edited><title>Let there be Bogeys</title><content type="html">&lt;a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/template_d%202011-07-06%2020-47-01-72.png" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/template_d%202011-07-06%2020-47-01-72.project%20featured.png" alt="bogeys" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;small&gt;(click to enlarge)&lt;/small&gt;&lt;br /&gt;
&lt;br /&gt;
It hasn't been very productive these last few months.  Got the usual family stuff that is, obviously, more important than this - but what I have done is experiment more with &lt;a href="http://mygui.info/" target="_new"&gt;MyGUI&lt;/a&gt; and added bogey trackers to some mine objects.  &lt;br /&gt;
&lt;br /&gt;
The bogey trackers are actually 2D GUIe widgets and each corner of a box surrounding a mine is it's own widget.  The performance ain't hot let me say that much.  I'd like to also try 3D bogey trackers and actually put billboards in 3d space around the targets, but I kinda doubt that will be any faster.&lt;br /&gt;
&lt;br /&gt;
I've also tried to smooth the input and framerate a bit more.  In the process I implemented a mouse look system for the ships that is similar to the one in X3.&lt;br /&gt;
&lt;br /&gt;
In the process I broke my multiplayer input so now client ships can't move, and there is still a bit of jitter when moving fast, ugh.  I plan on attempting to fix the network bug and then do some renovations to the lasers &amp; thrusters.  After that it's some basic menus - joy!  One of those menus should be a menu to jump to another planet or solar system, so that will open a whole new can 'o worms.&lt;br /&gt;
&lt;br /&gt;
Here's a little vid I recorded - just shows the bogey tracker.&lt;br /&gt;
&lt;br /&gt;
&lt;iframe width="560" height="349" src="http://www.youtube.com/embed/JUr6shDSs7c" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;&lt;img src="http://feeds.feedburner.com/~r/Petrocket/~4/ecE_N5l-CCE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://petrocket.blogspot.com/feeds/6866053268780074014/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2884078902485203181&amp;postID=6866053268780074014" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/6866053268780074014?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/6866053268780074014?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Petrocket/~3/ecE_N5l-CCE/let-there-be-bogeys.html" title="Let there be Bogeys" /><author><name>alex peterson</name><uri>http://www.blogger.com/profile/10147348345426496177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://4.bp.blogspot.com/_Tt-WoSrRoOs/SqMaDwSfsqI/AAAAAAAAABM/sdkcPTvVX7s/S220/IMG_0932.JPG" /></author><thr:total>4</thr:total><feedburner:origLink>http://petrocket.blogspot.com/2011/07/let-there-be-bogeys.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkMHQ308cSp7ImA9Wx9bEks.&quot;"><id>tag:blogger.com,1999:blog-2884078902485203181.post-3507537851352737560</id><published>2011-02-20T20:57:00.000-08:00</published><updated>2011-02-20T21:00:32.379-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-02-20T21:00:32.379-08:00</app:edited><title>Helpful Mercurial Tips</title><content type="html">I spent a good bit of time trying to setup a &lt;a href="http://mercurial.selenic.com/" target="_new"&gt;Mercurial &lt;/a&gt;repository server on a Windows 7 Server that uses &lt;a href="http://www.wampserver.com/en/" target="_new"&gt;wamp&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
I had to install &lt;a href="http://tortoisehg.bitbucket.org/" target="_new"&gt;TortoiseHg &lt;/a&gt;and &lt;a href="http://python.org/" target="_new"&gt;Python 2.6.6&lt;/a&gt; and the latest &lt;a href="http://mercurial.selenic.com/" target="_new"&gt;Mercurial &lt;/a&gt;in that order so that &lt;a href="http://mercurial.selenic.com/" target="_new"&gt;Mercurial &lt;/a&gt;would add it's libraries to the &lt;a href="http://python.org/"&gt;Python &lt;/a&gt;install. All that is important because the library.zip file that comes with &lt;a href="http://tortoisehg.bitbucket.org/" target="_new"&gt;TortoiseHg&lt;/a&gt; doesn't have the right &lt;a href="http://python.org/" target="_new"&gt;Python &lt;/a&gt;modules you need to make the &lt;a href="http://mercurial.selenic.com/" target="_new"&gt;Mercurial &lt;/a&gt;hgweb.cgi work. Also I needed to install &lt;a href="http://code.google.com/p/modwsgi/" target="_new"&gt;mod_wsgi&lt;/a&gt; on the &lt;a href="http://www.wampserver.com/en/" target="_new"&gt;wamp &lt;/a&gt;server which uses Apache.&amp;nbsp; Lastly, here is my hgweb.cgi&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; #!c:/Python26/python.exe&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; #&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; # An example hgweb CGI script, edit as necessary&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; # See also http://mercurial.selenic.com/wiki/PublishingRepositories&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; import os; os.environ["HGRCPATH"] = "C:\wamp\www\hg"&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Path to repo or hgweb config to serve (see 'hg help hgweb')&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; config = "c:\\wamp\\www\\hg\\hgweb.config"&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Uncomment to send python tracebacks to the browser if an error occurs:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; import cgitb; cgitb.enable()&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; from mercurial import demandimport; demandimport.enable()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; from mercurial.hgweb import hgweb, hgwebdir, wsgicgi&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; application = hgwebdir(config)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; wsgicgi.launch(application)&lt;img src="http://feeds.feedburner.com/~r/Petrocket/~4/0XmgouJ4IFU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://petrocket.blogspot.com/feeds/3507537851352737560/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2884078902485203181&amp;postID=3507537851352737560" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/3507537851352737560?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/3507537851352737560?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Petrocket/~3/0XmgouJ4IFU/helpful-mercurial-tips.html" title="Helpful Mercurial Tips" /><author><name>alex peterson</name><uri>http://www.blogger.com/profile/10147348345426496177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://4.bp.blogspot.com/_Tt-WoSrRoOs/SqMaDwSfsqI/AAAAAAAAABM/sdkcPTvVX7s/S220/IMG_0932.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://petrocket.blogspot.com/2011/02/helpful-mercurial-tips.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkQNQngyfSp7ImA9Wx9bEks.&quot;"><id>tag:blogger.com,1999:blog-2884078902485203181.post-2443591464439788337</id><published>2011-02-20T20:54:00.000-08:00</published><updated>2011-02-20T20:59:53.695-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-02-20T20:59:53.695-08:00</app:edited><title>Nobody Likes To Fly In Space - They Want To Drive</title><content type="html">There are a lot of arguments out there about how much "fun" realistic space physics are and I am a believer that it's annoying to have to deal with so many ways to maneuver and the concept of the ship pointing one direction while flying another with the engines off!&amp;nbsp; So, I'd like to share with you how I decided to implement &lt;i&gt;&lt;b&gt;unrealistic &lt;/b&gt;&lt;/i&gt;but "fun" spaceship flying. Oh, and back in the day&lt;a href="http://alexcpeterson.com/portfolio/cassinidivision" target="_new"&gt; I did participate in the making of a game with realistic space physics&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://alexcpeterson.com/portfolio/cassinidivision" imageanchor="1" style="margin-left: auto; margin-right: auto;" target="_new"&gt;&lt;img border="0" src="http://alexcpeterson.com/sites/default/files/images/cassini_blue_ship.project%20featured.jpg" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Cassini Division 2004&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
To start with lets consider that most games use some kind of physics engine and those deal in forces primarily so we need to make each of the engines apply forces to the spaceship.&amp;nbsp; But we can't stop there because that is the realistic way and controlling a for-real spaceship can be so challenging that you don't have much time to deal with anything else like, say, shooting.&amp;nbsp; I mean, just think about all the controls you have to have in your ship to make your ship rotate in any direction and move in any direction!&amp;nbsp; Now, I have considered a game where each spaceship has a pilot and a separate player as the gunner, but lets not get distracted...&lt;br /&gt;
&lt;br /&gt;
The easiest way to fly in space besides autopilot is to make it like driving - something that most people are used to.&amp;nbsp;&amp;nbsp; You see, I want two things when I'm driving:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;I usually want to be traveling in the direction my spaceship is pointing&lt;/li&gt;
&lt;li&gt;When I hit the gas I want the spaceship to move, and when I let go I want it to come to a stop.&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
Handling the first issue is simple after you handle the second issue, just make the back engine the biggest and don't go putting big engines on the sides or front.&amp;nbsp; The second issue is not too difficult either - apply dampening to the spaceship so that it acts more like it is moving through liquid/air than through a vacuum.&lt;br /&gt;
&lt;br /&gt;
By applying the dampening we ruin realistic space physics, but make spaceships easier to control.&amp;nbsp; Now since the ship is really moving through some kind of liquid/air it takes constant force to keep it moving and we now have an excuse for a fuel gauge and as an added bonus, when the spaceship enters the atmosphere or ocean we can use the same controls just fiddle with the amount of dampening.&lt;br /&gt;
&lt;br /&gt;
Last thing I'd like to mention is the issue of 'max speed'.&amp;nbsp; When we have dampening then the 'max speed' of a spaceship makes more sense and we have the excuse for putting spaceships in the game with more powerful engines - where with realistic space games you can fly incredibly fast in a tin can with the help of some gravity, you just can't start or stop fast.&lt;br /&gt;
&lt;br /&gt;
Oh, and collisions should work with our physics plus dampening model too and keep all that space debris from moving off into infinity where nobody could tell that it was once part of a destroyed spaceship.&lt;br /&gt;
&lt;br /&gt;
On a more practical note, here is how I implemented the above physics model in &lt;a href="https://sourceforge.net/apps/mediawiki/oge/index.php?title=Main_Page" target="_new"&gt;OGE &lt;/a&gt;with &lt;a href="http://bulletphysics.org/" target="_new"&gt;Bullet&lt;/a&gt;.&lt;br /&gt;
1. Use btRigidBody::setDampening() to set the dampening on the Bullet rigid&amp;nbsp; body object&lt;br /&gt;
2. Use Bullet's internal tick callback to apply constant forces before the dampening is applied:&lt;br /&gt;
btRigidBody-&amp;gt;applyCentralImpulse(velocity * deltaTime);&lt;br /&gt;
btRigidBody-&amp;gt;applyTorqueImpulse(angular * deltaTime);&lt;img src="http://feeds.feedburner.com/~r/Petrocket/~4/nB5o_4E6z3Q" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://petrocket.blogspot.com/feeds/2443591464439788337/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2884078902485203181&amp;postID=2443591464439788337" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/2443591464439788337?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/2443591464439788337?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Petrocket/~3/nB5o_4E6z3Q/nobody-likes-to-fly-in-space-they-want.html" title="Nobody Likes To Fly In Space - They Want To Drive" /><author><name>alex peterson</name><uri>http://www.blogger.com/profile/10147348345426496177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://4.bp.blogspot.com/_Tt-WoSrRoOs/SqMaDwSfsqI/AAAAAAAAABM/sdkcPTvVX7s/S220/IMG_0932.JPG" /></author><thr:total>2</thr:total><feedburner:origLink>http://petrocket.blogspot.com/2011/02/nobody-likes-to-fly-in-space-they-want.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C04FSHk9cCp7ImA9Wx9XEUs.&quot;"><id>tag:blogger.com,1999:blog-2884078902485203181.post-7465777250961016281</id><published>2011-01-04T09:25:00.000-08:00</published><updated>2011-01-04T09:25:19.768-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-01-04T09:25:19.768-08:00</app:edited><title>A New Year With New Goals?</title><content type="html">The end of last year was somewhat unproductive for me on the planet front.&amp;nbsp; I was looking back at my calendar today and see that I spent most of my time doing real life work and being a dad.&amp;nbsp; I also spent a lot of free time playing games too instead of making them.&lt;br /&gt;
&lt;br /&gt;
The two things I did work on that were planet related were &lt;a href="http://sourceforge.net/projects/oge/"&gt;OGE&lt;/a&gt; and &lt;a href="http://alexcpeterson.com/portfolio/spacescape"&gt;Spacescape&lt;/a&gt;.&amp;nbsp; I made the developer list for &lt;a href="http://sourceforge.net/projects/oge/"&gt;OGE&lt;/a&gt;, and I might be the only active developer for now, but I hope that changes soon.&amp;nbsp; I spent most of my &lt;a href="http://sourceforge.net/projects/oge/"&gt;OGE&lt;/a&gt; developer time working on the &lt;a href="http://www.jenkinssoftware.com/raknet/"&gt;RakNet&lt;/a&gt; networking and &lt;a href="http://www.bulletphysics.org/"&gt;Bullet&lt;/a&gt; physics systems and have been trying to get a minimal networking example working with a small player controlled spaceship, some exploding mines and a planet.&amp;nbsp; Let's just say that networking + physics debugging can be annoying and I had no idea that making a spaceship NOT have Newtonian physics in space would be so challenging! - more on that later, maybe.&lt;br /&gt;
&lt;br /&gt;
Spacescape got some bug fixes and minor features and I added the CMake build system to ease the pain for new developers and for me each time I develop on a new machine, especially one with a different OS like OSX. I also got my first and only Spacescape donation woohoo! and a bunch of feature requests, support requests and compliments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On the table for this year are:&lt;br /&gt;
- Finish the OGE networking space example&lt;br /&gt;
- Re-asses and tackle placing objects on planets (vegetation, buildings, players etc)&lt;br /&gt;
- Fix planet underwater shaders &lt;br /&gt;
- Add simple clouds to planets&lt;br /&gt;
- Make the networking space example into a small game&lt;br /&gt;
- Release the planet plugin source&lt;br /&gt;
- Port Spacescape to OSX&lt;br /&gt;
- Divide Spacescape into "basic" and "advanced" modes so it is loads easier to use for the casual user.&lt;br /&gt;
&lt;br /&gt;
Other possibilities include:&lt;br /&gt;
- Use acko.net method for computing planet normal maps&lt;br /&gt;
- Figure out additional light maps so we can have lights on the dark side of the planet&lt;br /&gt;
- Re-asses how distance/scale is handled when approaching the limits.&lt;br /&gt;
- Form a team of like-minded individuals&lt;br /&gt;
&lt;br /&gt;
Hope you have a great start to the new year!&lt;img src="http://feeds.feedburner.com/~r/Petrocket/~4/Nndh8gA5P9M" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://petrocket.blogspot.com/feeds/7465777250961016281/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2884078902485203181&amp;postID=7465777250961016281" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/7465777250961016281?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/7465777250961016281?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Petrocket/~3/Nndh8gA5P9M/new-year-with-new-goals.html" title="A New Year With New Goals?" /><author><name>alex peterson</name><uri>http://www.blogger.com/profile/10147348345426496177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://4.bp.blogspot.com/_Tt-WoSrRoOs/SqMaDwSfsqI/AAAAAAAAABM/sdkcPTvVX7s/S220/IMG_0932.JPG" /></author><thr:total>4</thr:total><feedburner:origLink>http://petrocket.blogspot.com/2011/01/new-year-with-new-goals.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0QBQHo9cSp7ImA9WxFUGUw.&quot;"><id>tag:blogger.com,1999:blog-2884078902485203181.post-5708755194286728765</id><published>2010-06-30T09:29:00.000-07:00</published><updated>2010-06-30T09:29:11.469-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-06-30T09:29:11.469-07:00</app:edited><title>Planet Water Shader Tests &amp; OGE</title><content type="html">First of all, I haven't posted in a while because I've been sick, then I got my new dev machine and was busy setting it up and playing games on it and other real life stuff.&lt;br /&gt;
&lt;br /&gt;
So, water for this small planet has been difficult for me and I've tried a couple approaches and have yet to get something I like.&lt;br /&gt;
&lt;br /&gt;
What I want:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;reflections, refraction, transparency, specular, normal mapping&lt;/li&gt;
&lt;li&gt; under water fog&lt;/li&gt;
&lt;li&gt;fog color changes based on depth and distance&lt;/li&gt;
&lt;/ul&gt;Here's what I've got so far (no reflection or refraction)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;object height="340" width="560"&gt;&lt;param name="movie" value="http://www.youtube.com/v/PdqRk1RBtA4&amp;hl=en_US&amp;fs=1&amp;rel=0&amp;color1=0x3a3a3a&amp;color2=0x999999"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/PdqRk1RBtA4&amp;hl=en_US&amp;fs=1&amp;rel=0&amp;color1=0x3a3a3a&amp;color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;
&lt;a href="http://www.youtube.com/watch?v=PdqRk1RBtA4" target="_new"&gt;Video of planet water on YouTube&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Reflection and Refraction&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
There is no reflection or refraction on the water because I don't know how I will manage that on a curved surface yet.  I think what I will try first is only doing water reflection and refraction when you're close enough to the water that it appears to be more flat so I can use conventional techniques.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Underwater Fog&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
To support underwater I applied a fog to the pixel shader for the terrain based on the terrain depth under water.&amp;nbsp; I have a outward facing sphere with a shader for transparency, normal mapping and specular.&amp;nbsp; I also have an inward facing sphere with a shader for when you are underwater looking up at the surface from below.&lt;br /&gt;
&lt;br /&gt;
Unfortunately, the fog shader on the terrain does not line up perfectly with the underwater inward facing sphere so you see cracks at the water edge where there is no fog.&amp;nbsp; I think I can only fix this issue with post processing.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;New Game Dev Machine&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
I got a new developer machine with an i7 processor and Radeon 5770.&amp;nbsp; I tried to choose a middle of the road graphics card.&amp;nbsp; You can see the &lt;a href="http://www.eggxpert.com/forums/thread/632787.aspx" target="_new"&gt;new game dev machine specs and discussion on eggxpert.com&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;OGE&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Lastly, I've spent a some time working with &lt;a href="http://oge.sourceforge.net/" target="_new"&gt;OGE&lt;/a&gt; which stands for "Open Game Engine".&amp;nbsp;&amp;nbsp;&amp;nbsp; I've created a small &lt;a href="http://www.jenkinssoftware.com/raknet/index.html" target="_new"&gt;RakNet&lt;/a&gt; plugin for it and have been trying to get a little client/server action going.&amp;nbsp; This is a potential game engine that I might adopt for MyFirstPlanet, at least in the development stages to do all the audio, graphics, user interface, networking, gameplay, physics, and scripting that I would have to build myself.&amp;nbsp; It supports &lt;a href="http://ogre.org/" target="_new"&gt;OGRE&lt;/a&gt; as a graphics engine plugin so I shouldn't have to rewrite any of my graphics code.&lt;br /&gt;
&lt;br /&gt;
I'll try to post again when I have a video to show of the network tests.&amp;nbsp; It will mostly just be a couple clients on a server flying ships around in space over a planet.&lt;img src="http://feeds.feedburner.com/~r/Petrocket/~4/72UDVGNXwxk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://petrocket.blogspot.com/feeds/5708755194286728765/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2884078902485203181&amp;postID=5708755194286728765" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/5708755194286728765?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/5708755194286728765?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Petrocket/~3/72UDVGNXwxk/planet-water-shader-tests-oge.html" title="Planet Water Shader Tests &amp; OGE" /><author><name>alex peterson</name><uri>http://www.blogger.com/profile/10147348345426496177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://4.bp.blogspot.com/_Tt-WoSrRoOs/SqMaDwSfsqI/AAAAAAAAABM/sdkcPTvVX7s/S220/IMG_0932.JPG" /></author><thr:total>2</thr:total><feedburner:origLink>http://petrocket.blogspot.com/2010/06/planet-water-shader-tests-oge.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0MNRngzeSp7ImA9WxFXFEo.&quot;"><id>tag:blogger.com,1999:blog-2884078902485203181.post-8161770696191626514</id><published>2010-05-05T17:44:00.000-07:00</published><updated>2010-05-21T13:58:17.681-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-05-21T13:58:17.681-07:00</app:edited><title>Planet Terrain Shader With Atmosphere</title><content type="html">Before you read this post, if you have not watched Ysaneya's latest tech demo video  &lt;a href="http://infinity-universe.com/Infinity/index.php?option=com_content&amp;task=view&amp;id=113&amp;Itemid=93" target="_new"&gt;go watch it now&lt;/a&gt;!  It is amazing!&lt;br /&gt;
&lt;br /&gt;
In the &lt;a href="http://petrocket.blogspot.com/2010/04/atmosphere-shader-update-and-treegrass.html" target="_new"&gt;previous posts&lt;/a&gt; I described and published my latest atmosphere shader and I got some useful feedback and requests for information, which I thought I should include here:&lt;br /&gt;
&lt;br /&gt;
- The atmosphere shader is applied to an inverted sphere that is drawn before the planet.  This means that if you have a single atmosphere shell and a planet with no atmosphere shader added to it, then you will just see the atmosphere effect behind the planet.  I go into how I've added worked in atmosphere shader code into my terrain shader later on in the post you are reading now.&lt;br /&gt;
&lt;br /&gt;
- In the atmosphere shader the camera and light should be in object space, as should the vertices.&lt;br /&gt;
&lt;br /&gt;
- The atmosphere is still not fully opaque when on the sunny side.  It is opaque (not see through) at the horizon and gets slightly transparent as it approaches the sun so some stars still show through which may not be desired.  I plan on addressing this later when I add other planets and moons.  I'm concerned that if I make the atmosphere too opaque then you won't see the moon or planet (or large space ships!) out there, and if I make the atmosphere too transparent then you'll see too many stars on the day side.  I may just end up darkening the skybox as the user gets on the daylight side of the planet, but I haven't gotten there yet.&lt;br /&gt;
&lt;br /&gt;
Now, about the planet terrain.  I create an 8 way blend look up table based on terrain slope and height.  When the planet is first created I render to texture a medium resolution texture (512x512 currently) that blends 8 textures based on this look up table.  When viewing the planet from far away I display this medium resolution texture, then when the camera approaches the surface I blend between this medium resolution texture and a shader that actually blends the 8 textures per frame, which is slower but looks better close up.&lt;br /&gt;
&lt;br /&gt;
Too add the atmosphere effect to my terrain in the vertex shader I basically calculate the amount of atmosphere fog like this:&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;// atmosphere fog / haze attenuation
float3 camToPos = position.xyz- camPos.xyz;
float camToPosDist = length(camToPos);
float visibilityDistance = min(AtmosphereHeight,VisibilityDistance);
oAttenuation = saturate((camToPosDist - VisibilityDistance)/ (AtmosphereHeight + visibilityDistance));
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
position - The vertex position in object space&lt;br /&gt;
camPos - The camera position in object space&lt;br /&gt;
AtmosphereHeight - Atmosphere sphere radius minus terrain sphere radius.&lt;br /&gt;
VisibilityDistance - At distance = 0, fog is 0 at distance = VisibilityDistance, fog = 1&lt;br /&gt;
&lt;br /&gt;
In my fragment shader I do this:&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;// gradient0 is a look up table like atmosphere gradient but two pixels high. 
// Top row is atmosphere gradient and bottom row is sun color gradient
float4 sunColor = tex2D(gradient0,float2(uv2,1));
float4 atmosphereColor = tex2D(gradient0,float2(uv2,0));

// how transparent is the atmosphere?
float transparency = min(AtmosphereTransparency,attenuation); 

// get diffuse amount from 8 way texture blend and apply lighting with normals
// or shadow map/light map
...

// get atmosphere contribution    
float3 atmosphereAmt = (atmosphereColor * sunColor * (transparency + (transparency * shadow)));

// add in atmosphere
outColor.rgb = (diffuse.rgb * sunColor * (1.0 - transparency)) + atmosphereAmt;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
I use a constant called AtmosphereTransparency to make sure that the atmosphere contribution is no more than a certain amount.  I use 0.3 because it looks OK, but on a really dense atmosphere you might want a higher amount.&lt;br /&gt;
&lt;br /&gt;
Here's the full terrain shader you see in the videos when the camera is on the surface - this is the one I use for &lt;a href="http://ogre3d.org" target="_new"&gt;Ogre3d&lt;/a&gt; not for FX Composer.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;void main_vp( float4 position : POSITION,
float2 uv       : TEXCOORD0,

out float4 oPosition : POSITION,
out float2 oUV1    : TEXCOORD0,
out float3 oLightDir : TEXCOORD1,
out float  oBlendAmt : TEXCOORD2,
out float  oUV2    : TEXCOORD3,
out float  oAttenuation: TEXCOORD4,

uniform float4x4 worldViewProjMatrix,
uniform float4 camPos,
uniform float4 lightPos,
uniform float AtmosphereHeight,
uniform float VisibilityDistance     
)
{
oPosition = mul(worldViewProjMatrix, position);
oUV1 = uv;

// directional light
oLightDir = normalize(lightPos.xyz);

// dot product of position and light in range 0..1
float posLength = length(position.xyz);
float3 normal = position.xyz / posLength;
oUV2 = (dot(oLightDir, normal) + 1.0) * 0.5;

// atmosphere fog / haze attenuation
float3 camToPos = position.xyz- camPos.xyz;
float camToPosDist = length(camToPos);
float visibilityDistance = min(AtmosphereHeight,VisibilityDistance);
oAttenuation = saturate((camToPosDist - VisibilityDistance)/ (AtmosphereHeight + visibilityDistance));

// start blending between low res texture and high at 512 units out
float blendStart = 512.0;
float blendEnd = 0.0;
float blendDistance = blendStart - blendEnd;

oBlendAmt = max(0.0, camToPosDist - blendEnd);
oBlendAmt = min(1.0, oBlendAmt / blendDistance); 
}
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
And here is the fragment shader:&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;sampler diffTex0 : register(s0);
sampler diffTex1 : register(s1);
sampler diffTex2 : register(s2);
sampler diffTex3 : register(s3);
sampler diffTex4 : register(s4);
sampler diffTex5 : register(s5);
sampler diffTex6 : register(s6);
sampler diffTex7 : register(s7);
sampler blend0 : register(s8);
sampler blend1 : register(s9);
sampler diffuse0 : register(s10);
sampler gradient0 : register(s11);

float4 getBlendedSample8(in float4 weights0, in float4 weights1, in float2 diffUV) 
{ 
// use w,x,y,z order because PNG uses pixel format A8R8G8B8
return tex2D(diffTex0, diffUV)  * weights0.w +
tex2D(diffTex1, diffUV)  * weights0.x +
tex2D(diffTex2, diffUV)  * weights0.y +
tex2D(diffTex3, diffUV)  * weights0.z +
tex2D(diffTex4, diffUV)  * weights1.w +
tex2D(diffTex5, diffUV)  * weights1.x +
tex2D(diffTex6, diffUV)  * weights1.y +
tex2D(diffTex7, diffUV)  * weights1.z;
}

void main_fp(
float2 uv : TEXCOORD0,
float3 lightDir : TEXCOORD1,
float  blendAmt : TEXCOORD2,
float  uv2 : TEXCOORD3, 
float  attenuation : TEXCOORD4,

uniform float AtmosphereTransparency,
uniform float tileFactor,

out float4 outColor : COLOR
)
{
float4 sunColor = tex2D(gradient0,float2(uv2,1));
float4 atmosphereColor = tex2D(gradient0,float2(uv2,0));

// how transparent is the atmosphere?
float transparency = min(AtmosphereTransparency,attenuation); 

// get the texture color and lit value
float4 diffuse = tex2D(diffuse0, uv);
float shadow = diffuse.a;

// FYI YOU MAY NOT WANT TO DO THIS IN YOUR SHADER
// make ambient dark on side where light is
// and light on the side where it is dark
float3 ambient = sunColor * (1.0 - uv2);

float4 blended =  getBlendedSample8(tex2D(blend0, uv), tex2D(blend1, uv), uv * tileFactor);
diffuse = lerp(blended, diffuse, blendAmt);

// now shade based on the normal
diffuse.rgb = ((1.0 - shadow) * diffuse.rgb * ambient) + (diffuse.rgb * shadow);

// get atmosphere contribution    
float3 atmosphereAmt = (atmosphereColor * sunColor * (transparency + (transparency * shadow)));    

// add in atmosphere
outColor.rgb = (diffuse.rgb * sunColor * (1.0 - transparency)) + atmosphereAmt;
outColor.a = 1.0;
}
&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/Petrocket/~4/KethZ1megC4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://petrocket.blogspot.com/feeds/8161770696191626514/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2884078902485203181&amp;postID=8161770696191626514" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/8161770696191626514?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/8161770696191626514?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Petrocket/~3/KethZ1megC4/planet-terrain-shader-with-atmosphere.html" title="Planet Terrain Shader With Atmosphere" /><author><name>alex peterson</name><uri>http://www.blogger.com/profile/10147348345426496177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://4.bp.blogspot.com/_Tt-WoSrRoOs/SqMaDwSfsqI/AAAAAAAAABM/sdkcPTvVX7s/S220/IMG_0932.JPG" /></author><thr:total>3</thr:total><feedburner:origLink>http://petrocket.blogspot.com/2010/05/planet-terrain-shader-with-atmosphere.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0AMQnw-eCp7ImA9WxFXFEo.&quot;"><id>tag:blogger.com,1999:blog-2884078902485203181.post-1265245049082720001</id><published>2010-04-28T06:50:00.000-07:00</published><updated>2010-05-21T14:03:03.250-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-05-21T14:03:03.250-07:00</app:edited><title>Atmosphere Shader Update And Tree/Grass Test</title><content type="html">&lt;a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/MieScattering.jpg" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/MieScattering.project%20featured.jpg"  border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I've gone and made the atmosphere shader more complex, sorry.  The basic idea is still pretty straight forward, but I added mie scattering to the pixel shader and added extra code to fix issues with the atmosphere being too transparent when near the surface of the planet (stars were showing through).&lt;br /&gt;&lt;br /&gt;Also, I worked on pre-calculated/static shadow maps for the terrain and used those with the grass and trees.  JohnJ created &lt;a href="http://code.google.com/p/ogre-paged/" target="_new"&gt;Paged Geometry&lt;/a&gt;, which is built for 2d heightmaps, but I semi-adapted it so that each face of the planet cube has its' own paged geometry instance.  Here's a video of that:&lt;br /&gt;&lt;br /&gt;&lt;object width="480" height="295"&gt;&lt;param name="movie" value="http://www.youtube.com/v/Nqjc3kBgxyc&amp;hl=en_US&amp;fs=1&amp;color1=0x3a3a3a&amp;color2=0x999999"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/Nqjc3kBgxyc&amp;hl=en_US&amp;fs=1&amp;color1=0x3a3a3a&amp;color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="295"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;strong&gt;Note: the atmosphere shader in this video is the &lt;i&gt;old&lt;/i&gt; atmosphere shader so the atmosphere is still too transparent on the sunny side of the planet&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;It has issues like, the billboard trees don't display right when viewed top down and they don't fade out based on height like they should.  Also there is an abrupt transition from one paged geometry instance to the next when you cross over from one cube planet face to another.  I may just have to roll my own simplified version.&lt;br /&gt;&lt;br /&gt;And now, here is the NVIDIA FX Composer shader for the current atmosphere shader I'm using:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: cpp"&gt;&lt;br /&gt;// outer atmosphere radius&lt;br /&gt;float AtmosphereRadius &lt;&lt;br /&gt; string UIName =  "Atmosphere Radius";&lt;br /&gt; string UIWidget = "Slider";&lt;br /&gt; float UIMin = 0.0;&lt;br /&gt; float UIMax = 10000.0;&lt;br /&gt; float UIStep = 1.0; &lt;br /&gt;&gt; = {1200.0f};&lt;br /&gt;&lt;br /&gt;// planet surface radius&lt;br /&gt;float SurfaceRadius &lt;&lt;br /&gt; string UIName =  "Surface Radius";&lt;br /&gt; string UIWidget = "Slider";&lt;br /&gt; float UIMin = 0.0;&lt;br /&gt; float UIMax = 10000.0;&lt;br /&gt; float UIStep = 1.0; &lt;br /&gt;&gt; = {1024.0f};&lt;br /&gt;&lt;br /&gt;// this is the sun position/direction&lt;br /&gt;float4 gLamp0DirPos : POSITION &lt; // or direction, if W==0&lt;br /&gt;    string Object = "Light0";&lt;br /&gt;    string UIName =  "Lamp 0 Position/Direction";&lt;br /&gt;    string Space = (LIGHT_COORDS);&lt;br /&gt;&gt; = {10.0f,10.0f,10.0f,1.0};&lt;br /&gt;&lt;br /&gt;// this is the atmosphere 2d gradient&lt;br /&gt;texture gTex  &lt;&lt;br /&gt;    string ResourceName = "AtmosphereGradient";&lt;br /&gt;    string ResourceType = "2D";&lt;br /&gt;    string UIName = "Gradient Texture";&lt;br /&gt;&gt;;&lt;br /&gt;sampler2D gTexSampler = sampler_state &lt;br /&gt;{&lt;br /&gt;    Texture = &lt;gTex&gt;;&lt;br /&gt;    Filter = MIN_MAG_MIP_LINEAR;&lt;br /&gt;    AddressU = Clamp;&lt;br /&gt;    AddressV = Clamp;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;// this is for setting where the horizon should fall on the sphere&lt;br /&gt;float StretchAmt &lt;&lt;br /&gt; string UIName =  "Stretch Amount";&lt;br /&gt; string UIWidget = "Slider";&lt;br /&gt; float UIMin = 0.0;&lt;br /&gt; float UIMax = 1.0;&lt;br /&gt; float UIStep = 0.01; &lt;br /&gt;&gt; = {0.25f};&lt;br /&gt;&lt;br /&gt;// this is for mie scattering&lt;br /&gt;float Atmosphere_G &lt;&lt;br /&gt; string UIName =  "Atmosphere G";&lt;br /&gt; string UIWidget = "Slider";&lt;br /&gt; float UIMin = -1.0;&lt;br /&gt; float UIMax = -0.5;&lt;br /&gt; float UIStep = 0.001; &lt;br /&gt;&gt; = {-0.95f};&lt;br /&gt;&lt;br /&gt;float4x4 WorldViewProj : WorldViewProjection;&lt;br /&gt;float4x4 ViewIXf : ViewInverse;&lt;br /&gt;float4x4 WorldXf : World;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;void main2VS(&lt;br /&gt;    float3 pos : POSITION,&lt;br /&gt;    uniform float4 lightPos,&lt;br /&gt; &lt;br /&gt;    out float4 oPosition: POSITION,&lt;br /&gt;    out float2 oUV: TEXCOORD0,&lt;br /&gt;    out float oAlpha: TEXCOORD1,&lt;br /&gt;    out float3 oCamToPos: TEXCOORD2,&lt;br /&gt;    out float3 oLightDir :TEXCOORD3&lt;br /&gt;    ) &lt;br /&gt;{&lt;br /&gt;    float4 Po = float4(pos.xyz,1);&lt;br /&gt;    float4 Pw = mul(Po,WorldXf);&lt;br /&gt;    float3 position = Pw.xyz;&lt;br /&gt;    float4 camPos = float4(ViewIXf[3].xyz,1);&lt;br /&gt; &lt;br /&gt;    oPosition = mul(Po, WorldViewProj); &lt;br /&gt; &lt;br /&gt;    float radius = length(position);&lt;br /&gt;    float radius2 = radius * radius; &lt;br /&gt;    float camHeight = length(camPos.xyz);&lt;br /&gt;    float3 camToPos = position - camPos.xyz;&lt;br /&gt;    float farDist = length(camToPos);&lt;br /&gt; &lt;br /&gt;    float3 lightDir = normalize(lightPos.xyz);&lt;br /&gt;    float3 normal = normalize(position);&lt;br /&gt; &lt;br /&gt;    float3 rayDir = camToPos / farDist;&lt;br /&gt;    float camHeight2 = camHeight * camHeight;&lt;br /&gt; &lt;br /&gt;    // Calculate the closest intersection of the ray with the outer atmosphere&lt;br /&gt;    float B = 2.0 * dot(camPos.xyz, rayDir);&lt;br /&gt;    float C = camHeight2 - radius2;&lt;br /&gt;    float det = max(0.0, B*B - 4.0 * C);&lt;br /&gt;    float nearDist = 0.5 * (-B - sqrt(det));&lt;br /&gt;    float3 nearPos = camPos.xyz + (rayDir * nearDist);&lt;br /&gt;    float3 nearNormal = normalize(nearPos);&lt;br /&gt;&lt;br /&gt;    // get dot products we need&lt;br /&gt;    float lc = dot(lightDir, camPos / camHeight);&lt;br /&gt;    float ln = dot(lightDir, normal);&lt;br /&gt;    float lnn = dot(lightDir, nearNormal);&lt;br /&gt;&lt;br /&gt;    // get distance to surface horizon&lt;br /&gt;    float altitude = camHeight - SurfaceRadius;&lt;br /&gt;    float horizonDist = sqrt((altitude*altitude) + (2.0 * SurfaceRadius * altitude));&lt;br /&gt;    float maxDot = horizonDist / camHeight;&lt;br /&gt; &lt;br /&gt;    // get distance to atmosphere horizon - use max(0,...) because we can go into the atmosphere&lt;br /&gt;    altitude = max(0,camHeight - AtmosphereRadius);&lt;br /&gt;    horizonDist = sqrt((altitude*altitude) + (2.0 * AtmosphereRadius * altitude));&lt;br /&gt; &lt;br /&gt;    // without this, the shift between inside and outside atmosphere is  jarring&lt;br /&gt;    float tweakAmount = 0.1;&lt;br /&gt;    float minDot = max(tweakAmount,horizonDist / camHeight);&lt;br /&gt; &lt;br /&gt;    // scale minDot from 0 to -1 as we enter the atmosphere&lt;br /&gt;    float minDot2 = ((camHeight - SurfaceRadius) * (1.0 / (AtmosphereRadius  - SurfaceRadius))) - (1.0 - tweakAmount);&lt;br /&gt;    minDot = min(minDot, minDot2);&lt;br /&gt;  &lt;br /&gt;    // get dot product of the vertex we're looking out&lt;br /&gt;    float posDot = dot(camToPos / farDist,-camPos.xyz / camHeight) - minDot;&lt;br /&gt; &lt;br /&gt;    // calculate the height from surface in range 0..1&lt;br /&gt;    float height = posDot * (1.0 / (maxDot - minDot));&lt;br /&gt; &lt;br /&gt;    // push the horizon back based on artistic taste&lt;br /&gt;    ln = max(0,ln + StretchAmt);&lt;br /&gt;    lnn = max(0,lnn + StretchAmt);&lt;br /&gt;&lt;br /&gt;    // the front color is the sum of the near and far normals&lt;br /&gt;    float brightness = saturate(ln + (lnn * lc));&lt;br /&gt; &lt;br /&gt;    // use "saturate(lc + 1.0 + StretchAmt)" to make more of the sunset side color be used when behind the planet&lt;br /&gt;    oUV.x = brightness * saturate(lc + 1.0 + StretchAmt);&lt;br /&gt;    oUV.y = height;&lt;br /&gt; &lt;br /&gt;    // as the camera gets lower in the atmosphere artificially increase the height&lt;br /&gt;    // so that the alpha value gets raised and multiply the increase amount&lt;br /&gt;    // by the dot product of the light and the vertex normal so that &lt;br /&gt;    // vertices closer to the sun are less transparent than vertices far from the sun.&lt;br /&gt;    height -= min(0.0,minDot2 + (ln * minDot2));&lt;br /&gt;    oAlpha = height * brightness;&lt;br /&gt; &lt;br /&gt;    // normalised camera to position ray&lt;br /&gt;    oCamToPos = -rayDir;&lt;br /&gt; &lt;br /&gt;    oLightDir = normalize(lightPos.xyz - position.xyz); &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;float4 mainBPS( &lt;br /&gt;    float2 uv : TEXCOORD0,&lt;br /&gt;    float alpha : TEXCOORD1,&lt;br /&gt;    float3 camToPos : TEXCOORD2,&lt;br /&gt;    float3 lightDir :TEXCOORD3,&lt;br /&gt;    uniform sampler2D TexSampler&lt;br /&gt;) : COLOR {&lt;br /&gt; &lt;br /&gt;    const float fExposure = 1.5;&lt;br /&gt;    float g = Atmosphere_G;&lt;br /&gt;    float g2 = g * g;&lt;br /&gt;&lt;br /&gt;    // atmosphere color&lt;br /&gt;    float4 diffuse = tex2D(TexSampler,uv);&lt;br /&gt; &lt;br /&gt;    // sun outer color - might could use atmosphere color&lt;br /&gt;    float4 diffuse2 = tex2D(TexSampler,float2(min(0.5,uv.x),1));&lt;br /&gt;&lt;br /&gt;    // this is equivilant but faster than fCos = dot(normalize(lightDir.xyz),normalize(camToPos));&lt;br /&gt;    float fCos = dot(lightDir.xyz,camToPos) * rsqrt( dot(lightDir.xyz,lightDir.xyz) * dot(camToPos,camToPos));&lt;br /&gt;    float fCos2 = fCos * fCos;&lt;br /&gt;&lt;br /&gt;    // apply alpha to atmosphere&lt;br /&gt;    float4 diffuseColor = diffuse * alpha;&lt;br /&gt;    &lt;br /&gt;    // sun glow color&lt;br /&gt;    float fMiePhase = 1.5 * ((1.0 - g2) / (2.0 + g2)) * (1.0 + fCos2) /(1.0 + g2 - 2.0*g*fCos);&lt;br /&gt;    float4 mieColor = diffuse2 * fMiePhase * alpha;&lt;br /&gt;  &lt;br /&gt;    // use exponential falloff because mie color is in high dynamic range&lt;br /&gt;    // boost diffuse color near horizon because it gets desaturated by falloff&lt;br /&gt;    return 1.0 - exp((diffuseColor * (1.0 + uv.y) + mieColor) * -fExposure);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;technique technique1 {&lt;br /&gt; pass p0 {&lt;br /&gt;     ZEnable = false;&lt;br /&gt;     ZWriteEnable = false;&lt;br /&gt;     CullMode = CCW;&lt;br /&gt;     AlphaBlendEnable = true;&lt;br /&gt;     SrcBlend = One ;&lt;br /&gt;     DestBlend = InvSrcAlpha;&lt;br /&gt;     VertexShader = compile vs_3_0 main2VS(gLamp0DirPos);&lt;br /&gt;     PixelShader = compile ps_3_0 mainBPS(gTexSampler);  &lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Possible Improvements&lt;/strong&gt;&lt;br /&gt;- pre-calculate camera height, camera height squared and other such variables. you should notice that a lot of the vertex shader code would be the same for every vertex including calculating horizon distance, camera and light only based calculations and parts of the sphere intersection calculations.&lt;br /&gt;- simplify mie scattering equation and remove hdr&lt;br /&gt;- when the camera is inside the atmosphere we no longer need to calculate the atmosphere closest intersection so the program should switch to a simpler version of the shader once inside.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Known Issues&lt;/strong&gt;&lt;br /&gt;- transition from outer atmosphere to inner atmosphere is not smooth.  I suspect this is due to my atmosphere being an un-realistic size so I had to add a tweak amount so that the transition point is actually a bit inside the atmosphere at a point where only the inside of the sphere is visible to the camera.  At the point where the camera is the same height as the atmosphere, it can still see the outside of the atmosphere shell.&lt;br /&gt;- when on the surface of the planet looking back at the horizon it looks more like a painted shell than a spherical haze&lt;br /&gt;- when you get really close to the edge of the atmosphere on the side facing the sun there is an artifact that appears that I haven't fixed yet.&lt;br /&gt;- there are banding issues in the sky gradient when on the side of the planet facing the sun that I haven't solved yet and I think they're related to the color choices in my gradient, but I'm not sure.&lt;br /&gt;&lt;br /&gt;If you have any suggestions, improvements or bug fixes please let me know in the comments!&lt;img src="http://feeds.feedburner.com/~r/Petrocket/~4/xZOdZotopXk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://petrocket.blogspot.com/feeds/1265245049082720001/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2884078902485203181&amp;postID=1265245049082720001" title="9 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/1265245049082720001?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/1265245049082720001?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Petrocket/~3/xZOdZotopXk/atmosphere-shader-update-and-treegrass.html" title="Atmosphere Shader Update And Tree/Grass Test" /><author><name>alex peterson</name><uri>http://www.blogger.com/profile/10147348345426496177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://4.bp.blogspot.com/_Tt-WoSrRoOs/SqMaDwSfsqI/AAAAAAAAABM/sdkcPTvVX7s/S220/IMG_0932.JPG" /></author><thr:total>9</thr:total><feedburner:origLink>http://petrocket.blogspot.com/2010/04/atmosphere-shader-update-and-treegrass.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0cMRXg5cSp7ImA9WxFXFEQ.&quot;"><id>tag:blogger.com,1999:blog-2884078902485203181.post-722518782043658400</id><published>2010-04-23T07:58:00.000-07:00</published><updated>2010-05-21T20:31:24.629-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-05-21T20:31:24.629-07:00</app:edited><title>Sphere to Cube Mapping</title><content type="html">The following unit cube to unit sphere mapping is nice because the resulting sphere vertices are distributed somewhat evently:&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://mathproofs.blogspot.com/2005/07/mapping-cube-to-sphere.html" target="_new"&gt;Math Proofs: Mapping a Cube to a Sphere, by Phil&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Here's the c++ version where x,y,z are the cube coords and sx,sy,sz are the sphere coords:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush:cpp"&gt;sx = x * sqrtf(1.0f - y * y * 0.5f - z * z * 0.5f + y * y * z * z / 3.0f);

sy = y * sqrtf(1.0f - z * z * 0.5f - x * x * 0.5f + z * z * x * x / 3.0f);

sz = z * sqrtf(1.0f - x * x * 0.5f - y * y * 0.5f + x * x * y * y / 3.0f);

&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Recently, I've been working on the reverse mapping (from unit sphere to unit cube) and have come up with this solution:&lt;br /&gt;
&lt;br /&gt;
First determine the cube face the sphere point projects to. This step is simple - just find the component of the sphere vector with the greatest length.&lt;br /&gt;
&lt;br /&gt;
Next, for each face, take the remaining cube vector components denoted as s and t and solve for them using these equations, which are based on the remaining sphere vector components denoted as a and b:&lt;br /&gt;
&lt;br /&gt;
s = sqrt(-sqrt((2 a^2-2 b^2-3)^2-24 a^2)+2 a^2-2 b^2+3)/sqrt(2)&lt;br /&gt;
t = sqrt(-sqrt((2 a^2-2 b^2-3)^2-24 a^2)-2 a^2+2 b^2+3)/sqrt(2)&lt;br /&gt;
&lt;br /&gt;
You should see that the inner square root is used in both equations, so only do that part once.&lt;br /&gt;
&lt;br /&gt;
Here's the final function with the equations thrown in and checks for 0.0 and -0.0 and the code to properly set the sign of the cube component - it should be equal to the sign of the sphere component.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush:cpp"&gt;void cubizePoint(Vector3&amp; position)
{
double x,y,z;
x = position.x;
y = position.y;
z = position.z;

double fx, fy, fz;
fx = fabsf(x);
fy = fabsf(y);
fz = fabsf(z);

const double inverseSqrt2 = 0.70710676908493042;

if (fy &gt;= fx &amp;&amp; fy &gt;= fz) {
double a2 = x * x * 2.0;
double b2 = z * z * 2.0;
double inner = -a2 + b2 -3;
double innersqrt = -sqrtf((inner * inner) - 12.0 * a2);

if(x == 0.0 || x == -0.0) { 
position.x = 0.0; 
}
else {
position.x = sqrtf(innersqrt + a2 - b2 + 3.0) * inverseSqrt2;
}

if(z == 0.0 || z == -0.0) {
position.z = 0.0;
}
else {
position.z = sqrtf(innersqrt - a2 + b2 + 3.0) * inverseSqrt2;
}

if(position.x &gt; 1.0) position.x = 1.0;
if(position.z &gt; 1.0) position.z = 1.0;

if(x &lt; 0) position.x = -position.x;
if(z &lt; 0) position.z = -position.z;

if (y &gt; 0) {
// top face
position.y = 1.0;
}
else {
// bottom face
position.y = -1.0;
}
}
else if (fx &gt;= fy &amp;&amp; fx &gt;= fz) {
double a2 = y * y * 2.0;
double b2 = z * z * 2.0;
double inner = -a2 + b2 -3;
double innersqrt = -sqrtf((inner * inner) - 12.0 * a2);

if(y == 0.0 || y == -0.0) { 
position.y = 0.0; 
}
else {
position.y = sqrtf(innersqrt + a2 - b2 + 3.0) * inverseSqrt2;
}

if(z == 0.0 || z == -0.0) {
position.z = 0.0;
}
else {
position.z = sqrtf(innersqrt - a2 + b2 + 3.0) * inverseSqrt2;
}

if(position.y &gt; 1.0) position.y = 1.0;
if(position.z &gt; 1.0) position.z = 1.0;

if(y &lt; 0) position.y = -position.y;
if(z &lt; 0) position.z = -position.z;

if (x &gt; 0) {
// right face
position.x = 1.0;
}
else {
// left face
position.x = -1.0;
}
}
else {
double a2 = x * x * 2.0;
double b2 = y * y * 2.0;
double inner = -a2 + b2 -3;
double innersqrt = -sqrtf((inner * inner) - 12.0 * a2);

if(x == 0.0 || x == -0.0) { 
position.x = 0.0; 
}
else {
position.x = sqrtf(innersqrt + a2 - b2 + 3.0) * inverseSqrt2;
}

if(y == 0.0 || y == -0.0) {
position.y = 0.0;
}
else {
position.y = sqrtf(innersqrt - a2 + b2 + 3.0) * inverseSqrt2;
}

if(position.x &gt; 1.0) position.x = 1.0;
if(position.y &gt; 1.0) position.y = 1.0;

if(x &lt; 0) position.x = -position.x;
if(y &lt; 0) position.y = -position.y;

if (z &gt; 0) {
// front face
position.z = 1.0;
}
else {
// back face
position.z = -1.0;
}
}
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
I posted a &lt;a href="http://stackoverflow.com/questions/2656899/mapping-a-sphere-to-a-cube/" target="_new"&gt;stackoverflow question&lt;/a&gt; and got a lot of help from there and from &lt;a href="http://mathoverflow.net/questions/21638/mapping-a-sphere-to-a-cube" target="_new"&gt;mathoverflow&lt;/a&gt; too.  I used &lt;a href="http://wolframalpha.com" target="_new"&gt;wolframalpha.com&lt;/a&gt; to get the equations for s and t.&lt;br /&gt;
&lt;br /&gt;
My thanks to gmatt and Leonid Kovalev!&lt;img src="http://feeds.feedburner.com/~r/Petrocket/~4/DLU50J-QDQs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://petrocket.blogspot.com/feeds/722518782043658400/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2884078902485203181&amp;postID=722518782043658400" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/722518782043658400?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/722518782043658400?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Petrocket/~3/DLU50J-QDQs/sphere-to-cube-mapping.html" title="Sphere to Cube Mapping" /><author><name>alex peterson</name><uri>http://www.blogger.com/profile/10147348345426496177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://4.bp.blogspot.com/_Tt-WoSrRoOs/SqMaDwSfsqI/AAAAAAAAABM/sdkcPTvVX7s/S220/IMG_0932.JPG" /></author><thr:total>1</thr:total><feedburner:origLink>http://petrocket.blogspot.com/2010/04/sphere-to-cube-mapping.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEMHQ3o_eip7ImA9WxFXFEo.&quot;"><id>tag:blogger.com,1999:blog-2884078902485203181.post-6837280760228488294</id><published>2010-03-17T19:06:00.000-07:00</published><updated>2010-05-21T14:13:52.442-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-05-21T14:13:52.442-07:00</app:edited><title>Tri-Planar Texturing On A Sphere And Spacescape Release!</title><content type="html">&lt;a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/triplanar-mapping-normals.jpg" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/triplanar-mapping-normals.project%20featured.jpg" alt="tri-planar normals on a sphere"/&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Applying an animated normal map to a sphere is a problem.  You have stretching issues and if using a cube-to-sphere mapping you have uv direction issues.  The only solutions I know of to solve these is to do perlin noise in a shader, a 3d repeating noise texture(?) or do tri-planar texturing and use a 2d texture map, which is what I've done here.&lt;br /&gt;
&lt;br /&gt;
&lt;object width="480" height="295"&gt;&lt;param name="movie" value="http://www.youtube.com/v/LUEVlSNpF6Q&amp;hl=en_US&amp;fs=1&amp;rel=0&amp;color1=0x3a3a3a&amp;color2=0x999999"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/LUEVlSNpF6Q&amp;hl=en_US&amp;fs=1&amp;rel=0&amp;color1=0x3a3a3a&amp;color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="295"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;
&lt;br /&gt;
I used the code from &lt;a href="http://http.developer.nvidia.com/GPUGems3/gpugems3_ch01.html" target="_new"&gt;this GPU Gems 3 article&lt;/a&gt; and added a second bump map and animated them by updating the vertex uv coords and the results are decent.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/triplanar-water-shader.jpg" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/triplanar-water-shader.project%20featured.jpg" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Now there are no visible seams on the sphere and the bump map is pretty evenly spread across the surface.  Also when it animates you don't have any visible seams due to opposing uv directions because of the way tri-planar texturing blends the uv maps.  This blending does mean, however, that where the cube edges meet on the sphere you get most of the stretching and the bump map is more random.  This side affect is OK for water because I want the bumps to look random.&lt;br /&gt;
&lt;br /&gt;
I still have to deal with a bunch of issues including the fps hit this shader brings with it.  Now instead of 2 normal map texture look ups per pixel there are 6 - 1 for each of the 3 axis and there are 2 normal maps.  On top of this I have texture look ups for the atmosphere color, sun color and the water depth and I haven't even tried adding reflection or refraction.&lt;br /&gt;
&lt;br /&gt;
I've pasted the FX Composer .fx HLSL file at the bottom of this post if you want to try it out.&lt;br /&gt;
&lt;br /&gt;
Also, I have released the &lt;a href="http://alexcpeterson.com/spacescape" target="_new"&gt;Spacescape skybox tool&lt;/a&gt; and uploaded the source code to &lt;a href="http://sourceforge.net/projects/spacescape" target="_new"&gt;sourceforge.net/projects/spacescape&lt;/a&gt;!&lt;br /&gt;
&lt;br /&gt;
The tool is rather complex and so I plan on writing some tutorials &amp; tips to help answer some questions that have been coming up.&lt;br /&gt;
&lt;br /&gt;
Here's an intro video:&lt;br /&gt;
&lt;object width="480" height="295"&gt;&lt;param name="movie" value="http://www.youtube.com/v/py2OeGYhZVw&amp;hl=en_US&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/py2OeGYhZVw&amp;hl=en_US&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="295"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;
&lt;br /&gt;
Here's the tri-planar sphere.fx file code for NVidia FX Composer. NOTE: this is not my water shader, just the tri-planar stuff and it has a slider called OFFSET that you can drag to see how the bump map animates.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;/************* UN-TWEAKABLES **************/

float4x4 WorldITXf : WorldInverseTranspose &lt; string UIWidget="None"; &gt;;
float4x4 WvpXf     : WorldViewProjection &lt; string UIWidget="None"; &gt;;
float4x4 WorldXf   : World     &lt; string UIWidget="None"; &gt;;
float4x4 ViewIXf   : ViewInverse   &lt; string UIWidget="None"; &gt;;

float3 Lamp0Pos : Position &lt;
string Object = "PointLight0";
string UIName =  "Lamp 0 Position";
string Space = "World";
&gt; = {-0.5f,2.0f,1.25f};

float OFFSET &lt;
string UIWidget = "slider";
float UIMin = 0.0;
float UIMax = 1.0;
float UIStep = 0.001;
string UIName =  "Offset";
&gt; = 0.0;

texture normalTexture  &lt;
string ResourceName = "water-normal.png";
string ResourceType = "2D";
string UIName = "Water Normal Texture";
&gt;;
sampler2D NormalSampler = sampler_state 
{
Texture = &lt;normaltexture&gt;;
Filter = MIN_MAG_MIP_LINEAR;
AddressU = Wrap;
AddressV = Wrap;
};

/************* DATA STRUCTS **************/

/* data from application vertex buffer */
struct appdata {
float3 Position : POSITION;
};

/* data passed from vertex shader to pixel shader */
struct vertexOutput {
float4 HPosition : POSITION;
float3 UV  : TEXCOORD0;
float3 UV2  : TEXCOORD1;
float3 WorldNormal : TEXCOORD2;
float3 LightVec : TEXCOORD3;
};

/*********** vertex shader ******/

vertexOutput simpleVS(appdata IN) {
vertexOutput OUT = (vertexOutput)0;

float4 Po = float4(IN.Position.xyz,1);    
float3 Pw = mul(Po,WorldXf).xyz;
OUT.HPosition = mul(Po, WvpXf);
OUT.LightVec = (Lamp0Pos - Pw);

OUT.WorldNormal = Pw;

// OFFSET is used to preview what animation would look like

// first uv for large waves
OUT.UV = ((Pw + 1.0) * 0.5);
OUT.UV.xy +=OFFSET;

// second uv for small waves
OUT.UV2 = ((Pw + 1.0) * 0.5);
OUT.UV2.xz +=(OFFSET * 2.0);

return OUT;
}

/********* pixel shader ********/

float4 simplePS(vertexOutput IN) : COLOR {

float3 blend_weights = abs( IN.WorldNormal );   // Tighten up the blending zone:  
blend_weights = (blend_weights - 0.2) * 7;  
blend_weights = max(blend_weights, 0);      // Force weights to sum to 1.0 (very important!)  
blend_weights /= (blend_weights.x + blend_weights.y + blend_weights.z ).xxx;  

float4 blended_color; // .w hold spec value  
float3 blended_bump_vec; 

// Compute the UV coords for each of the 3 planar projections.  
// tex_scale (default ~ 1.0) determines how big the textures appear.  
float tex_scale = 4.0;
float tex_scale2 = 8.0;
float2 coord1 = IN.UV.yz * tex_scale;
float2 coord2 = IN.UV.zx * tex_scale;
float2 coord3 = IN.UV.xy * tex_scale;
float2 coord4 = IN.UV2.yz * tex_scale2;  
float2 coord5 = IN.UV2.zx * tex_scale2;  
float2 coord6 = IN.UV2.xy * tex_scale2;   

// Sample color maps for each projection, at those UV coords.  
float4 col1 = float4(1.0,0,0,1);  
float4 col2 = float4(0,1.0,0,1);  
float4 col3 = float4(0,0,1.0,1);  

// Sample bump maps too, and generate bump vectors.  
float2 bumpFetch1 = tex2D(NormalSampler,coord1).xy - 0.5;  
float2 bumpFetch2 = tex2D(NormalSampler,coord2).xy - 0.5;  
float2 bumpFetch3 = tex2D(NormalSampler,coord3).xy - 0.5;  
float2 bumpFetch4 = tex2D(NormalSampler,coord4).xy - 0.5;  
float2 bumpFetch5 = tex2D(NormalSampler,coord5).xy - 0.5;  
float2 bumpFetch6 = tex2D(NormalSampler,coord6).xy - 0.5;  

// (Note: this uses an oversimplified tangent basis.)  
float3 bump1 = float3(0, bumpFetch1.x, bumpFetch1.y);  
float3 bump2 = float3(bumpFetch2.y, 0, bumpFetch2.x);  
float3 bump3 = float3(bumpFetch3.x, bumpFetch3.y, 0);

float3 bump4 = float3(0, bumpFetch4.x, bumpFetch4.y);  
float3 bump5 = float3(bumpFetch5.y, 0, bumpFetch5.x);  
float3 bump6 = float3(bumpFetch6.x, bumpFetch6.y, 0);   

// Finally, blend the results of the 3 planar projections.  
blended_color = col1.xyzw * blend_weights.xxxx +  
col2.xyzw * blend_weights.yyyy +  
col3.xyzw * blend_weights.zzzz;  

blended_bump_vec = bump1.xyz * blend_weights.xxx +  
bump2.xyz * blend_weights.yyy +  
bump3.xyz * blend_weights.zzz;

blended_bump_vec += (bump4.xyz * blend_weights.xxx +  
bump5.xyz * blend_weights.yyy +  
bump6.xyz * blend_weights.zzz) * 0.5;

float3 N_for_lighting = normalize(IN.WorldNormal + blended_bump_vec);
return saturate(blended_color) * dot(normalize(IN.LightVec),N_for_lighting);
}

/*************/

technique main
{
pass p0
{
VertexShader = compile vs_3_0 simpleVS();
PixelShader = compile ps_3_0 simplePS();
ZEnable = true;
ZWriteEnable = true;  
CullMode=None; 
}
}

/***************************** eof ***/
&lt;/pre&gt;&lt;img src="http://feeds.feedburner.com/~r/Petrocket/~4/uzRPV5pmqKY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://petrocket.blogspot.com/feeds/6837280760228488294/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2884078902485203181&amp;postID=6837280760228488294" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/6837280760228488294?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/6837280760228488294?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Petrocket/~3/uzRPV5pmqKY/tri-planar-texturing-on-sphere-and.html" title="Tri-Planar Texturing On A Sphere And Spacescape Release!" /><author><name>alex peterson</name><uri>http://www.blogger.com/profile/10147348345426496177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://4.bp.blogspot.com/_Tt-WoSrRoOs/SqMaDwSfsqI/AAAAAAAAABM/sdkcPTvVX7s/S220/IMG_0932.JPG" /></author><thr:total>4</thr:total><feedburner:origLink>http://petrocket.blogspot.com/2010/03/tri-planar-texturing-on-sphere-and.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0YESHo6eSp7ImA9WxBVFEo.&quot;"><id>tag:blogger.com,1999:blog-2884078902485203181.post-5140250171951876559</id><published>2010-02-17T19:37:00.000-08:00</published><updated>2010-02-17T21:31:49.411-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-02-17T21:31:49.411-08:00</app:edited><title>Spacescape  - Now With Billboards</title><content type="html">&lt;a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/screenshot02172010_221930023.png" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/screenshot02172010_221930023.project%20featured.png" alt="spacescape image with billboard sprites" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;small&gt;(click to enlarge)&lt;/small&gt;&lt;br /&gt;&lt;br /&gt;Just a minor update - I've added billboard sprites to the mix where as before I was just using point sprites.  I also added an extra line to the noise shader like this:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;noiseSum = pow(noiseSum / powerAmount);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;This allows me to control the slope of the noise gradient so it is more steep or more gradual, which is something I needed for masks.&lt;br /&gt;&lt;br /&gt;The image above really taxes my system (3-4 fps).  It has 12 layers: one ridged noise mask for the brightest stars, then another for the middle level of stars and then two more ridged noise haze layers and the rest are mixes of billboard and point stars.&lt;br /&gt;&lt;br /&gt;For kicks I threw the generated skybox into the planet app and it's definitely a bit over the top and low-res/blurry.  Still it is "fun"&lt;br /&gt;&lt;br /&gt;&lt;small&gt;(click images to enlarge)&lt;/small&gt;&lt;br /&gt;&lt;a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/screenshot02182010_001134846.png" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/screenshot02182010_001134846.project%20featured.png" alt="planet with generated skybox" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/screenshot02182010_001318019.png" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/screenshot02182010_001318019.project%20featured.png" alt="planet with generated skybox 2" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;As usual, I uploaded these images and more to the &lt;a href="http://alexcpeterson.com/image/tid/1" target="_new"&gt;My First Planet gallery&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;I re-implemented writeToFile() in the plugin so I can save to files.  I also added a writeToMaterial() function to the plugin so I can preview the skybox in &lt;a href="http://www.ogre3d.org" target="_new"&gt;ogre&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;One thing I've noticed is that the resolution of skybox really affects the brightness of small stars.  When I save a 2048x2048 skybox out the single pixel point stars are crisp, but get lost when imported into a program with a low screen resolution.  So you kinda have to take that into account when making the skyboxes.  It might look great at the resolution on your monitor, but not at the resolution on someone else's monitor.  This is where the writeToMaterial() function will be useful so you can preview the skybox at different resolutions to see if it works OK at low resolutions.&lt;br /&gt;&lt;br /&gt;I might mess with the mipmap generation for lower levels so that stars don't loose their brightness as quickly when the high resolution image is scaled down.&lt;br /&gt;&lt;br /&gt;Here's a sample generated skybox (click for 1024x1024 version - open in new window):&lt;br /&gt;right&lt;br /&gt;&lt;a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/test-skybox_right1.png" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/test-skybox_right1.project%20featured.png" alt="right" /&gt;&lt;/a&gt;&lt;br /&gt;left&lt;br /&gt;&lt;a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/test-skybox_left2.png" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/test-skybox_left2.project%20featured.png" alt="left" /&gt;&lt;/a&gt;&lt;br /&gt;top&lt;br /&gt;&lt;a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/test-skybox_top3.png" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/test-skybox_top3.project%20featured.png" alt="top" /&gt;&lt;/a&gt;&lt;br /&gt;bottom&lt;br /&gt;&lt;a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/test-skybox_bottom4.png" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/test-skybox_bottom4.project%20featured.png" alt="bottom" /&gt;&lt;/a&gt;&lt;br /&gt;front&lt;br /&gt;&lt;a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/test-skybox_front5.png" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/test-skybox_front5.project%20featured.png" alt="front" /&gt;&lt;/a&gt;&lt;br /&gt;back&lt;br /&gt;&lt;a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/test-skybox_back6.png" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/test-skybox_back6.project%20featured.png" alt="back" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;And here's a funny little screenshot of what a skybox layered sphere looks like from the outside (not the same as the one above):&lt;br /&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/screenshot02162010_125123844.project%20featured.png" alt="outside skybox layer sphere" /&gt;&lt;img src="http://feeds.feedburner.com/~r/Petrocket/~4/_NpSMtwj-_g" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://petrocket.blogspot.com/feeds/5140250171951876559/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2884078902485203181&amp;postID=5140250171951876559" title="5 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/5140250171951876559?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/5140250171951876559?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Petrocket/~3/_NpSMtwj-_g/spacescape-now-with-billboards.html" title="Spacescape  - Now With Billboards" /><author><name>alex peterson</name><uri>http://www.blogger.com/profile/10147348345426496177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://4.bp.blogspot.com/_Tt-WoSrRoOs/SqMaDwSfsqI/AAAAAAAAABM/sdkcPTvVX7s/S220/IMG_0932.JPG" /></author><thr:total>5</thr:total><feedburner:origLink>http://petrocket.blogspot.com/2010/02/spacescape-now-with-billboards.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkcCRns4cCp7ImA9WxBVEkQ.&quot;"><id>tag:blogger.com,1999:blog-2884078902485203181.post-2039000128156494075</id><published>2010-02-15T20:59:00.000-08:00</published><updated>2010-02-15T21:27:47.538-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-02-15T21:27:47.538-08:00</app:edited><title>Introducting Spacescape! A Space Skybox Creator.</title><content type="html">&lt;a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/screenshot02152010_235831652.png" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/screenshot02152010_235831652.project%20featured.png" alt="Spacescape Alpha" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Spacescape is a tool that uses &lt;a href="http://www.ogre3d.org" target="_new"&gt;Ogre&lt;/a&gt; to create / generate space scene skyboxes.  The way it works is a camera sits inside a number of user defined layers / shells.  Each layer can be a bunch of point sprites ( for stars), or a noise field (for nebulas/haze etc.)  You can define how many stars you want and the color based on distance.  In the screenshots I'm posting there are 7 layers.  3 of the layers are regular blue/white stars, 1 is a few red stars, 2 layers are ridged fbm noise of different colours and the 3rd layer is regular fbm noise used  as a mask to make stars cluster by darkening regions of space.&lt;br /&gt;&lt;br /&gt;This has been a really fun tool to make and I still have a lot left to do like the GUI. At present it reads in xml config files or you can use the plugin api to manipulate the skybox via code.  Did I mention this will be an Ogre plugin too?  I plan on releasing the plugin and tool as soon as I get a GUI and finish refactoring the save to file code.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;How it works&lt;/h2&gt;&lt;br /&gt;Making a bunch of point sprites is easy. I use an Ogre::ManualObject for that with pointSprites enabled on the material.&lt;br /&gt;&lt;br /&gt;For making the haze I create an inverted unit sphere and use a glsl shader on it that implements &lt;a href="http://britonia-game.com/?p=60" target="_new"&gt;fbm&lt;/a&gt; and &lt;a href="http://britonia-game.com/?p=60" target="_new"&gt;ridged fbm&lt;/a&gt; noise using Perlin's improved noise (not simplex noise). Lintfordpickle at &lt;a href="http://britonia-game.com" target="_new"&gt;britonia-game.com&lt;/a&gt; has a good &lt;a href="http://britonia-game.com/?p=60" target="_new"&gt;explanation with code samples about how fbm and ridged fbm noise work&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;To create the skyboxes I just create a camera with FOV set to 90degrees and render to texture the six images of the skybox.  I have it set up to render to texture the mipmap levels too, so if a user wants to save a dds file with mipmaps they can, or they can just save out the six individual images.  With the Ogre plugin it will also be possible to not save out the file but just tell the plugin to create a skybox with a given config file and use it in your own application.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here's some more images (click to enlarge - you'll need to in order to see the stars better):&lt;br /&gt;&lt;a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/screenshot02152010_235158046.png" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/screenshot02152010_235158046.project%20featured.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/screenshot02152010_235844268.png" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/screenshot02152010_235844268.project%20featured.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/screenshot02152010_235659094.png" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/screenshot02152010_235659094.project%20featured.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;A note about dithering:&lt;/strong&gt;&lt;br /&gt;I've had a tough time figuring out what to do about gradient banding with dark colors in the space backgrounds.  Without some kind of dithering or noise the gradient is very obvious.  You can see the banding clearly in all the videos and screenshots I've posted prior to this post.  The skybox I was using before was generated with blender and spiced up in photoshop, but there was no dithering on the haze so it's really ugly.  To get around this with Spacescape, I provide the option to dither a noise layer by a controllable amount and this seems to make the banding issue go away.&lt;br /&gt;&lt;br /&gt;The plan is to use this plugin in MyFirstPlanet to let users design their own space skyboxes easily too.&lt;br /&gt;&lt;br /&gt;Hopefully, I'll have a demo and some source code posted in the next week or so.&lt;img src="http://feeds.feedburner.com/~r/Petrocket/~4/qh7sXCFXH-g" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://petrocket.blogspot.com/feeds/2039000128156494075/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2884078902485203181&amp;postID=2039000128156494075" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/2039000128156494075?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/2039000128156494075?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Petrocket/~3/qh7sXCFXH-g/introducting-spacescape-space-skybox.html" title="Introducting Spacescape! A Space Skybox Creator." /><author><name>alex peterson</name><uri>http://www.blogger.com/profile/10147348345426496177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://4.bp.blogspot.com/_Tt-WoSrRoOs/SqMaDwSfsqI/AAAAAAAAABM/sdkcPTvVX7s/S220/IMG_0932.JPG" /></author><thr:total>3</thr:total><feedburner:origLink>http://petrocket.blogspot.com/2010/02/introducting-spacescape-space-skybox.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Dk8HQXo-eyp7ImA9WxBWFEU.&quot;"><id>tag:blogger.com,1999:blog-2884078902485203181.post-6257378695781273917</id><published>2010-02-06T11:17:00.001-08:00</published><updated>2010-02-06T11:33:50.453-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-02-06T11:33:50.453-08:00</app:edited><title>New YouTube Channel For Planet Dev Videos</title><content type="html">I started the &lt;a href="http://www.youtube.com/user/petrocket" target="_new"&gt;petrocket YouTube channel&lt;/a&gt; and am posting dev videos there for now.  I like &lt;a href="http://vimeo.com" target="_new"&gt;Vimeo&lt;/a&gt;, but YouTube now allows HD videos and I think it has a larger developer audience.&lt;br /&gt;&lt;br /&gt;Here's another quick video I uploaded to test the HD quality.  Sorry for the jerky camera movement.&lt;br /&gt;&lt;object width="480" height="295"&gt;&lt;param name="movie" value="http://www.youtube.com/v/ETKvLL1WBA0&amp;hl=en_US&amp;fs=1&amp;color1=0x3a3a3a&amp;color2=0x999999"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/ETKvLL1WBA0&amp;hl=en_US&amp;fs=1&amp;color1=0x3a3a3a&amp;color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="295"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;img src="http://feeds.feedburner.com/~r/Petrocket/~4/XFbFqMxZgbc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://petrocket.blogspot.com/feeds/6257378695781273917/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2884078902485203181&amp;postID=6257378695781273917" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/6257378695781273917?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/6257378695781273917?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Petrocket/~3/XFbFqMxZgbc/new-youtube-channel-for-planet-dev.html" title="New YouTube Channel For Planet Dev Videos" /><author><name>alex peterson</name><uri>http://www.blogger.com/profile/10147348345426496177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://4.bp.blogspot.com/_Tt-WoSrRoOs/SqMaDwSfsqI/AAAAAAAAABM/sdkcPTvVX7s/S220/IMG_0932.JPG" /></author><thr:total>1</thr:total><feedburner:origLink>http://petrocket.blogspot.com/2010/02/new-youtube-channel-for-planet-dev.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEEFQng6eip7ImA9WxBXE0Q.&quot;"><id>tag:blogger.com,1999:blog-2884078902485203181.post-7835842769565635751</id><published>2010-01-24T19:10:00.000-08:00</published><updated>2010-01-24T21:16:53.612-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-01-24T21:16:53.612-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="atmosphere shader code ogre fxcomposer nvidia gpu" /><title>Simple Flexibile Atmosphere Shaders</title><content type="html">&lt;a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/Earth1.JPG" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/Earth1.project%20featured.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;edit&gt;Uploaded a video of the effect&lt;br /&gt;&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/hv77SQtMBOY&amp;hl=en_US&amp;fs=1&amp;rel=0&amp;color1=0x3a3a3a&amp;color2=0x999999"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/hv77SQtMBOY&amp;hl=en_US&amp;fs=1&amp;rel=0&amp;color1=0x3a3a3a&amp;color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;/edit&gt;&lt;br /&gt;First, why no posting since September? Well, in October my wife went into pre-term labor so she was on bed rest and that meant I had to become a mom till our son was born late November. Then in early December it was holiday madness and new baby madness!&lt;br /&gt;&lt;br /&gt;Slowly, after the holidays I started work on the planet again.  I've mostly been converting it to an Ogre Plugin and refactoring it.  I'll do a separate blog post about the architecture of the plugin later I hope, but for now this post is about my work in NVidia FX Composer 2.5 working on some flexible atmosphere shaders.&lt;br /&gt;&lt;br /&gt;If you don't know, my earlier shaders were based entirely off &lt;a href="http://sponeil.net/" target="_new"&gt;Sean O'Neil's free atmosphere shaders&lt;/a&gt;. Now, Sean does things the right way, which is why his work looks so good! His shaders represent the atmosphere of the earth very accurately.  The one thing that prevented me from cutting and pasting them into my project was they rely on your atmosphere radius being a certain ratio to the surface radius (an earth sized ratio).  My atmosphere's are much exaggerated so it didn't really work and I was kind of lost in all the math.  &lt;br /&gt;&lt;br /&gt;Side note:If you're ever struggling with this stuff I highly recommend you contact him because he's very kind and helpful.&lt;br /&gt;&lt;br /&gt;So I started work on a shader that isn't mathematically correct, it just uses a look up table for the blend colors based on 2 things:&lt;br /&gt;- dot product between the camera and the light&lt;br /&gt;- dot products between the two sphere intersections of a ray from the camera to the vertex being drawn and the light.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here's the 32x16 look up table for the atmosphere shell.&lt;br /&gt;&lt;br /&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/AtmosphereGradient3.jpg" /&gt;&lt;br /&gt;&lt;br /&gt;On the horizontal axis values on the left are used when the point on the atmosphere is pointing away from the sun and values on the right are used when the point on the atmosphere is pointing toward the sun.  The vertical axis values are for blending between points near the surface of the planet (bottom) and points at the edge of the atmosphere (top).&lt;br /&gt;&lt;br /&gt;So here is a side view of the planet that shows the gradient well.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/EarthSunset.JPG" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/EarthSunset.project%20featured.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;To calculate the color to use on the horizontal axis I use this:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;float StretchAmount = 0.5;&lt;br /&gt;ln = dot(lightDir, farVertexPosition);&lt;br /&gt;lnn = dot(lightDir, nearVertexPosition);&lt;br /&gt;lc = dot(lightDir, cameraPosition);&lt;br /&gt;&lt;br /&gt;ln = max(0,ln + StretchAmount);&lt;br /&gt;lnn = max(0,lnn + StretchAmount);&lt;br /&gt;&lt;br /&gt;uv.x = saturate(ln + (lnn * lc)) * saturate(lc + 1.0 + StretchAmount);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;So when the camera is between the planet and the sun ln will be 0 and lnn will be 1 and lc will be 1 so you'll get uv.x = 1 (the blue color of the atmosphere). When the camera is on the back side of the planet ln will be 1, lnn will be 0 so uv.x would be 1.0 (the blueish color of the atmosphere) from the back too except the &lt;code&gt;saturate(lc + 1.0 + StretchAmount)&lt;/code&gt; bit scales the value based on lc, which would be -1, so -1 plus 1 + stretch amount = 0.5, so uv.x ends up being 0.5 and you end up seeing the redish colour.&lt;br /&gt;&lt;br /&gt;The StretchAmount is used to determine where the sunset should begin.&lt;br /&gt;&lt;br /&gt;I also multiple the color by the height so it fades out as the atmosphere gets thinner, and also multiply by another amount so values at the back of the sphere fade out.  This value is defined by:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;    float StretchAmt2 = 0.5;&lt;br /&gt;&lt;br /&gt;    float ln2 = max(0,ln + StretchAmt + StretchAmt2);&lt;br /&gt;    float lnn2 = max(0,lnn + StretchAmt + StretchAmt2 );&lt;br /&gt;    float alpha = saturate(ln2 + (lnn2 * lc));&lt;br /&gt;    &lt;br /&gt;    float finalAlpha = height * alpha;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;I wanted to have the alpha fade out after the point at which the sunset starts and this allows for that.  Notice it is basically identical to the uv.x calculation it just offsets the ln and lnn values so that I can control when to start fading out the atmosphere.  If StretchAmt2 is 0 then the atmosphere will be faded out by the horizon, a value of 0.5 is what is used in the pictures and it lets the atmosphere fade out about a quarter way around the back of the planet.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/Earth3.JPG" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/Earth3.project%20featured.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The surface shader uses a smaller 32x2 gradient map.&lt;br /&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/AtmosphereGradient2.jpg" /&gt;&lt;br /&gt;&lt;br /&gt;The top row corresponds to the atmosphere color and the bottom row corresponds to the sun color.  Horizontal values correspond to the dot product between the surface position and the sun position.&lt;br /&gt;&lt;br /&gt;Currently the pixel shader color output comes from this:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;outColor = (diffuse * sunColor) + (atmosphereColor * min(AtmosphereTransparency,attenuation)) * sunColor;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;The AtmosphereTransparency is how transparent I want the atmosphere to be, and presently I'm using 0.4 based on personal preference.&lt;br /&gt;&lt;br /&gt;Lastly, the attenuation factor is based on the distance from the camera to the vertex being drawn and the code to calculate it is this:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;float vd = min(AtmosphereHeight,VisibilityDistance);&lt;br /&gt;outAttenuation = saturate((cameraToVertexDistance - VisibilityDistance)/ (AtmosphereHeight + vd));&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;VisibilityDistance is the minimum visibility distance so you can adjust it for personal taste.  A large visibility distance will give the atmosphere a very thin impression and a small visibility distance would be a very dense atmosphere.&lt;br /&gt;&lt;br /&gt;Here's a boring picture from the surface:&lt;br /&gt;&lt;a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/EarthSurface.JPG" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/EarthSurface.project%20featured.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Next step is to put these shaders into Ogre and see how they look. Until then, don't forget to read the &lt;a href="http://developer.nvidia.com/object/gpu_programming_guide.html" target="_new"&gt;NVidia GPU Guide&lt;/a&gt; and &lt;a href="http://developer.amd.com/gpu/radeon/pages/RadeonSDKSamplesDocuments.aspx#documentation" target="_new"&gt;ATI GPU Guides&lt;/a&gt; every night before you go to bed.&lt;img src="http://feeds.feedburner.com/~r/Petrocket/~4/smXnTL8FQnY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://petrocket.blogspot.com/feeds/7835842769565635751/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2884078902485203181&amp;postID=7835842769565635751" title="9 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/7835842769565635751?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/7835842769565635751?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Petrocket/~3/smXnTL8FQnY/simple-flexibile-atmosphere-shaders.html" title="Simple Flexibile Atmosphere Shaders" /><author><name>alex peterson</name><uri>http://www.blogger.com/profile/10147348345426496177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://4.bp.blogspot.com/_Tt-WoSrRoOs/SqMaDwSfsqI/AAAAAAAAABM/sdkcPTvVX7s/S220/IMG_0932.JPG" /></author><thr:total>9</thr:total><feedburner:origLink>http://petrocket.blogspot.com/2010/01/simple-flexibile-atmosphere-shaders.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEEERX45fCp7ImA9WxNRF0U.&quot;"><id>tag:blogger.com,1999:blog-2884078902485203181.post-7799963379588558222</id><published>2009-09-12T10:43:00.000-07:00</published><updated>2009-09-12T12:10:04.024-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-09-12T12:10:04.024-07:00</app:edited><title>How Much Memory Does This Planet Need?</title><content type="html">These are the numbers I'm using for the planet in the video and below are estimates of how much uncompressed memory would be needed for a planet with these properties:&lt;br /&gt;&lt;br /&gt;Patch Size (# vertices on a single patch edge): 33&lt;br /&gt;Max Depth of Quad Tree: 5&lt;br /&gt;Texture Size Per Patch: 128 x 128&lt;br /&gt;&lt;br /&gt;Assuming I could use a single height map, normal map and tangent map and sample them by using geomipmapping:&lt;br /&gt;16 bit height map memory = 6 faces x ((33 verts per patch x 2^(max depth + 1)) - (2^(max depth + 1) - 1))^2 x 2 (because 16 bit) &lt;br /&gt;= 6 x ((33 x 64) - (64 - 1))^2 x 2 &lt;br /&gt;= 6 x (2049 x 2049) x 2&lt;br /&gt;= 6 x 8,396,802&lt;br /&gt;= 58,777,614 bytes&lt;br /&gt;&lt;br /&gt;8 bit normal map memory = 6 faces x ((33 verts per patch x 2^(max depth + 1)) - (2^(max depth + 1) - 1))^2 x 3 (for x,y,z)&lt;br /&gt;= 6 x (2049 x 2049) x 3&lt;br /&gt;= 75,571,218 bytes&lt;br /&gt;&lt;br /&gt;tangent map is the same size as normal map&lt;br /&gt;&lt;br /&gt;128x128 textures memory: this is a summation for each level or you can just calculate the amount needed for the deepest level and multiply by 1/3rd for a ceiling estimate (same estimate used when doing mip mapping) because each level is one mip map level lower than the level below it.&lt;br /&gt;= 6 faces x texture size x num patches at lowest level x num bytes per pixel&lt;br /&gt;= 6 faces x (128 x 128) x (2^(max depth + 1))^2 x 3 &lt;br /&gt;= 6 x (128 x 128) x 4096 x 3&lt;br /&gt;= 1,207,959,552 bytes&lt;br /&gt;ceiling = 1,207,959,552 + (1,207,959,552 / 3) = 1,610,612,736 bytes&lt;br /&gt;&lt;br /&gt;So the total is:&lt;br /&gt;58,777,614 + 75,571,218 + 75,571,218 + 1,610,612,736&lt;br /&gt;= 1,820,532,786 bytes&lt;br /&gt;&lt;br /&gt;So just under 2 GB for a single planet and nothing else.  While 2GB is not an unreasonable amount of RAM to ask a gaming rig to set aside these days it is still too much if you want to have a lot of other models, animations and textures loaded.  That's why I've been working on resource management more than anything else. &lt;br /&gt;&lt;br /&gt;I would like to allow the entire planet to be custom made and loaded from disk rather than just generated on the fly and I'd like to be able to support a combination of both.  The idea is that a planet starts out randomly generated and then get's customized by the artist - this should work well in cases where you have a couple continents and the rest is ocean floor, or where you have a moon that is not customized at all.  No reason for your artists to spend time on the ocean floor usually, and hopefully they can tweak the generation parameters to get close the the type of land formations they want.&lt;br /&gt;&lt;br /&gt;Really, I could load the height map into memory and always generate the normals and tangents based on the height map.  The textures would be too large to keep all in memory at once so I would still have to load/unload those as needed.&lt;br /&gt;&lt;br /&gt;Alternately, I could scrap the whole texture per patch thing and go back to some blended texture pixel shader based on a blend map that is the same resolution as the height maps ( 6 x (2049 x 2049) x 8 layers  =  201,523,248 bytes)&lt;img src="http://feeds.feedburner.com/~r/Petrocket/~4/b_tSCxMi69o" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://petrocket.blogspot.com/feeds/7799963379588558222/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2884078902485203181&amp;postID=7799963379588558222" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/7799963379588558222?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/7799963379588558222?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Petrocket/~3/b_tSCxMi69o/how-much-memory-does-this-planet-need.html" title="How Much Memory Does This Planet Need?" /><author><name>alex peterson</name><uri>http://www.blogger.com/profile/10147348345426496177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://4.bp.blogspot.com/_Tt-WoSrRoOs/SqMaDwSfsqI/AAAAAAAAABM/sdkcPTvVX7s/S220/IMG_0932.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://petrocket.blogspot.com/2009/09/how-much-memory-does-this-planet-need.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEMDRHs6eip7ImA9WxNREk0.&quot;"><id>tag:blogger.com,1999:blog-2884078902485203181.post-4406356120779521022</id><published>2009-09-05T18:39:00.000-07:00</published><updated>2009-09-05T19:01:15.512-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-09-05T19:01:15.512-07:00</app:edited><title>MyFirstPlanet Video</title><content type="html">Here's the first video showing the planet with textures and atmosphere shader.  I used &lt;a href="http://fraps.com" target="_new"&gt;fraps&lt;/a&gt; (windows only) and recorded it while running in OpenGL mode.  DirectX would probably be smoother but I haven't ported the shaders to HLSL yet.&lt;br /&gt;&lt;br /&gt;&lt;object width="513" height="282"&gt;&lt;param name="allowfullscreen" value="true" /&gt;&lt;param name="allowscriptaccess" value="always" /&gt;&lt;param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=6449865&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=1&amp;amp;show_portrait=0&amp;amp;color=00ADEF&amp;amp;fullscreen=1" /&gt;&lt;embed src="http://vimeo.com/moogaloop.swf?clip_id=6449865&amp;amp;server=vimeo.com&amp;amp;show_title=1&amp;amp;show_byline=1&amp;amp;show_portrait=0&amp;amp;color=00ADEF&amp;amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="513" height="282"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;p&gt;&lt;a href="http://vimeo.com/6449865"&gt;My First Planet - Work In Progress - Ogre3d Engine&lt;/a&gt; from &lt;a href="http://vimeo.com/petrocket"&gt;petrocket&lt;/a&gt; on &lt;a href="http://vimeo.com"&gt;Vimeo&lt;/a&gt;.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;Now I'm still working on a simple way to pull terrain patch textures and normal maps from the disk when they're available instead of creating them on the fly - this way I hope to be able to modify the diffuse textures and customize the planet (so easy to say, so hard for me to do).&lt;br /&gt;&lt;br /&gt;My first idea is to create a resource pool for the terrain patch diffuse images and normal map images and then load files from disk into those resource pools as need from the build thread.  Not sure if this will work well enough because it may just not be loading enough images in advance to keep ahead of demand.&lt;br /&gt;&lt;br /&gt;I should probably create a second thread that is a low priority thread with an entirely different quad tree based on the camera position in the future (assuming the user keeps moving in the same direction).  I could update this quad tree and load images for this future position when the real camera position based quad tree isn't updating/building (and when would that be???)&lt;img src="http://feeds.feedburner.com/~r/Petrocket/~4/PnqmAsN8fD8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://petrocket.blogspot.com/feeds/4406356120779521022/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2884078902485203181&amp;postID=4406356120779521022" title="5 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/4406356120779521022?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/4406356120779521022?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Petrocket/~3/PnqmAsN8fD8/myfirstplanet-video.html" title="MyFirstPlanet Video" /><author><name>alex peterson</name><uri>http://www.blogger.com/profile/10147348345426496177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://4.bp.blogspot.com/_Tt-WoSrRoOs/SqMaDwSfsqI/AAAAAAAAABM/sdkcPTvVX7s/S220/IMG_0932.JPG" /></author><thr:total>5</thr:total><feedburner:origLink>http://petrocket.blogspot.com/2009/09/myfirstplanet-video.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Dk8CSXY5eyp7ImA9WxNSEkw.&quot;"><id>tag:blogger.com,1999:blog-2884078902485203181.post-2875323573795068649</id><published>2009-08-25T08:04:00.000-07:00</published><updated>2009-08-25T08:41:08.823-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-08-25T08:41:08.823-07:00</app:edited><title>Water Shader Update &amp; Atmosphere Added</title><content type="html">I reintegrated the atmosphere shell/shader and updated the water shell with a heightmap of the terrain under it so I can have the water depth affect the transparency and color and I think it adds a lot - although now everything looks tropical - which I don't mind.&lt;br /&gt;&lt;br /&gt;Water Depth Effects:&lt;br /&gt;&lt;a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/shallow-water-shader2.jpg" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/shallow-water-shader2.project%20featured.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Also I made my underwater texture have fake caustics (static) on them which is subtle but nice:&lt;br /&gt;&lt;br /&gt;Fake Caustics texture:&lt;br /&gt;&lt;a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/fake-caustics.png" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/fake-caustics.project%20featured.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;From Above:&lt;br /&gt;&lt;a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/fake-caustics-above.png" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/fake-caustics-above.project%20featured.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;And here are some pictures of the atmosphere and water shader together from various spots on the planet.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/entering-atmosphere.png" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/entering-atmosphere.project%20featured.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/mountain-lake.png" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/mountain-lake.project%20featured.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/sunset-lake.png" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/sunset-lake.project%20featured.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/mountain-lake-side.png" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/mountain-lake-side.project%20featured.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/sunset-zone3.png" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/sunset-zone3.project%20featured.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You can view all the My First Planet Images in the &lt;a href="http://alexcpeterson.com/alexcpeterson.com/image/tid/1" target="_new"&gt;gallery section&lt;/a&gt; on &lt;a href="http://alexcpeterson.com" target="_new"&gt;my website&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Notes:&lt;br /&gt;- I pretty much eliminated banding in the generated terrain texture images by increasing the resolution of my terrain height maps from 8bit to 16bit.&lt;br /&gt;- The atmosphere still has problems and needs tweaking - there is no sun and the sky to space transition is too abrupt amongst other things.&lt;br /&gt;- PSSM VSM shadows slowed the frame rate down too like 30-40 fps so I left them out for now.&lt;br /&gt;- I need to solve the issue of how noticable texture repeating is from up in the atmosphere and I need to add some noise to the texture generation to make things more interesting.&lt;img src="http://feeds.feedburner.com/~r/Petrocket/~4/FvgInO0yM7g" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://petrocket.blogspot.com/feeds/2875323573795068649/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2884078902485203181&amp;postID=2875323573795068649" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/2875323573795068649?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/2875323573795068649?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Petrocket/~3/FvgInO0yM7g/water-shader-update-atmosphere-added.html" title="Water Shader Update &amp; Atmosphere Added" /><author><name>alex peterson</name><uri>http://www.blogger.com/profile/10147348345426496177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://4.bp.blogspot.com/_Tt-WoSrRoOs/SqMaDwSfsqI/AAAAAAAAABM/sdkcPTvVX7s/S220/IMG_0932.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://petrocket.blogspot.com/2009/08/water-shader-update-atmosphere-added.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkIDQXw-fSp7ImA9WxNTEU4.&quot;"><id>tag:blogger.com,1999:blog-2884078902485203181.post-2462956521477878710</id><published>2009-08-12T19:46:00.000-07:00</published><updated>2009-08-12T20:36:10.255-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-08-12T20:36:10.255-07:00</app:edited><title>Mipmapping RTT in Ogre3D and Look Up Table Filtering</title><content type="html">Two things to write about in this post about the texture generation.  First of all, when you create textures via render to texture in Ogre3d you do not get mipmaps auto-generated for you.  Strangely enough, DirectX still seemed to do some kind of mipmapping, but OpenGL did not.  To implement it in Ogre3d you have to do a render to texture for each mipmap level you want to generate.  Here's how I did it...&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="cpp:nogutter"&gt;&lt;br /&gt;for(unsigned int i = 0; i &lt;= numMipMaps; ++i) {&lt;br /&gt;    // select mipmap level&lt;br /&gt;    target = mTexture-&gt;getBuffer(0,i)-&gt;getRenderTarget();&lt;br /&gt;    target-&gt;setAutoUpdated(false);&lt;br /&gt;&lt;br /&gt;    if(target-&gt;getNumViewports()) {&lt;br /&gt;     // get an existing viewport&lt;br /&gt;     mViewport = target-&gt;getViewport(0);&lt;br /&gt;    }&lt;br /&gt;    else {&lt;br /&gt;     // add a new viewport &lt;br /&gt;     mViewport = target-&gt;addViewport(mRTTCam);&lt;br /&gt;     mViewport-&gt;setClearEveryFrame(false);&lt;br /&gt;     mViewport-&gt;setOverlaysEnabled(false);&lt;br /&gt;    }&lt;br /&gt;    // render the quad&lt;br /&gt;    mSceneMgr-&gt;manualRender(&lt;br /&gt;            &amp;mRenderOp, &lt;br /&gt;            mPass, &lt;br /&gt;            mViewport, &lt;br /&gt;            Matrix4::IDENTITY, &lt;br /&gt;            Matrix4::IDENTITY, &lt;br /&gt;            Matrix4::IDENTITY, &lt;br /&gt;            mBeginEnd //issue a _begin and _end render call&lt;br /&gt;    );&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The results were decent - not as good as hardware generated mipmaps, but better than no mipmaps and yes, it does affect the speed.  Rendering 2 mipmaps isn't so bad a hit but rendering 6+ becomes noticable - sorry I don't have any hard numbers.&lt;br /&gt;&lt;br /&gt;Secondly, I was trying to combat texture banding due to the low resolution of the height maps, slope maps, and look up table.  I use filtering on the height maps and slope maps so those are blended decently, but the look up table couldn't be filtered because the look up table is really 16 look up tables combined into one texture.  When I introduced filtering on the look up table the banding would be lessened but I'd get artifacts where there was bleed between look up tables.  Recall the look up table texture is a 1024x256 texture that is 4 256x256 textures end on end horizontally.  So the horizontal access is all that really matters because vertically there is no bleed (the texture address mode is set to clamp, not wrap).  The horizontal access is the slope value and so what I did was compress the slope value and center it on the middle of the look up table texture so instead of values being from 0 - 255, now they are from 15 - 239 so I don't have to worry about bleeding artifacts anymore (no pun intended).&lt;br /&gt;&lt;br /&gt;Here's a couple before/after images showing how the trilinear filtering on the look up table improves the banding issue:&lt;br /&gt;&lt;br /&gt;Without filtering...&lt;br /&gt;&lt;a href="http://alexcpeterson.com/alexcpeterson.com/node/92" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/lut-no-filter.project%20featured.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;small&gt;(click to zoom in)&lt;/small&gt;&lt;br /&gt;&lt;br /&gt;And with filtering...&lt;br /&gt;&lt;a href="http://alexcpeterson.com/alexcpeterson.com/node/93" target="_new"&gt;&lt;img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/lut-trilinear-filtering.project%20featured.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;small&gt;(click to zoom in)&lt;/small&gt;&lt;br /&gt;&lt;br /&gt;Thoughts:&lt;br /&gt;1. How can I use Multiple Render Targets to render textures faster - group them up so I can render 4 textures with one shader?&lt;br /&gt;2. How can I cheaply introduce noise to the altitude and slope values to make the blending better and more random looking?&lt;br /&gt;3. Why is the terrain slightly blueish and dark?&lt;br /&gt;4. When should I work atmosphere and water back in.&lt;img src="http://feeds.feedburner.com/~r/Petrocket/~4/leZG-ntQkcU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://petrocket.blogspot.com/feeds/2462956521477878710/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2884078902485203181&amp;postID=2462956521477878710" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/2462956521477878710?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/2462956521477878710?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Petrocket/~3/leZG-ntQkcU/mipmapping-rtt-in-ogre3d-and-look-up.html" title="Mipmapping RTT in Ogre3D and Look Up Table Filtering" /><author><name>alex peterson</name><uri>http://www.blogger.com/profile/10147348345426496177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://4.bp.blogspot.com/_Tt-WoSrRoOs/SqMaDwSfsqI/AAAAAAAAABM/sdkcPTvVX7s/S220/IMG_0932.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://petrocket.blogspot.com/2009/08/mipmapping-rtt-in-ogre3d-and-look-up.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUADQHo5eyp7ImA9WxJaF0s.&quot;"><id>tag:blogger.com,1999:blog-2884078902485203181.post-3338548124990991835</id><published>2009-08-08T12:55:00.000-07:00</published><updated>2009-08-08T13:36:11.423-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-08-08T13:36:11.423-07:00</app:edited><title>Planet Terrain Texture Generation Optimization Continues</title><content type="html">I put a lot of profiling code in &lt;a href="http://ogre3d.org" target="_new"&gt;Ogre's&lt;/a&gt; SceneManager::manualRender() function and in SceneManager::_setPass() as well as in the GL_RenderSystem::_render() function etc.  Turns out my profiling code in GL_RenderSystem seems to have skewed my profile results.&lt;br /&gt;&lt;br /&gt;Profiling the code wasn't giving me many optimization ideas so I took another approach.  You know how when you have slow code sometimes you just cut parts of it out till you find out what is slow about it - not the best way to optimize but it can give you some insight when you don't fully understand the design and implementation of libraries you are using (&lt;a href="http://ogre3d.org" target="_new"&gt;Ogre3d&lt;/a&gt; in my case).  I could see from the profiling results that it would be good to focus on the Render To Texture(RTT) code so I started removing all the texture look ups in my RTT shader except one and the timing/stuttering issues improved noticeably.  I started by adding back in each texture look up one by one to see if adding a certain texture brought back the stuttering/slowness.&lt;br /&gt;&lt;br /&gt;It seems that some of my terrain textures were 1024x1024 while the rest were 512x512 (I have 16 terrain textures that get blended in the RTT shader).  So I converted those to 512x512 and that helped - and it seems that going above ~8 512x512 textures gives unacceptable slowness and more stuttering.  For some reason this is only an issue with OpenGL Render System not DirectX Render System which seems to handle 16 blends fine with no stuttering and faster render times.  I may look into this more later because I think I need at least 12 terrain textures.&lt;br /&gt;&lt;br /&gt;I might try having several large shared height maps and slope maps - one per cube face to start - instead of one small height map and slope map per terrain patch.  I just like the simplicity of the current approach, but it is probably going to be too slow.&lt;br /&gt;&lt;br /&gt;Also, I've moved up to the latest &lt;a href="http://ogre3d.org" target="_new"&gt;Ogre release v1.6.3&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Lastly, I tried &lt;a href="http://glintercept.nutty.org/" target="_new"&gt;GLIntercept&lt;/a&gt; which was very nice and easy to use and can output textures, all the OpenGL calls and lots more.  Did I mention it's free?&lt;br /&gt;&lt;br /&gt;At some point I need to start saving rendered terrain textures and height maps and normal maps to disk then reading them back from disk instead of generating them every time.&lt;img src="http://feeds.feedburner.com/~r/Petrocket/~4/El0c0_UolJE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://petrocket.blogspot.com/feeds/3338548124990991835/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2884078902485203181&amp;postID=3338548124990991835" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/3338548124990991835?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/3338548124990991835?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Petrocket/~3/El0c0_UolJE/planet-terrain-texture-generation.html" title="Planet Terrain Texture Generation Optimization Continues" /><author><name>alex peterson</name><uri>http://www.blogger.com/profile/10147348345426496177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://4.bp.blogspot.com/_Tt-WoSrRoOs/SqMaDwSfsqI/AAAAAAAAABM/sdkcPTvVX7s/S220/IMG_0932.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://petrocket.blogspot.com/2009/08/planet-terrain-texture-generation.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUMMR38_fCp7ImA9WxJbFks.&quot;"><id>tag:blogger.com,1999:blog-2884078902485203181.post-4101755293982335872</id><published>2009-07-26T19:38:00.000-07:00</published><updated>2009-07-26T19:58:06.144-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-07-26T19:58:06.144-07:00</app:edited><title>OpenGL Render To Texture 10x Slower than DirectX</title><content type="html">That's my main problem right now.  It takes roughly 10 - 20 times longer when I call mSceneManager-&gt;manualRender() when using OpenGL in &lt;a href="http://ogre3d.org" target="_new"&gt;Ogre&lt;/a&gt; instead of DirectX (9).&lt;br /&gt;&lt;br /&gt;After getting my app running in DirectX, I used NVidia Perfhud to debug the framerate spikes - only to find that DirectX is vastly outperforming OpenGL!  So now I can't really afford &lt;a href="http://www.gremedy.com/purchase.php" target="_new"&gt;gDEBugger&lt;/a&gt; ($800), so I'm stuck with inserting my mini-profiler into the GL_RenderSystem code to figure out what parts are slowing down etc.  That will be a good experience and help me get more familiar with Ogre RenderSystem calls.&lt;br /&gt;&lt;br /&gt;Misc Notes:&lt;br /&gt; - Make sure you play around with your RenderSystem configuration settings.  I had set my Display Frequency to 59 and that caused the framerate to be cut in half.  Dunno why I had it set to that value.&lt;br /&gt; - With OpenGL you don't need the RenderSystem to issue _begin() and _end() frame calls, but you do in DirectX.&lt;br /&gt; - &lt;a href="http://ogre3d.org/forums/viewtopic.php?f=2&amp;t=51258" target="_net"&gt;Fixed a bug where when writing dynamic textures I was using pointer math and it was messing up my textures in DirectX&lt;/a&gt;.  I switched to using array notation and it fixed the issue.  Haven't spent much time figuring out why I was having so much grief with that (it worked fine with the OpenGL RenderSystem).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Next, I plan on profiling the GL_RenderSystem to figure out those RTT issues, and upgrading to the &lt;a href="http://www.ogre3d.org/2009/07/26/ogre-v163-shoggoth-released" target="_new"&gt;newly released Ogre version 1.6.3!!&lt;/a&gt;&lt;img src="http://feeds.feedburner.com/~r/Petrocket/~4/fAQQEwl0dzc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://petrocket.blogspot.com/feeds/4101755293982335872/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2884078902485203181&amp;postID=4101755293982335872" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/4101755293982335872?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/4101755293982335872?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Petrocket/~3/fAQQEwl0dzc/opengl-render-to-texture-10x-slower.html" title="OpenGL Render To Texture 10x Slower than DirectX" /><author><name>alex peterson</name><uri>http://www.blogger.com/profile/10147348345426496177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://4.bp.blogspot.com/_Tt-WoSrRoOs/SqMaDwSfsqI/AAAAAAAAABM/sdkcPTvVX7s/S220/IMG_0932.JPG" /></author><thr:total>0</thr:total><feedburner:origLink>http://petrocket.blogspot.com/2009/07/opengl-render-to-texture-10x-slower.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DU4BRXk6fSp7ImA9WxJbEk8.&quot;"><id>tag:blogger.com,1999:blog-2884078902485203181.post-9202347246541254984</id><published>2009-07-21T18:43:00.000-07:00</published><updated>2009-07-21T18:59:14.715-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-07-21T18:59:14.715-07:00</app:edited><title>Optimisation Fail</title><content type="html">This is a maintenance/progress blog post so nothing exciting really.  I just try to post a few times a month as any developer keeping a journal should.&lt;br /&gt;&lt;br /&gt;I got rid of the vertex buffer and texture resource pools and created a mesh pool and each mesh has its' own vertex buffer and textures so the same thing is accomplished and the mesh resource manager is now way simpler.  I used to have std::maps with pointers to the meshes in each list depending on what stage the mesh was in (needs building, built, and visible, cached and cache build) - now I have 3 std::vectors for 3 lists: needs building, built and visible.&lt;br /&gt;&lt;br /&gt;The lists are stored in an array like this:&lt;br /&gt;&lt;br /&gt;std::vector&lt;MeshHandle h&gt; mMeshLists[3];&lt;br /&gt;&lt;br /&gt;The built and visible lists are in index 0 and 1 and I swap them periodically like this:&lt;br /&gt;&lt;br /&gt;mVisibleListIndex = (mBuiltListIndex + 1) % 2;&lt;br /&gt;&lt;br /&gt;And the build list is always index 2.&lt;br /&gt;&lt;br /&gt;Unfortunately, the app is still too jerky.  Creating the textures on the graphics card is taking too long, generating the heightmaps is taking too long and it's not smooth even though I'm using threads for all the non-opengl stuff.  Most of the time spikes are now happening in Ogre so I will probably have to add some profiling there to figure out what's going on.&lt;br /&gt;&lt;br /&gt;Also, I switch over to DirectX 9 so that I can use NVidia's Perfhud tool to help me analyze how the graphics card and cpu are being utilized.  That's been fun.&lt;br /&gt;&lt;br /&gt;The only major bug I have at the moment is that the Render To Texture code that generates the terrain texture for each patch isn't working in DirectX right.  My dynamic heightmap texture is not being created correctly and I don't know why yet.  I have been experimenting with different pixel formats to no avail yet.&lt;br /&gt;&lt;br /&gt;I'm almost thinking of doing another simpler version of the quad tree planet that uses geomippmapping and the planet size is restricted to 1025x1025 vertices per side - or maybe 2049x2049.  This terrain is taking too much of my time to code that should be spent on other important game things!&lt;img src="http://feeds.feedburner.com/~r/Petrocket/~4/xobKmghKNig" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://petrocket.blogspot.com/feeds/9202347246541254984/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=2884078902485203181&amp;postID=9202347246541254984" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/9202347246541254984?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2884078902485203181/posts/default/9202347246541254984?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Petrocket/~3/xobKmghKNig/optimisation-fail.html" title="Optimisation Fail" /><author><name>alex peterson</name><uri>http://www.blogger.com/profile/10147348345426496177</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://4.bp.blogspot.com/_Tt-WoSrRoOs/SqMaDwSfsqI/AAAAAAAAABM/sdkcPTvVX7s/S220/IMG_0932.JPG" /></author><thr:total>2</thr:total><feedburner:origLink>http://petrocket.blogspot.com/2009/07/optimisation-fail.html</feedburner:origLink></entry></feed>
