<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Courne Supremacy &#187; Computer Graphics</title>
	<atom:link href="http://www.cournesupremacy.com/category/computer-graphics/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cournesupremacy.com</link>
	<description>Just fire one out!</description>
	<lastBuildDate>Sun, 01 Aug 2010 05:19:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=9835</generator>
		<item>
		<title>How Evangelion Inspired Me To 3D Model Again</title>
		<link>http://www.cournesupremacy.com/2010/07/31/how-evangelion-inspired-me-to-3d-model-again/</link>
		<comments>http://www.cournesupremacy.com/2010/07/31/how-evangelion-inspired-me-to-3d-model-again/#comments</comments>
		<pubDate>Sun, 01 Aug 2010 05:11:21 +0000</pubDate>
		<dc:creator>AlbinoGrimby</dc:creator>
				<category><![CDATA[3D Modeling]]></category>
		<category><![CDATA[Computer Graphics]]></category>
		<category><![CDATA[Drawing Technique]]></category>

		<guid isPermaLink="false">http://www.cournesupremacy.com/?p=702</guid>
		<description><![CDATA[A friend of mine hadn&#8217;t ever seen Neon Genesis Evangelion. I knew that Khara Studios and Hideaki Anno were redoing the 26-episode TV series as a tetralogy of movies. The first movie came out in 2007 and honestly, I just didn&#8217;t really care. Evangelion might be the landmark anime that no other anime&#8217;s ever even [...]]]></description>
			<content:encoded><![CDATA[<p>A friend of mine hadn&#8217;t ever seen Neon Genesis Evangelion. I knew that Khara Studios and Hideaki Anno were redoing the 26-episode TV series as a tetralogy of movies. The first movie came out in 2007 and honestly, I just didn&#8217;t really care. Evangelion might be the landmark anime that no other anime&#8217;s ever even approached in terms of depth and scope, but it was old-hat. I was done with it nearly a decade ago when I decided Shinji was just a whiny little bitch and the anti-hero shtick was boring. Still, there&#8217;s things I love about Eva &#8212; some of the individual episodes had interesting takes on the monster-of-the-week with Angels coming at Nerv in the form of viruses, angry whales, three dimensional shadows, mirror-moving identical twins, and ambiguously gay classmates who leave the ambiguous part at the door before descending Terminal Dogma to meet Lilith.</p>
<p>We decided to watch the new movies hoping that would serve as a good digest for Evangelion. Suddenly, I found myself getting excited for Eva again. When I was a teenager I was inspired by the Christian-laden mythology and the psychobabble. After watching Evangelion 1.11 I&#8217;m more impressed with how they rebuilt the movie&#8217;s imagery. After watching so much anime it hadn&#8217;t really hit me just how far toon-shaded rendering had come. I could easily tell that vehicles, buildings were redone as full-on 3D models but they were well integrated with the hand-drawn characters. What solidified that mind-blowing-away-ness was watching The Rebuild of Evangelion featurette. It went through how they reconstructed Tokyo-3&#8242;s buildings as 3D models and the layers of effects they put over it to achieve the images in the film.</p>
<p>And I thought, &#8220;I&#8217;m an engineer. I&#8217;m an artist. I can do that.&#8221;</p>
<p>Just to give you an idea of what&#8217;s inspiring me, here&#8217;s some screencaps from Evangelion. First up is Tokyo-3. Those skyscrapers are 3D and the houses in front are painted:</p>
<p><a href="http://www.cournesupremacy.com/wp-content/uploads/2010/07/evangelion-tokyo3-2.png" rel="lightbox[702]"><img class="aligncenter size-medium wp-image-703" title="evangelion-tokyo3-2" src="http://www.cournesupremacy.com/wp-content/uploads/2010/07/evangelion-tokyo3-2-300x197.png" alt="" width="300" height="197" /></a></p>
<p>Below is one of Tokyo-3&#8242;s buildings as it&#8217;s rising out of the Geofront. The staircase for the overhead walkway, the rail guard, and trees are painted. The building is created in 3D and toon-shaded. You can see this scene in Rebuild of Evangelion as they go through the different processes of making this scene. It starts out with some crude drawings of a tree with the 3D elements behind it and then gets refined and various filters and effects are used to create the sunset scene.</p>
<p><a href="http://www.cournesupremacy.com/wp-content/uploads/2010/07/evangelion-tokyo3.png" rel="lightbox[702]"><img class="aligncenter size-medium wp-image-721" title="evangelion-tokyo3" src="http://www.cournesupremacy.com/wp-content/uploads/2010/07/evangelion-tokyo3-300x197.png" alt="" width="300" height="197" /></a></p>
<p>I&#8217;m not sure how much CG is in this shot (I think the Angel in the upper right is CG but most of this shot looks painted), but it is quite an epic view of Tokyo-3:</p>
<p><a href="http://www.cournesupremacy.com/wp-content/uploads/2010/07/evangelion-tokyo3-3.png" rel="lightbox[702]"><img class="aligncenter size-medium wp-image-722" title="evangelion-tokyo3-3" src="http://www.cournesupremacy.com/wp-content/uploads/2010/07/evangelion-tokyo3-3-300x197.png" alt="" width="300" height="197" /></a></p>
<p>As an artist, I&#8217;ve shied away from doing 3D and mixing it with my hand drawn work. I have this mental block that says, &#8220;It&#8217;s cool, but it&#8217;s cheating.&#8221; I&#8217;ve seen plenty of brilliant artists on DeviantArt who have the skills to create amazing art without having to resort to it. I vowed to myself unconsciously that I would never cheat, but now that I&#8217;ve seen the Rebuild of Evangelion it&#8217;s removed that block from my mind. It&#8217;s not cheating to me anymore. I decided I wanted to make cinematic, cel-shaded looking artwork and with that I started exploring my old friend, Blender.</p>
<p>Blender has gone through a great deal of changes since I last used it back in January of 2008. For instance the entire UI has changed. I had long forgotten everything I knew about modeling and rendering with Blender so it wasn&#8217;t an issue. I downloaded the latest stable build and got to work learning the ins-and-outs of this new beast.</p>
<p>Without further ado, this is the final rendering at 1920&#215;1080:</p>
<p><a href="http://www.cournesupremacy.com/wp-content/uploads/2010/07/superhawke-cityscape-toon.jpg" rel="lightbox[702]"><img class="aligncenter size-medium wp-image-711" title="superhawke-cityscape-toon" src="http://www.cournesupremacy.com/wp-content/uploads/2010/07/superhawke-cityscape-toon-300x168.jpg" alt="" width="300" height="168" /></a></p>
<p>I did this as a request for a Deviant Art member. It wasn&#8217;t enough for me to just draw his character. I didn&#8217;t want another free floating character without a backdrop. I wanted a cinematic look. I wanted a detailed background, toon-rendered, and bigger than life. I drew his character from the position of a camera looking down at her and to reinforce that perspective I decided to create a city to match. I deliberated on how I would approach this for a few days and then decided to go into Blender and just start modeling rudimentary block buildings and came out with this:</p>
<p><a href="http://www.cournesupremacy.com/wp-content/uploads/2010/07/oldcity-prototype.png" rel="lightbox[702]"><img class="aligncenter size-medium wp-image-712" title="oldcity-prototype" src="http://www.cournesupremacy.com/wp-content/uploads/2010/07/oldcity-prototype-300x168.png" alt="" width="300" height="168" /></a></p>
<p>I superimposed my finished version of the girl, her name is Superhawke, over top of the first rendering and it served as a crude prototype. From there I built a better city and pulled the camera back to make it appear that she was higher up and floating in the sky above 50 story skyscrapers. The buildings are still fairly low-poly. I used some of Evangelion&#8217;s rebuild of Tokyo-3 as a benchmark for various details. I put simple air-conditioning units and water towers on the rooftops to give them more life. I placed some crude trees which were there to show scale and color so I could paint over them in Photoshop later.</p>
<p>This is the final version of that city as it was rendered:</p>
<p><a href="http://www.cournesupremacy.com/wp-content/uploads/2010/07/cityscape-final.jpg" rel="lightbox[702]"><img class="aligncenter size-medium wp-image-713" title="cityscape-final" src="http://www.cournesupremacy.com/wp-content/uploads/2010/07/cityscape-final-300x168.jpg" alt="" width="300" height="168" /></a></p>
<p>While I was constructing this city I had begun doing various rendering tests to get down the toon shading.  The first test I did was just to use Blender&#8217;s edge rendering with the toon shaded materials. What happens is that some of the lines don&#8217;t show up and if you render it to small the lines are thick. I&#8217;d have to go into Photoshop and up the levels until the lines were dark enough and I didn&#8217;t want to do that since the color would be ruined. The thick lines, bleck. Do not want. I wanted the right colors and sharp, thin lines where I expected them to be. To get thin lines what you need to do is to render out at least 200% larger than your final resolution (which is 1920&#215;1080 for me). In Photoshop I could then resize the image and get my crisp lines. Still, some of the thinner lines don&#8217;t show up. I decided the best way would be if I could separate out the line rendering and shading so I could manipulate the lines to darken them and composite everything together.</p>
<p>Well, Blender has a means of doing that when it finishes the rendering, it&#8217;s called (wait for it) the compositor. You can basically add nodes and string them together to manipulate the rendered images and layer them together. You can try and combine nodes to create all sorts of effects. To do this you need different render layers. So, one layer had my AC Units with the shadeless materials so I could get the the black lines on a white background. The only rendering options I set on this layer was to do edges. The edge rendering was set to 100. The second layer was my toon shaded version and it had all of the default rendering options checked. To get darker lines I used the RGB curve on the line render layer and increased the levels until the lines showed up and then Blender composites the toon-shaded layer to it using an Overlay mix node.</p>
<p>Here is a line shading test with shadows:</p>
<p><a href="http://www.cournesupremacy.com/wp-content/uploads/2010/07/line-shading-test.jpg" rel="lightbox[702]"><img class="aligncenter size-medium wp-image-714" title="line shading test" src="http://www.cournesupremacy.com/wp-content/uploads/2010/07/line-shading-test-300x168.jpg" alt="" width="300" height="168" /></a></p>
<p>Here&#8217;s the blender compositor node setup I used:</p>
<div id="attachment_715" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.cournesupremacy.com/wp-content/uploads/2010/07/blender-composite-notes-toonshading.png" rel="lightbox[702]"><img class="size-medium wp-image-715" title="blender-composite-notes-toonshading" src="http://www.cournesupremacy.com/wp-content/uploads/2010/07/blender-composite-notes-toonshading-300x206.png" alt="" width="300" height="206" /></a><p class="wp-caption-text">click to enlarge</p></div>
<p>This is the final rendering with both the toon render layer and the lines:</p>
<p><a href="http://www.cournesupremacy.com/wp-content/uploads/2010/07/toontest.png" rel="lightbox[702]"><img class="aligncenter size-medium wp-image-716" title="toontest" src="http://www.cournesupremacy.com/wp-content/uploads/2010/07/toontest-300x168.png" alt="" width="300" height="168" /></a></p>
<p>So far so good. I figured out a decent way of doing the rendering. Here&#8217;s the problem: with my city scene doing the compositing in Blender is going to be a pain in the ass. Basically it means duplicating the geometry and there&#8217;s already a lot of geometry for the city. This is what my blender file looks like from the camera&#8217;s POV:</p>
<p><a href="http://www.cournesupremacy.com/wp-content/uploads/2010/07/blender-workspace-view.png" rel="lightbox[702]"><img class="aligncenter size-medium wp-image-717" title="blender-workspace-view" src="http://www.cournesupremacy.com/wp-content/uploads/2010/07/blender-workspace-view-300x236.png" alt="" width="300" height="236" /></a></p>
<p>Doubling that geo to do both layers would tax my machine. I attempted it anyway and it only caused Blender to up and crash during the rendering phase after all that trouble. So it was back to the alternative way: render out the individual scenes for line rendering and the toon shading and composite them in Photoshop. Here&#8217;s a grayscale version of the buildings with the lines as composited in Photoshop:</p>
<p><a href="http://www.cournesupremacy.com/wp-content/uploads/2010/07/city-grayscale-1920x1080-ps-composite.jpg" rel="lightbox[702]"><img class="aligncenter size-medium wp-image-718" title="city-grayscale-1920x1080-ps-composite" src="http://www.cournesupremacy.com/wp-content/uploads/2010/07/city-grayscale-1920x1080-ps-composite-300x168.jpg" alt="" width="300" height="168" /></a></p>
<p>Once I had all of this going there were a few other tests I wanted to try. I wanted to see if I could reflect the sky in some of the buildings but building a skybox, while that was easy, didn&#8217;t provide good results. It&#8217;s something I still need to explore. I thought of environment maps, but I&#8217;m still shaky on how they work in Blender. I even played with ambient occlusion and got this rendering:</p>
<p><a href="http://www.cournesupremacy.com/wp-content/uploads/2010/07/oldcity-withAO.jpg" rel="lightbox[702]"><img class="aligncenter size-medium wp-image-719" title="oldcity-withAO" src="http://www.cournesupremacy.com/wp-content/uploads/2010/07/oldcity-withAO-300x168.jpg" alt="" width="300" height="168" /></a></p>
<p>I thought of compositing that with my final image, but the AO just doesn&#8217;t fit. I wanted cel-shaded coloring and it would make it look too shaded.</p>
<p>One more note, I also tried a version of Blender 2.5 with Freestyle integrated. <a href="http://freestyle.sourceforge.net/" target="_self">Freestyle is a Google Summer of Code project</a> to do toon rendering. I thought it would be a boon and solve all my problems. Certainly there are scripts in there that do an amazing job. I found one with the right line thickness and decent enough shading, but alas, it didn&#8217;t work out. Everytime I tried to render my city at 200% the resolution it would crash Blender. I tried the parametric line rendering but it didn&#8217;t work either. Of course this version of Blender 2.5 is an experimental one, so it&#8217;ll be a bit before it&#8217;s working well. I thought of going back to an older version of Blender with Freestyle as well, but honestly, it&#8217;s a different UI, and I&#8217;m not interested in learning it. So this approach was the best way and something I intend to explore further.</p>
<p>As for my friend&#8230;we watched Evangelion 1.11 and 2.22 and it left him brimming with questions and no resolution so I picked up the Evangelion TV series and we rewatched that. All I can say is, he&#8217;s seen it all now except for End of Evangelion which we&#8217;ll watch sooner or later. Those last two episodes of the TV show&#8230;painful, utterly painful to watch for me nowadays. Of course, Eva&#8217;s probably not best marathoned straight through. Back when I was in high school we did that to a friend. When he watched the last episode he turned to us and said, &#8220;I&#8217;m never watching anime again.&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cournesupremacy.com/2010/07/31/how-evangelion-inspired-me-to-3d-model-again/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>That&#8217;s not a moon&#8230;</title>
		<link>http://www.cournesupremacy.com/2007/08/29/thats-not-a-moon/</link>
		<comments>http://www.cournesupremacy.com/2007/08/29/thats-not-a-moon/#comments</comments>
		<pubDate>Thu, 30 Aug 2007 04:29:38 +0000</pubDate>
		<dc:creator>AlbinoGrimby</dc:creator>
				<category><![CDATA[Computer Graphics]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[raytracer]]></category>

		<guid isPermaLink="false">http://www.cournesupremacy.com/2007/08/29/thats-not-a-moon/</guid>
		<description><![CDATA[&#8230;it&#8217;s a partially reflective UV texture mapped sphere with the image of the moon textured on it. And that one behind it is the place the Battlestar Galactica is going next season. And there&#8217;s a big fucking crate, because what wouldn&#8217;t a &#8220;Hello World&#8221; raytraced image be without a big fucking crate. Before that I [...]]]></description>
			<content:encoded><![CDATA[<p><a title="That's not a moon!" href="http://www.cournesupremacy.com/wp-content/uploads/2007/08/texturedraytrace.jpg" rel="lightbox[101]"><img src="http://www.cournesupremacy.com/wp-content/uploads/2007/08/texturedraytrace.jpg" alt="That's not a moon!" width="440" height="331" /></a></p>
<p>&#8230;it&#8217;s a partially reflective UV texture mapped sphere with the image of the moon textured on it. And that one behind it is the place the Battlestar Galactica is going next season. And there&#8217;s a big fucking crate, because what wouldn&#8217;t a &#8220;Hello World&#8221; raytraced image be without a big fucking crate. <img src='http://www.cournesupremacy.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Before that I had a nice ranchy image of Ino from Guilty Gear XX, but I figured, who would want to see that when you could be looking at a crate?</p>
<p>So what does this image prove?</p>
<p>a. I&#8217;m a big nerd and have too much free time &#8212; and I do, cause I&#8217;m on vacation (or &#8220;vacation?&#8221;) which means I get to do whatever the hell I want, and yes, I choose to work on my raytracer, because I enjoy it. Put that in your pipe and smoke it;</p>
<p>b. I got rudimentary UV texture maps working for spheres and triangle meshes;</p>
<p>c. I can load arbitrary triangle meshes, so obviously I would load a cube because there&#8217;s nothing more interesting than a cube;</p>
<p>d. The moon is actually partially reflective and would in reality reflect a red and blue infinite checkerboard plane that stretches far and wide across the universe;</p>
<p>e. All of the above.</p>
<p>My raytracer&#8217;s actually come to the point where it takes a couple of minutes to raytrace a triangle mesh.  Such as this image:</p>
<p><a title="MMmmm Donut" href="http://www.cournesupremacy.com/wp-content/uploads/2007/08/donut.jpg" rel="lightbox[101]"><img src="http://www.cournesupremacy.com/wp-content/uploads/2007/08/donut.jpg" alt="MMmmm Donut" width="460" height="345" /></a></p>
<p>So what&#8217;s next on the agenda? Well&#8230;I fixed some of the horkiness of the raytracer, but it&#8217;s still horked in other ways. There are still issues with the reflection, refraction doesn&#8217;t work and so on and so forth&#8230;a lot of little quibbles with the mathematics that I need to iron out. It&#8217;ll get there. If you&#8217;re curious how long it took to add texture mapping and mesh loading, on my part not too long&#8230; a couple of hours each. For mesh loading, I had an OBJ loader cooked up for our old game engine Bushido. The tricky part was to understand how to find ray-triangle intersections &#8212; and to find a good one at that. If you&#8217;re looking for a good resource for barycentric ray-triangle intersection testing then google search for &#8220;Fast, Minimum Storage Ray/Triangle Intersection&#8221; by Tomas Moeller and Ben Trumbore. They also wrote a book called Real-Time Rendering which I need to get my hands on. As one senior engineer where I work told me, it&#8217;s the new bible for computer graphics.</p>
<p>For texture mapping. I had also done a TGA loader for Bushido, so I imported that and made it much more portable. There are also great UV coordinate finding algorithms online for spheres. The 3D mesh UV coordinate algorithm is just based off of the barycentric intersection test. Nice and easy and it gives me much more flexibility in what I can load into my raytracer.</p>
<p>For even further down the road I&#8217;m looking at implementing a kd-tree to speed up my raytracing especially with all these triangle meshes. I also need to consider anti-aliasing. I should also think about a transformation pipeline &#8212; that&#8217;s right, I got away without one for as long as I could! Multiple lights might be fun. Soft shadows. I&#8217;d really like to get into the procedural texturing.</p>
<p>Above all&#8230;having a GUI interface to set up a raytracer scene would really help. One of my goals is to keep my raytracer code portable, so it&#8217;s not dependent on OGL or DirectX. That way I can implement a GUI in the future so I can get a wireframe view of everything before I hit the big ole render button.</p>
<p>More to come&#8230;but dinner beckons, and then Rapture.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cournesupremacy.com/2007/08/29/thats-not-a-moon/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Horked but Working!</title>
		<link>http://www.cournesupremacy.com/2007/08/14/horked-but-working/</link>
		<comments>http://www.cournesupremacy.com/2007/08/14/horked-but-working/#comments</comments>
		<pubDate>Tue, 14 Aug 2007 09:51:15 +0000</pubDate>
		<dc:creator>AlbinoGrimby</dc:creator>
				<category><![CDATA[Computer Graphics]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[raytracer]]></category>

		<guid isPermaLink="false">http://www.cournesupremacy.com/2007/08/14/horked-but-working/</guid>
		<description><![CDATA[Here&#8217;s an image from the current state of my raytracer. The big win from all of this is that my raytracer is now recursive so I can cast reflection and refraction rays from my incident ray. It&#8217;s still buggy as hell and not showing correct results. I believe the issue I&#8217;m facing here is a [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s an image from the current state of my raytracer. The big win from all of this is that my raytracer is now recursive so I can cast reflection and refraction rays from my incident ray.  It&#8217;s still buggy as hell and not showing correct results.</p>
<p><a href="http://www.cournesupremacy.com/wp-content/uploads/2007/08/raytrace3.jpg" rel="lightbox[100]" title="Raytracing with Reflections"><img src="http://www.cournesupremacy.com/wp-content/uploads/2007/08/raytrace3.jpg" alt="Raytracing with Reflections" height="324" width="431" /></a></p>
<p>I believe the issue I&#8217;m facing here is a z-depth one. I&#8217;m noticing that a lot of my calculations are the inverse of what I expect. I don&#8217;t believe I&#8217;m supposed to see the shadow like that, and definitely I should not be seeing the reflection of those two smaller spheres. Now that I have a fairly decent raytracer working it&#8217;s time to go back and correct all the little details.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cournesupremacy.com/2007/08/14/horked-but-working/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Raytracing II</title>
		<link>http://www.cournesupremacy.com/2007/08/06/raytracing-ii/</link>
		<comments>http://www.cournesupremacy.com/2007/08/06/raytracing-ii/#comments</comments>
		<pubDate>Mon, 06 Aug 2007 09:02:00 +0000</pubDate>
		<dc:creator>AlbinoGrimby</dc:creator>
				<category><![CDATA[Computer Graphics]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[raytracer]]></category>

		<guid isPermaLink="false">http://www.cournesupremacy.com/2007/08/06/raytracing-ii/</guid>
		<description><![CDATA[After another day of work here&#8217;s the result: With the help of Foley, et al. I fixed my illumination code. The specular highlight you see here works more correctly then in the previous image. I&#8217;m not so hot about the washed out look of the sphere, but that&#8217;s mainly due to the white ambient light [...]]]></description>
			<content:encoded><![CDATA[<p>After another day of work here&#8217;s the result:</p>
<p><a href="http://www.cournesupremacy.com/wp-content/uploads/2007/08/raytrace2.jpg" rel="lightbox[95]" title="Raytracing II"><img src="http://www.cournesupremacy.com/wp-content/uploads/2007/08/raytrace2.jpg" alt="Raytracing II" height="370" width="492" /></a></p>
<p>With the help of Foley, et al. I fixed my illumination code. The specular highlight you see here works more correctly then in the previous image. I&#8217;m not so hot about the washed out look of the sphere, but that&#8217;s mainly due to the white ambient light I&#8217;m using. I also have shadows. I&#8217;m not 100% sure if the shadows are correct, but it&#8217;s a start.</p>
<p>Three spheres, one checkerboard infinite plane&#8230;I have a very simple scene list now and I can add spheres and planes at will. Maybe oneday even arbitrary 3D models. How could would that be?</p>
<p>I&#8217;m excited.</p>
<p>There&#8217;s so much I can do now. The next major refactoring/addition will be to create a recursive raytracing algorithm which will provide me with refraction and reflection. Chrome spheres here I comes!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cournesupremacy.com/2007/08/06/raytracing-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Raytracing</title>
		<link>http://www.cournesupremacy.com/2007/08/05/raytracing/</link>
		<comments>http://www.cournesupremacy.com/2007/08/05/raytracing/#comments</comments>
		<pubDate>Sun, 05 Aug 2007 08:28:27 +0000</pubDate>
		<dc:creator>AlbinoGrimby</dc:creator>
				<category><![CDATA[Computer Graphics]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[raytracing]]></category>

		<guid isPermaLink="false">http://www.cournesupremacy.com/2007/08/05/raytracing/</guid>
		<description><![CDATA[I&#8217;m taking a bit of a hiatus from perspective drawing, but I&#8217;ve learned some more interesting perspective techniques that I can share with you later, along with a really good book on the subject, but I&#8217;ve started on yet another project I&#8217;ve had on the back-burner for a while now: a raytracing engine. At work [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m taking a bit of a hiatus from perspective drawing, but I&#8217;ve learned some more interesting perspective techniques that I can share with you later, along with a really good book on the subject, but I&#8217;ve started on yet another project I&#8217;ve had on the back-burner for a while now: a raytracing engine.</p>
<p>At work we&#8217;ve got a little bit of downtime coming up, and one of the senior engineering guys, Bill, and myself started talking about raytracing. I don&#8217;t recall exactly how we began discussing the topic &#8212; something to do with Pixar, Ed Catmull, and him trying to remember the name of the guy that invented raytracing, and then there was a short discussing I initiated about this guy: <a href="http://graphics.stanford.edu/~fedkiw/" target="_blank">Ron Fedkiw</a>. Do yourself a favor and look at the videos on his site. Be prepared to change your pants and/or underpants (if you are the kind that wears underpants) during the viewing of these animations.</p>
<p>Our discussions on computer graphics rekindled my interest to write a raytracer. During my undergrad at the University of Southern California I took a graphics course and the last assignment was to put one together. I only got mine partially working, and had no more time during the semester to go back to the raytracer. So, I gave it up. Plus, through my over-zealous use of object oriented programming, OpenGL, and MFC, it was a horrible mess of partially functioning shit. Moral of that story: keep it simple, stupid.</p>
<p>Last night and all of today, I&#8217;ve been working on remedying that epic failure in my college career. Raytracing and all that it entails is an expansive subject. At it&#8217;s core, raytracing is firing (out) rays into a 3D scene and intersecting objects to return their color values. You have a picture plane (defined as a grid of pixels), and you use some vector mathematics to fire rays into a 3D scene. A ray is a point in space along with a direction. In this case, you use a point camera, and fire rays from the point through each pixel in the grid into the 3D scene. You test to see if the rays hit things in the scene&#8230;spheres, boxes, planes, what have you, and you return the color value and write it to the grid. We can get into discussing things like local illumination models, shadow casting, radiosity, super-sampling, and a whole slew of mathematically challenging topics related to image-based rendering, which I haven&#8217;t touched in a couple of years, but we won&#8217;t. Time for me to dust that portion of my brain off anyway.</p>
<p>The &#8220;Hello World&#8221; of raytracing is a checkerboard floor with any grouping of chrome spheres in which everything is reflecting everything else and casting shadows all around. That&#8217;s my first major goal, and this time, being a bit wiser, I&#8217;ll try and keep it as simple as I can be.</p>
<p>The work-in-progress of my version 0.1 raytracer:</p>
<p><a href="http://www.cournesupremacy.com/wp-content/uploads/2007/08/raytrace.jpg" rel="lightbox[92]" title="Glennâ€™s Version 0.1 Asstastic Raytraced Image"><img src="http://www.cournesupremacy.com/wp-content/uploads/2007/08/raytrace.jpg" alt="Glennâ€™s Version 0.1 Asstastic Raytraced Image" height="300" width="476" /></a></p>
<p>Click on it to see it in it&#8217;s full 1920&#215;1200 pixel glory.</p>
<p>Features so far: well it works, don&#8217;t it? It&#8217;s fairly fast. I can raytrace an image of any size. It has a simple illumination model and I can do plane and sphere intersections. All the bread and butter.</p>
<p>How did I go about building this program with my busy work schedule and only having scant hours available on weekends and weekdays? I broke it down into milestones that I thought were doable in a couple of hour chunks.</p>
<p>The first milestone was just to get the project setup. In that case, if I sudden got incredibly lazy, I could have at least the basic project setup in Visual Studio for me to continue on later. This included some math code I jacked from the Cloud game engine, Bushido and a TGA exporter I wrote a long while back. My idea is that this program will draw everything into a pixel buffer (huge ass array of RGBA values), and then spit it out as an image that I can view in Photoshop.</p>
<p>The second milestone was just to build a raycaster. This is the first step in a raytracer&#8230;just being able to fire rays into the scene and hit things. I kept true to my word and kept it simple, there&#8217;s no complicated scene manager or lighting models, etc. It&#8217;s currently all hardcoded. I wrote ray-plane and ray-sphere intersection tests.</p>
<p>The next milestone was to do a simple illumination model. Since I started writing my code willy-nilly, hardcoding things here and there, and such, you can see the lights don&#8217;t match. The purple and white plane has a light source of it&#8217;s own and the sphere&#8217;s light isn&#8217;t the same, but that&#8217;s fine, I&#8217;m messing around with phong shading, and right now it works, and it produces a pretty damn cool (and asstastic) result.</p>
<p>I though this would take me at least a couple of days to do&#8230;but it&#8217;s 1 am, Sunday morning, and after only at least, I&#8217;d say, 10 hours of coding between Friday and Saturday, I&#8217;ve got quite a lot of what I wanted to do.</p>
<p>My next milestone is to make everything a little more organized so I can do some recursive raytracing &#8212; this will allow me to get the refections, refraction, and shadows, that I&#8217;ve been dying to see in my own raytraced imagine.</p>
<p>Once I have that, I think I will have the start of a scene list, which I can expand to include ray-triangle intersection and generic 3D models I can import into the raytracing engine. What I&#8217;d love to do is to raytrace a Dyadin level or a the islands in Cloud. That would be pretty damn schweet.</p>
<p>And from there&#8230;well the sky&#8217;s the limit, and I&#8217;d love to start learning the more complicated mathematics behind all the cool stuff you can do. I have a book on procedural texturing and modeling, that would be awesome to infuse into my raytracer. You&#8217;ll be seeing more of this on the Courne Supremacy.</p>
<p>Oh, and I saw the Courne Ultimatum. I suggest you do the same, it&#8217;s an excellent movie.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cournesupremacy.com/2007/08/05/raytracing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
