我创建了着色器文件crop.frag
以将效果裁剪为Texture
作为圆形:
#version 150
varying vec4 v_color;
varying vec2 v_texCoord0;
uniform sampler2D u_texture;
vec4 borderColor;
uniform vec3 outlineColor;
uniform float outlineAlpha;
uniform float offset;
uniform float outerRadius;
uniform float innerRadius;
uniform float intensity;
uniform float brightness;
void main() {
vec4 color = texture2D(u_texture, v_texCoord0) * v_color;
borderColor = vec4(outlineColor.rgb, outlineAlpha);
// circle crop
vec2 relativePosition = v_texCoord0.xy - 0.5;
float len = length(relativePosition);
float vignette = smoothstep(outerRadius, innerRadius, len);
color.rgba = mix(color.rgba, color.rgba * vignette, intensity);
// make outline over circle cropped
float vignetteOutline = smoothstep(outerRadius - offset / 100.0, innerRadius - offset / 100.0, len);
borderColor.rgba = mix(borderColor.rgba, color.rgba * vignetteOutline, color.a * vignetteOutline);
gl_FragColor = color * (borderColor + brightness + 0.20);
}
将此着色器应用于Texture
可以正常工作。但是,如果我将其应用于TextureRegion
的单Texture
,效果仅适用于region.getTexture();
。
所以,我想修改着色器文件中的region
个顶点。
我不是GL Shader Language的专家。