iOS模拟器GL_OES_standard_derivatives [英] iOS Simulator GL_OES_standard_derivatives
问题描述
在iOS4上,仅设备支持GL_OES_standard_derivatives(从我输出扩展名时所看到的),有没有办法:
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:
-
在片段着色器中检测是否支持扩展
Detect in the fragment shader if the extension is supported or not
如果不支持,是否有人拥有dFdx和dFdy的代码?似乎无法在Google上找到任何内容.
If not supported, does anyone have a the code for the dFdx and dFdy? Can't seems that find anything on google.
TIA!
推荐答案
对于抗锯齿SDM字体,我遇到了同样的问题.您可以通过以下方式计算相似的dfdx/dfdx: 使用当前的变换矩阵转换2个2d向量:
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;
然后将dFdx/dFdy作为制服发送到着色器-只需与您的参数相乘即可获得相同的功能,即
then send dFdx/dFdy to your shader as uniforms - and simply multiply with your parameter to get the same functionality i.e.
dFdx(myval)
现在变为
dFdx*myval;
dFdy(myval) dFdy*myval;
fwidth(myval) abs(dFdx*myval)+abs(dFdy*myval);
这篇关于iOS模拟器GL_OES_standard_derivatives的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!