我有原始图片:
http://i.stack.imgur.com/7qYW2.png
我如何在这张图片上绘画,而不是得到以下内容:
http://i.stack.imgur.com/w3ij3.png
PS:此代码无效:
public void render() {
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batcher.begin();
batcher.setColor(Color.BLUE);
batcher.draw(texture, x, y, width, height);
batcher.end();
}
最佳答案
您可以使用具有以下逻辑的片段着色器:
if(alpha of the pixel is 1.0) then pixel=cyan
else pixel=white
当然,这需要包围企鹅的空间是透明的(具有a = 0)
varying vec4 v_color;
varying vec2 v_texCoords;
uniform sampler2D u_texture;
void main() {
vec4 color=v_color * texture2D(u_texture, v_texCoords);
if(color.a==1.0)gl_FragColor=vec4(0.5,0.5,1,1);
else gl_FragColor=vec(0.0,0.0,0.0,0.0);
}