Jump to content

  • Log In with Google      Sign In   
  • Create Account

Normal packing problem with spheremap transform


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 BuraCULa   Members   -  Reputation: 105

Like
0Likes
Like

Posted 03 April 2012 - 12:48 PM

Hi. I am trying to pack my view space normals into two float with spheremap transformation. Actually i can pack and unpack them well but, while packing specific vectors - (0,0,1) and (0,0,-1) - , the algorithm is trying to call normalize(0,0). So this is causing a infinite result. Is there any way to solve this without placing some if statements into packing and unpacking functions ? I am using functions from here.

Sponsor:

#2 jischneider   Members   -  Reputation: 252

Like
0Likes
Like

Posted 03 April 2012 - 01:24 PM

A year ago, I also have a problem with Crytek's method (don’t remember why).

Now I use a similar method that works well:

float4 CompressNormal(float3 inputNormal)
{
   float f = inputNormal.z * 2 + 1;
   float g = dot(inputNormal, inputNormal);
   float p = sqrt(g + f);
   return float4(inputNormal.xy / p * 0.5 + 0.5, 1, 1);		  
}

float3 SampleNormal(float2 uv, sampler2D textureSampler)
{
   float2 normalInformation = tex2Dlod(textureSampler, float4(uv, 0, 0)).xy;
   float3 N;
   N.xy = -normalInformation * normalInformation + normalInformation;
   N.z = -1;
   float f = dot(N, float3(1, 1, 0.25));
   float m = sqrt(f);
   N.xy = (normalInformation * 8 - 4) * m;
   N.z = -(1 - 8 * f);			
}

I don’t have the Crytek shaders source code in this computer but I think that the use a cool image processing method in the final version. Unfortunately I don’t have time to implement it but with a texture (used to transform the normals to another space) you can implemented easily. I think.

Project page: < XNA FINAL Engine >


#3 programci_84   Members   -  Reputation: 336

Like
0Likes
Like

Posted 03 April 2012 - 11:06 PM

Take a look at here.

hth.
-R
There's no "hard", and "the impossible" takes just a little time.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS