Cube Mapping Whoes

Blitz3D Forums/Blitz3D Programming/Cube Mapping Whoes

Neochrome(Posted 2004) [#1]
Danmit! i cant seem to get a cube to do cubemapping!

my card does support it cos a demo has worked

BUT i do this
water=createcube()
cubetex = createtexture(64,64,128)
entitytexture water,cubetex

and then use this function
Function UpdateCubemap(tex,camera,entity) 

	tex_sz=TextureWidth(tex) 

	; Show the camera we have specifically created for updating the cubemap 
	ShowEntity camera 

	; Hide entity that will have cubemap applied to it. This is so we can get cubemap from its position, without it blocking the view 
	HideEntity entity 

	; Position camera where the entity is - this is where we will be rendering views from for cubemap 
	PositionEntity camera,EntityX#(entity),EntityY#(entity),EntityZ#(entity) 

	CameraClsMode camera,False,True 

	; Set the camera's viewport so it is the same size as our texture - so we can fit entire screen contents into texture 
	CameraViewport camera,0,0,tex_sz,tex_sz 

	; Update cubemap 

	; do left view 
	SetCubeFace tex,0 
	RotateEntity camera,0,90,0 
	RenderWorld 
	CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex) 

	;; do forward view 
	SetCubeFace tex,1 
	RotateEntity camera,0,0,0 
	RenderWorld 
	CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex) 

	; do right view 
	SetCubeFace tex,2 
	RotateEntity camera,0,-90,0 
	RenderWorld 
	CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex) 

	; do backward view 
	SetCubeFace tex,3 
	RotateEntity camera,0,180,0 
	RenderWorld 
	CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex) 

	; do up view 
	SetCubeFace tex,4 
	RotateEntity camera,-90,0,0 
	RenderWorld 
	CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex) 

	; do down view 
	SetCubeFace tex,5 
	RotateEntity camera,90,0,0 
	RenderWorld 
	CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex) 

	; Show entity again 
	ShowEntity entity 

	; Hide the cubemap camera 
	HideEntity camera 

End Function 
but the water dissapears and looks liek nothing is there?


sswift(Posted 2004) [#2]
"Danmit! i cant seem to get a cube to do cubemapping!"

Damnit! I thought this thread was going to be about cube mapping whores!


jfk EO-11110(Posted 2004) [#3]
damn-int - we have discussed this lately. depending on the object you want to map, you need to position the camera.

; Position camera where the entity is - this is where we will be rendering views from for cubemap
. This is wrong in some situations.

For a Water surface I have found that you need to position the cubemapping-camera x and z-wise at the players position, and y-wise at ground minus(the player cameras height over ground).


sswift(Posted 2004) [#4]
I imagine that you actually want to flip the camera's Y position around the water plane, not the ground height. That would make more sense. But I haven't actually tried it.


Agamer(Posted 2004) [#5]
That must be ironey

can't get CUBEmapping to work on a CUBE


jfk EO-11110(Posted 2004) [#6]
sswift - yes, you're right. But basicly: not the cubes position.


Neochrome(Posted 2004) [#7]
i have to have the screen res at 32bit? it doesn't show up at all in 16bit :( how can i get around this?


sswift(Posted 2004) [#8]
" i have to have the screen res at 32bit? it doesn't show up at all in 16bit :( how can i get around this?"

You can't. Mark discovered this bug, and thinks it's a problem with NVidia's drivers. It held up the release of this version of Blitz for a long time. But he released Cubemapping as a feature anyway eventually, but not a full feature.

I suggest you don't use cubemapping if you want your game to run on lower end hardware. A TNT2 isn't going to support it, and osme folks might still be using those.