IOS Simulator GL_OES_standard_derivatives
In iOS4 GL_OES_standard_derivatives is only supported on device (from what I see when displaying extensions), is there a way:
-
Detecting in the shader a fragment if the extension is supported or not
-
If not supported, does anyone have any code for dFdx and dFdy? Nothing seems to be found on google.
TIA!
+2
source to share
1 answer
I had the same problem for anti-aliasing SDM fonts. You can calculate similar dfdx / dfdx to Translation of 2 2d vectors using the current transformation matrix:
vec2 p1(0,0); vec2 p2(1,1);
p1=TransformUsingCurrentMatrix(p1);
p2=TransformUsingCurrentMatrix(p2);
float magic=35; // you'll need to play with this - it linked to screen size I think :P
float dFdx=(p2.x-p1.x)/magic;
float dFdy=(p2.y-p1.y)/magic;
then send dFdx / dFdy to your uniform shader - and just multiply your parameter to get the same functionality, ie
dFdx(myval)
now becomes
dFdx*myval;
dFdy(myval) dFdy*myval;
fwidth(myval) abs(dFdx*myval)+abs(dFdy*myval);
+1
source to share