No shadows and no skybox.
This commit is contained in:
+87
-48
@@ -45,16 +45,22 @@ void GameWorld::Initialize()
|
|||||||
|
|
||||||
RegisterComponents();
|
RegisterComponents();
|
||||||
|
|
||||||
//auto camera = CreateEntity();
|
auto camera = CreateEntity();
|
||||||
//{
|
{
|
||||||
// auto transform = AddComponent<Components::Transform>(camera);
|
auto transform = AddComponent<Components::Transform>(camera);
|
||||||
// transform->Position.z = 20.f;
|
transform->Position.z = 20.f;
|
||||||
// transform->Position.y = 20.f;
|
transform->Position.y = 20.f;
|
||||||
// //transform->Orientation = glm::quat(glm::vec3(glm::pi<float>() / 8.f, 0.f, 0.f));
|
//transform->Orientation = glm::quat(glm::vec3(glm::pi<float>() / 8.f, 0.f, 0.f));
|
||||||
// auto cameraComp = AddComponent<Components::Camera>(camera);
|
auto cameraComp = AddComponent<Components::Camera>(camera);
|
||||||
// cameraComp->FarClip = 2000.f;
|
cameraComp->FarClip = 2000.f;
|
||||||
// auto freeSteering = AddComponent<Components::FreeSteering>(camera);
|
auto freeSteering = AddComponent<Components::FreeSteering>(camera);
|
||||||
//}
|
}
|
||||||
|
{
|
||||||
|
Events::SetViewportCamera e;
|
||||||
|
e.CameraEntity = camera;
|
||||||
|
e.ViewportFrame = "Viewport2";
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
auto player1 = CreateEntity();
|
auto player1 = CreateEntity();
|
||||||
@@ -70,32 +76,71 @@ void GameWorld::Initialize()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//{
|
||||||
|
// auto ground = CreateEntity();
|
||||||
|
// auto transform = AddComponent<Components::Transform>(ground);
|
||||||
|
// transform->Position = glm::vec3(0, -50, 0);
|
||||||
|
// //transform->Scale = glm::vec3(400.0f, 10.0f, 400.0f);
|
||||||
|
// transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.0f));
|
||||||
|
// auto model = AddComponent<Components::Model>(ground);
|
||||||
|
// model->ModelFile = "Models/TestScene3/testScene.obj";
|
||||||
|
// //model->ModelFile = "Models/Placeholders/Terrain/Terrain2.obj";
|
||||||
|
//
|
||||||
|
// auto physics = AddComponent<Components::Physics>(ground);
|
||||||
|
// physics->Mass = 10;
|
||||||
|
// physics->Static = true;
|
||||||
|
|
||||||
|
|
||||||
|
// auto groundshape = CreateEntity(ground);
|
||||||
|
// auto transformshape = AddComponent<Components::Transform>(groundshape);
|
||||||
|
// auto meshShape = AddComponent<Components::MeshShape>(groundshape);
|
||||||
|
// //meshShape->ResourceName = "Models/Placeholders/Terrain/Terrain2.obj";
|
||||||
|
// meshShape->ResourceName = "Models/TestScene3/testScene.obj";
|
||||||
|
|
||||||
|
//
|
||||||
|
// CommitEntity(groundshape);
|
||||||
|
// CommitEntity(ground);
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
auto ground = CreateEntity();
|
auto ground = CreateEntity();
|
||||||
auto transform = AddComponent<Components::Transform>(ground);
|
auto transform = AddComponent<Components::Transform>(ground);
|
||||||
transform->Position = glm::vec3(0, -50, 0);
|
transform->Position = glm::vec3(0, -5, 0);
|
||||||
//transform->Scale = glm::vec3(400.0f, 10.0f, 400.0f);
|
transform->Scale = glm::vec3(1600.0f, 10.0f, 1600.0f);
|
||||||
transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.0f));
|
transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.0f));
|
||||||
auto model = AddComponent<Components::Model>(ground);
|
auto model = AddComponent<Components::Model>(ground);
|
||||||
model->ModelFile = "Models/TestScene3/testScene.obj";
|
model->ModelFile = "Models/Placeholders/PhysicsTest/Cube.obj";
|
||||||
//model->ModelFile = "Models/Placeholders/Terrain/Terrain2.obj";
|
|
||||||
|
|
||||||
auto physics = AddComponent<Components::Physics>(ground);
|
auto physics = AddComponent<Components::Physics>(ground);
|
||||||
physics->Mass = 10;
|
physics->Mass = 10;
|
||||||
physics->Static = true;
|
physics->Static = true;
|
||||||
|
|
||||||
|
|
||||||
auto groundshape = CreateEntity(ground);
|
auto groundshape = CreateEntity(ground);
|
||||||
auto transformshape = AddComponent<Components::Transform>(groundshape);
|
auto transformshape = AddComponent<Components::Transform>(groundshape);
|
||||||
auto meshShape = AddComponent<Components::MeshShape>(groundshape);
|
auto box = AddComponent<Components::BoxShape>(groundshape);
|
||||||
//meshShape->ResourceName = "Models/Placeholders/Terrain/Terrain2.obj";
|
box->Width = 800;
|
||||||
meshShape->ResourceName = "Models/TestScene3/testScene.obj";
|
box->Height = 5;
|
||||||
|
box->Depth = 800;
|
||||||
|
|
||||||
|
|
||||||
CommitEntity(groundshape);
|
CommitEntity(groundshape);
|
||||||
CommitEntity(ground);
|
CommitEntity(ground);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//for (int i = 0; i < 500; i++)
|
||||||
|
//{
|
||||||
|
// auto Light = CreateEntity();
|
||||||
|
// auto transform = AddComponent<Components::Transform>(Light);
|
||||||
|
// transform->Position = glm::vec3((5 + (i*2.f))*cos(i*2.f), 3.f, (5 + (i*2.f))*sin(i*2.f));
|
||||||
|
// auto light = AddComponent<Components::PointLight>(Light);
|
||||||
|
// light->Specular = glm::vec3(0.5f, 0.5f, 0.5f);
|
||||||
|
// light->Diffuse = glm::vec3(0.5f, 0.5f, 0.5f);
|
||||||
|
// light->Radius = 15.f;
|
||||||
|
// light->specularExponent = 100.f;
|
||||||
|
// CommitEntity(Light);
|
||||||
|
// //auto model = AddComponent<Components::Model>(Light, "Model");
|
||||||
|
// //model->ModelFile = "Models/Placeholders/PhysicsTest/PointLight.obj";
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
/*{
|
/*{
|
||||||
@@ -336,17 +381,17 @@ void GameWorld::Initialize()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
//{
|
||||||
auto lightentity = CreateEntity(tank);
|
// auto lightentity = CreateEntity(tank);
|
||||||
auto transform = AddComponent<Components::Transform>(lightentity);
|
// auto transform = AddComponent<Components::Transform>(lightentity);
|
||||||
transform->Position = glm::vec3(0, 0, 0);
|
// transform->Position = glm::vec3(0, 0, 0);
|
||||||
auto light = AddComponent<Components::PointLight>(lightentity);
|
// auto light = AddComponent<Components::PointLight>(lightentity);
|
||||||
//light->Diffuse = glm::vec3(128.f/255.f, 172.f/255.f, 242.f/255.f);
|
// //light->Diffuse = glm::vec3(128.f/255.f, 172.f/255.f, 242.f/255.f);
|
||||||
//light->Specular = glm::vec3(1.f);
|
// //light->Specular = glm::vec3(1.f);
|
||||||
/*light->ConstantAttenuation = 0.3f;
|
// /*light->ConstantAttenuation = 0.3f;
|
||||||
light->LinearAttenuation = 0.003f;
|
// light->LinearAttenuation = 0.003f;
|
||||||
light->QuadraticAttenuation = 0.002f;*/
|
// light->QuadraticAttenuation = 0.002f;*/
|
||||||
}
|
//}
|
||||||
|
|
||||||
// auto wheelpair = CreateEntity(tank);
|
// auto wheelpair = CreateEntity(tank);
|
||||||
// SetProperty(wheelpair, "Name", "WheelPair");
|
// SetProperty(wheelpair, "Name", "WheelPair");
|
||||||
@@ -751,25 +796,19 @@ void GameWorld::Initialize()
|
|||||||
//auto freeSteering = AddComponent<Components::FreeSteering>(cameraTower);
|
//auto freeSteering = AddComponent<Components::FreeSteering>(cameraTower);
|
||||||
}
|
}
|
||||||
CommitEntity(cameraTower);
|
CommitEntity(cameraTower);
|
||||||
{
|
|
||||||
Events::SetViewportCamera e;
|
|
||||||
e.CameraEntity = cameraTower;
|
|
||||||
e.ViewportFrame = "Viewport2";
|
|
||||||
EventBroker->Publish(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
//{
|
||||||
auto lightentity = CreateEntity(tank);
|
// auto lightentity = CreateEntity(tank);
|
||||||
auto transform = AddComponent<Components::Transform>(lightentity);
|
// auto transform = AddComponent<Components::Transform>(lightentity);
|
||||||
transform->Position = glm::vec3(0, 0, 0);
|
// transform->Position = glm::vec3(0, 0, 0);
|
||||||
auto light = AddComponent<Components::PointLight>(lightentity);
|
// auto light = AddComponent<Components::PointLight>(lightentity);
|
||||||
//light->Diffuse = glm::vec3(128.f/255.f, 172.f/255.f, 242.f/255.f);
|
// //light->Diffuse = glm::vec3(128.f/255.f, 172.f/255.f, 242.f/255.f);
|
||||||
//light->Specular = glm::vec3(1.f);
|
// //light->Specular = glm::vec3(1.f);
|
||||||
/*light->ConstantAttenuation = 0.3f;
|
// /*light->ConstantAttenuation = 0.3f;
|
||||||
light->LinearAttenuation = 0.003f;
|
// light->LinearAttenuation = 0.003f;
|
||||||
light->QuadraticAttenuation = 0.002f;*/
|
// light->QuadraticAttenuation = 0.002f;*/
|
||||||
}
|
//}
|
||||||
|
|
||||||
// auto wheelpair = CreateEntity(tank);
|
// auto wheelpair = CreateEntity(tank);
|
||||||
// SetProperty(wheelpair, "Name", "WheelPair");
|
// SetProperty(wheelpair, "Name", "WheelPair");
|
||||||
|
|||||||
+18
-33
@@ -23,7 +23,7 @@ Renderer::Renderer(std::shared_ptr<::ResourceManager> resourceManager)
|
|||||||
m_SunTarget = glm::vec3(0, 0, 0);
|
m_SunTarget = glm::vec3(0, 0, 0);
|
||||||
m_SunProjection_height = glm::vec2(-40.f, 40.f);
|
m_SunProjection_height = glm::vec2(-40.f, 40.f);
|
||||||
m_SunProjection_width = glm::vec2(-40.f, 40.f);
|
m_SunProjection_width = glm::vec2(-40.f, 40.f);
|
||||||
m_SunProjection_length = glm::vec2(500.f, -500.f);
|
m_SunProjection_length = glm::vec2(-500.f, 500.f);
|
||||||
m_SunProjection = glm::ortho<float>(m_SunProjection_width.x, m_SunProjection_width.y, m_SunProjection_height.x, m_SunProjection_height.y, m_SunProjection_length.x, m_SunProjection_length.y);
|
m_SunProjection = glm::ortho<float>(m_SunProjection_width.x, m_SunProjection_width.y, m_SunProjection_height.x, m_SunProjection_height.y, m_SunProjection_length.x, m_SunProjection_length.y);
|
||||||
/* Lights = 0;*/
|
/* Lights = 0;*/
|
||||||
}
|
}
|
||||||
@@ -106,12 +106,12 @@ void Renderer::LoadContent()
|
|||||||
m_ShaderProgramDebugAABB.AddShader(standardVS);
|
m_ShaderProgramDebugAABB.AddShader(standardVS);
|
||||||
m_ShaderProgramDebugAABB.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/AABB.frag.glsl")));
|
m_ShaderProgramDebugAABB.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/AABB.frag.glsl")));
|
||||||
m_ShaderProgramDebugAABB.Compile();
|
m_ShaderProgramDebugAABB.Compile();
|
||||||
m_ShaderProgramDebugAABB.Link();
|
m_ShaderProgramDebugAABB.Link();*/
|
||||||
|
|
||||||
m_ShaderProgramSkybox.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Skybox.vert.glsl")));
|
m_ShaderProgramSkybox.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Skybox.vert.glsl")));
|
||||||
m_ShaderProgramSkybox.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Skybox.frag.glsl")));
|
m_ShaderProgramSkybox.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Skybox.frag.glsl")));
|
||||||
m_ShaderProgramSkybox.Compile();
|
m_ShaderProgramSkybox.Compile();
|
||||||
m_ShaderProgramSkybox.Link();*/
|
m_ShaderProgramSkybox.Link();
|
||||||
|
|
||||||
m_SunPassProgram.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/SunPass.vert.glsl")));
|
m_SunPassProgram.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/SunPass.vert.glsl")));
|
||||||
m_SunPassProgram.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/SunPass.frag.glsl")));
|
m_SunPassProgram.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/SunPass.frag.glsl")));
|
||||||
@@ -156,6 +156,7 @@ void Renderer::LoadContent()
|
|||||||
FrameBufferTextures();
|
FrameBufferTextures();
|
||||||
|
|
||||||
m_sphereModel = ResourceManager->Load<Model>("Model", "Models/Placeholders/PhysicsTest/Sphere.obj");
|
m_sphereModel = ResourceManager->Load<Model>("Model", "Models/Placeholders/PhysicsTest/Sphere.obj");
|
||||||
|
m_Skybox = std::make_shared<Skybox>("Textures/Skybox/Sunset", "jpg");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::Draw(double dt)
|
void Renderer::Draw(double dt)
|
||||||
@@ -368,7 +369,7 @@ void Renderer::DrawWorld(RenderQueue &rq)
|
|||||||
// Clear G-buffer
|
// Clear G-buffer
|
||||||
GLenum windowBuffClear[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 };
|
GLenum windowBuffClear[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 };
|
||||||
glDrawBuffers(4, windowBuffClear);
|
glDrawBuffers(4, windowBuffClear);
|
||||||
glClearColor(0.0f, 0.7f, 0.3f, 0.f);
|
glClearColor(115.f / 255, 192.f / 255, 255.f / 255, 0.f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
// Execute the first render stage which will fill out the internal buffers with data(??)
|
// Execute the first render stage which will fill out the internal buffers with data(??)
|
||||||
@@ -400,6 +401,7 @@ void Renderer::DrawWorld(RenderQueue &rq)
|
|||||||
|
|
||||||
glCullFace(GL_FRONT);
|
glCullFace(GL_FRONT);
|
||||||
DrawLightScene(rq);
|
DrawLightScene(rq);
|
||||||
|
DrawSunLightScene();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Final pass
|
Final pass
|
||||||
@@ -436,8 +438,9 @@ void Renderer::Swap()
|
|||||||
|
|
||||||
void Renderer::DrawSkybox()
|
void Renderer::DrawSkybox()
|
||||||
{
|
{
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
//glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
glViewport(0, 0, m_Width, m_Height);
|
//glViewport(0, 0, m_Width, m_Height);
|
||||||
|
//glScissor(0, 0, m_Width, m_Height);
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
m_ShaderProgramSkybox.Bind();
|
m_ShaderProgramSkybox.Bind();
|
||||||
@@ -483,12 +486,13 @@ void Renderer::DrawShadowMap(RenderQueue &rq)
|
|||||||
//Binds the FBO and sets the veiwport, witch in effect is how large the shadowmap is and what resolution it has.
|
//Binds the FBO and sets the veiwport, witch in effect is how large the shadowmap is and what resolution it has.
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, m_ShadowFrameBuffer);
|
glBindFramebuffer(GL_FRAMEBUFFER, m_ShadowFrameBuffer);
|
||||||
glViewport(0, 0, m_ShadowMapRes, m_ShadowMapRes);
|
glViewport(0, 0, m_ShadowMapRes, m_ShadowMapRes);
|
||||||
|
glScissor(0, 0, m_ShadowMapRes, m_ShadowMapRes);
|
||||||
|
|
||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
//glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
//glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
//Creates the "camera" for the shadowmap from the direction of the sun.
|
//Creates the "camera" for the shadowmap from the direction of the sun.
|
||||||
glm::mat4 depthViewMatrix = glm::lookAt(m_SunPosition, m_SunTarget, glm::vec3(0, 1, 0)) * glm::translate(-m_Camera->Position() * glm::vec3(1, 1, 1));
|
glm::mat4 depthViewMatrix = glm::lookAt(m_SunPosition, m_SunTarget, glm::vec3(0, 1, 0)) * glm::translate(m_Camera->Position() * glm::vec3(1, 1, 1));
|
||||||
//glm::mat4 depthViewMatrix = glm::lookAt(m_SunPosition, m_SunTarget, glm::vec3(0, 1, 0)) * glm::translate((-m_Camera->Position() + (glm::vec3(40.0) * -m_Camera->Forward())) * glm::vec3(1, 1, 1));
|
//glm::mat4 depthViewMatrix = glm::lookAt(m_SunPosition, m_SunTarget, glm::vec3(0, 1, 0)) * glm::translate((-m_Camera->Position() + (glm::vec3(40.0) * -m_Camera->Forward())) * glm::vec3(1, 1, 1));
|
||||||
glm::mat4 depthCamera = m_SunProjection * depthViewMatrix;
|
glm::mat4 depthCamera = m_SunProjection * depthViewMatrix;
|
||||||
glm::mat4 MVP;
|
glm::mat4 MVP;
|
||||||
@@ -505,7 +509,7 @@ void Renderer::DrawShadowMap(RenderQueue &rq)
|
|||||||
glm::mat4 modelMatrix = modelJob->ModelMatrix;
|
glm::mat4 modelMatrix = modelJob->ModelMatrix;
|
||||||
|
|
||||||
MVP = depthCamera * modelMatrix;
|
MVP = depthCamera * modelMatrix;
|
||||||
glUniformMatrix4fv(glGetUniformLocation(m_FirstPassProgram.GetHandle(), "MVP"), 1, GL_FALSE, glm::value_ptr(MVP));
|
glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgramShadows.GetHandle(), "MVP"), 1, GL_FALSE, glm::value_ptr(MVP));
|
||||||
//glUniform3fv(glGetUniformLocation(m_SecondPassProgram.GetHandle(), "SunDirection_cameraspace"), 1, glm::value_ptr(sunDirection_cameraview));
|
//glUniform3fv(glGetUniformLocation(m_SecondPassProgram.GetHandle(), "SunDirection_cameraspace"), 1, glm::value_ptr(sunDirection_cameraview));
|
||||||
|
|
||||||
glBindVertexArray(modelJob->VAO);
|
glBindVertexArray(modelJob->VAO);
|
||||||
@@ -514,25 +518,6 @@ void Renderer::DrawShadowMap(RenderQueue &rq)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (auto tuple : ModelsToRender)
|
|
||||||
{
|
|
||||||
Model* model;
|
|
||||||
glm::mat4 modelMatrix;
|
|
||||||
bool shadow;
|
|
||||||
std::tie(model, modelMatrix, std::ignore, shadow) = tuple;
|
|
||||||
if (!shadow)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
MVP = depthCamera * modelMatrix;
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgramShadows.GetHandle(), "MVP"), 1, GL_FALSE, glm::value_ptr(MVP));
|
|
||||||
|
|
||||||
glBindVertexArray(model->VAO);
|
|
||||||
for (auto texGroup : model->TextureGroups)
|
|
||||||
{
|
|
||||||
glDrawArrays(GL_TRIANGLES, texGroup.StartIndex, texGroup.EndIndex - texGroup.StartIndex + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::DrawDebugShadowMap()
|
void Renderer::DrawDebugShadowMap()
|
||||||
@@ -1001,12 +986,12 @@ void Renderer::DrawFBOScene(RenderQueue &rq)
|
|||||||
|
|
||||||
MVP = cameraMatrix * modelMatrix;
|
MVP = cameraMatrix * modelMatrix;
|
||||||
depthMVP = depthCameraMatrix * modelMatrix;
|
depthMVP = depthCameraMatrix * modelMatrix;
|
||||||
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, "DepthMVP"), 1, GL_FALSE, glm::value_ptr(depthMVP));
|
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "DepthMVP"), 1, GL_FALSE, glm::value_ptr(depthMVP));
|
||||||
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(m_Camera->ViewMatrix()));
|
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_Camera->ViewMatrix()));
|
||||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "P"), 1, GL_FALSE, glm::value_ptr(cameraProjection));
|
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "P"), 1, GL_FALSE, glm::value_ptr(cameraProjection));
|
||||||
glUniform3fv(glGetUniformLocation(ShaderProgramHandle, "SunDirection_cameraspace"), 1, glm::value_ptr(sunDirection_cameraview));
|
glUniform3fv(glGetUniformLocation(ShaderProgramHandle, "SunDirection_cameraspace"), 1, glm::value_ptr(sunDirection_cameraview));
|
||||||
|
|
||||||
glBindVertexArray(modelJob->VAO);
|
glBindVertexArray(modelJob->VAO);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ out vec4 frag_Specular;
|
|||||||
|
|
||||||
float Shadow(vec4 ShadowCoord, vec3 normal)
|
float Shadow(vec4 ShadowCoord, vec3 normal)
|
||||||
{
|
{
|
||||||
|
return 1.0;
|
||||||
|
|
||||||
if (Input.ShadowCoord.x < 0.0 || Input.ShadowCoord.x > 1.0 || Input.ShadowCoord.y < 0.0 || Input.ShadowCoord.y > 1.0)
|
if (Input.ShadowCoord.x < 0.0 || Input.ShadowCoord.x > 1.0 || Input.ShadowCoord.y < 0.0 || Input.ShadowCoord.y > 1.0)
|
||||||
return 0.9;
|
return 0.9;
|
||||||
|
|
||||||
@@ -43,7 +45,7 @@ float Shadow(vec4 ShadowCoord, vec3 normal)
|
|||||||
bias = clamp(bias, 0.0, 0.00003);
|
bias = clamp(bias, 0.0, 0.00003);
|
||||||
|
|
||||||
//Fixed bias
|
//Fixed bias
|
||||||
//float bias = 0.0005;
|
bias = 0;
|
||||||
|
|
||||||
if( texture(ShadowTexture, Input.ShadowCoord.xy).z < ShadowCoord.z + bias)
|
if( texture(ShadowTexture, Input.ShadowCoord.xy).z < ShadowCoord.z + bias)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user