fix(perf): assign color once per pixel

This commit is contained in:
stitchy 2024-12-26 00:59:14 +00:00
parent b5df780b75
commit 367153bbf6
Signed by: stitchy
SSH key fingerprint: SHA256:yz2SoxdnY67tfY5Jzb0f2v8f5W3o/IF359kbcquWip8

View file

@ -33,6 +33,7 @@ float remap11(float val) {
return ((val - .5) * 2.);
}
// returns a vec3 of the vector transformed by the matrix
vec3 mat3_vec_mul(vec3 m[3], vec3 v) {
return v.x * m[0] + v.y * m[1] + v.z * m[2];
}
@ -46,7 +47,8 @@ void main() {
const vec3 sphere_pos = vec3(0., 0., 3.);
const float rad = 1.;
for (int i = 0; i < MAX_ITERATIONS; i++) {
int i = 0;
for (; i < MAX_ITERATIONS; i++) {
float distance = sphere_render(ray_pos, rad, sphere_pos);
// Check If within tolerances
@ -55,8 +57,8 @@ void main() {
}
ray_pos += (distance * ray_dir);
color = vec4(mix(color1, color2, float(i) / float(MAX_ITERATIONS)), 1.);
}
color = vec4(mix(color1, color2, float(i) / float(MAX_ITERATIONS)), 1.);
// Image stuff for later
/*