Fragment shader for depth returns valid u8 values
This commit is contained in:
parent
0aacccdf67
commit
bca5dafabf
@ -1,5 +1,7 @@
|
||||
#include "depth_shader.h"
|
||||
#include "constants.h"
|
||||
#include "shader.h"
|
||||
#include "utils.h"
|
||||
|
||||
VertexData depth_shader_vertex(void *shader, const VertexData *vert, u8 index, const Model *model) {
|
||||
DepthShader *shdr = (DepthShader *)shader;
|
||||
@ -20,7 +22,8 @@ FragmentResult depth_shader_fragment(void *shader, const V3f *barycentric, const
|
||||
pos_mat = mat3x3_transpose(pos_mat);
|
||||
V3f position = mat3x3_mul_vec3(pos_mat, (*barycentric));
|
||||
|
||||
V4f output = {.r = position.z, .g = position.z, .b = position.z, .a = 255};
|
||||
f32 channel = clamp(position.z + DEPTH_MAX, 0.0f, DEPTH_MAX);
|
||||
V4f output = {.r = channel, .g = channel, .b = channel, .a = 255};
|
||||
|
||||
return (FragmentResult){.colour = output};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user