IggY
IggY

Reputation: 3125

OpenGl ES : Make a skybox look realistic

I'm having a trouble with a skybox. Everything is working fine, but we really feels like we are in a cube when the camera is in the middle (or everywhere else), the front face contains a part of the ground present un bottom face and we really feels the 90° angle between them. Any idea to improve this ?

NB. I already edited the images so the colors are the same and desactivated any light effect

Edited on 10/10

What I do now is this (mix OpenGL & pseudocode)

glMatrixMode(GL_PROJECTION)
glEnable(GL_DEPH_TEST)
glMatrixMode(GL_MODELVIEW);
Define_skybox (set vertices/texture coords; bind them on triangles)
glEnable(GL_DEPH_TEST)
glEnable(GL_LIGHTING)
glEnable(GL_TEXTURE_2D)
glEnable(GL_BLEND)
glMatrixMode(GL_PROJECTION)
glLoadIdentity();
glFrustumf(xmin, xmax, ymin, ymax, m_near, m_far) 
     with : m_fov = 90.0f; m_near = 0.1f; ymax = m_near * tan(m_fov * PI / 360); ymin = -ymax; xmax = ymax; xmin = -xmax;
glMatrixMode(GL_MODELVIEW)
glLoadIdentity();
Create 3 vect (center, eye, up) with spherical coordinate for my camera rotation
    eye(0;0;0), up (0; 1; 0), 
    center is calculated from rotation angle & spherical coordiantes
modelviewmatrix = glulookat(eye, center, up);
glLoadMatrix(modelviewmatrix);

Upvotes: 0

Views: 875

Answers (1)

datenwolf
datenwolf

Reputation: 162164

Where's your vantage point in relation of the cube? The camera must be in the exact center of the cube and the cube faces being rendered using a planar, center perspective projection with a 90° FOV. If you create your skybox that way, it should not "feel" like a cube.

Update due to comments

Principal operation when drawing a skybox (pseudocode)

render_scene_with_skybox():
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glDepthMask(GL_FALSE) # disable depth writes
    glDisable(GL_DEPTH_TEST)

    set_projection()
    set_modelview(orientation=camera.orientation, location=(0,0,0))

    draw_skybox() # the skybox spans from -1 to 1 in either direction

    # those should be really on-demand
    glEnable(GL_DEPTH_TEST)
    glDepthMask(GL_TRUE)

    set_modelview(orientation=camera.orientation, location=camera.location)
    draw_scene()

Upvotes: 2

Related Questions