跳到主要内容
← Image Manipulation with Shaders

Image Manipulation with Shaders

Saturation

忘了其实用dot就好了

实时渲染 · 纹理 GLSL

第 6 课:Saturation

我的解:忘了其实用dot就好了

我的解

uniform vec2 iResolution;
uniform sampler2D iChannel0;

vec3 RelativeLuminance(vec4 tex){
  return vec3(tex.r * 0.2126 + tex.g * 0.7152 + tex.b * 0.0722);
}

void main() {
  // Normalized pixel coordinates (from 0 to 1)
  vec2 uv = gl_FragCoord.xy / iResolution.xy;
  vec4 tex = texture(iChannel0, uv);
  vec3 luminance = RelativeLuminance(tex);
  vec3 saturated = mix(luminance,tex.rgb,5.0);
  gl_FragColor = vec4(saturated,1.0);
}

复盘笔记

  • 忘了其实用dot就好了
  • mix 像素某亮度 * (-5.0) + 贴图 * (5.0),增加色度的同时减少爆出来的亮度