Improve the light sample + tweaks
This commit is contained in:
parent
8654ff24a2
commit
fd3e7cde6c
|
@ -395,7 +395,7 @@ void _glCalculateLighting(EyeSpaceData* ES, Vertex* vertex) {
|
|||
const GLfloat k0 = light->constant_attenuation;
|
||||
const GLfloat k1 = light->linear_attenuation;
|
||||
const GLfloat k2 = light->quadratic_attenuation;
|
||||
const GLfloat att = (light->position[3] == 0) ? 1.0f : 1.0f / k0 + (k1 * VPpliL) + (k2 * VPpliL * VPpliL);
|
||||
const GLfloat att = (light->position[3] == 0.0f) ? 1.0f : 1.0f / (k0 + (k1 * VPpliL) + (k2 * VPpliL * VPpliL));
|
||||
const GLfloat spot = 1.0f; // FIXME: Spotlights
|
||||
|
||||
const GLfloat fi = (ndotVPpli == 0) ? 0 : 1;
|
||||
|
|
|
@ -171,6 +171,16 @@ void InitGL(int Width, int Height)
|
|||
glLightfv(GL_LIGHT0, GL_POSITION, position);
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
diffuseLight[1] = 1.0f;
|
||||
|
||||
glEnable(GL_LIGHT1);
|
||||
glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuseLight);
|
||||
glLightfv(GL_LIGHT1, GL_SPECULAR, specularLight);
|
||||
|
||||
glLightf(GL_LIGHT1, GL_CONSTANT_ATTENUATION, 1.0);
|
||||
glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, 4.5 / 100);
|
||||
glLightf(GL_LIGHT1, GL_QUADRATIC_ATTENUATION, 75.0f / (100 * 100));
|
||||
}
|
||||
|
||||
|
||||
|
@ -189,6 +199,14 @@ void ReSizeGLScene(int Width, int Height)
|
|||
}
|
||||
|
||||
void DrawCube(float x, float z) {
|
||||
static float pos = 0.0f;
|
||||
const static float radius = 30.0f;
|
||||
|
||||
pos += 0.001f;
|
||||
|
||||
GLfloat position[] = { cos(pos) * radius, 15.0f, sin(pos) * radius, 1.0f };
|
||||
glLightfv(GL_LIGHT1, GL_POSITION, position);
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(x, 0, z);
|
||||
glColor4f(1, 1, 1, 1);
|
||||
|
|
Loading…
Reference in New Issue
Block a user