summaryrefslogtreecommitdiff
path: root/src/cl/spirt.cl
diff options
context:
space:
mode:
authorAiden Gall <aiden@aidengall.xyz>2024-02-06 08:49:55 +0000
committerAiden Gall <aiden@aidengall.xyz>2024-02-06 09:03:40 +0000
commit3b90152d969056682069254ddcdcc2d04148402b (patch)
tree260ca18b1489e603ca4594405cba6dc24457eb37 /src/cl/spirt.cl
parent71277d9af0a9c89ffeab47f01dcb1426f8ffa253 (diff)
switch canvas to floating point rgb
Diffstat (limited to 'src/cl/spirt.cl')
-rw-r--r--src/cl/spirt.cl9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/cl/spirt.cl b/src/cl/spirt.cl
index 943f317..f55aa74 100644
--- a/src/cl/spirt.cl
+++ b/src/cl/spirt.cl
@@ -68,19 +68,18 @@ hit_sphere(const float3 center, const float radius, const struct ray ray)
}
void
-write_pixel(__global uchar *const pixel, float3 colour)
+write_pixel(__global float *const pixel, float3 colour)
{
/* gamma correction */
- colour = 256.0f * clamp(pow(colour, 1.0f/2.2f), 0.0f, 0.999f);
+ colour = clamp(pow(colour, 1.0f / 2.2f), 0.0f, 1.0f);
pixel[0] = colour.x;
pixel[1] = colour.y;
pixel[2] = colour.z;
- pixel[3] = 255;
}
__kernel void
-ray_colour(__global uchar *const canvas, __global const float3 *const rays)
+ray_colour(__global float *const canvas, __global const float3 *const rays)
{
struct ray ray;
@@ -114,5 +113,5 @@ ray_colour(__global uchar *const canvas, __global const float3 *const rays)
colour = (1.0f - a) * 1.0f + a * (float3)(0.5f, 0.7f, 1.0f);
}
- write_pixel(canvas + 4 * (w * j + i), colour);
+ write_pixel(canvas + 3 * (w * j + i), colour);
}