# INTRO

I'm using a Java JOGL wrapper called processing.org and I have coded some environment on it and I'm quite proud of it even if it has some library stuff that I didn't know anything about it (==LIGHTS).

Now, for some geometry, I've decided to use a VBO. I had to pass in the hard way and recode all lights. But I can't achieve the same result.

With that environment if i use the standard lights i get this result:

This environment wrap the opengl functions and i don't manage to understand the pure OPENGL calls.

i know that the code for standard light in processing.org enviroment is:

public void lights() {
enableLighting();

// need to make sure colorMode is RGB 255 here
int colorModeSaved = colorMode;
colorMode = RGB;

lightFalloff(1, 0, 0);
lightSpecular(0, 0, 0);

ambientLight(colorModeX * 0.5f, colorModeY * 0.5f, colorModeZ * 0.5f);
directionalLight(colorModeX * 0.5f, colorModeY * 0.5f, colorModeZ * 0.5f, 0, 0, -1);

colorMode = colorModeSaved;
}


# PROBLEM

I want to replicate this light system with pure openGL calls.

Now, i have done some trial with no succes.

ambient and spot lights:

# QUESTION

Now, i'd like for someone to help me in analysing the first picture and help me in understanding what kind (light or material or whatever) of OPENGL calls i can use to achieve a similar result.

# CODE

this is my code so far:

gl.glEnable(GL.GL_LIGHTING);
gl.glEnable(GL.GL_LIGHT0);
gl.glEnable(GL.GL_COLOR_MATERIAL);

Vec3D l = new Vec3D(0,0,-10);
gl.glColor3f(0.8f,0f,0f);
gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, new float[] { l.x, l.y, l.z, 0 }, 0);
gl.glLightfv(GL.GL_LIGHT0, GL.GL_SPOT_DIRECTION, new float[] { 1, 1, 1 }, 0);
//gl.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, new float[] { 1, 1, 1}, 0); // if i comment this line nothing change, why?

gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT,        new float[]{1f,0f,0f}, 0);
gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_SPOT_DIRECTION, new float[]{1f,0f,0f}, 0);
//gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_SPECULAR, new float[]{1f, 1f, 1f, 1.0f}, 0);  // if i comment this line nothing change, why?

• Your second image said "and this is the FBO" I changed that to VBO since I thought it was a typo (since you don't mention FBOs anywhere else). Just letting you know so you can change it back if that's wrong. – MichaelHouse May 31 '12 at 16:45
• Can you post your code for original geometry and new code with vbo? – zacharmarz Jun 1 '12 at 5:26
• ok i've added some code – nkint Jun 1 '12 at 7:44

It seems to me that you're either passing smooth normals or have smooth shading enabled in the 2nd picture compared to the first one, but I can't really tell with just what you have posted.

• yeah i use normals but if i remove them i don't have any other light apart from ambiental (flat color no shadow like in the first pic) – nkint May 31 '12 at 16:41
• Of course you need normals, but you need to check if the vertices of a face have different normals. For the same shading as the first picture, the vertices of a given face need to have the same normals. Also check if you have "glShadeModel(GL_SMOOTH)" enabled by using "glShadeModel(GL_FLAT)". – Grieverheart May 31 '12 at 16:52
• Do you have specular enabled? The first picture you posted doesn't seem to havee any specular, just diffuse. – Grieverheart Jun 1 '12 at 10:39
• sorry.. how can can disable specular light? – nkint Jun 1 '12 at 10:50
• You set its color to 0. You should probably post your code or at least part of it. The post you linked is quite different from what you want to achieve. – Grieverheart Jun 1 '12 at 11:25

• sounds quite weird that is a normal problem because i'm not calculating normals directly but i'm using only mesh.computeFaceNormals(); .. – nkint Nov 29 '12 at 19:05