This repository has been archived on 2024-12-30. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
2024CG-project-render/glsl/interpolate.glsl
github-classroom[bot] 686dcaf351
Initial commit
2024-11-29 09:50:03 +00:00

16 lines
466 B
GLSL

// Using gl_TessCoord interpolate between values stored at three corners of a
// triangle.
//
// Inputs:
// v0 value at corner 0
// v1 value at corner 1
// v2 value at corner 2
// Return linearly interpolated value based on gl_TessCoord.
vec3 interpolate(vec3 bary, vec3 v0, vec3 v1, vec3 v2)
{
return bary.x * v0 + bary.y * v1 + bary.z * v2;
}
vec4 interpolate(vec3 bary, vec4 v0, vec4 v1, vec4 v2)
{
return bary.x * v0 + bary.y * v1 + bary.z * v2;
}