Add inset on layers for animations to avoid bleed; change GL settings to avoid stretching pixels if crop larger than texture size

This commit is contained in:
2025-11-17 03:15:34 -05:00
parent b207a78a1f
commit 61e38a1482
2 changed files with 12 additions and 5 deletions

View File

@@ -392,13 +392,20 @@ namespace anm2ed::imgui
math::percent_to_unit(frame.scale), frame.rotation);
auto layerTransform = transform * layerModel;
auto uvMin = frame.crop / vec2(texture.size);
auto uvMax = (frame.crop + frame.size) / vec2(texture.size);
auto vertices = math::uv_vertices_get(uvMin, uvMax);
auto texSize = vec2(texture.size);
if (texSize.x <= 0.0f || texSize.y <= 0.0f) continue;
auto uvMin = frame.crop / texSize;
auto uvMax = (frame.crop + frame.size) / texSize;
vec3 frameColorOffset = frame.colorOffset + colorOffset;
vec4 frameTint = frame.tint;
frameTint.a = std::max(0.0f, frameTint.a - alphaOffset);
auto inset = vec2(0.5f) / texSize;
uvMin += inset;
uvMax -= inset;
auto vertices = math::uv_vertices_get(uvMin, uvMax);
texture_render(shaderTexture, texture.id, layerTransform, frameTint, frameColorOffset, vertices.data());
auto color = isOnionskin ? vec4(colorOffset, 1.0f - alphaOffset) : color::RED;

View File

@@ -43,8 +43,8 @@ namespace anm2ed::resource
glBindTexture(GL_TEXTURE_2D, id);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);