• Create Account

Banner advertising on our site currently available from just \$5!

### #ActualAuskennfuchs

Posted 16 May 2013 - 04:23 PM

Uhm, may be I'm missing something but:

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:

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