Reputation: 1134
I am game developer using libGDX framework, but new in shader
OpenGL. I was trying to do outer glow like this image:
I found simple tutorials in different sites for example like this 2D Selection Outline Shader in LibGDX. It works fine but Outline only drew and the image didn't draw I don't know why !
The image:
In render method:
@Override
public void render() {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
shaderOutline.begin();
shaderOutline.setUniformf("u_viewportInverse", new Vector2(1f / 99, 1f / 94));
shaderOutline.setUniformf("u_offset", 2);
shaderOutline.setUniformf("u_step", Math.min(1f, 99 / 70f));
shaderOutline.setUniformf("u_color", new Vector3(123/255, 1, 71/255));
shaderOutline.end();
batch.setShader(shaderOutline);
batch.begin();
batch.draw(img, 240, 400);
batch.end();
batch.setShader(null);
}
Output:
Finally, I need any advice in this field (shading language).
Upvotes: 1
Views: 2697
Reputation: 6028
You need to add the drawing of the image
itself as well:
In render
:
batch.setShader(shaderOutline);
batch.begin();
batch.draw(img, 240, 400);
batch.end();
batch.setShader(null);
// Add this:
batch.begin();
batch.draw(img, 240, 400);
batch.end();
Upvotes: 1