<?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>Game Rendering &#187; Cameras</title>
	<atom:link href="http://www.gamerendering.com/category/cameras/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gamerendering.com</link>
	<description></description>
	<lastBuildDate>Thu, 21 Jan 2010 01:32:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Position Reconstruction</title>
		<link>http://www.gamerendering.com/2009/12/07/position-reconstruction/</link>
		<comments>http://www.gamerendering.com/2009/12/07/position-reconstruction/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 15:34:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Cameras]]></category>
		<category><![CDATA[Math]]></category>
		<category><![CDATA[Deferred Rendering]]></category>
		<category><![CDATA[Deferred Shading]]></category>
		<category><![CDATA[HLSL]]></category>
		<category><![CDATA[Position]]></category>
		<category><![CDATA[Position Reconstruction]]></category>
		<category><![CDATA[Screen Space]]></category>
		<category><![CDATA[View Space]]></category>

		<guid isPermaLink="false">http://www.gamerendering.com/?p=751</guid>
		<description><![CDATA[There are many occasions when the fragment position in world space needs to be reconstructed from a texture holding the scene depth (depth texture). One example of use is in deferred rendering when trying to decrease memory usage by not saving the position but instead only the depth. This will result in one channel of [...]]]></description>
			<content:encoded><![CDATA[<p style="MARGIN-BOTTOM: 0cm">There are many occasions when the fragment position in world space needs to be reconstructed from a texture holding the scene depth (depth texture). One example of use is in deferred rendering when trying to decrease memory usage by not saving the position but instead only the depth. This will result in one channel of data, instead of three channels needed when saving the whole position.</p>
<p style="MARGIN-BOTTOM: 0cm"> </p>
<div class="mceTemp"><a href="http://www.gamerendering.com/wp-content/uploads/scenedepth.jpg"><img class="size-medium wp-image-755" title="Viewspace scene depth texture" src="http://www.gamerendering.com/wp-content/uploads/scenedepth-400x300.jpg" alt="Viewspace scene depth" width="400" height="300" /></a></div>
<p style="MARGIN-BOTTOM: 0cm">There are different ways to save the depth. The most popular are view space depth and screen space depth. Saving depth in view space instead of screen space gives two advantages. It&#8217;s faster, and it gives better precision because it&#8217;s linear in view space.</p>
<p style="MARGIN-BOTTOM: 0cm">This is how <strong>screen space depth</strong> can be rendered in HLSL:</p>

<div class="wp_codebox"><table width="100%" ><tr id="p7513"><td class="code" id="p751code3"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">struct</span> VS_OUTPUT
<span style="color: #009900;">&#123;</span>
   float4 Pos<span style="color: #339933;">:</span> POSITION<span style="color: #339933;">;</span>
   float4 posInProjectedSpace<span style="color: #339933;">:</span> TEXCOORD0<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// vertex shader</span>
VS_OUTPUT vs_main<span style="color: #009900;">&#40;</span> float4 Pos<span style="color: #339933;">:</span> POSITION <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
   VS_OUTPUT Out <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>VS_OUTPUT<span style="color: #009900;">&#41;</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
   Out.<span style="color: #202020;">Pos</span> <span style="color: #339933;">=</span> mul<span style="color: #009900;">&#40;</span>Pos<span style="color: #339933;">,</span>matWorldViewProjection<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   Out.<span style="color: #202020;">posInProjectedSpace</span> <span style="color: #339933;">=</span> Out.<span style="color: #202020;">Pos</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">return</span> Out<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// pixel shader</span>
float4 ps_main<span style="color: #009900;">&#40;</span> VS_OUTPUT Input <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> COLOR
<span style="color: #009900;">&#123;</span>
   <span style="color: #993333;">float</span> depth <span style="color: #339933;">=</span> Input.<span style="color: #202020;">posInProjectedSpace</span>.<span style="color: #202020;">z</span> <span style="color: #339933;">/</span> Input.<span style="color: #202020;">posInProjectedSpace</span>.<span style="color: #202020;">w</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">return</span> depth<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>The HLSL pixel shader below shows how the position can be reconstructed from the depth map stored with the code above. Although this is one of the slowest ways of doing position reconstruction since it requires a matrix multiplication.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p7514"><td class="code" id="p751code4"><pre class="c" style="font-family:monospace;">float4 ps_main<span style="color: #009900;">&#40;</span>float2 vPos <span style="color: #339933;">:</span> VPOS<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> COLOR0
<span style="color: #009900;">&#123;</span>
   <span style="color: #993333;">float</span> depth <span style="color: #339933;">=</span> tex2D<span style="color: #009900;">&#40;</span>depthTexture<span style="color: #339933;">,</span>vPos<span style="color: #339933;">*</span>fInverseViewportDimensions <span style="color: #339933;">+</span> fInverseViewportDimensions<span style="color: #339933;">*</span><span style="color:#800080;">0.5</span><span style="color: #009900;">&#41;</span>.<span style="color: #202020;">r</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">// scale it to -1..1 (screen coordinates)</span>
   float2 projectedXY <span style="color: #339933;">=</span> vPos<span style="color: #339933;">*</span>fInverseViewportDimensions<span style="color: #339933;">*</span><span style="color: #0000dd;">2</span><span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
   projectedXY.<span style="color: #202020;">y</span> <span style="color: #339933;">=</span> <span style="color: #339933;">-</span>projectedXY.<span style="color: #202020;">y</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">// create the position in screen space</span>
   float4 pos <span style="color: #339933;">=</span> float4<span style="color: #009900;">&#40;</span>projectedXY<span style="color: #339933;">,</span>depth<span style="color: #339933;">,</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">// transform position into world space by multiplication with the inverse view projection matrix</span>
   pos <span style="color: #339933;">=</span> mul<span style="color: #009900;">&#40;</span>pos<span style="color: #339933;">,</span>matViewProjectionInverse<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
   <span style="color: #666666; font-style: italic;">// make it homogeneous</span>
   pos <span style="color: #339933;">/=</span> pos.<span style="color: #202020;">w</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// result will be (x,y,z,1) in world space</span>
&nbsp;
   <span style="color: #b1b100;">return</span> pos<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// for now, just render it out</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p style="MARGIN-BOTTOM: 0cm">To reconstruct<strong> depth from view space</strong>, a ray from the camera position to the frustum far plane is needed. For a full screen quad, this ray can be precalculated for the four corners and passed to the shader. This is how the computer game Crysis did it [1] . But for arbitrary geometry, as needed in deferred rendering, the ray must be calculated in the shaders [2] .</p>
<p style="MARGIN-BOTTOM: 0cm">[1] &#8220;Finding next gen: CryEngine 2&#8243;<br />
<a href="http://ati.amd.com/developer/gdc/2007/mittring-finding_nextgen_cryengine2(siggraph07).pdf">http://ati.amd.com/developer/gdc/2007/mittring-finding_nextgen_cryengine2(siggraph07).pdf</a></p>
<p style="MARGIN-BOTTOM: 0cm">[2] “Reconstructing Position From Depth, Continued”<br />
<a href="http://mynameismjp.wordpress.com/2009/05/05/reconstructing-position-from-depth-continued/">http://mynameismjp.wordpress.com/2009/05/05/reconstructing-position-from-depth-continued/</a></p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Please share:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow" id="print" href="javascript:window.location='http%3A%2F%2Fwww.printfriendly.com%2Fprint%3Furl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2009%252F12%252F07%252Fposition-reconstruction%252F%26amp%3Bpartner%3Dsociable';" title="Print this article!"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print this article!" alt="Print this article!" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="digg" href="javascript:window.location='http%3A%2F%2Fdigg.com%2Fsubmit%3Fphase%3D2%26amp%3Burl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2009%252F12%252F07%252Fposition-reconstruction%252F%26amp%3Btitle%3DPosition%2520Reconstruction%26amp%3Bbodytext%3DThere%2520are%2520many%2520occasions%2520when%2520the%2520fragment%2520position%2520in%2520world%2520space%2520needs%2520to%2520be%2520reconstructed%2520from%2520a%2520texture%2520holding%2520the%2520scene%2520depth%2520%2528depth%2520texture%2529.%2520One%2520example%2520of%2520use%2520is%2520in%2520deferred%2520rendering%2520when%2520trying%2520to%2520decrease%2520memory%2520usage%2520by%2520not%2520saving%2520the%2520po';" title="Digg"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="sphinn" href="javascript:window.location='http%3A%2F%2Fsphinn.com%2Findex.php%3Fc%3Dpost%26m%3Dsubmit%26link%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2009%252F12%252F07%252Fposition-reconstruction%252F';" title="Sphinn"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="del.icio.us" href="javascript:window.location='http%3A%2F%2Fdelicious.com%2Fpost%3Furl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2009%252F12%252F07%252Fposition-reconstruction%252F%26amp%3Btitle%3DPosition%2520Reconstruction%26amp%3Bnotes%3DThere%2520are%2520many%2520occasions%2520when%2520the%2520fragment%2520position%2520in%2520world%2520space%2520needs%2520to%2520be%2520reconstructed%2520from%2520a%2520texture%2520holding%2520the%2520scene%2520depth%2520%2528depth%2520texture%2529.%2520One%2520example%2520of%2520use%2520is%2520in%2520deferred%2520rendering%2520when%2520trying%2520to%2520decrease%2520memory%2520usage%2520by%2520not%2520saving%2520the%2520po';" title="del.icio.us"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="facebook" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2009%252F12%252F07%252Fposition-reconstruction%252F%26amp%3Bt%3DPosition%2520Reconstruction';" title="Facebook"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="mixx" href="javascript:window.location='http%3A%2F%2Fwww.mixx.com%2Fsubmit%3Fpage_url%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2009%252F12%252F07%252Fposition-reconstruction%252F%26amp%3Btitle%3DPosition%2520Reconstruction';" title="Mixx"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="google" href="javascript:window.location='http%3A%2F%2Fwww.google.com%2Fbookmarks%2Fmark%3Fop%3Dedit%26amp%3Bbkmk%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2009%252F12%252F07%252Fposition-reconstruction%252F%26amp%3Btitle%3DPosition%2520Reconstruction%26amp%3Bannotation%3DThere%2520are%2520many%2520occasions%2520when%2520the%2520fragment%2520position%2520in%2520world%2520space%2520needs%2520to%2520be%2520reconstructed%2520from%2520a%2520texture%2520holding%2520the%2520scene%2520depth%2520%2528depth%2520texture%2529.%2520One%2520example%2520of%2520use%2520is%2520in%2520deferred%2520rendering%2520when%2520trying%2520to%2520decrease%2520memory%2520usage%2520by%2520not%2520saving%2520the%2520po';" title="Google Bookmarks"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="current" href="javascript:window.location='http%3A%2F%2Fcurrent.com%2Fclipper.htm%3Furl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2009%252F12%252F07%252Fposition-reconstruction%252F%26amp%3Btitle%3DPosition%2520Reconstruction';" title="Current"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/current.png" title="Current" alt="Current" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="linkedin" href="javascript:window.location='http%3A%2F%2Fwww.linkedin.com%2FshareArticle%3Fmini%3Dtrue%26amp%3Burl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2009%252F12%252F07%252Fposition-reconstruction%252F%26amp%3Btitle%3DPosition%2520Reconstruction%26amp%3Bsource%3DGame%2BRendering%2B%26amp%3Bsummary%3DThere%2520are%2520many%2520occasions%2520when%2520the%2520fragment%2520position%2520in%2520world%2520space%2520needs%2520to%2520be%2520reconstructed%2520from%2520a%2520texture%2520holding%2520the%2520scene%2520depth%2520%2528depth%2520texture%2529.%2520One%2520example%2520of%2520use%2520is%2520in%2520deferred%2520rendering%2520when%2520trying%2520to%2520decrease%2520memory%2520usage%2520by%2520not%2520saving%2520the%2520po';" title="LinkedIn"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="live" href="javascript:window.location='https%3A%2F%2Ffavorites.live.com%2Fquickadd.aspx%3Fmarklet%3D1%26amp%3Burl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2009%252F12%252F07%252Fposition-reconstruction%252F%26amp%3Btitle%3DPosition%2520Reconstruction';" title="Live"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="myspace" href="javascript:window.location='http%3A%2F%2Fwww.myspace.com%2FModules%2FPostTo%2FPages%2F%3Fu%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2009%252F12%252F07%252Fposition-reconstruction%252F%26amp%3Bt%3DPosition%2520Reconstruction';" title="MySpace"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="netvibes" href="javascript:window.location='http%3A%2F%2Fwww.netvibes.com%2Fshare%3Ftitle%3DPosition%2520Reconstruction%26amp%3Burl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2009%252F12%252F07%252Fposition-reconstruction%252F';" title="Netvibes"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="stumbleupon" href="javascript:window.location='http%3A%2F%2Fwww.stumbleupon.com%2Fsubmit%3Furl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2009%252F12%252F07%252Fposition-reconstruction%252F%26amp%3Btitle%3DPosition%2520Reconstruction';" title="StumbleUpon"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="twitter" href="javascript:window.location='http%3A%2F%2Ftwitter.com%2Fhome%3Fstatus%3DPosition%2520Reconstruction%2520-%2520http%253A%252F%252Fwww.gamerendering.com%252F2009%252F12%252F07%252Fposition-reconstruction%252F';" title="Twitter"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="reddit" href="javascript:window.location='http%3A%2F%2Freddit.com%2Fsubmit%3Furl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2009%252F12%252F07%252Fposition-reconstruction%252F%26amp%3Btitle%3DPosition%2520Reconstruction';" title="Reddit"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="technorati" href="javascript:window.location='http%3A%2F%2Ftechnorati.com%2Ffaves%3Fadd%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2009%252F12%252F07%252Fposition-reconstruction%252F';" title="Technorati"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow" id="yahoo! bookmarks" href="javascript:window.location='http%3A%2F%2Fbookmarks.yahoo.com%2Ftoolbar%2Fsavebm%3Fu%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2009%252F12%252F07%252Fposition-reconstruction%252F%26amp%3Bt%3DPosition%2520Reconstruction%26opener%3Dbm%26amp%3Bei%3DUTF-8%26amp%3Bd%3DThere%2520are%2520many%2520occasions%2520when%2520the%2520fragment%2520position%2520in%2520world%2520space%2520needs%2520to%2520be%2520reconstructed%2520from%2520a%2520texture%2520holding%2520the%2520scene%2520depth%2520%2528depth%2520texture%2529.%2520One%2520example%2520of%2520use%2520is%2520in%2520deferred%2520rendering%2520when%2520trying%2520to%2520decrease%2520memory%2520usage%2520by%2520not%2520saving%2520the%2520po';" title="Yahoo! Bookmarks"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.gamerendering.com/2009/12/07/position-reconstruction/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Geometry Pipeline</title>
		<link>http://www.gamerendering.com/2008/10/05/geometry-pipeline/</link>
		<comments>http://www.gamerendering.com/2008/10/05/geometry-pipeline/#comments</comments>
		<pubDate>Sun, 05 Oct 2008 13:08:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Cameras]]></category>
		<category><![CDATA[Rendering Methods]]></category>

		<guid isPermaLink="false">http://www.gamerendering.com/?p=223</guid>
		<description><![CDATA[The geometry pipeline is the pipeline of transformations for geometry ( for example a face ) from object space to screen space. It looks like the following.

Information about the different spaces:
http://www.glprogramming.com/red/chapter03.html



Please share:


	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	


]]></description>
			<content:encoded><![CDATA[<p>The geometry pipeline is the pipeline of transformations for geometry ( for example a face ) from object space to screen space. It looks like the following.</p>
<p><a href="http://www.gamerendering.com/wp-content/uploads/geometrypipeline.jpg"><img class="size-full wp-image-224" title="Geometry Pipeline" src="http://www.gamerendering.com/wp-content/uploads/geometrypipeline.jpg" alt="Geometry Pipeline" width="294" height="519" /></a></p>
<p>Information about the different spaces:<br />
<a href="http://www.glprogramming.com/red/chapter03.html">http://www.glprogramming.com/red/chapter03.html</a></p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Please share:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow" id="print" href="javascript:window.location='http%3A%2F%2Fwww.printfriendly.com%2Fprint%3Furl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fgeometry-pipeline%252F%26amp%3Bpartner%3Dsociable';" title="Print this article!"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print this article!" alt="Print this article!" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="digg" href="javascript:window.location='http%3A%2F%2Fdigg.com%2Fsubmit%3Fphase%3D2%26amp%3Burl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fgeometry-pipeline%252F%26amp%3Btitle%3DGeometry%2520Pipeline%26amp%3Bbodytext%3DThe%2520geometry%2520pipeline%2520is%2520the%2520pipeline%2520of%2520transformations%2520for%25C2%25A0geometry%2520%2528%2520for%2520example%2520a%25C2%25A0face%2520%2529%25C2%25A0from%2520object%2520space%2520to%2520screen%2520space.%2520It%2520looks%2520like%2520the%2520following.%250D%250A%250D%250A%250D%250A%250D%250AInformation%2520about%2520the%2520different%2520spaces%253A%250D%250Ahttp%253A%252F%252Fwww.glprogramming.com%252Fred%252Fchapter03';" title="Digg"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="sphinn" href="javascript:window.location='http%3A%2F%2Fsphinn.com%2Findex.php%3Fc%3Dpost%26m%3Dsubmit%26link%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fgeometry-pipeline%252F';" title="Sphinn"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="del.icio.us" href="javascript:window.location='http%3A%2F%2Fdelicious.com%2Fpost%3Furl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fgeometry-pipeline%252F%26amp%3Btitle%3DGeometry%2520Pipeline%26amp%3Bnotes%3DThe%2520geometry%2520pipeline%2520is%2520the%2520pipeline%2520of%2520transformations%2520for%25C2%25A0geometry%2520%2528%2520for%2520example%2520a%25C2%25A0face%2520%2529%25C2%25A0from%2520object%2520space%2520to%2520screen%2520space.%2520It%2520looks%2520like%2520the%2520following.%250D%250A%250D%250A%250D%250A%250D%250AInformation%2520about%2520the%2520different%2520spaces%253A%250D%250Ahttp%253A%252F%252Fwww.glprogramming.com%252Fred%252Fchapter03';" title="del.icio.us"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="facebook" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fgeometry-pipeline%252F%26amp%3Bt%3DGeometry%2520Pipeline';" title="Facebook"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="mixx" href="javascript:window.location='http%3A%2F%2Fwww.mixx.com%2Fsubmit%3Fpage_url%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fgeometry-pipeline%252F%26amp%3Btitle%3DGeometry%2520Pipeline';" title="Mixx"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="google" href="javascript:window.location='http%3A%2F%2Fwww.google.com%2Fbookmarks%2Fmark%3Fop%3Dedit%26amp%3Bbkmk%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fgeometry-pipeline%252F%26amp%3Btitle%3DGeometry%2520Pipeline%26amp%3Bannotation%3DThe%2520geometry%2520pipeline%2520is%2520the%2520pipeline%2520of%2520transformations%2520for%25C2%25A0geometry%2520%2528%2520for%2520example%2520a%25C2%25A0face%2520%2529%25C2%25A0from%2520object%2520space%2520to%2520screen%2520space.%2520It%2520looks%2520like%2520the%2520following.%250D%250A%250D%250A%250D%250A%250D%250AInformation%2520about%2520the%2520different%2520spaces%253A%250D%250Ahttp%253A%252F%252Fwww.glprogramming.com%252Fred%252Fchapter03';" title="Google Bookmarks"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="current" href="javascript:window.location='http%3A%2F%2Fcurrent.com%2Fclipper.htm%3Furl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fgeometry-pipeline%252F%26amp%3Btitle%3DGeometry%2520Pipeline';" title="Current"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/current.png" title="Current" alt="Current" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="linkedin" href="javascript:window.location='http%3A%2F%2Fwww.linkedin.com%2FshareArticle%3Fmini%3Dtrue%26amp%3Burl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fgeometry-pipeline%252F%26amp%3Btitle%3DGeometry%2520Pipeline%26amp%3Bsource%3DGame%2BRendering%2B%26amp%3Bsummary%3DThe%2520geometry%2520pipeline%2520is%2520the%2520pipeline%2520of%2520transformations%2520for%25C2%25A0geometry%2520%2528%2520for%2520example%2520a%25C2%25A0face%2520%2529%25C2%25A0from%2520object%2520space%2520to%2520screen%2520space.%2520It%2520looks%2520like%2520the%2520following.%250D%250A%250D%250A%250D%250A%250D%250AInformation%2520about%2520the%2520different%2520spaces%253A%250D%250Ahttp%253A%252F%252Fwww.glprogramming.com%252Fred%252Fchapter03';" title="LinkedIn"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="live" href="javascript:window.location='https%3A%2F%2Ffavorites.live.com%2Fquickadd.aspx%3Fmarklet%3D1%26amp%3Burl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fgeometry-pipeline%252F%26amp%3Btitle%3DGeometry%2520Pipeline';" title="Live"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="myspace" href="javascript:window.location='http%3A%2F%2Fwww.myspace.com%2FModules%2FPostTo%2FPages%2F%3Fu%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fgeometry-pipeline%252F%26amp%3Bt%3DGeometry%2520Pipeline';" title="MySpace"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="netvibes" href="javascript:window.location='http%3A%2F%2Fwww.netvibes.com%2Fshare%3Ftitle%3DGeometry%2520Pipeline%26amp%3Burl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fgeometry-pipeline%252F';" title="Netvibes"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="stumbleupon" href="javascript:window.location='http%3A%2F%2Fwww.stumbleupon.com%2Fsubmit%3Furl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fgeometry-pipeline%252F%26amp%3Btitle%3DGeometry%2520Pipeline';" title="StumbleUpon"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="twitter" href="javascript:window.location='http%3A%2F%2Ftwitter.com%2Fhome%3Fstatus%3DGeometry%2520Pipeline%2520-%2520http%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fgeometry-pipeline%252F';" title="Twitter"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="reddit" href="javascript:window.location='http%3A%2F%2Freddit.com%2Fsubmit%3Furl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fgeometry-pipeline%252F%26amp%3Btitle%3DGeometry%2520Pipeline';" title="Reddit"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="technorati" href="javascript:window.location='http%3A%2F%2Ftechnorati.com%2Ffaves%3Fadd%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fgeometry-pipeline%252F';" title="Technorati"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow" id="yahoo! bookmarks" href="javascript:window.location='http%3A%2F%2Fbookmarks.yahoo.com%2Ftoolbar%2Fsavebm%3Fu%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fgeometry-pipeline%252F%26amp%3Bt%3DGeometry%2520Pipeline%26opener%3Dbm%26amp%3Bei%3DUTF-8%26amp%3Bd%3DThe%2520geometry%2520pipeline%2520is%2520the%2520pipeline%2520of%2520transformations%2520for%25C2%25A0geometry%2520%2528%2520for%2520example%2520a%25C2%25A0face%2520%2529%25C2%25A0from%2520object%2520space%2520to%2520screen%2520space.%2520It%2520looks%2520like%2520the%2520following.%250D%250A%250D%250A%250D%250A%250D%250AInformation%2520about%2520the%2520different%2520spaces%253A%250D%250Ahttp%253A%252F%252Fwww.glprogramming.com%252Fred%252Fchapter03';" title="Yahoo! Bookmarks"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.gamerendering.com/2008/10/05/geometry-pipeline/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Screen Space</title>
		<link>http://www.gamerendering.com/2008/10/05/screen-space/</link>
		<comments>http://www.gamerendering.com/2008/10/05/screen-space/#comments</comments>
		<pubDate>Sun, 05 Oct 2008 10:10:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Cameras]]></category>
		<category><![CDATA[Depth buffer]]></category>
		<category><![CDATA[Fragment Shader]]></category>
		<category><![CDATA[Normalized Device Coordinates]]></category>
		<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[Screen Space]]></category>
		<category><![CDATA[Transformations]]></category>
		<category><![CDATA[Viewport]]></category>
		<category><![CDATA[Z-buffer]]></category>

		<guid isPermaLink="false">http://www.gamerendering.com/?p=196</guid>
		<description><![CDATA[The last step of transformations (world to screen) when rendering is to get the rendered objects to screen space. This is a 2D space with the origin in the middle of the screen. After the vertex shader but before the fragment shader the fragments will be normalized device coordinates and will automatically be transformed to screen space. The fragments x,y [...]]]></description>
			<content:encoded><![CDATA[<p>The last step of transformations (world to screen) when rendering is to get the rendered objects to screen space. This is a 2D space with the origin in the middle of the screen. After the vertex shader but before the fragment shader the fragments will be normalized device coordinates and will automatically be transformed to screen space. The fragments x,y coordinates will be mapped to the x and y coordinates on the screen (the exact mapping is set by viewportbounds). And the z coordinates will be mapped to the depth buffer (z-buffer) as the following [-1] -&gt; [near clip plane limit] and [1] -&gt; [far clip plane limit].</p>
<p>The viewport mapping is the following [-1,1] in X is mapped to the left to right of the viewport range. The [-1,1] in Y is mapped to the bottom to top of the viewport range</p>
<p>Framents will automatically be transformed to screen space before the fragment shader, you just need to set the viewport mapping with the following OpenGL call.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p1966"><td class="code" id="p196code6"><pre class="c" style="font-family:monospace;">glViewport<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> screenHeight<span style="color: #339933;">/</span><span style="color: #0000dd;">2</span><span style="color: #339933;">,</span> screenWidth<span style="color: #339933;">/</span><span style="color: #0000dd;">2</span><span style="color: #339933;">,</span> screenHeight<span style="color: #339933;">/</span><span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>You can access the current fragment depth in a fragment shader with the variable gl_FragDepth which in default is the same as gl_FragCoord.z. The screen coordinates can be accessed in the variable gl_FragCoord.xy.</p>
<p>Information about pixel shaders in DirectX (most is the same in OpenGL):<br />
<a href="http://www.gamedev.net/columns/hardcore/dxshader3/">http://www.gamedev.net/columns/hardcore/dxshader3/</a></p>
<p>A quick reference guide to GLSL:<br />
<a href="http://www.opengl.org/sdk/libs/OpenSceneGraph/glsl_quickref.pdf">http://www.opengl.org/sdk/libs/OpenSceneGraph/glsl_quickref.pdf</a></p>
<p>Description of the mapping in DirectX:<br />
<a href="http://msdn.microsoft.com/en-us/library/bb219690.aspx">http://msdn.microsoft.com/en-us/library/bb219690.aspx</a></p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Please share:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow" id="print" href="javascript:window.location='http%3A%2F%2Fwww.printfriendly.com%2Fprint%3Furl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fscreen-space%252F%26amp%3Bpartner%3Dsociable';" title="Print this article!"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print this article!" alt="Print this article!" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="digg" href="javascript:window.location='http%3A%2F%2Fdigg.com%2Fsubmit%3Fphase%3D2%26amp%3Burl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fscreen-space%252F%26amp%3Btitle%3DScreen%2520Space%26amp%3Bbodytext%3DThe%2520last%2520step%2520of%2520transformations%25C2%25A0%2528world%2520to%2520screen%2529%25C2%25A0when%2520rendering%2520is%2520to%2520get%2520the%2520rendered%2520objects%2520to%2520screen%2520space.%2520This%2520is%2520a%25202D%2520space%2520with%2520the%2520origin%2520in%2520the%2520middle%2520of%2520the%2520screen.%2520After%2520the%2520vertex%2520shader%2520but%2520before%2520the%2520fragment%2520shader%2520the%25C2%25A0fragments%2520';" title="Digg"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="sphinn" href="javascript:window.location='http%3A%2F%2Fsphinn.com%2Findex.php%3Fc%3Dpost%26m%3Dsubmit%26link%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fscreen-space%252F';" title="Sphinn"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="del.icio.us" href="javascript:window.location='http%3A%2F%2Fdelicious.com%2Fpost%3Furl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fscreen-space%252F%26amp%3Btitle%3DScreen%2520Space%26amp%3Bnotes%3DThe%2520last%2520step%2520of%2520transformations%25C2%25A0%2528world%2520to%2520screen%2529%25C2%25A0when%2520rendering%2520is%2520to%2520get%2520the%2520rendered%2520objects%2520to%2520screen%2520space.%2520This%2520is%2520a%25202D%2520space%2520with%2520the%2520origin%2520in%2520the%2520middle%2520of%2520the%2520screen.%2520After%2520the%2520vertex%2520shader%2520but%2520before%2520the%2520fragment%2520shader%2520the%25C2%25A0fragments%2520';" title="del.icio.us"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="facebook" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fscreen-space%252F%26amp%3Bt%3DScreen%2520Space';" title="Facebook"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="mixx" href="javascript:window.location='http%3A%2F%2Fwww.mixx.com%2Fsubmit%3Fpage_url%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fscreen-space%252F%26amp%3Btitle%3DScreen%2520Space';" title="Mixx"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="google" href="javascript:window.location='http%3A%2F%2Fwww.google.com%2Fbookmarks%2Fmark%3Fop%3Dedit%26amp%3Bbkmk%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fscreen-space%252F%26amp%3Btitle%3DScreen%2520Space%26amp%3Bannotation%3DThe%2520last%2520step%2520of%2520transformations%25C2%25A0%2528world%2520to%2520screen%2529%25C2%25A0when%2520rendering%2520is%2520to%2520get%2520the%2520rendered%2520objects%2520to%2520screen%2520space.%2520This%2520is%2520a%25202D%2520space%2520with%2520the%2520origin%2520in%2520the%2520middle%2520of%2520the%2520screen.%2520After%2520the%2520vertex%2520shader%2520but%2520before%2520the%2520fragment%2520shader%2520the%25C2%25A0fragments%2520';" title="Google Bookmarks"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="current" href="javascript:window.location='http%3A%2F%2Fcurrent.com%2Fclipper.htm%3Furl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fscreen-space%252F%26amp%3Btitle%3DScreen%2520Space';" title="Current"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/current.png" title="Current" alt="Current" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="linkedin" href="javascript:window.location='http%3A%2F%2Fwww.linkedin.com%2FshareArticle%3Fmini%3Dtrue%26amp%3Burl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fscreen-space%252F%26amp%3Btitle%3DScreen%2520Space%26amp%3Bsource%3DGame%2BRendering%2B%26amp%3Bsummary%3DThe%2520last%2520step%2520of%2520transformations%25C2%25A0%2528world%2520to%2520screen%2529%25C2%25A0when%2520rendering%2520is%2520to%2520get%2520the%2520rendered%2520objects%2520to%2520screen%2520space.%2520This%2520is%2520a%25202D%2520space%2520with%2520the%2520origin%2520in%2520the%2520middle%2520of%2520the%2520screen.%2520After%2520the%2520vertex%2520shader%2520but%2520before%2520the%2520fragment%2520shader%2520the%25C2%25A0fragments%2520';" title="LinkedIn"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="live" href="javascript:window.location='https%3A%2F%2Ffavorites.live.com%2Fquickadd.aspx%3Fmarklet%3D1%26amp%3Burl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fscreen-space%252F%26amp%3Btitle%3DScreen%2520Space';" title="Live"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="myspace" href="javascript:window.location='http%3A%2F%2Fwww.myspace.com%2FModules%2FPostTo%2FPages%2F%3Fu%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fscreen-space%252F%26amp%3Bt%3DScreen%2520Space';" title="MySpace"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="netvibes" href="javascript:window.location='http%3A%2F%2Fwww.netvibes.com%2Fshare%3Ftitle%3DScreen%2520Space%26amp%3Burl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fscreen-space%252F';" title="Netvibes"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="stumbleupon" href="javascript:window.location='http%3A%2F%2Fwww.stumbleupon.com%2Fsubmit%3Furl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fscreen-space%252F%26amp%3Btitle%3DScreen%2520Space';" title="StumbleUpon"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="twitter" href="javascript:window.location='http%3A%2F%2Ftwitter.com%2Fhome%3Fstatus%3DScreen%2520Space%2520-%2520http%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fscreen-space%252F';" title="Twitter"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="reddit" href="javascript:window.location='http%3A%2F%2Freddit.com%2Fsubmit%3Furl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fscreen-space%252F%26amp%3Btitle%3DScreen%2520Space';" title="Reddit"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="technorati" href="javascript:window.location='http%3A%2F%2Ftechnorati.com%2Ffaves%3Fadd%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fscreen-space%252F';" title="Technorati"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow" id="yahoo! bookmarks" href="javascript:window.location='http%3A%2F%2Fbookmarks.yahoo.com%2Ftoolbar%2Fsavebm%3Fu%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fscreen-space%252F%26amp%3Bt%3DScreen%2520Space%26opener%3Dbm%26amp%3Bei%3DUTF-8%26amp%3Bd%3DThe%2520last%2520step%2520of%2520transformations%25C2%25A0%2528world%2520to%2520screen%2529%25C2%25A0when%2520rendering%2520is%2520to%2520get%2520the%2520rendered%2520objects%2520to%2520screen%2520space.%2520This%2520is%2520a%25202D%2520space%2520with%2520the%2520origin%2520in%2520the%2520middle%2520of%2520the%2520screen.%2520After%2520the%2520vertex%2520shader%2520but%2520before%2520the%2520fragment%2520shader%2520the%25C2%25A0fragments%2520';" title="Yahoo! Bookmarks"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.gamerendering.com/2008/10/05/screen-space/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Normalized Device Coordinates</title>
		<link>http://www.gamerendering.com/2008/10/05/normalized-device-coordinates/</link>
		<comments>http://www.gamerendering.com/2008/10/05/normalized-device-coordinates/#comments</comments>
		<pubDate>Sun, 05 Oct 2008 01:04:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Cameras]]></category>
		<category><![CDATA[Clip Plane]]></category>
		<category><![CDATA[Fragment Shader]]></category>
		<category><![CDATA[Normalized Device Coordinates]]></category>
		<category><![CDATA[Projection]]></category>
		<category><![CDATA[Vertex Shader]]></category>

		<guid isPermaLink="false">http://www.gamerendering.com/?p=192</guid>
		<description><![CDATA[After projection to clip space the points will no longer be normalized. This can be restored by dividing all components of the vertex by the fourth component (w). This will (together with the projection transformation) result in that the projection volume will map to a cube with minimum corner in (-1,-1,-1) and maximum corner in (1,1,1). For example [...]]]></description>
			<content:encoded><![CDATA[<p>After <a title="Projection to Clip Space" href="http://www.gamerendering.com/2008/10/05/clip-space/">projection to clip space</a> the points will no longer be normalized. This can be restored by dividing all components of the vertex by the fourth component (w). This will (together with the projection transformation) result in that the projection volume will map to a cube with minimum corner in (-1,-1,-1) and maximum corner in (1,1,1). For example in OpenGL, the near clip plane will map to -1 ( in DirectX it will be mapped to 0) and the far clip plane will map to 1.</p>
<p>The division by w (homogenization) is performed automatically between the vertex shader and the fragment shader in the procedure called Rasterization.</p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Please share:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow" id="print" href="javascript:window.location='http%3A%2F%2Fwww.printfriendly.com%2Fprint%3Furl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fnormalized-device-coordinates%252F%26amp%3Bpartner%3Dsociable';" title="Print this article!"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/printfriendly.png" title="Print this article!" alt="Print this article!" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="digg" href="javascript:window.location='http%3A%2F%2Fdigg.com%2Fsubmit%3Fphase%3D2%26amp%3Burl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fnormalized-device-coordinates%252F%26amp%3Btitle%3DNormalized%2520Device%2520Coordinates%26amp%3Bbodytext%3DAfter%2520projection%25C2%25A0to%2520clip%25C2%25A0space%25C2%25A0the%2520points%2520will%2520no%2520longer%2520be%2520normalized.%2520This%2520can%2520be%2520restored%2520by%2520dividing%2520all%2520components%2520of%2520the%2520vertex%2520by%2520the%2520fourth%2520component%2520%2528w%2529.%2520This%2520will%2520%2528together%2520with%2520the%2520projection%2520transformation%2529%2520result%2520in%2520that%2520the%2520projectio';" title="Digg"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="sphinn" href="javascript:window.location='http%3A%2F%2Fsphinn.com%2Findex.php%3Fc%3Dpost%26m%3Dsubmit%26link%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fnormalized-device-coordinates%252F';" title="Sphinn"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="del.icio.us" href="javascript:window.location='http%3A%2F%2Fdelicious.com%2Fpost%3Furl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fnormalized-device-coordinates%252F%26amp%3Btitle%3DNormalized%2520Device%2520Coordinates%26amp%3Bnotes%3DAfter%2520projection%25C2%25A0to%2520clip%25C2%25A0space%25C2%25A0the%2520points%2520will%2520no%2520longer%2520be%2520normalized.%2520This%2520can%2520be%2520restored%2520by%2520dividing%2520all%2520components%2520of%2520the%2520vertex%2520by%2520the%2520fourth%2520component%2520%2528w%2529.%2520This%2520will%2520%2528together%2520with%2520the%2520projection%2520transformation%2529%2520result%2520in%2520that%2520the%2520projectio';" title="del.icio.us"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="facebook" href="javascript:window.location='http%3A%2F%2Fwww.facebook.com%2Fshare.php%3Fu%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fnormalized-device-coordinates%252F%26amp%3Bt%3DNormalized%2520Device%2520Coordinates';" title="Facebook"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="mixx" href="javascript:window.location='http%3A%2F%2Fwww.mixx.com%2Fsubmit%3Fpage_url%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fnormalized-device-coordinates%252F%26amp%3Btitle%3DNormalized%2520Device%2520Coordinates';" title="Mixx"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="google" href="javascript:window.location='http%3A%2F%2Fwww.google.com%2Fbookmarks%2Fmark%3Fop%3Dedit%26amp%3Bbkmk%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fnormalized-device-coordinates%252F%26amp%3Btitle%3DNormalized%2520Device%2520Coordinates%26amp%3Bannotation%3DAfter%2520projection%25C2%25A0to%2520clip%25C2%25A0space%25C2%25A0the%2520points%2520will%2520no%2520longer%2520be%2520normalized.%2520This%2520can%2520be%2520restored%2520by%2520dividing%2520all%2520components%2520of%2520the%2520vertex%2520by%2520the%2520fourth%2520component%2520%2528w%2529.%2520This%2520will%2520%2528together%2520with%2520the%2520projection%2520transformation%2529%2520result%2520in%2520that%2520the%2520projectio';" title="Google Bookmarks"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="current" href="javascript:window.location='http%3A%2F%2Fcurrent.com%2Fclipper.htm%3Furl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fnormalized-device-coordinates%252F%26amp%3Btitle%3DNormalized%2520Device%2520Coordinates';" title="Current"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/current.png" title="Current" alt="Current" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="linkedin" href="javascript:window.location='http%3A%2F%2Fwww.linkedin.com%2FshareArticle%3Fmini%3Dtrue%26amp%3Burl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fnormalized-device-coordinates%252F%26amp%3Btitle%3DNormalized%2520Device%2520Coordinates%26amp%3Bsource%3DGame%2BRendering%2B%26amp%3Bsummary%3DAfter%2520projection%25C2%25A0to%2520clip%25C2%25A0space%25C2%25A0the%2520points%2520will%2520no%2520longer%2520be%2520normalized.%2520This%2520can%2520be%2520restored%2520by%2520dividing%2520all%2520components%2520of%2520the%2520vertex%2520by%2520the%2520fourth%2520component%2520%2528w%2529.%2520This%2520will%2520%2528together%2520with%2520the%2520projection%2520transformation%2529%2520result%2520in%2520that%2520the%2520projectio';" title="LinkedIn"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="live" href="javascript:window.location='https%3A%2F%2Ffavorites.live.com%2Fquickadd.aspx%3Fmarklet%3D1%26amp%3Burl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fnormalized-device-coordinates%252F%26amp%3Btitle%3DNormalized%2520Device%2520Coordinates';" title="Live"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="myspace" href="javascript:window.location='http%3A%2F%2Fwww.myspace.com%2FModules%2FPostTo%2FPages%2F%3Fu%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fnormalized-device-coordinates%252F%26amp%3Bt%3DNormalized%2520Device%2520Coordinates';" title="MySpace"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="netvibes" href="javascript:window.location='http%3A%2F%2Fwww.netvibes.com%2Fshare%3Ftitle%3DNormalized%2520Device%2520Coordinates%26amp%3Burl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fnormalized-device-coordinates%252F';" title="Netvibes"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="stumbleupon" href="javascript:window.location='http%3A%2F%2Fwww.stumbleupon.com%2Fsubmit%3Furl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fnormalized-device-coordinates%252F%26amp%3Btitle%3DNormalized%2520Device%2520Coordinates';" title="StumbleUpon"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="twitter" href="javascript:window.location='http%3A%2F%2Ftwitter.com%2Fhome%3Fstatus%3DNormalized%2520Device%2520Coordinates%2520-%2520http%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fnormalized-device-coordinates%252F';" title="Twitter"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="reddit" href="javascript:window.location='http%3A%2F%2Freddit.com%2Fsubmit%3Furl%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fnormalized-device-coordinates%252F%26amp%3Btitle%3DNormalized%2520Device%2520Coordinates';" title="Reddit"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" id="technorati" href="javascript:window.location='http%3A%2F%2Ftechnorati.com%2Ffaves%3Fadd%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fnormalized-device-coordinates%252F';" title="Technorati"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow" id="yahoo! bookmarks" href="javascript:window.location='http%3A%2F%2Fbookmarks.yahoo.com%2Ftoolbar%2Fsavebm%3Fu%3Dhttp%253A%252F%252Fwww.gamerendering.com%252F2008%252F10%252F05%252Fnormalized-device-coordinates%252F%26amp%3Bt%3DNormalized%2520Device%2520Coordinates%26opener%3Dbm%26amp%3Bei%3DUTF-8%26amp%3Bd%3DAfter%2520projection%25C2%25A0to%2520clip%25C2%25A0space%25C2%25A0the%2520points%2520will%2520no%2520longer%2520be%2520normalized.%2520This%2520can%2520be%2520restored%2520by%2520dividing%2520all%2520components%2520of%2520the%2520vertex%2520by%2520the%2520fourth%2520component%2520%2528w%2529.%2520This%2520will%2520%2528together%2520with%2520the%2520projection%2520transformation%2529%2520result%2520in%2520that%2520the%2520projectio';" title="Yahoo! Bookmarks"><img src="http://www.gamerendering.com/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.gamerendering.com/2008/10/05/normalized-device-coordinates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
