glslify / glslify/glslify

Modules that use extensions

Open
#46 4 comments 0 reactions 0 assignees View on GitHub
enhancement question
Dominant language
JavaScript
Stars
2.3k
Forks
83
PR merge metrics
No merged PRs in 30d

Description

Using standard derivatives is a common way to anti-alias 2D shapes, but it requires an extension. What's the best way of modularizing something that looks like this?

``` glsl
#ifdef GL_OES_standard_derivatives
#extension GL_OES_standard_derivatives : enable
#endif

float aastep(float threshold, float value) {
#ifdef GL_OES_standard_derivatives
float afwidth = 0.7 * length(vec2(dFdx(value), dFdy(value)));
#else
float afwidth = /* some fallback approach */;
#endif
return smoothstep(threshold-afwidth, threshold+afwidth, value);
}
```

More reading:
http://webstaff.itn.liu.se/~stegu/webglshadertutorial/shadertutorial.html (part 3)
https://github.com/Jam3/three-bmfont-text/issues/1

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.