• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps OpenGL ES Light attenuation problem

skinhat

Newbie
Does light attenuation work in opengl ES (GL10)? I havent seen any demos in google.

I've been trying to get light attenuation working (where light source fades further away something is from the light) but I'm finding as I move the camera I get flicker eg in the video after 10 seconds:

YouTube - ‪Android light flicker‬‏

Wondering if light attenuation works in Android and if so what might the problem be that I'm getting?

Ive been playing around with

gl.glLightf(lightarray, GL10.GL_LINEAR_ATTENUATION,1.0f);
gl.glLightf(lightarray, GL10.GL_CONSTANT_ATTENUATION, 0.0f);
gl.glLightf(lightarray, GL10.GL_QUADRATIC_ATTENUATION, 0.0f);

with doing different combination of the above settings but they all are like in the video.

I set the 4th vector element in the position vector to 1 which switches on attenuation:
gl.glLightfv(object3D.lightItem.gllight, GL10.GL_POSITION, new float[] { 0f, 0f, 1f, 1f }, 0);
 
Looks like the problem is that when you make a light source directional (4th element in GL_POSITION vector element set to 1) the light position becomes absolute. When the light source is not directional I would update the light source position relative to the camera with translatef every time the camera moved. When its directional I only need to set the position of the light source once.
 
Back
Top Bottom