setting grass normals for recieving more uniform lighting

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)



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.
Posted By: oliver2s

Re: setting grass normals for recieving more uniform lighting - 11/21/13 15:27

Thank you laugh
Posted By: Superku

Re: setting grass normals for recieving more uniform lighting - 11/21/13 17:25

Thanks for the tip, the tree shading looks nice, too!
Posted By: EpsiloN

Re: setting grass normals for recieving more uniform lighting - 12/04/13 13:54

Quote:
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.


I'm very bad with graphical stuff tongue but your trees look awesome!
Could you explain more in-depth what the above means? laugh
Posted By: sivan

Re: setting grass normals for recieving more uniform lighting - 12/04/13 14:07

I will share that script here too, but is already available in MapBuilder, in obstacleplace.c
now I use a bit refined grass normal setting function, if I have time I will put here...
Posted By: wrekWIRED

Re: setting grass normals for recieving more uniform lighting - 12/06/13 07:13

MB just keeps getting better and better. cool work.
© 2024 lite-C Forums