• Create Account

### #Actualnfactorial

Posted 24 January 2013 - 06:54 PM

Hey, thanks for the images. The lighting in the first one shows your problem much clearer for me.It looks like your normals are incorrect. For terrain normals I take the height sample x,y and compute the normal for that sample with:

float h0 = GetSample( x + 0, y - 1 );
float h1 = GetSample( x - 1, y + 0 );
float h2 = GetSample( x + 1, y + 0 );
float h3 = GetSample( x + 0, y + 1 );

Vector3 normal;

normal.x = h1 - h2;
normal.y = separation; // separation = distance between samples (I use 1.0f).
normal.z = h0 - h3;

normal.Normalize();

return normal;

If that doesn't help, perhaps posting your normal calculation code?

n!

### #2nfactorial

Posted 24 January 2013 - 06:54 PM

Hey, thanks for the images. The lighting in the first one shows your problem much clearer for me.It looks like your normals are incorrect. For terrain normals I take the height sample x,y and compute the normal for that sample with:

float h0 = GetSample( x + 0, y - 1 );
float h1 = GetSample( x - 1, y + 0 );
float h2 = GetSample( x + 1, y + 0 );
float h3 = GetSample( x + 0, y + 1 );

Vector3 normal;

normal.x = h1 - h2;
normal.y = separation; // separation = distance between samples (I use 1.0f).
normal.z = h0 - h3;

normal.Normalize();

return normal;

If that doesn't help, perhaps posting your normal calculation code?

n!

### #1nfactorial

Posted 24 January 2013 - 06:53 PM

Hey, thanks for the images. The lighting in the first one shows your problem much clearer for me.It looks like your normals are incorrect. For terrain normals I take the height sample x,y and compute the normal for that sample with:

float h0 = GetSample( x + 0, y - 1 );

float h1 = GetSample( x - 1, y + 0 );

float h2 = GetSample( x + 1, y + 0 );

float h3 = GetSample( x + 0, y + 1 );

Vector normal;

normal.x = h1 - h2;

normal.y = separation;   // separation = distance between samples (I use 1.0f).

normal.z = h0 - h3;

normal.Normalize();

return normal;

If that doesn't help, perhaps posting your normal calculation code?

n!

PARTNERS