Merge remote-tracking branch 'origin/master' into Sound+Particles
Conflicts: assets
This commit is contained in:
+1
-1
Submodule assets updated: a6e3f120fd...e09ebf5a29
+32
-29
@@ -513,12 +513,15 @@ void GameWorld::BindGamepadButton(Gamepad::Button button, std::string command, f
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
void GameWorld::CreateGate(glm::vec3 Position)
|
||||
void GameWorld::CreateGate(EntityID parent, glm::vec3 position, glm::quat orientation)
|
||||
{
|
||||
auto gateParent = CreateEntity(parent);
|
||||
auto transform = AddComponent<Components::Transform>(gateParent);
|
||||
transform->Position = position;
|
||||
transform->Orientation = orientation;
|
||||
{
|
||||
auto gateBase = CreateEntity();
|
||||
auto gateBase = CreateEntity(gateParent);
|
||||
auto transform = AddComponent<Components::Transform>(gateBase);
|
||||
transform->Position = Position;
|
||||
auto model = AddComponent<Components::Model>(gateBase);
|
||||
model->ModelFile = "Models/Gate/Lift/Lift.obj";
|
||||
auto physics = AddComponent<Components::Physics>(gateBase);
|
||||
@@ -577,10 +580,9 @@ void GameWorld::CreateGate(glm::vec3 Position)
|
||||
CommitEntity(gateBase);
|
||||
}
|
||||
|
||||
auto gate = CreateEntity(gateParent);
|
||||
{
|
||||
auto gate = CreateEntity();
|
||||
auto transform = AddComponent<Components::Transform>(gate);
|
||||
transform->Position = Position;
|
||||
auto model = AddComponent<Components::Model>(gate);
|
||||
model->ModelFile = "Models/Gate/Gate/Gate.obj";
|
||||
auto physics = AddComponent<Components::Physics>(gate);
|
||||
@@ -588,8 +590,8 @@ void GameWorld::CreateGate(glm::vec3 Position)
|
||||
physics->CollisionLayer = (int)Components::Physics::CollisionLayer::STATIC;
|
||||
auto move = AddComponent<Components::Move>(gate);
|
||||
move->Speed = 5.f;
|
||||
move->GoalPosition = glm::vec3(Position.x, Position.y + 9.02345f, Position.z);
|
||||
move->StartPosition = glm::vec3(Position.x, Position.y, Position.z);
|
||||
move->GoalPosition = glm::vec3(0, 9.02345f, 0);
|
||||
move->StartPosition = glm::vec3(0, 0, 0);
|
||||
{
|
||||
auto mainShape = CreateEntity(gate);
|
||||
auto transform = AddComponent<Components::Transform>(mainShape);
|
||||
@@ -611,29 +613,27 @@ void GameWorld::CreateGate(glm::vec3 Position)
|
||||
CommitEntity(lowerShape);
|
||||
}
|
||||
CommitEntity(gate);
|
||||
}
|
||||
|
||||
{
|
||||
auto gateTrigger = CreateEntity(gateParent);
|
||||
auto transform = AddComponent<Components::Transform>(gateTrigger);
|
||||
transform->Position = glm::vec3(0, 2.8241, 0);
|
||||
auto trigger = AddComponent<Components::Trigger>(gateTrigger);
|
||||
auto triggerMove = AddComponent<Components::TriggerMove>(gateTrigger);
|
||||
triggerMove->Entity = gate;
|
||||
|
||||
{
|
||||
auto gateTrigger = CreateEntity();
|
||||
auto transform = AddComponent<Components::Transform>(gateTrigger);
|
||||
transform->Position = glm::vec3(Position.x, Position.y + 2.8241, Position.z);
|
||||
auto trigger = AddComponent<Components::Trigger>(gateTrigger);
|
||||
auto triggerMove = AddComponent<Components::TriggerMove>(gateTrigger);
|
||||
triggerMove->Entity = gate;
|
||||
|
||||
|
||||
{
|
||||
auto shape = CreateEntity(gateTrigger);
|
||||
auto transform = AddComponent<Components::Transform>(shape);
|
||||
transform->Position = glm::vec3(0.f, 2.8241f, 0.f);
|
||||
auto box = AddComponent<Components::BoxShape>(shape);
|
||||
box->Width = 6.963f;
|
||||
box->Height = 3.104f;
|
||||
box->Depth = 10.356f;
|
||||
CommitEntity(shape);
|
||||
}
|
||||
CommitEntity(gateTrigger);
|
||||
auto shape = CreateEntity(gateTrigger);
|
||||
auto transform = AddComponent<Components::Transform>(shape);
|
||||
transform->Position = glm::vec3(0.f, 2.8241f, 0.f);
|
||||
auto box = AddComponent<Components::BoxShape>(shape);
|
||||
box->Width = 6.963f;
|
||||
box->Height = 3.104f;
|
||||
box->Depth = 10.356f;
|
||||
CommitEntity(shape);
|
||||
}
|
||||
|
||||
CommitEntity(gateTrigger);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -949,7 +949,7 @@ void GameWorld::CreateBase(glm::quat orientation, int playerID)
|
||||
auto base = CreateEntity();
|
||||
auto transform = AddComponent<Components::Transform>(base);
|
||||
transform->Orientation = orientation;
|
||||
|
||||
#pragma region Terrain
|
||||
{
|
||||
auto ground_small = CreateEntity(base);
|
||||
auto transform = AddComponent<Components::Transform>(ground_small);
|
||||
@@ -1012,7 +1012,7 @@ void GameWorld::CreateBase(glm::quat orientation, int playerID)
|
||||
auto shape = CreateEntity(bridge_middle);
|
||||
auto transformshape = AddComponent<Components::Transform>(shape);
|
||||
auto meshShape = AddComponent<Components::MeshShape>(shape);
|
||||
meshShape->ResourceName = "Models/TerrainFiveIstles/Bridges/MiddleBridge.obj";
|
||||
meshShape->ResourceName = "Models/TerrainFiveIstles/Bridges/MiddleBridgeCollision.obj";
|
||||
CommitEntity(shape);
|
||||
}
|
||||
CommitEntity(bridge_middle);
|
||||
@@ -1105,6 +1105,9 @@ void GameWorld::CreateBase(glm::quat orientation, int playerID)
|
||||
}
|
||||
CommitEntity(bridge_base);
|
||||
}
|
||||
#pragma endregion Terrain
|
||||
|
||||
CreateGate(base, glm::vec3(273.f, 40.185f, 0.06f), glm::quat(glm::vec3(0, glm::pi<float>() / 2.f, 0)));
|
||||
|
||||
CreateGarage(base, glm::vec3(323.2f, 41.4f, -10.2f), glm::quat(glm::vec3(0, glm::pi<float>() / 2.f, 0)), playerID);
|
||||
}
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ private:
|
||||
void BindGamepadAxis(Gamepad::Axis axis, std::string command, float value);
|
||||
void BindGamepadButton(Gamepad::Button button, std::string command, float value);
|
||||
|
||||
void CreateGate(glm::vec3 Position);
|
||||
void CreateGate(EntityID parent, glm::vec3 position, glm::quat orientation);
|
||||
void AddTankWheelPair(EntityID tankEntity, glm::vec3 position, int axleID, bool steering);
|
||||
EntityID CreateJeep(int playerID);
|
||||
EntityID CreateWall(glm::vec3 pos, glm::quat orientation);
|
||||
|
||||
+9
-6
@@ -93,7 +93,7 @@ Model::Model(std::shared_ptr<ResourceManager> rm, OBJ &obj)
|
||||
if (Vertices.size() > 0)
|
||||
{
|
||||
CreateTangents();
|
||||
//getSimilarVertexIndex();
|
||||
getSimilarVertexIndex();
|
||||
CreateBuffers(Vertices, Normals, TangentNormals, BiTangentNormals, TextureCoords);
|
||||
}
|
||||
else
|
||||
@@ -105,7 +105,7 @@ Model::Model(std::shared_ptr<ResourceManager> rm, OBJ &obj)
|
||||
void Model::CreateBuffers( std::vector<glm::vec3> vertices, std::vector<glm::vec3> normals, std::vector<glm::vec3> tangents, std::vector<glm::vec3> biTangents, std::vector<glm::vec2>textureCoords)
|
||||
{
|
||||
|
||||
LOG_INFO("Generating VertexBuffer");
|
||||
//LOG_INFO("Generating VertexBuffer");
|
||||
glGenBuffers(1, &VertexBuffer);
|
||||
if (vertices.size() > 0)
|
||||
{
|
||||
@@ -118,7 +118,7 @@ void Model::CreateBuffers( std::vector<glm::vec3> vertices, std::vector<glm::vec
|
||||
LOG_WARNING("Created empty vertex buffer!");
|
||||
}
|
||||
|
||||
LOG_INFO("Generating NormalBuffer");
|
||||
//LOG_INFO("Generating NormalBuffer");
|
||||
glGenBuffers(1, &NormalBuffer);
|
||||
if (normals.size() > 0)
|
||||
{
|
||||
@@ -131,7 +131,7 @@ void Model::CreateBuffers( std::vector<glm::vec3> vertices, std::vector<glm::vec
|
||||
LOG_WARNING("Created empty normal buffer!");
|
||||
}
|
||||
|
||||
LOG_INFO("Generating TangentNormalsBuffer");
|
||||
//LOG_INFO("Generating TangentNormalsBuffer");
|
||||
glGenBuffers(1, &TangentNormalsBuffer);
|
||||
if (tangents.size() > 0)
|
||||
{
|
||||
@@ -144,7 +144,7 @@ void Model::CreateBuffers( std::vector<glm::vec3> vertices, std::vector<glm::vec
|
||||
LOG_WARNING("Created empty tangent buffer!");
|
||||
}
|
||||
|
||||
LOG_INFO("Generating BiTangentNormalsBuffer");
|
||||
//LOG_INFO("Generating BiTangentNormalsBuffer");
|
||||
glGenBuffers(1, &BiTangentNormalsBuffer);
|
||||
if (biTangents.size() > 0)
|
||||
{
|
||||
@@ -158,7 +158,7 @@ void Model::CreateBuffers( std::vector<glm::vec3> vertices, std::vector<glm::vec
|
||||
}
|
||||
|
||||
|
||||
LOG_INFO("Generating textureCoordBuffer");
|
||||
//LOG_INFO("Generating textureCoordBuffer");
|
||||
glGenBuffers(1, &TextureCoordBuffer);
|
||||
if (textureCoords.size() > 0)
|
||||
{
|
||||
@@ -223,6 +223,8 @@ void Model::getSimilarVertexIndex()
|
||||
{
|
||||
glm::vec3 tempNormal, tempTangent, tempBiTangent;
|
||||
|
||||
if(glm::dot(Normals[i], Normals[t]) > 0)
|
||||
{
|
||||
tempNormal = Normals[i] + Normals[t];
|
||||
tempTangent = TangentNormals[i] + TangentNormals[t];
|
||||
tempBiTangent = BiTangentNormals[i] + BiTangentNormals[t];
|
||||
@@ -235,6 +237,7 @@ void Model::getSimilarVertexIndex()
|
||||
|
||||
BiTangentNormals[i] = tempBiTangent;
|
||||
BiTangentNormals[t] = tempBiTangent;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -13,7 +13,7 @@ bool OBJ::LoadFromFile(std::string filename)
|
||||
return false;
|
||||
}
|
||||
|
||||
LOG_INFO("Parsing .obj \"%s\"", m_Path.string().c_str());
|
||||
//LOG_INFO("Parsing .obj \"%s\"", m_Path.string().c_str());
|
||||
|
||||
std::string line;
|
||||
while (std::getline(file, line))
|
||||
@@ -121,7 +121,7 @@ void OBJ::ParseMaterial()
|
||||
return;
|
||||
}
|
||||
|
||||
LOG_INFO("Parsing .mtl \"%s\"", m_MaterialPath.string().c_str());
|
||||
//LOG_INFO("Parsing .mtl \"%s\"", m_MaterialPath.string().c_str());
|
||||
|
||||
std::string currentMaterialName;
|
||||
MaterialInfo* currentMaterial = nullptr;
|
||||
@@ -144,7 +144,7 @@ void OBJ::ParseMaterial()
|
||||
{
|
||||
MaterialInfo mat;
|
||||
ss >> currentMaterialName;
|
||||
LOG_INFO("Parsing material %s", currentMaterialName.c_str());
|
||||
//LOG_INFO("Parsing material %s", currentMaterialName.c_str());
|
||||
Materials[currentMaterialName] = mat;
|
||||
currentMaterial = &Materials[currentMaterialName];
|
||||
continue;
|
||||
|
||||
+108
-81
@@ -22,7 +22,7 @@ Renderer::Renderer(std::shared_ptr<::ResourceManager> resourceManager)
|
||||
LAtt = 0.0f;
|
||||
QAtt = 3.0f;
|
||||
m_ShadowMapRes = 1;
|
||||
m_SunPosition = glm::vec3(0.f, 1.0f, 0.5f);
|
||||
m_SunPosition = glm::vec3(0.f, 1.0f, 0.7f);
|
||||
m_SunTarget = glm::vec3(0, 0, 0);
|
||||
m_SunProjection_height = glm::vec2(-40.f, 40.f);
|
||||
m_SunProjection_width = glm::vec2(-40.f, 40.f);
|
||||
@@ -126,6 +126,7 @@ void Renderer::LoadContent()
|
||||
m_SunPassProgram.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/SunPass.vert.glsl")));
|
||||
m_SunPassProgram.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/SunPass.frag.glsl")));
|
||||
m_SunPassProgram.Compile();
|
||||
glBindFragDataLocation(m_SunPassProgram.GetHandle(), 0, "frag_Light");
|
||||
m_SunPassProgram.Link();
|
||||
|
||||
m_ForwardRendering.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ForwardRendering.vert.glsl")));
|
||||
@@ -142,7 +143,6 @@ void Renderer::LoadContent()
|
||||
m_FirstPassProgram.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Vertex.glsl")));
|
||||
m_FirstPassProgram.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Fragment.glsl")));
|
||||
m_FirstPassProgram.Compile();
|
||||
|
||||
glBindFragDataLocation(m_FirstPassProgram.GetHandle(), 0, "frag_Diffuse");
|
||||
glBindFragDataLocation(m_FirstPassProgram.GetHandle(), 1, "frag_Position");
|
||||
glBindFragDataLocation(m_FirstPassProgram.GetHandle(), 2, "frag_Normal");
|
||||
@@ -151,6 +151,7 @@ void Renderer::LoadContent()
|
||||
m_SecondPassProgram.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Vertex2.glsl")));
|
||||
m_SecondPassProgram.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Fragment2.glsl")));
|
||||
m_SecondPassProgram.Compile();
|
||||
glBindFragDataLocation(m_SecondPassProgram.GetHandle(), 0, "frag_Light");
|
||||
m_SecondPassProgram.Link();
|
||||
|
||||
m_SecondPassProgram_Debug.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Vertex2.glsl")));
|
||||
@@ -161,6 +162,7 @@ void Renderer::LoadContent()
|
||||
m_FinalPassProgram.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/FinalPass.vert.glsl")));
|
||||
m_FinalPassProgram.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/FinalPass.frag.glsl")));
|
||||
m_FinalPassProgram.Compile();
|
||||
glBindFragDataLocation(m_FinalPassProgram.GetHandle(), 0, "frag_Diffuse");
|
||||
m_FinalPassProgram.Link();
|
||||
m_ScreenQuad = CreateQuad();
|
||||
CreateShadowMap(m_ShadowMapRes);
|
||||
@@ -269,6 +271,7 @@ void Renderer::Draw(double dt)
|
||||
|
||||
void Renderer::DrawFrame(RenderQueuePair &rq)
|
||||
{
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glViewport(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height);
|
||||
glScissor(m_Scissor.X, m_Height - m_Scissor.Y - m_Scissor.Height, m_Scissor.Width, m_Scissor.Height);
|
||||
@@ -386,81 +389,78 @@ void Renderer::DrawWorld(RenderQueuePair &rq)
|
||||
rq.Forward.Jobs.sort(Renderer::DepthSort);
|
||||
|
||||
//DrawShadowMap(rq.Deferred);
|
||||
|
||||
/*
|
||||
Base pass
|
||||
Base pass
|
||||
*/
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbBasePass);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_fbBasePass);
|
||||
glViewport(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height);
|
||||
glScissor(m_Scissor.X, m_Height - m_Scissor.Y - m_Scissor.Height, m_Scissor.Width, m_Scissor.Height);
|
||||
//glViewport(0, 0, m_Width, m_Height);
|
||||
|
||||
// Clear G-buffer
|
||||
GLenum windowBuffClear[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 };
|
||||
glDrawBuffers(4, windowBuffClear);
|
||||
glClearColor(115.f / 255, 192.f / 255, 255.f / 255, 0.f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// Execute the first render stage which will fill out the internal buffers with data(??)
|
||||
m_FirstPassProgram.Bind();
|
||||
GLenum windowBuffOpaque[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 };
|
||||
glDrawBuffers(4, windowBuffOpaque);
|
||||
|
||||
glCullFace(GL_BACK);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
DrawSkybox();
|
||||
//DrawSkybox();
|
||||
|
||||
DrawFBOScene(rq.Deferred);
|
||||
|
||||
/*
|
||||
Lighting pass
|
||||
Lighting pass
|
||||
*/
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbLightingPass);
|
||||
//glBindFramebuffer(GL_FRAMEBUFFER, m_fbBasePass);
|
||||
glViewport(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height);
|
||||
glScissor(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height);
|
||||
GLenum lightingPassAttachments[] = { GL_COLOR_ATTACHMENT0 };
|
||||
glDrawBuffers(1, lightingPassAttachments);
|
||||
glScissor(m_Scissor.X, m_Height - m_Scissor.Y - m_Scissor.Height, m_Scissor.Width, m_Scissor.Height);
|
||||
|
||||
|
||||
glCullFace(GL_FRONT);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_ALPHA);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
|
||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
m_SecondPassProgram.Bind();
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, m_fPositionTexture);
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, m_fNormalsTexture);
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
glBindTexture(GL_TEXTURE_2D, m_fSpecularTexture);
|
||||
|
||||
glCullFace(GL_FRONT);
|
||||
DrawLightScene(rq.Deferred);
|
||||
glCullFace(GL_BACK);
|
||||
DrawSunLightScene();
|
||||
|
||||
/*
|
||||
Final pass
|
||||
Final pass
|
||||
*/
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
//glViewport(m_Viewport.X, m_Viewport.Y, m_Viewport.Width, m_Viewport.Height);
|
||||
glViewport(0, 0, m_Width, m_Height);
|
||||
//glScissor(0, 0, m_Width, m_Height);
|
||||
glScissor(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height);
|
||||
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_fbFinalPass);
|
||||
glViewport(0, 0, m_Width, m_Height);
|
||||
glScissor(0, 0, m_Width, m_Height);
|
||||
//glScissor(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||
|
||||
|
||||
|
||||
|
||||
m_FinalPassProgram.Bind();
|
||||
// Ambient light
|
||||
glUniform3fv(glGetUniformLocation(m_FinalPassProgram.GetHandle(), "La"), 1, glm::value_ptr(glm::vec3(1.0f)));
|
||||
//glUniform1f(glGetUniformLocation(m_FinalPassProgram.GetHandle(), "Gamma"), Gamma);
|
||||
|
||||
// Ambient light
|
||||
glUniform3fv(glGetUniformLocation(m_FinalPassProgram.GetHandle(), "La"), 1, glm::value_ptr(glm::vec3(0.7f)));
|
||||
glUniform1f(glGetUniformLocation(m_FinalPassProgram.GetHandle(), "Gamma"), Gamma);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, m_fDiffuseTexture);
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, m_fLightingTexture);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, m_fDiffuseTexture);
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, m_fLightingTexture);
|
||||
|
||||
glCullFace(GL_BACK);
|
||||
glBindVertexArray(m_ScreenQuad);
|
||||
glEnableVertexAttribArray(0);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
glCullFace(GL_BACK);
|
||||
glBindVertexArray(m_ScreenQuad);
|
||||
glEnableVertexAttribArray(0);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
|
||||
/*
|
||||
Transparency
|
||||
@@ -470,25 +470,23 @@ void Renderer::DrawWorld(RenderQueuePair &rq)
|
||||
|
||||
void Renderer::ForwardRendering(RenderQueue &rq)
|
||||
{
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbBasePass);
|
||||
|
||||
glViewport(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height);
|
||||
glScissor(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height);
|
||||
|
||||
// Clear G-buffer
|
||||
GLenum attachments[] = { GL_COLOR_ATTACHMENT0, GL_NONE , GL_NONE , GL_NONE };
|
||||
glDrawBuffers(4, attachments);
|
||||
//glClearColor(0.f, 0.f, 0.f, 1.f);
|
||||
//glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
|
||||
glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_BACK);
|
||||
|
||||
//glBindFramebuffer(GL_FRAMEBUFFER, m_fbBasePass);
|
||||
glViewport(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height);
|
||||
glScissor(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height);
|
||||
|
||||
// Clear G-buffer
|
||||
//GLenum attachments[] = { GL_COLOR_ATTACHMENT0, GL_NONE , GL_NONE, GL_NONE };
|
||||
//glDrawBuffers(4, attachments);
|
||||
//glClear(GL_COLOR_BUFFER_BIT);
|
||||
//glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||
|
||||
glm::mat4 cameraProjection = m_Camera->ProjectionMatrix((float)m_Viewport.Width / m_Viewport.Height);
|
||||
glm::mat4 cameraMatrix = cameraProjection * m_Camera->ViewMatrix();
|
||||
glm::mat4 MVP;
|
||||
@@ -497,7 +495,7 @@ void Renderer::ForwardRendering(RenderQueue &rq)
|
||||
GLuint ShaderProgramHandle = m_ForwardRendering.GetHandle();
|
||||
for (auto &job : rq)
|
||||
{
|
||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||
if (modelJob)
|
||||
{
|
||||
glm::mat4 modelMatrix = modelJob->ModelMatrix;
|
||||
@@ -508,12 +506,14 @@ void Renderer::ForwardRendering(RenderQueue &rq)
|
||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "P"), 1, GL_FALSE, glm::value_ptr(cameraProjection));
|
||||
glUniform4fv(glGetUniformLocation(ShaderProgramHandle, "Color"), 1, glm::value_ptr(modelJob->Color));
|
||||
glUniform3fv(glGetUniformLocation(ShaderProgramHandle, "La"), 1, glm::value_ptr(glm::vec3(1.0f)));
|
||||
glUniform3fv(glGetUniformLocation(ShaderProgramHandle, "directionToSun"), 1, glm::value_ptr(glm::normalize(m_SunPosition)));
|
||||
|
||||
glBindVertexArray(modelJob->VAO);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture);
|
||||
/*if (modelJob->NormalTexture != 0)
|
||||
if (modelJob->NormalTexture != 0)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
glBindTexture(GL_TEXTURE_2D, modelJob->NormalTexture);
|
||||
@@ -522,7 +522,7 @@ void Renderer::ForwardRendering(RenderQueue &rq)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE3);
|
||||
glBindTexture(GL_TEXTURE_2D, modelJob->SpecularTexture);
|
||||
}*/
|
||||
}
|
||||
glDrawArrays(GL_TRIANGLES, modelJob->StartIndex, modelJob->EndIndex - modelJob->StartIndex + 1);
|
||||
|
||||
continue;
|
||||
@@ -555,7 +555,8 @@ void Renderer::ForwardRendering(RenderQueue &rq)
|
||||
/*
|
||||
Final pass
|
||||
*/
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glViewport(0, 0, m_Width, m_Height);
|
||||
glScissor(0, 0, m_Width, m_Height);
|
||||
|
||||
@@ -571,7 +572,9 @@ void Renderer::ForwardRendering(RenderQueue &rq)
|
||||
//glUniform1f(glGetUniformLocation(ShaderProgramHandle, "Gamma"), Gamma);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, m_fDiffuseTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, m_fFinalDiffuseTexture);
|
||||
// glActiveTexture(GL_TEXTURE1);
|
||||
// glBindTexture(GL_TEXTURE_2D, m_fLightingTexture);
|
||||
|
||||
glCullFace(GL_BACK);
|
||||
glBindVertexArray(m_ScreenQuad);
|
||||
@@ -947,7 +950,7 @@ void Renderer::FrameBufferTextures()
|
||||
//Generate and bind diffuse texture
|
||||
glGenTextures(1, &m_fDiffuseTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, m_fDiffuseTexture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_Width, m_Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, m_Width, m_Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
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_WRAP_S, GL_REPEAT);
|
||||
@@ -999,6 +1002,9 @@ void Renderer::FrameBufferTextures()
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT3, GL_TEXTURE_2D, m_fSpecularTexture, 0);
|
||||
//glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT3, GL_TEXTURE_2D, m_fShadowTexture, 0);
|
||||
|
||||
GLenum FirstPass[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 };
|
||||
glDrawBuffers(4, FirstPass);
|
||||
|
||||
GLenum fbStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
if(fbStatus != GL_FRAMEBUFFER_COMPLETE)
|
||||
{
|
||||
@@ -1006,12 +1012,37 @@ void Renderer::FrameBufferTextures()
|
||||
//exit(1);
|
||||
}
|
||||
|
||||
m_fbFinalPass = 0;
|
||||
glGenFramebuffers(1, &m_fbFinalPass);
|
||||
glGenTextures(1, &m_fFinalDiffuseTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, m_fFinalDiffuseTexture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, m_Width, m_Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
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_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_fbFinalPass);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_fFinalDiffuseTexture, 0);
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_fDepthBuffer);
|
||||
|
||||
GLenum FinalPassAttachments[] = { GL_COLOR_ATTACHMENT0 };
|
||||
glDrawBuffers(1, FinalPassAttachments);
|
||||
|
||||
fbStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
if(fbStatus != GL_FRAMEBUFFER_COMPLETE)
|
||||
{
|
||||
LOG_ERROR("DeferredLighting:Init: m_fbLightingPass incomplete: 0x%x\n", fbStatus);
|
||||
//exit(1);
|
||||
}
|
||||
|
||||
|
||||
m_fbLightingPass = 0;
|
||||
glGenFramebuffers(1, &m_fbLightingPass);
|
||||
|
||||
glGenTextures(1, &m_fLightingTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, m_fLightingTexture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, m_Width, m_Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, m_Width, m_Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
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_WRAP_S, GL_REPEAT);
|
||||
@@ -1020,6 +1051,9 @@ void Renderer::FrameBufferTextures()
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_fbLightingPass);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_fLightingTexture, 0);
|
||||
|
||||
GLenum lightingPassAttachments[] = { GL_COLOR_ATTACHMENT0 };
|
||||
glDrawBuffers(1, lightingPassAttachments);
|
||||
|
||||
fbStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
if(fbStatus != GL_FRAMEBUFFER_COMPLETE)
|
||||
{
|
||||
@@ -1268,12 +1302,7 @@ void Renderer::DrawFBOScene(RenderQueue &rq)
|
||||
|
||||
void Renderer::DrawLightScene(RenderQueue &rq)
|
||||
{
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation (GL_FUNC_ADD);
|
||||
glBlendFunc(GL_ONE,GL_ONE);
|
||||
|
||||
glDisable (GL_DEPTH_TEST);
|
||||
glDepthMask (GL_FALSE);
|
||||
glBindVertexArray(m_sphereModel->VAO);
|
||||
|
||||
glm::mat4 cameraProjection = m_Camera->ProjectionMatrix((float)m_Viewport.Width / m_Viewport.Height);
|
||||
@@ -1284,6 +1313,13 @@ void Renderer::DrawLightScene(RenderQueue &rq)
|
||||
m_SecondPassProgram.Bind();
|
||||
GLuint ShaderProgramHandle = m_SecondPassProgram.GetHandle();
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, m_fPositionTexture);
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, m_fNormalsTexture);
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
glBindTexture(GL_TEXTURE_2D, m_fSpecularTexture);
|
||||
|
||||
for (auto &light : Lights)
|
||||
{
|
||||
MVP = cameraMatrix * light.SphereModelMatrix;
|
||||
@@ -1306,21 +1342,10 @@ void Renderer::DrawLightScene(RenderQueue &rq)
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, m_sphereModel->Vertices.size());
|
||||
};
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthMask(GL_TRUE);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
void Renderer::DrawSunLightScene()
|
||||
{
|
||||
glCullFace(GL_BACK);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glBlendFunc(GL_ONE,GL_ONE);
|
||||
|
||||
glDisable (GL_DEPTH_TEST);
|
||||
glDepthMask (GL_FALSE);
|
||||
//glBindVertexArray(m_sphereModel->VAO);
|
||||
|
||||
glm::mat4 cameraProjection = m_Camera->ProjectionMatrix((float)m_Viewport.Width / m_Viewport.Height);
|
||||
@@ -1330,6 +1355,12 @@ void Renderer::DrawSunLightScene()
|
||||
m_SunPassProgram.Bind();
|
||||
GLuint ShaderProgramHandle = m_SunPassProgram.GetHandle();
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, m_fPositionTexture);
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, m_fNormalsTexture);
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
glBindTexture(GL_TEXTURE_2D, m_fSpecularTexture);
|
||||
|
||||
glUniform2fv(glGetUniformLocation(ShaderProgramHandle, "ViewportSize"), 1, glm::value_ptr(glm::vec2(m_Width, m_Height)));
|
||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "MVP"), 1, GL_FALSE, glm::value_ptr(MVP));
|
||||
@@ -1341,10 +1372,6 @@ void Renderer::DrawSunLightScene()
|
||||
glBindVertexArray(m_ScreenQuad);
|
||||
glEnableVertexAttribArray(0);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
|
||||
glEnable (GL_DEPTH_TEST);
|
||||
glDepthMask (GL_TRUE);
|
||||
glDisable (GL_BLEND);
|
||||
}
|
||||
|
||||
void Renderer::SetSphereModel( Model* _model )
|
||||
|
||||
@@ -167,6 +167,10 @@ private:
|
||||
GLuint m_ShadowFrameBuffer;
|
||||
GLuint m_ShadowDepthTexture;
|
||||
|
||||
|
||||
GLuint m_fbFinalPass;
|
||||
GLuint m_fFinalDiffuseTexture;
|
||||
|
||||
GLuint m_fbBasePass;
|
||||
GLuint m_fDiffuseTexture;
|
||||
GLuint m_fPositionTexture;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#version 430
|
||||
|
||||
//uniform vec3 La;
|
||||
|
||||
layout (binding=0) uniform sampler2D DiffuseTexture;
|
||||
|
||||
@@ -15,11 +14,11 @@ out vec4 FragmentColor;
|
||||
void main()
|
||||
{
|
||||
vec4 DiffuseTexel = texture(DiffuseTexture, Input.TextureCoord);
|
||||
//vec4 LightingTexel = texture(LightingTexture, Input.TextureCoord);
|
||||
|
||||
//FragmentColor = LightingTexel + vec4(LightingTexel.a, LightingTexel.a, LightingTexel.a, 0.0);
|
||||
//FragmentColor = DiffuseTexel;
|
||||
|
||||
FragmentColor = DiffuseTexel;
|
||||
//FragmentColor = DiffuseTexel * (vec4(La, 0.0) + vec4(LightingTexel.rgb, 0.0)) + vec4(LightingTexel.a, LightingTexel.a, LightingTexel.a, 0.0);
|
||||
//FragmentColor = vec4(pow(_FragmentColor.rgb, vec3(1.0 / Gamma)), _FragmentColor.a);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
#version 430
|
||||
//Dicksdickdickdickssssss
|
||||
|
||||
uniform vec3 La;
|
||||
uniform float Gamma;
|
||||
|
||||
layout (binding=0) uniform sampler2D DiffuseTexture;
|
||||
layout (binding=1) uniform sampler2D LightingTexture;
|
||||
@@ -12,7 +12,7 @@ in VertexData
|
||||
vec2 TextureCoord;
|
||||
} Input;
|
||||
|
||||
out vec4 FragmentColor;
|
||||
out vec4 frag_Diffuse;
|
||||
|
||||
void main()
|
||||
{
|
||||
@@ -21,7 +21,12 @@ void main()
|
||||
|
||||
//FragmentColor = LightingTexel + vec4(LightingTexel.a, LightingTexel.a, LightingTexel.a, 0.0);
|
||||
//FragmentColor = DiffuseTexel;
|
||||
//FragmentColor = DiffuseTexel;
|
||||
//frag_Diffuse = vec4(LightingTexel.rgb, 0.0);
|
||||
|
||||
//frag_Diffuse = DiffuseTexel * ((vec4(LightingTexel.rgb, 0.0) + vec4(LightingTexel.a, LightingTexel.a, LightingTexel.a, 0.0)));
|
||||
frag_Diffuse = DiffuseTexel * (vec4(La, 0.0) * (vec4(LightingTexel.rgb, 0.0) + vec4(LightingTexel.a, LightingTexel.a, LightingTexel.a, 0.0)));
|
||||
//frag_Diffuse = LightingTexel;
|
||||
|
||||
FragmentColor = DiffuseTexel * (vec4(La, 0.0) + vec4(LightingTexel.rgb, 0.0)) + vec4(LightingTexel.a, LightingTexel.a, LightingTexel.a, 0.0);
|
||||
//FragmentColor = vec4(pow(_FragmentColor.rgb, vec3(1.0 / Gamma)), _FragmentColor.a);
|
||||
}
|
||||
@@ -1,8 +1,23 @@
|
||||
#version 430
|
||||
|
||||
uniform vec4 Color;
|
||||
uniform vec3 La;
|
||||
uniform vec3 directionToSun;
|
||||
uniform mat4 V;
|
||||
|
||||
layout(binding=0) uniform sampler2D texture0;
|
||||
layout(binding=1) uniform sampler2D PositionTexture;
|
||||
layout(binding=2) uniform sampler2D NormalsTexture;
|
||||
layout(binding=3) uniform sampler2D SpecularTexture;
|
||||
|
||||
const vec3 ks = 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 float kshine = 1.0;
|
||||
const vec3 SunDiffuseLight = vec3(1.0, 1.0, 1.0);
|
||||
const vec3 SunSpecularLight = vec3(1.0, 1.0, 1.0);
|
||||
const vec3 SunPos = directionToSun*vec3(100);
|
||||
const float specularExponent = 100;
|
||||
|
||||
in VertexData {
|
||||
vec3 Position;
|
||||
@@ -12,9 +27,34 @@ in VertexData {
|
||||
|
||||
out vec4 frag_Diffuse;
|
||||
|
||||
vec4 phong(vec3 position, vec3 normal, vec3 specular)
|
||||
{
|
||||
|
||||
//Diffuse Sunlight
|
||||
vec3 directionToLight = normalize(vec3(V * vec4(directionToSun, 0.0)));
|
||||
float dotProdLight = dot(directionToLight, normal);
|
||||
dotProdLight = max(dotProdLight, 0.0);
|
||||
vec3 sId = kd * SunDiffuseLight * dotProdLight;
|
||||
|
||||
//Specular Sunlight
|
||||
vec3 surfaceToViewer = normalize(-position);
|
||||
vec3 halfWay = normalize(surfaceToViewer + directionToLight);
|
||||
float dotSpecular = max(dot(halfWay, normal), 0.0);
|
||||
float specularFactorSun = pow(dotSpecular, specularExponent);
|
||||
vec3 sIs = specular.r * SunSpecularLight * specularFactorSun;
|
||||
|
||||
return vec4((sId), sIs.r);
|
||||
}
|
||||
|
||||
void main() {
|
||||
// Texture
|
||||
vec4 texel = texture(texture0, Input.TextureCoord);
|
||||
vec4 PositionTexel = texture(PositionTexture, Input.TextureCoord);
|
||||
vec4 NormalTexel = texture(NormalsTexture, Input.TextureCoord);
|
||||
vec4 SpecularTexel = texture(SpecularTexture, Input.TextureCoord);
|
||||
|
||||
|
||||
frag_Diffuse = texel * Color;
|
||||
//frag_Diffuse = texel * Color * (vec4(La, 0.0) * phong(vec3(PositionTexel), vec3(NormalTexel), vec3(SpecularTexel)));
|
||||
//frag_Diffuse = DiffuseTexel * (vec4(La, 0.0) * (vec4(LightingTexel.rgb, 0.0) + vec4(LightingTexel.a, LightingTexel.a, LightingTexel.a, 0.0)));
|
||||
|
||||
}
|
||||
@@ -24,6 +24,7 @@ const vec3 ks = 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 float kshine = 1.0;
|
||||
const vec3 La = vec3(0.3, 0.3, 0.3);
|
||||
|
||||
|
||||
in VertexData
|
||||
@@ -32,7 +33,7 @@ in VertexData
|
||||
vec2 TextureCoord;
|
||||
} Input;
|
||||
|
||||
out vec4 FragColor;
|
||||
out vec4 frag_Light;
|
||||
|
||||
vec4 phong(vec3 position, vec3 normal, vec3 specular)
|
||||
{
|
||||
@@ -67,6 +68,8 @@ void main()
|
||||
vec4 NormalTexel = texture(NormalsTexture, TextureCoord);
|
||||
vec4 SpecularTexel = texture(SpecularTexture, TextureCoord);
|
||||
|
||||
FragColor = phong(vec3(PositionTexel), vec3(NormalTexel), vec3(SpecularTexel));
|
||||
frag_Light = phong(vec3(PositionTexel), vec3(NormalTexel), vec3(SpecularTexel));
|
||||
//FragColor = DiffuseTexel * vec4(1.0/La, 0.0) * (vec4(La, 0.0) + vec4(LightTexel.rgb, 0.0) + vec4(LightTexel.a, LightTexel.a, LightTexel.a, 0.0));
|
||||
//FragColor = DiffuseTexel * (vec4(La, 0.0) + vec4(LightTexel.rgb, 0.0)) + vec4(LightTexel.a, LightTexel.a, LightTexel.a, 0.0);
|
||||
//FragColor = NormalTexel;
|
||||
}
|
||||
@@ -4,6 +4,7 @@ layout (binding=0) uniform sampler2D PositionTexture;
|
||||
layout (binding=1) uniform sampler2D NormalsTexture;
|
||||
layout (binding=2) uniform sampler2D SpecularTexture;
|
||||
|
||||
|
||||
uniform vec2 ViewportSize;
|
||||
uniform mat4 MVP;
|
||||
uniform mat4 M;
|
||||
@@ -16,10 +17,12 @@ const vec3 ks = 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 float kshine = 1.0;
|
||||
const vec3 SunDiffuseLight = vec3(0.3, 0.3, 0.3);
|
||||
const vec3 SunDiffuseLight = vec3(1.0, 1.0, 1.0);
|
||||
const vec3 SunSpecularLight = vec3(1.0, 1.0, 1.0);
|
||||
const vec3 SunPos = directionToSun*vec3(100);
|
||||
const float specularExponent = 5;
|
||||
const float specularExponent = 100;
|
||||
const vec3 La = vec3(0.3, 0.3, 0.3);
|
||||
|
||||
|
||||
|
||||
in VertexData
|
||||
@@ -28,7 +31,7 @@ in VertexData
|
||||
vec2 TextureCoord;
|
||||
} Input;
|
||||
|
||||
out vec4 FragColor;
|
||||
out vec4 frag_Light;
|
||||
|
||||
vec4 phong(vec3 position, vec3 normal, vec3 specular)
|
||||
{
|
||||
@@ -46,7 +49,7 @@ vec4 phong(vec3 position, vec3 normal, vec3 specular)
|
||||
float specularFactorSun = pow(dotSpecular, specularExponent);
|
||||
vec3 sIs = specular.r * SunSpecularLight * specularFactorSun;
|
||||
|
||||
return vec4((sId), sIs.r);
|
||||
return vec4((sId + La), sIs.r);
|
||||
}
|
||||
|
||||
void main()
|
||||
@@ -56,6 +59,8 @@ void main()
|
||||
vec4 NormalTexel = texture(NormalsTexture, TextureCoord);
|
||||
vec4 SpecularTexel = texture(SpecularTexture, TextureCoord);
|
||||
|
||||
FragColor = phong(vec3(PositionTexel), vec3(normalize(NormalTexel)), vec3(SpecularTexel));
|
||||
|
||||
frag_Light = phong(vec3(PositionTexel), vec3(NormalTexel), vec3(SpecularTexel));
|
||||
//FragColor = DiffuseTexel * (vec4(La, 0.0) * (vec4(LightTexel.rgb, 0.0) + vec4(LightTexel.a, LightTexel.a, LightTexel.a, 0.0)));
|
||||
//FragColor = NormalTexel;
|
||||
}
|
||||
@@ -60,7 +60,6 @@ void Systems::SoundSystem::Update(double dt)
|
||||
}
|
||||
//LOG_INFO("Antal emitters i listan: %i", m_Channels.size());
|
||||
|
||||
std::map<EntityID, FMOD_CHANNEL*>::iterator it;
|
||||
for(it = m_Channels.begin(); it != m_Channels.end();)
|
||||
{
|
||||
FMOD_BOOL isPlaying = false;
|
||||
|
||||
Reference in New Issue
Block a user