分享一个我厂 iOS 程序员写的水纹滤镜源码 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
请不要在回答技术问题时复制粘贴 AI 生成的内容
liuliupet
V2EX    程序员

分享一个我厂 iOS 程序员写的水纹滤镜源码

  •  
  •   liuliupet 2015-04-01 17:30:05 +08:00 5890 次点击
    这是一个创建于 3854 天前的主题,其中的信息可能已经有所发展或是发生改变。
    17 条回复    2015-04-21 14:32:33 +08:00
    wzyuliyang
        1
    wzyuliyang  
       2015-04-01 18:35:59 +08:00
    GPU?????
    kepenj
        2
    kepenj  
       2015-04-01 19:12:31 +08:00
    感谢分享
    sincway
        3
    sincway  
       2015-04-01 19:29:12 +08:00
    看起来很不错的样子
    PP
        4
    PP  
       2015-04-01 20:42:16 +08:00 via iPad   1
    好逼真,我还以为我的屏幕出了问题。
    liuliupet
        5
    liuliupet  
    OP
       2015-04-01 21:10:15 +08:00
    @wzyuliyang OpenGLES
    liuliupet
        6
    liuliupet  
    OP
       2015-04-01 21:12:52 +08:00
    @sincway 在准备做一个哈哈镜的App
    sumhat
        7
    sumhat  
       2015-04-01 21:15:24 +08:00
    目测源码里有一堆 double 型常量,你们厂只能祈祷那个程序员不要离职了....
    lzsadam
        8
    lzsadam  
       2015-04-01 21:31:04 +08:00
    猛一看还以为阿森纳有iOS程序员。
    zhangchioulin
        9
    zhangchioulin  
       2015-04-01 21:40:53 +08:00
    好逼真!!
    sophymax
        10
    sophymax  
       2015-04-01 22:59:45 +08:00 via iPad
    那用的是个什么库,GPUImage开头的那一堆?看到这个第一感觉是写的opengl shader,但打眼一看好像没shader文件,只有一堆GPUimagexxxxxx文件
    ryd994
        11
    ryd994  
       2015-04-01 23:35:31 +08:00 via Android
    @sumhat 求问double常量是什么坑?
    sumhat
        12
    sumhat  
       2015-04-01 23:41:30 +08:00   1
    @ryd994 就是形如这样的代码,摘录自楼主的 Github。一点注释都没有,后人完全没办法维护。

    void main()
    {
    vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
    vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);

    float maskY = 0.2989 * colorToReplace.r + 0.5866 * colorToReplace.g + 0.1145 * colorToReplace.b;
    float maskCr = 0.7132 * (colorToReplace.r - maskY);
    float maskCb = 0.5647 * (colorToReplace.b - maskY);

    float Y = 0.2989 * textureColor.r + 0.5866 * textureColor.g + 0.1145 * textureColor.b;
    float Cr = 0.7132 * (textureColor.r - Y);
    float Cb = 0.5647 * (textureColor.b - Y);

    // float blendValue = 1.0 - smoothstep(thresholdSensitivity - smoothing, thresholdSensitivity , abs(Cr - maskCr) + abs(Cb - maskCb));
    float blendValue = 1.0 - smoothstep(thresholdSensitivity, thresholdSensitivity + smoothing, distance(vec2(Cr, Cb), vec2(maskCr, maskCb)));
    gl_FragColor = mix(textureColor, textureColor2, blendValue);
    }
    theoractice
        13
    theoractice  
       2015-04-02 01:41:40 +08:00   1
    liyonghelpme
        14
    liyonghelpme  
       2015-04-02 09:18:12 +08:00
    学shader 上这个网站哈哈 有一起玩得同学没 https://www.shadertoy.com/
    magicianzrh
        15
    magicianzrh  
       2015-04-02 09:56:04 +08:00
    kepenj
        16
    kepenj  
       2015-04-02 13:28:13 +08:00
    theoractice
        17
    theoractice  
       2015-04-21 14:32:33 +08:00
    @sumhat 那些常量是色彩空间转换公式里用到的。RGB转灰度时也会用到类似的常量。
    科学家研究的结果,不需要改~
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2626 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 24ms UTC 12:32 PVG 20:32 LAX 05:32 JFK 08:32
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86