• Advertisement
Sign in to follow this  

CryEngine GBuffer Normal storing technique

This topic is 1655 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi!

 

I am creating an engine on XNA 4.0 that utilizes deferred shading technique. My GBuffer is 4 R8G8B8A8 textures for Albedo, Depth, Normals and Lights, where Normals were stored like R - N.x, G - N.y, B - N.z. I was dissatisfied with the quality of my specular highlights, especially when I saw how they look when normals are stored with 16 bit precision so I started searching for other techniques. Right now I settled on CryEngine2 technique of Spheremap Transforms that stores only N.x and N.y and reconstructs N.z. Here is the link to the PPt file:

http://www.crytek.com/sites/default/files/A_bit_more_deferred_-_CryEngine3.ppt

 

I did it just like the slide #13 suggests and everything looks awesome, though a little different from the original approach, but I am in doubt whether I did it correctly. The problem is, their formula of normals deconstruction has this part: "N.z = length2(G.xy)" and I don't know what length2 means. I simply used "length(G.xy)" there and gave the formula a float2 vector (G.xy), just like in the slide. Is that correct? I also tried "length (G.x - G.y)" and it gives a totally different result.

 

Would be grateful for any advise/link.

Thanks!

Share this post


Link to post
Share on other sites
Advertisement

You know the length has to be one. So solving for z it should be sqrt(1-x^2-y^2) where x is G.x and y is G.y. So in that case your N.z should N.z=sqrt(1-(G.x*G.x)-(G.y*G.y)).

Edited by BornToCode

Share this post


Link to post
Share on other sites

Ok the code in the article is either wrong or improperly explained. Firstly it seems to constantly compute imaginary square roots, which leads to errors, but when I solved it with abs() the ligts it produces are absolutely stupid.

The BornToCode's advise (sqrt(1-(G.x*G.x)-(G.y*G.y))) also led to wrong results. The author seems to have mistaken the Guerilla's approach to normal packing with CryTech's one.

Share this post


Link to post
Share on other sites

I ended up using normal packing technique from Crysis 3. Thankfully they explained it quite well in their presentation.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement