<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss version="2.0">
  <channel>
    <title>DuartePeixinho.com</title>

    <link>http://www.duartepeixinho.com</link>
    <description>DuartePeixinho.com</description><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/duartepeixinho" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="duartepeixinho" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
       <title>Merry Christmas to you all</title>
       <link>http://www.duartepeixinho.com/post/7/</link>
       <description>And a Happy New Year!!!<br /><br /><div align="center"><img src="http://www.duartepeixinho.com/images/Merry%20Christmas.png" alt="MerryChristmas" title="MerryChristmas" /><br />
<br />
(and here it is, a model loaded into my engine, it had to be a geeky Christmas wish, right? ;) )</div></description>
    </item><item>
       <title>Environment Reflection Help</title>
       <link>http://www.duartepeixinho.com/post/6/</link>
       <description>While I was developing some materials for my little C++/OpenGL engine, I tried to create an environment reflection map (also known as cubemap reflection). It's one of my favorite effects and since I couldn't find any solution online, I'm going to share my own solution.<br /><br />I'm just going to focus to the vertex and fragment shaders, I suppose that you know how to send uniforms and attributes to the shaders.<br />
<br />
The secret about this shader is to calculate the camera direction to the vertex position, and that calculation have to be done on World Space. In the Vertex Shader you have to send the Camera Position in World Coordinates, and the Model Matrix (sometimes called Model To World Matrix) to be able to calculate the vertex position in World Coordinates. <br />
All the other uniforms are common to almost all shaders.<br />
<br />
<pre class="brush: cpp"><br />
// Vertex Shader<br />
<br />
attribute vec3 aPosition, aNormal;<br />
uniform vec3 CameraPos;<br />
uniform mat4 ModelViewProjectionMatrix, NormalMatrix, ModelMatrix;<br />
varying vec3 vReflection;<br />
void main() {<br />
      // normal and position calculation<br />
      vec3 normal = normalize(NormalMatrix * vec4(aNormal,1)).xyz;<br />
      gl_Position = ModelViewProjectionMatrix * vec4(aPosition,1);<br />
<br />
      // Here is the environment map calculation<br />
      //<br />
      // First you have to calculate the Vertex Position in WorldPosition<br />
      // So you just need to multiply the Position by the ModelMatrix<br />
      vec3 vertex = (ModelMatrix * vec4(aPosition,1)).xyz;<br />
      // Now you have to do the same to the Normal, so you multiply<br />
      // the normal by the ModelMatrix (don't use the Normal calculated <br />
      // before)<br />
      vec3 N = normalize((ModelMatrix * vec4(aNormal,0)).xyz);<br />
      // The Incident value is the different of vertex and camera position<br />
      // (both on world coordinates)<br />
      vec3 I = vertex - CameraPos;<br />
      // Finaly you just simply calculate the reflection using reflect<br />
      // and as it is a varying variable, it is sent to the Fragment Shader<br />
      vReflection = reflect(I,N);<br />
}<br />
</pre>For the Fragment Shader you just need to send the samplerCube (it is just a combination of 6 images, one for each side of the cube).<br />
<pre class="brush: cpp"><br />
// Fragment Shader<br />
<br />
uniform samplerCube CubeMap;<br />
varying vec3 vReflection;<br />
void main() {<br />
      // Get the pixel color from the samplerCube using the Reflection that<br />
      // was calculated on the Vertex Shader<br />
      vec4 cubeColor = textureCube( CubeMap, vReflection );<br />
      // Just send the Color to the gl_FragColor<br />
      gl_FragColor = cubeColor;<br />
}<br />
</pre><br />
<br />
Here is an example:<br />
<img src="http://www.duartepeixinho.com/images/cubemap.png" alt="CubeMap" title="CubeMap" /><br />
<br />
Now, you can add other stuff, like reflection factor, lighting and much more.</description>
    </item><item>
       <title>Some old flash experiments</title>
       <link>http://www.duartepeixinho.com/post/5/</link>
       <description>I think it should be nice to post some of my old flash experiments that I left on <a href="http://wonderfl.net" target="_blank">Wonderfl.net</a>.<br /><br />As3 Tree:<br />
<script type="text/javascript" src="http://wonderfl.net/blogparts/j4h8/js" /><p class="ttlBpWonderfl" style="width: 465px; margin: 0; text-align: right; font-size: 11px;"><a href="http://wonderfl.net/c/j4h8" title="AS3 Tree">AS3 Tree - wonderfl build flash online</a></p><br />
<br />
Pixel Perfect Particles with Basic Physics:<br />
<script type="text/javascript" src="http://wonderfl.net/blogparts/lCG5/js" /><p class="ttlBpWonderfl" style="width: 465px; margin: 0; text-align: right; font-size: 11px;"><a href="http://wonderfl.net/c/lCG5" title="Pixel Perfect Particles with Basic Physics">Pixel Perfect Particles with Basic Physics - wonderfl build flash online</a></p><br />
<br />
And another version:<br />
<script type="text/javascript" src="http://wonderfl.net/blogparts/3yRr/js" /><p class="ttlBpWonderfl" style="width: 465px; margin: 0; text-align: right; font-size: 11px;"><a href="http://wonderfl.net/c/3yRr" title="forked from: Pixel Perfect Particles with Basic Physics">forked from: Pixel Perfect Particles with Basic Physics - wonderfl build flash online</a></p><br />
<br />
Those experiments combined:<br />
<object type="application/x-shockwave-flash" data="/flash/explodingTree/pixel.swf" width="640" height="480"><param name="movie" value="/flash/explodingTree/pixel.swf" /> </object><br />
(click on the scene to create a new tree)</description>
    </item><item>
       <title>Plans for this year</title>
       <link>http://www.duartepeixinho.com/post/4/</link>
       <description>After this long period without posting anything, I remembered that I own a website, and writing sometimes ain't that bad.<br />
