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
\$\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\$
  • \$\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\$ – Alexsey Shestacov Jan 2 '15 at 20:04
  • \$\begingroup\$ You should make a new question with a screenshot of this second problem. \$\endgroup\$ – Stephane Hockenhull Jan 3 '15 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\$ – Alexsey Shestacov Jan 3 '15 at 17:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.