Radiosity Bumpmapping

Blitz3D Forums/Blitz3D Programming/Radiosity Bumpmapping

It might be possible to perform lightmapped bumpmapping in Blitz3D, with specular reflection.

The bumpmap will blend with whatever is underneath it, right? Normally people use vertex colors, but you could insert a light direction map (like a lightmap) in the first texture unit, to control where the light is coming from. This is how HL2 does it.

I assume DX7 calculates the binormal/bitangent arrays on the GPU, then calculates the TBN matrix from those values? If so, this would work.

I have implemented this in my own engine, and have written a bsp/vis/light compiler to compile 3D World Studio files into .bsp files.

If Blitz3D bumpmaps work like I think they do, it should be possible for you to render them in Blitz3D like this:




Hey dude, looks good! your right it, is possible in BlitzBasic. I've been working on a generating a light directional map for the last few days (like a baked on lightmap as you mentioned), I've tested it on a quad, i.e. floor, wall etc. How far have you got? I am finding it difficult to calculate/generate a tangent space matrix. Applying it, and everything else there on out is easy. I am having to "manualy" set up the matrix atm (based on the face tangent space) and apply it to each texel at a time in the light directional map. Looks amazing! But now that I know it works, I need it to automaticly do it for me. I generate my light maps in 3DS Max, it's a shame it can't render a light directional map or alike.

Any chance of seeing an .exe of this? Pretty please :)

Jason.

that looks good! but where is the radiosity? its just specular bump mapping and lightmaps...

That's what Valve calls it, probably because it sounds high-tech:
http://www2.ati.com/developer/gdc/D3DTutorial10_Half-Life2_Shading.pdf

I have been using this technique for months, and the lightmapper works perfectly.

However I am storing the light vectors in world space because I found that easier. I don't know how to convert that to tangent space. I guess if I created a matrix, set the X row to the binormal and the Y row to the tangent, and the z row to the normal, then transformed the vector with that, it should work.

I first tried that approach, but I was writing the shader at the same time, so I was double-blind to whether the results were correct or not. So I switched to global space because then I knew the vectors were right.

I've got example code of this sort of bumpmap, but you still have to make the bumpmap layer in order to have this sort of visual, and for most people in the Blitz3D community, I think it's something relatively out of reach. A good tutorial on how to build proper bump map layer would be a good starting point. It's the same problem with specular map. You just don't want to use whatever media on the web, but make your own, and it's not the most evident thing.


Here's an example code from Tom, which require a special DLL that Tom wrote for the occasion. Sadly, I don't have a link to that DLL.
Graphics3D 800,600,32,2

;Must let the DLL know a few things about Blitz3D!
d3d=SystemProperty$("Direct3D7")
dev7=SystemProperty$("Direct3DDevice7")
draw7=SystemProperty$("DirectDraw7")
hwnd=SystemProperty$("AppHWND")
instance=SystemProperty$("AppHINSTANCE")
If DX7_SetSystemProperties(d3d,dev7,draw7,hwnd,instance) RuntimeError "Error setting 1 or more System Propertys!"

;Does the hardware support bump mapping, and luminance bump mapping?
If Not DX7_SupportsBumpMapping() Then RuntimeError("No Hardware support for Bump Mapping!")
If Not DX7_SupportsLumiBumpMapping() Then RuntimeError("No Hardware support for Luminance Bump Mapping!")

; Camera.. Light(s).. Action!
cam=CreateCamera()
PositionEntity cam,0,0,-2
CameraRange cam,.01,10
CameraClsColor cam,100,120,200


sphere=CreateSphere(32)
RotateEntity sphere,0,90,0


colorTex = CreateTexture(1,1)
SetBuffer TextureBuffer(colorTex)
c=255
Color 155,120,20
Rect 0,0,1,1,True
SetBuffer BackBuffer()

;Load a bump map. Bump maps for this type of bump mapping are nothing
;more than normal maps. The blue channel/pixels can be used to set the
;Luminance is the bump mode is 0 (see below)
bumpTex = LoadTexture("bumpmap.png",1+256)

;cubemap
envTex=LoadTexture("cubemap\cloudyhills.jpg",1+128+256)

;Set blend mode for cubemap to Add
TextureBlend envTex,3

;Apply the 3 textures
EntityTexture sphere,colorTex,0,0
EntityTexture sphere,bumpTex,0,1
EntityTexture sphere,envTex,0,2


;The bump settings
;If bumpMode = 0, the luminance is taken from the textures Blue channel/pixels
;If bumpMode = 1, luminance is set via lumScale and lumOffset
bumpMode=1
lumScale#=1.5
lumOffset#=0
m00#=1:m10#=-1
m01#=-1:m11#=1



MoveMouse 400,300

fps=0
counter=0
timer=MilliSecs()
While Not KeyDown(1)


	
	If MouseDown(1) TurnEntity sphere,0,-.05,0

	v#=.001
	If KeyDown(42) v=.0005
	If KeyDown(30) MoveEntity cam,-v,0,0
	If KeyDown(32) MoveEntity cam,v,0,0
	If KeyDown(17) MoveEntity cam,0,0,v
	If KeyDown(31) MoveEntity cam,0,0,-v
	
	RotateEntity cam,(400+MouseY())*.5, -(MouseX()-400)*.5,0


	If KeyHit(57)
		m00=0:m01=0
		m10=0:m11=0
	End If

	s#=.002
	If KeyDown(2)
		m00=m00 - s
		m01=m01 + s
	End If
	
	If KeyDown(3)
		m00=m00 + s
		m01=m01 - s
	End If

	If KeyDown(4)
		m10=m10 - s
		m11=m11 + s
	End If
	
	If KeyDown(5)
		m10=m10 + s
		m11=m11 - s
	End If

	If KeyDown(200) lumScale=lumScale+.001
	If KeyDown(208) lumScale=lumScale-.001
	If KeyDown(205) lumOffset=lumOffset+.001
	If KeyDown(203) lumOffset=lumOffset-.001
	
	DX7_SetBumpInfo m00,m01,m10,m11,lumScale,lumOffset,bumpMode


	;This function forces settings for the next geometry rendered
	;It makes texture layer 1 use bump mapping
	DX7_EnableRenderBumpTexture

	RenderWorld

	;Return texture layer 1 to normal Blitz3D settings
	DX7_DisableRenderBumpTexture


	;Update FPS counter
	counter=counter+1
	If MilliSecs() - timer > 999
		fps=counter
		counter=0
		timer=MilliSecs()
	End If

	Color 0,0,0
	Text 0,0,"FPS: "+fps
	Text 0,12,"w,s,a,d,mouse to move/look, LMB to spin sphere"

	Text 0,40,"1,2 and 3,4 adjust the bump matrix. Cursors adjust scale & offset"
	Text 0,52,"SPACE sets the bump matrix to 0,0,0,0"

	Text 0,64,"m00: "+m00+" , m01: "+m01
	Text 0,76,"m10: "+m10+" , m11: "+m11
	Text 0,88,"scale: "+lumScale
	Text 0,100,"offset: "+lumOffset
	
	Flip 0
	Wend
End


where IS tom's DLL!! argh!

Look here: http://www.blitzbasic.com/Community/posts.php?topic=73478

but thats environmental bump mapping AND NOT dot3 bump mapping which josh showed there.

if you want ENBM, just download the devil shadow system...