tag:blogger.com,1999:blog-6950833531562942289.post7514619179468403168..comments2024-03-25T03:36:48.099-07:00Comments on C0DE517E: Notes on G-Buffer normal encodingsDEADC0DEhttp://www.blogger.com/profile/01477408942876127202noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-6950833531562942289.post-48789156657311059892019-11-02T17:31:41.618-07:002019-11-02T17:31:41.618-07:00I can't remember anymore the details of my imp...I can't remember anymore the details of my implementation, as it was a while ago (Call of Duty - Black Ops 3) and I tried a ton of different things. I am sure I managed to tweak the view-space projection so that it was shippable, but in the end the world-space with multiple encodings one was the one that shipped.<br /><br />FWIW I think thought that I ended up using only 2 bits. Not 100% sure though, I think it was 2 bits and carefully made sure the encodings on the different tangent frames did not overlap too much. Some overlap is needed of course otherwise decal blending risks to "slam" on the boundary of the permitted space, but especially when selecting the encoding space using the geometric normal (and not the normal-mapped one) you don't need too much slack.<br /><br />In theory you need each space to cover only a hemisphere plus the angular extent that the quadrant of that tangent space covers, so you can ensure that in the worst case, when discretizing the geometric normal to the chosen tangent space, you still have space around it to encode the full hemisphere around the original surface.DEADC0DEhttps://www.blogger.com/profile/01477408942876127202noreply@blogger.comtag:blogger.com,1999:blog-6950833531562942289.post-50245090953623407362019-11-02T04:34:50.728-07:002019-11-02T04:34:50.728-07:00Just gonna add some notes here incase anyone else ...Just gonna add some notes here incase anyone else is trying this.<br />I have implemented this, works pretty well using 10, 10 for UV and 3 bits for the space.<br />It appears to lose about as much data as encoding with RGB10.<br /><br />Implemented using 8 spaces (3 bits) to work out the encoding space.<br />int coordSpace = (int)dot(saturate(IN.vertex.normal > 0), float3(1, 2, 4));<br /><br />I am using the lamber azimuthal equal area projection as described in this post.<br /><br />I have however found that using the decoded normal for a reflected vector becomes quite lossy with noticable artifacts on shiny surfaces.<br /><br />To fixed this i tried adding a blue noise jitter post decode, but the artifacts were still clearly visible.<br /><br />I tried adding a blue noise jitter to the UV component before it gets quantized instead. <br /><br />Since i use TAA this worked really well, no artifacts noticable (other than the noise of course)<br /><br /><br />Bluenoise source - http://momentsingraphics.de/BlueNoise.htmlAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-6950833531562942289.post-28397292329140360912015-02-02T22:36:05.555-08:002015-02-02T22:36:05.555-08:00Sebastien: Thanks for reading this.
I suspect usi...Sebastien: Thanks for reading this.<br /><br />I suspect using the geometric normal for the basis selection would yield the best results (at least, I think that's the case), dunno if you're doing that or using the base-layer normalmapped normal.<br /><br />Also I think you can get a bit more precision if you encode the normal in a way that bounds the normals representable in a given basis selection.<br /><br />The basis choice will span a given solid angle, and you don't need to encode more than an hemisphere+that solid angle. I don't think that normals facing outside the surface tangent hemisphere make much sense...<br /><br />But if you do so one has to be careful to exactly clamp normals to the surface tangent hemisphere (I guess for regular normalmapping and linear blends that's always the case, but things can go bad with other procedural modifications) otherwise there could be seams due to the fact that some points have more "wiggle" room than others.<br /><br />I wonder if you guys do restring the normals in such way to gain precision or just use stuff like lambert equal area on the full normal sphere.DEADC0DEhttps://www.blogger.com/profile/01477408942876127202noreply@blogger.comtag:blogger.com,1999:blog-6950833531562942289.post-79522990366576763792015-02-02T05:51:04.703-08:002015-02-02T05:51:04.703-08:00>"We can just read which projection was us...>"We can just read which projection was used and project the decal normals in the same space,"<br /><br />yes you get it. In practice this mean you decal can't modify your normal more than the angle authorized by your basis. In our case we use a cube, mean normal can't deviate more than 45° from current cube face axis but in practice it looks ok.Sébastien Lagardehttps://www.blogger.com/profile/11170507314218400784noreply@blogger.com