Shadows are pretty much done.

This commit is contained in:
FakeShemp
2016-02-29 19:45:56 +01:00
parent 2ed5fad699
commit 0908be1e02
5 changed files with 26 additions and 19 deletions
@@ -19,12 +19,14 @@ struct DirectionalLightJob : RenderJob
Direction = glm::vec4(0,0,-1,0) * glm::inverse(Orientation);
Color = (glm::vec4)directionalLightComponent["Color"];
Intensity = (double)directionalLightComponent["Intensity"];
//TextureAlphaShadows = (bool)directionalLightComponent["TextureAlphaShadows"];
};
glm::quat Orientation;
glm::vec4 Direction;
glm::vec4 Color;
float Intensity;
bool TextureAlphaShadows = false;
void CalculateHash() override
{
@@ -2,5 +2,6 @@
<DirectionalLight xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="DirectionalLight.xsd">
<Color R="1" G="1" B="1" A="1"/>
<Intensity>0.8</Intensity>
<!--<TextureAlphaShadows>false</TextureAlphaShadows>-->
<Visible>true</Visible>
</DirectionalLight>
@@ -9,6 +9,7 @@
<xs:all>
<xs:element name="Color" type="t:Color" minOccurs="0"/>
<xs:element name="Intensity" type="t:double" minOccurs="0"/>
<!--<xs:element name="TextureAlphaShadows" type="t:bool" minOccurs="0"/>-->
<xs:element name="Visible" type="t:bool" minOccurs="0"/>
</xs:all>
</xs:complexType>
-1
View File
@@ -2,7 +2,6 @@
#define MAX_SPLITS 4
#define MIN_AMBIENT_LIGHT 0.3
#define SHADOW_STRENGTH 0.3 //Should be ambient
uniform mat4 M;
uniform mat4 V;
+22 -18
View File
@@ -254,28 +254,31 @@ void ShadowPass::Draw(RenderScene & scene)
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), modelJob->Color.a);
/*switch (modelJob->Type) {
case RawModel::MaterialType::SingleTextures:
case RawModel::MaterialType::Basic:
{
glActiveTexture(GL_TEXTURE24);
if (modelJob->DiffuseTexture.size() > 0 && modelJob->DiffuseTexture[0]->Texture != nullptr) {
glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture[0]->Texture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(modelJob->DiffuseTexture[0]->UVRepeat));
if (directionalLightJob->TextureAlphaShadows) {
switch (modelJob->Type) {
case RawModel::MaterialType::SingleTextures:
case RawModel::MaterialType::Basic:
{
glActiveTexture(GL_TEXTURE24);
if (modelJob->DiffuseTexture.size() > 0 && modelJob->DiffuseTexture[0]->Texture != nullptr) {
glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture[0]->Texture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(modelJob->DiffuseTexture[0]->UVRepeat));
}
else {
glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
}
break;
}
else {
case RawModel::MaterialType::SplatMapping:
{
glActiveTexture(GL_TEXTURE24);
glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
break;
}
}
break;
}
case RawModel::MaterialType::SplatMapping:
{
glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
break;
}
}*/
glBindVertexArray(modelJob->Model->VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
@@ -288,7 +291,8 @@ void ShadowPass::Draw(RenderScene & scene)
}
}
}
m_ShadowProgram->Unbind();
glActiveTexture(GL_TEXTURE24);
glDisable(GL_TEXTURE_2D);
glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
m_DepthBuffer.Unbind();
delete state;