Posted By: sivan
setting grass normals for recieving more uniform lighting - 11/21/13 15:26
a little tip: setting vertex normals to point upwards makes lighting of grass models more uniform, and look much better when the camera moves around (I added this quick feature to MapBuilder a few minutes ago)
another tip: for tree leaves I use an modified central normalization. more exactly, normals got by lerping 2 values: the vector pointing out from entity middle to the actual vertex, and its original normal vector.
Code:
void Grass_SetNormals(ENTITY* ent) { int i; for (i=1; i<=(var)(ent_status(ent, 0)); i++) { CONTACT* c = ent_getvertex(ent, NULL, i); // vertex number begins with 1 ! c.v.nx = (float)0; c.v.nz = (float)0; c.v.ny = (float)1; // upwards - uniform lighting ent_setvertex(ent, c, i); } }
another tip: for tree leaves I use an modified central normalization. more exactly, normals got by lerping 2 values: the vector pointing out from entity middle to the actual vertex, and its original normal vector.