SceneLight component now working
This commit is contained in:
@@ -17,15 +17,13 @@ public:
|
||||
void InitializeFrameBuffers();
|
||||
void InitializeShaderPrograms();
|
||||
|
||||
void Draw(GLuint sceneTexture, GLuint bloomTexture);
|
||||
void Draw(GLuint sceneTexture, GLuint bloomTexture, GLfloat gamma, GLfloat exposure);
|
||||
private:
|
||||
const IRenderer* m_Renderer;
|
||||
|
||||
ShaderProgram* m_ColorCorrectionProgram;
|
||||
|
||||
Model* m_ScreenQuad;
|
||||
GLfloat m_Exposure = 1;
|
||||
GLfloat m_Gamma = 2.2;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -26,6 +26,7 @@ struct RenderScene
|
||||
std::list<std::shared_ptr<RenderJob>> DirectionalLightJobs;
|
||||
Rectangle Viewport;
|
||||
bool ClearDepth = false;
|
||||
glm::vec4 AmbientColor;
|
||||
|
||||
void Clear()
|
||||
{
|
||||
@@ -40,6 +41,9 @@ struct RenderScene
|
||||
struct RenderFrame
|
||||
{
|
||||
public:
|
||||
//TODO: Getters
|
||||
GLfloat Gamma = 2.2f;
|
||||
GLfloat Exposure = 1.f;
|
||||
|
||||
void Add(RenderScene &scene)
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity>
|
||||
<Entity name="Listener">
|
||||
<Components>
|
||||
<c:Camera/>
|
||||
<c:Listener/>
|
||||
@@ -43,7 +43,7 @@
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Position X="2.1529963" Y="6.59221172" Z="0.169116676"/>
|
||||
<Orientation X="4.16300011" Y="1885.31665" Z="0"/>
|
||||
<Orientation X="4.16300011" Y="1939.05518" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
@@ -85,7 +85,7 @@
|
||||
<Components>
|
||||
<c:Animation>
|
||||
<Name>Run</Name>
|
||||
<Time>0.33637802883706303</Time>
|
||||
<Time>0.20192568323882343</Time>
|
||||
<Speed>1</Speed>
|
||||
</c:Animation>
|
||||
<c:Model>
|
||||
@@ -101,7 +101,7 @@
|
||||
<Components>
|
||||
<c:Animation>
|
||||
<Name>Walk</Name>
|
||||
<Time>0.0036570774087083535</Time>
|
||||
<Time>0.86920473181046898</Time>
|
||||
<Speed>1</Speed>
|
||||
</c:Animation>
|
||||
<c:Model>
|
||||
@@ -163,7 +163,7 @@
|
||||
<Axis X="1" Y="1" Z="1"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="494.357269" Y="494.357269" Z="494.357269"/>
|
||||
<Orientation X="545.536804" Y="545.536804" Z="545.536804"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -227,7 +227,7 @@
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="290.653473" Z="0"/>
|
||||
<Orientation X="0" Y="341.83255" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -259,7 +259,7 @@
|
||||
<Axis X="0.699999988" Y="1" Z="0.300000012"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="712.485046" Y="1017.83423" Z="305.350739"/>
|
||||
<Orientation X="748.309875" Y="1069.01184" Z="320.704285"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -299,6 +299,13 @@
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
<Entity name="SceneColors">
|
||||
<Components>
|
||||
<c:SceneLight/>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
</Children>
|
||||
|
||||
</Entity>
|
||||
|
||||
@@ -7,6 +7,7 @@ uniform vec4 Color;
|
||||
uniform vec4 DiffuseColor;
|
||||
uniform vec2 ScreenDimensions;
|
||||
uniform vec4 FillColor;
|
||||
uniform vec4 AmbientColor;
|
||||
uniform float FillPercentage;
|
||||
layout (binding = 0) uniform sampler2D DiffuseTexture;
|
||||
layout (binding = 1) uniform sampler2D NormalMapTexture;
|
||||
@@ -60,8 +61,6 @@ in VertexData{
|
||||
out vec4 sceneColor;
|
||||
out vec4 bloomColor;
|
||||
|
||||
vec4 scene_ambient = vec4(0.3,0.3,0.3,1);
|
||||
|
||||
struct LightResult {
|
||||
vec4 Diffuse;
|
||||
vec4 Specular;
|
||||
@@ -128,7 +127,7 @@ void main()
|
||||
tilePos.y = int(gl_FragCoord.y/TILE_SIZE);
|
||||
|
||||
LightResult totalLighting;
|
||||
totalLighting.Diffuse = scene_ambient;
|
||||
totalLighting.Diffuse = AmbientColor;
|
||||
int currentTile = int(floor(gl_FragCoord.x/TILE_SIZE) + (floor(gl_FragCoord.y/TILE_SIZE) * int(ScreenDimensions.x/TILE_SIZE)));
|
||||
|
||||
int start = int(LightGrids.Data[currentTile].Start);
|
||||
|
||||
@@ -20,7 +20,7 @@ void DrawColorCorrectionPass::InitializeShaderPrograms()
|
||||
m_ColorCorrectionProgram->Link();
|
||||
}
|
||||
|
||||
void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture)
|
||||
void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture, GLfloat gamma, GLfloat exposure)
|
||||
{
|
||||
//glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
GLERROR("DrawScreenQuadPass::Draw: Pre");
|
||||
@@ -28,8 +28,8 @@ void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture)
|
||||
DrawScreenQuadPassState state = DrawScreenQuadPassState();
|
||||
m_ColorCorrectionProgram->Bind();
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glUniform1f(glGetUniformLocation(m_ColorCorrectionProgram->GetHandle(), "Exposure"), m_Exposure);
|
||||
glUniform1f(glGetUniformLocation(m_ColorCorrectionProgram->GetHandle(), "Gamma"), m_Gamma);
|
||||
glUniform1f(glGetUniformLocation(m_ColorCorrectionProgram->GetHandle(), "Exposure"), exposure);
|
||||
glUniform1f(glGetUniformLocation(m_ColorCorrectionProgram->GetHandle(), "Gamma"), gamma);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, sceneTexture);
|
||||
|
||||
@@ -141,18 +141,22 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
||||
glBindVertexArray(explosionEffectJob->Model->VAO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, explosionEffectJob->Model->ElementBuffer);
|
||||
glDrawElements(GL_TRIANGLES, explosionEffectJob->EndIndex - explosionEffectJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(explosionEffectJob->StartIndex*sizeof(unsigned int)));
|
||||
GLERROR("DrawFinalPass::Model: 1");
|
||||
|
||||
} else {
|
||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||
if (modelJob) {
|
||||
//bind forward program
|
||||
m_ForwardPlusProgram->Bind();
|
||||
GLERROR("DrawFinalPass::Model: 2");
|
||||
|
||||
//bind uniforms
|
||||
BindModelUniforms(forwardHandle, modelJob, scene);
|
||||
GLERROR("DrawFinalPass::Model: 3");
|
||||
|
||||
//bind textures
|
||||
BindModelTextures(modelJob);
|
||||
GLERROR("DrawFinalPass::Model: 4");
|
||||
|
||||
if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) {
|
||||
|
||||
@@ -161,6 +165,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
||||
glUniformMatrix4fv(glGetUniformLocation(forwardHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||
}
|
||||
}
|
||||
GLERROR("DrawFinalPass::Model: 5");
|
||||
|
||||
//draw
|
||||
glBindVertexArray(modelJob->Model->VAO);
|
||||
@@ -175,6 +180,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
||||
|
||||
void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene)
|
||||
{
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "AmbientColor"), 1, GL_FALSE, glm::value_ptr(scene.AmbientColor));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->Resolution().Width, m_Renderer->Resolution().Height);
|
||||
@@ -196,8 +202,10 @@ void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<E
|
||||
|
||||
void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr<ModelJob>& job, RenderScene& scene)
|
||||
{
|
||||
glUniform4fv(glGetUniformLocation(shaderHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
|
||||
glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->Resolution().Width, m_Renderer->Resolution().Height);
|
||||
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix));
|
||||
@@ -205,6 +213,7 @@ void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr<Model
|
||||
glUniform4fv(glGetUniformLocation(shaderHandle, "DiffuseColor"), 1, glm::value_ptr(job->DiffuseColor));
|
||||
glUniform4fv(glGetUniformLocation(shaderHandle, "FillColor"), 1, glm::value_ptr(job->FillColor));
|
||||
glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), job->FillPercentage);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -240,20 +240,17 @@ void RenderSystem::Update(double dt)
|
||||
m_Camera->SetOrientation(Transform::AbsoluteOrientation(m_CurrentCamera));
|
||||
}
|
||||
|
||||
|
||||
RenderScene scene;
|
||||
scene.Camera = m_Camera;
|
||||
scene.Viewport = Rectangle(1280, 720);
|
||||
|
||||
//auto cSceneLight = m_Renderer->m_World->GetComponents("SceneLight");
|
||||
//if (cSceneLight != nullptr) {
|
||||
// m_Gamma = (double)(*cSceneLight->begin())["Gamma"];
|
||||
// m_Exposure = (double)(*cSceneLight->begin())["Exposure"];
|
||||
//}
|
||||
auto cSceneLight = m_World->GetComponents("SceneLight");
|
||||
if (cSceneLight != nullptr) {
|
||||
m_RenderFrame->Gamma = (double)(*cSceneLight->begin())["Gamma"];
|
||||
m_RenderFrame->Exposure = (double)(*cSceneLight->begin())["Exposure"];
|
||||
scene.AmbientColor = (glm::vec4)(*cSceneLight->begin())["AmbientColor"];
|
||||
}
|
||||
|
||||
//scene.ambient
|
||||
//scene.gamma
|
||||
//scene.exponent
|
||||
fillModels(scene.OpaqueObjects, scene.TransparentObjects);
|
||||
fillPointLights(scene.PointLightJobs, m_World);
|
||||
fillDirectionalLights(scene.DirectionalLightJobs, m_World);
|
||||
|
||||
@@ -120,8 +120,8 @@ void Renderer::Draw(RenderFrame& frame)
|
||||
|
||||
}
|
||||
m_DrawBloomPass->Draw(m_DrawFinalPass->BloomTexture());
|
||||
if(m_DebugTextureToDraw == 0) {
|
||||
m_DrawColorCorrectionPass->Draw(m_DrawFinalPass->SceneTexture(), m_DrawBloomPass->GaussianTexture());
|
||||
if (m_DebugTextureToDraw == 0) {
|
||||
m_DrawColorCorrectionPass->Draw(m_DrawFinalPass->SceneTexture(), m_DrawBloomPass->GaussianTexture(), frame.Gamma, frame.Exposure);
|
||||
}
|
||||
if (m_DebugTextureToDraw == 1) {
|
||||
m_DrawScreenQuadPass->Draw(m_DrawFinalPass->SceneTexture());
|
||||
|
||||
Reference in New Issue
Block a user