Friday, October 21, 2022
HomeGame Developmentopengl - Half-transparent borders of texture

opengl – Half-transparent borders of texture


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

I feel the pixel-perfect rendering can resolve the difficulty, however IDK find out how to obtain that.
The sport 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.top; // 0.0f
float u1 = (texture.x + texture.width)  / texture.width;  // 1.0f
float v1 = (texture.y + texture.top) / texture.top; // 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

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments