<?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>JeGX&#039;s HackLAB &#187; Programming</title>
	<atom:link href="http://www.ozone3d.net/blogs/lab/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ozone3d.net/blogs/lab</link>
	<description>Pixel hacking, prog 3D et autres bizarreries</description>
	<lastBuildDate>Tue, 13 Dec 2011 16:25:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Live Coding</title>
		<link>http://www.ozone3d.net/blogs/lab/20111123/live-coding/</link>
		<comments>http://www.ozone3d.net/blogs/lab/20111123/live-coding/#comments</comments>
		<pubDate>Wed, 23 Nov 2011 15:30:04 +0000</pubDate>
		<dc:creator>JeGX</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[glsl]]></category>
		<category><![CDATA[live coding]]></category>
		<category><![CDATA[sexyvisuals]]></category>

		<guid isPermaLink="false">http://www.ozone3d.net/blogs/lab/?p=736</guid>
		<description><![CDATA[A cool video that shows what live coding (or live programming) is. The same kind of thing is now available in GeeXLab 0.3.0+.]]></description>
			<content:encoded><![CDATA[<p><center><br />
<iframe width="640" height="360" src="http://www.youtube.com/embed/FHxDmLf3VYk" frameborder="0" allowfullscreen></iframe><br />
</center></p>
<p><span id="more-736"></span></p>
<p>A cool video that shows what live coding (or live programming) is. The same kind of thing is now available in <a href="http://www.geeks3d.com/20111025/geexlab-0-3-0-released-geometry-and-tessellation-shaders-live-coding/">GeeXLab 0.3.0+</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ozone3d.net/blogs/lab/20111123/live-coding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Les Sampler States OpenGL 3.3: Configurer les Unités de Texture</title>
		<link>http://www.ozone3d.net/blogs/lab/20110908/tutorial-opengl-3-3-sampler-states-configurer-unites-de-texture/</link>
		<comments>http://www.ozone3d.net/blogs/lab/20110908/tutorial-opengl-3-3-sampler-states-configurer-unites-de-texture/#comments</comments>
		<pubDate>Thu, 08 Sep 2011 11:33:35 +0000</pubDate>
		<dc:creator>JeGX</dc:creator>
				<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[GL_ARB_sampler_objects]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[sampler]]></category>
		<category><![CDATA[texture]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.ozone3d.net/blogs/lab/?p=701</guid>
		<description><![CDATA[Je viens de tester les sampler states disponibles avec OpenGL 3.3 dans Kombustor 2.2.x. Les samplers states servent tout simplement à définir l&#8217;état d&#8217;une unité de texture, indépendamment de l&#8217;objet texture qui y est appliqué. Les sampler states sont décrits dans cette spec OpenGL: GL_ARB_sampler_objects. Chose intéressante, les sampler states OpenGL 3.3 permettent de coller [...]]]></description>
			<content:encoded><![CDATA[<p><center></p>
<p><img src="http://www.ozone3d.net/public/jegx/201109/msi_kombustor_tessy_sphere.jpg" alt="MSI Kombustor, tessellated sphere, DoF and soft shadows" /></p>
<p></center></p>
<p><span id="more-701"></span></p>
<p>Je viens de tester les sampler states disponibles avec <b>OpenGL 3.3</b> dans Kombustor 2.2.x. Les samplers states servent tout simplement à définir l&#8217;état d&#8217;une unité de texture, indépendamment de l&#8217;objet texture qui y est appliqué. Les sampler states sont décrits dans cette spec OpenGL: <a href="http://www.opengl.org/registry/specs/ARB/sampler_objects.txt">GL_ARB_sampler_objects</a>.</p>
<p>Chose intéressante, les sampler states OpenGL 3.3 permettent de coller à la logique de <b>Direct3D 11</b> qui définit aussi cette abstraction hardware avec la structure <b>D3D11_SAMPLER_DESC</b> et les fonctions CreateSamplerState (device D3D11) et PSSetSamplers (contexte immediat). Avant OpenGL 3.3, l&#8217;état d&#8217;une unité de texture était lié à un objet texture (créé avec glGenTextures). Maintenant avec les sampler states, on s&#8217;approche du niveau hardware / GPU. </p>
<p>Voyons rapidement comment utiliser les sampler states. </p>
<p><b>1 &#8211; Création et initialisation du sampler:</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="c" style="font-family:monospace;">GLuint sampler_state <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
glGenSamplers<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>sampler_state<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
glSamplerParameteri<span style="color: #009900;">&#40;</span>sampler_state<span style="color: #339933;">,</span> GL_TEXTURE_WRAP_S<span style="color: #339933;">,</span> GL_REPEAT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
glSamplerParameteri<span style="color: #009900;">&#40;</span>sampler_state<span style="color: #339933;">,</span> GL_TEXTURE_WRAP_T<span style="color: #339933;">,</span> GL_REPEAT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
glSamplerParameteri<span style="color: #009900;">&#40;</span>sampler_state<span style="color: #339933;">,</span> GL_TEXTURE_MAG_FILTER<span style="color: #339933;">,</span> GL_LINEAR<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
glSamplerParameteri<span style="color: #009900;">&#40;</span>sampler_state<span style="color: #339933;">,</span> GL_TEXTURE_MIN_FILTER<span style="color: #339933;">,</span> GL_LINEAR_MIPMAP_LINEAR<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
glSamplerParameterf<span style="color: #009900;">&#40;</span>sampler_state<span style="color: #339933;">,</span> GL_TEXTURE_MAX_ANISOTROPY_EXT<span style="color: #339933;">,</span> <span style="color:#800080;">16.0f</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Je viens de créer un sampler state de filtrage linéaire avec X16 de filtrage anisotropique. Les paramètres sont les mêmes que ceux utilisés lors de la création d&#8217;une texture.</p>
<p><b>2 &#8211; Utilisation du sampler</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="c" style="font-family:monospace;">GLuint texture_unit <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
glBindSampler<span style="color: #009900;">&#40;</span>texture_unit<span style="color: #339933;">,</span> sampler_state<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
...</pre></td></tr></table></div>

<p>Rien de plus simple: il suffit de dire sur quelle unité de texture doit on appliquer notre sampler. Une fois appliqué sur une unité de texture, les réglages du sampler sont prioritaires à ceux d&#8217;un objet de texture. Donc c&#8217;est super simple d&#8217;ajouter les sampler states dans votre code OpenGL. Pas besoin de modifier le code existant de création des textures.</p>
<p>Quand on ne veut plus utiliser un sampler sur une unité de texture, il suffit d&#8217;appeller le code suivant:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="c" style="font-family:monospace;">glBindSampler<span style="color: #009900;">&#40;</span>texture_unit<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><b>3 &#8211; Destruction du sampler:</b></p>
<pre>
glDeleteSamplers(1, &#038;sampler_state);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ozone3d.net/blogs/lab/20110908/tutorial-opengl-3-3-sampler-states-configurer-unites-de-texture/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Programming &#8211; Misc Links</title>
		<link>http://www.ozone3d.net/blogs/lab/20110517/programming-misc-links/</link>
		<comments>http://www.ozone3d.net/blogs/lab/20110517/programming-misc-links/#comments</comments>
		<pubDate>Tue, 17 May 2011 19:10:08 +0000</pubDate>
		<dc:creator>JeGX</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[cyrus script]]></category>
		<category><![CDATA[font]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[vsfl]]></category>

		<guid isPermaLink="false">http://www.ozone3d.net/blogs/lab/?p=498</guid>
		<description><![CDATA[Petite librairie pour le rendu de texte en mode bitmap avec OpenGL 3+ (core profile): VSFL – Very Simple Font Library Nouveau language de scripting. A tester un de ces quatres (dans une autre vie surtout!) dans GeeXLab: Cyrus Script]]></description>
			<content:encoded><![CDATA[<ul>
<li>Petite librairie pour le rendu de texte en mode bitmap avec OpenGL 3+ (core profile): <a href="http://www.lighthouse3d.com/very-simple-libs/vsfl/">VSFL – Very Simple Font Library</a></li>
<li>Nouveau language de scripting. A tester un de ces quatres (dans une autre vie surtout!) dans <a href="http://www.geeks3d.com/geexlab/">GeeXLab</a>: <a href="http://cyrusscript.com">Cyrus Script</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.ozone3d.net/blogs/lab/20110517/programming-misc-links/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>offsetof macro in C</title>
		<link>http://www.ozone3d.net/blogs/lab/20110427/offsetof-macro-in-c/</link>
		<comments>http://www.ozone3d.net/blogs/lab/20110427/offsetof-macro-in-c/#comments</comments>
		<pubDate>Wed, 27 Apr 2011 12:28:07 +0000</pubDate>
		<dc:creator>JeGX</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[macro]]></category>
		<category><![CDATA[offsetof]]></category>

		<guid isPermaLink="false">http://www.ozone3d.net/blogs/lab/?p=445</guid>
		<description><![CDATA[I just discovered this macro available in C: offsetof. Here is an simple example: struct &#123; char a; int b; char c; &#125; example; &#160; struct example s1; &#160; unsigned int offset; offset = &#40;unsigned int&#41;&#40;&#38;&#40;&#40;&#40;example *&#41;&#40;0&#41;&#41;-&#62;b&#41;&#41;; Thanks to offsetof (in the header stddef.h), the last line can be rewritten in: unsigned int offset; offset [...]]]></description>
			<content:encoded><![CDATA[<p>I just discovered this macro available in C: <b>offsetof</b>. Here is an simple example:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">struct</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #993333;">char</span> a<span style="color: #339933;">;</span>
  <span style="color: #993333;">int</span> b<span style="color: #339933;">;</span>
  <span style="color: #993333;">char</span> c<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> example<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">struct</span> example s1<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> offset<span style="color: #339933;">;</span>
offset <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>example <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>b<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Thanks to offsetof (in the header stddef.h), the last line can be rewritten in:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> offset<span style="color: #339933;">;</span>
offset <span style="color: #339933;">=</span> offsetof<span style="color: #009900;">&#40;</span>example<span style="color: #339933;">,</span> b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><a href="http://www.safercode.com/blog/2009/05/05/find-element-offset-structure-c-offsetof.html">[via]</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ozone3d.net/blogs/lab/20110427/offsetof-macro-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FreeImage: Erreur de Compilation Sous Ubuntu 10.10</title>
		<link>http://www.ozone3d.net/blogs/lab/20101007/freeimage-erreur-de-compilation-sous-ubuntu-10-10/</link>
		<comments>http://www.ozone3d.net/blogs/lab/20101007/freeimage-erreur-de-compilation-sous-ubuntu-10-10/#comments</comments>
		<pubDate>Thu, 07 Oct 2010 19:21:38 +0000</pubDate>
		<dc:creator>JeGX</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[compilation]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[freeimage]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.ozone3d.net/blogs/lab/?p=390</guid>
		<description><![CDATA[La compilation de la librairie FreeImage 3.14.1 sous Ubuntu 10.10 gènère cette erreur: In file included from Source/OpenEXR/IlmImf/ImfChromaticities.h:47, from Source/OpenEXR/./IlmImf/ImfChromaticities.cpp:43: Source/OpenEXR/Imath/ImathMatrix.h: In constructor ‘Imath::Matrix44::Matrix44() [with T = float]’: Source/OpenEXR/./IlmImf/ImfChromaticities.cpp:110: instantiated from here Source/OpenEXR/Imath/ImathMatrix.h:1813: error: ‘memset’ was not declared in this scope La solution à ce problème: ajouter l&#8217;include string.h dans le fichier Source/OpenEXR/Imath/ImathMatrix.h: #include "ImathPlatform.h" [...]]]></description>
			<content:encoded><![CDATA[<p>La compilation de la librairie <b>FreeImage 3.14.1</b> sous <b>Ubuntu 10.10</b> gènère cette erreur:</p>
<pre>
In file included from Source/OpenEXR/IlmImf/ImfChromaticities.h:47,
from Source/OpenEXR/./IlmImf/ImfChromaticities.cpp:43:
Source/OpenEXR/Imath/ImathMatrix.h: In constructor ‘Imath::Matrix44<t>::Matrix44() [with T = float]’:
Source/OpenEXR/./IlmImf/ImfChromaticities.cpp:110: instantiated from here
Source/OpenEXR/Imath/ImathMatrix.h:1813: error: ‘memset’ was not declared in this scope
</t></pre>
<p><span id="more-390"></span><br />
La solution à ce problème: ajouter l&#8217;include <i>string.h</i> dans le fichier<br />
<i>Source/OpenEXR/Imath/ImathMatrix.h</i>:</p>
<pre>
#include "ImathPlatform.h"
#include "ImathFun.h"
#include "ImathExc.h"
#include "ImathVec.h"
#include "ImathShear.h"

#include &lt;iostream&gt;
#include &lt;iomanip&gt;

#if (defined _WIN32 || defined _WIN64) &#038;&#038; defined _MSC_VER
// suppress exception specification warnings
#pragma warning(disable:4290)
#endif

<b>#include &lt;string.h&gt;</b>

namespace Imath {
...
...
</pre>
<p>Après cette modif, la compilation du projet complet FreeImage avec make devrait se dérouler sans problème. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.ozone3d.net/blogs/lab/20101007/freeimage-erreur-de-compilation-sous-ubuntu-10-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Geometry Instancing en OpenGL: le Presque Retour!</title>
		<link>http://www.ozone3d.net/blogs/lab/20100625/geometry-instancing-opengl-gtx480-hd5870/</link>
		<comments>http://www.ozone3d.net/blogs/lab/20100625/geometry-instancing-opengl-gtx480-hd5870/#comments</comments>
		<pubDate>Fri, 25 Jun 2010 12:20:55 +0000</pubDate>
		<dc:creator>JeGX</dc:creator>
				<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[geometry instancing]]></category>

		<guid isPermaLink="false">http://www.ozone3d.net/blogs/lab/?p=318</guid>
		<description><![CDATA[80,000,000 de polygones&#8230; c&#8217;est cool l&#8217;instancing! Vue les feedbacks réguliers (genre: le download n&#8217;est plus dispo!!!) que je reçois par rapport au petit article que j&#8217;ai pondu il y a 2 ans sur le geometry instancing en OpenGL, j&#8217;ai decidé de remettre le pack de demos à jour. Et j&#8217;ai ajouté un nouveau mode basé [...]]]></description>
			<content:encoded><![CDATA[<p><center></p>
<p><img src="http://www.ozone3d.net/public/jegx/201006/opengl_geometry_instancing_20100625.jpg" alt="OpenGL geometry instancing"/><br /><i>80,000,000 de polygones&#8230; c&#8217;est cool l&#8217;instancing!</i></p>
<p></center><br />
<span id="more-318"></span></p>
<p>Vue les feedbacks réguliers (genre: le download n&#8217;est plus dispo!!!) que je reçois par rapport au <a href="http://www.ozone3d.net/blogs/lab/20080316/opengl-geometry-instancing/">petit article</a> que j&#8217;ai pondu il y a 2 ans sur le <b>geometry instancing en OpenGL</b>, j&#8217;ai decidé de remettre le pack de demos à jour. </p>
<p>Et j&#8217;ai ajouté un nouveau mode basé sur les <b>uniform buffers</b>.</p>
<p>Les demos fonctionnent maintenant correctement sur ma <b>GTX 480</b>. Et bien sûr, je viens juste de tester sur une <b>HD 5870</b> + Cat 10.6 et ça mer&#8230; euh crashe!</p>
<p>Et vue que j&#8217;ai pas envie de remplacer la GTX 480 par la HD 5870 sur ma machine de dev, je vais devoir debugger à distance&#8230;</p>
<p>Dès que c&#8217;est ok sur la radeon, je publie l&#8217;article complet sur <a href="http://www.geeks3d.com">Geeks3D.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ozone3d.net/blogs/lab/20100625/geometry-instancing-opengl-gtx480-hd5870/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>(GeeXLab) Bump Mapping et Self Shadow</title>
		<link>http://www.ozone3d.net/blogs/lab/20090803/geexlab-bump-mapping-et-self-shadow/</link>
		<comments>http://www.ozone3d.net/blogs/lab/20090803/geexlab-bump-mapping-et-self-shadow/#comments</comments>
		<pubDate>Mon, 03 Aug 2009 15:26:03 +0000</pubDate>
		<dc:creator>JeGX</dc:creator>
				<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[Pixel Hacking]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tools de JeGX]]></category>
		<category><![CDATA[bump mapping]]></category>
		<category><![CDATA[GeeXLab]]></category>
		<category><![CDATA[normal map]]></category>
		<category><![CDATA[self shadow]]></category>

		<guid isPermaLink="false">http://www.ozone3d.net/blogs/lab/?p=237</guid>
		<description><![CDATA[Bump mapping &#8211; front face Ca faisait une éternité que j&#8217;avais lu un petit article sur la façon d&#8217;améliorer le bump mapping et j&#8217;ai enfin pris le temps de le tester. C&#8217;est pas une technique révolutionnaire, c&#8217;est juste une amélioration de l&#8217;ombre propre (ou self shadow) d&#8217;un objet rendu avec du bump mapping. Avec un [...]]]></description>
			<content:encoded><![CDATA[<p><center></p>
<p><img src="http://www.ozone3d.net/blogs/lab/public/200908/bump-mapping-sel-shadow-01.jpg" alt="GeeXLab demo"/><br />Bump mapping &#8211; front face</p>
<p></center><br />
<span id="more-237"></span><br />
Ca faisait une éternité que j&#8217;avais lu un petit article sur la façon d&#8217;améliorer le bump mapping et j&#8217;ai enfin pris le temps de le tester. C&#8217;est pas une technique révolutionnaire, c&#8217;est juste une amélioration de l&#8217;ombre propre (ou self shadow) d&#8217;un objet rendu avec du bump mapping. Avec un shader de bump mapping classique, l&#8217;ombre propre ressemble à ça:<br />
<center></p>
<p><img src="http://www.ozone3d.net/blogs/lab/public/200908/bump-mapping-sel-shadow-02.jpg" alt="GeeXLab demo"/><br />Bump mapping &#8211; back face</p>
<p><img src="http://www.ozone3d.net/blogs/lab/public/200908/bump-mapping-sel-shadow-03.jpg" alt="GeeXLab demo"/><br />Bump mapping back face &#8211; détail de la surface &#8211; bugs dans l&#8217;ombre propre</p>
<p></center><br />
Certaines zones sont éclairées alors qu&#8217;elles ne le devraient pas. Ce bug visuel est du à la normal map qui, pour certaines zones de la surface de l&#8217;objet, possède des vecteurs normaux qui font face à la lumière. La normal map représente les micro détails de la surface (ou, encore mieux, contrôle l&#8217;ombre propre à petite échelle) et dans certains cas ces micro détails sont si accentués que le vecteur normal perturbé (bump) qui représente l&#8217;orientation donne un DOT(bump,L)>0 alors que globalement ces micro détails sont dans l&#8217;ombre de l&#8217;objet. La solution à ce petit problème fait intervenir le vecteur normal non perturbé qui représente l&#8217;orientation globale de l&#8217;objet (ou permet de contrôler l&#8217;ombre propre à l&#8217;echelle de l&#8217;objet). En gros si DOT(N, L) est plus petit que 0 (N est vecteur normal non perturbé &#8211; gl_Normal dans un shader de Phong) alors tous les calculs qui suivent se font dans l&#8217;ombre. Mais il y a une petite ruse qui permet de rapidement savoir si un pixel est dans l&#8217;ombre sans devoir utiliser gl_Normal. Comme nous sommes dans un shader de bump mapping, nous travaillons dans l&#8217;espace tangent ou TBN. Et dans cet espace au niveau d&#8217;un pixel shader, si la composante z du vecteur lumière (vLight) est plus petite que 0 alors nous sommes dans l&#8217;ombre propre globale de l&#8217;objet:</p>
<p><center></p>
<p><img src="http://www.ozone3d.net/blogs/lab/public/200908/bump-mapping-sel-shadow-04.jpg" alt="GeeXLab demo"/><br />Bump mapping &#8211; back face &#8211; avec ombre propre correcte </p>
<p></center></p>
<p>Je détaillerai prochainement le code du shader avec un petite démo GeeXLab.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ozone3d.net/blogs/lab/20090803/geexlab-bump-mapping-et-self-shadow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HowTo: Matrice de Projection Perspective en OpenGL</title>
		<link>http://www.ozone3d.net/blogs/lab/20090728/howto-matrice-de-projection-perspective-en-opengl/</link>
		<comments>http://www.ozone3d.net/blogs/lab/20090728/howto-matrice-de-projection-perspective-en-opengl/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 08:48:52 +0000</pubDate>
		<dc:creator>JeGX</dc:creator>
				<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[camera]]></category>
		<category><![CDATA[direct3d]]></category>
		<category><![CDATA[larrabee]]></category>
		<category><![CDATA[matrice]]></category>
		<category><![CDATA[perspective]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[projection]]></category>

		<guid isPermaLink="false">http://www.ozone3d.net/blogs/lab/?p=215</guid>
		<description><![CDATA[Je viens de tomber sur ce post de Xavier Gouchet qui avait besoin d&#8217;une routine pour initialiser la matrice de projection de la caméra en OpenGL. Vu qu&#8217;il ne pouvait pas utiliser les fonctions de la glu/glut car non supportées sous Android, il a du trouver une routine avec juste deux fonctions de base d&#8217;OpenGL: [...]]]></description>
			<content:encoded><![CDATA[<p><center></p>
<p><img src="http://www.ozone3d.net/blogs/lab/public/common/maths.jpg" alt="Maths..."/></p>
<p></center><br />
<span id="more-215"></span><br />
Je viens de tomber sur <a href="http://www.xgouchet.fr/blog/index.php/post/2009/07/27/Definir-le-zoom-du-Camera-sous-OpenGL-ES">ce post</a> de Xavier Gouchet qui avait besoin d&#8217;une routine pour initialiser la matrice de projection de la caméra en OpenGL. Vu qu&#8217;il ne pouvait pas utiliser les fonctions de la glu/glut car non supportées sous Android, il a du trouver une routine avec juste deux fonctions de base d&#8217;OpenGL: glMatrixMode et glFrustum. C&#8217;est bien! Mais on peut mieux faire: rendre le calcul de la matrice totalement indépendant d&#8217;OpenGL. En gros, recoder la fonction glFrustum. </p>
<p><b>Gros intéret de la méthode</b>: la routine peut être utilisée aussi bien avec <b>Direct3D</b> qu&#8217;avec avec le futur <b>Larrabee</b>&#8230;</p>
<p>Okay mes amis, voici le code extrait de mes routines 3D (et légèrement modifié pour les besoins de ce post):</p>
<pre>
void BuildPerspProjMat(float *m, float fov, float aspect,
float znear, float zfar)
{
  float xymax = znear * tan(fov * PI_OVER_360);
  float ymin = -ymax;
  float xmin = -xmax;

  float width = xymax - xmin;
  float height = xymax - ymin;

  float depth = zfar - znear;
  float q = -(zfar + znear) / depth;
  float qn = -2 * (zfar * znear) / depth;

  float w = 2 * znear / width;
  w = w / aspect;
  float h = 2 * znear / height;

  m[0]  = w;
  m[1]  = 0;
  m[2]  = 0;
  m[3]  = 0;

  m[4]  = 0;
  m[5]  = h;
  m[6]  = 0;
  m[7]  = 0;

  m[8]  = 0;
  m[9]  = 0;
  m[10] = q;
  m[11] = -1;

  m[12] = 0;
  m[13] = 0;
  m[14] = qn;
  m[15] = 0;
}
</pre>
<p>et voici son utilisation:</p>
<pre>
float m[16] = {0};
float fov=60.0f; // en degrés
float aspect=1.3333f;
float znear=1.0f;
float zfar=1000.0f;
BuildPerspProjMat(m, fov, aspect, znear, zfar);
glMatrixMode(GL_PROJECTION);
glLoadMatrixf(m);

// et hop on repasse en modelview pour le reste des matrices
glMatrixMode(GL_MODELVIEW);
...
</pre>
<p>Pour finir et juste pour optimiser un peu, la fonction glLoadIdentity dans le code de Xavier n&#8217;est pas nécessaire car la fonction glFrustum remplace complétement la matrice&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ozone3d.net/blogs/lab/20090728/howto-matrice-de-projection-perspective-en-opengl/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>HowTo: Solutionner l&#8217;Erreur &#8220;The application failed to initialize properly (0xc0150002)&#8221;</title>
		<link>http://www.ozone3d.net/blogs/lab/20090723/howto-solutioner-lerreur-the-application-failed-to-initialize-properly-0xc0150002/</link>
		<comments>http://www.ozone3d.net/blogs/lab/20090723/howto-solutioner-lerreur-the-application-failed-to-initialize-properly-0xc0150002/#comments</comments>
		<pubDate>Thu, 23 Jul 2009 14:56:52 +0000</pubDate>
		<dc:creator>JeGX</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[0xc0150002]]></category>
		<category><![CDATA[Dependency Walker]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[msvcr90.dll]]></category>
		<category><![CDATA[vs2005]]></category>
		<category><![CDATA[vs2008]]></category>

		<guid isPermaLink="false">http://www.ozone3d.net/blogs/lab/?p=203</guid>
		<description><![CDATA[Dans un des derniers dev, je suis tombé face à ce message d&#8217;erreur: &#8220;The application failed to initialize properly (0xc0150002)&#8221; lors du test de mon app sous un Windows XP SP2 fraichement installé. What the hell??? Qu&#8217;est ce que tu me veux Windows? J&#8217;ai tout bien codé alors quel est le problème? Comme d&#8217;hab je [...]]]></description>
			<content:encoded><![CDATA[<p><center></p>
<p><img src="http://www.ozone3d.net/blogs/lab/public/200907/error.jpg" alt="Erreur"/></p>
<p></center><br />
<span id="more-203"></span><br />
Dans un des derniers dev, je suis tombé face à ce message d&#8217;erreur:<br />
&#8220;The application failed to initialize properly (0xc0150002)&#8221;<br />
lors du test de mon app sous un Windows XP SP2 fraichement installé.</p>
<p>What the hell???</p>
<p>Qu&#8217;est ce que tu me veux Windows? J&#8217;ai tout bien codé alors quel est le problème?</p>
<p>Comme d&#8217;hab je demande à gOOgle un petit coup de pouce et il me file des tonnes de liens sur le problème. Un des premiers liens, si je me souviens bien, concerne la suite Office&#8230; chuis bien avancé moi! Bon je continue mes recherches et toujours pas de solution en vue mais à un moment je vois le mot clé <b>Dependency Walker</b>. Oui c&#8217;est le soft génial qui permet d&#8217;analyser les dépendances d&#8217;un binaire: en gros il montre toutes les DLL liées à un binaire (*.exe ou *.dll). Et là la solution: une des DLLs de mon application était dépendante de <b>msvcr90.dll</b>.  msvcr90.dll est une des dlls de Visual Studio 2008 et donc toutes les applications compilées avec VS2008 poseront ce problème sous XP (pas sous Vista on dirait&#8230;).</p>
<p>La solution au message d&#8217;erreur 0xc0150002: soit vous installez les <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=a5c84275-3b97-4ab7-a40d-3802b2af5fc2&#038;displaylang=en">redistribuables VS2008</a> sur la machine cible, soit vous recompilez le binaire problématique avec VS2005 de façon à supprimer la dépendance avec msvcr90.dll, soit&#8230; c&#8217;est tout!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ozone3d.net/blogs/lab/20090723/howto-solutioner-lerreur-the-application-failed-to-initialize-properly-0xc0150002/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>[English]Depth of Field[/English][French]Depth of Field[/French]</title>
		<link>http://www.ozone3d.net/blogs/lab/20080717/depth-of-field/</link>
		<comments>http://www.ozone3d.net/blogs/lab/20080717/depth-of-field/#comments</comments>
		<pubDate>Thu, 17 Jul 2008 07:09:24 +0000</pubDate>
		<dc:creator>JeGX</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[depth of field]]></category>
		<category><![CDATA[dof]]></category>
		<category><![CDATA[post processing]]></category>
		<category><![CDATA[ssao]]></category>

		<guid isPermaLink="false">http://www.ozone3d.net/blogs/lab/?p=120</guid>
		<description><![CDATA[[English] I played with Depth Of Field (DoF) these last days in the upcoming Demoniak3D but I&#8217;m not very satisfied because I still have some problem to control the focus (the non blurred part of the field of view). Depth of field is done in a post processing step and uses the scene color and [...]]]></description>
			<content:encoded><![CDATA[<p>[English]<br />
I played with <b>Depth Of Field</b> (DoF) these last days in the upcoming <b>Demoniak3D</b> but I&#8217;m not very satisfied because I still have some problem to control the focus (the non blurred part of the field of view). Depth of field is done in a post processing step and uses the scene color and depth maps as only inputs (no multiple render targets). Here is a first preview:<br />
<center></p>
<p><img src="http://www.ozone3d.net/blogs/lab/public/200807/demoniak-depth-of-field-01.jpg" /></p>
<p></center><br />
I will continue my experimentations up to get a functional DoF and will add the support of MRT (multiple render targets) in the post processing effects (MRT will allow me to explore another cool effect: SSAO&#8230;).<br />
[/English]<br />
[French]<br />
Ces derniers jours j&#8217;ai fait quelques tests de <b>Depth Of Field</b> (DoF ou Profondeur de Champ) avec le nouveau <b>Demoniak3D</b> mais je ne suis pas satisfait du resultat car j&#8217;ai encore quelques petits soucis pour controler le focus (la zone du champ de vision qui est nette). Le Depth of field est fait dans une étape de post processing et utilise comme seules entrées la texture de couleur de la scene (scene map) et celle de la profondeur (depth map). Cet algo n&#8217;utilise pas les MRT (multiple render targets). Voilà un petit aperçu:<br />
<center></p>
<p><img src="http://www.ozone3d.net/blogs/lab/public/200807/demoniak-depth-of-field-01.jpg" /></p>
<p></center><br />
Je vais continuer mes expérimentations jusqu&#8217;à obtenir un DoF opérationnel et ajouter la gestion des MRT (les MRT me permettront d&#8217;explorer un autre effet bien sympa: le SSAO&#8230;).<br />
[/French]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ozone3d.net/blogs/lab/20080717/depth-of-field/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 1/65 queries in 0.060 seconds using disk: basic
Object Caching 594/767 objects using disk: basic

Served from: www.ozone3d.net @ 2012-02-11 17:28:51 -->
