• Welcome to Dark Bit Factory & Gravity.
 

Cubemapping

Started by Stonemonkey, July 09, 2007

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Stonemonkey

I've made a start on this, only got the rendering to the maps done so far which is the easy bit but i have a couple of questions:

What space should it be done in and is it ok or not to have the map aligned to an object or should the cubemap be aligned with the world axis?

I am planning on chopping up my tris so that they are split where the vectors cross the planes x=y, x=-y, x=z, x=-z, y=z, y=-z . I think anyway, but wondering if that can be done linearly or not?

Jim

Not totally sure how cube mapping works.

It's your choice as to how the cube is aligned.  This is why there's a texture matrix in d3d/opengl.

I think for the polygons you use the normal.  Whichever is the largest dimension picks which of the 6 maps to use (as you say, +-x, +-y, +-z) then use the normal to index the 2d texture in some way - I guess this is where the tricky bit comes in!  Far easier with sphere maps, the normal just indexes the sphere directly!

Jim
Challenge Trophies Won:

Stonemonkey

#2
My idea atm is to reflect the camera-vertex vector off the vertex using the normal and use that reflected vector for the mapping but since the reflected vector of each vertex can point to a different face of the cube I reckon I'll have to chop up the triangle so that each sub triangle only has part of a single cube face covering it. I see some problems ahead and I'm not quite sure about which way to start just yet.
I don't really see the problem with the indexing though,if i'm using the texture at +z then I'll use the vector to calculate what x and y are when z=1.0 then it's a case of u=x*.5+.5,v=y*.5+.5 sort of thing although it'll be slightly different for each side depending on the orientation of the camera for each render.

Stonemonkey

#3
A little test of it so far, I think I had some reports of my engine not working for some people before so it might not work. Anyway, it's only the cubemap mapped directly onto a cube so far.

It takes a little while for it to start up and it's the 2 mouse buttons to turn left/right, both to move forward.

EDIT: attatchment removed, updated test attatched further down.

Jim

That looks like it's working just fine!  Nice demo!
Challenge Trophies Won:

Stonemonkey

Cool, and thanks. Still got the hard stuff to do though.

ninogenio

that works just fine here fryer very cool stuff,

im curios what more has to be added to it cause to the untrained eye like mine it looks spot on.
Challenge Trophies Won:

Stonemonkey

At the moment, it renders to the cubemap which is rotated with the cube and the cubemap is applied directly onto the cube which isn't right for reflections and won't work for any shape other than a cube. What I have to do now is reflect each camera-vertex vector off each vertex and use the reflected vector to get the coordinates for the cubemap.

ninogenio

ah yes i see that now.

hope you get it all figured out which im sure you will.
Challenge Trophies Won:

Stonemonkey

I think you're right Jim, I really can't see my idea of splitting it up into smaller tris working properly so I think that I'm gonna have to test each pixel to find which texture to read from.

taj

Uhoh doesnt work here on atix1800 winxp sp2. I gte a white screen and an egg timer cursor :0(
Challenge Trophies Won:

Stonemonkey

Ah yep, it takes a little while to start up. The white screen with egg timer is what it does.

Stonemonkey

#12
I think I'm getting there but not sure if this is quite right yet:

EDIT: that maybe wasn't the best shape to test it with, made it a sphere now and it's looking much better.

It won't run from the zip, you need to unzip the files to a folder. It takes a little while to start up so you get a white window for a bit and then use the mouse buttons to turn, both together move forward.

ninogenio

stunning stunning work mate htf do you work that fast k+
Challenge Trophies Won:

Stonemonkey

Caffeine, lots of caffeine.

Also I was able to do most of it using my existing triangle code but instead of sending u,v,shade to it i sent the reflected 3d vector and then made the changes for the texture lookup.

ninogenio

again it really is great and i cant believe you managed it in software at these fps  :kewl:
Challenge Trophies Won:

Stonemonkey

Thanks nino, the way I'm doing it now should allow for normal mapping too. But that's for some other time.

Jim

Looks tremendous!
Challenge Trophies Won:

Stonemonkey

Cheers Jim,  I'm quite pleased with it so far.

Paul

Thats really cool, good work
I will bite you - http://s5.bitefight.se/c.php?uid=31059
Challenge Trophies Won: