Gamma correction and add missing light intensity

This commit is contained in:
sergeypdev 2024-02-12 16:40:31 +04:00
parent 70ff9c17b5
commit 6e46c54e6e
2 changed files with 9 additions and 5 deletions

View File

@ -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));
}

View File

@ -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