diff options
| author | ladevieq <ladevie.quentin@gmail.com> | 2022-07-07 23:01:36 +0200 |
|---|---|---|
| committer | ladevieq <ladevie.quentin@gmail.com> | 2022-07-07 23:01:36 +0200 |
| commit | 928b1b0503d2ecab09cc275e9775593a41e417cb (patch) | |
| tree | 3d90f2994c504544eb62a1e1363ee8ac17cbf5f0 /shaders/include/math.h | |
| parent | 5692f616c6201b39184e4353b6a4cb850a84a450 (diff) | |
Interpolation function & no more triangle structure in shader
Diffstat (limited to 'shaders/include/math.h')
| -rw-r--r-- | shaders/include/math.h | 8 |
1 files changed, 8 insertions, 0 deletions
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;
+}
|
