Poor shading problem in Android OpenGL ES -


i set diffuse lighting:

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, 2.0f, 1.0f };  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); gl.glenable(gl10.gl_light0);  gl.glshademodel(gl10.gl_smooth); 

but triangulated shading or flat color on cube located @ origin ( center) , rotated 45 deg around x , y. cube directly in front of light. reasons why getting such poor results? attached cube image.

enter image description here

opengl es calculates colors @ vertices of each triangle. color interpolated across triangle, ideally vertices should calculate same colors between 2 triangles variety of situations cause not to.

it appears though cube edges modeled 2 triangles. decompose cube side more triangles, adds more memory storage , slow down drawing.

you move opengl es 2.0 , write shader, can interpolate colors across surface, require rewriting entire pipeline. ogl es doesn't let mix old style , shader based implementations.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -