0
\$\begingroup\$

I Can't get correct rotations for cubemap faces. Thats should come to geometry shader, from camera "view" matrix I want make 6 faces for my cubemap, but seems I can't get it correctly...

My first guess that camera 'indent' matrix faces to '-z':

// +X //
 rot[0] = (mat4 (   0   ,  0    , -1.0  , 0 , 
                    0   ,  1.0  , 0     , 0 ,
                    1.0 ,  0    , 0     , 0 ,
                    0   ,  0    , 0     , 1.0 )) ;
// -X /
 rot[1] = (mat4 (   0   ,  0    , 1.0   , 0 , 
                    0   ,  1.0  , 0     , 0 ,
                    -1.0 ,  0   , 0     , 0 ,
                    0   ,  0    , 0     , 1.0 )) ;
 //+Y/
 rot[2] = (mat4 (   1   ,  0    , 0     , 0 , 
                    0   ,  0    , 1.0   , 0 ,
                    0   ,  -1.0 , 0     , 0 ,
                    0   ,  0    , 0     , 1.0 )) ;
 //-Y/
 rot[3] = (mat4 (   1   ,  0    , 0     , 0 , 
                    0   ,  0    , -1.0  , 0 ,
                    0   ,  1.0  , 0     , 0 ,
                    0   ,  0    , 0     , 1.0 )) ;
 //+z/
 rot[5] = (mat4 (   -1  ,  0    , 0     , 0 , 
                    0   ,  1    , 0     , 0 ,
                    0   ,  0    , -1    , 0 ,
                    0   ,  0    , 0     , 1.0 )) ;
 //-z/
 rot[4] = (mat4 (   1   ,  0    , 0     , 0 , 
                    0   ,  1    , 0     , 0 ,
                    0   ,  0    , 1     , 0 ,
                    0   ,  0    , 0     , 1.0 )) ;

EDIT: Correct for me: Using LookAt magic, finaly find correct order of rotation: NOTE: thats RH-coordinate system Column-major order (glsl default)

// +X
        rot[0] = (mat4 (    0   ,  0    , 1.0   , 0 , 
                            0   ,  1.0  , 0     , 0 ,
                            -1.0 ,  0   , 0     , 0 ,
                            0   ,  0    , 0     , 1.0 )) ;
// -X /
        rot[1] = (mat4 (    0   ,  0    , -1.0  , 0 , 
                            0   ,  1.0  , 0     , 0 ,
                            1.0 ,  0    , 0     , 0 ,
                            0   ,  0    , 0     , 1.0 )) ;
 //+Y/
        rot[3] = (mat4 (    -1  ,  0    , 0     , 0 , 
                            0   ,  0    , -1.0  , 0 ,
                            0   ,  -1.0 , 0     , 0 ,
                            0   ,  0    , 0     , 1.0 )) ;
 //-Y/
        rot[2] =(mat4 (     -1  ,  0    , 0     , 0 , 
                            0   ,  0    , 1.0   , 0 ,
                            0   ,  1.0  , 0     , 0 ,
                            0   ,  0    , 0     , 1.0 )) ;
 //+z/
        rot[4] = (mat4 (    -1  ,  0    , 0     , 0 , 
                            0   ,  1    , 0     , 0 ,
                            0   ,  0    , -1    , 0 ,
                            0   ,  0    , 0     , 1.0 )) ;
 //-z/
        rot[5] = (mat4 (    1   ,  0    , 0     , 0 , 
                            0   ,  1    , 0     , 0 ,
                            0   ,  0    , 1     , 0 ,
                            0   ,  0    , 0     , 1.0 )) ;
\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

To fix these kinds of issues create a test cubemap clearly marking each face directions and +/- XYZ you can then figure out which one(s) is(are) pointing the wrong way.

enter image description here

\$\endgroup\$
3
  • \$\begingroup\$ hm, seems that not only one issue, I make sphere with cubemap, project it using normals,but parts of cubemap are not connected \$\endgroup\$ Jan 2, 2015 at 20:04
  • \$\begingroup\$ You should make a new question with a screenshot of this second problem. \$\endgroup\$ Jan 3, 2015 at 16:45
  • \$\begingroup\$ Seems solved (mostly), but there new fun with convoling cubemap in compute shader (calculate SH harmonics), And there new issues. I need also correct reflections on planar surfaces somehow \$\endgroup\$ Jan 3, 2015 at 17:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .