tag:blogger.com,1999:blog-28840789024852031812024-03-12T20:16:12.608-07:00PETROCKETgame and graphics developer journalalex petersonhttp://www.blogger.com/profile/10147348345426496177noreply@blogger.comBlogger55125tag:blogger.com,1999:blog-2884078902485203181.post-9311032112620984002014-09-23T18:52:00.001-07:002014-09-23T19:06:13.762-07:00NEW Spacescape gets HDR, OSX and more<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: left;">
Version 0.5 of Spacescape has been released - <a href="http://alexcpeterson.com/spacescape" target="_blank">Download it!</a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkOGL5pvxjqGRQHlx8n7hWDZ1MJeuoU8ieQghJMkxXe4bDgtTbePWLyc9CbzX95vJCXhqmHLzQJ35eJ4EbFrQkQe1WDT3GMcHh_PmYJP_SNJ6r0tr9DYzLkZ6_r0o_ARzMI22imLSTg5RW/s1600/spacescape-0.5-windows.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkOGL5pvxjqGRQHlx8n7hWDZ1MJeuoU8ieQghJMkxXe4bDgtTbePWLyc9CbzX95vJCXhqmHLzQJ35eJ4EbFrQkQe1WDT3GMcHh_PmYJP_SNJ6r0tr9DYzLkZ6_r0o_ARzMI22imLSTg5RW/s1600/spacescape-0.5-windows.jpg" height="227" width="400" /></a></div>
<br />
<br />
If you were waiting for <a href="http://alexcpeterson.com/spacescape" target="_blank">Spacescape</a> to run on OSX, your wait is over! Not only is it over, Spacescape got some requested features that are really cool.<br />
<br />
v0.5 FEATURE LIST<br />
<br />
<ul>
<li>Support for OSX</li>
<li>HDR mode for working in high dynamic range and exporting 32bit per channel .exr or .dds skybox images. Also allows for using HDR billboards (.exr)</li>
<li>Import billboard data file to manually specify billboard positions, brightness, distance and colour</li>
<li>More export options! Export now adds support for <b>UNREAL</b> (3d cube map with correct rotations and .dds output), <b>UNITY</b> (correct naming), <b>SOURCE</b> (correct naming and .tga output)</li>
<li>Debug box option for those trying to determine the orientation of the exported skybox faces for importing into a different engine</li>
<li>Converted billboard file field to support a browse button so you can choose any file on your computer instead of having to put them in the media/materials/textures folder</li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1OrDzfgJdYUB_204SyKVF5ZZwMDbCesi1A3QBgtbql9Sn0ryiebAuiKDLOpR7SvhQDNmlq9ckMWQNZhCa8-hi-oUdZ2VJhPqLFc4_Sa0d524x2lEN01Mlcqf0p_pWhVnM2sMlruiZMmKy/s1600/spacescape-0.5-windows2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1OrDzfgJdYUB_204SyKVF5ZZwMDbCesi1A3QBgtbql9Sn0ryiebAuiKDLOpR7SvhQDNmlq9ckMWQNZhCa8-hi-oUdZ2VJhPqLFc4_Sa0d524x2lEN01Mlcqf0p_pWhVnM2sMlruiZMmKy/s1600/spacescape-0.5-windows2.jpg" height="227" width="400" /></a></div>
<h3>
</h3>
<h3>
About this HDR thing..</h3>
<div>
You can thank the good folks at <a href="http://nvidia.com/" target="_blank">NVidia Demos</a> for financing the addition for a <a href="http://game24.nvidia.com/maxwell/" target="_blank">recent demo</a> they released! You can see part of the Spacescape generated HDR starfield with actual star values, positions, brightness values, colours and some generated nebulas around 6:54.</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<object class="BLOGGER-youtube-video" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" data-thumbnail-src="https://ytimg.googleusercontent.com/vi/O9y_AVYMEUs/0.jpg" height="266" width="320"><param name="movie" value="https://youtube.googleapis.com/v/O9y_AVYMEUs&source=uds" /><param name="bgcolor" value="#FFFFFF" /><param name="allowFullScreen" value="true" /><embed width="320" height="266" src="https://youtube.googleapis.com/v/O9y_AVYMEUs&source=uds" type="application/x-shockwave-flash" allowfullscreen="true"></embed></object></div>
<div>
<br /></div>
<div>
It's really cool, but for most games you'll probably stick with non-HDR because you just don't need the extra data. HDR skyboxes are cool when you want to accurately adjust the exposure in your game for, say, a daytime scene when the stars are not visible because the atmosphere is so bright, and then as night comes and the atmosphere is no longer bright the stars become visible. Keep in mind a few things:</div>
<div>
<ol>
<li>Use HDR billboards in .exr format or the outlines of your billboard stars will get too blown out as you adjust the exposure. Some sample .exr billboards are included in the app or you can make your own in Gimp or Photoshop.</li>
<li>Use the new HDR Power field to push most of your stars into the background if you are using randomly generated star positions, otherwise use a data file.</li>
<li>If you use a data file to specify star data, the input is a csv file that requires an X, Y, Z, ABSMAG, and DISTANCE. All these values are based on actual star data and there is a sample data.csv file with a few constellations in it in the Files section of project. You can also find a massive star database at <a href="http://www.astronexus.com/hyg" target="_blank">http://www.astronexus.com/hyg</a></li>
<li>Use HDR Multiplier to make background stars and nebulas really faint and near stars bright</li>
<li>A good range for HDR brightness values is between 0 and 10, even though the colour values for stars is from 0 to 255, when in HDR mode those numbers are actually converted to the 0 to 1 range then the HDR power function is applied and the result is multiplied by the HDR multiplier.</li>
</ol>
</div>
<div>
<br /></div>
<h3>
There's lots left to do</h3>
<div>
And that's an <u>understatement</u>. Spacescape is nothing like the final tool I want it to be. I want to implement a simple mode for non-wizards, and a skybox library - a way to share skyboxes from within the app amongst many other things. I'd also like improve the way layer masks work and possibly add terrain and planets!</div>
<div>
<br /></div>
<h3>
Kickstarter?</h3>
<div>
To add all the features I want would take a lot of time. I was only able to add in these recent features because Nvidia was able to help pay for those hours. So I'm considering putting up a kickstarter or indiegogo project to get the other features funded. Maybe nobody will notice? On the other hand, Spacescape has been downloaded 41,000 times since I posted it in 2010.</div>
alex petersonhttp://www.blogger.com/profile/10147348345426496177noreply@blogger.com4tag:blogger.com,1999:blog-2884078902485203181.post-17879965852369467532014-08-11T17:49:00.002-07:002014-08-11T17:49:26.502-07:00Adventures in Phaser.ioWith the <a href="http://christiandevs.com/news/?page_id=509" target="_blank">Christian Game Dev contest </a>coming up, I decided to use a game engine I've wanted to use for a while. There's a web game engine called <a href="http://phaser.io/" target="_blank">Phaser</a>, written in Javascript that uses Canvas or WebGL for rendering and HTML5 for audio. The documentations and community is awesome, they even have an IRC chat room where you can get instant community support!<br />
<br />
<h3>
The Competition</h3>
<br />
For the competition theme this year, you could pick from one of three verses. I chose the Hosea 6:6 verse which says something like, "For I desire mercy, not sacrifice, and acknowledgment of God rather than burnt offerings."<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://alexcpeterson.com/sites/default/files/images/Screen%20Shot%202014-08-11%20at%208.11.32%20PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://alexcpeterson.com/sites/default/files/images/Screen%20Shot%202014-08-11%20at%208.11.32%20PM.png" height="225" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Yer a pirate yarg!</td></tr>
</tbody></table>
<br />
In my game you're player is a pirate and you go around collecting treasure and fighting while running from the King's men. At one point you get caught, told the truth and are given the option to be pardoned and join the King's men or be banished. After you join the King's men you are given a new sigil, clothes and a mission to recover the King's treasure/keep the peace and offer the same deal to any other pirates you encounter. Get it? I know, I'm no C.S. Lewis, but it's one of my favorite CDN game ideas so far.<br />
<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://alexcpeterson.com/sites/default/files/images/Screen%20Shot%202014-08-11%20at%208.11.50%20PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://alexcpeterson.com/sites/default/files/images/Screen%20Shot%202014-08-11%20at%208.11.50%20PM.png" height="225" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Booty!</td></tr>
</tbody></table>
I spent too much time on creating assets and just figuring out how to work with Phaser, and then went on vacation half way through the allotted time, so I never finished it.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://alexcpeterson.com/sites/default/files/images/pirate.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://alexcpeterson.com/sites/default/files/images/pirate.png" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Pirate sprite sheet</td></tr>
</tbody></table>
<br />
I used <a href="http://www.mapeditor.org/" target="_blank">Tiled</a> for making the levels, photoshop for all the art and did my coding in Sublime.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://alexcpeterson.com/sites/default/files/images/props.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://alexcpeterson.com/sites/default/files/images/props.png" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Custom props!</td></tr>
</tbody></table>
<br />In the end I would say that Phaser is a good engine for creating a web game. It has just about <a href="http://examples.phaser.io/" target="_blank">every kind of example</a> you need to make your 2D game. The downside of <a href="http://phaser.io/" target="_blank">Phaser</a>, for me, is that it is written in Javascript and I have yet to find an editor that I really like for Javascript. XCode has ruined me with it's code completion and super easy navigation. With Phaser, I was constantly flipping back and forth between the API in browser and Sublime, where as in XCode I would use auto-complete or cmd+click my way to the header files for whatever I was working on and rarely have to use my web browser for anything. Sooooo much faster!<br /><br />
If you have to chose a platform for a web game, I'd say <a href="http://phaser.io/" target="_blank">Phaser</a> is one of the best I've seen, but if you don't really care so much about open source and not needing any plugins you can always join the herd and head over to <a href="http://unity3d.com/">unity3d.com</a>alex petersonhttp://www.blogger.com/profile/10147348345426496177noreply@blogger.com0tag:blogger.com,1999:blog-2884078902485203181.post-39506421731469859132014-04-01T18:02:00.000-07:002014-04-01T18:04:50.654-07:003D Puzzle Game "PZL" Released!<div>
Back in, oh, last year I threw together a game for <a href="http://petrocket.blogspot.com/2013/05/ludum-dare-26.html" target="_blank">Ludum Dare 26 called "Puzzle Cube"</a> that was built entirely on <a href="http://ogre3d.org/" target="_blank">Ogre3D</a>. Shortly after, I ported that game to iOS and showed it to a friend who really encouraged me to develop it into a full-on mobile game with levels, scores, and everything. Since then I've made 30 code commits and added a bunch of features and levels and <a href="https://itunes.apple.com/us/app/pzl/id812626888?mt=8" target="_blank">released it on the iTunes Store</a> under the official name PZL. Dayum.<br />
<blockquote class="tr_bq">
<span style="font-family: Georgia, Times New Roman, serif; font-size: large; font-weight: normal;"><i>"IT'S LIKE SOME KINDA FRIKIN MAZE"</i></span></blockquote>
Well actually, in PZL you control a glowing blue orb that starts at the base of the puzzle tower. Each level of the tower can be rotated so you can move the blue orb up till you reach the end of the level - and eventually the top of the tower. Along the way you'll discover tunnels through the puzzle, prizes, and monsters to evade.<br />
<br /></div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjchjtqBP6sH0tQGnC3fMLQUXn7fOZW5m1QvEfpUGdIVa7RjK7iP9xcFUyVl03v-5JBealGR62wIXgEQJvgnZwPQJ9bT_lD5az6MTfKJgu4X7SE0WSE_AcPSfWl1ED80y9_DDx3us-ZYVgC/s1600/pzl568x568.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjchjtqBP6sH0tQGnC3fMLQUXn7fOZW5m1QvEfpUGdIVa7RjK7iP9xcFUyVl03v-5JBealGR62wIXgEQJvgnZwPQJ9bT_lD5az6MTfKJgu4X7SE0WSE_AcPSfWl1ED80y9_DDx3us-ZYVgC/s1600/pzl568x568.jpeg" height="320" width="180" /></a>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrfooNXu1aKsmehWrSzHghqO1scm-wMMDBNYCTcG1YZ1xSJVyKzP1PyNlKYcP1hWiddDebpzybZzmsvYxAPTijBeAS4vaiLIb2PKicLLBJQ3eCOM5MSqCOpp2FC0ZgXUcUsDffdxoF5HA8/s1600/pzl2568x568.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgrfooNXu1aKsmehWrSzHghqO1scm-wMMDBNYCTcG1YZ1xSJVyKzP1PyNlKYcP1hWiddDebpzybZzmsvYxAPTijBeAS4vaiLIb2PKicLLBJQ3eCOM5MSqCOpp2FC0ZgXUcUsDffdxoF5HA8/s1600/pzl2568x568.jpeg" height="320" width="180" /></a>
</div>
<br />
<h2>
</h2>
<h2>
</h2>
<h2>
The Journey.</h2>
<br />
So how did a game that started out looking like this:<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td><a href="http://www.ludumdare.com/compo/ludum-dare-26/?action=preview&uid=23254" imageanchor="1" style="margin-left: auto; margin-right: auto;" target="_blank"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfUuEK__tjJGcINIsLsCMbjE0OnJ4EZd0doNtLwUCTSSNgFaVhOh3ZkkjtUy7fCRIg8tYGg4WdI0JIiEctCWxFMJhCXgFXEGuDBCzyxTB6TrMw2H4B7F5c9cftRRnqqkXeayuZtght1muK/s320/puzzlecube.jpg" height="180" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="font-size: 13px;">Ludum Dare 26 - PuzzleCube</td></tr>
</tbody></table>
Get to this?<br />
<div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglKXYlH9qwFpvHwWsPVs5ED0NIoV17mL4o15CEM-l_CBDfld_SulinyBmqFJWmpG6PMFYHYCeUNdknO5c5ZJO8xlh1RWJrHFtOvoQe-ddsZ86scsYWHaCjVK_zUUckzU3gWHCMJCGmASrB/s1600/pzl3568x568.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglKXYlH9qwFpvHwWsPVs5ED0NIoV17mL4o15CEM-l_CBDfld_SulinyBmqFJWmpG6PMFYHYCeUNdknO5c5ZJO8xlh1RWJrHFtOvoQe-ddsZ86scsYWHaCjVK_zUUckzU3gWHCMJCGmASrB/s1600/pzl3568x568.jpeg" height="320" width="180" /></a>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihV8vs0dJuc6hJQwrmc_tuC9UpoTGz1J9IJlgHS4genzXRUtCzByDiQiDjSJTetVZiiRp3Lx0oNUZkB3L346oBktd8yoxAq8okLFcBcN7IUN4nuWZucbpBiyre6WD4qWjLvS7YoGHo8zxT/s1600/pzl4568x568.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihV8vs0dJuc6hJQwrmc_tuC9UpoTGz1J9IJlgHS4genzXRUtCzByDiQiDjSJTetVZiiRp3Lx0oNUZkB3L346oBktd8yoxAq8okLFcBcN7IUN4nuWZucbpBiyre6WD4qWjLvS7YoGHo8zxT/s1600/pzl4568x568.jpeg" height="320" width="180" /></a>
</div>
<br />
<br />
First of all, porting to an iOS mobile device when you start out with a Windows build isn't a walk in the park. In Windows your render loop is probably some endless while loop or frame listener. On iOS you have an Objective C app that sets up a CADisplayLink callback on a frame interval. The callback then manually instructs Ogre to renderOneFrame. Then there's the matter of getting input from the keyboard, touch input, outputting audio, not to mention any kind of networking or saving to disk you might need - ouch!<br />
<br />
Let's talk bout some of those -<br />
<br />
<h2>
Ogre3D</h2>
<br />
I used the OgreDemoApp/OgreFramework for iOS as a base so I had to refactor my initialization code so it worked with the OgreFramework. I had to pass down some things like the scene manager, camera and window handle to my main game class. I also decided to make my Game class a singleton mainly referenced through the OgreFramework so I could easily pass down frame render events and input events from OIS, but I probably could have architected it all differently and merged my main game class with the OgreDemoApp class. The downside of merging would have been that I would have a lot more code in that merged class that wouldn't get used on say the Windows version.<br />
<br />
Also, I had to remove all the OgreBites tray code and the majority of the camera manipulation so my game could control it instead.<br />
<br />
<h2>
Audio</h2>
<br />
Things got a bit hairy when I needed to expose some things to C++ code that were only available in Objective C, namely audio, keyboard input and session data (stored in NSUserDefaults).<br />
<br />
I chose to use the SimpleAudioEngine for audio which comes from CocosDenshion (Cocos2D also uses this). It's a really simple audio player that easily handles background and event audio. So how do you access an Objective C class from inside game code which is written in C++?<br />
<br />
What I did was create a GameAudio Objective C class:<br />
<br />
<script src="https://gist.github.com/anonymous/9925513.js"></script>
The implementation file for GameAudio (named GameAudio.mm) has my functions that call the SimpleAudioEngine class like so:<br />
<br />
<script src="https://gist.github.com/petrocket/9925695.js"></script>
To call those GameAudio functions from C++ I provide another header file called GameAudioInterface.h with headers for the functions in GameAudio.mm<br />
<br />
<script src="https://gist.github.com/petrocket/9925722.js"></script>
<br />
<h2>
Keyboard Input</h2>
<br />
WARNING HAX. I created a GameKeyboard Objective C class with an invisible UITextField added to the main UIWindow. <br />
<br />
<br />
<script src="https://gist.github.com/petrocket/9925734.js"></script>
Inside the implementation file I provided functions to show/hide the keyboard and called functions in my main game code when a key was pressed. Because the game code used OIS I had to map every character to the OIS equivalent. YUCK.<br />
<br />
<br />
<script src="https://gist.github.com/petrocket/9925744.js"></script>
Lastly, I exposed the keyboard show/hide functions in a header included in the C++ game code called<br />
<br />
<script src="https://gist.github.com/petrocket/9925749.js"></script>
<br />
<div class="p1">
Hopefully that code saves somebody some time.</div>
<br />
<br />
<h2>
Other Objective-C Stuff n' Thangs</h2>
<br />
OK besides audio and keyboard libraries I used NSUserDefaults to save some basic settings and the excellent <a href="http://scoreoid.net/" target="_blank">Scoreoid</a> API for saving player scores. For those who are unaware, <a href="http://scoreoid.net/" target="_blank">Scoreoid</a> lets you save scores for free using their platform agnostic API so this means if I port the game to <b>Android</b> I can access the same score data in the future.<br />
<br />
Lastly, I implemented the <a href="http://chartboost.com/" target="_blank">Chartboost SDK</a> to serve ads.<br />
<br />
<h2>
Technology Used</h2>
<br />
Graphics Engine: <a href="http://ogre3d.org/" target="_blank">Ogre3D</a><br />
GUI: <a href="https://github.com/betajaen/gorilla" target="_blank">Gorilla</a><br />
Input: <a href="http://sourceforge.net/projects/wgois/" target="_blank">OIS</a><br />
Audio: <a href="http://www.cocos2d-iphone.org/" target="_blank">SimpleAudioEngine (CocosDenshion)</a><br />
Scores: <a href="http://scoreoid.net/" target="_blank">Scoreoid</a><br />
Animation: <a href="https://code.google.com/p/cpptweener/" target="_blank">CppTweener</a><br />
Network: <a href="https://github.com/AFNetworking/AFNetworking" target="_blank">AFNetworking</a><br />
<br />
<br />
That pretty much about sums things up as far as the development goes. I do plan on adding some more gameplay elements in the future if the game has enough of an audience to warrant updates.<br />
<br />
You can download PZL via the iTunes App Store on your mobile device or click the link here:<br />
<a href="https://itunes.apple.com/us/app/pzl/id812626888?mt=8">https://itunes.apple.com/us/app/pzl/id812626888</a><br />
<br />
Thanks and enjoy!</div>
alex petersonhttp://www.blogger.com/profile/10147348345426496177noreply@blogger.com2tag:blogger.com,1999:blog-2884078902485203181.post-81395782088791575032014-01-11T19:44:00.000-08:002014-01-11T19:44:24.114-08:00My Fav Games 2013Before the game list I'd like to say the obvious - I've been really busy being a dad and running a business (<a href="http://inthepin.es/" target="_blank">http://inthepin.es</a>) and that has left me with little time to play or make games this year. I've have done a TON of iOS development and a good bit of web dev and am about to release a small puzzle game for iPhone/iPad soon - will post about that when I do. With that out of the way -<br />
<br />
A new year is upon us. Again. So what games were awesome in 2013 for me?<br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://naturalselection2.com/" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" target="_blank"><img alt="" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRkuvymgzh40aHSizRteY6cJHuBspF1Ess4WFofJ6iGVNau1E168aDz6EHMjt0l0F1isN-vSaPPx_nPZIxQIA0sxGPg7KEvrTr7D4KzsQlOkNdwKRsH3OzI32j2Km61vbKDMHS6slddvZd/s1600/ns2.png" style="cursor: move;" title="Natural Selection 2" /></a></div>
<h4>
Natural Selection 2 - <a href="http://naturalselection2.com/" target="_blank">naturalselection2.com</a></h4>
I spent a good bit of time playing this, mostly because I don't have enough time to commit to an MMO and I like to be able to jump into a quick game and out. The dev team has also been putting out some impressive updates to the game that have kept it interesting and fun. Also, the e-sport aspect of this game is immensely entertaining as well, and the matches have made appearances on <a href="http://twitch.tv/">twitch.tv</a> front page often for good reason.<br />
<br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQGV8OUYu270TD6na8Pw_gVN_UyWyQcU_L9t4bXel0swvQcTll-Oqp5AkHN3LWA93h1RVeecIls_3tWXy82opCMmHPf1_jHIqYUmyVxu5UWgPnIEFivM9BrptrZCAh7vAVPx_fYu6IrM-z/s1600/me3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQGV8OUYu270TD6na8Pw_gVN_UyWyQcU_L9t4bXel0swvQcTll-Oqp5AkHN3LWA93h1RVeecIls_3tWXy82opCMmHPf1_jHIqYUmyVxu5UWgPnIEFivM9BrptrZCAh7vAVPx_fYu6IrM-z/s1600/me3.png" /></a></div>
<br />
<h4>
Mass Effect 1 - 3 - <a href="http://masseffect.bioware.com/" target="_blank">masseffect.bioware.com</a></h4>
This game was the most compelling single player game that I played in 2013 - I had to buy it after it went on sale and after hearing how much the ending upset so many people. Load of fun and graphics are pretty good. If and when this franchise continues I will be watching to see if I want to continue my characters.<br />
<br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://minecraft.net/" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" target="_blank"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjr6w2wxtEKBcxfM097M4p1J-wmyQeay0MZWzMJZh3WoAWPty_64q_zIGmZPYsb_4H4Q3mfKA4oHe_7Bm0qwpS-E_PBEcT9rMG85CkZU6o3gileMTeXVMguwitAmGjNIoqnw8eK1j5SS9ib/s1600/minecraft.png" /></a></div>
<h4>
Minecraft - <a href="http://minecraft.net/" target="_blank">minecraft.net</a></h4>
My 4 year old son loves this game and because of that I have gone through the hell that is minecraft mod setup on multiple machines and servers. It has been worth it though, and has provided us a ton of fun multiplayer gaming and I would even say it has taught my son how to use a mouse and keyboard.<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMYvQ-ymNJHe0Lk4jbeFwpMAMkZyjiuLEJRscomE8Rv__4ZR-zzH_93inf4V4lkeH656q8ClVoqloelpcPNR9bn4xV9IeCOip1W8fKOiF2IgUQy2QhVxOANXyOWvZ-3oS39SQJh_YdLGGR/s1600/civ5.png" /></div>
<h4>
Civilization V - <a href="http://civilization5.com/" target="_blank">civilization5.com</a></h4>
This game has remained on my favorites list because it is so casual and addictive and sometimes I don't want to get my heart rate up trying to shoot things in a twitched based game. For casual and still awesome I recommend Civilization.<br />
<br />
<br />
As for honorable mentions, I also tried Borderlands, various X3 expansions and a few mobile games, but nothing really kept my attention for long except those listed above. Hopefully I'll have more to post soon after releasing this mobile puzzle game I have in the oven.alex petersonhttp://www.blogger.com/profile/10147348345426496177noreply@blogger.com0tag:blogger.com,1999:blog-2884078902485203181.post-11955680481441126022013-08-18T11:49:00.000-07:002013-08-21T19:33:03.935-07:00Christian Game Dev Speedgame 2013 - SalvationThe theme for this year's <a href="http://www.christiandevs.com/phpBB3/viewtopic.php?f=55&t=6293&sid=65826799514117dc11d5328d82844658" target="_blank">Christian Game Dev Speedgame</a> was "Salvation". My idea was to create a <a href="http://www.ftlgame.com/" target="_blank">Faster Than Light</a> clone where the goal is to escape the blast radius of an exploding star. <br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='550' height='310' src='https://www.youtube.com/embed/v41jicFEWVw?feature=player_embedded' frameborder='0'></iframe></div>
<br />
Source Code: <a href="https://github.com/petrocket/salvation" target="_blank">https://github.com/petrocket/salvation</a><br />
<br />
Download Game (Windows only sorry):<br />
<span style="color: #555555; font-family: monospace, sans-serif; font-size: 13px; line-height: 18px; white-space: nowrap;"><a href="http://sourceforge.net/projects/salvation-game" target="_blank">Download From Sourceforge.net</a></span><br />
<br />
Live broadcasts during speedgame:<br />
<a href="http://twitch.tv/petrocket" target="_blank">http://twitch.tv/petrocket</a><br />
<br />
<h3>
The Storyline</h3>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwHMclGjcfdQ1P6PO4wAS5rAnu9UuP6BdhFRxEUUj9sAhrze5SW6HA4h_81Fime7ErMVj1kkco7T8xP5hLOAZYfPH_VV-UBVLsX9m3GONiW-MCqYSV2KlK3wkXuDBkost-87Hq8iYrz8rx/s1600/salvation+2013-08-18+13-41-34-38.png" imageanchor="1" style="clear: left; display: inline !important; margin-bottom: 1em; margin-left: auto; margin-right: auto; text-align: center;"><img border="0" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwHMclGjcfdQ1P6PO4wAS5rAnu9UuP6BdhFRxEUUj9sAhrze5SW6HA4h_81Fime7ErMVj1kkco7T8xP5hLOAZYfPH_VV-UBVLsX9m3GONiW-MCqYSV2KlK3wkXuDBkost-87Hq8iYrz8rx/s400/salvation+2013-08-18+13-41-34-38.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Ye Title Screen with random background!</td></tr>
</tbody></table>
<br />
Your uncle sends you a message one day saying the star in your solar system will explode and he gives you a space ship called "Salvation" and tells you to fly it to the outer-most planet in the system to escape the blast radius. Along the way you may need to fight hostile attackers, upgrade your ship, and complete various missions to fund your journey. Also, you should pick up passengers along the way to get as many people to safety as possible.<br />
<br />
<h3>
The Gameplay</h3>
<div class="separator" style="clear: both; text-align: center;">
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfHKNy7e8Iz4QUEk4jtoSb666_v-VMh-UUDSl0N0bb9-UFIj-P7L9isQwYgemRUBmUQERO7OpjJjFr7OQE854agKeDj9rW-1E2NyvMb4232RcP9k3ce9nKupqEEgRWdaUv6Qv8B5ua2fvk/s1600/salvation+2013-08-18+13-37-20-62.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfHKNy7e8Iz4QUEk4jtoSb666_v-VMh-UUDSl0N0bb9-UFIj-P7L9isQwYgemRUBmUQERO7OpjJjFr7OQE854agKeDj9rW-1E2NyvMb4232RcP9k3ce9nKupqEEgRWdaUv6Qv8B5ua2fvk/s400/salvation+2013-08-18+13-37-20-62.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Space battle - go.</td></tr>
</tbody></table>
<br />
It's all RTS-style gameplay using menus with no first person stuff. You manage your ship's upgrades and passengers and plot a course out of the danger zone. Randomly, when entering a new system you will encounter a hostile ship and you can choose to engage or run. The game code also randomly generates missions in each system in which you deliver cargo, eliminate hostile ships etc.<br />
<br />
<h3>
The Content</h3>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhupeskdiLpWxNAeQTxtIOIaTSydisqvMcJ_hSgCC2uAto4nzkrjkV5pOzMgi1gTaPeV-wfE9HCvz4B0P13vm9lvwL5Ixchy_3dw-6P6OoeqvrEjKT-7MDqbWVRxtPZbD-U4WKo14elq_fV/s1600/salvation+2013-08-18+13-36-57-10.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhupeskdiLpWxNAeQTxtIOIaTSydisqvMcJ_hSgCC2uAto4nzkrjkV5pOzMgi1gTaPeV-wfE9HCvz4B0P13vm9lvwL5Ixchy_3dw-6P6OoeqvrEjKT-7MDqbWVRxtPZbD-U4WKo14elq_fV/s400/salvation+2013-08-18+13-36-57-10.png" width="400" /></a></div>
<br />
Planets, spaceships, stars oh my! And this time I made it a priority to include audio also. I also spent a good bit of time on the gui because I knew it would take up a lot of the screen most of the time. Given enough time I would have created space stations, futuristic cities and asteroids.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjf9c98IVesTJ6vaF5T7uykaJaGKZOWBKf469h847CndCxgqOsJ2cGQm3CRFGa8LQbp7HTq_ZbhpFXhm8_k_L5s9hs96v10CWxwl7T-s0mPUXN6btSRZr58M0WmrewRiJSiuEmbaL8nE_03/s1600/salvation+2013-08-18+13-39-08-71.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjf9c98IVesTJ6vaF5T7uykaJaGKZOWBKf469h847CndCxgqOsJ2cGQm3CRFGa8LQbp7HTq_ZbhpFXhm8_k_L5s9hs96v10CWxwl7T-s0mPUXN6btSRZr58M0WmrewRiJSiuEmbaL8nE_03/s400/salvation+2013-08-18+13-39-08-71.png" width="400" /></a></div>
<br />
Skybox look familiar? I tweaked some spacescape skyboxes for the game and think they add a lot.<br />
<br />
One thing you may not see so well in the screenshots is that I added some bokeh, shadows and animated screen lines on top of everything, something I've never done before but think it turned out well.<br />
<br />
<h4>
This game was brought to you by</h4>
Graphics: <a href="http://ogre3d.org/" target="_blank">Ogre3d</a><br />
GUI: <a href="http://mygui.info/" target="_blank">MyGUI</a><br />
Audio: <a href="http://sfml-dev.org/" target="_blank">SFML</a><br />
Input: <a href="http://sourceforge.net/projects/wgois/" target="_blank">OIS</a><br />
<br />
<h4>
Content created with:</h4>
Skybox: <a href="http://alexcpeterson.com/spacescape" target="_blank">Spacescape</a><br />
Spaceships: <a href="http://blender.org/" target="_blank">Blender3d</a><br />
Planets: <a href="https://code.google.com/p/planetcreator/" target="_blank">PlanetCreator</a><br />
Editor of choice: Photoshop<br />
<br />
<h3>
The Good The Bad The Ugly</h3>
<div>
<a href="http://ogre3d.org/" target="_blank">Ogre3d </a>has always been a nice engine to work with and this time was no exception. It rarely gives me grief and there is so much help online that I found samples for just about every problem I ran into. </div>
<div>
<br /></div>
<div>
<b>Example</b>: I wanted to overlay bokeh and shadow box images on top of the scene but under the GUI. This was a problem because MyGUI is hardcoded to use the overlay renderqueue, which is also the render queue that overlay in Ogre are hardcoded to use and you can't change either without coding the change into the libraries themselves. </div>
<div>
<b>Solution:</b> Just create your own Ogre::Rectangle2D entity and manually set the renderqueue to be just before the overlay render queue. #boom.</div>
<div>
<br /></div>
<div>
<a href="http://mygui.info/" target="_blank">MyGUI </a>has come a long way since a few years ago when I used it last. It has a layout editor and skin editor that are really slick. The biggest issues I faced with MyGUI were the lack of support for Ogre Materials and the lack of tutorials, code snippets online. Some day I would love to write some howtos for MyGUI basic implementation.</div>
<div>
<br /></div>
<div>
SFML is a great audio library. It is EXACTLY what I needed because it works cross platform and was super easy to set up, literally a couple lines of code to have background music and effects playing. Underneath it uses openal and sndlibrary so it is based on some solid code.</div>
<div>
<br /></div>
<div>
The last super great find was the <a href="https://code.google.com/p/planetcreator/" target="_blank">Planet Creator</a> tool. This thing is amazing, it randomly generates planets based on a large selection of templates (planet types like arid, earth-like, moon-like, etc.) and then it exports the texture maps, normal maps, specular maps and more! I'd really like to see <a href="http://alexcpeterson.com/spacescape" target="_blank">spacescape </a>and this planet creator get bundled together somehow to make some epic space game content creator.</div>
<div>
<br /></div>
<h3>
Other Stuff</h3>
<div>
I've actually done a lot more work on the puzzle game and I expect to have that out on the app store this fall. No OGE updates or other game updates so far. I am considering entering the August Ludum Dare, so if you are going to participate I'll see you there!</div>
alex petersonhttp://www.blogger.com/profile/10147348345426496177noreply@blogger.com2tag:blogger.com,1999:blog-2884078902485203181.post-45169610329457437252013-05-09T08:25:00.002-07:002013-05-09T08:25:59.470-07:00Ludum Dare 26<h4>
Ludum Dare 26 Entry - Puzzle Cube</h4>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://www.ludumdare.com/compo/ludum-dare-26/?action=preview&uid=23254" imageanchor="1" style="margin-left: auto; margin-right: auto;" target="_blank"><img border="0" height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfUuEK__tjJGcINIsLsCMbjE0OnJ4EZd0doNtLwUCTSSNgFaVhOh3ZkkjtUy7fCRIg8tYGg4WdI0JIiEctCWxFMJhCXgFXEGuDBCzyxTB6TrMw2H4B7F5c9cftRRnqqkXeayuZtght1muK/s320/puzzlecube.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Ludum Dare 26 - PuzzleCube</td></tr>
</tbody></table>
<br />
I decided to enter into the <a href="http://www.ludumdare.com/compo/" target="_blank">48 compo Ludum Dare 26</a> challenge where you make a theme-based game in 48 hours. 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.<br />
<br />
You can download/play the game on Windows or OSX (sorry Linux) here:<br />
<a href="http://www.ludumdare.com/compo/ludum-dare-26/?action=preview&uid=23254">http://www.ludumdare.com/compo/ludum-dare-26/?action=preview&uid=23254</a><br />
<br />
It's a simple puzzle game where you try to get the ball to the top of the cube by maneuvering it around and through the cube. 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.<br />
<br />
The game was built with <a href="http://ogre3d.org/" target="_blank">Ogre3D</a> in Visual Studio 2010.<br />
<br />
I also live streamed my 5-6 hours of game dev on twitch here:<br />
<div style="text-align: justify;">
<span style="color: #0000ee; font-family: Lucida Grande, Verdana, Arial, sans-serif;"><span style="font-size: 12px;"><u><a href="http://www.twitch.tv/petrocket/videos">http://www.twitch.tv/petrocket/videos</a></u></span></span></div>
<div style="text-align: justify;">
<span style="color: #0000ee; font-family: Lucida Grande, Verdana, Arial, sans-serif;"><span style="font-size: 12px;"><br /></span></span></div>
<div style="text-align: justify;">
<span style="text-align: start;">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. 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.</span></div>
<div style="text-align: justify;">
<span style="text-align: start;"><br /></span></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhW-9xVBbJnSNi9QpUgQBLoyhsNO2rNMH-4yCTTDwbqwpb43RH0hbvg44aJ7ZAxoXdt-2oKooea1xdMNFmEnARquRAuljy8eyTzUK1h_mm-xuMNV4lLv8xCftKznGpuvNVWKyZHDaizfsea/s1600/iOS+Simulator+Screen+shot+May+9,+2013+11.07.12+AM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="213" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhW-9xVBbJnSNi9QpUgQBLoyhsNO2rNMH-4yCTTDwbqwpb43RH0hbvg44aJ7ZAxoXdt-2oKooea1xdMNFmEnARquRAuljy8eyTzUK1h_mm-xuMNV4lLv8xCftKznGpuvNVWKyZHDaizfsea/s320/iOS+Simulator+Screen+shot+May+9,+2013+11.07.12+AM.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">iOS version</td></tr>
</tbody></table>
<div style="text-align: justify;">
<span style="text-align: start;"><br /></span></div>
<div style="text-align: justify;">
<br /></div>
<h4>
<span style="text-align: start;">OGE & Planet Stuff</span></h4>
<div>
<span style="text-align: start;">I haven't touched this in a while since becoming frustrated with the stuttering issues. 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. I haven't been able to solve it yet and got preoccupied with working on our other iOS game and client work.</span></div>
<div>
<span style="text-align: start;"><br /></span></div>
<div>
<span style="text-align: start;">Here's a couple updated screenshots of our iOS game with the new characters and graphics</span></div>
<div>
<span style="text-align: start;"><br /></span></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLuR3HL8STB2Viwdt-nFMlzP13sSWUORB8_ZbPaGNEM263RnXmkXMf3Sif_0mKV5TP50pbe7MvSOWXShihIw4T9Vz6gXUK0rSPe5jCAUbWCaMnkVx-uBVjA1mALzsaUzErE09a6XsLRiL6/s1600/iOS+Simulator+Screen+shot+May+9,+2013+11.14.24+AM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLuR3HL8STB2Viwdt-nFMlzP13sSWUORB8_ZbPaGNEM263RnXmkXMf3Sif_0mKV5TP50pbe7MvSOWXShihIw4T9Vz6gXUK0rSPe5jCAUbWCaMnkVx-uBVjA1mALzsaUzErE09a6XsLRiL6/s320/iOS+Simulator+Screen+shot+May+9,+2013+11.14.24+AM.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">iPad</td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPUtZPLpAq0NY6VqqSaRV4QSIbGXdWHBu0hvmUi2tE1gJHRkId0by_eQfD91mNsSslbXESd2TIccUhqZSzS-NjGu4j7AiV9-RH7Z8t27UWUKqte68rj1Mvp3DJy6E6a3r2Qs1vOQXTO_IN/s1600/iOS+Simulator+Screen+shot+May+9,+2013+11.11.26+AM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="213" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPUtZPLpAq0NY6VqqSaRV4QSIbGXdWHBu0hvmUi2tE1gJHRkId0by_eQfD91mNsSslbXESd2TIccUhqZSzS-NjGu4j7AiV9-RH7Z8t27UWUKqte68rj1Mvp3DJy6E6a3r2Qs1vOQXTO_IN/s320/iOS+Simulator+Screen+shot+May+9,+2013+11.11.26+AM.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">iPhone</td></tr>
</tbody></table>
<div>
<span style="text-align: start;"><br /></span></div>
<div>
<span style="text-align: start;"><br /></span></div>
alex petersonhttp://www.blogger.com/profile/10147348345426496177noreply@blogger.com0tag:blogger.com,1999:blog-2884078902485203181.post-52006461878058657982012-12-12T17:05:00.000-08:002012-12-12T17:05:13.075-08:00OGE And Game Updates<div class="separator" style="clear: both; text-align: left;">
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. The team at <a href="http://bearhanded.com/" target="_blank">Bearhanded</a> (where I work) decided to take our web game and make it a mobile game to be released before Christmas. Needless to say we decided to vastly expand on the original game, adding many more game objects, levels, pizzaz and eye candy yada yada.</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-qGKJzsadZV1Vjh0ArU8QW2Q_NpDG3zZzhc4Ys-b1sHOGWW35im-rdoBXeJnM7w4OeHCgk1wlWUX1SMgQyqOXLn0r2o_ONH3dSaUwTHsIY_6F8-9RgmgSd2CpNmPXKh0XRJPrvHvr9JYz/s1600/fireflies-beta-level0.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="242" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-qGKJzsadZV1Vjh0ArU8QW2Q_NpDG3zZzhc4Ys-b1sHOGWW35im-rdoBXeJnM7w4OeHCgk1wlWUX1SMgQyqOXLn0r2o_ONH3dSaUwTHsIY_6F8-9RgmgSd2CpNmPXKh0XRJPrvHvr9JYz/s320/fireflies-beta-level0.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Do you recognize the first level from our web version?</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
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. 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!</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiT6hd4ed6-GFwl8xGp-P7oi46O_iLfLH8d4Qp582buQSaS57H8STLiRsrPMgWSp_ntQHMfSE67D9GcLOd2KBekT-OulgaWHoso7JvAS_MQnUG34BHTTBg7aRgOkBmq4V3u9aZneRvM-Sol/s1600/fireflies-beta-level22.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="242" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiT6hd4ed6-GFwl8xGp-P7oi46O_iLfLH8d4Qp582buQSaS57H8STLiRsrPMgWSp_ntQHMfSE67D9GcLOd2KBekT-OulgaWHoso7JvAS_MQnUG34BHTTBg7aRgOkBmq4V3u9aZneRvM-Sol/s320/fireflies-beta-level22.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">This level is ALL developer art, but it shows the colored lights and shadows effects.</td></tr>
</tbody></table>
<br />
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. We've added so much that we had to push back our release till early 2013.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYCxweFfMFiKhRoCheGm4H1dcpt7qrCZN_QlEYEBQrpTrO4h37A4A4IE8YW9UwpIIBwb__cQ9FDR74wl8aKcrROn-b65eFFEeZJ2bEsAxLu09b5R2oT44Yg-JZ7HxW3hqFWgBbaKtWk_dn/s1600/fireflies-beta-level5.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYCxweFfMFiKhRoCheGm4H1dcpt7qrCZN_QlEYEBQrpTrO4h37A4A4IE8YW9UwpIIBwb__cQ9FDR74wl8aKcrROn-b65eFFEeZJ2bEsAxLu09b5R2oT44Yg-JZ7HxW3hqFWgBbaKtWk_dn/s320/fireflies-beta-level5.png" width="320" /></a></div>
<br />
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.<br />
<br />
<h4>
Ye OGE (Open source Game Engine)</h4>
<a href="http://sourceforge.net/projects/oge" target="_blank">ye link</a><br />
<br />
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. At this point, it appears to be working on windows 7 and linux, but not on OSX.<br />
<br />
What's been holding back progress on the planet? 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. 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. 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.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-3vsj2qkGi8Wcn1PvWFQ3yCvdoQzADxxNFMdDMrOfqMB4JyNzYc1vpuciyikUDu-szqfxV_HQfCucknxlGNoFRuPqRTFByOHVFEf9NlbD1qEg_216por3YQxtBv1TU8QpUG2QQTdfdxgD/s1600/gui_expermients.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-3vsj2qkGi8Wcn1PvWFQ3yCvdoQzADxxNFMdDMrOfqMB4JyNzYc1vpuciyikUDu-szqfxV_HQfCucknxlGNoFRuPqRTFByOHVFEf9NlbD1qEg_216por3YQxtBv1TU8QpUG2QQTdfdxgD/s320/gui_expermients.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">This is my temporary MyGUI implementation in my planet test suite with the latest OGE (bogey tracker broken in this build!)</td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZUgbu6VXkT1tF6n0LUFM9nm4pKoXLPQlMi583S1_yM2BMlnBKekntD0bDQhuBKxZjTk04cN75tduBIDPIiRbJKjlflM4RHTaTsxHk77zx6DIIo1VfkArBESaYQKd4y0btAyI30D24gQ_J/s1600/physics_sample.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="189" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZUgbu6VXkT1tF6n0LUFM9nm4pKoXLPQlMi583S1_yM2BMlnBKekntD0bDQhuBKxZjTk04cN75tduBIDPIiRbJKjlflM4RHTaTsxHk77zx6DIIo1VfkArBESaYQKd4y0btAyI30D24gQ_J/s320/physics_sample.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">This is my little physics sample that I hope will help me nail the stutter bugs.</td></tr>
</tbody></table>
<br />
I've also added a version of the OGRE profiler to OGE and added optional profiling blocks to all the major systems for now. It doesn't really work like I would like, but it's better than nothing for now.<br />
<br />
No fav games of 2012 post because I mostly just play one game - Natural Selection 2! They finally released it and it is super fun. <br />
<br />
<br />
<br />alex petersonhttp://www.blogger.com/profile/10147348345426496177noreply@blogger.com0tag:blogger.com,1999:blog-2884078902485203181.post-1226483625196465202012-07-29T11:33:00.001-07:002012-07-29T11:33:32.777-07:00CDN 2012 Game "Fireflies" Postmortem<div class="separator" style="clear: both; text-align: center;">
<a href="http://fireflies.bearhanded.com/" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" target="_blank"><img alt="Fireflies Game Home Screen" border="0" height="331" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhp8vKPU-6f3wbwqInGmujj3WVWVtmck0Y_PAnmkLCfOmnaSQVaCxF310uQvGqp4-K71_404D-FS4U8kwFKQEf7xWCZyaTmjok4xB76whEnxni9poVCdyoMCCmoWhVfl3wj9975CCNBllgc/s400/fireflies-home.jpg" title="Fireflies Game" width="400" /></a></div>
<br />
This year the whole <a href="http://bearhanded.com/" target="_blank">Bearhanded </a>team decided to participate in the <a href="http://speedgame.christiandevs.com/" target="_blank">Christian Developers Network Speedgame</a>. We created an online multiplayer game called <a href="http://fireflies.bearhanded.com/" target="_blank">Fireflies</a>. The theme this year was "testimony" and we decided we wanted to do a multiplayer game with HTML5 and <a href="http://nodejs.org/" target="_blank">NodeJS</a>. 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. 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. The idea being that God uses many people in our lives and in their lives to reach us with the gospel. When the whole tree is lit up, then the game is completed and the #parteh begins!<br />
<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglCLYadSwbS1TzX4Selw35v3WJvA4Wx2U9w49kLnN5X5a9HHcAP0MKSSPqw6HD5oWnGL6AMuu1mrS834WyXVpSld6dwwEclfcg_yyiQt_Xwc41OxhspwATRf9ia-FDcNywsJjOIK-AMz_e/s1600/fireflies-level1.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="Fireflies Game Level 1" border="0" height="295" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglCLYadSwbS1TzX4Selw35v3WJvA4Wx2U9w49kLnN5X5a9HHcAP0MKSSPqw6HD5oWnGL6AMuu1mrS834WyXVpSld6dwwEclfcg_yyiQt_Xwc41OxhspwATRf9ia-FDcNywsJjOIK-AMz_e/s400/fireflies-level1.jpg" title="Fireflies Game Level 1" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Level 1 is very straight forward no?</td></tr>
</tbody></table>
<br />
There are 5 levels, starting with simple puzzles and ending in some rather difficult ones. The final level is very difficult to beat by yourself, and even with three people it can take some time to finish.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwu6JDgyL6FBzS0DQ-UpOqC6YXHrpuVwILVlwwGQd0vw3-f2qTTU_p_2j3_e7pcOBwlLLh5SKLUP0RDOtNV5unOaszAZj9mCa7wuIF3oKVDgqXawlUqDuQPTTPcn2AGudV8GjCgKN1p_mg/s1600/fireflies-level2.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="Fireflies Game Level 2" border="0" height="298" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwu6JDgyL6FBzS0DQ-UpOqC6YXHrpuVwILVlwwGQd0vw3-f2qTTU_p_2j3_e7pcOBwlLLh5SKLUP0RDOtNV5unOaszAZj9mCa7wuIF3oKVDgqXawlUqDuQPTTPcn2AGudV8GjCgKN1p_mg/s400/fireflies-level2.jpg" title="Fireflies Game Level 2" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Every game needs a jumping puzzle! #lies</td></tr>
</tbody></table>
<br />
<h3>
Design</h3>
We took our design cues from games like Lemmings, <a href="http://limbogame.org/" target="_blank">Limbo</a>, <a href="http://botanicula.net/" target="_blank">Botanicula</a> and whatever was tossing around in our subconscious! Chris was the primary designer and Aaron took his characters and animated them using After Effects. Nate then took the animations and put them in the game.<br />
<br />
<h3>
Development</h3>
Fireflies was built with the following technologies & libraries<br />
<ul>
<li><a href="http://nodejs.org/" target="_blank">NodeJS</a> - server game logic</li>
<li><a href="http://nowjs.com/" target="_blank">NowJS</a> - server and client networking</li>
<li>HTML5 - client audio and canvas support</li>
<li>CSS3 - text glow effects and drop shadows </li>
<li><a href="http://box2d.org/" target="_blank">Box2d</a> - client physics</li>
<li><a href="http://cocos2d-javascript.org/" target="_blank">Cocos2d-javascript</a> - canvas drawing</li>
<li><a href="http://jquery.com/" target="_blank">jQuery</a> - various UI elements</li>
</ul>
I did all of the Javascript for the server and client using <a href="http://aptana.com/" target="_blank">Aptana</a> as my editor. This editor is free and good looking and the code completion is pretty decent. It's basically another flavor of <a href="http://eclipse.org/" target="_blank">Eclipse</a>.<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwOGIIrUZIwDO53cpkKzV0gt58sI0PXG-FvNk9BWBPPu-A-vybNiki_s7mFgSUnx_GPJp-3OikDpc1hm5nutB_VT6w9MV99_X8Ka2o9_dXpJ96XRJgfqPaq9Th-OTniRwSKNBD5o7dml7T/s1600/Screen+Shot+2012-07-01+at+7.26.59+PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="321" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwOGIIrUZIwDO53cpkKzV0gt58sI0PXG-FvNk9BWBPPu-A-vybNiki_s7mFgSUnx_GPJp-3OikDpc1hm5nutB_VT6w9MV99_X8Ka2o9_dXpJ96XRJgfqPaq9Th-OTniRwSKNBD5o7dml7T/s400/Screen+Shot+2012-07-01+at+7.26.59+PM.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">I love using dark text editor themes - if only it darkened the frame too #sigh</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
</div>
Chris used <a href="http://mapeditor.org/" target="_blank">Tiled</a> to build our levels and Nate used <a href="http://zwopple.com/zwoptex/" target="_blank">Zwoptex</a> to make our sprite sheets for our animations. Both are free and support Cocos2d.<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVO27gbiToGYVPFrEgbTQjM6puZs32oSkUlZ_ifsLLYCPwt26RNXKURlGQVUABsWP2HPGxqgZMlNk-WkWTk0LUx0IDtEHWXzP8v4QwfKozEXsaa0Wy0D1t0KKQ-gD1-PchK6TVI7hnPl-K/s1600/fireflies_level_design1.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="261" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVO27gbiToGYVPFrEgbTQjM6puZs32oSkUlZ_ifsLLYCPwt26RNXKURlGQVUABsWP2HPGxqgZMlNk-WkWTk0LUx0IDtEHWXzP8v4QwfKozEXsaa0Wy0D1t0KKQ-gD1-PchK6TVI7hnPl-K/s400/fireflies_level_design1.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Simple, but it works and it's free!</td></tr>
</tbody></table>
<br />
<h3>
Thoughts and ramblings</h3>
For anyone interested in using any of these technologies you should be aware of several things I discovered:<br />
- <b>Cocos2d-javascript is still very alpha</b>, 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. All that being said, it does work for simple things and it performed fairly well for our little game. To integrate box2d physics with cocos2d I had to modify the level import code to support reading polygon objects. Then in my client code I used the polygons to create box2d static shapes.<br />
<br />
- <b>NodeJS is really hot these days and can do some amazing things</b>. No complaints here except that it uses Javascript. All the wonderful things you are used to with object oriented programming are imitated and asynchronous behaviors abound. <br />
<br />
- <b>NowJS allows you to easily synchronize variables between server and client and do remote procedure calls</b>, however I quickly discovered that due to the asynchronous nature of NodeJS, using variable synchronizing would give random bad values and I ended up having to use remote procedure calls for everything. The groups feature is how we contain players in levels and it is super easy to do and useful and awesome.<br />
<br />
- <b>Box2d is made for realistic physics, not platformers</b>. 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. 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. So to bring box2d to its knees I had to<br />
<ul>
<li>Use a ball for the players physics shape so it wouldn't get stuck and friction wouldn't be such an issue. </li>
<li>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. When they move ease up on the friction. </li>
<li>When in the air, turn off friction and use a different damping or they'll get stuck on vertical walls. </li>
<li>Use impulses and not forces to get the player moving. </li>
<li>Turn off restitution or just use a tiny bit or you'll bounce all crazy. </li>
<li>Make sure your polygon world objects are created with the vertices in counterclockwise fashion or your player will fall through them.</li>
<li>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?</li>
</ul>
That's it for now - you can play the game at <a href="http://fireflies.bearhanded.com/">http://fireflies.bearhanded.com</a> and the source code is available for download via the christiandevs.com website <a href="http://talk.christiandevs.com/viewtopic.php?f=32&t=3784" target="_blank">here. </a><br />
<br />
In other news I will post about the latest OGE/planet updates soon and I <a href="http://www.packtpub.com/ogre-3d-1-7-application-development-cookbook/book" target="_blank">co-authored a book on OGRE</a>. alex petersonhttp://www.blogger.com/profile/10147348345426496177noreply@blogger.com1tag:blogger.com,1999:blog-2884078902485203181.post-80025087409628364102012-03-26T07:47:00.001-07:002012-03-26T07:47:19.656-07:00Spacescape for OSX, OGE gui and 2011 GamesLet's hit the "games I played in 2011" first - btw I'm stealing this idea from <a href="http://ntdb.net/" target="_new">nathan @ ntdb.org</a>. I think every game developer should be required to do a post on games they played once a year! Brilliant. <br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://naturalselection2.com/" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" target="_blank"><img alt="" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRkuvymgzh40aHSizRteY6cJHuBspF1Ess4WFofJ6iGVNau1E168aDz6EHMjt0l0F1isN-vSaPPx_nPZIxQIA0sxGPg7KEvrTr7D4KzsQlOkNdwKRsH3OzI32j2Km61vbKDMHS6slddvZd/s1600/ns2.png" title="Natural Selection 2" /></a></div>
<h4>
Natural Selection 2 - <a href="http://naturalselection2.com/" target="_blank">naturalselection2.com </a></h4>
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 & Strategy Game mash-up. 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. The commander on the marine side is also charged with directing, healing and keeping bullets available for his teammates. Each side accumulates resources through the game by building structures on resource nodes throughout the map. Resources can be spent on upgrades, or in the aliens case, for evolving into more sinister life forms.<br />
<br />
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!<br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZqSZq3q0YLZF07cLpw7uIAeeuOhw5zrjsqh9OVwUOAAFyuHrHk0KiIDpZrkFExjNpsmkIPncZbuFDQctuFAsjCTFlunaTwcfv-0K5jHaBkJmor8HcO26iKBourHDXRovLIMMpgeX4xKse/s1600/skyrim.png" /></div>
<h4>
The Elder Scrolls V: Skyrim - <a href="http://www.elderscrolls.com/skyrim/" target="_blank"><cite>elderscrolls.com/skyrim</cite></a></h4>
This is obvious no? Great graphics, huge expanse with variable gameplay, and I would be playing this a lot more if I weren't playing natural selection all the time. 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.<br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEia1uX57Ab3E63ugn8rmNFb2i7uKUs-0dof4M3ygh7sas_b6SsmXMyvpnQ7ggHupiVgb8Qo9efGiM_s1k6Ol5ewibea5gFCQ02oKcyCiYR_VhaUA0VX0ombygpXwxN5cJhmlQCkeBYq8GP6/s1600/lfd2.png" /></div>
<h4>
Left 4 Dead 2 - <a href="http://www.l4d.com/" target="_blank">l4d.com</a></h4>
I started playing this with friends at work and had a blast! I did enjoy mindlessly killing zombies while drinking a beer after a day of twisting my brain this way and that. Great way to unwind and I keep it in my back pocket in case I don't feel like playing TF2.<br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://minecraft.net/" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" target="_blank"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjr6w2wxtEKBcxfM097M4p1J-wmyQeay0MZWzMJZh3WoAWPty_64q_zIGmZPYsb_4H4Q3mfKA4oHe_7Bm0qwpS-E_PBEcT9rMG85CkZU6o3gileMTeXVMguwitAmGjNIoqnw8eK1j5SS9ib/s1600/minecraft.png" /></a></div>
<h4>
Minecraft - <a href="http://minecraft.net/" target="_blank">minecraft.net</a></h4>
There are only two games that my wife and I both get and this is one of them. The creativity in this is addictive and it is the only game I have like this. 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. Love. It. <br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHYYFjo2fJr7eiVOux1L6oJ0_8rJ-2qryKFQNI8pBr8aw1oPkEmVr48j7h3AcJqj8mawiY-8CInQmTUM_s1ldlsFOYC9QgYLAmRYJo1MfAh9Xeee4udzw6zJ3CZmJsgYcVXIsHThGF-LXe/s1600/portal2.png" /></div>
<h4>
Portal 2 - <a href="http://www.thinkwithportals.com/" target="_blank">thinkwithportals.com</a></h4>
Played this in single mode and then co-op mode and enjoyed every minute. I simply couldn't stop playing it and it was so refreshing to have an action game with humor in it. 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. Co-op mode was icing on the cake and I wish there were more longer campaigns.<br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMYvQ-ymNJHe0Lk4jbeFwpMAMkZyjiuLEJRscomE8Rv__4ZR-zzH_93inf4V4lkeH656q8ClVoqloelpcPNR9bn4xV9IeCOip1W8fKOiF2IgUQy2QhVxOANXyOWvZ-3oS39SQJh_YdLGGR/s1600/civ5.png" /></div>
<h4>
Civilization V - <a href="http://civilization5.com/" target="_blank">civilization5.com</a></h4>
Bought this on sale and the graphics look great, but I don't have enough time to play it. My wife loves Civilization but her computer can't run this version as well, so she is sticking with IV for now. The gameplay changes don't bother me, and I actually kind of like them.<br />
<br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-RMYutn3uFguVWL1erX2M__odQ-99cMHVQC62WXcH3Oglvhb_oP-j_jX6yqLKGn7IybR0o9sfUb2zLPPTfcrnA4MaMIhSLNZwDxHKWIj0jZgS4yAX9Du0wyuVvWSEWnexhWhvSTp7Zj5T/s1600/tf2.png" /></div>
<h4>
Team Fortress 2 - <a href="http://tf2.com/" target="_blank">tf2.com</a></h4>
Always a classic. I play this mostly to unwind in a gore-free environment. Going free-to-play was a good move for Valve - I bet most of their players purchased the game a decade ago anyways.<br />
<br />
<br />
<br />
<i><b>Honorable mentions...</b></i><br />
<h4>
Lord of the Rings Online</h4>
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. 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. Most of my guild friends did. I quit playing in 2011 and will probably not return until I have significantly more free time.<br />
<br />
<h4>
Tiny Wings </h4>
My favorite casual game. Simple, carefree and fun.<br />
<br />
<h4>
Sam & Max</h4>
I play through these with my wife on the TV sometimes when we're bored, the internet is down and the like. These are really fun little games and are fun to play with another person sitting beside you.<br />
<br />
<h4>
Sonic 2 for iOS </h4>
A classic from when I was a kid and played it on a Sega hand held. I cheat now to get to the higher levels that I couldn't get to when I was younger. <br />
<br />
<h4>
Counter-Strike: Source </h4>
I only downloaded this game and played it to see what was going on with the most popular online shooter game. More of the same. 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.<br />
<br />
<h4>
X3</h4>
These games are like references for me and full of ideas I want to have at hand in space games that I make. The story lines are teerrrrrriiibbbllleee and the voice acting is equally bad, but the space graphics are pretty amazing. 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. <br />
<br />
So that's it for the games I played - I may have played other games, but those are the ones I remember.<br />
<br />
<h3>
OGE GUI Experiments</h3>
<br />
In the world of game development I've been doing more work with GUI's in <a href="http://sourceforge.net/projects/oge" target="_blank">OGE</a>. I added a console and a simple menu system to explore the ins and outs of the <a href="http://mygui.info/" target="_blank">MyGUI</a> library. I suspect it is causing some framerate issues, but I haven't been able to track those down yet. I'll probably post a video of the GUI additions later. I've also spent time trying to better implement input and physics for moving. 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. It still doesn't.<br />
<br />
<br />
<h3>
Spacescape on OSX</h3>
I actually managed to get a version of <a href="http://alexcpeterson.com/portfolio/spacescape" target="_blank">Spacescape</a> to compile on OSX and run, but it has some major issues with masks and the whole build process was hell. 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 <a href="http://alexcpeterson.com/portfolio/spacescape" target="_blank">Spacescape</a> app for OSX and a native Win app for Windows - sorry Linux!<br />
<br />
I have learned, through opensourcing the code for <a href="http://sourceforge.net/projects/spacescape" target="_blank">Spacescape</a> 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. 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. 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.alex petersonhttp://www.blogger.com/profile/10147348345426496177noreply@blogger.com4tag:blogger.com,1999:blog-2884078902485203181.post-58465062555344278572011-08-26T21:20:00.000-07:002011-08-26T21:20:25.857-07:00CDN SpeedGame Postmortem!<p>Would you believe it -<i> I don't even have enough free time to make a little speedgame?!?</i> Maybe I was over ambitious but I'll get to that.</p>
<iframe width="560" height="349" src="http://www.youtube.com/embed/5ySilZEfwB4?hl=en&fs=1" frameborder="0" allowfullscreen></iframe>
<p>So my entry into the <a href="http://talk.christiandevs.com/viewtopic.php?f=38&t=3365"" target="_new">Christian Developer Network's 2011 SpeedGame</a> was going to be a <a href="http://games.adultswim.com/robot-unicorn-attack-twitchy-online-game.html"" target="_new">Robot-Unicorn</a> type game but with a cat. We each had to pick a verse as a theme for our game and I chose <a href="http://www.lolcatbible.com/index.php?title=Proverbs_15#24">Proverbs 15:24 - the lolcat Bible version</a>. </p>
<p><blockquote>Proverbs 15:24 - Smrt kittehs go up, not down to da basement.</blockquote></p>
<p>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.</p>
<p>But first - a simple rundown of the tools and libraries I used for the game:</p>
<p>
- <a href="http://ogre3d.org/"" target="_new">Ogre 3D graphics engine</a> (duh)<br />
- <a href="http://box2d.org/"" target="_new">Box2D </a>physics<br />
- <a href="http://connect.creativelabs.com/openal/default.aspx"" target="_new">OpenAL </a>audio<br />
- <a href="http://www.ogre3d.org/tikiwiki/Gorilla"" target="_new">Gorilla GUI</a><br />
- <a href="http://sourceforge.net/projects/wgois/"" target="_new">OIS </a>for input<br />
<br />
- <a href="http://blender.org/"" target="_new">Blender </a>3D for models<br />
- various free model and sound websites for the developer/test content<br />
</p>
<p>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.</p>
<p>
- design <-- all my design files<br />
- GameiOS <-- iOS specific XCode project<br />
- GameOSX <-- OSX specific XCode project<br />
- GameWin <-- Visual Studio 2010 project<br />
- lib <-- Box2D and OpenAL libs/source<br />
- media <-- all models, sounds, graphics etc.<br />
- src <-- all the shared source code<br />
</p>
<h3>Cross Platform Luv</h3>
<p>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 <a href="http://www.ogre3d.org/forums/viewtopic.php?f=4&t=64596&start=25#p435268">crash on startup</a>. Eventually I found that if I <a href="http://www.ogre3d.org/forums/viewtopic.php?f=4&t=64596&start=25#p435360">moved the log manager initialization to a line after Ogre::Root was initialized</a> 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.</p>
<p>Oh, and <a href="http://www.ogre3d.org/forums/viewtopic.php?f=2&t=63874">OSX fullscreen mode just doesn't seem to work</a> -- which was annoying because I had to restart my computer to regain control.</p>
<p>After getting the demo app working cross platform I put it all in a GIT repo (always a good idea to backup your code).</p>
<h3>Physics Physics Physics</h3>
<p>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.</p>
<p>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.</p>
<h3>OpenAL Lacks Decent File Import Capabilities</h3>
<p>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 <a href="http://enigma-dev.org/forums/index.php?topic=730.0">code off the internet for reading .wav files without ALUT</a>. I did find <a href="http://www.subfurther.com/blog/2011/07/15/alutloadwavfile-or-better-yet-dont/">solutions that involved using iOS/OSX libraries</a>, 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.</p>
<h3>Blender? I barely know her!</h3>
<p>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.</p>
<p><a href="http://alexcpeterson.com/sites/default/files/images/blender-dev-shot.jpg" target="_new"><img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/blender-dev-shot.project%20featured.jpg" /></a></p>
<p>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<a href="http://www.ogre3d.org/forums/viewtopic.php?f=2&t=66147"> I tried to read that shared vertex data in Ogre it didn't exist</a>! 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.</p>
<h3>Silverback</h3>
<p>I chose to use the <a href="http://www.ogre3d.org/tikiwiki/Gorilla" target="_new">Gorilla GUI for Ogre</a> because it was two files! - and I saw it in action in the Ogre forums and had to try it.</p>
<p><a href="http://alexcpeterson.com/sites/default/files/images/smrt_dev_4.jpg" target="_new"><img src="http://alexcpeterson.com/sites/default/files/images/smrt_dev_4.project%20featured.jpg" /></a></p>
<p>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.</p>
<p><a href="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/GameWin%202011-08-26%2023-47-49-34.png" target="_new"><img src="http://alexcpeterson.com/alexcpeterson.com/sites/default/files/images/GameWin%202011-08-26%2023-47-49-34.project%20featured.png" /></a></p>
<h3>In the End...</h3>
<p>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!</p>
<p>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.</p>alex petersonhttp://www.blogger.com/profile/10147348345426496177noreply@blogger.com6tag:blogger.com,1999:blog-2884078902485203181.post-68660532687800740142011-07-06T18:40:00.000-07:002014-04-01T18:31:27.305-07:00Let there be Bogeys<a href="http://alexcpeterson.com/sites/default/files/images/template_d%202011-07-06%2020-47-01-72.png" target="_new"><img src="http://alexcpeterson.com/sites/default/files/images/template_d%202011-07-06%2020-47-01-72.project%20featured.png" alt="bogeys" /></a><br />
<small>(click to enlarge)</small><br />
<br />
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 <a href="http://mygui.info/" target="_new">MyGUI</a> and added bogey trackers to some mine objects. <br />
<br />
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.<br />
<br />
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.<br />
<br />
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 & 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.<br />
<br />
Here's a little vid I recorded - just shows the bogey tracker.<br />
<br />
<iframe width="560" height="349" src="http://www.youtube.com/embed/JUr6shDSs7c" frameborder="0" allowfullscreen></iframe>alex petersonhttp://www.blogger.com/profile/10147348345426496177noreply@blogger.com4tag:blogger.com,1999:blog-2884078902485203181.post-35075378513527375602011-02-20T20:57:00.000-08:002011-02-20T21:00:32.379-08:00Helpful Mercurial TipsI spent a good bit of time trying to setup a <a href="http://mercurial.selenic.com/" target="_new">Mercurial </a>repository server on a Windows 7 Server that uses <a href="http://www.wampserver.com/en/" target="_new">wamp</a>.<br />
<br />
I had to install <a href="http://tortoisehg.bitbucket.org/" target="_new">TortoiseHg </a>and <a href="http://python.org/" target="_new">Python 2.6.6</a> and the latest <a href="http://mercurial.selenic.com/" target="_new">Mercurial </a>in that order so that <a href="http://mercurial.selenic.com/" target="_new">Mercurial </a>would add it's libraries to the <a href="http://python.org/">Python </a>install. All that is important because the library.zip file that comes with <a href="http://tortoisehg.bitbucket.org/" target="_new">TortoiseHg</a> doesn't have the right <a href="http://python.org/" target="_new">Python </a>modules you need to make the <a href="http://mercurial.selenic.com/" target="_new">Mercurial </a>hgweb.cgi work. Also I needed to install <a href="http://code.google.com/p/modwsgi/" target="_new">mod_wsgi</a> on the <a href="http://www.wampserver.com/en/" target="_new">wamp </a>server which uses Apache. Lastly, here is my hgweb.cgi<br />
<br />
#!c:/Python26/python.exe<br />
#<br />
# An example hgweb CGI script, edit as necessary<br />
# See also http://mercurial.selenic.com/wiki/PublishingRepositories<br />
<br />
import os; os.environ["HGRCPATH"] = "C:\wamp\www\hg"<br />
<br />
# Path to repo or hgweb config to serve (see 'hg help hgweb')<br />
config = "c:\\wamp\\www\\hg\\hgweb.config"<br />
<br />
# Uncomment to send python tracebacks to the browser if an error occurs:<br />
import cgitb; cgitb.enable()<br />
<br />
from mercurial import demandimport; demandimport.enable()<br />
from mercurial.hgweb import hgweb, hgwebdir, wsgicgi<br />
application = hgwebdir(config)<br />
wsgicgi.launch(application)alex petersonhttp://www.blogger.com/profile/10147348345426496177noreply@blogger.com0tag:blogger.com,1999:blog-2884078902485203181.post-24435914644397883372011-02-20T20:54:00.000-08:002011-02-20T20:59:53.695-08:00Nobody Likes To Fly In Space - They Want To DriveThere 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! So, I'd like to share with you how I decided to implement <i><b>unrealistic </b></i>but "fun" spaceship flying. Oh, and back in the day<a href="http://alexcpeterson.com/portfolio/cassinidivision" target="_new"> I did participate in the making of a game with realistic space physics</a>.<br />
<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://alexcpeterson.com/portfolio/cassinidivision" imageanchor="1" style="margin-left: auto; margin-right: auto;" target="_new"><img border="0" src="http://alexcpeterson.com/sites/default/files/images/cassini_blue_ship.project%20featured.jpg" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Cassini Division 2004</td></tr>
</tbody></table><br />
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. 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. 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! Now, I have considered a game where each spaceship has a pilot and a separate player as the gunner, but lets not get distracted...<br />
<br />
The easiest way to fly in space besides autopilot is to make it like driving - something that most people are used to. You see, I want two things when I'm driving:<br />
<ol><li>I usually want to be traveling in the direction my spaceship is pointing</li>
<li>When I hit the gas I want the spaceship to move, and when I let go I want it to come to a stop.</li>
</ol><br />
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. 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.<br />
<br />
By applying the dampening we ruin realistic space physics, but make spaceships easier to control. 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.<br />
<br />
Last thing I'd like to mention is the issue of 'max speed'. 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.<br />
<br />
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.<br />
<br />
On a more practical note, here is how I implemented the above physics model in <a href="https://sourceforge.net/apps/mediawiki/oge/index.php?title=Main_Page" target="_new">OGE </a>with <a href="http://bulletphysics.org/" target="_new">Bullet</a>.<br />
1. Use btRigidBody::setDampening() to set the dampening on the Bullet rigid body object<br />
2. Use Bullet's internal tick callback to apply constant forces before the dampening is applied:<br />
btRigidBody->applyCentralImpulse(velocity * deltaTime);<br />
btRigidBody->applyTorqueImpulse(angular * deltaTime);alex petersonhttp://www.blogger.com/profile/10147348345426496177noreply@blogger.com2tag:blogger.com,1999:blog-2884078902485203181.post-74657772509610162812011-01-04T09:25:00.000-08:002011-01-04T09:25:19.768-08:00A New Year With New Goals?The end of last year was somewhat unproductive for me on the planet front. 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. I also spent a lot of free time playing games too instead of making them.<br />
<br />
The two things I did work on that were planet related were <a href="http://sourceforge.net/projects/oge/">OGE</a> and <a href="http://alexcpeterson.com/portfolio/spacescape">Spacescape</a>. I made the developer list for <a href="http://sourceforge.net/projects/oge/">OGE</a>, and I might be the only active developer for now, but I hope that changes soon. I spent most of my <a href="http://sourceforge.net/projects/oge/">OGE</a> developer time working on the <a href="http://www.jenkinssoftware.com/raknet/">RakNet</a> networking and <a href="http://www.bulletphysics.org/">Bullet</a> 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. 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.<br />
<br />
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.<br />
<br />
<br />
On the table for this year are:<br />
- Finish the OGE networking space example<br />
- Re-asses and tackle placing objects on planets (vegetation, buildings, players etc)<br />
- Fix planet underwater shaders <br />
- Add simple clouds to planets<br />
- Make the networking space example into a small game<br />
- Release the planet plugin source<br />
- Port Spacescape to OSX<br />
- Divide Spacescape into "basic" and "advanced" modes so it is loads easier to use for the casual user.<br />
<br />
Other possibilities include:<br />
- Use acko.net method for computing planet normal maps<br />
- Figure out additional light maps so we can have lights on the dark side of the planet<br />
- Re-asses how distance/scale is handled when approaching the limits.<br />
- Form a team of like-minded individuals<br />
<br />
Hope you have a great start to the new year!alex petersonhttp://www.blogger.com/profile/10147348345426496177noreply@blogger.com4tag:blogger.com,1999:blog-2884078902485203181.post-57087551942867287652010-06-30T09:29:00.000-07:002010-06-30T09:29:11.469-07:00Planet Water Shader Tests & OGEFirst 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.<br />
<br />
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.<br />
<br />
What I want:<br />
<ul><li>reflections, refraction, transparency, specular, normal mapping</li>
<li> under water fog</li>
<li>fog color changes based on depth and distance</li>
</ul>Here's what I've got so far (no reflection or refraction)<br />
<br />
<br />
<br />
<object height="340" width="560"><param name="movie" value="http://www.youtube.com/v/PdqRk1RBtA4&hl=en_US&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/PdqRk1RBtA4&hl=en_US&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object><br />
<a href="http://www.youtube.com/watch?v=PdqRk1RBtA4" target="_new">Video of planet water on YouTube</a><br />
<br />
<b>Reflection and Refraction</b><br />
<br />
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.<br />
<br />
<b>Underwater Fog</b><br />
<br />
To support underwater I applied a fog to the pixel shader for the terrain based on the terrain depth under water. I have a outward facing sphere with a shader for transparency, normal mapping and specular. I also have an inward facing sphere with a shader for when you are underwater looking up at the surface from below.<br />
<br />
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. I think I can only fix this issue with post processing.<br />
<br />
<b>New Game Dev Machine</b><br />
<br />
I got a new developer machine with an i7 processor and Radeon 5770. I tried to choose a middle of the road graphics card. You can see the <a href="http://www.eggxpert.com/forums/thread/632787.aspx" target="_new">new game dev machine specs and discussion on eggxpert.com</a><br />
<br />
<b>OGE</b><br />
<br />
Lastly, I've spent a some time working with <a href="http://oge.sourceforge.net/" target="_new">OGE</a> which stands for "Open Game Engine". I've created a small <a href="http://www.jenkinssoftware.com/raknet/index.html" target="_new">RakNet</a> plugin for it and have been trying to get a little client/server action going. 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. It supports <a href="http://ogre.org/" target="_new">OGRE</a> as a graphics engine plugin so I shouldn't have to rewrite any of my graphics code.<br />
<br />
I'll try to post again when I have a video to show of the network tests. It will mostly just be a couple clients on a server flying ships around in space over a planet.alex petersonhttp://www.blogger.com/profile/10147348345426496177noreply@blogger.com2tag:blogger.com,1999:blog-2884078902485203181.post-81617706961916265142010-05-05T17:44:00.000-07:002010-05-21T13:58:17.681-07:00Planet Terrain Shader With AtmosphereBefore you read this post, if you have not watched Ysaneya's latest tech demo video <a href="http://infinity-universe.com/Infinity/index.php?option=com_content&task=view&id=113&Itemid=93" target="_new">go watch it now</a>! It is amazing!<br />
<br />
In the <a href="http://petrocket.blogspot.com/2010/04/atmosphere-shader-update-and-treegrass.html" target="_new">previous posts</a> 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:<br />
<br />
- 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.<br />
<br />
- In the atmosphere shader the camera and light should be in object space, as should the vertices.<br />
<br />
- 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.<br />
<br />
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.<br />
<br />
Too add the atmosphere effect to my terrain in the vertex shader I basically calculate the amount of atmosphere fog like this:<br />
<pre class="brush: cpp">// 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));
</pre><br />
<br />
position - The vertex position in object space<br />
camPos - The camera position in object space<br />
AtmosphereHeight - Atmosphere sphere radius minus terrain sphere radius.<br />
VisibilityDistance - At distance = 0, fog is 0 at distance = VisibilityDistance, fog = 1<br />
<br />
In my fragment shader I do this:<br />
<pre class="brush: cpp">// 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;
</pre><br />
<br />
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.<br />
<br />
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 <a href="http://ogre3d.org" target="_new">Ogre3d</a> not for FX Composer.<br />
<br />
<pre class="brush: cpp">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);
}
</pre><br />
<br />
And here is the fragment shader:<br />
<pre class="brush: cpp">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;
}
</pre>alex petersonhttp://www.blogger.com/profile/10147348345426496177noreply@blogger.com3tag:blogger.com,1999:blog-2884078902485203181.post-12652450490827200012010-04-28T06:50:00.000-07:002014-04-01T18:29:57.387-07:00Atmosphere Shader Update And Tree/Grass Test<a href="http://alexcpeterson.com/sites/default/files/images/MieScattering.jpg" target="_new"><img src="http://alexcpeterson.com/sites/default/files/images/MieScattering.project%20featured.jpg" border="0" /></a><br /><br />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).<br /><br />Also, I worked on pre-calculated/static shadow maps for the terrain and used those with the grass and trees. JohnJ created <a href="http://code.google.com/p/ogre-paged/" target="_new">Paged Geometry</a>, 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:<br /><br /><object width="480" height="295"><param name="movie" value="http://www.youtube.com/v/Nqjc3kBgxyc&hl=en_US&fs=1&color1=0x3a3a3a&color2=0x999999"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Nqjc3kBgxyc&hl=en_US&fs=1&color1=0x3a3a3a&color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="295"></embed></object><br /><strong>Note: the atmosphere shader in this video is the <i>old</i> atmosphere shader so the atmosphere is still too transparent on the sunny side of the planet</strong><br /><br />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.<br /><br />And now, here is the NVIDIA FX Composer shader for the current atmosphere shader I'm using:<br /><br /><pre class="brush: cpp"><br />// outer atmosphere radius<br />float AtmosphereRadius <<br /> string UIName = "Atmosphere Radius";<br /> string UIWidget = "Slider";<br /> float UIMin = 0.0;<br /> float UIMax = 10000.0;<br /> float UIStep = 1.0; <br />> = {1200.0f};<br /><br />// planet surface radius<br />float SurfaceRadius <<br /> string UIName = "Surface Radius";<br /> string UIWidget = "Slider";<br /> float UIMin = 0.0;<br /> float UIMax = 10000.0;<br /> float UIStep = 1.0; <br />> = {1024.0f};<br /><br />// this is the sun position/direction<br />float4 gLamp0DirPos : POSITION < // or direction, if W==0<br /> string Object = "Light0";<br /> string UIName = "Lamp 0 Position/Direction";<br /> string Space = (LIGHT_COORDS);<br />> = {10.0f,10.0f,10.0f,1.0};<br /><br />// this is the atmosphere 2d gradient<br />texture gTex <<br /> string ResourceName = "AtmosphereGradient";<br /> string ResourceType = "2D";<br /> string UIName = "Gradient Texture";<br />>;<br />sampler2D gTexSampler = sampler_state <br />{<br /> Texture = <gTex>;<br /> Filter = MIN_MAG_MIP_LINEAR;<br /> AddressU = Clamp;<br /> AddressV = Clamp;<br />};<br /><br />// this is for setting where the horizon should fall on the sphere<br />float StretchAmt <<br /> string UIName = "Stretch Amount";<br /> string UIWidget = "Slider";<br /> float UIMin = 0.0;<br /> float UIMax = 1.0;<br /> float UIStep = 0.01; <br />> = {0.25f};<br /><br />// this is for mie scattering<br />float Atmosphere_G <<br /> string UIName = "Atmosphere G";<br /> string UIWidget = "Slider";<br /> float UIMin = -1.0;<br /> float UIMax = -0.5;<br /> float UIStep = 0.001; <br />> = {-0.95f};<br /><br />float4x4 WorldViewProj : WorldViewProjection;<br />float4x4 ViewIXf : ViewInverse;<br />float4x4 WorldXf : World;<br /><br /><br />void main2VS(<br /> float3 pos : POSITION,<br /> uniform float4 lightPos,<br /> <br /> out float4 oPosition: POSITION,<br /> out float2 oUV: TEXCOORD0,<br /> out float oAlpha: TEXCOORD1,<br /> out float3 oCamToPos: TEXCOORD2,<br /> out float3 oLightDir :TEXCOORD3<br /> ) <br />{<br /> float4 Po = float4(pos.xyz,1);<br /> float4 Pw = mul(Po,WorldXf);<br /> float3 position = Pw.xyz;<br /> float4 camPos = float4(ViewIXf[3].xyz,1);<br /> <br /> oPosition = mul(Po, WorldViewProj); <br /> <br /> float radius = length(position);<br /> float radius2 = radius * radius; <br /> float camHeight = length(camPos.xyz);<br /> float3 camToPos = position - camPos.xyz;<br /> float farDist = length(camToPos);<br /> <br /> float3 lightDir = normalize(lightPos.xyz);<br /> float3 normal = normalize(position);<br /> <br /> float3 rayDir = camToPos / farDist;<br /> float camHeight2 = camHeight * camHeight;<br /> <br /> // Calculate the closest intersection of the ray with the outer atmosphere<br /> float B = 2.0 * dot(camPos.xyz, rayDir);<br /> float C = camHeight2 - radius2;<br /> float det = max(0.0, B*B - 4.0 * C);<br /> float nearDist = 0.5 * (-B - sqrt(det));<br /> float3 nearPos = camPos.xyz + (rayDir * nearDist);<br /> float3 nearNormal = normalize(nearPos);<br /><br /> // get dot products we need<br /> float lc = dot(lightDir, camPos / camHeight);<br /> float ln = dot(lightDir, normal);<br /> float lnn = dot(lightDir, nearNormal);<br /><br /> // get distance to surface horizon<br /> float altitude = camHeight - SurfaceRadius;<br /> float horizonDist = sqrt((altitude*altitude) + (2.0 * SurfaceRadius * altitude));<br /> float maxDot = horizonDist / camHeight;<br /> <br /> // get distance to atmosphere horizon - use max(0,...) because we can go into the atmosphere<br /> altitude = max(0,camHeight - AtmosphereRadius);<br /> horizonDist = sqrt((altitude*altitude) + (2.0 * AtmosphereRadius * altitude));<br /> <br /> // without this, the shift between inside and outside atmosphere is jarring<br /> float tweakAmount = 0.1;<br /> float minDot = max(tweakAmount,horizonDist / camHeight);<br /> <br /> // scale minDot from 0 to -1 as we enter the atmosphere<br /> float minDot2 = ((camHeight - SurfaceRadius) * (1.0 / (AtmosphereRadius - SurfaceRadius))) - (1.0 - tweakAmount);<br /> minDot = min(minDot, minDot2);<br /> <br /> // get dot product of the vertex we're looking out<br /> float posDot = dot(camToPos / farDist,-camPos.xyz / camHeight) - minDot;<br /> <br /> // calculate the height from surface in range 0..1<br /> float height = posDot * (1.0 / (maxDot - minDot));<br /> <br /> // push the horizon back based on artistic taste<br /> ln = max(0,ln + StretchAmt);<br /> lnn = max(0,lnn + StretchAmt);<br /><br /> // the front color is the sum of the near and far normals<br /> float brightness = saturate(ln + (lnn * lc));<br /> <br /> // use "saturate(lc + 1.0 + StretchAmt)" to make more of the sunset side color be used when behind the planet<br /> oUV.x = brightness * saturate(lc + 1.0 + StretchAmt);<br /> oUV.y = height;<br /> <br /> // as the camera gets lower in the atmosphere artificially increase the height<br /> // so that the alpha value gets raised and multiply the increase amount<br /> // by the dot product of the light and the vertex normal so that <br /> // vertices closer to the sun are less transparent than vertices far from the sun.<br /> height -= min(0.0,minDot2 + (ln * minDot2));<br /> oAlpha = height * brightness;<br /> <br /> // normalised camera to position ray<br /> oCamToPos = -rayDir;<br /> <br /> oLightDir = normalize(lightPos.xyz - position.xyz); <br />}<br /><br />float4 mainBPS( <br /> float2 uv : TEXCOORD0,<br /> float alpha : TEXCOORD1,<br /> float3 camToPos : TEXCOORD2,<br /> float3 lightDir :TEXCOORD3,<br /> uniform sampler2D TexSampler<br />) : COLOR {<br /> <br /> const float fExposure = 1.5;<br /> float g = Atmosphere_G;<br /> float g2 = g * g;<br /><br /> // atmosphere color<br /> float4 diffuse = tex2D(TexSampler,uv);<br /> <br /> // sun outer color - might could use atmosphere color<br /> float4 diffuse2 = tex2D(TexSampler,float2(min(0.5,uv.x),1));<br /><br /> // this is equivilant but faster than fCos = dot(normalize(lightDir.xyz),normalize(camToPos));<br /> float fCos = dot(lightDir.xyz,camToPos) * rsqrt( dot(lightDir.xyz,lightDir.xyz) * dot(camToPos,camToPos));<br /> float fCos2 = fCos * fCos;<br /><br /> // apply alpha to atmosphere<br /> float4 diffuseColor = diffuse * alpha;<br /> <br /> // sun glow color<br /> float fMiePhase = 1.5 * ((1.0 - g2) / (2.0 + g2)) * (1.0 + fCos2) /(1.0 + g2 - 2.0*g*fCos);<br /> float4 mieColor = diffuse2 * fMiePhase * alpha;<br /> <br /> // use exponential falloff because mie color is in high dynamic range<br /> // boost diffuse color near horizon because it gets desaturated by falloff<br /> return 1.0 - exp((diffuseColor * (1.0 + uv.y) + mieColor) * -fExposure);<br />}<br /><br />technique technique1 {<br /> pass p0 {<br /> ZEnable = false;<br /> ZWriteEnable = false;<br /> CullMode = CCW;<br /> AlphaBlendEnable = true;<br /> SrcBlend = One ;<br /> DestBlend = InvSrcAlpha;<br /> VertexShader = compile vs_3_0 main2VS(gLamp0DirPos);<br /> PixelShader = compile ps_3_0 mainBPS(gTexSampler); <br /> }<br />}<br /></pre><br /><br /><strong>Possible Improvements</strong><br />- 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.<br />- simplify mie scattering equation and remove hdr<br />- 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.<br /><br /><strong>Known Issues</strong><br />- 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.<br />- when on the surface of the planet looking back at the horizon it looks more like a painted shell than a spherical haze<br />- 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.<br />- 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.<br /><br />If you have any suggestions, improvements or bug fixes please let me know in the comments!alex petersonhttp://www.blogger.com/profile/10147348345426496177noreply@blogger.com10tag:blogger.com,1999:blog-2884078902485203181.post-7225187820436584002010-04-23T07:58:00.000-07:002014-04-01T18:27:19.695-07:00Sphere to Cube MappingThe following unit cube to unit sphere mapping is nice because the resulting sphere vertices are distributed somewhat evently:<br />
<br />
<a href="http://mathproofs.blogspot.com/2005/07/mapping-cube-to-sphere.html" target="_new">Math Proofs: Mapping a Cube to a Sphere, by Phil</a><br />
<br />
Here's the c++ version where x,y,z are the cube coords and sx,sy,sz are the sphere coords:<br />
<br />
<pre class="brush:cpp">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);
</pre><br />
<br />
Recently, I've been working on the reverse mapping (from unit sphere to unit cube) and have come up with this solution:<br />
<br />
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.<br />
<br />
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:<br />
<br />
s = sqrt(-sqrt((2 a^2-2 b^2-3)^2-24 a^2)+2 a^2-2 b^2+3)/sqrt(2)<br />
t = sqrt(-sqrt((2 a^2-2 b^2-3)^2-24 a^2)-2 a^2+2 b^2+3)/sqrt(2)<br />
<br />
You should see that the inner square root is used in both equations, so only do that part once.<br />
<br />
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.<br />
<br />
<br />
<pre class="brush:cpp">void cubizePoint(Vector3& 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 >= fx && fy >= 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 > 1.0) position.x = 1.0;
if(position.z > 1.0) position.z = 1.0;
if(x < 0) position.x = -position.x;
if(z < 0) position.z = -position.z;
if (y > 0) {
// top face
position.y = 1.0;
}
else {
// bottom face
position.y = -1.0;
}
}
else if (fx >= fy && fx >= 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 > 1.0) position.y = 1.0;
if(position.z > 1.0) position.z = 1.0;
if(y < 0) position.y = -position.y;
if(z < 0) position.z = -position.z;
if (x > 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 > 1.0) position.x = 1.0;
if(position.y > 1.0) position.y = 1.0;
if(x < 0) position.x = -position.x;
if(y < 0) position.y = -position.y;
if (z > 0) {
// front face
position.z = 1.0;
}
else {
// back face
position.z = -1.0;
}
}
</pre><br />
<br />
I posted a <a href="http://stackoverflow.com/questions/2656899/mapping-a-sphere-to-a-cube/" target="_new">stackoverflow question</a> and got a lot of help from there and from <a href="http://mathoverflow.net/questions/21638/mapping-a-sphere-to-a-cube" target="_new">mathoverflow</a> too. I used <a href="http://wolframalpha.com" target="_new">wolframalpha.com</a> to get the equations for s and t.<br />
<br />
My thanks to gmatt and Leonid Kovalev!alex petersonhttp://www.blogger.com/profile/10147348345426496177noreply@blogger.com1tag:blogger.com,1999:blog-2884078902485203181.post-68372807602284882942010-03-17T19:06:00.000-07:002014-04-01T18:26:36.672-07:00Tri-Planar Texturing On A Sphere And Spacescape Release!<a href="http://alexcpeterson.com/sites/default/files/images/triplanar-mapping-normals.jpg" target="_new"><img src="http://alexcpeterson.com/sites/default/files/images/triplanar-mapping-normals.project%20featured.jpg" alt="tri-planar normals on a sphere"/></a><br />
<br />
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.<br />
<br />
<object width="480" height="295"><param name="movie" value="http://www.youtube.com/v/LUEVlSNpF6Q&hl=en_US&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/LUEVlSNpF6Q&hl=en_US&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="295"></embed></object><br />
<br />
I used the code from <a href="http://http.developer.nvidia.com/GPUGems3/gpugems3_ch01.html" target="_new">this GPU Gems 3 article</a> and added a second bump map and animated them by updating the vertex uv coords and the results are decent.<br />
<br />
<a href="http://alexcpeterson.com/sites/default/files/images/triplanar-water-shader.jpg" target="_new"><img src="http://alexcpeterson.com/sites/default/files/images/triplanar-water-shader.project%20featured.jpg" alt="" /></a><br />
<br />
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.<br />
<br />
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.<br />
<br />
I've pasted the FX Composer .fx HLSL file at the bottom of this post if you want to try it out.<br />
<br />
Also, I have released the <a href="http://alexcpeterson.com/spacescape" target="_new">Spacescape skybox tool</a> and uploaded the source code to <a href="http://sourceforge.net/projects/spacescape" target="_new">sourceforge.net/projects/spacescape</a>!<br />
<br />
The tool is rather complex and so I plan on writing some tutorials & tips to help answer some questions that have been coming up.<br />
<br />
Here's an intro video:<br />
<object width="480" height="295"><param name="movie" value="http://www.youtube.com/v/py2OeGYhZVw&hl=en_US&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/py2OeGYhZVw&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="295"></embed></object><br />
<br />
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.<br />
<br />
<script src="https://gist.github.com/petrocket/9926386.js"></script>alex petersonhttp://www.blogger.com/profile/10147348345426496177noreply@blogger.com3tag:blogger.com,1999:blog-2884078902485203181.post-51402501719518765592010-02-17T19:37:00.000-08:002014-04-01T18:23:00.925-07:00Spacescape - Now With Billboards<a href="http://alexcpeterson.com/sites/default/files/images/screenshot02172010_221930023.png" target="_new"><img src="http://alexcpeterson.com/sites/default/files/images/screenshot02172010_221930023.project%20featured.png" alt="spacescape image with billboard sprites" /></a><br /><small>(click to enlarge)</small><br /><br />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:<br /><code><br />noiseSum = pow(noiseSum / powerAmount);<br /></code><br /><br />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.<br /><br />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.<br /><br />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"<br /><br /><small>(click images to enlarge)</small><br /><a href="http://alexcpeterson.com/sites/default/files/images/screenshot02182010_001134846.png" target="_new"><img src="http://alexcpeterson.com/sites/default/files/images/screenshot02182010_001134846.project%20featured.png" alt="planet with generated skybox" /></a><br /><br /><a href="http://alexcpeterson.com/sites/default/files/images/screenshot02182010_001318019.png" target="_new"><img src="http://alexcpeterson.com/sites/default/files/images/screenshot02182010_001318019.project%20featured.png" alt="planet with generated skybox 2" /></a><br /><br />As usual, I uploaded these images and more to the <a href="http://alexcpeterson.com/image/tid/1" target="_new">My First Planet gallery</a>.<br /><br />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 <a href="http://www.ogre3d.org" target="_new">ogre</a>.<br /><br />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.<br /><br />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.<br /><br />Here's a sample generated skybox (click for 1024x1024 version - open in new window):<br />right<br /><a href="http://alexcpeterson.com/sites/default/files/images/test-skybox_right1.png" target="_new"><img src="http://alexcpeterson.com/sites/default/files/images/test-skybox_right1.project%20featured.png" alt="right" /></a><br />left<br /><a href="http://alexcpeterson.com/sites/default/files/images/test-skybox_left2.png" target="_new"><img src="http://alexcpeterson.com/sites/default/files/images/test-skybox_left2.project%20featured.png" alt="left" /></a><br />top<br /><a href="http://alexcpeterson.com/sites/default/files/images/test-skybox_top3.png" target="_new"><img src="http://alexcpeterson.com/sites/default/files/images/test-skybox_top3.project%20featured.png" alt="top" /></a><br />bottom<br /><a href="http://alexcpeterson.com/sites/default/files/images/test-skybox_bottom4.png" target="_new"><img src="http://alexcpeterson.com/sites/default/files/images/test-skybox_bottom4.project%20featured.png" alt="bottom" /></a><br />front<br /><a href="http://alexcpeterson.com/sites/default/files/images/test-skybox_front5.png" target="_new"><img src="http://alexcpeterson.com/sites/default/files/images/test-skybox_front5.project%20featured.png" alt="front" /></a><br />back<br /><a href="http://alexcpeterson.com/sites/default/files/images/test-skybox_back6.png" target="_new"><img src="http://alexcpeterson.com/sites/default/files/images/test-skybox_back6.project%20featured.png" alt="back" /></a><br /><br />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):<br /><img src="http://alexcpeterson.com/sites/default/files/images/screenshot02162010_125123844.project%20featured.png" alt="outside skybox layer sphere" />alex petersonhttp://www.blogger.com/profile/10147348345426496177noreply@blogger.com5tag:blogger.com,1999:blog-2884078902485203181.post-20390001281564940752010-02-15T20:59:00.000-08:002014-04-01T18:21:29.740-07:00Introducting Spacescape! A Space Skybox Creator.<a href="http://alexcpeterson.com/sites/default/files/images/screenshot02152010_235831652.png" target="_new"><img src="http://alexcpeterson.com/sites/default/files/images/screenshot02152010_235831652.project%20featured.png" alt="Spacescape Alpha" /></a><br /><br />Spacescape is a tool that uses <a href="http://www.ogre3d.org" target="_new">Ogre</a> 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.<br /><br />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.<br /><br /><h2>How it works</h2><br />Making a bunch of point sprites is easy. I use an Ogre::ManualObject for that with pointSprites enabled on the material.<br /><br />For making the haze I create an inverted unit sphere and use a glsl shader on it that implements <a href="http://britonia-game.com/?p=60" target="_new">fbm</a> and <a href="http://britonia-game.com/?p=60" target="_new">ridged fbm</a> noise using Perlin's improved noise (not simplex noise). Lintfordpickle at <a href="http://britonia-game.com" target="_new">britonia-game.com</a> has a good <a href="http://britonia-game.com/?p=60" target="_new">explanation with code samples about how fbm and ridged fbm noise work</a><br /><br />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.<br /><br /><br />Here's some more images (click to enlarge - you'll need to in order to see the stars better):<br /><a href="http://alexcpeterson.com/sites/default/files/images/screenshot02152010_235158046.png" target="_new"><img src="http://alexcpeterson.com/sites/default/files/images/screenshot02152010_235158046.project%20featured.png" /></a><br /><br /><a href="http://alexcpeterson.com/sites/default/files/images/screenshot02152010_235844268.png" target="_new"><img src="http://alexcpeterson.com/sites/default/files/images/screenshot02152010_235844268.project%20featured.png" /></a><br /><br /><br /><a href="http://alexcpeterson.com/sites/default/files/images/screenshot02152010_235659094.png" target="_new"><img src="http://alexcpeterson.com/sites/default/files/images/screenshot02152010_235659094.project%20featured.png" /></a><br /><br /><strong>A note about dithering:</strong><br />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.<br /><br />The plan is to use this plugin in MyFirstPlanet to let users design their own space skyboxes easily too.<br /><br />Hopefully, I'll have a demo and some source code posted in the next week or so.alex petersonhttp://www.blogger.com/profile/10147348345426496177noreply@blogger.com3tag:blogger.com,1999:blog-2884078902485203181.post-62573786957812739172010-02-06T11:17:00.001-08:002010-02-06T11:33:50.453-08:00New YouTube Channel For Planet Dev VideosI started the <a href="http://www.youtube.com/user/petrocket" target="_new">petrocket YouTube channel</a> and am posting dev videos there for now. I like <a href="http://vimeo.com" target="_new">Vimeo</a>, but YouTube now allows HD videos and I think it has a larger developer audience.<br /><br />Here's another quick video I uploaded to test the HD quality. Sorry for the jerky camera movement.<br /><object width="480" height="295"><param name="movie" value="http://www.youtube.com/v/ETKvLL1WBA0&hl=en_US&fs=1&color1=0x3a3a3a&color2=0x999999"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/ETKvLL1WBA0&hl=en_US&fs=1&color1=0x3a3a3a&color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="295"></embed></object>alex petersonhttp://www.blogger.com/profile/10147348345426496177noreply@blogger.com1tag:blogger.com,1999:blog-2884078902485203181.post-78358427695656357512010-01-24T19:10:00.000-08:002014-04-01T18:19:56.621-07:00Simple Flexibile Atmosphere Shaders<a href="http://alexcpeterson.com/sites/default/files/images/Earth1.JPG" target="_new"><img src="http://alexcpeterson.com/sites/default/files/images/Earth1.project%20featured.JPG" border="0" /></a><br /><br /><edit>Uploaded a video of the effect<br /><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/hv77SQtMBOY&hl=en_US&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/hv77SQtMBOY&hl=en_US&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object><br /></edit><br />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!<br /><br />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.<br /><br />If you don't know, my earlier shaders were based entirely off <a href="http://sponeil.net/" target="_new">Sean O'Neil's free atmosphere shaders</a>. 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. <br /><br />Side note:If you're ever struggling with this stuff I highly recommend you contact him because he's very kind and helpful.<br /><br />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:<br />- dot product between the camera and the light<br />- dot products between the two sphere intersections of a ray from the camera to the vertex being drawn and the light.<br /><br /><br />Here's the 32x16 look up table for the atmosphere shell.<br /><br /><img src="http://alexcpeterson.com/sites/default/files/images/AtmosphereGradient3.jpg" border="0"/><br /><br />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).<br /><br />So here is a side view of the planet that shows the gradient well.<br /><br /><a href="http://alexcpeterson.com/sites/default/files/images/EarthSunset.JPG" target="_new"><img src="http://alexcpeterson.com/sites/default/files/images/EarthSunset.project%20featured.JPG" /></a><br /><br />To calculate the color to use on the horizontal axis I use this:<br /><code><br />float StretchAmount = 0.5;<br />ln = dot(lightDir, farVertexPosition);<br />lnn = dot(lightDir, nearVertexPosition);<br />lc = dot(lightDir, cameraPosition);<br /><br />ln = max(0,ln + StretchAmount);<br />lnn = max(0,lnn + StretchAmount);<br /><br />uv.x = saturate(ln + (lnn * lc)) * saturate(lc + 1.0 + StretchAmount);<br /></code><br /><br />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 <code>saturate(lc + 1.0 + StretchAmount)</code> 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.<br /><br />The StretchAmount is used to determine where the sunset should begin.<br /><br />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:<br /><code><br /> float StretchAmt2 = 0.5;<br /><br /> float ln2 = max(0,ln + StretchAmt + StretchAmt2);<br /> float lnn2 = max(0,lnn + StretchAmt + StretchAmt2 );<br /> float alpha = saturate(ln2 + (lnn2 * lc));<br /> <br /> float finalAlpha = height * alpha;<br /></code><br /><br />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.<br /><br /><a href="http://alexcpeterson.com/sites/default/files/images/Earth3.JPG" target="_new"><img src="http://alexcpeterson.com/sites/default/files/images/Earth3.project%20featured.JPG" /></a><br /><br />The surface shader uses a smaller 32x2 gradient map.<br /><img src="http://alexcpeterson.com/sites/default/files/images/AtmosphereGradient2.jpg" /><br /><br />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.<br /><br />Currently the pixel shader color output comes from this:<br /><code><br />outColor = (diffuse * sunColor) + (atmosphereColor * min(AtmosphereTransparency,attenuation)) * sunColor;<br /></code><br /><br />The AtmosphereTransparency is how transparent I want the atmosphere to be, and presently I'm using 0.4 based on personal preference.<br /><br />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:<br /><code><br />float vd = min(AtmosphereHeight,VisibilityDistance);<br />outAttenuation = saturate((cameraToVertexDistance - VisibilityDistance)/ (AtmosphereHeight + vd));<br /></code><br /><br />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.<br /><br />Here's a boring picture from the surface:<br /><a href="http://alexcpeterson.com/sites/default/files/images/EarthSurface.JPG" target="_new"><img src="http://alexcpeterson.com/sites/default/files/images/EarthSurface.project%20featured.JPG" /></a><br /><br />Next step is to put these shaders into Ogre and see how they look. Until then, don't forget to read the <a href="http://developer.nvidia.com/object/gpu_programming_guide.html" target="_new">NVidia GPU Guide</a> and <a href="http://developer.amd.com/gpu/radeon/pages/RadeonSDKSamplesDocuments.aspx#documentation" target="_new">ATI GPU Guides</a> every night before you go to bed.alex petersonhttp://www.blogger.com/profile/10147348345426496177noreply@blogger.com9tag:blogger.com,1999:blog-2884078902485203181.post-77999633795885582222009-09-12T10:43:00.000-07:002009-09-12T12:10:04.024-07:00How Much Memory Does This Planet Need?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:<br /><br />Patch Size (# vertices on a single patch edge): 33<br />Max Depth of Quad Tree: 5<br />Texture Size Per Patch: 128 x 128<br /><br />Assuming I could use a single height map, normal map and tangent map and sample them by using geomipmapping:<br />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) <br />= 6 x ((33 x 64) - (64 - 1))^2 x 2 <br />= 6 x (2049 x 2049) x 2<br />= 6 x 8,396,802<br />= 58,777,614 bytes<br /><br />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)<br />= 6 x (2049 x 2049) x 3<br />= 75,571,218 bytes<br /><br />tangent map is the same size as normal map<br /><br />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.<br />= 6 faces x texture size x num patches at lowest level x num bytes per pixel<br />= 6 faces x (128 x 128) x (2^(max depth + 1))^2 x 3 <br />= 6 x (128 x 128) x 4096 x 3<br />= 1,207,959,552 bytes<br />ceiling = 1,207,959,552 + (1,207,959,552 / 3) = 1,610,612,736 bytes<br /><br />So the total is:<br />58,777,614 + 75,571,218 + 75,571,218 + 1,610,612,736<br />= 1,820,532,786 bytes<br /><br />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. <br /><br />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.<br /><br />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.<br /><br />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)alex petersonhttp://www.blogger.com/profile/10147348345426496177noreply@blogger.com0tag:blogger.com,1999:blog-2884078902485203181.post-44063561207795210222009-09-05T18:39:00.000-07:002009-09-05T19:01:15.512-07:00MyFirstPlanet VideoHere's the first video showing the planet with textures and atmosphere shader. I used <a href="http://fraps.com" target="_new">fraps</a> (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.<br /><br /><object width="513" height="282"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=6449865&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=00ADEF&fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=6449865&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=00ADEF&fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="513" height="282"></embed></object><p><a href="http://vimeo.com/6449865">My First Planet - Work In Progress - Ogre3d Engine</a> from <a href="http://vimeo.com/petrocket">petrocket</a> on <a href="http://vimeo.com">Vimeo</a>.</p><br /><br />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).<br /><br />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.<br /><br />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???)alex petersonhttp://www.blogger.com/profile/10147348345426496177noreply@blogger.com5