0
I’m using a flame engine Engo, and made a Fork and I’m adding some things and at the same time trying to learn more about Opengl.
As it is a graphic question there is how to put an image of what is occurring:
All the images that create the square are the same, and all use the same texture sent to Opengl, just rotate and set the position:
It is a small edge, 8 pixels, the image is 128x128 pixels in total.
As you can see some of the "grids" get smaller or bigger, and depending until they disappear altogether.
This seems to be being caused by TEXTURE_MIN_FILTER
, since he is responsible for determining what should be done when the image needs to be shrunk.
I saw that there are several types of TEXTURE_MIN_FILTER
, since GL_LINEAR
and GL_NEAREST
and also others who require the Mipmap, with the NEAREST_MIPMAP_NEAREST
.
To make work these parameters that need Mipmap you need to create the Mipmap, for this I used the GenerateMipmap
shortly after the TexImage2D
, in this way:
gl.TexImage2D(uint32(target), int32(level), int32(internalFormat), int32(width), int32(height), int32(0), uint32(format), uint32(kind), gl.Ptr(pix))
gl.GenerateMipmap(uint32(target))
Anyway, the problem still persists, and in fact it can get worse. When using Mipmap it turns gray:
Also, use any filter LINEAR
(Whether you need Mipmap or not), it adds a small edge with distinct opacity:
I enlarged this image in Photoshop to make sure there was an edge, and it’s there.
Remember that the image is transparent inside and the edge is all the same opacity, there would be no reason to create an edge, if there wanted to know what would be the reason. And this behavior doesn’t happen in NEAREST
.
The Vertexshader used is:
attribute vec2 in_Position;
attribute vec2 in_TexCoords;
attribute vec4 in_Color;
uniform mat3 matrixProjView;
varying vec4 var_Color;
varying vec2 var_TexCoords;
void main() {
var_Color = in_Color;
var_TexCoords = in_TexCoords;
vec3 matr = matrixProjView * vec3(in_Position, 1.0);
gl_Position = vec4(matr.xy, 0, matr.z);
}
Already the Fragmentshader used is:
#ifdef GL_ES
#define LOWP lowp
precision mediump float;
#else
#define LOWP
#endif
varying vec4 var_Color;
varying vec2 var_TexCoords;
uniform sampler2D uf_Texture;
void main (void) {
gl_FragColor = var_Color * texture2D(uf_Texture, var_TexCoords);
}
The source code is on Github, if necessary. Obviously, the modifications I made, and mentioned above, are not there.
I am a few days ago looking for a solution to the problem, I mentioned here some attempts that came closer to give some result.
I wanted to know what could cause this problem and how could I fix it, if it is a problem with Opengl or if it might even be a problem in arrendomento when calculating the position, for example.
Although the code is in Golang it uses the same API in C, via CGO, and I am using Opengl 4.6