Vertex lighting.

Blitz3D Forums/Blitz3D Programming/Vertex lighting.

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Ok for the most part that worked, however im having some issues. Any particular reason why the colors are almost negated? EG: Mapping the color everywhere BUT where the light/radius is? Also is this a good solution for using multiple lights? And what kind of speed impact will this have with multiple lights against multiple surfaces? Any idea what the limit would be?



Function light_it_up(model)

	s=GetSurface(model,1)

For L.lamp=Each lamp

	For i=1 To CountVertices(s)-1

		TFormPoint VertexX(s,i),VertexY(s,i),VertexZ(s,i),model,0
		xd#=TFormedX()-EntityX(L\x)
		yd#=TFormedY()-EntityY(L\Y)
		zd#=TFormedZ()-EntityZ(L\Z)
		dist#=Sqr(xd*xd + yd*yd + zd*zd)*radius		

		If dist<0 Then dist=0
		If dist>255 Then dist=255
		
		VertexColor s,i,L\R - dist,L\G - dist,L\B - dist

	Next

Next

End Function