Skies and 3D ness
Re: Skies and 3D ness
Texture matrix? Don't think I knew about that one (though I was aware of there being more than just the MVP matrix), but then, I was concentrating on EGL stuff. I'll have to take another look to see what's available.
Leave others their otherness.
http://quakeforge.net/
http://quakeforge.net/
Re: Skies and 3D ness
Texture matrix.
The civilized way to handle skybox rotation and orientation. Of course, if you're using shaders you just load a new matrix as a uniform and multiply your texcoords by that.
I think that resolves the whole skybox issue; no need for flip/mirror/etc of image data and everything is oriented correctly and nice and fast and clean.
The civilized way to handle skybox rotation and orientation. Of course, if you're using shaders you just load a new matrix as a uniform and multiply your texcoords by that.
Code: Select all
// common
INOUTTYPE vec4 texcoords;
#ifdef VERTEXSHADER
uniform mat4 localMatrix;
uniform mat4 skymatrix;
layout(location = 0) in vec4 position;
void SkyVS ()
{
gl_Position = localMatrix * position;
texcoords = skymatrix * position;
}
#endif
#ifdef FRAGMENTSHADER
uniform samplerCube skydiffuse;
out vec4 fragColor;
void SkyFS ()
{
fragColor = texture (skydiffuse, texcoords.xyz);
}
#endif
Code: Select all
void RSky_BeginFrame (void)
{
glmatrix skymatrix = {0, 0, 1, 0, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1};
GL_RotateMatrix (&skymatrix, r_newrefdef.time * skyrotate, skyaxis[0], skyaxis[2], skyaxis[1]);
GL_TranslateMatrix (&skymatrix, -r_origin[0], -r_origin[1], -r_origin[2]);
glProgramUniformMatrix4fv (gl_skycubeprog, u_skytexturematrix, 1, GL_FALSE, skymatrix.m16);
}
Code: Select all
// load images in this order
char *suf[6] = {"ft", "bk", "up", "dn", "rt", "lf"};
// load cubemap faces in this order
glTexImage2D (GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB8, size, size, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, faces[i].data);
Last edited by mh on Tue Oct 23, 2012 8:58 pm, edited 1 time in total.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
We knew the words, we knew the score, we knew what we were fighting for
Re: Skies and 3D ness
one of q2's infostrings controls rotation of the skybox... spinny skies.
Re: Skies and 3D ness
QF actually supports spinning skies (glsl only, but with no run-time control yet). Somewhere between 0.2 and 0.4 radians/second made me feel a little ill.
Leave others their otherness.
http://quakeforge.net/
http://quakeforge.net/