aboutsummaryrefslogtreecommitdiffstats
path: root/shaders/compute.comp
diff options
context:
space:
mode:
authorladevieq <ladevie.quentin@gmail.com>2022-07-07 23:01:36 +0200
committerladevieq <ladevie.quentin@gmail.com>2022-07-07 23:01:36 +0200
commit928b1b0503d2ecab09cc275e9775593a41e417cb (patch)
tree3d90f2994c504544eb62a1e1363ee8ac17cbf5f0 /shaders/compute.comp
parent5692f616c6201b39184e4353b6a4cb850a84a450 (diff)
Interpolation function & no more triangle structure in shader
Diffstat (limited to 'shaders/compute.comp')
-rw-r--r--shaders/compute.comp17
1 files changed, 5 insertions, 12 deletions
diff --git a/shaders/compute.comp b/shaders/compute.comp
index 6ca193e..0f85da6 100644
--- a/shaders/compute.comp
+++ b/shaders/compute.comp
@@ -36,16 +36,10 @@ struct sphere {
float[3] padding;
};
-struct vertex {
- vec3 position;
- vec3 normal;
- vec2 uv;
-};
-
struct triangle {
- vertex v1;
- vertex v2;
- vertex v3;
+ vec3 positions[3];
+ vec3 normals[3];
+ vec2 uvs[3];
material mat;
};
@@ -141,11 +135,10 @@ vec3 ray_color(ray r, uint seed) {
- // TODO: Interpolation function & indices decoding function
triangle tri = get_triangle(info.primitive_id);
- vec3 shading_normal = normalize(tri.v1.normal * info.barycentrics.x + tri.v2.normal * info.barycentrics.y + tri.v3.normal * info.barycentrics.z);
- vec2 uv = tri.v1.uv * info.barycentrics.x + tri.v2.uv * info.barycentrics.y + tri.v3.uv * info.barycentrics.z;
+ vec2 uv = interpolate_attribute(tri.uvs, info.barycentrics);
+ vec3 shading_normal = normalize(interpolate_attribute(tri.normals, info.barycentrics));
vec3 diffuse_color = srgb_to_linear(texture(
sampler2D(