Skip to content

Latest commit

 

History

History

01_triangle

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

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();
}