diff --git a/data/shaders/fs_default.glsl b/data/shaders/fs_default.glsl index bdde627..ae8f39b 100644 --- a/data/shaders/fs_default.glsl +++ b/data/shaders/fs_default.glsl @@ -19,21 +19,18 @@ float ShadowCalculation(vec4 frag_pos_light_space) { projected_coordinates = projected_coordinates * 0.5 + 0.5; float closest_depth = texture(uShadowMap, projected_coordinates.xy).r; -// float closest_depth = texture(uAlbedoTexture, projected_coordinates.xy).r; float current_depth = projected_coordinates.z; -// return current_depth; -// return closest_depth; - float bias = 0.005; + float bias = max(0.05 * (1.0 - dot(ioFragNormal, uLightDirection)), 0.005); + bias = 0.0; return current_depth - bias > closest_depth ? 1.0 : 0.0; -// return current_depth; } void main() { vec4 albedo_color = texture(uAlbedoTexture, ioFragTexCoords) * ioFragColor * uColor; // ambient lighting - float ambient_strength = 0.1; + float ambient_strength = 0.2; vec4 ambient = ambient_strength * albedo_color; // diffuse lighting diff --git a/data/shaders/fs_simple.glsl b/data/shaders/fs_simple.glsl index 9122108..975a906 100644 --- a/data/shaders/fs_simple.glsl +++ b/data/shaders/fs_simple.glsl @@ -2,17 +2,10 @@ uniform vec4 uColor; -in vec4 fragmentColor; +in vec4 ioFragmentColor; -out vec3 outColor; +out vec4 outColor; void main() { - outColor = vec3( - uColor.r * fragmentColor.r, - uColor.g * fragmentColor.g, - uColor.b * fragmentColor.b - ); - - - outColor = fragmentColor.rgb + uColor.rgb - uColor.rgb; + outColor = vec4(ioFragmentColor.xyz * uColor.xyz * ioFragmentColor.w * uColor.w, 1.0); } diff --git a/data/shaders/vs_simple.glsl b/data/shaders/vs_simple.glsl index 398d47c..a8431f8 100644 --- a/data/shaders/vs_simple.glsl +++ b/data/shaders/vs_simple.glsl @@ -8,9 +8,9 @@ in vec4 inColor; uniform mat4 uModelViewProj; -out vec4 fragmentColor; +out vec4 ioFragmentColor; void main() { gl_Position = uModelViewProj * inCoord; - fragmentColor = inColor; + ioFragmentColor = inColor; } diff --git a/src/modules/RenderModule.cc b/src/modules/RenderModule.cc index d20ba71..3a1d2b3 100644 --- a/src/modules/RenderModule.cc +++ b/src/modules/RenderModule.cc @@ -411,6 +411,7 @@ void Renderer::RenderGl() { mLight.UpdateMatrices(); glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); glEnable(GL_DEPTH_TEST); + glCullFace(GL_FRONT); glUseProgram(mLight.mShadowMapProgram.mProgramId); if (mLight.mShadowMapProgram.SetMat44("uLightSpaceMatrix", mLight.mLightSpaceMatrix) == -1) { gLog ("Warning: Uniform %s not found!", "uLightSpaceMatrix"); @@ -418,6 +419,7 @@ void Renderer::RenderGl() { RenderScene(mLight.mShadowMapProgram, mLight.mCamera); mLight.mShadowMapTarget.RenderToLinearizedDepth(mLight.mCamera.mNear, mLight.mCamera.mFar, mLight.mCamera.mIsOrthographic); glBindFramebuffer(GL_FRAMEBUFFER, 0); + glCullFace(GL_BACK); // Regular rendering glEnable(GL_LINE_SMOOTH); @@ -465,7 +467,7 @@ void Renderer::RenderGl() { * mCamera.mViewMatrix * mCamera.mProjectionMatrix; mSimpleProgram.SetMat44("uModelViewProj", model_view_projection); - mSimpleProgram.SetVec4("uColor", Vector4f (1.0f, 0.0f, 0.0f, 1.0f)); + mSimpleProgram.SetVec4("uColor", Vector4f (1.0f, 1.0f, 1.0f, 0.4f)); gVertexArray.Bind(); gXZPlaneGrid.Draw(GL_LINES);