Transparancy now working for forward rendering

This commit is contained in:
tleety
2015-09-15 13:20:01 +02:00
parent b9eda67a2a
commit c5bbcec5dc
3 changed files with 10 additions and 6 deletions
+3 -3
View File
@@ -355,7 +355,7 @@ public:
glm::mat4 modelMatrix = glm::translate(absoluteTransform.Position) glm::mat4 modelMatrix = glm::translate(absoluteTransform.Position)
* glm::toMat4(orientation2D) * glm::toMat4(orientation2D)
* glm::scale(absoluteTransform.Scale); * glm::scale(absoluteTransform.Scale);
EnqueueSprite(texturediff, texturenorm, texturespec, modelMatrix, spriteComponent->Color); EnqueueSprite(texturediff, texturenorm, texturespec, modelMatrix, spriteComponent->Color, absoluteTransform.Position.z);
} }
} }
@@ -386,7 +386,7 @@ public:
} }
// TODO: Get this out of engine.h // TODO: Get this out of engine.h
void EnqueueSprite(Texture* texture, Texture* normalTexture, Texture* specularTexture, glm::mat4 modelMatrix, glm::vec4 color) void EnqueueSprite(Texture* texture, Texture* normalTexture, Texture* specularTexture, glm::mat4 modelMatrix, glm::vec4 color, float depth)
{ {
SpriteJob job; SpriteJob job;
job.TextureID = texture->ResourceID; job.TextureID = texture->ResourceID;
@@ -395,7 +395,7 @@ public:
job.SpecularTexture = *specularTexture; job.SpecularTexture = *specularTexture;
job.ModelMatrix = modelMatrix; job.ModelMatrix = modelMatrix;
job.Color = color; job.Color = color;
job.Depth = (glm::vec4(1,1,1,0) * modelMatrix).z; job.Depth = depth;
m_RendererQueue.Forward.Add(job); m_RendererQueue.Forward.Add(job);
+4 -1
View File
@@ -209,7 +209,6 @@ void dd::Renderer::Draw(RenderQueueCollection& rq)
{ {
//DrawDeferred(rq.Deferred, rq.Lights); //DrawDeferred(rq.Deferred, rq.Lights);
rq.Forward.Jobs.sort(dd::Renderer::DepthSort); rq.Forward.Jobs.sort(dd::Renderer::DepthSort);
DrawForward(rq.Forward, rq.Lights); DrawForward(rq.Forward, rq.Lights);
@@ -313,6 +312,10 @@ void dd::Renderer::DrawScene(RenderQueue &objects, ShaderProgram &program)
glUniformMatrix4fv(glGetUniformLocation(shaderProgramHandle, "MVP"), 1, GL_FALSE, glm::value_ptr(MVP)); glUniformMatrix4fv(glGetUniformLocation(shaderProgramHandle, "MVP"), 1, GL_FALSE, glm::value_ptr(MVP));
glUniformMatrix4fv(glGetUniformLocation(shaderProgramHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelMatrix)); glUniformMatrix4fv(glGetUniformLocation(shaderProgramHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelMatrix));
glUniformMatrix4fv(glGetUniformLocation(shaderProgramHandle, "V"), 1, GL_FALSE, glm::value_ptr(viewMatrix)); glUniformMatrix4fv(glGetUniformLocation(shaderProgramHandle, "V"), 1, GL_FALSE, glm::value_ptr(viewMatrix));
glUniform3fv(glGetUniformLocation(shaderProgramHandle, "LightPosition"), 1, glm::value_ptr(glm::vec3(0.f,0.f,-9.f)));
glUniform3fv(glGetUniformLocation(shaderProgramHandle, "LightSpecular"), 1, glm::value_ptr(glm::vec3(1.f)));
glUniform3fv(glGetUniformLocation(shaderProgramHandle, "LightDiffuse"), 1, glm::value_ptr(glm::vec3(1.f)));
glUniform1f(glGetUniformLocation(shaderProgramHandle, "LightRadius"), 40.0f);
glUniform1f(glGetUniformLocation(shaderProgramHandle, "MaterialShininess"), modelJob->Shininess); glUniform1f(glGetUniformLocation(shaderProgramHandle, "MaterialShininess"), modelJob->Shininess);
+3 -2
View File
@@ -83,7 +83,8 @@ void main()
vec4 specularTexel = texture(SpecularMap, Input.TextureCoord); vec4 specularTexel = texture(SpecularMap, Input.TextureCoord);
vec4 diffuseTexel = texture(DiffuseTexture, Input.TextureCoord); vec4 diffuseTexel = texture(DiffuseTexture, Input.TextureCoord);
vec4 La = vec4(0.3, 0.3, 0.3, 1.0);
//frag_Diffuse = phong(Input.Position, normalize(normal), specularTexel.rgb, specularTexel.a); vec4 light = phong(Input.Position, normalize(normal), specularTexel.rgb, specularTexel.a);
//frag_Diffuse = light;
frag_Diffuse = diffuseTexel; frag_Diffuse = diffuseTexel;
} }