So here are my expectations for this new year.<br /><br />I think that 2011 is gonna be a great year for game development after some huge announcements like <a href="http://labs.adobe.com/technologies/flashplatformruntimes/incubator/" target="_blank">Adobe Flash Molehill public beta available</a>, and <a href="http://blogs.unity3d.com/2011/02/27/unity-flash-3d-on-the-web/" target="_blank">Unity3D exporting to Flash Molehill</a>.<br />
<br />
For now, my main priority is to build my first game using my c++/OpenGL engine. The engine is in its early days, and working with vertex and fragment shaders is something very new to me.<br />
I'm expecting to share some stuff engine and game related in future posts.<br />
<br />
Following this game development stuff, a couple of days ago a friend came to me with a game idea and it seems a really good one, and I'm very interested in building something like that. The only problem is that the guy behind that idea, is the same that didn't respected <a href="http://www.duartepeixinho.com/post/3/" target="_blank">this</a>!<br />
So maybe it will happen, maybe it won't.<br />
<br />
See you around!</description>
    </item><item>
       <title>Arkanoid on Unity3D</title>
       <link>http://www.duartepeixinho.com/post/3/</link>
       <description>Unity 3D is one of the top subjects this moment over the internet, so, me and my friend <a href="http://www.twitter.com/rubenptm" target="_blank">@rubenptm</a> thought that we should give it a try.<br />
We have some ideas that could fit this technology, but first we had to learn it, and to make it fun, we decided to create a small challenge.<br /><br />Each one of us should develop a game in one week, in our spare time, and we decided that the game should be a breakout clone (that turned out to be not as easy as we thought).<br />
<br />
<p align="center"><a href="http://www.duartepeixinho.com/unity3d/arkanoid" target="_blank"><img src="http://www.duartepeixinho.com/images/arkanoidUnity.png" alt="Unity3d" title="Unity3d" /><br />click to play!</a></p><br />
I started to read some tutorials and watch some videos, to get confortable with Unity tools and GUI, and for development I choose C# because I've already had done some works with it.<br />
<br />
The game have 5 different levels, and if you want to check the levels, refresh the page, it should show the other levels.<br />
<br />
It was fun to understand how Unity works, and how easy is to set up a scene.<br />
Don't know if my approach for this game was the best (and I suspect it wasn't , because some collisions are buggy, but well, this is not a serious project) but here are my unclean <a href="/unity3d/sources/Arkanoid.zip">sources</a>.<br />
<br />
I've finished the game one day after schedule, but hey, at least I've done it, right <a href="http://www.twitter.com/rubenptm" target="_blank">@rubenptm</a>? Maybe next week we'll have another version of this game by him ;)<br />
<br />
In conclusion, I really enjoyed working with Unity3D, and I'm looking forward for something more serious in the future ;)<br />
</description>
    </item><item>
       <title>My first canvas experiment</title>
       <link>http://www.duartepeixinho.com/post/2/</link>
       <description>Canvas is something that I really wanted to try some time ago, and now with the relaunch of my website, I think its the perfect moment for that.<br /><br /><p style="text-align:center;"><a href="http://duartepeixinho.com/canvas/canvasTest1/canvas.htm" target="_blank"><img src="http://duartepeixinho.com/canvas/canvasTest1/canvasExperiment1.jpg" alt="canvas" title="canvas" border="0" /></a></p><br />
<br />
For this experiment, I just ported my flash header to Canvas, and used mootools for a better OOP support in javascript.<br />
<br />
This is a very simple experiment and its performance is far from good, but if you get to check it on google chrome, its very smooth.<br />
<br />
You can check it <a href="http://www.duartepeixinho.com/canvas/canvasTest1/canvas.htm" target="_blank">here</a>!<br />
<br />
PS. really hope to make some better experiments in a near future, when I have some spare time to explore it ;) </description>
    </item><item>
       <title>New website version (3.0)</title>
       <link>http://www.duartepeixinho.com/post/1/</link>
       <description>Hi all o/<br />
<br />
After 2 years since the 2nd version of duartepeixinho.com (<a href="http://www.duartepeixinho.com/oldFlash" target="_blank">built in flash</a>) I decided to move again to HTML and build a simple and minimalistic version, only with the necessary stuff.<br /><br />For this version I used ajax (thanks mootools for such an easy task) and swfaddress for deeplinking. These are 2 frameworks that I wanted to try for a long time, now this was the opportunity.<br />
<br />
This version will be mainly in english, so don't expect long texts (and well written) because its not my main language.<br />
<br />
My future posts will be about everything I'm interested at the moment I write them, could be flash development, game development ... or just anything.<br />
<br />
Hope to see you in the future :)</description>
    </item>  </channel>
</rss>

