<?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>José Ricardo&#039;s Home Page</title>
	<atom:link href="http://josericardojunior.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://josericardojunior.com</link>
	<description></description>
	<lastBuildDate>Mon, 31 Oct 2011 22:08:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Main web site updates</title>
		<link>http://josericardojunior.com/2010/05/main-web-site-updates/</link>
		<comments>http://josericardojunior.com/2010/05/main-web-site-updates/#comments</comments>
		<pubDate>Wed, 26 May 2010 14:57:27 +0000</pubDate>
		<dc:creator>jricardo</dc:creator>
				<category><![CDATA[Games]]></category>

		<guid isPermaLink="false">http://blog.josericardojunior.com/?p=147</guid>
		<description><![CDATA[With too many tasks to do for my thesis that I&#8217;m going to present at the end of this semester, I did not much time to post news in the blog. In a short time that I had the last &#8230; <a href="http://josericardojunior.com/2010/05/main-web-site-updates/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>With too many tasks to do for my thesis that I&#8217;m going to present at the end of this semester, I did not much time to post news in the blog. In a short time that I had the last weekend, I&#8217;ve update my main web site with a new layout and last game&#8217;s project that I worked on, like the Direção Defensiva and the Vehicle Cleaner, the last one being a semi finalist in the Imagine Cup 2009.</p>
]]></content:encoded>
			<wfw:commentRss>http://josericardojunior.com/2010/05/main-web-site-updates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fluid Simulation</title>
		<link>http://josericardojunior.com/2010/04/fluid-simulation/</link>
		<comments>http://josericardojunior.com/2010/04/fluid-simulation/#comments</comments>
		<pubDate>Sat, 10 Apr 2010 14:33:15 +0000</pubDate>
		<dc:creator>jricardo</dc:creator>
				<category><![CDATA[GPGPU]]></category>
		<category><![CDATA[Fluids]]></category>
		<category><![CDATA[SPH]]></category>

		<guid isPermaLink="false">http://blog.josericardojunior.com/?p=142</guid>
		<description><![CDATA[Today I&#8217;ve finished my fluid implementation using SPH (Smoothed Particle Hydrodynamics) method for my thesis master degree. As can be seen in the video below, I archived two way coupling between fluids and rigid bodies. At this time, I need &#8230; <a href="http://josericardojunior.com/2010/04/fluid-simulation/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Today I&#8217;ve finished my fluid implementation using SPH (Smoothed Particle Hydrodynamics) method for my thesis master degree. As can be seen in the video below, I archived two way coupling between fluids and rigid bodies. At this time, I need to work in GPU optmization to allow for more particles to be simulated. Also, I need to add others types of emitters for the fluid to simulate more interesting scenes.</p>
<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/iyM1bkVSc6U&#038;hl=pt_BR&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/iyM1bkVSc6U&#038;hl=pt_BR&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://josericardojunior.com/2010/04/fluid-simulation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&quot;Direção Defensiva&quot; Presentation</title>
		<link>http://josericardojunior.com/2010/03/direcao-defensiva-presentation/</link>
		<comments>http://josericardojunior.com/2010/03/direcao-defensiva-presentation/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 12:47:28 +0000</pubDate>
		<dc:creator>jricardo</dc:creator>
				<category><![CDATA[Games]]></category>

		<guid isPermaLink="false">http://blog.josericardojunior.com/?p=137</guid>
		<description><![CDATA[This week, the game &#8220;Direção Defensiva&#8221; was presented at a government conference. As I said in an old post, this game was developed to help people driving better as the player have to obey the traffic rules like stop at &#8230; <a href="http://josericardojunior.com/2010/03/direcao-defensiva-presentation/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">This week, the game &#8220;Direção Defensiva&#8221; was presented at a government conference. As I said in an old post, this game was developed to help people driving better as the player have to obey the traffic rules like stop at traffic light,  don&#8217;t exceed the road&#8217;s speed limit, and so on. At the same time, the player have make some delivers at a given time, wich is subtracted each time he disobeys the traffic&#8217;s rule.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">In the conference, people could play the game using a wheel&#8217;s joystick, wich gave more immersion for the player. The game was a sucess in the conference and always there was people waiting for playing it. Also, the game got attention for some jornalists that published some post in newspapers and on the TV.</div>
<p>This week, the game &#8220;Direção Defensiva&#8221; was presented at a government conference. As I said in an old post, this game was developed to help people driving better as the player have to obey the traffic rules like stop at traffic light,  don&#8217;t exceed the road&#8217;s speed limit, and so on. At the same time, the player have make some delivers at a given time, wich is subtracted each time he disobeys the traffic&#8217;s rule.</p>
<p>In the conference, people could play the game using a wheel&#8217;s joystick, wich gave more immersion for the player. The game was a sucess in the conference and always there was people waiting for playing it. Also, the game got attention for some jornalists that published some post in newspapers and on the TV.</p>
<div class="wp-caption aligncenter" style="width: 170px"><a title="Pessoas testando o jogo" href="http://picasaweb.google.com/108140362942811491309/ApresentacaoDirecaoDefensivaFAPERJ#5454400126173487618"><img class="pie-img " style="margin-top: 10px; margin-bottom: 10px;" src="http://lh4.ggpht.com/_7hAvJmaPb-g/S7HsBB9qogI/AAAAAAAAABk/BHzNE_qyVjU/s160-c/IMG_0131%5B1%5D.JPG" alt="Pessoas testando o jogo" width="160" height="160" /></a><p class="wp-caption-text">People trying the game</p></div>
<div class="wp-caption aligncenter" style="width: 170px"><a title="Jornalistas efetuando matéria sobre o jogo." href="http://picasaweb.google.com/108140362942811491309/ApresentacaoDirecaoDefensivaFAPERJ#5454401545475104034"><img class="pie-img " style="margin-top: 10px; margin-bottom: 10px;" src="http://lh6.ggpht.com/_7hAvJmaPb-g/S7HtTpRinSI/AAAAAAAAAB4/MpSlvOiAL0U/s160-c/IMG_0127%5B1%5D.JPG" alt="Jornalistas efetuando matéria sobre o jogo." width="160" height="160" /></a><p class="wp-caption-text">The Journalist</p></div>
<div class="wp-caption aligncenter" style="width: 170px"><a title="Eu testando o jogo" href="http://picasaweb.google.com/108140362942811491309/ApresentacaoDirecaoDefensivaFAPERJ#5454405655532227410"><img class="pie-img " style="margin-top: 10px; margin-bottom: 10px;" src="http://lh6.ggpht.com/_7hAvJmaPb-g/S7HxC4bhS1I/AAAAAAAAACk/7PbUJoAdSGc/s160-c/moto_0058.jpg" alt="Eu testando o jogo" width="160" height="160" /></a><p class="wp-caption-text">Me testing the game also</p></div>
]]></content:encoded>
			<wfw:commentRss>http://josericardojunior.com/2010/03/direcao-defensiva-presentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Depth Peeling in CUDA</title>
		<link>http://josericardojunior.com/2010/01/depth-peeling-in-cuda/</link>
		<comments>http://josericardojunior.com/2010/01/depth-peeling-in-cuda/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 12:56:13 +0000</pubDate>
		<dc:creator>jricardo</dc:creator>
				<category><![CDATA[GPGPU]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CUDA]]></category>
		<category><![CDATA[GLSL]]></category>

		<guid isPermaLink="false">http://blog.josericardojunior.com/?p=131</guid>
		<description><![CDATA[I&#8217;ve been working on an algorithm to generate a set of polygons from a given image using CUDA and GLSL. This technique is generally called Depth Peeling [1,2,3]. To setup the data coming from and to textures, I&#8217;ve used the &#8230; <a href="http://josericardojunior.com/2010/01/depth-peeling-in-cuda/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working on an algorithm to generate a set of polygons from a given image using CUDA and GLSL. This technique is generally called Depth Peeling [1,2,3]. To setup the data coming from and to textures, I&#8217;ve used the format<span style="color: #339966;"> GL_RGBA</span> and type<span style="color: #339966;"> GL_UNSIGNED_BYTE</span>. Obviuosly looking at it, one could imagine that color components is coming in four bytes in the order Red, Green, Blue and Alpha.</p>
<p> In this case, extracting the color components could be done using the following code:</p>
<p><em>int pixel = texture[i];<br />
int r = ( ( pixel &lt;&lt; 24 ) &amp; 0xFF);<br />
int g = ( ( pixel &lt;&lt; 16 ) &amp; 0xFF);<br />
int b = ( ( pixel &lt;&lt; 8 ) &amp; 0xFF);</em></p>
<p>But, for my surprise, the components are retrieved in the inverse order. After looking for why this problem occur and also found others looking for it, as <a href="http://lists.apple.com/archives/Mac-opengl/2007/Nov/msg00134.html" target="_blank">here</a>, I found out the problem. In the code above, I was using integer type. In the Intel architecture, little endian is used, so the most significative bytes are allocated in the end. This is why we get the color components in the inverse order, even requiring some predefined order.</p>
<p>To outline this problem, I changed the type from integer to CUDA&#8217;s <span style="color: #339966;">uchar4</span>, solving the problem as bit ordering are applyed only in 16-, 32- and 64 bit word. After this change in the code, I was able to get the color components in the right order.</p>
<p> </p>
<p>[1] Cass Everitt. 2001.  &#8221;Interactive Order-Independent Transparency&#8221;.</p>
<p>[2] Trapp, Matthias and D&#8221;ollner, J&#8221;urgen. 2008.  Real-Time Volumetric Tests Using Layered Depth Images.</p>
<p>[3] Liu, Fang and Huang, Meng-Cheng and Liu, Xue-Hui and Wu, En-Hua. 2009. &#8220;Efficient Depth Peeling via Bucket Sort&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://josericardojunior.com/2010/01/depth-peeling-in-cuda/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Defensive Direction Game Project</title>
		<link>http://josericardojunior.com/2009/12/defensive-direction-game-project/</link>
		<comments>http://josericardojunior.com/2009/12/defensive-direction-game-project/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 03:21:41 +0000</pubDate>
		<dc:creator>jricardo</dc:creator>
				<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://blog.josericardojunior.com/?p=119</guid>
		<description><![CDATA[Since last year, I&#8217;ve been working on a game called Defensive Direction. In this game, the player assumes the role of a delivery of parcels inside a big city, having a fixed time to complete all of them. But unlike other &#8230; <a href="http://josericardojunior.com/2009/12/defensive-direction-game-project/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Since last year, I&#8217;ve been working on a game called Defensive Direction. In this game, the player assumes the role of a delivery of parcels inside a big city, having a fixed time to complete all of them. But unlike other games, in Defensive Direction the player must obey the traffic rules like such as not driving on sidewalks, do not pass by traffic lights, do not run above an estipulated speed among others. Some levels are already finished likes the one where the player drives tipsy. The game is going well and has the prevision to be released in January in the next year.</p>
<p>In the next days, we will be working on the AI of the cars e pedestrian of the city. Whenever possible, I will discuss techniques that were used in the game development process. Below, there&#8217;s a video of the game (in Portuguese) for those interested to see it.</p>
<p>Wait for more news!</p>
<p>[YouTube]http://www.youtube.com/watch?v=KS__0i7cN20[/YouTube]</p>
]]></content:encoded>
			<wfw:commentRss>http://josericardojunior.com/2009/12/defensive-direction-game-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Real Time Shadow Volume</title>
		<link>http://josericardojunior.com/2009/10/real-time-shadow-volume/</link>
		<comments>http://josericardojunior.com/2009/10/real-time-shadow-volume/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 02:22:10 +0000</pubDate>
		<dc:creator>jricardo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Real Time Rendering]]></category>
		<category><![CDATA[Shadow]]></category>

		<guid isPermaLink="false">http://blog.josericardojunior.com/?p=112</guid>
		<description><![CDATA[After doing some research about shadows, I found this presentation about shadow volumes. It was presented in 2004 at Siggraph and explain very well about shadow volume technique. Real-time Shadowing Techniques: Shadow Volumes View more presentations from Mark Kilgard.]]></description>
			<content:encoded><![CDATA[<p>After doing some research about shadows, I found this presentation about shadow volumes. It was presented in 2004 at Siggraph and explain very well about shadow volume technique.</p>
<div id="__ss_2221760" style="width: 425px; text-align: left;"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" title="Real-time Shadowing Techniques: Shadow Volumes" href="http://www.slideshare.net/Mark_Kilgard/realtime-shadowing-techniques-shadow-volumes">Real-time Shadowing Techniques: Shadow Volumes</a><object style="margin:0px" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="355" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=sg2004shadowvolumes-091014105146-phpapp01&amp;rel=0&amp;stripped_title=realtime-shadowing-techniques-shadow-volumes" /><param name="allowfullscreen" value="true" /><embed style="margin:0px" type="application/x-shockwave-flash" width="425" height="355" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=sg2004shadowvolumes-091014105146-phpapp01&amp;rel=0&amp;stripped_title=realtime-shadowing-techniques-shadow-volumes" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<div style="font-size: 11px; font-family: tahoma,arial; height: 26px; padding-top: 2px;">View more <a style="text-decoration:underline;" href="http://www.slideshare.net/">presentations</a> from <a style="text-decoration:underline;" href="http://www.slideshare.net/Mark_Kilgard">Mark Kilgard</a>.</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://josericardojunior.com/2009/10/real-time-shadow-volume/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SBGames 2009</title>
		<link>http://josericardojunior.com/2009/10/sbgames-2009/</link>
		<comments>http://josericardojunior.com/2009/10/sbgames-2009/#comments</comments>
		<pubDate>Mon, 19 Oct 2009 17:21:43 +0000</pubDate>
		<dc:creator>jricardo</dc:creator>
				<category><![CDATA[SBGames 2009]]></category>

		<guid isPermaLink="false">http://blog.josericardojunior.com/?p=81</guid>
		<description><![CDATA[In this month occured two of the most important conferences for computer graphics. It was the SBGames and SIBGRAPI that took place at PUC, Rio de Janeiro. At SBGames I presented a tutorial about using the Unity3D engine for making &#8230; <a href="http://josericardojunior.com/2009/10/sbgames-2009/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In this month occured two of the most important conferences for computer graphics. It was the  SBGames and SIBGRAPI that took place at PUC, Rio de Janeiro.</p>
<p>At SBGames I presented a tutorial about using the Unity3D engine for making games. It was a very good presentation and attracted a lot of people for the tutorial. Unfortunatly, only 100 minutes was  given for the presentation so only the basic concepts was covered about it.</p>
<p>Another research that I presented there was about using XNA and CUDA for prototyping  physical worlds. As this research was only accepted as a short paper, I had only one  minute to preset it. So, I made a video of about one minute trying to show my research. The  video is in Portuguese and is shown below.</p>
<p>[kaltura-widget wid="oyyh8hucnw" width="400" height="365" addpermission="" editpermission="" /]</p>
<p>[flv:http://josericardojunior.com/wp-content/uploads/2009/10/FastTrack.flv 320 240]</p>
]]></content:encoded>
			<wfw:commentRss>http://josericardojunior.com/2009/10/sbgames-2009/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Global Game Jam 2009</title>
		<link>http://josericardojunior.com/2009/03/global-game-jam-2009/</link>
		<comments>http://josericardojunior.com/2009/03/global-game-jam-2009/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 20:20:36 +0000</pubDate>
		<dc:creator>jricardo</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[XNA]]></category>

		<guid isPermaLink="false">http://josericardojunior.com/?p=45</guid>
		<description><![CDATA[Some weeks ago, I take part on the first Global Game Jam, an event that took place around the world in more than 40 universities where teams of two o three people had to design and develop a game in &#8230; <a href="http://josericardojunior.com/2009/03/global-game-jam-2009/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Some weeks ago, I take part on the first <a href="http://globalgamejam.org/" target="_blank">Global Game Jam</a>, an event that took place around the world in more than 40 universities where teams of two o three people had to design and develop a game in 48 hours!</p>
<p>There was no imposition on what tools used for develop them but here, in Niteroi &#8211; RJ, the tool thas was adopt for developing the game was <a href="http://creators.xna.com/en-US/" target="_blank">XNA</a>. This could help local judges to measure the games developed here.</p>
<p>In the begginning we saw a video of the contest organizers and attended to a local keynote about game design, which was very important to situate people that that is impossible to develop a complex game in 48 hours.</p>
<p>After that, the theme was announced:<span style="color: #008000;"> <strong>&#8220;As long we have each other, we will never run out of trouble&#8221;</strong></span>. Additionally, the maximum game play time could not be greater than 5 minutes and one of the following adjectives needed to be presented in the design: busy, travelling and tiny.</p>
<p>With this insane theme, our team that was formed by a leader programmer (me), a programmer (Andre Brandão) and a graphics artist (Jorge Lopes) started to think how to make a game with this theme. A lot of ideas came in but that was either very complex or did not fill the theme.</p>
<p><span id="more-45"></span></p>
<p style="text-align: left;">
<p style="text-align: left;"><span style="text-decoration: underline;"><strong>The Game</strong></span></p>
<p>After about 6 hour of thought, we reached a game ideia that was not too complex, fun and was in conform with the theme.</p>
<p>The game is about a woman that wants to get married. For this, she needs to pursuit a man in a given time, which is more faster than she and he can wrap in the level boundaries. To help her with this hard work, she can throws various objects in the level, trying to block his passage. Below is some screenshots of the game:</p>

<a href='http://josericardojunior.com/2009/03/global-game-jam-2009/ingame/' title='The game'><img width="150" height="150" src="http://josericardojunior.com/wp-content/uploads/2009/07/ingame-150x150.jpg" class="attachment-thumbnail" alt="The game" title="The game" /></a>
<a href='http://josericardojunior.com/2009/03/global-game-jam-2009/menu/' title='Main Menu'><img width="150" height="150" src="http://josericardojunior.com/wp-content/uploads/2009/07/menu-150x150.jpg" class="attachment-thumbnail" alt="Main Menu" title="Main Menu" /></a>
<a href='http://josericardojunior.com/2009/03/global-game-jam-2009/youwin/' title='Winning'><img width="150" height="150" src="http://josericardojunior.com/wp-content/uploads/2009/07/youwin-150x150.jpg" class="attachment-thumbnail" alt="Winning" title="Winning" /></a>

<p>Previously, I had developed a framework in XNA for 2D games, handling collision events, animated menus, scene manager, sound and things like that. This was very helpful to have the game finished in the right time as we could concentrate mainly in the game that we are developing.</p>
<p><span style="text-decoration: underline;"><strong>Results</strong></span></p>
<p>At the end of the event, each team had to present the game developed, was it almost finished or not, for local judges. Some teams make very nice games while others, unfortunatelly did not accomplish it in this short period of time.</p>
<p>After all presentations, we reach the third place in all the games developed! To a game developed in this short period of time, we were very pleased with this as we developed a game that is simple, fun and have a great game play factor behind. Some photos of the hole event can be seen <a href="http://www.ic.uff.br/~esteban/global_game_jam_rio.html">here</a> as some other <a href="http://www.earenagames.com.br/noticiasinterna.php?id=272">reports</a> about the event.</p>
<p><strong><span style="text-decoration: underline;">Future Works</span></strong></p>
<p>As future works, we plan porting it to web using Adobe <a href="http://www.adobe.com/br/products/flash/">Flash</a>, enabling people to play it without the needs of installation. More levels will be added to it and a score mark will be implemented, saving the best time a person win the game in all levels.</p>
]]></content:encoded>
			<wfw:commentRss>http://josericardojunior.com/2009/03/global-game-jam-2009/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Projective Texture Step by Step</title>
		<link>http://josericardojunior.com/2008/12/projective-texture-step-by-step/</link>
		<comments>http://josericardojunior.com/2008/12/projective-texture-step-by-step/#comments</comments>
		<pubDate>Tue, 09 Dec 2008 13:56:33 +0000</pubDate>
		<dc:creator>jricardo</dc:creator>
				<category><![CDATA[XNA]]></category>
		<category><![CDATA[Shader]]></category>
		<category><![CDATA[Transform]]></category>

		<guid isPermaLink="false">http://josericardojunior.com/?p=38</guid>
		<description><![CDATA[In my research about projection, I came to projective texture. I found a lot of material about projective texture on the web but neither of them tells exactly what steps you need to follow to archieve the desired effect. In &#8230; <a href="http://josericardojunior.com/2008/12/projective-texture-step-by-step/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In my research about projection, I came to projective texture. I found a lot of material about projective texture on the web but neither of them tells exactly what steps you need to follow to archieve the desired effect. In this post, I will tell in more detail how this works.<br />
Basically, texture projection is a dynamic texture mapping of an object that is changed according to some point of view like a camera or a spot light. It works like projecting a point using the normal world, view and projection matrix but, in this time, projecting a texture coordinate. Below is the shader that accomplish this effect and we will see line by line how it works. So, let&#8217;s go.</p>
<p><span id="more-38"></span></p>
<p>First of all, we need the texture that will be projected:<br />
<span style="color: #339966;">texture gDiffuse;</span></p>
<p>After that, we need to create a sampler. Here there is a trick. The <strong>CLAMP</strong> mode needs to be used for all adrress. This is because, sometimes, as we will see, the texture coordinate generated can be greater than 1.0.<br />
<span style="color: #339966;">sampler2D gDiffuseSampler = sampler_state {<br />
Texture = &lt;gDiffuse&gt;;<br />
MagFilter = Linear;<br />
MinFilter = Linear;<br />
AddressU = CLAMP;<br />
AddressV = CLAMP;<br />
AddressW = CLAMP;<br />
};</span></p>
<p>Here is view matrix that will do the texture projection.<br />
<span style="color: #339966;">float4x4 projectorView;</span></p>
<p>And this is our normal camera matrix, composed by the Word, View and Projection.<br />
<span style="color: #339966;">float4x4 WorldViewProj;</span></p>
<p>To facilitate, I created some structs to store the information that will be needed by the shader effect.<br />
<span style="color: #339966;">struct VSIn<br />
{<br />
float4 position : POSITION0;<br />
float4 texcoord0 : TEXCOORD0;<br />
};</span></p>
<p>struct VSOut<br />
{<br />
float4 position : POSITION0;<br />
float4 texcoord0 : TEXCOORD0;<br />
};</p>
<p>Here is our main vertex shader. Let&#8217;s see how it works:</p>
<p><span style="color: #339966;">VSOut mainVS(VSIn input){</span></p>
<p>First, we create our struct to store the end result computed by the vertex shader.<br />
<span style="color: #339966;"> VSOut output;</span></p>
<p>In this line, we compute the texture coordinate. We can see here that, to do this, we get the position and multiply by the <strong>projectorView</strong>, which is a matrix composed of a world, view and a projection but of some other point of view that can be another camera, as is the case of this example. After this multiplication, we said that the position is in homogenius clip space. Points outside the field of view of this projector view will not be rendered, or in other words, will not have texture coordinates.<br />
<span style="color: #339966;">output.texcoord0 = mul(float4(input.position.xyz, 1.0), projectorView);</span></p>
<p>Here we compute normally the projected position of this position.<br />
<span style="color: #339966;"> output.position = mul(float4(input.position.xyz, 1.0), WorldViewProj);</span></p>
<p>And finally return these information<br />
<span style="color: #339966;"> return output;</span><br />
<span style="color: #339966;">}</span></p>
<p>Now let&#8217;s see the Fragment Shader.</p>
<p><span style="color: #339966;">float4 mainPS(VSOut input) : COLOR {</span></p>
<p>First of all, we are making a division of all components of texture coordinates by w. It&#8217;s is necessary because, as I said before, we are in homogenius clip space. This space is used to do clipping but here we do not need this. So, to get the real position of this vertex we have to make this division. After that we are in normalized clip space. That is, our vertex can go from -1.0 to 1.0. Vertex outside of this range are not showed. Here we have a problem: texture coordinates only can go from 0.0 to 1.0. To solve this, we multiply it by 0.5 and add 0.5. This will do the job.<br />
<span style="color: #339966;"> float4 texcoord = input.texcoord0;<br />
texcoord.x = ((texcoord.x / texcoord.w) * 0.5 ) + 0.5;<br />
texcoord.y = ((texcoord.y / texcoord.w) * -0.5 ) + 0.5;<br />
texcoord.z = ((texcoord.z / texcoord.w) * 0.5 ) + 0.5;<br />
texcoord.w = (texcoord.w / texcoord.w);</span></p>
<p>Next, we get the texel from the texture normally.<br />
<span style="color: #339966;"> float4 tex = tex2D(gDiffuseSampler, texcoord);</span></p>
<p>And finally here we return the color. Here there&#8217;s another trick. As we are using clamp mode, texture coordinates outside the range from 0.0 to 1.0 will have its color matched to the border of the texture. So, what I did here is make the border of the image transparent, or alfa equals to 0. After that I multiply the texel color from the texture with it&#8217;s alpha and added the color of my plane, which in this case is white.<br />
<span style="color: #339966;"> return float4(tex.r * tex.a + (1.0 * (1 &#8211; tex.a)),<br />
tex.g + (1.0 * (1 &#8211; tex.a)),<br />
tex.b + (1.0 * (1 &#8211; tex.a)), 1.0);<br />
}</span></p>
<p>And is it. Below is an image of this shader applied in a plane using my engine that I&#8217;m making in XNA. Here, I used a camera with different field of view. Instead of a plane, it can be applied in whatever object you want.</p>

<a href='http://josericardojunior.com/2008/12/projective-texture-step-by-step/proj1/' title='A field of view of 30 degrees'><img width="150" height="150" src="http://josericardojunior.com/wp-content/uploads/2009/07/proj1-150x150.jpg" class="attachment-thumbnail" alt="A field of view of 30 degrees" title="A field of view of 30 degrees" /></a>
<a href='http://josericardojunior.com/2008/12/projective-texture-step-by-step/proj2/' title='A field of view of 60 degrees'><img width="150" height="150" src="http://josericardojunior.com/wp-content/uploads/2009/07/proj2-150x150.jpg" class="attachment-thumbnail" alt="A field of view of 60 degrees" title="A field of view of 60 degrees" /></a>

<p>In this shader, I tried to use the <strong>tex2Dproj</strong> which takes the texture coordinates in homogeneous coordinate space but it doesn&#8217;t work for me. If anyone get it&#8217;s working please, let me know.</p>
<p>Any comment or question, don&#8217;t hesitate to write me.</p>
]]></content:encoded>
			<wfw:commentRss>http://josericardojunior.com/2008/12/projective-texture-step-by-step/feed/</wfw:commentRss>
		<slash:comments>53</slash:comments>
		</item>
		<item>
		<title>SBGames 2008 &#8211; Photos</title>
		<link>http://josericardojunior.com/2008/11/sbgames-2008-photos/</link>
		<comments>http://josericardojunior.com/2008/11/sbgames-2008-photos/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 14:07:05 +0000</pubDate>
		<dc:creator>jricardo</dc:creator>
				<category><![CDATA[SBGames 2008]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[SBGames]]></category>

		<guid isPermaLink="false">http://josericardojunior.com/?p=16</guid>
		<description><![CDATA[Hi people, Today I&#8217;m posting some photos of SBGames, a Brazilian conference about games, computer graphics and related topics. This year, I presented a short paper about NPC behaviors compositing. It&#8217;s only for now. As soon as possible, I will &#8230; <a href="http://josericardojunior.com/2008/11/sbgames-2008-photos/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Hi people,</p>
<p>Today I&#8217;m posting some photos of SBGames, a Brazilian conference about games, computer graphics and related topics. This year, I presented a short paper about NPC behaviors compositing.</p>

<a href='http://josericardojunior.com/2008/11/sbgames-2008-photos/dsc02202/' title='Microsoft Stand'><img width="150" height="150" src="http://josericardojunior.com/wp-content/uploads/2009/07/dsc02202-150x150.jpg" class="attachment-thumbnail" alt="Microsoft Stand" title="Microsoft Stand" /></a>
<a href='http://josericardojunior.com/2008/11/sbgames-2008-photos/dsc02203/' title='Google Stand'><img width="150" height="150" src="http://josericardojunior.com/wp-content/uploads/2009/07/dsc02203-150x150.jpg" class="attachment-thumbnail" alt="Google Stand" title="Google Stand" /></a>
<a href='http://josericardojunior.com/2008/11/sbgames-2008-photos/dsc02227/' title='My Short Paper Presentation'><img width="150" height="150" src="http://josericardojunior.com/wp-content/uploads/2009/07/dsc02227-150x150.jpg" class="attachment-thumbnail" alt="My Short Paper Presentation" title="My Short Paper Presentation" /></a>
<a href='http://josericardojunior.com/2008/11/sbgames-2008-photos/dsc02232/' title='My Short Paper Poster'><img width="150" height="150" src="http://josericardojunior.com/wp-content/uploads/2009/07/dsc02232-150x150.jpg" class="attachment-thumbnail" alt="My Short Paper Poster" title="My Short Paper Poster" /></a>

<p>It&#8217;s only for now. As soon as possible, I will discuss my short paper about NPC behavior composition here.</p>
]]></content:encoded>
			<wfw:commentRss>http://josericardojunior.com/2008/11/sbgames-2008-photos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

