Premultiplied alpha and gamma corrct!

This commit is contained in:
Krzosa Karol
2022-02-20 19:55:56 +01:00
parent 8cfd52ed81
commit a5b111d24a
4 changed files with 74 additions and 37 deletions

View File

@@ -101,11 +101,16 @@ FUNCTION void draw_triangle_PERSPECTIVE_CORRECT_INTERPOLATION_on_BILINEAR_BLEND_
}
if (draw_rects) {
draw_rect(dst, p0.x-4, p0.y-4, 8,8, 0x00ff0000);
if (draw_rects) {
draw_rect(dst, p0.x-4, p0.y-4, 8,8, 0x00ff0000);
draw_rect(dst, p1.x-4, p1.y-4, 8,8, 0x0000ff00);
draw_rect(dst, p2.x-4, p2.y-4, 8,8, 0x000000ff);
}
}
FUNCTION void draw_triangle_PERSPECTIVE_CORRECT_INTERPOLATION_on_BILINEAR_BLEND_on (Image* dst, float *depth_buffer, Image *src,
@@ -169,11 +174,16 @@ FUNCTION void draw_triangle_PERSPECTIVE_CORRECT_INTERPOLATION_off_BILINEAR_BLEND
// @Note: We could do: interpolated_z = 1.f / interpolated_z to get proper depth
// @Note: We could do: interpolated_z = 1.f / interpolated_z to get proper depth
// but why waste an instruction, the smaller the depth value the farther the object
float* depth = depth_buffer + (x + y * dst->x);
if (*depth < interpolated_z) {
*depth = interpolated_z;
u = u * (src->x - 2);
v = v * (src->y - 2);
I64 ui = (I64)(u);