add slight texture inset for layer UVs.
This commit is contained in:
@@ -65,6 +65,11 @@ struct Canvas
|
|||||||
0, 1, uvMin.x, uvMax.y \
|
0, 1, uvMin.x, uvMax.y \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define ATLAS_UV_MIN(type) (ATLAS_POSITION(type) / TEXTURE_ATLAS_SIZE)
|
||||||
|
#define ATLAS_UV_MAX(type) ((ATLAS_POSITION(type) + ATLAS_SIZE(type)) / TEXTURE_ATLAS_SIZE)
|
||||||
|
#define ATLAS_UV_ARGS(type) ATLAS_UV_MIN(type), ATLAS_UV_MAX(type)
|
||||||
|
#define ATLAS_UV_VERTICES(type) UV_VERTICES(ATLAS_UV_MIN(type), ATLAS_UV_MAX(type))
|
||||||
|
|
||||||
mat4 canvas_transform_get(Canvas* self, vec2 pan, f32 zoom, OriginType origin);
|
mat4 canvas_transform_get(Canvas* self, vec2 pan, f32 zoom, OriginType origin);
|
||||||
void canvas_axes_draw(Canvas* self, GLuint& shader, mat4& transform, vec4& color);
|
void canvas_axes_draw(Canvas* self, GLuint& shader, mat4& transform, vec4& color);
|
||||||
void canvas_bind(Canvas* self);
|
void canvas_bind(Canvas* self);
|
||||||
|
@@ -38,8 +38,9 @@ void generate_preview_draw(GeneratePreview* self)
|
|||||||
const s32 column = index % columns;
|
const s32 column = index % columns;
|
||||||
vec2 crop = startPosition + vec2(size.x * column, size.y * row);
|
vec2 crop = startPosition + vec2(size.x * column, size.y * row);
|
||||||
|
|
||||||
vec2 uvMin = crop / vec2(texture.size);
|
vec2 textureSize = vec2(texture.size);
|
||||||
vec2 uvMax = (crop + size) / vec2(texture.size);
|
vec2 uvMin = (crop + vec2(0.5f)) / textureSize;
|
||||||
|
vec2 uvMax = (crop + size - vec2(0.5f)) / textureSize;
|
||||||
f32 vertices[] = UV_VERTICES(uvMin, uvMax);
|
f32 vertices[] = UV_VERTICES(uvMin, uvMax);
|
||||||
|
|
||||||
mat4 generateTransform = transform * quad_model_get(size, {}, pivot);
|
mat4 generateTransform = transform * quad_model_get(size, {}, pivot);
|
||||||
|
@@ -134,8 +134,9 @@ void preview_draw(Preview* self)
|
|||||||
Texture& texture = spritesheet->texture;
|
Texture& texture = spritesheet->texture;
|
||||||
if (texture.isInvalid) return;
|
if (texture.isInvalid) return;
|
||||||
|
|
||||||
vec2 uvMin = frame.crop / vec2(texture.size);
|
vec2 inset = 0.5f / vec2(texture.size);
|
||||||
vec2 uvMax = (frame.crop + frame.size) / vec2(texture.size);
|
vec2 uvMin = frame.crop / vec2(texture.size) + inset;
|
||||||
|
vec2 uvMax = (frame.crop + frame.size) / vec2(texture.size) - inset;
|
||||||
f32 vertices[] = UV_VERTICES(uvMin, uvMax);
|
f32 vertices[] = UV_VERTICES(uvMin, uvMax);
|
||||||
canvas_texture_draw(&self->canvas, shaderTexture, texture.id, layerTransform, vertices, frameTint, frameColorOffset);
|
canvas_texture_draw(&self->canvas, shaderTexture, texture.id, layerTransform, vertices, frameTint, frameColorOffset);
|
||||||
|
|
||||||
|
@@ -126,4 +126,4 @@ bool texture_pixel_set(Texture* self, ivec2 position, vec4 color)
|
|||||||
glTexSubImage2D(GL_TEXTURE_2D, 0,position.x, position.y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, rgba8);
|
glTexSubImage2D(GL_TEXTURE_2D, 0,position.x, position.y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, rgba8);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user