From 6e46c54e6e4ce042ff499738bf0fd6cc43ac0bde Mon Sep 17 00:00:00 2001 From: sergeypdev Date: Mon, 12 Feb 2024 16:40:31 +0400 Subject: [PATCH] Gamma correction and add missing light intensity --- assets/shaders/mesh.frag.glsl | 6 +++++- src/game.zig | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/assets/shaders/mesh.frag.glsl b/assets/shaders/mesh.frag.glsl index 1891868..c1903a7 100644 --- a/assets/shaders/mesh.frag.glsl +++ b/assets/shaders/mesh.frag.glsl @@ -38,8 +38,12 @@ void main() { float ndotl = max(dot(L, normal), 0); - finalColor += ndotl * lights[i].color.xyz * att * diffuseColor; + finalColor += ndotl * lights[i].color.w * lights[i].color.xyz * att * diffuseColor; + } FragColor = vec4(finalColor, 1.0f); + + float gamma = 2.2; + FragColor.rgb = pow(FragColor.rgb, vec3(1.0/gamma)); } diff --git a/src/game.zig b/src/game.zig index 49aad98..366cf96 100644 --- a/src/game.zig +++ b/src/game.zig @@ -419,7 +419,7 @@ export fn game_init(global_allocator: *std.mem.Allocator) void { _ = g_mem.world.addEntity(.{ .transform = .{ .pos = Vec3.new(1, 1, 0) }, .flags = .{ .point_light = true, .rotate = true }, - .point_light = .{ .color_intensity = Vec4.new(1.0, 0.5, 0.2, 1.0), .radius = 1 }, + .point_light = .{ .color_intensity = Vec4.new(1.0, 0.3, 0.1, 100.0), .radius = 0.1 }, .rotate = .{ .axis = Vec3.up(), .rate = 60 }, }); @@ -427,10 +427,10 @@ export fn game_init(global_allocator: *std.mem.Allocator) void { .transform = .{ .pos = Vec3.new(-1, 1, 0) }, .flags = .{ .point_light = true, .rotate = true }, .point_light = .{ - .color_intensity = Vec4.new(0.2, 0.5, 1.0, 1.0), - .radius = 1, + .color_intensity = Vec4.new(0.2, 0.5, 1.0, 100.0), + .radius = 0.1, }, - .rotate = .{ .axis = Vec3.up(), .rate = -60 }, + .rotate = .{ .axis = Vec3.up(), .rate = -20 }, }); // Plane