Highlights w/ Vertex Lighting??

Blitz3D Forums/Blitz3D Programming/Highlights w/ Vertex Lighting??

Hi,

Does anyone know if it's possible using vertex-lighting techniques to ''light'' an object so as to create highlights as you might get when using basic DX7 lights (eg. with a mesh's shininess set to 1.0) ?! I've not been able to color a vertex/object above it's default 100% diffuse (textured-)color... which makes sense I understand, but it there a 'trick' to create some additive effect to it (ie. without using lightmapping)...?!

Thanks,
Danny

Tried LightMesh()?

yep vertex painting can get you some very good results
screen grabs form blitz, no lights just ambient set at 200 so the colours dont get washed out

i used lightwave but i think any program where you can bake the lighting to the mesh should work

NO vertex map & 1 tile



-----------------------------------------------------------------------

with vertex map & 1 tile, 6k tris




Thanks Gfk / Scribbla,

But what I mean is if it's possible to create really heavy burned out WHITE HIGHTLIGHTS as you get when using very bright dx7 lights. FOr example a default red (255,0,0) sphere with a bright point light close next to it, will produce a 255,255,255 highlight on the red sphere. With vertex lights & textured objects, I've only been able to create diffuse (non specular) surfaces as scribbla demonstrates with his (very cool looking by the way!!!) images - everything still remains 100% diffuse!

p.s. I haven't tried lightmesh because I'm using a range of light-shapes already coded myself...

Think you'll have a job getting convincing specular highlights simply using vertex colours - especially on low poly meshes. Any reason you can't use EntityShininess?

Entityshininess only reacts to DX7 lights. A vertex's color does not affect it's shininess. That's me whole point... :/

Guess it's not possible... so I'll put it on me xmas list then..

d.

memory who has not written the program but this is the version modified from me ;)

no remember

 
Include "fps.bb"

Graphics3D 640,480,16,2
;AmbientLight 0,0,0

Global DS=4
Const NObj=4
Dim sphereobj( NObj, NObj, NObj)

NObj2=NObj+1
Global FactPercent#=100.0/(NObj2*NObj2*NObj2)
Global val#=0

Global Light=CreateSphere(4)
Lightp=CreateLight(2,Light)


;Global Cube = LoadMesh("cubo128.3ds")
;ScaleEntity Cube,20,20,20

val=0
For x=1 To NObj
	For y= 1 To NObj
		For z= 1 To NObj
			sphereobj(x,y,z)=CreateSphere(32)
			EntityPickMode sphereobj(x,y,z),2
			PositionEntity sphereobj(x,y,z),x*DS,y*DS,z*DS
			val=val+FactPercent
			Print "Create Object :"+val
		Next
	Next
Next

For x=1 To NObj
	For y= 1 To NObj
		For z= 1 To NObj
			LightObject(sphereobj(x,y,z), Light)
		Next
	Next
Next



camera=CreateCamera()
PositionEntity camera,12,12,2
RotateEntity camera,0,0,315


Global vrot#=.5
Global vmove#=.2
Global OldTime=timer
Global mla#=.2, mlb#=0

While Not KeyHit(1)

		If KeyDown(63) Then Stop
		If (Not KeyDown(29)) And (Not KeyDown(157)) Then ; CTRL 
			If KeyDown(208) Then TurnEntity camera,vrot,0,0
			If KeyDown(200) Then TurnEntity camera,-vrot,0,0
			If KeyDown(203) Then TurnEntity camera,0,vrot,0
			If KeyDown(205) Then TurnEntity camera,0,-vrot,0
		Else 
			If KeyDown(208) Then MoveEntity camera,0,0,-vmove
			If KeyDown(200) Then MoveEntity camera,0,0, vmove
		EndIf

		mlb=EntityX(Light)
		If mlb>30 Then mla=-mla
		If mlb<0 Then mla=mla

		;PositionEntity Light,mlb,mlb,mlb
		MoveEntity Light,mla,mla,mla		
		PositionEntity Light, EntityX(sphereobj(1,1,1)), EntityY(sphereobj(1,1,1)), EntityZ(sphereobj(1,1,1))
		;LightObject(Cube, Light)

		val=0
