"Better" lighting and stuff

This commit is contained in:
2014-03-14 03:35:52 +01:00
parent 9f2334bcb6
commit 2d5ba34a1a
6 changed files with 29 additions and 21 deletions
+12 -10
View File
@@ -38,19 +38,21 @@ void GameWorld::Initialize()
pointLight->quadraticAttenuation = 0.f;
pointLight->spotExponent = 0.0f;
model = AddComponent<Components::Model>(ent, "Model");
model->ModelFile = "Models/sphere.obj";
model->ModelFile = "Models/sphere.obj";*/
ent = CreateEntity();
SetProperty(ent, "Name", std::string("Sun"));
transform = AddComponent<Components::Transform>(ent, "Transform");
transform->Position = glm::vec3(-10.f, 7.f, 0.f);
transform->Position = glm::vec3(0.f, 100.f, 30.f);
AddComponent<Components::Input>(ent, "Input");
pointLight = AddComponent<Components::PointLight>(ent, "PointLight");
pointLight->Specular = glm::vec3(1.0, 1.0, 1.0);
pointLight->Diffuse = glm::vec3(5.0, 0.0, 0.0);
pointLight->constantAttenuation = 0.f;
pointLight->linearAttenuation = 1.f;
pointLight->quadraticAttenuation = 0.f;
pointLight->Diffuse = glm::vec3(1.0, 0.45, 0.0);
pointLight->constantAttenuation = 0.009f;
pointLight->linearAttenuation = -0.0177f;
pointLight->quadraticAttenuation = 0.00043f;
pointLight->spotExponent = 0.0f;
model = AddComponent<Components::Model>(ent, "Model");
model->ModelFile = "Models/sphere.obj";*/
model->ModelFile = "Models/sphere.obj";
//ground
ent = CreateEntity();
@@ -94,7 +96,7 @@ void GameWorld::Initialize()
transform->Position = glm::vec3(1.5f, 0.25f, 2.5f);
pointLight = AddComponent<Components::PointLight>(playerLight, "PointLight");
pointLight->Specular = glm::vec3(0.1f, 0.1f, 0.1f);
pointLight->Diffuse = glm::vec3(0.45f, 0.65f, 1.f);
pointLight->Diffuse = glm::vec3(0.05f, 0.36f, 1.f);
pointLight->constantAttenuation = 0.f;
pointLight->linearAttenuation = 0.9f;
pointLight->quadraticAttenuation = 0.f;
@@ -106,7 +108,7 @@ void GameWorld::Initialize()
transform->Position = glm::vec3(-1.5f, 0.25f, 2.5f);
pointLight = AddComponent<Components::PointLight>(playerLight, "PointLight");
pointLight->Specular = glm::vec3(0.1f, 0.1f, 0.1f);
pointLight->Diffuse = glm::vec3(0.45f, 0.65f, 1.f);
pointLight->Diffuse = glm::vec3(0.05f, 0.36f, 1.f);
pointLight->constantAttenuation = 0.f;
pointLight->linearAttenuation = 0.9f;
pointLight->quadraticAttenuation = 0.f;
@@ -118,7 +120,7 @@ void GameWorld::Initialize()
transform->Position = glm::vec3(0.0f, 2.0f, 2.5f);
pointLight = AddComponent<Components::PointLight>(playerLight, "PointLight");
pointLight->Specular = glm::vec3(0.1f, 0.1f, 0.1f);
pointLight->Diffuse = glm::vec3(0.45f, 0.65f, 1.f);
pointLight->Diffuse = glm::vec3(0.05f, 0.36f, 1.f);
pointLight->constantAttenuation = 0.f;
pointLight->linearAttenuation = 1.0f;
pointLight->quadraticAttenuation = 0.f;
+7 -5
View File
@@ -13,10 +13,10 @@ Renderer::Renderer()
m_DrawBounds = false;
#endif
m_ShadowMapRes = 2048*2;
m_ShadowMapRes = 2048*8;
m_SunPosition = glm::vec3(0, 1.5f, 10);
m_SunTarget = glm::vec3(0, 0, 0);
m_SunProjection = glm::ortho<float>(-200, 200, -10, 100, -800, 800);
m_SunProjection = glm::ortho<float>(-200, 200, -100, 400, -800, 600);
Lights = 0;
}
@@ -29,8 +29,9 @@ void Renderer::Initialize()
}
// Create a window
WIDTH = 1280;
HEIGHT = 720;
WIDTH = 1920;
HEIGHT = 1080;
glfwWindowHint(GLFW_SAMPLES, 16);
m_Window = glfwCreateWindow(WIDTH, HEIGHT, "OpenGL", nullptr, nullptr);
if (!m_Window) {
LOG_ERROR("GLFW: Failed to create window");
@@ -308,7 +309,7 @@ void Renderer::DrawShadowMap()
void Renderer::DrawDebugShadowMap()
{
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glViewport(0, 0, 200*(16.f/9.f), 200);
glViewport(0, 0, 400, 400);
glClear(GL_DEPTH_BUFFER_BIT);
//glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
@@ -525,4 +526,5 @@ void Renderer::ClearStuff()
Light_linearAttenuation.clear();
Light_quadraticAttenuation.clear();
Light_spotExponent.clear();
Lights = 0;
}
+1 -1
View File
@@ -23,7 +23,7 @@ in VertexData {
vec3 ShadowCoord;
} Input;
vec3 scene_ambient = vec3(0.98, 0.95, 0.7);
vec3 scene_ambient = vec3(0.5, 0.5, 0.5);
out vec4 fragmentColor;
@@ -25,14 +25,13 @@ void Systems::LevelGenerationSystem::SpawnObstacle()
auto model = m_World->AddComponent<Components::Model>(ent, "Model");
auto sound = m_World->AddComponent<Components::SoundEmitter>(ent, "SoundEmitter");
positionRandom = -500 + startx + (rand() % 1000);
transform->Position = glm::vec3(positionRandom, startyz);
transform->Velocity = glm::vec3(0.f, 10.f, 0);
transform->Velocity = glm::vec3(0.f, 30.f, 0);
sound->Loop = true;
sound->Gain = 1.f;
sound->ReferenceDistance = 4.f;
sound->ReferenceDistance = 0.5f;
m_World->GetSystem<Systems::SoundSystem>("SoundSystem")->PlaySound(sound, "Sounds/hum.wav");
if(typeRandom >= 0 && typeRandom < 1) // Mountain stuff :D
@@ -77,7 +76,7 @@ void Systems::LevelGenerationSystem::SpawnObstacle()
// Put it below ground level
transform->Position.y -= bounds->VolumeVector.y * 2.f;
transform->Position.y -= transform->Scale.y * bounds->VolumeVector.y * 2.f;
}
+5
View File
@@ -63,6 +63,11 @@ bool World::ValidEntity(EntityID entity)
void World::RemoveEntity(EntityID entity)
{
m_EntitiesToRemove.push_back(entity);
for (auto pair : m_EntityParents) {
if (pair.second == entity) {
m_EntitiesToRemove.push_back(pair.first);
}
}
}
void World::ProcessEntityRemovals()