The shadows are working
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#define MAX_SPLITS 4
|
#define MAX_SPLITS 4
|
||||||
#define MIN_AMBIENT_LIGHT 0.3
|
#define MIN_AMBIENT_LIGHT 0.3
|
||||||
|
#define SHADOW_STRENGTH 0.3 //Should be ambient
|
||||||
|
|
||||||
uniform mat4 M;
|
uniform mat4 M;
|
||||||
uniform mat4 V;
|
uniform mat4 V;
|
||||||
@@ -235,7 +236,7 @@ float CalcShadowValue(vec4 light_space_pos, vec3 normal, vec3 light_dir, sampler
|
|||||||
//shadowMapDepth = PoissonDotShadow(depth_texture_array, projCoords, layer_index, 4, 25.0 * FarDistance[MAX_SPLITS - 1]);
|
//shadowMapDepth = PoissonDotShadow(depth_texture_array, projCoords, layer_index, 4, 25.0 * FarDistance[MAX_SPLITS - 1]);
|
||||||
shadowMapDepth = SoftwarePCF(depth_texture_array, projCoords, layer_index, bias);
|
shadowMapDepth = SoftwarePCF(depth_texture_array, projCoords, layer_index, bias);
|
||||||
|
|
||||||
return 1.0 - shadowMapDepth;
|
return shadowMapDepth;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getShadowIndex(float far_distance[1])
|
int getShadowIndex(float far_distance[1])
|
||||||
@@ -342,8 +343,8 @@ void main()
|
|||||||
totalLighting.Specular += vec4(light_result.Specular.rgb * ao, light_result.Specular.a);
|
totalLighting.Specular += vec4(light_result.Specular.rgb * ao, light_result.Specular.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
totalLighting.Diffuse *= (1.5 + vec4(AmbientColor.rgba)) - vec4(vec3(shadowFactor), 0.0);
|
totalLighting.Diffuse *= vec4(min(vec3(shadowFactor) + AmbientColor.xyz, vec3(1.0)), 1.0);
|
||||||
totalLighting.Specular *= (1.5 + vec4(AmbientColor.rgba)) - vec4(vec3(shadowFactor), 0.0);
|
totalLighting.Specular *= vec4(min(vec3(shadowFactor) + AmbientColor.xyz, vec3(1.0)), 1.0);
|
||||||
|
|
||||||
//LightResult getInformation;
|
//LightResult getInformation;
|
||||||
|
|
||||||
|
|||||||
@@ -25,14 +25,6 @@ out VertexData{
|
|||||||
vec4 PositionLightSpace[MAX_SPLITS];
|
vec4 PositionLightSpace[MAX_SPLITS];
|
||||||
}Output;
|
}Output;
|
||||||
|
|
||||||
// N
|
|
||||||
mat4 biasMatrix = mat4(
|
|
||||||
vec4(0.5, 0.0, 0.0, 0.0),
|
|
||||||
vec4(0.0, 0.5, 0.0, 0.0),
|
|
||||||
vec4(0.0, 0.0, 0.5, 0.0),
|
|
||||||
vec4(0.5, 0.5, 0.5, 1.0)
|
|
||||||
);
|
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = P*V*M * vec4(Position, 1.0);
|
gl_Position = P*V*M * vec4(Position, 1.0);
|
||||||
|
|||||||
@@ -1014,6 +1014,14 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptr<Model
|
|||||||
glBindTexture(GL_TEXTURE_2D, m_BlackTexture->m_Texture);
|
glBindTexture(GL_TEXTURE_2D, m_BlackTexture->m_Texture);
|
||||||
glUniform2fv(glGetUniformLocation(shaderHandle, "GlowUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
|
glUniform2fv(glGetUniformLocation(shaderHandle, "GlowUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE6);
|
||||||
|
if (m_ShadowPass->DepthMap() != NULL) {
|
||||||
|
glBindTexture(GL_TEXTURE_2D_ARRAY, m_ShadowPass->DepthMap());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
glBindTexture(GL_TEXTURE_2D_ARRAY, m_WhiteTexture->m_Texture);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case RawModel::MaterialType::SplatMapping:
|
case RawModel::MaterialType::SplatMapping:
|
||||||
@@ -1081,15 +1089,5 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptr<Model
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE4);
|
|
||||||
if (m_ShadowPass->DepthMap() != NULL) {
|
|
||||||
glBindTexture(GL_TEXTURE_2D_ARRAY, m_ShadowPass->DepthMap());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
glBindTexture(GL_TEXTURE_2D_ARRAY, m_WhiteTexture->m_Texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -253,8 +253,8 @@ void ShadowPass::Draw(RenderScene & scene)
|
|||||||
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||||
glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), modelJob->Color.a);
|
glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), modelJob->Color.a);
|
||||||
|
|
||||||
switch (modelJob->Type) {
|
/*switch (modelJob->Type) {
|
||||||
case RawModel::MaterialType::SingleTextures:
|
case RawModel::MaterialType::SingleTextures:
|
||||||
case RawModel::MaterialType::Basic:
|
case RawModel::MaterialType::Basic:
|
||||||
{
|
{
|
||||||
@@ -275,7 +275,7 @@ void ShadowPass::Draw(RenderScene & scene)
|
|||||||
glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
|
glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
glBindVertexArray(modelJob->Model->VAO);
|
glBindVertexArray(modelJob->Model->VAO);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||||
|
|||||||
Reference in New Issue
Block a user