Skip to content

Files

Latest commit

Jul 20, 2020
05bf7b1 · Jul 20, 2020

History

History

01_triangle

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jul 20, 2020
Jul 19, 2020
Jul 19, 2020

Interpolartion Triangle

The classic color gradient triangle.

Example Source

$ php examples/01_triangle/triangle.php
Triangle Example Triangle Example

This example exists to showcase the interpolation of the barycentric coordinates inside of a drawn triangle.

public function vertex(Vertex $vertex, array &$out) : Vec4
{
    $out['color'] = $vertex->color; // set the color attribute
    return Vec4::fromVec3($vertex->position); // return vertex positon
}

public function fragment(array &$in, array &$out)
{
    $out['color'] = $in['color']->toColorInt();
}