IOS – OPenGL ES 调节图像饱和度 GPUImageSaturationFilter

目录

创新互联公司是创新、创意、研发型一体的综合型网站建设公司,自成立以来公司不断探索创新,始终坚持为客户提供满意周到的服务,在本地打下了良好的口碑,在过去的十年时间我们累计服务了上千家以及全国政企客户,如成都房屋鉴定等企业单位,完善的项目管理流程,严格把控项目进度与质量监控加上过硬的技术实力获得客户的一致称誉。

  • 一.简介
  • 二.效果演示
  • 三.源码下载
  • 四.猜你喜欢

零基础 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 , 视觉效果相关.

GPUImageSaturationFilter 属于 GPUImage 颜色处理相关,用来处理图片饱和度,shader 源码如下:

/******************************************************************************************/
//@Author:猿说编程
//@Blog(个人博客地址): www.codersrc.com
//@File:IOS – OPenGL ES 调节图像饱和度 GPUImageSaturationFilter
//@Time:2022/03/12 07:30
//@Motto:不积跬步无以至千里,不积小流无以成江海,程序人生的精彩需要坚持不懈地积累!
/******************************************************************************************/

#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
NSString *const kGPUImageSaturationFragmentShaderString = SHADER_STRING
(
 varying highp vec2 textureCoordinate;

 uniform sampler2D inputImageTexture;
 uniform lowp float saturation;

 // Values from "Graphics Shaders: Theory and Practice" by Bailey and Cunningham
 const mediump vec3 luminanceWeighting = vec3(0.2125, 0.7154, 0.0721);

 void main()
 {
    lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
    lowp float luminance = dot(textureColor.rgb, luminanceWeighting);
    lowp vec3 greyScaleColor = vec3(luminance);

	gl_FragColor = vec4(mix(greyScaleColor, textureColor.rgb, saturation), textureColor.w);

 }
);
#else
NSString *const kGPUImageSaturationFragmentShaderString = SHADER_STRING
(
 varying vec2 textureCoordinate;

 uniform sampler2D inputImageTexture;
 uniform float saturation;

 // Values from "Graphics Shaders: Theory and Practice" by Bailey and Cunningham
 const vec3 luminanceWeighting = vec3(0.2125, 0.7154, 0.0721);

 void main()
 {
     vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
     float luminance = dot(textureColor.rgb, luminanceWeighting);
     vec3 greyScaleColor = vec3(luminance);

     gl_FragColor = vec4(mix(greyScaleColor, textureColor.rgb, saturation), textureColor.w);

 }
 );
#endif

二.效果演示

三.源码下载

下载地址:IOS – OPenGL ES 调节图像饱和度 GPUImageSaturationFilter

四.猜你喜欢

  • IOS – OPenGL ES 设置图像亮度 GPUImageBrightnessFilter
  • IOS – OPenGL ES 调节图像曝光度 GPUImageExposureFilter
  • IOS – OpenGL ES 调节图像对比度 GPUImageContrastFilter
  • IOS – OPenGL ES 调节图像饱和度 GPUImageSaturationFilter

本文由博客 - 猿说编程 猿说编程 发布!


本文名称:IOS – OPenGL ES 调节图像饱和度 GPUImageSaturationFilter
网页URL:http://ybzwz.com/article/dsoijji.html