• Create Account

### #Actualjischneider

Posted 03 April 2012 - 01:26 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.

### #4jischneider

Posted 03 April 2012 - 01:26 PM

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

Now I use a similar method that work 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.

### #3jischneider

Posted 03 April 2012 - 01:26 PM

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

Now I use a similar method that work 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.

### #2jischneider

Posted 03 April 2012 - 01:25 PM

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

Now I use a similar method that work 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.

### #1jischneider

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 work 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.

PARTNERS