Buggy transparent shadows.
Transparent textures might glow.
This commit is contained in:
@@ -62,6 +62,7 @@ private:
|
||||
GLuint m_DepthMap;
|
||||
FrameBuffer m_DepthBuffer;
|
||||
ShaderProgram* m_ShadowProgram;
|
||||
//ShaderProgram* m_TransparentShadowProgram;
|
||||
|
||||
std::array<glm::mat4, MAX_SPLITS> m_LightProjection;
|
||||
std::array<glm::mat4, MAX_SPLITS> m_LightView;
|
||||
@@ -74,6 +75,8 @@ private:
|
||||
float m_SplitWeight = 0.91f;
|
||||
|
||||
std::array<Frustum, MAX_SPLITS> m_shadowFrusta;
|
||||
|
||||
Texture* m_WhiteTexture = ResourceManager::Load<Texture>("Textures/Core/White.png");
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -568,8 +568,8 @@
|
||||
<Entity name="Cube1">
|
||||
<Components>
|
||||
<c:Model>
|
||||
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||
<Color A="0.2" B="0" G="1" R="0"/>
|
||||
<Resource>Models/BushAlive.mesh</Resource>
|
||||
<Color A="1" B="0" G="1" R="0"/>
|
||||
<Transparent>true</Transparent>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
|
||||
@@ -327,8 +327,8 @@ void main()
|
||||
totalLighting.Specular += light_result.Specular;
|
||||
}
|
||||
|
||||
totalLighting.Diffuse *= (1.5 + vec4(AmbientColor.rgb, 1.0)) - vec4(vec3(shadowFactor), 0.0);
|
||||
totalLighting.Specular *= (1.5 + vec4(AmbientColor.rgb, 1.0)) - vec4(vec3(shadowFactor), 0.0);
|
||||
totalLighting.Diffuse *= (1.0 + vec4(AmbientColor.rgba)) - vec4(vec3(shadowFactor), 0.0);
|
||||
totalLighting.Specular *= (1.0 + vec4(AmbientColor.rgba)) - vec4(vec3(shadowFactor), 0.0);
|
||||
|
||||
//LightResult getInformation;
|
||||
|
||||
|
||||
@@ -1,10 +1,24 @@
|
||||
#version 430
|
||||
|
||||
layout(location = 0 ) out float ShadowMap;
|
||||
#define ALPHA_CUTOFF 0.3
|
||||
|
||||
layout (binding = 12) uniform sampler2D DiffuseTexture;
|
||||
uniform float Alpha;
|
||||
|
||||
in VertexData{
|
||||
vec2 TextureCoordinate;
|
||||
}Input;
|
||||
|
||||
layout (location = 0) out float ShadowMap;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 diffuseTexel = texture(DiffuseTexture, Input.TextureCoordinate) * Alpha;
|
||||
|
||||
if (diffuseTexel.a < ALPHA_CUTOFF)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,9 +4,15 @@ uniform mat4 M;
|
||||
uniform mat4 V;
|
||||
uniform mat4 P;
|
||||
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout (location = 0) in vec3 Position;
|
||||
layout (location = 4) in vec2 TextureCoords;
|
||||
|
||||
out VertexData{
|
||||
vec2 TextureCoordinate;
|
||||
}Output;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = P * V * M * vec4(Position, 1.0);
|
||||
Output.TextureCoordinate = TextureCoords;
|
||||
}
|
||||
@@ -68,14 +68,6 @@ void Renderer::InitializeShaders()
|
||||
{
|
||||
m_BasicForwardProgram = ResourceManager::Load<ShaderProgram>("#m_BasicForwardProgram");
|
||||
m_ExplosionEffectProgram = ResourceManager::Load<ShaderProgram>("#ExplosionEffectProgram");
|
||||
//m_ExplosionEffectProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ExplosionEffect.vert.glsl")));
|
||||
//m_ExplosionEffectProgram->AddShader(std::shared_ptr<Shader>(new GeometryShader("Shaders/ExplosionEffect.geom.glsl")));
|
||||
//m_ExplosionEffectProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ExplosionEffect.frag.glsl")));
|
||||
//m_ExplosionEffectProgram->Compile();
|
||||
//m_ExplosionEffectProgram->Link();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Renderer::InputUpdate(double dt)
|
||||
@@ -93,7 +85,7 @@ void Renderer::Update(double dt)
|
||||
|
||||
void Renderer::Draw(RenderFrame& frame)
|
||||
{
|
||||
ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0Gaussian\0Picking\0Shadow");
|
||||
ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0Gaussian\0Picking");
|
||||
//clear buffer 0
|
||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
@@ -147,6 +147,8 @@ void ShadowPass::InitializeShaderPrograms()
|
||||
m_ShadowProgram->Compile();
|
||||
m_ShadowProgram->BindFragDataLocation(0, "ShadowMap");
|
||||
m_ShadowProgram->Link();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ShadowPass::ClearBuffer()
|
||||
@@ -241,6 +243,15 @@ void ShadowPass::Draw(RenderScene & scene)
|
||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(objectJob);
|
||||
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||
glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), modelJob->Color.a);
|
||||
|
||||
glActiveTexture(GL_TEXTURE12);
|
||||
if (modelJob->DiffuseTexture != nullptr) {
|
||||
glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture->m_Texture);
|
||||
}
|
||||
else {
|
||||
glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture);
|
||||
}
|
||||
|
||||
glBindVertexArray(modelJob->Model->VAO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||
|
||||
@@ -9,6 +9,8 @@ ShadowPassState::ShadowPassState(GLuint frameBuffer)
|
||||
Disable(GL_TEXTURE_2D);
|
||||
CullFace(GL_FRONT);
|
||||
ClearColor(glm::vec4(0.f, 0.f, 0.f, 0.f));
|
||||
//Enable(GL_ALPHA_TEST);
|
||||
//glAlphaFunc(GL_GREATER, 0.9f);
|
||||
}
|
||||
|
||||
ShadowPassState::~ShadowPassState()
|
||||
|
||||
Reference in New Issue
Block a user