Cubemapping bug, or ChrML bug?

Blitz3D Forums/Blitz3D Programming/Cubemapping bug, or ChrML bug?

ChrML(Posted 2004) [#1]


This looks exactly like it looks in 3dsmax when the UV's are wrong. You see the error happens in the triangle seperator. How can I fix that? Here's my code:

debugmap = HM_GetModel("mirror1")
	
cubex=512
cubey=512
	
debugcam = CreateCamera()
debugtex = CreateTexture(cubex,cubey,128+256+1)
	
HideEntity debugmap
PositionEntity debugcam,EntityX(debugmap),EntityY(debugmap),EntityZ(debugmap)
CameraViewport(debugcam,0,0,cubex,cubey)
EntityTexture debugmap,debugtex
	
;0
SetCubeFace debugtex,0
RotateEntity debugcam,0,90,0
RenderWorld
CopyRect 0,0,cubex,cubey,0,0,BackBuffer(),TextureBuffer(debugtex)
	
;1
SetCubeFace debugtex,1
RotateEntity debugcam,0,0,0
RenderWorld
CopyRect 0,0,cubex,cubey,0,0,BackBuffer(),TextureBuffer(debugtex)
	
;2
SetCubeFace debugtex,2
RotateEntity debugcam,0,-90,0
RenderWorld
CopyRect 0,0,cubex,cubey,0,0,BackBuffer(),TextureBuffer(debugtex)
	
;3
SetCubeFace debugtex,3
RotateEntity debugcam,0,180,0
RenderWorld
CopyRect 0,0,cubex,cubey,0,0,BackBuffer(),TextureBuffer(debugtex)
	
;4
SetCubeFace debugtex,4
RotateEntity debugcam,-90,0,0
RenderWorld
CopyRect 0,0,cubex,cubey,0,0,BackBuffer(),TextureBuffer(debugtex)
	
;5
SetCubeFace debugtex,5
RotateEntity debugcam,90,0,0
RenderWorld
CopyRect 0,0,cubex,cubey,0,0,BackBuffer(),TextureBuffer(debugtex)
	
	  
ShowEntity debugmap
FreeEntity debugcam
FreeTexture debugtex


This happens each mainloop. Don't worry about that I create the camera and the texture and free them each time, because this is only a test. HM_GetModel is my function and returns the model named 'mirror1' (the cube in the screenshot). What can be wrong?


ChrML(Posted 2004) [#2]
Anyone knows?


napole0n(Posted 2004) [#3]
Something is wrong with your UV map. Try to triangulate your mesh ie cut a line through the middle.


ChrML(Posted 2004) [#4]
That cube is created using CreateCube() :S.


ChrML(Posted 2004) [#5]
I have the cubemap texture at the second texture channel btw.


Vorderman(Posted 2004) [#6]
You get the same effect on the playstation due to the lack of perspective-correction when texture mapping. Usually you only notice it on large polys.

I believe you can see it in Max too, if you turn off perspective correction and texture map a large poly.

Does the error decrease as you turn the poly to face it straight on? Do you get the same effect with a texture in the 1st texture channel?

Perhaps texture channels higher than 0 have no perspective correction, or maybe it's a videocard thing you could enable...?


ChrML(Posted 2004) [#7]
It's looks correct when I look right at it, but when I go to left or right, and look at it from a perspective, then it looks like the screenshot above. Yeah, it might have something to do with the perspective correction, because if I turn off Texture Correction in 3dsmax's perspective viewport, then it would've looked same.

Yup, it looks the same in texture channel 0 :(. I have a GeForce 2 MX-400. It does support Cubemapping, but idunno if it supports cubemapping combined with texture correction. Is there anything I can enable in blitz, or in my video card settings that can correct this?


ChrML(Posted 2004) [#8]
You think it will look better if I cut the face up in several segments?


ChrML(Posted 2004) [#9]
Ok, I just cutted it up in 5 segments. Now it looks kinda like a glass with water on :P, but atleast it looks better. Thanks :)!


Gabriel(Posted 2004) [#10]
Cube mapping doesn't look great for these kind of big reflections. You absolutely must subdivide the object and as you've found, it still doesn't look fantastic.

It's nice in certain situations, but I haven't found it as hugely useful as sphere mapping, which never ceases to surprise me with it's flexibility.


ChrML(Posted 2004) [#11]
Spheremaps can't be dynamic, I guess, unless you can find a way to render those "180 degrees pictures", and map it right, so it looks like a proper reflection. The nice thing with cubemaps though, is that I can make the game pre-render them in the loading section.


Gabriel(Posted 2004) [#12]
No, you can't really use spheremaps for "proper reflections", but you can use them for 101 other things.

For "proper reflections" I still can't find a better way than simply duplicating the geometry and hiding it behind an alphae'd floor/wall/whatever is supposed to reflect.


_PJ_(Posted 2004) [#13]

Spheremaps can't be dynamic, I guess, unless you can find a way to render those "180 degrees pictures", and map it right, so it looks like a proper reflection. The nice thing with cubemaps though, is that I can make the game pre-render them in the loading section.



Even panoramic images may not look correct, due to polar distortion.

It would be ideal (and probably such a 'perfect-world') if to have true reflective capability as a texture flag! Or if Mirrors weren't infinite and flat all the time!


Ross C(Posted 2004) [#14]
Make sure as well, that your hiding the mirror cube. It sort of looks like the camera is rotating, but catching the side of the cube and rendering it. Hide the cube when doing you cubemap rendering.


ChrML(Posted 2004) [#15]
Malice: Yeah, I've noticed that :). What can I do to get most real-looking dynamic reflections with cubemapping?

Ross C: Ofcourse :D, as in the code sample above.


Rob(Posted 2004) [#16]
For flat objects, avoid cubemaps as they are completely unnecesary - instead render a single view out and copyrect to texture.

IMHO, cubemaps are not designed for planes.


ChrML(Posted 2004) [#17]
If I do a single view out, then the reflection wouldn't be correct, right? Because the image at the mirror depends on the perspective of the camera.

Mark (the blitz3d developer), can you please comment the following questions?:
Will there ever be a CreateMirror() function in blitz that makes a mirror that's not infinite? I know that is hard to make, but will it come? And one more question about lighting. Loops in BB are kinda slow compared to loops in C++ and Delphi, so will there be functions for easier dynamic lighting, like render 3d directly to texturebuffer, and stuff like that...?