Home Game Development opengl – Half-transparent borders of texture

opengl – Half-transparent borders of texture

0
opengl – Half-transparent borders of texture

[ad_1]

I’m dealing with the gaps between the feel that I render and the stuff round it. I consider the issue is with no pixel-perfect rendering. Rendered texture has half-transparent borders, so it produces gaps between different workers. As you may see on the connected screenshot, alpha is totally different, so there aren’t any gaps generally.

I believe the pixel-perfect rendering can resolve the difficulty, however IDK the best way to obtain that.
The recreation is designed for a number of gadgets, desired view measurement is utilized.

For instance:

vec2 screen_size(1920, 1080);
float scale = screen_size.y / 768;
float view_width  = screen_size.x / scale;
float view_height = screen_size.y / scale;

Params I take advantage of earlier than rendering:

glViewport(0, 0, spherical(scale * view_width), spherical(scale * view_height));
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

float u0 = texture.x / texture.width;  // 0.0f
float v0 = texture.y / texture.peak; // 0.0f
float u1 = (texture.x + texture.width)  / texture.width;  // 1.0f
float v1 = (texture.y + texture.peak) / texture.peak; // 1.0f

Ortho projection is used within the vertex shader, additionally premultiplied alpha is utilized.

Idk what so as to add else, not a professional on this subject.

That is how gaps look

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here