From 928b1b0503d2ecab09cc275e9775593a41e417cb Mon Sep 17 00:00:00 2001 From: ladevieq Date: Thu, 7 Jul 2022 23:01:36 +0200 Subject: Interpolation function & no more triangle structure in shader --- shaders/include/math.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'shaders/include/math.h') diff --git a/shaders/include/math.h b/shaders/include/math.h index cc4e2f4..c95b065 100644 --- a/shaders/include/math.h +++ b/shaders/include/math.h @@ -43,3 +43,11 @@ vec3 rotate_point(vec4 q, vec3 v) { const vec3 q_axis = q.xyz; return 2.0f * dot(q_axis, v) * q_axis + (q.w * q.w - dot(q_axis, q_axis)) * v + 2.0f * q.w * cross(q_axis, v); } + +vec3 interpolate_attribute(vec3 values[3], vec3 weights) { + return values[0] * weights.x + values[1] * weights.y + values[2] * weights.z; +} + +vec2 interpolate_attribute(vec2 values[3], vec3 weights) { + return values[0] * weights.x + values[1] * weights.y + values[2] * weights.z; +} -- cgit v1.3