<?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>Encelo's Blog &#187; Programming</title>
	<atom:link href="http://encelo.netsons.org/blog/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://encelo.netsons.org/blog</link>
	<description>When I grow up I want to be a game developer</description>
	<lastBuildDate>Mon, 02 Nov 2009 23:49:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Gimme some (real-time) water!</title>
		<link>http://encelo.netsons.org/blog/2009/11/02/gimme-some-real-time-water/</link>
		<comments>http://encelo.netsons.org/blog/2009/11/02/gimme-some-real-time-water/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 22:20:44 +0000</pubDate>
		<dc:creator>encelo</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Real-time Graphics]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Fresnel]]></category>
		<category><![CDATA[GLSL]]></category>
		<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[reflection]]></category>
		<category><![CDATA[refraction]]></category>
		<category><![CDATA[shaders]]></category>

		<guid isPermaLink="false">http://encelo.netsons.org/blog/?p=411</guid>
		<description><![CDATA[Computer generated water has always interested me, since the days of POVRay on Amiga I was trying to simulate it in some way.
Some days ago, while studying another technique, I put everything aside because in that particular moment I felt the urge to implement a water shader.  

I began looking for existing implementations and [...]]]></description>
			<content:encoded><![CDATA[<p>Computer generated water has always interested me, since the days of POVRay on Amiga I was trying to simulate it in some way.<br />
Some days ago, while studying another technique, I put everything aside because in that particular moment I felt the urge to implement a water shader. <img src='http://encelo.netsons.org/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p><img src="http://encelo.netsons.org/blog/wp-content/uploads/2009/11/water_crop.png" alt="water_crop" title="water_crop" width="400" height="175" class="aligncenter size-full wp-image-415" /></p>
<p>I began looking for existing implementations and I found <a href="http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series4/The_water_technique.php">Reimer&#8217;s XNA tutorial</a>, a simple approach which I think could be optimized, but that already provides a nice looking water.</p>
<p>The technique is composed of four passes:</p>
<ul>
<li>Rendering the reflection map</li>
<li>Rendering the refraction map</li>
<li>Rendering the scene</li>
<li>Rendering the water plane linearly interpolating the two maps with a Fresnel term</li>
</ul>
<p>One of the drawbacks is represented by the fact that the whole scene is rendered three times during the first three passes, I&#8217;m sure that this procedure could be optimized, but I was lazy enough to cease any further test. <img src='http://encelo.netsons.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Moreover having every pass clearly separated helps with debugging and makes the application capable of displaying them one at a time.</p>
<p>The scene is rendered with parallax mapping enabled, and that is more evident than ever thanks to the new bricks textures, but with an altered shader that also performs user plane clipping, decisive for the first two passes.<br />
Talking about the Fresnel term I have implemented a naive (nothing more than a <tt>dot(V, N)</tt>) and a better approximation based on the Nvidia&#8217;s  <a href="http://developer.nvidia.com/object/fresnel_wp.html">Fresnel reflection</a> paper.<br />
In the source you will find both but only the first one is actually used, it works better in the scene used in this demo.<br />
You can easily see that waves are fake, the water is composed of just two triangles, the ripple animation is generated by the fragment shader altering texture coordinates based on a normal map and using a time variable.</p>
<p>Of course you can have a look at videos on YouTube (<a href="http://www.youtube.com/watch?v=oBZhS2btj2U<br />
">GLSL_water</a>, <a href=http://www.youtube.com/watch?v=nmc8WQhgkNM">GLSL_water_HD</a>) or Vimeo (<a href="http://vimeo.com/7400766<br />
">GLSL_water</a>, <a href="http://vimeo.com/7401000 ">GLSL_water_HD</a>) and download the <a href="http://encelo.netsons.org/_download/glsl_water.tar.gz">sources</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://encelo.netsons.org/blog/2009/11/02/gimme-some-real-time-water/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>High Dynamic Range galore</title>
		<link>http://encelo.netsons.org/blog/2009/10/14/high-dynamic-range-galore/</link>
		<comments>http://encelo.netsons.org/blog/2009/10/14/high-dynamic-range-galore/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 19:42:50 +0000</pubDate>
		<dc:creator>encelo</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Real-time Graphics]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[GLSL]]></category>
		<category><![CDATA[HDR]]></category>
		<category><![CDATA[High Dynamic Range]]></category>
		<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[post-processing]]></category>
		<category><![CDATA[shaders]]></category>
		<category><![CDATA[snippets]]></category>

		<guid isPermaLink="false">http://encelo.netsons.org/blog/?p=378</guid>
		<description><![CDATA[In January, during my internship activity, I was researching in the field of HDR imaging, today I had the time, at last, to polish a bit and release the two demos I made at the time.
They both load an RGBE image (the two you see here are courtesy of the Paul Devebec&#8217;s Light Probe Image [...]]]></description>
			<content:encoded><![CDATA[<p>In January, during my internship activity, I was researching in the field of HDR imaging, today I had the time, at last, to polish a bit and release the two demos I made at the time.</p>
<p>They both load an <a href="http://en.wikipedia.org/wiki/RGBE_image_format">RGBE</a> image (the two you see here are courtesy of the Paul Devebec&#8217;s <a href="http://www.debevec.org/probes/">Light Probe Image Gallery</a>) through the <a href="http://www.graphics.cornell.edu/online/formats/rgbe/">library</a> of Bruce Walter.</p>
<div id="attachment_382" class="wp-caption aligncenter" style="width: 310px"><a href="http://encelo.netsons.org/blog/wp-content/uploads/2009/10/hdr_strip1.png"><img src="http://encelo.netsons.org/blog/wp-content/uploads/2009/10/hdr_strip1-300x100.png" alt="Light probe at different exposure levels (hdr_load1)" title="hdr_strip1" width="300" height="100" class="size-medium wp-image-382" /></a><p class="wp-caption-text">Light probe at different exposure levels (hdr_load1)</p></div>
<p>The first demo implements the technique described in the article <a href="http://www.gamedev.net/columns/hardcore/hdrrendering/">High Dynamic Range Rendering</a> published on GameDev.net and is based on five passes and four FBOs:</p>
<ol>
<li>Rendering of the floating-point texture in an FBO</li>
<li>Down-sampling in a 1/4 FBO and high-pass filter</li>
<li>Gaussian filter along the X axis</li>
<li>Gaussian filter along the Y axis</li>
<li>Tone-mapping and composition</li>
</ol>
<p>The algorithm is very simple, it first renders the original scene then it extracts bright parts at the second pass, which merely discards fragments which are below a specified threshold:</p>
<pre class="brush: cpp;">
// excrpt from hipass.frag
if (colorMap.r &gt; 1.0 || colorMap.g &gt; 1.0 || colorMap.b &gt; 1.0)
	gl_FragColor = colorMap;
else
	gl_FragColor = vec4(0.0);
</pre>
<p>While the third and fourth passes blurs the bright mask, the last one mixes it with the first FBO and sets exposure and gamma to achieve a bloom effect.</p>
<pre class="brush: cpp;">
// excerpt from tonemap.frag
gl_FragColor = colorMap + Factor * (bloomMap - colorMap);
gl_FragColor *= Exposure;
gl_FragColor = pow(gl_FragColor, vec4(Gamma));
</pre>
<div id="attachment_382" class="wp-caption aligncenter" style="width: 310px"><a href="http://encelo.netsons.org/blog/wp-content/uploads/2009/10/hdr_strip2.png"><img src="http://encelo.netsons.org/blog/wp-content/uploads/2009/10/hdr_strip2-300x100.png" alt="Light probe at different exposure levels (hdr_load2)" title="hdr_strip2" width="300" height="100" class="size-medium wp-image-382" /></a><p class="wp-caption-text">Light probe at different exposure levels (hdr_load2)</p></div>
<p>The second demo implements the technique described in the article <a href="http://www.ziggyware.com/readarticle.php?article_id=226">High Dynamic Range Rendering in XNA</a> published on Ziggyware and is based on seven passed and more than five FBOs:</p>
<ol>
<li>Rendering of the floating-point texture in an FBO</li>
<li>Calculating maximum and mean luminance for the entire scene</li>
<li>Bright-pass filter</li>
<li>Gaussian filter along the X axis</li>
<li>Gaussian filter along the Y axis</li>
<li>Tone-mapping</li>
<li>Bloom layer addition</li>
</ol>
<p>This approach is far more complex than the previous one and is based on converting the scene to its <a href="http://en.wikipedia.org/wiki/Luma_%28video%29">luminance</a> (defined as <em>Y = 0.299*R + 0.587*G + 0.114*B</em>) version, the mean and maximum value can be calculated using a particular downsampling shader and working in more passes, at each one rendering on an FBO with a smaller resolution than the previous until the last pass, when you render the luminance of the entire scene on a 1&#215;1 FBO.</p>
<p>As usual you can have a look at YouTube (<a href="http://www.youtube.com/watch?v=D93glosIbbo">GLSL_hdrload1</a>, <a href="http://www.youtube.com/watch?v=BRdkseJs7t0">GLSL_hdrload2</a>) or Vimeo (<a href="http://vimeo.com/7067100">GLSL_hdrload1</a>, <a href="http://vimeo.com/7067374">GLSL_hdrload2</a>) videos and download the <a href="http://encelo.netsons.org/_download/glsl_hdrload.tar.gz">sources</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://encelo.netsons.org/blog/2009/10/14/high-dynamic-range-galore/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GL O.B.S.: two years after</title>
		<link>http://encelo.netsons.org/blog/2009/10/05/gl-o-b-s-two-years-after/</link>
		<comments>http://encelo.netsons.org/blog/2009/10/05/gl-o-b-s-two-years-after/#comments</comments>
		<pubDate>Mon, 05 Oct 2009 18:17:35 +0000</pubDate>
		<dc:creator>encelo</dc:creator>
				<category><![CDATA[G.L.O.B.S.]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[PyGTK]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://encelo.netsons.org/blog/?p=327</guid>
		<description><![CDATA[You&#8217;re reading about GL O.B.S. after *exactly* 730 days (I swear it was not made on purpose  ): today revision 50 has been committed.
No new feature has been added, I&#8217;ve dedicated the efforts of the last days to a case study about updating an application after a very long time, the process mainly involved [...]]]></description>
			<content:encoded><![CDATA[<p>You&#8217;re reading about GL O.B.S. after *exactly* 730 days (I swear it was not made on purpose <img src='http://encelo.netsons.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> ): today revision 50 has been committed.<br />
No new feature has been added, I&#8217;ve dedicated the efforts of the last days to a case study about updating an application after a very long time, the process mainly involved removing deprecated things and adding support for new ones.</p>
<div id="attachment_355" class="wp-caption aligncenter" style="width: 406px"><img src="http://encelo.netsons.org/blog/wp-content/uploads/2009/10/globs_glade.png" alt="GL O.B.S. GUI is now based on GtkBuider" title="globs_glade" width="396" height="168" class="size-full wp-image-355" /><p class="wp-caption-text">GL O.B.S. GUI is now based on GtkBuider</p></div>
<p>Let&#8217;s read together some lines from the <a href="http://globs.svn.sourceforge.net/viewvc/globs?view=rev&#038;revision=50">revision log</a>:</p>
<ul>
<li><em>GUI migrated from libglade to GtkBuilder</em><br />
This was, with no doubt, the most time consuming task: <tt>gtk-builder-convert</tt> tool was not so reliable and I was compelled to recreate the GUI from scratch with Glade. I have also set the minimum GTK version required to 2.16</li>
<li><em>using JSON format for storing benchmark information dictionaries</em><br />
This feature is a way to get rid of the deprecated <tt>execfile()</tt> built-in function, instead of executing a python script to read a dictionary, the Benchmark class now parses a JSON file with the new integrated <a href="http://docs.python.org/library/json.html">json</a> module.<br />
Comparing an <a href="http://globs.svn.sourceforge.net/viewvc/globs/benchmarks/trunk/Fake/__globs_info.py?revision=1&#038;view=markup&#038;pathrev=48">old</a> and a <a href="http://globs.svn.sourceforge.net/viewvc/globs/benchmarks/trunk/Fake/globs_info.json?view=markup&#038;pathrev=49">new</a> file you can notice how simple it was the conversion, I&#8217;ve only lost the ability to comment a line. <img src='http://encelo.netsons.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </li>
<li><em>importing numpy instead of numerix in matplotlib</em><br />
This is another deprecation related issue, <a href="http://matplotlib.sourceforge.net/">matplotlib</a> is now based upon <a href="http://numpy.scipy.org/">numpy</a>.</li>
<li><em>matplotlib canvas get refreshed instead of being destroyed and then recreated</em><br />
I don&#8217;t know why two years ago I was destroying and recreating the object instead of just calling the <tt>draw()</tt> method every time it had to be refreshed. <img src='http://encelo.netsons.org/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' /> </li>
<li><em>some more attributes and objects integrated in the GtkBuilder XML file</em><br />
I&#8217;ve integrated more attributes in the XML GUI file, like default size for secondary windows or <a href=http://www.pygtk.org/docs/pygtk/class-gtkpaned.html""><tt>Paned</tt></a> positions.<br />
Moreover, thanks to GtkBuilder, even some objects have been integrated, like <a href="http://www.pygtk.org/docs/pygtk/class-gtkadjustment.html"><tt>Adjustment</tt></a> or <a href="http://www.pygtk.org/docs/pygtk/class-gtktextbuffer.html"><tt>TextBuffer</tt></a>.<br />
Actually also <a href="http://www.pygtk.org/docs/pygtk/class-gtktreemodel.html"><tt>TreeModel</tt></a> objects should be configurable inside Glade and integrated inside the XML, but I didn&#8217;t manage to make them work. <img src='http://encelo.netsons.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </li>
</ul>
<p>Other remarkable changes in the field of Python3 future support and deprecated features removal were:</p>
<ul>
<li><em>all the print statements converted to functions</em><br />
Well, we all know the content of <a href="http://www.python.org/dev/peps/pep-3105/">PEP 3105</a>&#8230; <img src='http://encelo.netsons.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </li>
<li><em>using hashlib.md5 instead of md5</em><br />
The <tt><a href="http://docs.python.org/library/md5.html">md5</a></tt> module has been deprecated in favour of the <tt><a href="http://docs.python.org/library/hashlib.html">hashlib</a></tt> one</li>
<li><em>using &#8220;key in dict&#8221; instead of dict.has_key()</em><br />
The <tt>has_key()</tt> method no longer exists in Python 3</li>
<li><em>using subprocess.Popen instead of os.popen()</em><br />
<tt><a href=http://docs.python.org/library/os.html"">os</a>.popen()</tt> have been deprecated in favour of the <tt><a href="http://docs.python.org/library/subprocess.html">subprocess</a></tt> module</li>
<li><em>using urllib2.urlopen() instead of urllib.urlopen()</em><br />
Another deprecation suggested substitution, from <tt><a href="http://docs.python.org/library/urllib.html">urllib.urlopen()</a></tt> to <tt><a href="http://docs.python.org/library/urllib2.html">urllib2.urlopen()</a></tt></li>
<li><em>removed &#8220;copyright&#8221; argument and added &#8220;classifiers&#8221; in setup.py</em><br />
The <tt><a href="http://docs.python.org/distutils/setupscript.html#additional-meta-data">distutils.core.setup()</a></tt> function loses the &#8220;copyright&#8221; argument but gains &#8220;classifiers&#8221;. <img src='http://encelo.netsons.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </li>
<li><em>dropped support for pysqlite2 and old webbrowser module</em><br />
Now that the minimum requirement is Python 2.6, there is no need for <a href="http://oss.itsystementwicklung.de/trac/pysqlite">pysqlite2</a> or old <a href="http://www.python.org/doc/2.4/lib/module-webbrowser.html">webbrowser</a> module support</li>
<li>I have also removed the deprecated <tt>Options</tt> class in some SCons scripts.</li>
</ul>
<p>I&#8217;m not sure I will have some time in the future to continue developing, but this was a nice &#8220;reboot&#8221; and I also have some new ideas in my to-do list. <img src='http://encelo.netsons.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://encelo.netsons.org/blog/2009/10/05/gl-o-b-s-two-years-after/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Yet another toon shader</title>
		<link>http://encelo.netsons.org/blog/2009/04/26/yet-another-toon-shader/</link>
		<comments>http://encelo.netsons.org/blog/2009/04/26/yet-another-toon-shader/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 20:33:42 +0000</pubDate>
		<dc:creator>encelo</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Real-time Graphics]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[GLSL]]></category>
		<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[post-processing]]></category>
		<category><![CDATA[shaders]]></category>

		<guid isPermaLink="false">http://encelo.netsons.org/blog/?p=241</guid>
		<description><![CDATA[Maybe is true, as I wrote in the README file, that I coded this demo because I felt like the only one who hasn&#8217;t yet implemented a toon shader. 
Actually this is not the only reason, I came with the inspiration when I was presenting the first part of my updated Modern GPUs slides at [...]]]></description>
			<content:encoded><![CDATA[<p>Maybe is true, as I wrote in the README file, that I coded this demo because I felt like the only one who hasn&#8217;t yet implemented a toon shader. <img src='http://encelo.netsons.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Actually this is not the only reason, I came with the inspiration when I was presenting the first part of my updated <a href="http://encelo.netsons.org/_download/le_moderne_gpu.pdf">Modern GPUs</a> slides at the university, this time the event was organized by some students and advertised with leaflets. <img src='http://encelo.netsons.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
So, for the second part that will be held next Wednesday, I&#8217;m planning to integrate the explanations about the internals of this demo.</p>
<div id="attachment_251" class="wp-caption aligncenter" style="width: 490px"><img src="http://encelo.netsons.org/blog/wp-content/uploads/2009/04/toon_strip.png" alt="From untextured to textured with outlines" title="toon_strip" width="480" height="120" class="size-full wp-image-251" /><p class="wp-caption-text">From untextured to textured with outlines</p></div>
<p>It was easy and fast to have a basic toon shader working, thanks to the Lighthouse 3D <a href="http://encelo.netsons.org/_download/gl3_parallax_dof.tar.gz">tutorial</a>.<br />
This version uses a cascade of <em>if-then-else</em> instead of a more usual 1D texture lookup but, judging from the tests I have run, it&#8217;s not a performance issue, at least on GeForce 8 and newer cards.</p>
<p>For the edge detecting I wanted to exploit the fragment shader capabilities, working in screen space with the <a href="http://en.wikipedia.org/wiki/Sobel_operator">sobel operator</a> and thus being independent from geometric complexity. </p>
<p>The only problem was about *what* to filter.</p>
<ol>
<li>The first test was straight, I filtered the rendered image, a grey version of the textured and lit MrFixit head, but the results were poor: edge detecting outlined toon lighting shades too.</li>
<li>In the second one I decided to filter the depth buffer, I could get rid of colour to grey conversion but, again, the results were not satisfactory: there were no outlines in the model, just a contour all around.<br />
Maybe it could have been corrected with a per-model clip planes tuning, but I gave up.</li>
<li>With the third test I filtered out the unilluminated color texture and the results were better. Unfortunately it relied on the presence of a texture and outlined too much details.</li>
<li>I think the fourth approach, as seen in this demo, is the best one.<br />
I used MRTs to save the eye-space normal buffer during the toon shader pass, then I filtered a grey version of it, outlining the contour plus some other geometric details.
</li>
</ol>
<p>A small note: saving an already grey converted buffer in the toon shader pass speeds up the demo a bit, but storing the normal in a single 8 bits component of the texture causes a loss of precision that leads to some visible artefacts.<br />
Using a floating point texture helps with the precision issue but makes the demo too slow.<br />
Maybe I should try using a single component texture or some kind of RGBA packing algorithm&#8230;</p>
<p>As usual you can have a look at <a href="http://www.youtube.com/watch?v=3k3o-W1UIKk">YouTube</a> or <a href="http://vimeo.com/4340872">Vimeo</a> videos and download the <a href="http://encelo.netsons.org/_download/glsl_toon.tar.gz">sources</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://encelo.netsons.org/blog/2009/04/26/yet-another-toon-shader/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting weights to vertex colors</title>
		<link>http://encelo.netsons.org/blog/2009/04/19/converting-weights-to-vertex-colors/</link>
		<comments>http://encelo.netsons.org/blog/2009/04/19/converting-weights-to-vertex-colors/#comments</comments>
		<pubDate>Sun, 19 Apr 2009 12:34:39 +0000</pubDate>
		<dc:creator>encelo</dc:creator>
				<category><![CDATA[3d Graphics]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Blender]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[snippets]]></category>

		<guid isPermaLink="false">http://encelo.netsons.org/blog/?p=206</guid>
		<description><![CDATA[If you have read my LinkedIn profile lately you should already know that, by now, some months have passed since I started my pre-graduation internship activity at Raylight (and since I signed my first NDA   ).
The real-time graphic R&#038;D work that I&#8217;m doing there for my thesis is enjoying and stimulating, but this [...]]]></description>
			<content:encoded><![CDATA[<p>If you have read my <a href="http://www.linkedin.com/in/encelo">LinkedIn profile</a> lately you should already know that, by now, some months have passed since I started my pre-graduation internship activity at <a href="http://www.raylightgames.com/">Raylight</a> (and since I signed my first <a href="http://en.wikipedia.org/wiki/Non-disclosure_agreement">NDA</a> <img src='http://encelo.netsons.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ).<br />
The real-time graphic R&#038;D work that I&#8217;m doing there for my thesis is enjoying and stimulating, but this is not the topic of the post&#8230;</p>
<p><a href="http://www.raylightgames.com"><img src="http://encelo.netsons.org/blog/wp-content/uploads/2009/04/raylight_logo.jpg" alt="Raylight logo" title="Raylight logo" width="640" height="160" class="alignnone size-full wp-image-210" /></a></p>
<p>Some days ago a 3d artist of the team, <a href="http://www.aardolino.com/">Alessandro</a>, asked me a script that would have helped him using Blender for one more task along the company asset creation pipeline, weight painting.<br />
He  needed a simple script to actually convert vertex weights to per-bone vertex colors layers, in order to bake them to per-bone UV maps and later import them inside 3d Studio Max.</p>
<table align="center">
<tr>
<td>
<div id="attachment_213" class="wp-caption alignnone" style="width: 160px"><a href="http://encelo.netsons.org/blog/wp-content/uploads/2009/04/weight.png"><img src="http://encelo.netsons.org/blog/wp-content/uploads/2009/04/weight-150x150.png" alt="Weight painting" title="Weight painting" width="150" height="150" class="size-thumbnail wp-image-213" /></a><p class="wp-caption-text">Weight painting</p></div>
</td>
<td>
<div id="attachment_214" class="wp-caption alignnone" style="width: 160px"><a href="http://encelo.netsons.org/blog/wp-content/uploads/2009/04/vcol.png"><img src="http://encelo.netsons.org/blog/wp-content/uploads/2009/04/vcol-150x150.png" alt="Vertex painting" title="Vertex painting" width="150" height="150" class="size-thumbnail wp-image-214" /></a><p class="wp-caption-text">Vertex painting</p></div>
</td>
</tr>
</table>
<p>At first I didn&#8217;t even know where to start, how to extract and match per-vertex weight data with per-face vertex color one, but my second try with it went as smoothly as honey.<br />
The core algorithm is, indeed, very simple:</p>
<pre class="brush: python;">
for f in faces:
  for i,v in enumerate(f):
      infs = me.getVertexInfluences(v.index)
      for vgroup, w in infs:
        me.activeColorLayer = vgroup
        col = f.col[i]
        col.r = col.g = col.b = int(255*w)
</pre>
<p>Well, he has not yet taken advantage of it nor I know if he will ever use it, nevertheless the script is working and I have <a href="/_download/weight_to_vcol.py.gz">shared it</a> on my site, as usual. <img src='http://encelo.netsons.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://encelo.netsons.org/blog/2009/04/19/converting-weights-to-vertex-colors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Habemus OpenGL 3.0!</title>
		<link>http://encelo.netsons.org/blog/2009/01/16/habemus-opengl-30/</link>
		<comments>http://encelo.netsons.org/blog/2009/01/16/habemus-opengl-30/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 18:47:30 +0000</pubDate>
		<dc:creator>encelo</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Real-time Graphics]]></category>
		<category><![CDATA[GLX]]></category>
		<category><![CDATA[Nvidia]]></category>
		<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[OpenGL3]]></category>
		<category><![CDATA[snippets]]></category>

		<guid isPermaLink="false">http://encelo.netsons.org/blog/?p=164</guid>
		<description><![CDATA[We have been waiting OpenGL 3.0 for ages, we were all very excited about the wonderful features ARB was promising, then, on the 11th of August 2008, the specs were released&#8230;
I, like everyone else, was really disappointed, the Architecture Review Board was not only really late on schedule but it didn&#8217;t keep its word about [...]]]></description>
			<content:encoded><![CDATA[<p>We have been waiting OpenGL 3.0 for ages, we were all very excited about the wonderful features ARB was promising, then, on the 11th of August 2008, the <a href="http://opengl.org/documentation/specs/">specs</a> were released&#8230;<br />
I, like everyone else, was really disappointed, the <a href="http://www.opengl.org/about/arb/">Architecture Review Board</a> was not only really late on schedule but it didn&#8217;t keep its word about many key features that should have been introduced with this release.<br />
Nevertheless I&#8217;m still confident in the future, when older API functions will be <em>removed</em> and not simply, as in the current version, tagged as deprecated.</p>
<p><img src="http://encelo.netsons.org/blog/wp-content/uploads/2009/01/opengl-3-logo.jpg" alt="OpenGL3 Logo" title="OpenGL3 Logo" width="400" height="118" class="alignnone size-full wp-image-172" /></p>
<p>Now, after the long but needed introduction, let&#8217;s talk about things that matter: today the <a href="http://www.archlinux.org">ArchLinux</a> team moved the new stable 180.22 driver release from the <tt>[testing]</tt> to the <tt>[extra]</tt> repository.<br />
Well, apart from the equally important <a href="http://en.wikipedia.org/wiki/CUDA">CUDA 2.1</a> and <a href="http://en.wikipedia.org/wiki/VDPAU">VDPAU</a> support, this release has been bundled with OpenGL 3 and GLSL 1.30 support, so have a look at how to create an OpenGL 3.0 context.</p>
<p>First of all, it seems like there&#8217;s no other way to open the new context without getting your hands dirty, that is talking directly with GLX.<br />
What follows is a snippet to create an OpenGL 3.0 context integrated in SDL 1.2, which still doesn&#8217;t support it natively.</p>
<p>First of all you need some new defines.</p>
<pre class="brush: cpp;">
#define GLX_CONTEXT_DEBUG_BIT_ARB                         0x00000001
#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB   0x00000002
#define GLX_CONTEXT_MAJOR_VERSION_ARB                  0x2091
#define GLX_CONTEXT_MINOR_VERSION_ARB                   0x2092
#define GLX_CONTEXT_FLAGS_ARB                                0x2094
</pre>
<p>You need also to retrieve the address of the following new GLX function.</p>
<pre class="brush: cpp;">
typedef GLXContext ( * PFNGLXCREATECONTEXTATTRIBSARBPROC)
	(Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list);
PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB =
	(PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress((GLubyte*)&quot;glXCreateContextAttribsARB&quot;);
</pre>
<p>Then you have to define a bunch of GLX related variables.</p>
<pre class="brush: cpp;">
Display *dpy;
GLXDrawable draw, read;
GLXContext ctx, ctx3;
GLXFBConfig *cfg;
int nelements;
int attribs[]= {
	GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
	GLX_CONTEXT_MINOR_VERSION_ARB, 0,
	GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
	0
};
</pre>
<p>At last, after having called <tt>SDL_SetVideoMode()</tt>, create a new context, make it current and destroy the old one.</p>
<pre class="brush: cpp;">
ctx = glXGetCurrentContext();
dpy = glXGetCurrentDisplay();
draw = glXGetCurrentDrawable();
read = glXGetCurrentReadDrawable();
cfg = glXGetFBConfigs(dpy, 0, &amp;nelements);
ctx3 = glXCreateContextAttribsARB(dpy, *cfg, 0, 1, attribs);
glXMakeContextCurrent(dpy, draw, read, ctx3);
glXDestroyContext(dpy, ctx);
</pre>
<p>Don&#8217;t forget to put some querying code, just to be sure the whole process worked. <img src='http://encelo.netsons.org/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<pre class="brush: cpp;">
const GLubyte* string;

string = glGetString(GL_VENDOR);
printf(&quot;Vendor: %s\n&quot;, string);
string = glGetString(GL_RENDERER);
printf(&quot;Renderer: %s\n&quot;, string);
string = glGetString(GL_VERSION);
printf(&quot;OpenGL Version: %s\n&quot;, string);
string = glGetString(GL_SHADING_LANGUAGE_VERSION);
printf(&quot;GLSL Version: %s\n\n&quot;, string);
</pre>
<p>On my workstation I get this:<br />
<tt>Vendor: NVIDIA Corporation<br />
Renderer: GeForce 8600 GT/PCI/SSE2<br />
OpenGL Version: 3.0 NVIDIA 180.22<br />
GLSL Version: 1.30 NVIDIA via Cg compiler</tt></p>
<p>If you want to retrieve also the extension list, a new function can help you simplify the process.</p>
<pre class="brush: cpp;">
typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index);
PFNGLGETSTRINGIPROC glGetStringi = (PFNGLGETSTRINGIPROC)glXGetProcAddress((GLubyte*)&quot;glGetStringi&quot;);
</pre>
<p>You can then use it like this:</p>
<pre class="brush: cpp;">
GLint numExtensions = 0;
glGetIntegerv(GL_NUM_EXTENSIONS, &amp;numExtensions);

printf(&quot;Extension list: \n&quot;);
for (int i = 0; i &lt; numExtensions; ++i)
{
	printf(&quot;%s &quot;, glGetStringi(GL_EXTENSIONS, i));
}
printf(&quot;\n&quot;);
</pre>
<p>This new OpenGL version seems to perform just like the old one at the moment, drivers do not honour the <tt>GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB</tt> attribute, this means everything is still in place, backward compatible and unoptimized. <img src='http://encelo.netsons.org/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://encelo.netsons.org/blog/2009/01/16/habemus-opengl-30/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Composing renders in a strip</title>
		<link>http://encelo.netsons.org/blog/2009/01/06/composing-renders-in-a-strip/</link>
		<comments>http://encelo.netsons.org/blog/2009/01/06/composing-renders-in-a-strip/#comments</comments>
		<pubDate>Tue, 06 Jan 2009 03:58:43 +0000</pubDate>
		<dc:creator>encelo</dc:creator>
				<category><![CDATA[3d Graphics]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Blender]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://encelo.netsons.org/blog/?p=159</guid>
		<description><![CDATA[First of all happy new year to everyone, then let&#8217;s talk about this post topic&#8230;  
During these days I was relaxing and practicing subdivision modeling, after a long time away from Blender I was back to the dream of creating a convincing human head model, but my programming side win the day. 
While I [...]]]></description>
			<content:encoded><![CDATA[<p>First of all happy new year to everyone, then let&#8217;s talk about this post topic&#8230; <img src='http://encelo.netsons.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>During these days I was relaxing and practicing subdivision modeling, after a long time away from Blender I was back to the dream of creating a convincing human head model, but my programming side win the day. <img src='http://encelo.netsons.org/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /><br />
While I was studying in detail some face key parts topology from <a hrefl="http://www.subdivisionmodeling.com/forums/showthread.php?t=2806">here</a>, I noticed the <a href="http://en.wikipedia.org/wiki/Picture-in-picture">PiP</a>-like composed images attached to the first post&#8230;</p>
<div id="attachment_136" class="wp-caption alignnone" style="width: 310px"><a href="http://encelo.netsons.org/blog/wp-content/uploads/2009/01/strip_3dview.png"><img src="http://encelo.netsons.org/blog/wp-content/uploads/2009/01/strip_3dview-300x235.png" alt="Showing camera keyframes" title="strip_3dview" width="300" height="235" class="size-medium wp-image-136" /></a><p class="wp-caption-text">Showing camera keyframes</p></div>
<p>Last night I was thinking of a way to automates the process and today it becomes reality in the form of a Blender Python script: it is capable of producing an image which is composed of multiple rendered frames, think of a daily comic strip and you understand the name <img src='http://encelo.netsons.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<p>The user can select which frames to render specifying a string similar to the following one: &#8220;<em>1-3, 5, 7, 9-11</em>&#8220;.<br />
Moreover it is possible, of course, to choose the size of a single frame and the composed image table dimensions, i.e. how many rows and columns it should have.<br />
Have a look to how well my topology study renders fit the script purpose. <img src='http://encelo.netsons.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<div id="attachment_137" class="wp-caption alignnone" style="width: 310px"><a href="http://encelo.netsons.org/blog/wp-content/uploads/2009/01/strip_imgeditor.png"><img src="http://encelo.netsons.org/blog/wp-content/uploads/2009/01/strip_imgeditor-300x235.png" alt="The resulting composed image" title="strip_imgeditor" width="300" height="235" class="size-medium wp-image-137" /></a><p class="wp-caption-text">The resulting composed image</p></div>
<p>This second script is a bit more complex than <a href="/blog/2008/10/18/automatic-parallax-map-generation-with-blender/">my first one</a>, making use of the <em>Registry</em> module to load and save options and the <em>Draw.PupBlock()</em> method to display a bigger GUI.</p>
<p>Of course it is released under the GNU GPL License and available online, download it from <a href="http://encelo.netsons.org/_download/strip_render.py.gz">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://encelo.netsons.org/blog/2009/01/06/composing-renders-in-a-strip/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Blurring the parallax</title>
		<link>http://encelo.netsons.org/blog/2008/11/10/blurring-the-parallax/</link>
		<comments>http://encelo.netsons.org/blog/2008/11/10/blurring-the-parallax/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 22:26:14 +0000</pubDate>
		<dc:creator>encelo</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Real-time Graphics]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[GLSL]]></category>
		<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[post-processing]]></category>
		<category><![CDATA[shaders]]></category>

		<guid isPermaLink="false">http://encelo.netsons.org/blog/?p=99</guid>
		<description><![CDATA[Today I have published the first demo making use of my new C++ class library, I designed it to be very easily ported to a strict GL3 profile or to ES 2.0.
As a matter of fact, it doesn&#8217;t make use of fixed pipeline or deprecated functions at all:

No immediate mode, only VBOs
No use of OpenGL [...]]]></description>
			<content:encoded><![CDATA[<p>Today I have published the first demo making use of my new C++ class library, I designed it to be very easily ported to a strict GL3 profile or to ES 2.0.</p>
<div id="attachment_101" class="wp-caption alignnone" style="width: 310px"><a href="http://encelo.netsons.org/blog/wp-content/uploads/2008/11/plain_to_dof_strip.jpg"><img src="http://encelo.netsons.org/blog/wp-content/uploads/2008/11/plain_to_dof_strip-300x75.jpg" alt="From plain rendering to depth of field" title="From plain rendering to depth of field" width="300" height="75" class="size-medium wp-image-101" /></a><p class="wp-caption-text">From plain rendering to depth of field</p></div>
<p>As a matter of fact, it doesn&#8217;t make use of fixed pipeline or deprecated functions at all:</p>
<ul>
<li>No immediate mode, only VBOs</li>
<li>No use of OpenGL matrix stacks, I have my classes handling transformations and passing matrices to shaders directly</li>
<li>No OpenGL lighting, only per-fragment one</li>
<li>No quads or polygons, just triangles</li>
</ul>
<div id="attachment_116" class="wp-caption alignnone" style="width: 310px"><a href="http://encelo.netsons.org/blog/wp-content/uploads/2008/11/normal_vs_parallax.jpg"><img src="http://encelo.netsons.org/blog/wp-content/uploads/2008/11/normal_vs_parallax-300x75.jpg" alt="Normal versus parallax mapping" title="Normal vs parallax" width="300" height="75" class="size-medium wp-image-116" /></a><p class="wp-caption-text">Normal versus parallax mapping</p></div>
<p>I couldn&#8217;t release something only to show changes &#8220;under the hood&#8221;, I had to make something cool, so I decided to mix together parallax mapping (that, as you can see in the screenshot, is a lot more pronounced now) and depth of field, with the little addition of Stanford PLY mesh loading. <img src='http://encelo.netsons.org/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>Mr.Fixit model and maps (the character players protray in <a href="http://www.sauerbraten.org">Sauerbraten</a>) are courtesy of John Siar, thank you John. <img src='http://encelo.netsons.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>As usual, you can have a look to Vimeo videos (<a href="http://vimeo.com/2208683">640&#215;480</a>, <a href="http://vimeo.com/2208706">1280&#215;720</a>) and download the <a href="/_download/gl3_parallax_dof.tar.gz">sources</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://encelo.netsons.org/blog/2008/11/10/blurring-the-parallax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automatic parallax map generation with Blender</title>
		<link>http://encelo.netsons.org/blog/2008/10/18/automatic-parallax-map-generation-with-blender/</link>
		<comments>http://encelo.netsons.org/blog/2008/10/18/automatic-parallax-map-generation-with-blender/#comments</comments>
		<pubDate>Sat, 18 Oct 2008 16:24:47 +0000</pubDate>
		<dc:creator>encelo</dc:creator>
				<category><![CDATA[3d Graphics]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Blender]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://encelo.netsons.org/blog/?p=66</guid>
		<description><![CDATA[It has been a long time since I last wrote something here, during these months two new things happened that are worth to be mentioned: first of all I&#8217;m really close to graduation!
Well, actually I need to pass the last exam and spend a period of at least four months of internship, nothing is sure [...]]]></description>
			<content:encoded><![CDATA[<p>It has been a long time since I last wrote something here, during these months two new things happened that are worth to be mentioned: first of all I&#8217;m really close to graduation!<br />
Well, actually I need to pass the last exam and spend a period of at least four months of internship, nothing is sure now but I&#8217;m in close contact with a game developing company&#8230; <img src='http://encelo.netsons.org/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>The second thing is closely related to this post instead, a couple of months ago I began to convert, following M3xican&#8217;s advice, my OpenGL demos to object oriented C++.<br />
What I have now is really not much, nevertheless my class library can load a Stanford PLY model, it is ES 2.0 compliant (this means it will be easily converted to &#8220;Pure&#8221; OpenGL 3.x), and it can already display both parallax mapping and depth of field!</p>
<p>I&#8217;m not going to publish any screenshot by now because I think it&#8217;s not the time yet, what I&#8217;m showing you is a easy script, my first one, which I wrote yesterday night using the Blender Python API.<br />
What it does is really simple yet time-saving, you select a high-poly and a low-poly model, run the script from the Object->Scripts menu and watch Blender baking your normal and height map and then saving them.</p>
<p><a href="/blog/wp-content/uploads/2008/10/parallax_maps.png"><img src="/blog/wp-content/uploads/2008/10/parallax_maps-320x200.png" alt="Blender parallax maps" /></a></p>
<p>I have also set up an easy compositing nodes configuration to mix the two images in a single parallax map with height data encoded in the alpha channel.</p>
<p><a href="/blog/wp-content/uploads/2008/10/parallax_maps_nodes.png"><img src="/blog/wp-content/uploads/2008/10/parallax_maps_nodes-320x200.png" alt="Blender parallax maps nodes" /></a></p>
<p>You can download the script from <a href="/_download/parallax_maps.py.gz">here</a>.<br />
Everything is very simple (and funny!) with the astonishing power of Blender! <img src='http://encelo.netsons.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://encelo.netsons.org/blog/2008/10/18/automatic-parallax-map-generation-with-blender/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Let there be light!</title>
		<link>http://encelo.netsons.org/blog/2008/04/28/let-there-be-light/</link>
		<comments>http://encelo.netsons.org/blog/2008/04/28/let-there-be-light/#comments</comments>
		<pubDate>Mon, 28 Apr 2008 20:24:12 +0000</pubDate>
		<dc:creator>encelo</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Real-time Graphics]]></category>
		<category><![CDATA[deferred]]></category>
		<category><![CDATA[GLSL]]></category>
		<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[PyOpenGL]]></category>
		<category><![CDATA[shaders]]></category>

		<guid isPermaLink="false">http://encelo.netsons.org/blog/?p=62</guid>
		<description><![CDATA[I started exploring deferred shading rendering to display multiple light sources and ended writing a demo featuring eight different lighting techniques and a PyOpenGL class library.  

The whole story is more than a month old, just after releasing the first depth of field demo I began studying deferred shading, but I extended my purpose [...]]]></description>
			<content:encoded><![CDATA[<p>I started exploring deferred shading rendering to display multiple light sources and ended writing a demo featuring eight different lighting techniques and a PyOpenGL class library. <img src='http://encelo.netsons.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><img src="/blog/wp-content/uploads/2008/04/glsl_multilight.png" alt="glsl_multilight" /></p>
<p>The whole story is more than a month old, just after releasing the first depth of field demo I began studying deferred shading, but I extended my purpose to include other lighting methods, like single and multi-pass fixed-pipeline lighting, per-vertex and per-pixel single and multi-pass shader lighting and, of course, deferred one.</p>
<p>While writing the C code, I thought it was going to be fun to also port it to Python, this way I could have also have a look to the &#8220;new&#8221; (ArchLinux adopted it quite late <img src='http://encelo.netsons.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) ctypes PyOpenGL, aka PyOpenGL 3.</p>
<p>Unfortunately, many little but annoying issues delayed me until today:</p>
<ul>
<li>not setting explicitely <tt>glDepthFunc(GL_LEQUAL)</tt> (or, alternatively, not clearing the depth buffer at each pass) for multi-pass scene rendering made every pass to be discarded excepting the first one.</li>
<li>trying to make a buggy Python <tt>glDrawBuffers()</tt> wrapper work.<br />
Actually I had no luck with this and give up on MRTs support in PyOpenGL.</li>
<li>trying to figure out why VBOs didn&#8217;t work on PyOpenGL, I give up on this too. <img src='http://encelo.netsons.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
<li>using a uniform variable to index the <tt>gl_LightSource</tt> structure array, which prevented the shader from running on Shader Model 3.0 cards</li>
<li>exploring all the possibilities that could ever lead to &#8220;the brick room is very dark in fixed-pipeline mode&#8221; issue, only to discover today that this was a mere scaled normals problem.<br />
It was easily solved enabling <tt>GL_RESCALE_NORMAL</tt></li>
</ul>
<p>At last I made it, I have made a multi light demo that includes deferred lighting (although very rough and not optimized at all) and shows coherent lighting in all rendering modes.<br />
The PyOpenGL class library almost works, no MRTs and VBOs, but it is functional enough to sport a complete DoF2  and multilight (without deferred mode, which relies on MRTs, of course) demo conversions.</p>
<p>It&#8217;s not a news anymore that you can view it in action on my <a href="http://www.youtube.com/encelo">YouTube Channel</a>, or in a high definition <a href="http://www.vimeo.com/952114">720p version</a> hosted on my <a href="http://www.vimeo.com/encelo">Vimeo page</a>.</p>
<p>All&#8217;s well that ends well. <img src='http://encelo.netsons.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://encelo.netsons.org/blog/2008/04/28/let-there-be-light/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
