From a039ced6cf90cabf63241ae28bce67a3a688ceb0 Mon Sep 17 00:00:00 2001 From: emamaker Date: Mon, 27 Mar 2023 19:19:27 +0200 Subject: [PATCH] gamma correction --- shaders/shader.fs | 10 ++++++---- src/chunkmesher.cpp | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/shaders/shader.fs b/shaders/shader.fs index fbcd60f..5193cf4 100644 --- a/shaders/shader.fs +++ b/shaders/shader.fs @@ -9,9 +9,9 @@ out vec4 FragColor; vec3 lightColor = vec3(1.0); vec3 lightDir = -normalize(vec3(0.0, 100.0, 0.0) - vec3(32.0)); -float ambientStrength = 0.5; -float diffuseStrength = 0.3; -float specularStrength = 0.2; +float ambientStrength = 0.05; +float diffuseStrength = 0.7; +float specularStrength = 0.25; uniform vec3 viewPos; uniform float u_time; @@ -38,5 +38,7 @@ void main() // Final color vec3 color = ambient * ambientStrength + diffuse * diffuseStrength + specular * specularStrength; - FragColor = vec4(color, 1.0); + + float gamma = 2.2; + FragColor.rgb = pow(color.rgb, vec3(1.0/gamma)); } diff --git a/src/chunkmesher.cpp b/src/chunkmesher.cpp index c9abde2..2821eca 100755 --- a/src/chunkmesher.cpp +++ b/src/chunkmesher.cpp @@ -312,9 +312,9 @@ void quad(Chunk::Chunk* chunk, glm::vec3 bottomLeft, glm::vec3 topLeft, glm::vec b = 0.0f; break; case Block::DIRT: - r = 0.176f; - g = 0.282f; - b = 0.169f; + r = 0.152f; + g = 0.056f; + b = 0.056f; break; default: r = 0.0f;