<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Encoding floats to RGBA &#8211; the final?</title>
	<atom:link href="http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/feed/" rel="self" type="application/rss+xml" />
	<link>http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/</link>
	<description>Random thoughts of a triangle pusher</description>
	<lastBuildDate>Sat, 19 May 2012 10:53:32 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: Alkis</title>
		<link>http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/#comment-173874</link>
		<dc:creator>Alkis</dc:creator>
		<pubDate>Thu, 09 Feb 2012 18:28:07 +0000</pubDate>
		<guid isPermaLink="false">http://aras-p.info/blog/?p=369#comment-173874</guid>
		<description>Great and very precise!
However, the .w component of the original float4 does not get decoded.</description>
		<content:encoded><![CDATA[<p>Great and very precise!<br />
However, the .w component of the original float4 does not get decoded.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marc</title>
		<link>http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/#comment-121601</link>
		<dc:creator>Marc</dc:creator>
		<pubDate>Fri, 19 Aug 2011 14:59:07 +0000</pubDate>
		<guid isPermaLink="false">http://aras-p.info/blog/?p=369#comment-121601</guid>
		<description>Aras,

This technique works beautifully.  Thank you for the post.  

I&#039;m encoding on the CPU for a target that doesn&#039;t support floating point textures.  The solution is dead on.

Regards,

Marc</description>
		<content:encoded><![CDATA[<p>Aras,</p>
<p>This technique works beautifully.  Thank you for the post.  </p>
<p>I&#8217;m encoding on the CPU for a target that doesn&#8217;t support floating point textures.  The solution is dead on.</p>
<p>Regards,</p>
<p>Marc</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aras Pranckevičius</title>
		<link>http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/#comment-33431</link>
		<dc:creator>Aras Pranckevičius</dc:creator>
		<pubDate>Fri, 11 Jun 2010 03:35:17 +0000</pubDate>
		<guid isPermaLink="false">http://aras-p.info/blog/?p=369#comment-33431</guid>
		<description>@stephen: this is HLSL/Cg code. And unlike C/C++ compilers, shader compilers are allowed to change divisions into multiplications by inverse (even if it&#039;s not exactly the same under floating point). So this actually compiles into multiplications by inverses already.</description>
		<content:encoded><![CDATA[<p>@stephen: this is HLSL/Cg code. And unlike C/C++ compilers, shader compilers are allowed to change divisions into multiplications by inverse (even if it&#8217;s not exactly the same under floating point). So this actually compiles into multiplications by inverses already.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stephen</title>
		<link>http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/#comment-33422</link>
		<dc:creator>stephen</dc:creator>
		<pubDate>Fri, 11 Jun 2010 00:00:23 +0000</pubDate>
		<guid isPermaLink="false">http://aras-p.info/blog/?p=369#comment-33422</guid>
		<description>would it be quicker and would you lose any precision if you precalculated the divisions as constants like 

const float x = 1.0/255.0;
const float y = 1/65025.0;
const float z = 1/16581375.0;


inline float4 EncodeFloatRGBA( float v ) {
  float4 enc = float4(1.0, 255.0, 65025.0, 16581375.0) * v;
  enc = frac(enc);
  enc -= enc.yzww * float4(x,x,x,0.0);
  return enc;
}
inline float DecodeFloatRGBA( float4 rgba ) {
  return dot( rgba, float4(1.0, x, y,z) );
}</description>
		<content:encoded><![CDATA[<p>would it be quicker and would you lose any precision if you precalculated the divisions as constants like </p>
<p>const float x = 1.0/255.0;<br />
const float y = 1/65025.0;<br />
const float z = 1/16581375.0;</p>
<p>inline float4 EncodeFloatRGBA( float v ) {<br />
  float4 enc = float4(1.0, 255.0, 65025.0, 16581375.0) * v;<br />
  enc = frac(enc);<br />
  enc -= enc.yzww * float4(x,x,x,0.0);<br />
  return enc;<br />
}<br />
inline float DecodeFloatRGBA( float4 rgba ) {<br />
  return dot( rgba, float4(1.0, x, y,z) );<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Real-Time Rendering &#187; Blog Archive &#187; Clearing the Queue</title>
		<link>http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/#comment-20919</link>
		<dc:creator>Real-Time Rendering &#187; Blog Archive &#187; Clearing the Queue</dc:creator>
		<pubDate>Thu, 17 Sep 2009 17:55:16 +0000</pubDate>
		<guid isPermaLink="false">http://aras-p.info/blog/?p=369#comment-20919</guid>
		<description>[...] is worthwhile for a developer making this decision. Aras&#8217; blog has other nice bits such as packing a float into RGBA and SSAO [...]</description>
		<content:encoded><![CDATA[<p>[...] is worthwhile for a developer making this decision. Aras&#8217; blog has other nice bits such as packing a float into RGBA and SSAO [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aras Pranckevičius</title>
		<link>http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/#comment-20918</link>
		<dc:creator>Aras Pranckevičius</dc:creator>
		<pubDate>Thu, 17 Sep 2009 17:47:42 +0000</pubDate>
		<guid isPermaLink="false">http://aras-p.info/blog/?p=369#comment-20918</guid>
		<description>@imbusy: whoops, yeah.</description>
		<content:encoded><![CDATA[<p>@imbusy: whoops, yeah.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: imbusy</title>
		<link>http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/#comment-20908</link>
		<dc:creator>imbusy</dc:creator>
		<pubDate>Thu, 17 Sep 2009 10:37:56 +0000</pubDate>
		<guid isPermaLink="false">http://aras-p.info/blog/?p=369#comment-20908</guid>
		<description>255^0 = 1
255^1 = 255
255^2 = 65025
255^3 = 16581375
Shouldn&#039;t the last component be 16581375 instead of 160581375?</description>
		<content:encoded><![CDATA[<p>255^0 = 1<br />
255^1 = 255<br />
255^2 = 65025<br />
255^3 = 16581375<br />
Shouldn&#8217;t the last component be 16581375 instead of 160581375?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aras Pranckevičius</title>
		<link>http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/#comment-20211</link>
		<dc:creator>Aras Pranckevičius</dc:creator>
		<pubDate>Tue, 04 Aug 2009 09:59:21 +0000</pubDate>
		<guid isPermaLink="false">http://aras-p.info/blog/?p=369#comment-20211</guid>
		<description>@Pat: I&#039;ve experimented with spherical and spheremap based normal encodings. Here are my results so far: &lt;a href=&quot;http://aras-p.info/texts/CompactNormalStorage.html&quot; rel=&quot;nofollow&quot;&gt;article link&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>@Pat: I&#8217;ve experimented with spherical and spheremap based normal encodings. Here are my results so far: <a href="http://aras-p.info/texts/CompactNormalStorage.html" rel="nofollow">article link</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aras Pranckevičius</title>
		<link>http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/#comment-20183</link>
		<dc:creator>Aras Pranckevičius</dc:creator>
		<pubDate>Sun, 02 Aug 2009 14:59:55 +0000</pubDate>
		<guid isPermaLink="false">http://aras-p.info/blog/?p=369#comment-20183</guid>
		<description>@corysama: yeah, I&#039;ve tried your approach as well. It works when done on the CPU, but has small errors here and there when done on the GPU.</description>
		<content:encoded><![CDATA[<p>@corysama: yeah, I&#8217;ve tried your approach as well. It works when done on the CPU, but has small errors here and there when done on the GPU.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: goryh</title>
		<link>http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/#comment-20181</link>
		<dc:creator>goryh</dc:creator>
		<pubDate>Sun, 02 Aug 2009 14:21:01 +0000</pubDate>
		<guid isPermaLink="false">http://aras-p.info/blog/?p=369#comment-20181</guid>
		<description>That’s great! 
It&#039;s a perfect match for storing depth in texture for our depth pass. My previous approach was based on storing integral and fractional parts of log2 of depth (multiplied by 16) and future decoding with exp2. It required only 2 channels of texture and with perfectly precision restored original depth value, but takes 7 instructions for encoding and 3 for decoding. Your new approach takes only 3 and 2 instruction respectively with the same precision (I can’t find any differences in precision test). 
Thanks.</description>
		<content:encoded><![CDATA[<p>That’s great!<br />
It&#8217;s a perfect match for storing depth in texture for our depth pass. My previous approach was based on storing integral and fractional parts of log2 of depth (multiplied by 16) and future decoding with exp2. It required only 2 channels of texture and with perfectly precision restored original depth value, but takes 7 instructions for encoding and 3 for decoding. Your new approach takes only 3 and 2 instruction respectively with the same precision (I can’t find any differences in precision test).<br />
Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: corysama</title>
		<link>http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/#comment-20161</link>
		<dc:creator>corysama</dc:creator>
		<pubDate>Sat, 01 Aug 2009 06:36:10 +0000</pubDate>
		<guid isPermaLink="false">http://aras-p.info/blog/?p=369#comment-20161</guid>
		<description>I haven&#039;t tested this as thoroughly as you have been, but it still might help you out.  Check out my post in this thread:

http://www.gamedev.net/community/forums/topic.asp?topic_id=486847</description>
		<content:encoded><![CDATA[<p>I haven&#8217;t tested this as thoroughly as you have been, but it still might help you out.  Check out my post in this thread:</p>
<p><a href="http://www.gamedev.net/community/forums/topic.asp?topic_id=486847" rel="nofollow">http://www.gamedev.net/community/forums/topic.asp?topic_id=486847</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pat Wilson</title>
		<link>http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/#comment-20153</link>
		<dc:creator>Pat Wilson</dc:creator>
		<pubDate>Thu, 30 Jul 2009 19:09:51 +0000</pubDate>
		<guid isPermaLink="false">http://aras-p.info/blog/?p=369#comment-20153</guid>
		<description>@Aras: Yeah I am really a big fan of spherical normals. They take more operations, but the assumption that is floating around about view-space normals not having a -z is totally false, so you need to either store spherical normals, or you need to reserve a bit (somewhere) for +/- on the Z value you reconstruct via sqrt(1 - x * x + y * y).

I did some performance testing a while ago that seemed to indicate that sampling a texture for atan2() is better than actually performing atan2(), especially on older ATI cards, but my current implementation doesn&#039;t do this. I want to re-run the test first.</description>
		<content:encoded><![CDATA[<p>@Aras: Yeah I am really a big fan of spherical normals. They take more operations, but the assumption that is floating around about view-space normals not having a -z is totally false, so you need to either store spherical normals, or you need to reserve a bit (somewhere) for +/- on the Z value you reconstruct via sqrt(1 &#8211; x * x + y * y).</p>
<p>I did some performance testing a while ago that seemed to indicate that sampling a texture for atan2() is better than actually performing atan2(), especially on older ATI cards, but my current implementation doesn&#8217;t do this. I want to re-run the test first.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aras Pranckevičius</title>
		<link>http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/#comment-20152</link>
		<dc:creator>Aras Pranckevičius</dc:creator>
		<pubDate>Thu, 30 Jul 2009 18:55:31 +0000</pubDate>
		<guid isPermaLink="false">http://aras-p.info/blog/?p=369#comment-20152</guid>
		<description>@Pat: well, you are a step ahead on encoding normals in two channels :P

Figuring out a good encoding for normals is next step on my list. Is the spherical encoding the one you settled on?</description>
		<content:encoded><![CDATA[<p>@Pat: well, you are a step ahead on encoding normals in two channels :P</p>
<p>Figuring out a good encoding for normals is next step on my list. Is the spherical encoding the one you settled on?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pat Wilson</title>
		<link>http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/#comment-20151</link>
		<dc:creator>Pat Wilson</dc:creator>
		<pubDate>Thu, 30 Jul 2009 18:48:36 +0000</pubDate>
		<guid isPermaLink="false">http://aras-p.info/blog/?p=369#comment-20151</guid>
		<description>Aras, you have an uncanny ability to be working on the same things I am working on, with similar results. You were a step ahead of me on this one :)</description>
		<content:encoded><![CDATA[<p>Aras, you have an uncanny ability to be working on the same things I am working on, with similar results. You were a step ahead of me on this one :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aras Pranckevičius</title>
		<link>http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/#comment-20149</link>
		<dc:creator>Aras Pranckevičius</dc:creator>
		<pubDate>Thu, 30 Jul 2009 17:41:32 +0000</pubDate>
		<guid isPermaLink="false">http://aras-p.info/blog/?p=369#comment-20149</guid>
		<description>I don&#039;t think hardware does gamma correction, unless I tell it to. I&#039;m not setting sRGB states on the samplers or on the framebuffer writes.</description>
		<content:encoded><![CDATA[<p>I don&#8217;t think hardware does gamma correction, unless I tell it to. I&#8217;m not setting sRGB states on the samplers or on the framebuffer writes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: steve</title>
		<link>http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/#comment-20148</link>
		<dc:creator>steve</dc:creator>
		<pubDate>Thu, 30 Jul 2009 17:31:30 +0000</pubDate>
		<guid isPermaLink="false">http://aras-p.info/blog/?p=369#comment-20148</guid>
		<description>Maybe the problems you&#039;re having are related to gamma correction? 

The hardware is by default going to try to gamma correct the output of the fragment program, but you don&#039;t want that if you want to keep predictable levels of precision. Also, when you sample back out of the texture the reverse gamma correction is also applied, since it&#039;s assumed that artists designed the texture in gamma space. 

There&#039;s a good article in GPU Gems 3 about this that might help: http://http.developer.nvidia.com/GPUGems3/gpugems3_ch24.html . Obviously they&#039;re talking about lighting accuracy but maybe it&#039;s an issue in your case too.</description>
		<content:encoded><![CDATA[<p>Maybe the problems you&#8217;re having are related to gamma correction? </p>
<p>The hardware is by default going to try to gamma correct the output of the fragment program, but you don&#8217;t want that if you want to keep predictable levels of precision. Also, when you sample back out of the texture the reverse gamma correction is also applied, since it&#8217;s assumed that artists designed the texture in gamma space. </p>
<p>There&#8217;s a good article in GPU Gems 3 about this that might help: <a href="http://http.developer.nvidia.com/GPUGems3/gpugems3_ch24.html" rel="nofollow">http://http.developer.nvidia.com/GPUGems3/gpugems3_ch24.html</a> . Obviously they&#8217;re talking about lighting accuracy but maybe it&#8217;s an issue in your case too.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

