Hey,
I'm attempting to enable lighting on Android, OpenGL ES 1.x, right now, only on the Android Emulator.
I've successfully imported some OBJs into a scene and rendered them, moved the camera around etc... but when I add these lines to my GLSurfaceView :: onSurfaceCreated, there is no visible change
My normals are being imported as well from the OBJ, but even if those were incorrect, shouldn't the ambient lighting have a noticable difference?
Make sure objects have normals, and make sure such are properly normalized.
How are your objects positioned? If your objects a re positioned at x,y,z (0.0f, 0.0f,-12.0f) , and since your light is placed at -20.0f, I doubt much effect would be cast.
Make sure objects have normals, and make sure such are properly normalized.
How are your objects positioned? If your objects a re positioned at x,y,z (0.0f, 0.0f,-12.0f) , and since your light is placed at -20.0f, I doubt much effect would be cast.
Thanks for the reply. I suppose the light is not intense enough to change the scene due to the positioning of my objects. My normals are normalized and such, they should be fine.
The object I'm trying to light (or show a lack thereof) is a textured terrain where the vertices are evenly spaced in the X/Y plane and the heights are controlled by a heightmap. The terrain spans the area between 0,0,0 and 300,300,H, where H is the maximum value within the heightmap.
Thus, I assume, if lighting is even enabled with a point light at 0,0,-20, then I should see most of the terrain as pitch black. But this is not true. The lighting is even and the scene is identical to if lighting was disabled.
give a code snippet of your terrain initiation code. Based on how it's set up, I might have a simple trick for lighting it that involves hitting your keyboard three times to achieve desired result.
give a code snippet of your terrain initiation code. Based on how it's set up, I might have a simple trick for lighting it that involves hitting your keyboard three times to achieve desired result.
Hey!
Thanks again for your reply. Here's the core of my terrain generation code. It basically steps through a grid of quads, breaks them into triangles and duplicates the vertices in order to connect the edges.
// Create the normal
Vector3d face1Normal = Vector3d.cross(
firstCornerVert.subtract(secondCornerVert),
thirdCornerVert.subtract(secondCornerVert));
face1Normal.normalise();
// Each vertex needs a normal, which is the same for all three vertices in the triangle
for(int i = 0 ; i < 3; i++){
norms.add(face1Normal.x);
norms.add(face1Normal.y);
norms.add(face1Normal.z);
}
/**
* Face2: Fourth Corner, First Corner, Third Corner
*/
inds.add(fourthCornerInd);
inds.add(firstCornerInd);
inds.add(thirdCornerInd);
Vector3d face2Normal = Vector3d.cross(
fourthCornerVert.subtract(firstCornerVert),
thirdCornerVert.subtract(firstCornerVert));
face2Normal.normalise();
// Each vertex needs a normal, which is the same for all three vertices in the triangle
for(int i = 0 ; i < 3; i++){
norms.add(face2Normal.x);
norms.add(face2Normal.y);
norms.add(face2Normal.z);
}
}
}
// Second corner
short secondCornerInd = (short) (verts.size()/3);
Vector3d secondCornerVert = new Vector3d((xSide+1)*xStep, heightMap[xSide+1][zSide], zSide * zStep)
Many terrain use similar ways to construct and generate their structure. Subtract 50 from like so "heightMap[xSide+1][zSide - 50.0f".... tell me what you see.
Many terrain use similar ways to construct and generate their structure. Subtract 50 from like so "heightMap[xSide+1][zSide - 50.0f".... tell me what you see.
This
Vector3d firstCornerVert = new Vector3d(xSide*xStep, heightMap[xSide][zSide] - 50.0f, zSide * zStep);
Vector3d secondCornerVert = new Vector3d((xSide+1)*xStep, heightMap[xSide+1][zSide] - 50.0f, zSide * zStep);
Vector3d thirdCornerVert = new Vector3d((xSide+1)*xStep, heightMap[xSide+1][zSide+1] - 50.0f, (zSide+1) * zStep);
Vector3d fourthCornerVert = new Vector3d((xSide)*xStep, heightMap[xSide][zSide+1] - 50.0f, (zSide+1) * zStep);
is what I assume you meant, but the entire terrain map was translated, the lighting issues remain. That is, the texture remains fully lit.
Here are some screens.
Lighting Enabled, with textures
Lighting Disabled, with textures
Lighting Enabled, no textures
Lighting Disabled, no textures
I understand the reason why the scene is uniform color, because the light position is behind me. But shouldn't there be a difference between lighting being enabled and disabled?!
Well, that's what I was about to do after finishing my particle system class. Oddly enough, after activating my particle system, lighting began working.
I'll update the thread when I isolate the problem. It's going to be something stupid and obvious in hindsight.
Well, that's what I was about to do after finishing my particle system class. Oddly enough, after activating my particle system, lighting began working.
I'll update the thread when I isolate the problem. It's going to be something stupid and obvious in hindsight.