bump mapping

Blitz3D Forums/Blitz3D Programming/bump mapping

chwaga(Posted 2007) [#1]
is there any function out there, with which you can type "entitybumpmap (entity, "bumpmaptexture.bmp")" before the loop and "updatebumpmap()" in the main loop??? I've been on a hunt for a function of this sort, without any success. I hear tom's DLL can do this, but I cannot find it anywhere. Can anybody help??


t3K|Mac(Posted 2007) [#2]
I've uploaded all my DX7-Libs for B3D. I don't know which one is the right one, so you have to try yourself.

http://www.t3k-entertainment.com/freefiles/DX7-Libs_for_Blitz3D.zip


bytecode77(Posted 2007) [#3]
try the devil shadow system instead; its a full library. download it in my signature!


_33(Posted 2007) [#4]
t3K|Mac, thanks a lot!


chwaga(Posted 2007) [#5]
dss does ENBM, not quite what i'm looking for, t3K|Mac, i'm looking into your files now. (I need just plain old bump mapping, normal mapping, whatever you want to call it)


chwaga(Posted 2007) [#6]
Ok, found it in "anotherDX7 too", but how do i use it?

;Bump Mapping
UserBumpTexture():"_UserBumpTexture@0"
EnableRenderBumpTexture():"_EnableRenderBumpTexture@0"
DisableRenderBumpTexture():"_DisableRenderBumpTexture@0"
SetBumpInfo(m00#,m10#,m01#,m11#,lumScale#,lumOffset#,bumpMode%):"_SetBumpInfo@28"

how do I use these?


t3K|Mac(Posted 2007) [#7]
I have a source, i think this is what you are looking for:

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 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 SupportsBumpMapping() Then RuntimeError("No Hardware support for Bump Mapping!")
If Not 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
	
	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
	EnableRenderBumpTexture

	RenderWorld

	;Return texture layer 1 to normal Blitz3D settings
	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


or download the archive with bumpmaps + dll:

http://www.t3k-entertainment.com/freefiles/bumpy_text_demo.zip


chwaga(Posted 2007) [#8]
works beautifully, thanks


chwaga(Posted 2007) [#9]
ditto, the bumpmapping affects the cubemap texture, is there a way to bumpmap the diffuse texture??


bytecode77(Posted 2007) [#10]
the DLL in the DSS is absolutely the latest there is!!!!!!


chwaga(Posted 2007) [#11]
that's still ENBM, I want diffuse bump mapping, the simple stuff for non-shiny surfaces


bytecode77(Posted 2007) [#12]
that wont be possible with toms dll which you want to do it


chwaga(Posted 2007) [#13]
then with what can it be done?


bytecode77(Posted 2007) [#14]
with the simple commands of b3d


chwaga(Posted 2007) [#15]
I'm a total noob to texture-editing and stuff(with almost a year of experience), enlighten me on how :)


Tab(Posted 2007) [#16]
Graphics3D 800,600,32,2

tex = LoadTexture ("wall.jpg")
normal = LoadTexture ("wall_DOT.jpg")

TextureBlend normal,4
TextureBlend tex,2

cube = CreateCube()
PositionEntity cube,0,0,3

EntityTexture cube,normal,0,0
EntityTexture cube,tex,0,1


AmbientLight 255,255,255

cam = CreateCamera()
CameraClsColor cam,255,255,255

While Not KeyHit(1)

   TurnEntity cube,0,.1,0

   RenderWorld
   Flip


Wend



boomboom(Posted 2007) [#17]
Tab, that code doens't take into consideration the position and movements of lights does it? As in the 'bump' on the object won't update if a light moves across it?


Dreamora(Posted 2007) [#18]
Normal maps don't react to DX light sources, you must do it manually and either color the vertices manually or use a different approach to map the normal light color onto the object


Tab(Posted 2007) [#19]
My code is only a little example.

This code take in consideration the position of the light.
http://www.blitzbasic.com/codearcs/codearcs.php?code=2097


chwaga(Posted 2007) [#20]
I'll check that out tab, thanks