Normals

From vegard.wiki
Revision as of 19:27, 25 January 2020 by Vegard (talk | contribs) (new page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

dFdx/dFdy

in vec3 vertex_coord;

// https://community.khronos.org/t/getting-the-normal-with-dfdx-and-dfdy/70177
// http://web.archive.org/web/20120302100158/http://athile.net/library/blog/?tag=dfdx
vec3 normal()
{
    vec3 x = dFdx(vertex_coord);
    vec3 y = dFdy(vertex_coord);
    return normalize(cross(x, y));
}