libGDX:如何将TextureRegion椎体加载到着色器(GPU)中以对其应用某些效果?

时间:2017-08-01 14:14:03

标签: java opengl opengl-es libgdx

我创建了着色器文件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的专家。

0 个答案:

没有答案