Bumpmap problem
Blitz3D Forums/Blitz3D Programming/Bumpmap problem
While I'm playing around in the bump map demo< I figured out that, when you turn the camera around the entity, bump texture starts disappearing.
I think its related to [ SetCubemode tex,3 ] command appearing in CreateNormMap() function
Function CreateNormMap()
tex=CreateTexture( 256,256,128 )
SetCubeMode tex,3
For x=0 To 255
For y=0 To 255
nx#=(x-127.5)/127.5
ny#=(y-127.5)/127.5
nz#=1/Sqr(nx*nx+ny*ny+1)
nx=nx*nz
ny=ny*nz
tr=nx*127.5+127.5
tg=ny*127.5+127.5
tb=nz*127.5+127.5
SetCubeFace tex,1
WritePixel x,y,tr Shl 16 Or tg Shl 8 Or tb,TextureBuffer(tex)
Next
Next
Return tex
End Function
do you know any way to overcome this problem??
Sorry, I have no idea - I'm gonna wait until someone is going to post a perfect Solution :) Don't forget it's only an easteregg. I hope we gonna have some nice DX9 Features such as freely programmable Shaders in BlitzMAX. But until then I am patient.
I've seen Nvidias Elf "Dawn" - almost photorealistic - in Realtime!
Afaik BlitzMax is OpenGL, therefore we will have a little easier to implement Pixel, and Vertex Shaders, (since I know how different the setting up of them are in the 2 languages) but still, I would like to see how many people here, really know how to use them :).
Ok, here is my working Code for fix thies Problem. The Demo Example using only "Forward" Face-Side for Bump Mapping and simple CubeMode 3.
You most use all 6 Cube Faces for Bump Mapping and Set CubeMode to 1 for perfekt 360° Bump Mapping Effekt without disappearing Effekt. :)
Here My CreateNormMap() Function:
Function CreateNormMap()
tex=CreateTexture( 256,256,128 )
SetCubeMode tex,1 ;<<<< Mode 1 !
For Face=0 to 5 ;<<<< New "For,Next" Bow for all 6 Face Sides
For x=0 To 255
For y=0 To 255
nx#=(x-127.5)/127.5
ny#=(y-127.5)/127.5
nz#=1/Sqr(nx*nx+ny*ny+1)
nx=nx*nz
ny=ny*nz
tr=nx*127.5+127.5
tg=ny*127.5+127.5
tb=nz*127.5+127.5
SetCubeFace tex,Face ;<<< Replace "1" with "Face"
WritePixel x,y,tr Shl 16 Or tg Shl 8 Or tb,TextureBuffer(tex)
Next
Next
Next ;<<< Next for Face Bow
Return tex
End Function
Have Fun ! :)
oh thanks it working, but when U start rotate the camera around the object it look like there is another texture sliding??
Test it also witch SetCubeMode 2.
It works similarly like SetCubeMode 1 but causes another Sliding (Standard) effect.
thanks Ogi, but when I used SetCubeMode 2 , I lost the bumpmap effect and it look like normal multitextured object ..
Hmm, Ok.
Then use again CubeMode 1. Is the best Mode think I.
Is better as Mode 3 and disappearing effekt. :)
I use allways Mode 1 and have no Problems with that.
ok I will send ya an e-mail with attached demo wait