tag:blogger.com,1999:blog-7880177819181437000.post1054522608252746558..comments2017-08-08T01:34:21.003-07:00Comments on rgba32: Improved Normal-map DistributionsMark Leehttp://www.blogger.com/profile/17809545020783713176noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-7880177819181437000.post-53559265235503456412013-06-12T21:59:06.765-07:002013-06-12T21:59:06.765-07:00Hi Kaseigan
Thanks for the comment. I had read th...Hi Kaseigan<br /><br />Thanks for the comment. I had read that page before but hadn't played around with the test app - nice little app. Your implementation is spot on but the issue is that Aras is looking at encoding schemes for viewspace normals, whereas this method (and method #1 on that page) only concern themselves with normals which live strictly within a hemisphere. The common use case for this scheme would be encode tangent space normal maps. Viewspace normals are different in that they can and do go outside the hemisphere; the wider the FOV, the wider the range of normals you need to be able to encode. That would explain why you were seeing less error when you switched to an orthographic view, in which case viewspace normals would be constrained to a within a hemisphere again. The pdf link on that page in the description of Method #1 goes into details on why viewspace normals combined with perspective projection may go outside the hemisphere. Hope that helps.<br /><br />Mark Leehttps://www.blogger.com/profile/17809545020783713176noreply@blogger.comtag:blogger.com,1999:blog-7880177819181437000.post-6064312426971421912013-06-12T10:14:26.780-07:002013-06-12T10:14:26.780-07:00Hi,
using the very nice tool from http://aras-p.i...Hi,<br /><br />using the very nice tool from http://aras-p.info/texts/CompactNormalStorage.html ,<br />I (tried to) implement your method, but I ended up with wrong results, especially in "corners" (you'll see)<br /><br />you may try that by downloading this tool, and add a textfile in /data :<br /><br />//=================================================<br /><br />half4 encode (half3 n, float3 view)<br />{<br /> float3 src = n;<br /> float2 srcSq = src.xy*src.xy;<br /> <br /> float _4a = 4*(srcSq.x + srcSq.y);<br /> float b = src.z;<br /> float discriminant = (b*b) + _4a; // -4ac changed to +4a since c == -1<br /> <br /> //float t = (-b + sqrt(discriminant)) / (2.f * a); // /2a becomes /4a since we should mult. res by 0.5<br /> float t = (-b + sqrt(discriminant)) / _4a;<br /> float2 res = float2(src.xy) *t; // *0.5<br /> res += float2(0.5, 0.5);<br /> return half4 (res, 0.0, 0.0);<br />}<br /><br />half3 decode (half2 enc, float3 view)<br />{<br /> float2 src = enc;<br /> src = src - float2(0.5, 0.5);<br /> src *= float2 (2.0, 2.0);<br /> <br /> float2 tmp = src*src;<br /> tmp = float2(1.0, 1.0)-tmp;<br /> float3 res = normalize(float3(src, tmp.x*tmp.y));<br /> <br /> return res;<br />}<br /><br />//=================================================<br /><br />note, the error is way smaller with an orthographic view : replace line 366 in tester.Cpp by<br />D3DXMatrixOrthoLH ( &s_ProjMatrix, float(d3d::SCR_WIDTH)/150.0, float(d3d::SCR_HEIGHT)/150.0, 0.1f, 100.0f );<br /><br /><br />That's annoying because I really liked your idea :/Kaseigannoreply@blogger.comtag:blogger.com,1999:blog-7880177819181437000.post-46459026444658005322013-01-19T13:14:08.560-08:002013-01-19T13:14:08.560-08:00A question came up if the paraboloid normal repres...A question came up if the paraboloid normal representation combines easily with other normals, like partital derivative normals do. I would say, not as easily but combining normals isn't a lot of work regardless of format. One approach I've used in the past is to represent primary normals maps in paraboloid format and represent further detail maps with partial derivatives (it seems a fair tradeoff since horizontal normals aren't as critical for detail maps). This leads to the following code for combining them together:<br /><br /><br />float3 CombineParaboloidNormalWithPD(float2 pn, float2 pd)<br />{<br /> float nz = saturate(1 - pn.x * pn.x - pn.y * pn.y);<br /><br /> float3 combined;<br /> combined.xy = (pd * -nz) + pn;<br /> combined.z = nz;<br /><br /> return normalize(combined);<br />}<br />Mark Leehttps://www.blogger.com/profile/17809545020783713176noreply@blogger.com