The last weeks i was dealing with dot3 code. I've seen Fredborgs demo and a demo of a guy who's name i forgot. It demonstrates Bumpmapping on a floor plane with three lights... i think the ones who saw it, too, know what i mean... I just didn't know how to get halos code, it seems to be lost or something.
well... All the demos i've seen had some important features left out, some of them didn't allow more than one dot3-light, some didn't regard the lights direction, some didn't regard the normalmapped mesh's direction and some ignored the lights range in their caclulations.
Yesterday i coded an own method from scratch... I tried to regard most of the features.
It works pretty well in most situations. Only thing is i didn't get multiple lights to add to each other. It's always the last light only, that's regarded.
Here's the code:
Raitsun
well... All the demos i've seen had some important features left out, some of them didn't allow more than one dot3-light, some didn't regard the lights direction, some didn't regard the normalmapped mesh's direction and some ignored the lights range in their caclulations.
Yesterday i coded an own method from scratch... I tried to regard most of the features.
It works pretty well in most situations. Only thing is i didn't get multiple lights to add to each other. It's always the last light only, that's regarded.
Here's the code:
Global redd#, greend#, blued# Global bumpvec = CreatePivot() Type bumpmesh Field mesh ;bumpmapped mesh's handle End Type Type d3light Field light ;dot3 light's handle Field rng# ;dot3 light's range End Type Function graphics_Dot3_Normalupdate() For bm.bumpmesh = Each bumpmesh redd = 0 greend= 0 blued =0 For n = 1 To CountSurfaces(bm\mesh) surf = GetSurface(bm\mesh,n) For v = 0 To CountVertices(surf)-1 For d.d3light= Each d3light TFormPoint VertexX(surf,v),VertexY(surf,v),VertexZ(surf,v),bm\mesh,0 x# = TFormedX() - EntityX(d\light) y# = TFormedY() - EntityY(d\light) z# = TFormedZ() - EntityZ(d\light) TFormNormal VertexNX(surf,v),VertexNY(surf,v),VertexNZ(surf,v),bm\mesh,0 dist# = Sqr(x*x+y*y+z*z) Intens# = 1.0 - (dist/(d\rng*8)) If intens < 0 Then intens = 0 PositionEntity bumpvec,TFormedX(),TFormedY(),TFormedZ(),1 AlignToVector bumpvec,TFormedX(),TFormedY(),TFormedZ(),3,1 RotateEntity bumpvec,EntityPitch(bumpvec,1),EntityYaw(bumpvec,1),0,1 TFormNormal x,y,z,0,bumpvec redd = redd+(1.0-TFormedX())*127 greend = greend+(1.0-TFormedY())*127 blued = blued+((1.0-TFormedZ())*127)*Intens Next Next VertexColor surf,v,redd,greend,blued Next Next End Function
Raitsun

