目录
- 一.简介
- 二.效果演示
- 三.源码下载
- 四.猜你喜欢
零基础 OpenGL (ES) 推荐学习路线 : OpenGL (ES) 学习目录 >> OpenGL ES 基础
零基础 OpenGL (ES) 推荐学习路线 : OpenGL (ES) 学习目录 >> OpenGL ES 转场
零基础 OpenGL (ES) 推荐学习路线 : OpenGL (ES) 学习目录 >> OpenGL ES 特效
零基础 OpenGL (ES) 推荐学习路线 : OpenGL (ES) 学习目录 >> OpenGL ES 函数
零基础 OpenGL (ES) 推荐学习路线 : OpenGL (ES) 学习目录 >> OpenGL ES GPUImage 使用
零基础 OpenGL (ES) 推荐学习路线 : OpenGL (ES) 学习目录 >> OpenGL ES GLSL 编程
一.简介
GPUImage 共 125 个滤镜, 分为四类
1、Color adjustments : 31 filters , 颜色处理相关 2、Image processing : 40 filters , 图像处理相关. 3、Blending modes : 29 filters , 与混合模式有关. 4、Visual effects : 25 filters , 视觉效果相关.
GPUImageLookupFilter:使用 RGB 颜色搜索图像在图像中重新映射的颜色。 首先,使用你最喜欢的照片编辑应用程序
GPUImage / framework / Resources中 lookup.png 应用一个过滤器。 为了使其正常工作,每个像素的颜色必须不依赖于其他像素(例如,模糊不起作用)。 如果需要更复杂的过滤器,可以根据需要创建任何数量的搜索表。 一旦准备就绪,请使用新的 lookup.png 文件作为GPUImageLookupFilter第二个输入。
shader 源码如下:
/******************************************************************************************/ //@Author:猿说编程 //@Blog(个人博客地址): www.codersrc.com //@File:IOS – OpenGL ES 设置图像 lookup 滤镜 GPUImageLookupFilter //@Time:2022/04/07 07:30 //@Motto:不积小步不至千里,不积小流就不能成江海,精彩的程序生活需要不懈的积累! /******************************************************************************************/ #if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE NSString *const kGPUImageLookupFragmentShaderString = SHADER_STRING ( varying highp vec2 textureCoordinate; varying highp vec2 textureCoordinate2; // TODO: This is not used uniform sampler2D inputImageTexture; uniform sampler2D inputImageTexture2; // lookup texture uniform lowp float intensity; void main() { highp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate); highp float blueColor = textureColor.b * 63.0; highp vec2 quad1; quad1.y = floor(floor(blueColor) / 8.0); quad1.x = floor(blueColor) - (quad1.y * 8.0); highp vec2 quad2; quad2.y = floor(ceil(blueColor) / 8.0); quad2.x = ceil(blueColor) - (quad2.y * 8.0); highp vec2 texPos1; texPos1.x = (quad1.x * 0.125) 0.5/512.0 ((0.125 - 1.0/512.0) * textureColor.r); texPos1.y = (quad1.y * 0.125) 0.5/512.0 ((0.125 - 1.0/512.0) * textureColor.g); highp vec2 texPos2; texPos2.x = (quad2.x * 0.125) 0.5/512.0 ((0.125 - 1.0/512.0) * textureColor.r); texPos2.y = (quad2.y * 0.125) 0.5/512.0 ((0.125 - 1.0/512.0) * textureColor.g); lowp vec4 newColor1 = texture2D(inputImageTexture2, texPos1); lowp vec4 newColor2 = texture2D(inputImageTexture2, texPos2); lowp vec4 newColor = mix(newColor1, newColor2, fract(blueColor)); gl_FragColor = mix(textureColor, vec4(newColor.rgb, textureColor.w), intensity); } ); #else NSString *const kGPUImageLookupFragmentShaderString = SHADER_STRING ( varying vec2 textureCoordinate; varying vec2 textureCoordinate2; // TODO: This is not used uniform sampler2D inputImageTexture; uniform sampler2D inputImageTexture2; // lookup texture uniform float intensity; void main() { vec4 textureColor = texture2D(inputImageTexture, textureCoordinate); float blueColor = textureColor.b * 63.0; vec2 quad1; quad1.y = floor(floor(blueColor) / 8.0); quad1.x = floor(blueColor) - (quad1.y * 8.0); vec2 quad2; quad2.y = floor(ceil(blueColor) / 8.0); quad2.x = ceil(blueColor) - (quad2.y * 8.0); vec2 texPos1; texPos1.x = (quad1.x * 0.125) 0.5/512.0 ((0.125 - 1.0/512.0) * textureColor.r); texPos1.y = (quad1.y * 0.125) 0.5/512.0 ((0.125 - 1.0/512.0) * textureColor.g); vec2 texPos2; texPos2.x = (quad2.x * 0.125) 0.5/512.0 ((0.125 - 1.0/512.0) * textureColor.r); texPos2.y = (quad2.y * 0.125) 0.5/512.0 ((0.125 - 1.0/512.0) * textureColor.g); vec4 newColor1 = texture2D(inputImageTexture2, texPos1); vec4 newColor2 = texture2D(inputImageTexture2, texPos2); vec4 newColor = mix(newColor1, newColor2, fract(blueColor)); gl_FragColor = mix(textureColor, vec4(newColor.rgb, textureColor.w), intensity); } ); #endif
二.效果演示
使用 ** * 处理图片 ****lookup 滤镜****,原图:
效果图:
三.源码下载
OpenGL ES Demo 下载地址 : IOS – OpenGL ES 设置图像 lookup 滤镜 GPUImageLookupFilter
四.猜你喜欢
- IOS – OPenGL ES 设置图像亮度 GPUImageBrightnessFilter
- IOS – OPenGL ES 调节图像曝光度 GPUImageExposureFilter
- IOS – OpenGL ES 调节图像对比度 GPUImageContrastFilter
- IOS – OPenGL ES 调节图像饱和度 GPUImageSaturationFilter
- IOS – OPenGL ES 调节图像伽马线 GPUImageGammaFilter
- IOS – OpenGL ES 调节图像反色 GPUImageColorInvertFilter
- IOS – OpenGL ES 调节图像褐色 GPUImageSepiaFilter
- IOS – OpenGL ES 调节图像灰色 GPUImageGrayscaleFilter
- IOS – OpenGL ES 调节图像 RGB 通道 GPUImageRGBFilter
- IOS – OpenGL ES 调节图像不透明度 GPUImageOpacityFilter
- IOS – OpenGL ES 调节图像阴影 GPUImageHighlightShadowFilter
- IOS – OpenGL ES 调节图像色彩替换 GPUImageFalseColorFilter
- GPUImage – 色彩直方图 GPUImageHistogramFilter
- GPUImage – 色彩直方图 GPUImageHistogramGenerator
- GPUImage – 像素平均色值 GPUImageAverageColor
- GPUImage – 亮度平均 GPUImageLuminosity
- IOS – OpenGL ES 调节图像色度 GPUImageHueFilter
- IOS – OpenGL ES 指定颜色抠图 GPUImageChromaKeyFilter
- IOS – OpenGL ES 调节图像白平衡/色温 GPUImageWhiteBalanceFilter
- IOS – OpenGL ES 设置图像 lookup 滤镜 GPUImageLookupFilter