iOS Simulator GL_OES_standard_derivatives

北城以北 提交于 2019-12-12 18:31:36

问题


On iOS4 GL_OES_standard_derivatives is only supported on the device (from what I see when I output the extensions), is there a way to be able to:

  1. Detect in the fragment shader if the extension is supported or not

  2. If not supported, does anyone have a the code for the dFdx and dFdy? Can't seems that find anything on google.

TIA!


回答1:


I had the same issue for antialiasing SDM fonts. You can calculate a similar dfdx/dfdx by Translating 2 2d vectors using the current transform 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's 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 shader as uniforms - and simply multiply with your parameter to get the same functionality i.e.

dFdx(myval) now becomes

dFdx*myval;
dFdy(myval)   dFdy*myval;
fwidth(myval) abs(dFdx*myval)+abs(dFdy*myval);


来源:https://stackoverflow.com/questions/5959542/ios-simulator-gl-oes-standard-derivatives

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!