I am currently working on adding lighting to my project and am still at the basics (getting everything to render properly) with lighting. I am using LWJGL (Java) on a Windows 7 machine, more detailed information at the bottom.
So the issue is, when trying to create a spotlight with a cutoff (limited angle affected by the light) I get very hard edges, almost like stairs, as seen in this picture:
[ATTACH=CONFIG]980[/ATTACH]
There is no ambient light (using
glLightModel(GL_LIGHT_MODEL_AMBIENT, colorToFloatBuffer(new Color(0.0f, 0.0f, 0.0f, 1.0f)))
) and I also disabled spot exponent (specifies how the light is distributed in the cone) and all attenuations to make the effect clearer and the background is a big white image (made black by the lack of ambient light; I am also wondering why I even need ot use an image at all in order to see the light).
And that is obviously not what it is supposed to look like (it should be a triangle-like shape, right?) and I have no idea why. Additionally, I scale the context before rendering anything in order to maintain using orhtographic coordinates in a perspective (GLUT) view for visual effects.
This is how I setup my light:
glEnable(GL_LIGHTING);
glEnable(GL_COLOR_MATERIAL);
glLight(glLightID, GL_AMBIENT, colorToFloatBuffer(Color.blue));
glLight(glLightID, GL_DIFFUSE, colorToFloatBuffer(Color.black));
glLight(glLightID, GL_SPECULAR, colorToFloatBuffer(Color.black));
glLight(glLightID, GL_POSITION, floatBuffer.put(position.x).put(position.y).put(0.0f).put(1.0f));
glLight(glLightID, GL_SPOT_DIRECTION, otherFloatBuffer.put(1.0f, 0.0f, 0.0f));
glLightf(glLightID, GL_SPOT_EXPONENT, lightSource.getSpotExponent());
glLightf(glLightID, GL_SPOT_CUTOFF, 22.5f);
glLightf(glLightID, GL_CONSTANT_ATTENUATION, 1.0f);
glLightf(glLightID, GL_LINEAR_ATTENUATION, 0.0f);
glLightf(glLightID, GL_QUADRATIC_ATTENUATION, 0.0f);
Also, the Form Posting Guide told me to post specific information about the system I am using, so here it goes:
OS: Windows 7 | OS_VERSION: 6.1
JAVA_VERSION: 1.7.0_71
LWJGL_VERSION: 2.9.0
GL_VERSION: 4.3.0
GL_VENDOR: NVIDIA Corporation
GL_RENDERER: GeForce GTX 560 Ti/PCIe/SSE2
Thanks for any help in advance.