Modern lighting techniques in B3d?

Blitz3D Forums/Blitz3D Programming/Modern lighting techniques in B3d?

The kind of techniques used in recent AAA games ie Doom 3 et al... okay these use DX9. B3D uses DX7. But I've seen a couple of posts here that suggest these lighting techniques could be used in Blitz, in software mode, a lot slower than would be playable.

I want to make a specific 3D app, and I want to include that kind of lighting (not necessarily specifically Doom 3 but whatever is current) - maybe have a 'preview' mode with no lighting, and then a render mode that outputs an animation with all the lighting bells and whistles.

Can anyone comment about this?

check this one
http://www.blitzbasic.com/codearcs/codearcs.php?code=641

i think this is an raytracing like approach

Cool - thanks for that - that might come in really handy, although it would be nice to have something a *little* faster. That was like five seconds per frame; [guess]I imagine I can get something like between 1-5 frames per second with some software-based Doom 3-style lighting.[/guess]

per pixel operations in Blitz are slow!
DX9 Shadows are based on pixelshader and operate per pixel

But check out sswift's shadowsystem
this one uses projection and is fast enough to be used in realtime
http://www.blitzbasic.com/logs/userlog.php?user=963&log=269

How slow for per pixel stuff? Like I say, I'm not talking realtime game-type speed here but rendering... If I can get 1 frame per second in what might be a normal game type scene, that's good enough.

I think sswift's system might not be good for me - I want fairly realistic self shadowing etc. For example, a human face lit from the side would be half in darkness, with the nose casting a shadow on the rest of the face.

if you operate on any type of large texture you won't be even next to 1 fps I fear.

What type of lighting are you after?

You can get lovely, ultra fast multiple per pixel lights using cubic lighting.(They can be colored and all done in a single pass.)

Here's the code I used in cryo for cubic lighting...I'm switching to vivid, so feel free to use it.



Function actorsAlpha(alpha#,actorType)
	For a.actor=Each actor
		If a\aType=actorType
			EntityAlpha a\id,alpha
			If alpha=0 And a\did<>0 HideEntity a\did
			If alpha>0 And a\did<>0 ShowEntity a\did
		EndIf
	Next
End Function

Function updateCubicLighting()
	actorsAlpha(0,aSoldier)
	actorsAlpha(0,aWeapon)
	HideEntity lev\id
	;TextureBlend lev\lightmap,1
	For a.actor =Each actor
		If a\cmap<>0
		
			If a\waist<>0 
			renderCubeFrom(a\cmap,a\waist,Handle(a),False) 
			Else 
			renderCubeFrom(a\cmap,A\id,Handle(a),False)
			EndIf
			
		EndIf
	Next
	;TextureBlend lev\lightmap,5
	;renderCubeFrom(lev\cmap,lev\id)
	ShowEntity lev\id
	actorsAlpha(1,aSoldier)
	actorsAlpha(1,aWeapon)
	For l.light =Each light
		HideEntity l\id
	Next
	
End Function
Function renderCubeFrom(tex,id,lid,reflection=False)
	;HideEntity lev\id
	HideEntity eng\cpiv
	
	For l.light =Each light
		If reflection=1
		End
		Else
		ShowEntity l\id
		PointEntity l\id,id
		TurnEntity l\id,90,0,0
		;PointEntity l\id,id
		;TurnEntity l\id,90,0,0
		td#=EntityDistance(id,l\id)
		If td>4100 td=4100
		
		ad#=td/4100.
		If ad>1 ad=1
		If ad<0 ad=0
		ad=1.-ad
		If ad>0
		
		;	x#=EntityX(id,True)
		;	y#=EntityY(id,True)
		;	z#=EntityZ(id,True)
		;	lx#=EntityX(l\id,True)
		;	ly#=EntityY(l\id,True)
		;	lz#=EntityZ(l\id,True)
			
		;	hit=LinePick(lx,ly,lz,x-lx,y-ly,z-lz,0.1)
		;	If hit=lev\id
		;		l\as[lid]=l\as[lid]*0.80
		;		If l\noFade=True l\as[lid]=0
		;	Else
			If l\as[lid]<1 l\as[lid]=l\as[lid]+0.05
			If l\noFade=True l\as[lid]=1
		;	EndIf
			
	 	EndIf
		EndIf
		
		EntityAlpha l\id,ad*l\as[lid]	
	
	Next
	ShowEntity eng\cpiv
	updateCubeMap(tex,EntityX(id,True),EntityY(id,True),EntityZ(id,True),cubicRes)
End Function




Function UpdateCubeMap(tex,x#,y#,z#,size) 

HideEntity eng\cam\id
Local cam=CreateCamera() 
CameraRange cam,1,100000 

CameraViewport cam,0,0,TextureWidth(tex),TextureHeight(tex) 
PositionEntity cam,x,y,z 
TurnEntity cam,0,90,0 
RenderWorld
;RenderWorld 
;RenderWorld  

SetCubeFace tex,0 
CopyRect 0,0,size,size,0,0,BackBuffer(),TextureBuffer(tex) 
TurnEntity cam,0,-90,0 
RenderWorld 
;RenderWorld 
;RenderWorld 
SetCubeFace tex,1 
CopyRect 0,0,size,size,0,0,BackBuffer(),TextureBuffer(tex) 
TurnEntity cam,0,-90,0 
RenderWorld 
;RenderWorld 
;RenderWorld 
SetCubeFace tex,2 
CopyRect 0,0,size,size,0,0,BackBuffer(),TextureBuffer(tex) 
TurnEntity cam,0,-90,0 
RenderWorld 
;RenderWorld 
;RenderWorld 
SetCubeFace tex,3 
CopyRect 0,0,size,size,0,0,BackBuffer(),TextureBuffer(tex) 
TurnEntity cam,0,-180,0 
TurnEntity cam,90,0,0 
RenderWorld 
;RenderWorld 
;RenderWorld 
SetCubeFace tex,5
CopyRect 0,0,size,size,0,0,BackBuffer(),TextureBuffer(tex) 
TurnEntity cam,180,0,0 
RenderWorld 
;RenderWorld 
;RenderWorld 
SetCubeFace tex,4 
CopyRect 0,0,size,size,0,0,BackBuffer(),TextureBuffer(tex) 
FreeEntity cam 
Return tex 
ShowEntity eng\cam\id
End Function 


the stuff commented out may be of use..been a while since I touched this. but it works as is.(Well it well once integrated;p)

At the light positions, they are not blitz lights, but instead a quad textured with a light. This is rendered onto the player's cubic light map, then projected on. You change the color of these quads to mimic differant light colors. Increase the size of the quad to represent light strength.
fade the light colors to represent fall off.

The actual texture..imagine you were looking directly at a light. a lens flare-ish image.

Use cubemode 2 for normal smooth lighting, cube mode 1 for shiny metalic lighting.

Tangent mapping your other option..but overall, not a realistic one for real-world use in blitz3d.

Thanks for that Spaced -- I'll try that out when I get a chance.