```
````rnmBlendRepack`

does not work very well.

Yes, sorry, I gave bad advice earlier; you need to add 0.5 when repacking, not 1 (standard unpacking is `nu = n*2 - 1`

; the reverse is (nu + 1)/2, which is the same as `nu/2 + 0.5`

).

it has a strange problem ... you can see some random highlights on the unlit side of a sphere

It’s a bit hard to debug remotely, but there are a couple of potential issues that could creep in due to negative z values. Try the following functions (one at a time):

`float3 UnpackNormalSafer(float4 packednormal)`

{

float3 normal;

normal.xy = packednormal.wy*2 - 1;

float d = dot(normal.xy, normal.xy);

normal.z = (d <= 1) ? sqrt(1 - d) : 0;

return normalize(normal);

}

float3 rnmBlendUnpackedClampZ(float3 n1, float3 n2)

{

n1 += float3( 0, 0, 1);

n2 *= float3(-1, -1, 1);

float3 n = n1*dot(n1, n2)/n1.z - n2;

if (n.z < 0)

n = normalize(float3(n.x, n.y, 0));

return n;

}