Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid OpenGL skybox light not really working
    primarykey
    data
    text
    <p>Okay, I have made a "skybox" (it's actually 5 plane, because of the different textures). It's works fine, but there is a problem with the lightning. It's not my strongest point in OpenGL, so I will be not surprised if the answer is not so hard.</p> <p>So that is my start position view. As you can see the front plane is bright, but the left, top, right are not really, and there is a border between them and the front.</p> <p><a href="http://img696.imageshack.us/img696/3673/light01.png" rel="nofollow">http://img696.imageshack.us/img696/3673/light01.png</a></p> <p>When I go to the absolute center (nearly) of the skybox then the border are not so visible (I guess at the absolute center there is no border.</p> <p><a href="http://img233.imageshack.us/img233/2949/light02.png" rel="nofollow">http://img233.imageshack.us/img233/2949/light02.png</a></p> <p>First I tried with one light at the posistion (0,0,0) with these settings, but nothing, I tried to change the ambient, the diffuse, but not really helps:</p> <pre><code> private float[] lightAmbient = {0.5f, 0.5f, 0.5f, 1.0f}; private float[] lightDiffuse = {1.0f, 1.0f, 1.0f, 1.0f}; private float[] lightPosition = {0.0f, 0.0f, 0.0f, 1.0f}; public void onSurfaceCreated(GL10 gl, EGLConfig config) { gl.glEnable(GL10.GL_DITHER); gl.glEnable(GL10.GL_TEXTURE_2D); gl.glShadeModel(GL10.GL_SMOOTH); gl.glClearColor(0, 0, 0, 0); gl.glClearDepthf(1.0f); gl.glEnable(GL10.GL_DEPTH_TEST); gl.glDepthFunc(GL10.GL_LEQUAL); gl.glEnable(GL10.GL_LIGHT0); gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST); gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_AMBIENT, lightAmbientBuffer); gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_DIFFUSE, lightDiffuseBuffer); gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_POSITION, lightPositionBuffer); } public void onDrawFrame(GL10 gl) { gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); gl.glLoadIdentity(); gl.glEnable(GL10.GL_LIGHTING); GLU.gluLookAt(gl, eyeX, eyeY, eyeZ, centerX, centerY, centerZ, 0.0f, 1.0f, 0.0f); } public void onSurfaceChanged(GL10 gl, int width, int height) { if(height == 0) { height = 1; } gl.glViewport(0, 0, width, height); gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadIdentity(); GLU.gluPerspective(gl, 65.0f, (float)width / (float)height, 1.0f, 80.0f); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); } </code></pre> <p>So the question is how can I make this to work in every place where I am. I hope someone can help me, because now it's not really looking nice (without light is good, but I don't really want a night scene, ecspecially with a texture where there is the sun :).</p> <p><strong>EDIT (how it works now)</strong>: as it was in the answer there are no normals for the skybox anymore, but after I have enabled lightning I was needed to add this line to the code, and now it works like a charm, and the sky is bright everywhere.</p> <pre><code> gl.glLightModelf(GL10.GL_LIGHT_MODEL_TWO_SIDE, GL10.GL_TRUE); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload