PDA

View Full Version : Dynamic cubemapping woes



MarcusL
05-15-2002, 02:48 AM
Hi!

Despite reading all the previous posts here (which helped me a bit), I can't get it to work properly. The cube map seem misaligned and 'stretched' over the object, but does contain the right colours, here and there. (I recently got big blotches of green and purple in a few places too.)


I've gotten so far as rendering the cube's sides correctly (posx, negx, etc..) and they seem to be correct when I view them. The cube is aligned to 'world' coordinates. (I can also align it to the object, however it doesn't make things better at all)

I have enabled texture coord generation (reflection map + enable texgen for s,t,r).

I am putting the inverse of the upper 3x3 part of the modelview matrix in the texture matrix.

Here's a screenshot with the cubemap and the object:
http://www.dtek.chalmers.se/~d98macke/shot_2002-05-15_13.37.05.png

Tell me what parts of the code you need, if any. Thanks in advance!

mbespalov
05-15-2002, 03:30 AM
Hi
I don't know that the problem is, but have one guess. This texgen generates s,t,r vector using eye space normal, don't forget to supply normals and make sure that they are still normalized after transformation to the eye space.

Adrian
05-15-2002, 04:23 AM
Another guess...check you are not changing your projection matrix.

Why are you doing anything with the texture matrix?

Humus
05-15-2002, 10:59 AM
Originally posted by Adrian:
Why are you doing anything with the texture matrix?

As the texcoord generated from the normal is in eyespace it must be transformed back into model space by the inverse of the modelview matrix.

MarcusL
05-15-2002, 01:36 PM
mbespalov: I do have normals, since lighting works correctly. And enabling normalization makes no difference. (Although looking at the reflections, it seems to be the normals that are wrong.)

Adrian: Of course I am changing the projection matrix. When rendering the cube maps i have a fov of 90 with 1:1 ratio. When rendering the object I have 60 with 4:3 ratio. What did you mean exactly?

Humus: Could this be avoided by creating the cube map aligned to the object (or somesuch thing, perhaps applying the inverse at this stage instead)?

[This message has been edited by macke (edited 05-15-2002).]

MarcusL
05-16-2002, 12:21 AM
Hmm.. When I tried with just a sphere (gluSphere) it is colored the same over the whole surface. It does shift between different colors as different sides of the cube are applied, but every triangle has the same color. (Lighting still works properly.)

If I didn't know better, I'd say either there's only one normal being used, or that the normals generated are very un-normalized.

As to how this can happen, I have no idea.

Humus
05-16-2002, 09:45 AM
Originally posted by macke:
Humus: Could this be avoided by creating the cube map aligned to the object (or somesuch thing, perhaps applying the inverse at this stage instead)?

Sure, but I'm not sure if that's simplier or better in any way though.