;		For x=1 To NObj
;			For y= 1 To NObj
;				For z= 1 To NObj
;					LightObject(sphereobj(x,y,z), Light)
;				Next
;			Next
;		Next

    UpdateWorld
    RenderWorld
		DrawFps()
		Text 5,15 ,TrisRendered()+"   "+EntityX(Light)
    Flip
Wend
End

Function LightObject(entity, Light)
	ApplyAmbient(entity,32,32,32)
                    
	ApplyLight(entity, EntityX(Light), EntityY(Light), EntityZ(Light), 20, 1,255,255,255)                        
	EntityFX entity,3
End Function

Function ApplyAmbient(entity,r,g,b)        
    
    count=CountSurfaces(entity)    
    For n=1 To count
        surf=GetSurface(entity,n)    
        Vcount=CountVertices(surf)-1    
        For v=0 To Vcount
            VertexColor surf,v,r,g,b        
        Next            
    Next

End Function

Function ApplyLight(entity,LX#,LY#,LZ#,radius#,flag,Lr,Lg,Lb)
	
	;Lambert shading in blitz "by Staton Richardson (Arbitrage)"    
	;This function is meant for 1 time lighting not realtime    
	;entity is the entity you wish to light
	;LX, LY, LZ are the coodinates of the light in world space
	;Lr, Lg, Lb are the colors of the light
	;radius is the radius the light affects. Light falls off with distance so half the radius would be half the light
	;flag tells the function to include the current vertex color for multiple lights
	
	Local AttSHW#=0.8
	Local kx#,ky#,kz#

	kx = EntityX(entity)-LX#
	ky = EntityY(entity)-LY#
	kz = EntityZ(entity)-LZ#

	Lrr# = (Lr/radius)
	Lrg# = (Lg/radius)
	Lrb# = (Lb/radius)
	
	count=CountSurfaces(entity) 
	For n=1 To count
		surf=GetSurface(entity,n) 
		Vcount=CountVertices(surf)-1 
		For v=0 To Vcount          
			xd#=VertexX(surf,v)+kx
			yd#=VertexY(surf,v)+ky
			zd#=VertexZ(surf,v)+kz
			mag#=Sqr(xd#*xd# + yd#*yd# + zd#*zd#)
				
			If flag=1
				vcr=VertexRed(surf,v)
				vcg=VertexGreen(surf,v)
				vcb=VertexBlue(surf,v)
			EndIf    
			
			vr=Lr-Lrr*mag#
			vg=Lg-Lrg*mag#
			vb=Lb-Lrb*mag# 
			
			If vr>255 Then vr=255
			If vg>255 Then vg=255
			If vb>255 Then vb=255 
			
			vx#=VertexNX(surf,v)
			vy#=VertexNY(surf,v)
			vz#=VertexNZ(surf,v)
			
			mag#=1/mag#
;			LnX#=xd#*mag#*-1
;			LnY#=yd#*mag#*-1
;			LnZ#=zd#*mag#*-1
			LnX#=-(xd#*mag#)
			LnY#=-(yd#*mag#)
			LnZ#=-(zd#*mag#)
			
			Kh#=((vx)*LnX+(vy)*LnY+(vz)*LnZ)
			
			
			DLx = (LX-xd)
			DLy = (LY-yd)
			DLz = (LZ-zd)
			;Stop
			a = LinePick (xd,yd,zd,DLx,DLy,DLz)
			
			If kh#>0 And a=0
				VertexColor surf,v, vr*Kh#+vcr, vg*Kh#+vcg, vb*Kh#+vcb
			Else
				;VertexColor surf,v, vcr*AttSHW, vcg*AttSHW, vcb*AttSHW
				VertexColor surf,v, 0, 0, 0
			EndIf  
			
		Next   
	Next 
End Function


Here's a picture to illustrate my question.

As you'll see the bottom two spheres have bright highlights on them from the DX7 point-light AND setting entityShininess to 1.0.
But you'll also see that the top-right sphere (done using vertex lighting) won't produce a highlight.

So, could it possible somehow to create a highlight like that on a textured and vertex-lit object??



cheers,
Danny

I think you'd need to work that out yourself...

There has a couple of examples posted using a combination of cubemapping and normalmapping, to produce specular lighting on a mesh. Honestly can't remember the link though... It's on these forums somewhere...

Thanks Ross,

I was hoping someone perhaps knew of a trick to do/fake this without additional textures...

cheers,
Danny