correct cubic environment mapping, how?

Blitz3D Forums/Blitz3D Programming/correct cubic environment mapping, how?

Raitsun(Posted 2005) [#1]
How can i manage to get a CORRECT cubic environment mapping? well just placing the camera at the coordinates of the mesh that i want to be cubemapped and rotating it for all faces of the cubemap is no real solution... it only works for small meshes... have no clue how to make this work properly
Can anyone help me?

raitsun


jfk EO-11110(Posted 2005) [#2]
As far as I know you need to use the game cameras x and z coordinate, pick the floor Y under the camera and subtract that distance from the floor Y to get the Y of the cubemap camera. Or maybe you need to use

cubecam_Y= entityY(chrome_mesh) - (entityY(gamecam)-entityY(chrome_mesh))
(But then I ask myself how to use it for multiple meshes...so better try to use "Floor minus" or "Zero minus")

Well, something like that. Although some people would not agree with my method, but it's tested :)

The pro of this method is, you only need to render the cubemaps one time for the whole world. It's not mesh oriented, it's viewer oriented.

In the end you'll see it isn't an exact science and you'll probably never mirror all things totally correct.

Nevertheless you should be able to get a chrome effect or something.

EDIT:
Some people say all you have to do is position the cube cam at the game cam position, but as far as I remeber the was a problem with this method.


Raitsun(Posted 2005) [#3]
thanks jfk... works fine for my marble floor and my water... maybe it is not, but it at least looks very correct

and now i will forget about this marble-sphere-water-thing ^^


Snarkbait(Posted 2005) [#4]
jfk, please put a small code example of the floor method, not sure I am following you. thx :)


jfk EO-11110(Posted 2005) [#5]
I don't have the source right here (new machine).

-Get X and Z from the main camera.
-Do a linepick from the main cameras position against the ground.
-Calculate main camera Y minus pickedY.
-Calculate pickedY minus the prev. calculations result, to get the Cube cam Y.
Now position the cube cam at this X,cubeY,Z and perform a 6 sided render for cubemapping as seen eg. in the cubed-Markio Demo.
             .game cam
          ______________________ground
  _______/
_/           °cube cam
-------------------- Zero



You see the distance from game cam to the ground is the same as from cube cam to the ground, only the cube cam is on the other side. Sorry if I explained it complicated :)

EDIT: btw. I'd also reccomend to use an optimzed cube-rendering function as seen in the code archives, that will use multiple cameras with side by side organized viewports to render all 6 sides with a single renderworld.


Snarkbait(Posted 2005) [#6]
Thx... my main question was I wasn't sure if by 'floor' you meant the function Floor or you meant floor i.e. ground. Now I get it. ;)