I'm not sure why, but I've just created a simple 3D model and normalised it but lighting looks very pixelated; as seen in the picture below (inside the spoiler).
Spoiler
This is the code I used to normalise it:
for (i=0; i<global.gridParts;i+=1) {
d3d_model_primitive_begin(terModel,pr_trianglelist);
for (j=0; j<global.gridParts; j+=1) {
x1 = i*global.gridSize;
y1 = j*global.gridSize;
z1 = ds_grid_get(heightGrid,i,j);
x2 = (i+1)*global.gridSize;
y2 = j*global.gridSize;
z2 = ds_grid_get(heightGrid,i+1,j);
x3 = (i+1)*global.gridSize;
y3 = (j+1)*global.gridSize;
z3 = ds_grid_get(heightGrid,i+1,j+1);
nX = (y2-y1)*(z3-z1)-(y3-y1)*(z2-z1);
nY = (z2-z1)*(x3-x1)-(z3-z1)*(x2-x1);
nZ = (x2-x1)*(y3-y1)-(x3-x1)*(y2-y1);
m = sqrt(nX*nX + nY*nY + nZ*nZ);
nX /= m;
nY /= m;
nZ /= m;
d3d_model_vertex_normal(terModel,x1,y1,z1,nX,nY,nZ);
d3d_model_vertex_normal(terModel,x2,y2,z2,nX,nY,nZ);
d3d_model_vertex_normal(terModel,x3,y3,z3,nX,nY,nZ);
x1 = (i+1)*global.gridSize;
y1 = (j+1)*global.gridSize;
z1 = ds_grid_get(heightGrid,i+1,j+1);
x2 = i*global.gridSize;
y2 = (j+1)*global.gridSize;
z2 = ds_grid_get(heightGrid,i,j+1);
x3 = i*global.gridSize;
y3 = j*global.gridSize;
z3 = ds_grid_get(heightGrid,i,j);
nX = (y2-y1)*(z3-z1)-(y3-y1)*(z2-z1);
nY = (z2-z1)*(x3-x1)-(z3-z1)*(x2-x1);
nZ = (x2-x1)*(y3-y1)-(x3-x1)*(y2-y1);
m = sqrt(nX*nX + nY*nY + nZ*nZ);
nX /= m;
nY /= m;
nZ /= m;
d3d_model_vertex_normal(terModel,x1,y1,z1,nX,nY,nZ);
d3d_model_vertex_normal(terModel,x2,y2,z2,nX,nY,nZ);
d3d_model_vertex_normal(terModel,x3,y3,z3,nX,nY,nZ);
}
d3d_model_primitive_end(terModel)
}
If this is normal, is there a way to achieve something smoother? Perhaps another method of normalising possible in GM?
Thank you very much,
I appreciate your help
Edited by loverock125, 25 April 2012 - 01:38 AM.












