【发布时间】:2015-05-08 11:29:20
【问题描述】:
我看过很多关于晕影着色器的教程,比如 these,但没有一个说如何更改晕影的颜色,他们只谈论将棕褐色或灰色着色器应用于整个合成图像。
例如,上面的视频给出了晕影着色器的以下代码。如何更改小插图的颜色?所以它不是黑色而是红色或橙色,并且小插图内部的图像部分保持不变。
const float outerRadius = .65, innerRadius = .4, intensity = .6;
void main(){
vec4 color = texture2D(u_sampler2D, v_texCoord0) * v_color;
vec2 relativePosition = gl_FragCoord.xy / u_resolution - .5;
relativePosition.y *= u_resolution.x / u_resolution.y;
float len = length(relativePosition);
float vignette = smoothstep(outerRadius, innerRadius, len);
color.rgb = mix(color.rgb, color.rgb * vignette, intensity);
gl_FragColor = color;
}
【问题讨论】:
标签: opengl-es libgdx opengl-es-2.0 shader vertex-shader