Reformatting and cleanup
This commit is contained in:
parent
72ab9f6aa2
commit
390ab7c3b4
@ -19,14 +19,12 @@ FragmentResult depth_shader_fragment(void *shader, const V3f *barycentric, const
|
||||
const Model *model) {
|
||||
DepthShader *shdr = (DepthShader *)shader;
|
||||
|
||||
// clang-format off
|
||||
M3x3f pos_mat = {.rows = {shdr->vertices[0].position, shdr->vertices[1].position, shdr->vertices[2].position}};
|
||||
pos_mat = mat3x3_transpose(pos_mat);
|
||||
// clang-format on
|
||||
|
||||
V3f position = mat3x3_mul_vec3(pos_mat, (*barycentric));
|
||||
f32 channel = clamp(position.z + DEPTH_MAX, 0.0f, DEPTH_MAX);
|
||||
Colour output = {.r = (u8)(channel), .g = (u8)(channel), .b = (u8)(channel), .a = 255};
|
||||
V3f position = mat3x3_mul_vec3(pos_mat, (*barycentric));
|
||||
f32 channel = clamp(position.z + DEPTH_MAX, 0.0f, DEPTH_MAX);
|
||||
Colour output = {.r = (u8)(channel), .g = (u8)(channel), .b = (u8)(channel), .a = 255};
|
||||
|
||||
return (FragmentResult){.colour = output};
|
||||
}
|
||||
|
@ -48,8 +48,8 @@ FragmentResult diffuse_shader_fragment(void *shader, const V3f *barycentric, con
|
||||
u64 nm_x = uv.u * model->normal->width;
|
||||
u64 nm_y = uv.v * model->normal->height;
|
||||
|
||||
Colour pixel = get_pixel(Colour, model->normal, nm_x, nm_y);
|
||||
V3f tangent = (V3f){
|
||||
Colour pixel = get_pixel(Colour, model->normal, nm_x, nm_y);
|
||||
V3f tangent = (V3f){
|
||||
.x = pixel.r / 255.f * 2.f - 1.f,
|
||||
.y = pixel.g / 255.f * 2.f - 1.f,
|
||||
.z = pixel.b / 255.f * 2.f - 1.f,
|
||||
@ -58,7 +58,7 @@ FragmentResult diffuse_shader_fragment(void *shader, const V3f *barycentric, con
|
||||
V3f p0p1 = sub_v3(shdr->vertices[1].position, shdr->vertices[0].position);
|
||||
V3f p0p2 = sub_v3(shdr->vertices[2].position, shdr->vertices[0].position);
|
||||
|
||||
M3x3f A = {.rows = {p0p1, p0p2, normal}};
|
||||
M3x3f A = {.rows = {p0p1, p0p2, normal}};
|
||||
M3x3f A_inv = mat3x3_inv(A);
|
||||
|
||||
V2f uv0 = shdr->vertices[0].uv;
|
||||
@ -106,12 +106,9 @@ FragmentResult albedo_shader_fragment(void *shader, const V3f *barycentric, cons
|
||||
const Model *model) {
|
||||
Shader *shdr = (Shader *)shader;
|
||||
|
||||
// clang-format off
|
||||
M3x2f uvs = {shdr->vertices[0].uv, shdr->vertices[1].uv, shdr->vertices[2].uv};
|
||||
M3x2f uvs = {shdr->vertices[0].uv, shdr->vertices[1].uv, shdr->vertices[2].uv};
|
||||
M2x3f uv_mat = mat3x2_transpose(uvs);
|
||||
// clang-format on
|
||||
|
||||
V2f uv = mat2x3_mul_vec3(uv_mat, (*barycentric));
|
||||
V2f uv = mat2x3_mul_vec3(uv_mat, (*barycentric));
|
||||
|
||||
Colour output;
|
||||
if (model->texture) {
|
||||
|
@ -29,14 +29,12 @@ M4x4f lookat(V3f eye, V3f target, V3f up) {
|
||||
}
|
||||
|
||||
M4x4f projection(f32 coeff) {
|
||||
// clang-format off
|
||||
return (M4x4f){
|
||||
.row0 = {1.0f, 0.0f, 0.0f, 0.0f},
|
||||
.row1 = {0.0f, 1.0f, 0.0f, 0.0f},
|
||||
.row2 = {0.0f, 0.0f, 1.0f, 0.0f},
|
||||
.row3 = {0.0f, 0.0f, coeff, 1.0f},
|
||||
};
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
M4x4f viewport(f32 x, f32 y, u64 w, u64 h) {
|
||||
|
Loading…
Reference in New Issue
Block a user