Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/render/draw.cc32
-rw-r--r--src/render/render.cc6
-rw-r--r--src/render/state.cc9
3 files changed, 35 insertions, 12 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 2236d8c..0f39385 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -62,14 +62,25 @@ void pass_reset_lights()
{
// lighting settings for the default light GL_LIGHT0
GLfloat light_position[] = { 0.0, 0.0, 0.0, 1.0 };
- GLfloat ambient_light[] = { r_ambient->value(), r_ambient->value(), r_ambient->value(), 1.0f };
- GLfloat diffuse_light[] = { r_diffuse->value(), r_diffuse->value(), r_diffuse->value(), 1.0f };
- GLfloat specular_light[] = { r_specular->value(), r_specular->value(), r_specular->value(), 1.0f };
+ GLfloat ambient_light[4];
+ GLfloat diffuse_light[4];
+ GLfloat specular_light[4];
for (size_t i = 0; i < 3; i++) {
light_position[i] = Camera::eye()[i];
+ ambient_light[i] = r_ambient->value();
+ diffuse_light[i] = r_diffuse->value();
+ specular_light[i] = r_specular->value();
}
+ ambient_light[3] = 1.0;
+ diffuse_light[3] = 1.0;
+ specular_light[3] = 1.0;
+
+ glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 2);
+ glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 1);
+ glLightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, 0.5);
+
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_light);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_light);
@@ -127,21 +138,28 @@ void pass_prepare(float seconds)
// bright globes set level light
GLfloat diffuse_light[4];
- GLfloat ambient_light[] = { 0.0f, 0.0f, 0.0f, 1.0f };
- GLfloat specular_light[] = { r_specular->value(), r_specular->value(), r_specular->value(), 1.0f };
+ GLfloat ambient_light[4];
+ GLfloat specular_light[4];
for (size_t i = 0; i < 3; i++) {
zone_light[i] = globe->location()[i];
zone_color[i] = globe->color()[i];
- diffuse_light[i] = globe->color()[i] * (r_diffuse->value() * 2);
+ ambient_light[i] = globe->color()[i] * (r_ambient->value() * 0.1);
+ diffuse_light[i] = globe->color()[i] * (r_diffuse->value() * 0.8);
+ specular_light[i] = globe->color()[i] * (r_specular->value() * 0.4);
}
zone_light[3] = 1.0f;
+ ambient_light[3] = 1.0f;
diffuse_light[3] = 1.0f;
+ specular_light[3] = 1.0f;
+
+ glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, 0.0001);
glLightfv(GL_LIGHT1, GL_POSITION, zone_light);
glLightfv(GL_LIGHT1, GL_AMBIENT, ambient_light);
glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse_light);
glLightfv(GL_LIGHT1, GL_SPECULAR, specular_light);
+
gl::enable(GL_LIGHT1);
has_zone_light = true;
}
@@ -329,7 +347,7 @@ void draw_globe(const core::EntityGlobe* globe)
gl::enable(GL_TEXTURE_2D);
}
- // draw the globe an apply rotation if required
+ // draw the globe and apply rotation if required
gl::push();
gl::translate(location);
gl::multmatrix(globe->axis());
diff --git a/src/render/render.cc b/src/render/render.cc
index 3d538da..dae1cf5 100644
--- a/src/render/render.cc
+++ b/src/render/render.cc
@@ -102,13 +102,13 @@ void init(int width, int height)
r_lights = core::Cvar::get("r_lights", "1", core::Cvar::Archive);
r_lights->set_info("[bool] render lights");
- r_ambient = core::Cvar::get("r_ambient", "0.1", core::Cvar::Archive);
+ r_ambient = core::Cvar::get("r_ambient", "1.0", core::Cvar::Archive);
r_ambient->set_info("[float] ambient light intensity");
- r_diffuse = core::Cvar::get("r_diffuse", "0.2", core::Cvar::Archive);
+ r_diffuse = core::Cvar::get("r_diffuse", "1.0", core::Cvar::Archive);
r_diffuse->set_info("[float] diffuse light intensity");
- r_specular = core::Cvar::get("r_specular", "0.2", core::Cvar::Archive);
+ r_specular = core::Cvar::get("r_specular", "1.0", core::Cvar::Archive);
r_specular->set_info("[float] specular light intensity");
r_physics = core::Cvar::get("r_physics", "0", core::Cvar::Archive);
diff --git a/src/render/state.cc b/src/render/state.cc
index dbcb276..538d784 100644
--- a/src/render/state.cc
+++ b/src/render/state.cc
@@ -136,13 +136,18 @@ void State::clear()
gl::shademodel(GL_SMOOTH);
//gl::shademodel(GL_FLAT);
+ // lighting model
+ GLfloat global_ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
+ glLightModelfv(GL_LIGHT_MODEL_AMBIENT, global_ambient);
+ glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
+
// color tracking
glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
// material settings
- GLfloat specular_reflectance[] = { 0.2f, 0.2f, 0.2f, 1.0f };
+ GLfloat specular_reflectance[] = { 1.0f, 1.0f, 1.0f, 1.0f };
glMaterialfv(GL_FRONT, GL_SPECULAR, specular_reflectance);
- glMateriali(GL_FRONT, GL_SHININESS, 128); // shininess 1-128
+ glMateriali(GL_FRONT, GL_SHININESS, 8); // shininess 1-128
// alpha blending function
gl::blendfunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);