<?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>textures &#8211; Matthew Petroff</title>
	<atom:link href="https://mpetroff.net/tag/textures/feed/" rel="self" type="application/rss+xml" />
	<link>https://mpetroff.net</link>
	<description>mpetroff.net</description>
	<lastBuildDate>Wed, 30 Nov 2016 02:08:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>Bandwidth-efficient HDR WebGL Textures</title>
		<link>https://mpetroff.net/2015/11/bandwidth-efficient-hdr-webgl-textures/</link>
					<comments>https://mpetroff.net/2015/11/bandwidth-efficient-hdr-webgl-textures/#comments</comments>
		
		<dc:creator><![CDATA[Matthew Petroff]]></dc:creator>
		<pubDate>Sun, 15 Nov 2015 17:08:47 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[hdr]]></category>
		<category><![CDATA[high dynamic range]]></category>
		<category><![CDATA[textures]]></category>
		<category><![CDATA[WebGL]]></category>
		<guid isPermaLink="false">http://mpetroff.net/?p=2003</guid>

					<description><![CDATA[Storing high dynamic range (HDR) images is a solved problem in general, such as using the excellent OpenEXR format. When is comes to the web, however, there are two major problems. The first is that web browsers don&#8217;t support any &#8230; <a href="https://mpetroff.net/2015/11/bandwidth-efficient-hdr-webgl-textures/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
										<content:encoded><![CDATA[<p><span class="dropcap">S</span>toring high dynamic range (HDR) images is a solved problem in general, such as using the excellent <a href="http://www.openexr.com/">OpenEXR format</a>. When is comes to the web, however, there are two major problems. The first is that web browsers don&#8217;t support any of the standard HDR image formats, and the second is that HDR images tend to be rather large, which is a problem for conserving bandwidth and reducing load times. Although there are ways to load HDR textures into WebGL using pre-encoded textures and <a href="https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Using_Extensions">WebGL extensions</a>, this is very bandwidth-inefficient and not supported by all WebGL devices. Thus, the first problem has to be worked around by encoding the HDR image information into standard web images, e.g. JPEG and PNG. The earliest example of this that I can find is the pre-WebGL <a href="http://pfstools.sourceforge.net/hdrhtml.html">pfstools HDR HTML viewer</a>, which layers multiple JPEG images at different exposures and blends them with different opacity settings.<sup id="rf1-2003"><a href="https://mpetroff.net/2015/11/bandwidth-efficient-hdr-webgl-textures/#fn1-2003" title=" Rafa&#322; Mantiuk and Wolfgang Heidrich. &#8220;Visualizing high dynamic range images in a web browser&#8221;. In: &lt;i&gt;Journal of Graphics, GPU, and Game Tools&lt;/i&gt; 14.1 (2009), pp. 43–53. DOI: 10.1080/2151237X.2009.10129276. URL: &lt;a href=&quot;http://pfstools.sourceforge.net/papers/mantiuk09vhdri.pdf&quot;&gt;http://pfstools.sourceforge.net/papers/mantiuk09vhdri.pdf&lt;/a&gt;. " rel="footnote">1</a></sup> This method was good for its time, since before WebGL image processing calculations were difficult to perform in the browser. However, the method is bandwidth-inefficient as it requires downloading the same image at multiple exposures&mdash;five images in the example. This brings us to WebGL, where a method PNG-based method was developed by <a href="http://spidergl.org/example.php?id=13">SpiderGL</a> (and copied by <a href="http://threejs.org/examples/webgl_hdr.html">three.js</a>). Although the provided encoder is undocumented, it appears to be based on JPEG-HDR, which uses a tone-mapped base image combined with a subband image that encodes the ratio between the tone-mapped image and the original HDR image.<sup id="rf2-2003"><a href="https://mpetroff.net/2015/11/bandwidth-efficient-hdr-webgl-textures/#fn2-2003" title=" Greg Ward and Maryann Simmons. &#8220;JPEG-HDR: A backwards-compatible, high dynamic range extension to JPEG&#8221;. In: &lt;i&gt;ACM SIGGRAPH 2006 Courses&lt;/i&gt;. ACM, 2006, p. 3. DOI: 10.1145/1185657.1185685. URL: &lt;a href=&quot;http://www.anyhere.com/gward/papers/cic05.pdf&quot;&gt;http://www.anyhere.com/gward/papers/cic05.pdf&lt;/a&gt;. " rel="footnote">2</a></sup> The method encodes the tone-mapped image in the RGB channels of a PNG and the ratio in the alpha channel. This works well when lossless compression is desired but is bandwidth-inefficient for photographic textures.</p>
<p><span id="more-2003"></span></p>
<p>After fiddling around with encoding <a href="https://en.wikipedia.org/wiki/RGBE_image_format">RGBE</a> as a JPEG and PNG and porting the SpiderGL technique to two separate JPEG images instead of a single PNG image, I stumbled upon a paper describing a better method (which happens to be written by the same person who created the SpiderGL HDR example). The &#8220;BoostHDR&#8221; technique described in the paper segments the image based on luminance, creating a compression-driven map (CDM), and tone maps the image with different parameters in each segment.<sup id="rf3-2003"><a href="https://mpetroff.net/2015/11/bandwidth-efficient-hdr-webgl-textures/#fn3-2003" title=" Francesco Banterle and Roberto Scopigno. &lt;i&gt;BoostHDR: a novel backward-compatible method for HDR images&lt;/i&gt;. 2012. DOI: 10.1117/12.931504. URL: &lt;a href=&quot;http://vcg.isti.cnr.it/Publications/2012/BS12/spie_2012_compression_hdr.pdf&quot;&gt;http://vcg.isti.cnr.it/Publications/2012/BS12/spie_2012_compression_hdr.pdf&lt;/a&gt;. " rel="footnote">3</a></sup> With the spatial and tone map parameters contained in the CDM, the original HDR image can be recovered from the tone mapped image. The map is stored as a PNG, and the tone mapped image is stored as a JPEG. See the paper for details and figures. I implemented the paper&#8217;s encoding scheme in Python, although I left out some of the filtering steps to reduce the script&#8217;s external dependencies since the filtering didn&#8217;t help much. To display the HDR image in WebGL, both the tone mapped image and CDM image are first loaded using JavaScript, and the CDM is then loaded into the tone mapped image&#8217;s alpha channel using the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API">Canvas API</a>. This RGBA texture is then loaded into WebGL, where a fragment shader function is used to recover the HDR image. As one would expect from a photograph encoded as a JPEG versus a PNG, this technique results in files sizes a few times smaller than the SpiderGL method. For lack of a better name, I&#8217;m calling this technique &#8220;WebHDR.&#8221;</p>
<p>A demo can be viewed <a href="//mpetroff.net/files/webhdr/">here</a>. Both the encoder and demo viewer are available on <a href="https://github.com/mpetroff/webhdr">GitHub</a> and have been released into the public domain.</p>
<hr class="footnotes"><ol class="footnotes" style="list-style-type:decimal"><li id="fn1-2003"><p > Rafa&#322; Mantiuk and Wolfgang Heidrich. &#8220;Visualizing high dynamic range images in a web browser&#8221;. In: <i>Journal of Graphics, GPU, and Game Tools</i> 14.1 (2009), pp. 43–53. DOI: 10.1080/2151237X.2009.10129276. URL: <a href="http://pfstools.sourceforge.net/papers/mantiuk09vhdri.pdf">http://pfstools.sourceforge.net/papers/mantiuk09vhdri.pdf</a>. &nbsp;<a href="https://mpetroff.net/2015/11/bandwidth-efficient-hdr-webgl-textures/#rf1-2003" class="backlink" title="Return to footnote 1.">&#8617;</a></p></li><li id="fn2-2003"><p > Greg Ward and Maryann Simmons. &#8220;JPEG-HDR: A backwards-compatible, high dynamic range extension to JPEG&#8221;. In: <i>ACM SIGGRAPH 2006 Courses</i>. ACM, 2006, p. 3. DOI: 10.1145/1185657.1185685. URL: <a href="http://www.anyhere.com/gward/papers/cic05.pdf">http://www.anyhere.com/gward/papers/cic05.pdf</a>. &nbsp;<a href="https://mpetroff.net/2015/11/bandwidth-efficient-hdr-webgl-textures/#rf2-2003" class="backlink" title="Return to footnote 2.">&#8617;</a></p></li><li id="fn3-2003"><p > Francesco Banterle and Roberto Scopigno. <i>BoostHDR: a novel backward-compatible method for HDR images</i>. 2012. DOI: 10.1117/12.931504. URL: <a href="http://vcg.isti.cnr.it/Publications/2012/BS12/spie_2012_compression_hdr.pdf">http://vcg.isti.cnr.it/Publications/2012/BS12/spie_2012_compression_hdr.pdf</a>. &nbsp;<a href="https://mpetroff.net/2015/11/bandwidth-efficient-hdr-webgl-textures/#rf3-2003" class="backlink" title="Return to footnote 3.">&#8617;</a></p></li></ol>]]></content:encoded>
					
					<wfw:commentRss>https://mpetroff.net/2015/11/bandwidth-efficient-hdr-webgl-textures/feed/</wfw:commentRss>
			<slash:comments>12</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Content Delivery Network via Amazon Web Services: CloudFront: cdn0.mpetroff.net
Minified using Disk

Served from: mpetroff.net @ 2026-03-31 01:33:14 by W3 Total Cache
-->