Here are two pictures of the same image:
this is what it looks like when viewed in preview...
and this is how it looks in my game...
Obviously the character is scaled down in my game, however, when I scale down the sprite in preview or pixelmator, it is still smooth. Even when the image is at a 1:1 scale it still has the jagged edges.
This is my render method
public void render(Camera camera, List<Entity> entities) {
shader.loadViewMatrix(Main.createViewMatrix(camera));
//per textured model
GL30.glBindVertexArray(((RenderComponent) entities.get(0).getComponent(EntityComponentType.RENDER)).texturedModel.getRawModel().getVaoID());
GL20.glEnableVertexAttribArray(0);
GL20.glEnableVertexAttribArray(1);
for(Entity e : entities) {
RenderComponent render = (RenderComponent) e.getComponent(EntityComponentType.RENDER);
//load transformation matrix per entity
shader.loadTransformationMatrix(Main.createTransformationMatrix(render.position, render.rx, render.ry, render.getScaleX(), render.getScaleY()));
shader.loadSprite((AnimationComponentContainer) e.getComponent(EntityComponentType.ANIMATION));
//activate texture for each entity
GL13.glActiveTexture(GL13.GL_TEXTURE0);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, render.getTexturedModel().getTexture().getTextureID());
//render entity
GL11.glDrawElements(GL11.GL_TRIANGLES, render.getTexturedModel().getRawModel().getVertexCount(), GL11.GL_UNSIGNED_INT, 0);
}
//per textured model
GL20.glDisableVertexAttribArray(0);
GL20.glDisableVertexAttribArray(1);
GL30.glBindVertexArray(0);
}
And in my fragment shader I sample the image
vec4 color = texture(sampler, pass_TextureCoords);
and remove transparency
if(color.a < 0.5) discard;
out_Color = vec4(totalDiffuse, 1) * color;
My question is, how do I prevent the jagged edges from occurring (they are most prominent around his pants)? Or how do I smooth them out? The image itself if 512x1024
Aucun commentaire:
Enregistrer un commentaire