Specular maps working.
This commit is contained in:
+143
-145
@@ -13,54 +13,54 @@ void GameWorld::Initialize()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
auto ground = CreateEntity();
|
auto ground = CreateEntity();
|
||||||
auto transform = AddComponent<Components::Transform>(ground, "Transform");
|
auto transform = AddComponent<Components::Transform>(ground, "Transform");
|
||||||
transform->Position = glm::vec3(0, -5, 0);
|
transform->Position = glm::vec3(0, -5, 0);
|
||||||
transform->Scale = glm::vec3(800.0f, 10.0f, 800.0f);
|
transform->Scale = glm::vec3(800.0f, 10.0f, 800.0f);
|
||||||
transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.0f));
|
transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.0f));
|
||||||
auto model = AddComponent<Components::Model>(ground, "Model");
|
auto model = AddComponent<Components::Model>(ground, "Model");
|
||||||
model->ModelFile = "Models/Placeholders/PhysicsTest/Cube.obj";
|
model->ModelFile = "Models/Placeholders/PhysicsTest/Cube.obj";
|
||||||
auto box = AddComponent<Components::Box>(ground, "Box");
|
auto box = AddComponent<Components::Box>(ground, "Box");
|
||||||
box->Width = 400;
|
box->Width = 400;
|
||||||
box->Height = 5;
|
box->Height = 5;
|
||||||
box->Depth = 400;
|
box->Depth = 400;
|
||||||
|
|
||||||
auto physics = AddComponent<Components::Physics>(ground, "Physics");
|
auto physics = AddComponent<Components::Physics>(ground, "Physics");
|
||||||
physics->Mass = 10;
|
physics->Mass = 10;
|
||||||
physics->Static = true;
|
physics->Static = true;
|
||||||
|
|
||||||
CommitEntity(ground);
|
CommitEntity(ground);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
auto jeep = CreateEntity();
|
auto jeep = CreateEntity();
|
||||||
auto transform = AddComponent<Components::Transform>(jeep, "Transform");
|
auto transform = AddComponent<Components::Transform>(jeep, "Transform");
|
||||||
transform->Position = glm::vec3(0, 2, 0);
|
transform->Position = glm::vec3(0, 2, 0);
|
||||||
|
|
||||||
auto physics = AddComponent<Components::Physics>(jeep, "Physics");
|
auto physics = AddComponent<Components::Physics>(jeep, "Physics");
|
||||||
physics->Mass = 1200;
|
physics->Mass = 1200;
|
||||||
auto box = AddComponent<Components::Box>(jeep, "Box");
|
auto box = AddComponent<Components::Box>(jeep, "Box");
|
||||||
box->Width = 1.487f;
|
box->Width = 1.487f;
|
||||||
box->Height = 0.727f;
|
box->Height = 0.727f;
|
||||||
box->Depth = 2.594f;
|
box->Depth = 2.594f;
|
||||||
auto vehicle = AddComponent<Components::Vehicle>(jeep, "Vehicle");
|
auto vehicle = AddComponent<Components::Vehicle>(jeep, "Vehicle");
|
||||||
|
|
||||||
AddComponent<Components::Input>(jeep, "Input");
|
AddComponent<Components::Input>(jeep, "Input");
|
||||||
|
|
||||||
for(int i = 0; i < 5; i++)
|
for(int i = 0; i < 1; i++)
|
||||||
{
|
{
|
||||||
auto Light = CreateEntity(jeep);
|
auto Light = CreateEntity(jeep);
|
||||||
auto transform = AddComponent<Components::Transform>(Light, "Transform");
|
auto transform = AddComponent<Components::Transform>(Light, "Transform");
|
||||||
transform->Position = glm::vec3((5+(i/2.f))*cos(i/5.0f), 0.3f, 0 + (5+(i/5.f))*sin(i/2.0f));
|
transform->Position = glm::vec3((5+(i/2.f))*cos(i/5.0f), 0.3f, 0 + (5+(i/5.f))*sin(i/2.0f));
|
||||||
auto light = AddComponent<Components::PointLight>(Light, "PointLight");
|
auto light = AddComponent<Components::PointLight>(Light, "PointLight");
|
||||||
light->Specular = glm::vec3(1.0f, 1.0f, 1.0f);
|
light->Specular = glm::vec3(1.0f, 1.0f, 1.0f);
|
||||||
light->Diffuse = glm::vec3((float)(rand()%255)/255.f, (float)(rand()%255)/255.f, (float)(rand()%255)/255.f);
|
light->Diffuse = glm::vec3(1.0f, 1.0f, 1.0f);
|
||||||
auto model = AddComponent<Components::Model>(Light, "Model");
|
auto model = AddComponent<Components::Model>(Light, "Model");
|
||||||
model->ModelFile = "Models/Placeholders/PhysicsTest/PointLight.obj";
|
model->ModelFile = "Models/Placeholders/PhysicsTest/PointLight.obj";
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto camera = CreateEntity();
|
auto camera = CreateEntity();
|
||||||
auto transform = AddComponent<Components::Transform>(camera, "Transform");
|
auto transform = AddComponent<Components::Transform>(camera, "Transform");
|
||||||
@@ -74,91 +74,91 @@ void GameWorld::Initialize()
|
|||||||
auto freeSteering = AddComponent<Components::FreeSteering>(camera, "FreeSteering");
|
auto freeSteering = AddComponent<Components::FreeSteering>(camera, "FreeSteering");
|
||||||
CommitEntity(camera);
|
CommitEntity(camera);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto chassis = CreateEntity(jeep);
|
||||||
|
auto transform = AddComponent<Components::Transform>(chassis, "Transform");
|
||||||
|
transform->Position = glm::vec3(0, -0.6577f, 0);
|
||||||
|
auto model = AddComponent<Components::Model>(chassis, "Model");
|
||||||
|
model->ModelFile = "Models/Jeep/Chassi/chassi.OBJ";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto chassis = CreateEntity(jeep);
|
auto wheel = CreateEntity(jeep);
|
||||||
auto transform = AddComponent<Components::Transform>(chassis, "Transform");
|
auto transform = AddComponent<Components::Transform>(wheel, "Transform");
|
||||||
transform->Position = glm::vec3(0, -0.6577f, 0);
|
transform->Position = glm::vec3(1.4f, 0.5546f - 0.6577f - 0.2, -0.9242f);
|
||||||
auto model = AddComponent<Components::Model>(chassis, "Model");
|
transform->Scale = glm::vec3(1.0f);
|
||||||
model->ModelFile = "Models/Jeep/Chassi/chassi.OBJ";
|
auto model = AddComponent<Components::Model>(wheel, "Model");
|
||||||
|
model->ModelFile = "Models/Jeep/WheelFront/wheelFront.obj";
|
||||||
|
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
|
||||||
|
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, 1.f, 0.f);
|
||||||
|
Wheel->AxleID = 0;
|
||||||
|
Wheel->Mass = 50;
|
||||||
|
Wheel->Radius = 0.837f;
|
||||||
|
Wheel->Steering = true;
|
||||||
|
Wheel->SuspensionStrength = 40.f;
|
||||||
|
Wheel->Friction = 4.0f;
|
||||||
|
Wheel->ConnectedToHandbrake = true;
|
||||||
|
CommitEntity(wheel);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
{
|
||||||
|
auto wheel = CreateEntity(jeep);
|
||||||
|
auto transform = AddComponent<Components::Transform>(wheel, "Transform");
|
||||||
|
transform->Position = glm::vec3(-1.4f, 0.5546f - 0.6577f - 0.2, -0.9242f);
|
||||||
|
transform->Scale = glm::vec3(1.0f);
|
||||||
|
transform->Orientation = glm::angleAxis(glm::pi<float>(), glm::vec3(0, 0, 1));
|
||||||
|
auto model = AddComponent<Components::Model>(wheel, "Model");
|
||||||
|
model->ModelFile = "Models/Jeep/WheelFront/wheelFront.obj";
|
||||||
|
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
|
||||||
|
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, 1.f, 0.f);
|
||||||
|
Wheel->AxleID = 0;
|
||||||
|
Wheel->Mass = 50;
|
||||||
|
Wheel->Radius = 0.837f;
|
||||||
|
Wheel->Steering = true;
|
||||||
|
Wheel->SuspensionStrength = 40.f;
|
||||||
|
Wheel->Friction = 4.0f;
|
||||||
|
Wheel->ConnectedToHandbrake = true;
|
||||||
|
CommitEntity(wheel);
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto wheel = CreateEntity(jeep);
|
auto wheel = CreateEntity(jeep);
|
||||||
auto transform = AddComponent<Components::Transform>(wheel, "Transform");
|
auto transform = AddComponent<Components::Transform>(wheel, "Transform");
|
||||||
transform->Position = glm::vec3(1.4f, 0.5546f - 0.6577f - 0.2, -0.9242f);
|
transform->Position = glm::vec3(0.2726f, 0.2805f - 0.6577f, 1.9307f);
|
||||||
transform->Scale = glm::vec3(1.0f);
|
auto model = AddComponent<Components::Model>(wheel, "Model");
|
||||||
auto model = AddComponent<Components::Model>(wheel, "Model");
|
model->ModelFile = "Models/Jeep/WheelBack/wheelBack.obj";
|
||||||
model->ModelFile = "Models/Jeep/WheelFront/wheelFront.obj";
|
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
|
||||||
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
|
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, 1.f, 0.f);
|
||||||
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, 1.f, 0.f);
|
Wheel->AxleID = 1;
|
||||||
Wheel->AxleID = 0;
|
Wheel->Mass = 10;
|
||||||
Wheel->Mass = 50;
|
Wheel->Radius = 0.737f;
|
||||||
Wheel->Radius = 0.837f;
|
Wheel->Steering = false;
|
||||||
Wheel->Steering = true;
|
Wheel->SuspensionStrength = 50.f;
|
||||||
Wheel->SuspensionStrength = 40.f;
|
Wheel->Friction = 4.0f;
|
||||||
Wheel->Friction = 4.0f;
|
CommitEntity(wheel);
|
||||||
Wheel->ConnectedToHandbrake = true;
|
}
|
||||||
CommitEntity(wheel);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
auto wheel = CreateEntity(jeep);
|
auto wheel = CreateEntity(jeep);
|
||||||
auto transform = AddComponent<Components::Transform>(wheel, "Transform");
|
auto transform = AddComponent<Components::Transform>(wheel, "Transform");
|
||||||
transform->Position = glm::vec3(-1.4f, 0.5546f - 0.6577f - 0.2, -0.9242f);
|
transform->Position = glm::vec3(-0.2726f, 0.2805f - 0.6577f, 1.9307f);
|
||||||
transform->Scale = glm::vec3(1.0f);
|
transform->Orientation = glm::angleAxis(glm::pi<float>(), glm::vec3(0, 0, 1));
|
||||||
transform->Orientation = glm::angleAxis(glm::pi<float>(), glm::vec3(0, 0, 1));
|
|
||||||
auto model = AddComponent<Components::Model>(wheel, "Model");
|
|
||||||
model->ModelFile = "Models/Jeep/WheelFront/wheelFront.obj";
|
|
||||||
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
|
|
||||||
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, 1.f, 0.f);
|
|
||||||
Wheel->AxleID = 0;
|
|
||||||
Wheel->Mass = 50;
|
|
||||||
Wheel->Radius = 0.837f;
|
|
||||||
Wheel->Steering = true;
|
|
||||||
Wheel->SuspensionStrength = 40.f;
|
|
||||||
Wheel->Friction = 4.0f;
|
|
||||||
Wheel->ConnectedToHandbrake = true;
|
|
||||||
CommitEntity(wheel);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
auto wheel = CreateEntity(jeep);
|
|
||||||
auto transform = AddComponent<Components::Transform>(wheel, "Transform");
|
|
||||||
transform->Position = glm::vec3(0.2726f, 0.2805f - 0.6577f, 1.9307f);
|
|
||||||
auto model = AddComponent<Components::Model>(wheel, "Model");
|
auto model = AddComponent<Components::Model>(wheel, "Model");
|
||||||
model->ModelFile = "Models/Jeep/WheelBack/wheelBack.obj";
|
model->ModelFile = "Models/Jeep/WheelBack/wheelBack.obj";
|
||||||
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
|
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
|
||||||
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, 1.f, 0.f);
|
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, 1.f, 0.f);
|
||||||
Wheel->AxleID = 1;
|
Wheel->AxleID = 1;
|
||||||
Wheel->Mass = 10;
|
Wheel->Mass = 10;
|
||||||
Wheel->Radius = 0.737f;
|
Wheel->Radius = 0.737f;
|
||||||
Wheel->Steering = false;
|
Wheel->Steering = false;
|
||||||
Wheel->SuspensionStrength = 50.f;
|
Wheel->SuspensionStrength = 50.f;
|
||||||
Wheel->Friction = 4.0f;
|
Wheel->Friction = 4.0f;
|
||||||
CommitEntity(wheel);
|
CommitEntity(wheel);
|
||||||
}
|
}
|
||||||
|
CommitEntity(jeep);
|
||||||
{
|
}
|
||||||
auto wheel = CreateEntity(jeep);
|
|
||||||
auto transform = AddComponent<Components::Transform>(wheel, "Transform");
|
|
||||||
transform->Position = glm::vec3(-0.2726f, 0.2805f - 0.6577f, 1.9307f);
|
|
||||||
transform->Orientation = glm::angleAxis(glm::pi<float>(), glm::vec3(0, 0, 1));
|
|
||||||
auto model = AddComponent<Components::Model>(wheel, "Model");
|
|
||||||
model->ModelFile = "Models/Jeep/WheelBack/wheelBack.obj";
|
|
||||||
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
|
|
||||||
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, 1.f, 0.f);
|
|
||||||
Wheel->AxleID = 1;
|
|
||||||
Wheel->Mass = 10;
|
|
||||||
Wheel->Radius = 0.737f;
|
|
||||||
Wheel->Steering = false;
|
|
||||||
Wheel->SuspensionStrength = 50.f;
|
|
||||||
Wheel->Friction = 4.0f;
|
|
||||||
CommitEntity(wheel);
|
|
||||||
}
|
|
||||||
CommitEntity(jeep);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
@@ -236,26 +236,24 @@ void GameWorld::Initialize()
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
for(int i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
for(int i = 0; i < 10; i++)
|
auto cube = CreateEntity();
|
||||||
{
|
auto transform = AddComponent<Components::Transform>(cube, "Transform");
|
||||||
auto cube = CreateEntity();
|
transform->Position = glm::vec3(20, 10 + i*2, 0);
|
||||||
auto transform = AddComponent<Components::Transform>(cube, "Transform");
|
//transform->Scale = glm::vec3(1);
|
||||||
transform->Position = glm::vec3(20, 10 + i*2, 0);
|
transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.0f));
|
||||||
//transform->Scale = glm::vec3(1);
|
auto model = AddComponent<Components::Model>(cube, "Model");
|
||||||
transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.0f));
|
model->ModelFile = "Models/Placeholders/PhysicsTest/Cube2.obj";
|
||||||
auto model = AddComponent<Components::Model>(cube, "Model");
|
|
||||||
model->ModelFile = "Models/Placeholders/PhysicsTest/Cube2.obj";
|
auto physics = AddComponent<Components::Physics>(cube, "Physics");
|
||||||
|
physics->Mass = 100;
|
||||||
auto physics = AddComponent<Components::Physics>(cube, "Physics");
|
auto box = AddComponent<Components::Box>(cube, "Box");
|
||||||
physics->Mass = 100;
|
box->Width = 0.5f;
|
||||||
auto box = AddComponent<Components::Box>(cube, "Box");
|
box->Height = 0.5f;
|
||||||
box->Width = 0.5f;
|
box->Depth = 0.5f;
|
||||||
box->Height = 0.5f;
|
CommitEntity(cube);
|
||||||
box->Depth = 0.5f;
|
}
|
||||||
CommitEntity(cube);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*{
|
/*{
|
||||||
auto entity = CreateEntity();
|
auto entity = CreateEntity();
|
||||||
|
|||||||
+16
-9
@@ -536,7 +536,7 @@ void Renderer::FrameBufferTextures()
|
|||||||
//Generate and bind position texture
|
//Generate and bind position texture
|
||||||
glGenTextures(1, &m_fPositionTexture);
|
glGenTextures(1, &m_fPositionTexture);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_fPositionTexture);
|
glBindTexture(GL_TEXTURE_2D, m_fPositionTexture);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, WIDTH, HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, WIDTH, HEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
@@ -545,7 +545,7 @@ void Renderer::FrameBufferTextures()
|
|||||||
//Generate and bind normal texture
|
//Generate and bind normal texture
|
||||||
glGenTextures(1, &m_fNormalsTexture);
|
glGenTextures(1, &m_fNormalsTexture);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_fNormalsTexture);
|
glBindTexture(GL_TEXTURE_2D, m_fNormalsTexture);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB10_A2, WIDTH, HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, WIDTH, HEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
@@ -554,7 +554,7 @@ void Renderer::FrameBufferTextures()
|
|||||||
//Generate and bind normal texture
|
//Generate and bind normal texture
|
||||||
glGenTextures(1, &m_fSpecularTexture);
|
glGenTextures(1, &m_fSpecularTexture);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_fSpecularTexture);
|
glBindTexture(GL_TEXTURE_2D, m_fSpecularTexture);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB10_A2, WIDTH, HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, WIDTH, HEIGHT, 0, GL_RED, GL_UNSIGNED_BYTE, NULL);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
@@ -621,15 +621,15 @@ void Renderer::DrawFBO()
|
|||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbBasePass);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbBasePass);
|
||||||
|
|
||||||
// Clear G-buffer
|
// Clear G-buffer
|
||||||
GLenum windowBuffClear[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 };
|
GLenum windowBuffClear[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 };
|
||||||
glDrawBuffers(3, windowBuffClear);
|
glDrawBuffers(4, windowBuffClear);
|
||||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
glClearColor(0.5f, 0.f, 0.f, 0.f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
// Execute the first render stage which will fill out the internal buffers with data(??)
|
// Execute the first render stage which will fill out the internal buffers with data(??)
|
||||||
m_FirstPassProgram.Bind();
|
m_FirstPassProgram.Bind();
|
||||||
GLenum windowBuffOpaque[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 };
|
GLenum windowBuffOpaque[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 };
|
||||||
glDrawBuffers(3, windowBuffOpaque);
|
glDrawBuffers(4, windowBuffOpaque);
|
||||||
|
|
||||||
glCullFace(GL_BACK);
|
glCullFace(GL_BACK);
|
||||||
|
|
||||||
@@ -651,6 +651,8 @@ void Renderer::DrawFBO()
|
|||||||
glBindTexture(GL_TEXTURE_2D, m_fPositionTexture);
|
glBindTexture(GL_TEXTURE_2D, m_fPositionTexture);
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_fNormalsTexture);
|
glBindTexture(GL_TEXTURE_2D, m_fNormalsTexture);
|
||||||
|
glActiveTexture(GL_TEXTURE2);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_fSpecularTexture);
|
||||||
|
|
||||||
glCullFace(GL_FRONT);
|
glCullFace(GL_FRONT);
|
||||||
DrawLightScene();
|
DrawLightScene();
|
||||||
@@ -664,7 +666,7 @@ void Renderer::DrawFBO()
|
|||||||
m_FinalPassProgram.Bind();
|
m_FinalPassProgram.Bind();
|
||||||
|
|
||||||
// Ambient light
|
// Ambient light
|
||||||
glUniform3fv(glGetUniformLocation(m_FinalPassProgram.GetHandle(), "La"), 1, glm::value_ptr(glm::vec3(0.1f, 0.1f, 0.1f)));
|
glUniform3fv(glGetUniformLocation(m_FinalPassProgram.GetHandle(), "La"), 1, glm::value_ptr(glm::vec3(0.4f, 0.4f, 0.4f)));
|
||||||
glUniform1f(glGetUniformLocation(m_FinalPassProgram.GetHandle(), "Gamma"), Gamma);
|
glUniform1f(glGetUniformLocation(m_FinalPassProgram.GetHandle(), "Gamma"), Gamma);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
@@ -728,6 +730,11 @@ void Renderer::DrawFBOScene()
|
|||||||
glActiveTexture(GL_TEXTURE2);
|
glActiveTexture(GL_TEXTURE2);
|
||||||
glBindTexture(GL_TEXTURE_2D, *texGroup.NormalMap);
|
glBindTexture(GL_TEXTURE_2D, *texGroup.NormalMap);
|
||||||
}
|
}
|
||||||
|
if (texGroup.SpecularMap)
|
||||||
|
{
|
||||||
|
glActiveTexture(GL_TEXTURE3);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, *texGroup.SpecularMap);
|
||||||
|
}
|
||||||
glDrawArrays(GL_TRIANGLES, texGroup.StartIndex, texGroup.EndIndex - texGroup.StartIndex + 1);
|
glDrawArrays(GL_TRIANGLES, texGroup.StartIndex, texGroup.EndIndex - texGroup.StartIndex + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,8 +22,10 @@ void main()
|
|||||||
vec4 ShadowTexel = texture(ShadowTexture, Input.TextureCoord);
|
vec4 ShadowTexel = texture(ShadowTexture, Input.TextureCoord);
|
||||||
|
|
||||||
|
|
||||||
vec4 _FragmentColor = DiffuseTexel * vec4(La, 1.0) + LightingTexel;
|
FragmentColor = DiffuseTexel * (LightingTexel + vec4(La, 0.0));
|
||||||
FragmentColor = vec4(pow(_FragmentColor.rgb, vec3(1.0 / Gamma)), _FragmentColor.a);
|
//FragmentColor = vec4(pow(_FragmentColor.rgb, vec3(1.0 / Gamma)), _FragmentColor.a);
|
||||||
|
|
||||||
|
//FragmentColor = DiffuseTexel;
|
||||||
//FragmentColor = DiffuseTexel;
|
//FragmentColor = DiffuseTexel;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -19,7 +19,7 @@ in VertexData
|
|||||||
out vec4 frag_Diffuse;
|
out vec4 frag_Diffuse;
|
||||||
out vec4 frag_Position;
|
out vec4 frag_Position;
|
||||||
out vec4 frag_Normal;
|
out vec4 frag_Normal;
|
||||||
out vec4 frag_specular;
|
out vec4 frag_Specular;
|
||||||
|
|
||||||
float Shadow(vec4 ShadowCoord)
|
float Shadow(vec4 ShadowCoord)
|
||||||
{
|
{
|
||||||
@@ -51,5 +51,5 @@ void main()
|
|||||||
//frag_Normal = vec4(Input.Normal, 0.0);
|
//frag_Normal = vec4(Input.Normal, 0.0);
|
||||||
|
|
||||||
//G-buffer Specular
|
//G-buffer Specular
|
||||||
frag_specular = texture(SpecularMapTexture, Input.TextureCoord);
|
frag_Specular = texture(SpecularMapTexture, Input.TextureCoord);
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
layout (binding=0) uniform sampler2D PositionTexture;
|
layout (binding=0) uniform sampler2D PositionTexture;
|
||||||
layout (binding=1) uniform sampler2D NormalsTexture;
|
layout (binding=1) uniform sampler2D NormalsTexture;
|
||||||
|
layout (binding=2) uniform sampler2D SpecularTexture;
|
||||||
|
|
||||||
uniform vec2 ViewportSize;
|
uniform vec2 ViewportSize;
|
||||||
uniform mat4 MVP;
|
uniform mat4 MVP;
|
||||||
@@ -22,6 +23,7 @@ const vec3 ks = vec3(1.0, 1.0, 1.0);
|
|||||||
const vec3 kd = vec3(1.0, 1.0, 1.0);
|
const vec3 kd = vec3(1.0, 1.0, 1.0);
|
||||||
const vec3 ka = vec3(1.0, 1.0, 1.0);
|
const vec3 ka = vec3(1.0, 1.0, 1.0);
|
||||||
const float kshine = 1.0;
|
const float kshine = 1.0;
|
||||||
|
const float LRadius = 5.0;
|
||||||
|
|
||||||
in VertexData
|
in VertexData
|
||||||
{
|
{
|
||||||
@@ -31,7 +33,7 @@ in VertexData
|
|||||||
|
|
||||||
out vec4 FragColor;
|
out vec4 FragColor;
|
||||||
|
|
||||||
vec4 phong(vec3 position, vec3 normal)
|
vec4 phong(vec3 position, vec3 normal, vec3 specular)
|
||||||
{
|
{
|
||||||
// Diffuse
|
// Diffuse
|
||||||
vec3 lightPos = vec3(V * vec4(lp, 1.0));
|
vec3 lightPos = vec3(V * vec4(lp, 1.0));
|
||||||
@@ -47,13 +49,15 @@ vec4 phong(vec3 position, vec3 normal)
|
|||||||
vec3 halfWay = normalize(surfaceToViewer + directionToLight);
|
vec3 halfWay = normalize(surfaceToViewer + directionToLight);
|
||||||
float dotSpecular = max(dot(halfWay, normal), 0.0);
|
float dotSpecular = max(dot(halfWay, normal), 0.0);
|
||||||
float specularFactor = pow(dotSpecular, specularExponent * 2.0);
|
float specularFactor = pow(dotSpecular, specularExponent * 2.0);
|
||||||
vec3 Is = ks * ls * specularFactor;
|
vec3 Is = specular.r * ls * specularFactor;
|
||||||
|
|
||||||
//Attenuation
|
//Attenuation
|
||||||
float dist = distance(lightPos, position);
|
float dist = distance(lightPos, position);
|
||||||
//float attenuation = -log(min(1.0, dist / LightRadius));
|
//float attenuation = -log(min(1.0, dist / LightRadius));
|
||||||
|
|
||||||
float attenuation = 1.0 / (ConstantAttenuation + (LinearAttenuation * dist) + (QuadraticAttenuation * dist * dist));
|
//float attenuation = 1.0 / (ConstantAttenuation + (LinearAttenuation * dist) + (QuadraticAttenuation * dist * dist));
|
||||||
|
|
||||||
|
float attenuation = pow(max(0.0f, 1.0 - (dist / LRadius)), 2);
|
||||||
|
|
||||||
//float attenuation = 1.0 / (1.0 - 0.0001 * pow(dist, 2));
|
//float attenuation = 1.0 / (1.0 - 0.0001 * pow(dist, 2));
|
||||||
|
|
||||||
@@ -79,7 +83,8 @@ void main()
|
|||||||
vec2 TextureCoord = gl_FragCoord.xy / ViewportSize;
|
vec2 TextureCoord = gl_FragCoord.xy / ViewportSize;
|
||||||
vec4 PositionTexel = texture(PositionTexture, TextureCoord);
|
vec4 PositionTexel = texture(PositionTexture, TextureCoord);
|
||||||
vec4 NormalTexel = texture(NormalsTexture, TextureCoord);
|
vec4 NormalTexel = texture(NormalsTexture, TextureCoord);
|
||||||
|
vec4 SpecularTexel = texture(SpecularTexture, TextureCoord);
|
||||||
|
|
||||||
FragColor = phong(vec3(PositionTexel), vec3(NormalTexel));
|
FragColor = phong(vec3(PositionTexel), vec3(NormalTexel), vec3(SpecularTexel));
|
||||||
//FragColor = NormalTexel;
|
//FragColor = NormalTexel;
|
||||||
}
|
}
|
||||||
@@ -39,4 +39,7 @@ Global
|
|||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
GlobalSection(Performance) = preSolution
|
||||||
|
HasPerformanceSessions = true
|
||||||
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
@@ -0,0 +1,89 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<VSPerformanceSession Version="1.00">
|
||||||
|
<Options>
|
||||||
|
<Solution>Returngeance.sln</Solution>
|
||||||
|
<CollectionMethod>Sampling</CollectionMethod>
|
||||||
|
<AllocationMethod>None</AllocationMethod>
|
||||||
|
<AddReport>true</AddReport>
|
||||||
|
<ResourceBasedAnalysisSelected>true</ResourceBasedAnalysisSelected>
|
||||||
|
<UniqueReport>Timestamp</UniqueReport>
|
||||||
|
<SamplingMethod>Cycles</SamplingMethod>
|
||||||
|
<CycleCount>10000000</CycleCount>
|
||||||
|
<PageFaultCount>10</PageFaultCount>
|
||||||
|
<SysCallCount>10</SysCallCount>
|
||||||
|
<SamplingCounter Name="" ReloadValue="00000000000f4240" DisplayName="" />
|
||||||
|
<RelocateBinaries>false</RelocateBinaries>
|
||||||
|
<HardwareCounters EnableHWCounters="false" />
|
||||||
|
<EtwSettings />
|
||||||
|
<PdhSettings>
|
||||||
|
<PdhCountersEnabled>false</PdhCountersEnabled>
|
||||||
|
<PdhCountersRate>500</PdhCountersRate>
|
||||||
|
<PdhCounters>
|
||||||
|
<PdhCounter>\Memory\Pages/sec</PdhCounter>
|
||||||
|
<PdhCounter>\PhysicalDisk(_Total)\Avg. Disk Queue Length</PdhCounter>
|
||||||
|
<PdhCounter>\Processor(_Total)\% Processor Time</PdhCounter>
|
||||||
|
</PdhCounters>
|
||||||
|
</PdhSettings>
|
||||||
|
</Options>
|
||||||
|
<ExcludeSmallFuncs>true</ExcludeSmallFuncs>
|
||||||
|
<InteractionProfilingEnabled>false</InteractionProfilingEnabled>
|
||||||
|
<JScriptProfilingEnabled>false</JScriptProfilingEnabled>
|
||||||
|
<PreinstrumentEvent>
|
||||||
|
<InstrEventExclude>false</InstrEventExclude>
|
||||||
|
</PreinstrumentEvent>
|
||||||
|
<PostinstrumentEvent>
|
||||||
|
<InstrEventExclude>false</InstrEventExclude>
|
||||||
|
</PostinstrumentEvent>
|
||||||
|
<Binaries>
|
||||||
|
<ProjBinary>
|
||||||
|
<Path>bin\Debug\Returngeance.exe</Path>
|
||||||
|
<ArgumentTimestamp>01/01/0001 00:00:00</ArgumentTimestamp>
|
||||||
|
<Instrument>true</Instrument>
|
||||||
|
<Sample>true</Sample>
|
||||||
|
<ExternalWebsite>false</ExternalWebsite>
|
||||||
|
<InteractionProfilingEnabled>false</InteractionProfilingEnabled>
|
||||||
|
<IsLocalJavascript>false</IsLocalJavascript>
|
||||||
|
<IsWindowsStoreApp>false</IsWindowsStoreApp>
|
||||||
|
<IsWWA>false</IsWWA>
|
||||||
|
<LaunchProject>true</LaunchProject>
|
||||||
|
<OverrideProjectSettings>false</OverrideProjectSettings>
|
||||||
|
<LaunchMethod>Executable</LaunchMethod>
|
||||||
|
<ExecutablePath>bin\Debug\Returngeance.exe</ExecutablePath>
|
||||||
|
<StartupDirectory>..\bin\Debug</StartupDirectory>
|
||||||
|
<Arguments>
|
||||||
|
</Arguments>
|
||||||
|
<NetAppHost>IIS</NetAppHost>
|
||||||
|
<NetBrowser>InternetExplorer</NetBrowser>
|
||||||
|
<ExcludeSmallFuncs>true</ExcludeSmallFuncs>
|
||||||
|
<JScriptProfilingEnabled>false</JScriptProfilingEnabled>
|
||||||
|
<PreinstrumentEvent>
|
||||||
|
<InstrEventExclude>false</InstrEventExclude>
|
||||||
|
</PreinstrumentEvent>
|
||||||
|
<PostinstrumentEvent>
|
||||||
|
<InstrEventExclude>false</InstrEventExclude>
|
||||||
|
</PostinstrumentEvent>
|
||||||
|
<ProjRef>{E8B4A2A2-882B-402A-98A7-8B4F7233C8B3}|Returngeance\Returngeance.vcxproj</ProjRef>
|
||||||
|
<ProjPath>Returngeance\Returngeance.vcxproj</ProjPath>
|
||||||
|
<ProjName>Returngeance</ProjName>
|
||||||
|
</ProjBinary>
|
||||||
|
</Binaries>
|
||||||
|
<Reports>
|
||||||
|
<Report>
|
||||||
|
<Path>Returngeance140519.vsp</Path>
|
||||||
|
</Report>
|
||||||
|
<Report>
|
||||||
|
<Path>Returngeance140519(1).vsp</Path>
|
||||||
|
</Report>
|
||||||
|
<Report>
|
||||||
|
<Path>Returngeance140519(2).vsp</Path>
|
||||||
|
</Report>
|
||||||
|
<Report>
|
||||||
|
<Path>Returngeance140519(3).vsp</Path>
|
||||||
|
</Report>
|
||||||
|
</Reports>
|
||||||
|
<Launches>
|
||||||
|
<ProjBinary>
|
||||||
|
<Path>:PB:{E8B4A2A2-882B-402A-98A7-8B4F7233C8B3}|Returngeance\Returngeance.vcxproj</Path>
|
||||||
|
</ProjBinary>
|
||||||
|
</Launches>
|
||||||
|
</VSPerformanceSession>
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user