Author Topic: Cubemapping  (Read 10489 times)

0 Members and 1 Guest are viewing this topic.

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Cubemapping
« on: July 09, 2007 »
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?

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Cubemapping
« Reply #1 on: July 09, 2007 »
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:

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: Cubemapping
« Reply #2 on: July 09, 2007 »
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.
« Last Edit: July 09, 2007 by Stonemonkey »

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: Cubemapping
« Reply #3 on: July 10, 2007 »
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.
« Last Edit: July 11, 2007 by Stonemonkey »

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Cubemapping
« Reply #4 on: July 10, 2007 »
That looks like it's working just fine!  Nice demo!
Challenge Trophies Won:

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: Cubemapping
« Reply #5 on: July 10, 2007 »
Cool, and thanks. Still got the hard stuff to do though.

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: Cubemapping
« Reply #6 on: July 10, 2007 »
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:

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: Cubemapping
« Reply #7 on: July 10, 2007 »
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.

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: Cubemapping
« Reply #8 on: July 10, 2007 »
ah yes i see that now.

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

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: Cubemapping
« Reply #9 on: July 10, 2007 »
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.

Offline taj

  • Bytes hurt
  • DBF Aficionado
  • ******
  • Posts: 4810
  • Karma: 189
  • Scene there, done that.
    • View Profile
Re: Cubemapping
« Reply #10 on: July 11, 2007 »
Uhoh doesnt work here on atix1800 winxp sp2. I gte a white screen and an egg timer cursor :0(
Challenge Trophies Won:

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: Cubemapping
« Reply #11 on: July 11, 2007 »
Ah yep, it takes a little while to start up. The white screen with egg timer is what it does.

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: Cubemapping
« Reply #12 on: July 11, 2007 »
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.
« Last Edit: July 11, 2007 by Stonemonkey »

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: Cubemapping
« Reply #13 on: July 11, 2007 »
stunning stunning work mate htf do you work that fast k+
Challenge Trophies Won:

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: Cubemapping
« Reply #14 on: July 11, 2007 »
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.

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: Cubemapping
« Reply #15 on: July 11, 2007 »
again it really is great and i cant believe you managed it in software at these fps  :kewl:
Challenge Trophies Won:

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: Cubemapping
« Reply #16 on: July 11, 2007 »
Thanks nino, the way I'm doing it now should allow for normal mapping too. But that's for some other time.

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Cubemapping
« Reply #17 on: July 11, 2007 »
Looks tremendous!
Challenge Trophies Won:

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: Cubemapping
« Reply #18 on: July 11, 2007 »
Cheers Jim,  I'm quite pleased with it so far.

Offline Paul

  • Pentium
  • *****
  • Posts: 1490
  • Karma: 47
    • View Profile
Re: Cubemapping
« Reply #19 on: July 12, 2007 »
Thats really cool, good work
I will bite you - http://s5.bitefight.se/c.php?uid=31059
Challenge Trophies Won: