GPUImage寫雙輸入的濾鏡

2021-07-10 08:15:30 字數 1734 閱讀 9620

今天主要來講一下怎麼用gpuimage來手擼乙個雙輸入(blend)的濾鏡。

那麼先說一下為什麼要自己手擼多輸入的濾鏡:

雙輸入的濾鏡其實是三輸入(也就是多個輸入端濾鏡)的簡單版,讓大家比較容易上手。

雙輸入的濾鏡可以通過gpuimagetwoinputfilter來實現,只要實現了疊加的演算法就可以了。

_downsoftlightblendfilter = [[gpuimagetwoinputfilter alloc] initwithfragmentshaderfromfile:@"customblendshader"];

customblendshader.fsh **如下:

varying

highp

vec2 texturecoordinate;

varying

highp

vec2 texturecoordinate2;

uniform

sampler2d inputimagetexture;

uniform

sampler2d inputimagetexture2;

void main()

else

}

當然你也可以做別的一些操作,比如 先柔光混合,再讓亮度+0.5:

varying

highp

vec2 texturecoordinate;

varying

highp

vec2 texturecoordinate2;

uniform

sampler2d inputimagetexture;

uniform

sampler2d inputimagetexture2;

void main()

else

gl_fragcolor = vec4((mixcolor.rgb + vec3(0.5)), mixcolor.w);

}

這樣基本就能做只使用兩張混合(例如加上水印)的所有濾鏡效果了。

用法也是非常簡單,直接當成是gpuimagetwoinputfilter來用就好。

別人寫的雙鏈表

寫了個雙向鍊錶 include template struct nodetype template class doublelist template const doublelist doublelist operator const doublelist otherlist if this ot...

雙通輸入法的使用者介面

雙通輸入法的使用者介面 結合我看得那個雙通輸入法程式來總結一下該輸入法的所有使用者介面 啟動並初始化當前ime輸入法 bool imeinquire lpimeinfo lpimeinfo,用於初始化該輸入法的結構位址 lptstr lpszwndclass,當前輸入法的名稱 lpctstr或者dw...

雙通輸入法的使用者介面

結合我看得那個雙通輸入法程式來總結一下該輸入法的所有使用者介面 啟動並初始化當前 ime輸入法 bool imeinquire lpimeinfo lpimeinfo,用於初始化該輸入法的結構位址 lptstr lpszwndclass,當前輸入法的名稱 lpctstr 或者dword lpszda...