• Create Account

#Actuallipsryme

Posted 11 September 2012 - 11:42 AM

I've been trying to correctly encode my view-space normals for a while now but it's just not working.
I tried every algorithm in here (http://aras-p.info/t...rage.html#intro) but every time I get wrong normals.
Well except the basic one.
half4 encode (half3 n, float3 view)
{
return half4(n.xyz*0.5+0.5,0);
}
half3 decode (half4 enc, float3 view)
{
return enc.xyz*2-1;
}


This works perfectly but my specular keeps jumping around. I guess that would be a precision issue because of the 8bit target.
Well so then I try the next easiest thing which is storing X&Y and reconstructing Z like this:
half4 encode (half3 n, float3 view)
{
return half4(n.xy*0.5+0.5,0,0);
}
half3 decode (half2 enc, float3 view)
{
half3 n;
n.xy = enc*2-1;
n.z = sqrt(1-dot(n.xy, n.xy));
return n;
}


And it's error all over again. The lighting changes with my view direction. (where I look at)
I tried this with both an R8G8B8A8 and R16G16 format but no change.
How is it that every encoding method I try fails.
Any idea what I'm fundamentally doing wrong ?

Normals are calculated this way:
float4x4 WorldView = mul(World, View);

// Output view space normals
output.Normal.xyz = mul(input.Normal, (float3x3)WorldView);


#4lipsryme

Posted 11 September 2012 - 11:42 AM

I've been trying to correctly encode my view-space normals for a while now but it's just not working.
I tried every algorithm in here (http://aras-p.info/t...rage.html#intro) but every time I get wrong normals.
Well except the basic one.
half4 encode (half3 n, float3 view)
{
return half4(n.xyz*0.5+0.5,0);
}
half3 decode (half4 enc, float3 view)
{
return enc.xyz*2-1;
}


This works perfectly but my specular keeps jumping around. I guess that would be a precision issue because of the 8bit target.
Well so then I try the next easiest thing which is storing X&Y and reconstructing Z like this:
half4 encode (half3 n, float3 view)
{
return half4(n.xy*0.5+0.5,0,0);
}
half3 decode (half2 enc, float3 view)
{
half3 n;
n.xy = enc*2-1;
n.z = sqrt(1-dot(n.xy, n.xy));
return n;
}


And it's error all over again. The lighting changes with my view direction. (where I look at)
I tried this with both an R8G8B8A8 and R16G16 format but no change.
How is it that every encoding method I try fails.
Any idea what I'm fundamentally doing wrong ?

Normals are calculated this way:
float4x4 WorldView = mul(World, View);
// Output view space normals
output.Normal.xyz = mul(input.Normal, (float3x3)WorldView);


#3lipsryme

Posted 11 September 2012 - 11:39 AM

I've been trying to correctly encode my view-space normals for a while now but it's just not working.
I tried every algorithm in here (http://aras-p.info/texts/CompactNormalStorage.html#intro) but every time I get wrong normals.
Well except the basic one.
half4 encode (half3 n, float3 view)
{
return half4(n.xyz*0.5+0.5,0);
}
half3 decode (half4 enc, float3 view)
{
return enc.xyz*2-1;
}


This works perfectly but my specular keeps jumping around. I guess that would be a precision issue because of the 8bit target.
Well so then I try the next easiest thing which is storing X&Y and reconstructing Z like this:
half4 encode (half3 n, float3 view)
{
return half4(n.xy*0.5+0.5,0,0);
}
half3 decode (half2 enc, float3 view)
{
half3 n;
n.xy = enc*2-1;
n.z = sqrt(1-dot(n.xy, n.xy));
return n;
}


And it's error all over again. The lighting changes with my view direction. (where I look at)
I tried this with both an R8G8B8A8 and R16G16 format but no change.
How is it that every encoding method I try fails.
Any idea what I'm fundamentally doing wrong ?

Normals are calculated this way:
// Output view space normals
output.Normal.xyz = mul(input.Normal, (float3x3)WorldViewIT); // WorldViewInverseTranspose


#2lipsryme

Posted 11 September 2012 - 11:38 AM

I've been trying to correctly encode my view-space normals for a while now but it's just not working.
I tried every algorithm in here but every time I get wrong normals.
Well except the basic one.
half4 encode (half3 n, float3 view)
{
return half4(n.xyz*0.5+0.5,0);
}
half3 decode (half4 enc, float3 view)
{
return enc.xyz*2-1;
}


This works perfectly but my specular keeps jumping around. I guess that would be a precision issue because of the 8bit target.
Well so then I try the next easiest thing which is storing X&Y and reconstructing Z like this:
half4 encode (half3 n, float3 view)
{
return half4(n.xy*0.5+0.5,0,0);
}
half3 decode (half2 enc, float3 view)
{
half3 n;
n.xy = enc*2-1;
n.z = sqrt(1-dot(n.xy, n.xy));
return n;
}


And it's error all over again. The lighting changes with my view direction. (where I look at)
I tried this with both an R8G8B8A8 and R16G16 format but no change.
How is it that every encoding method I try fails.
Any idea what I'm fundamentally doing wrong ?

Normals are calculated this way:
// Output view space normals
output.Normal.xyz = mul(input.Normal, (float3x3)WorldViewIT); // WorldViewInverseTranspose


#1lipsryme

Posted 11 September 2012 - 11:37 AM

I've been trying to correctly encode my view-space normals for a while now but it's just not working.
I tried every algorithm in here but every time I get wrong normals.
Well except the basic one.
half4 encode (half3 n, float3 view)
{
return half4(n.xyz*0.5+0.5,0);
}
half3 decode (half4 enc, float3 view)
{
return enc.xyz*2-1;
}


This works perfectly but my specular keeps jumping around. I guess that would be a precision issue because of the 8bit target.
Well so then I try the next easiest thing which is storing X&Y and reconstructing Z like this:
half4 encode (half3 n, float3 view)
{
return half4(n.xy*0.5+0.5,0,0);
}
half3 decode (half2 enc, float3 view)
{
half3 n;
n.xy = enc*2-1;
n.z = sqrt(1-dot(n.xy, n.xy));
return n;
}


And it's error all over again. The lighting changes with my view direction. (where I look at)
I tried this with both an R8G8B8A8 and R16G16 format but no change.
How is it that every encoding method I try fails.
Any idea what I'm fundamentally doing wrong ?

Normals are calculated this way:
// Output view space normals
output.Normal.xyz = mul(input.Normal, (float3x3)WorldViewIT); // WorldViewInverseTranspose


PARTNERS