diff --git a/client/src/main/resources/shaders/block/frag.glsl b/client/src/main/resources/shaders/block/frag.glsl index 5d64b0e2..3cba6033 100644 --- a/client/src/main/resources/shaders/block/frag.glsl +++ b/client/src/main/resources/shaders/block/frag.glsl @@ -52,5 +52,5 @@ void main() { position = fragIn.position; normal = fragIn.normal; - color.rgb *= fragIn.brightness * 0.8 + 0.2; + color.rgb *= sqrt(fragIn.brightness) * 0.8 + 0.2; } diff --git a/client/src/main/resources/shaders/block/vert.glsl b/client/src/main/resources/shaders/block/vert.glsl index 5f6dc5e9..baaff230 100644 --- a/client/src/main/resources/shaders/block/vert.glsl +++ b/client/src/main/resources/shaders/block/vert.glsl @@ -55,5 +55,5 @@ void main() { fragIn.mult = mult; fragInFlat.texIndex = texIndex; - fragIn.brightness = brightness; + fragIn.brightness = brightness * brightness; } \ No newline at end of file diff --git a/client/src/main/scala/hexacraft/client/render/BlockVboData.scala b/client/src/main/scala/hexacraft/client/render/BlockVboData.scala index 64cd50fa..540d66c5 100644 --- a/client/src/main/scala/hexacraft/client/render/BlockVboData.scala +++ b/client/src/main/scala/hexacraft/client/render/BlockVboData.scala @@ -301,13 +301,15 @@ object BlockVboData { } case _ => cornerIdx match { - case 0 => b += Offset(0, 1, 0) - case 1 => b += Offset(0, 1, 0) - case 2 => b += Offset(0, -1, 0) - case 3 => b += Offset(0, -1, 0) + case 0 => b += Offset(0, 1, 0); b += Offset(0, 1, 0) + case 1 => b += Offset(0, 1, 0); b += Offset(0, 1, 0) + case 2 => b += Offset(0, -1, 0); b += Offset(0, -1, 0) + case 3 => b += Offset(0, -1, 0); b += Offset(0, -1, 0) } } + // TODO: calculate ambient occlusion based on the neighbors, and make sure it's independent of `side` + var brSum = 0f var brCount = 0 var bIdx = 0 @@ -320,7 +322,11 @@ object BlockVboData { } bIdx += 1 } - if brCount == 0 then brightness(neighborBlockCoords) else brSum / brCount + if brCount == 0 then brightness(neighborBlockCoords) + else { + val ambientOcclusionFactor = (brCount - 1).toFloat / (bLen - 1) * 0.2f + 0.8f // TODO: temporary + brSum / brCount * ambientOcclusionFactor + } } private def oppositeSide(s: Int): Int = {