效果图
之前写过一篇偏理论的介绍镜头眩光的文章 ShaderJoy —— 伪镜头眩光 【GLSL】,这次介绍另一种直接用 shader 实现的效果(实现起来更简单,而且效果也还不错)。
废话不多说,直接上代码!
完整代码和注释
#iChannel0::WrapMode "Repeat"
#iChannel0 "file://../ShaderToy/image (5).png"
float noise(float t)
{
return texture(iChannel0, vec2(t, .0) / iResolution.xy).x;
}
float noise(vec2 t)
{
return texture(iChannel0, t / iResolution.xy).x;
}
float flare0(vec2 pos, float a, float b, float c)
{
return max(1.0 / (1.0 + 32.0 * pow(length(pos), a)), b) * c;
}
float flare1(vec2 pos, float r, float b, float c)
{
return max(0.01 - pow(length(pos), r), b) * c;
}
#iUniform float noiseWe