Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#ActualAuskennfuchs

Posted 16 May 2013 - 04:23 PM

Uhm, may be I'm missing something but:

you got your heightmap map[x][y]:

0011000
0111110
0110000

now you can build your normal for every point normal[x][y]

float2 n1 = calcNormal(map[p.x][p.y],map[p.x-1][p.y],map[p.x][p.y-1])
float2 n2 = calcNormal(map[p.x][p.y],map[p.x+1][p.y],map[p.x][p.y-1])
float2 n3 = calcNormal(map[p.x][p.y],map[p.x-1][p.y],map[p.x][p.y+1])
float2 n4 = calcNormal(map[p.x][p.y],map[p.x+1][p.y],map[p.x][p.y+1])

float3 normal[p.x][p.y]=normalize((n1 x n2 x n3 x n4),1.0f)

Now you can build your trianglelist with position and normal and in pixelshader

 

float3 lightVector = -normalize(lightDirection);
float NdL = max(0,dot(normal,lightVector));
float3 diffuseLight = NdL * lightColor.rgb * texColor.rgb;


#1Auskennfuchs

Posted 16 May 2013 - 04:21 PM

Uhm, may be I'm missing something but:

you got your heightmap map[x][y]:

0011000
0111110
0110000

now you can build your normal for every point normal[x][y]

float2 n1 = calcNormal(map[p.x][p.y],map[p.x-1][p.y],map[p.x][p.y-1])
float2 n2 = calcNormal(map[p.x][p.y],map[p.x+1][p.y],map[p.x][p.y-1])
float2 n3 = calcNormal(map[p.x][p.y],map[p.x-1][p.y],map[p.x][p.y+1])
float2 n4 = calcNormal(map[p.x][p.y],map[p.x+1][p.y],map[p.x][p.y+1])

float3 normal[p.x][p.y]=normalize((n1 x n2 x n3 x n4),1.0f)

Now you can build your trianglelist with position and normal and in pixelshader

 

float3 lightVector = -normalize(lightDirection);
float NdL = max(0,dot(normal,lightVector));
float3 diffuseLight = NdL * lightColor.rgb * texColor;


PARTNERS