mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 18:52:44 +01:00
graphics: Bug fix: rounding texels is required even on the nearest filter
Fixes #558
This commit is contained in:
parent
d421648e57
commit
927a4388b5
@ -100,6 +100,10 @@ highp vec2 roundTexel(highp vec2 p) {
|
|||||||
void main(void) {
|
void main(void) {
|
||||||
highp vec2 pos = varying_tex_coord;
|
highp vec2 pos = varying_tex_coord;
|
||||||
|
|
||||||
|
// pos might include a very slight error.
|
||||||
|
// roundTexel adjusts pos by rounding it (#315, #558).
|
||||||
|
pos = roundTexel(pos);
|
||||||
|
|
||||||
#if defined(FILTER_NEAREST)
|
#if defined(FILTER_NEAREST)
|
||||||
vec4 color = texture2D(texture, pos);
|
vec4 color = texture2D(texture, pos);
|
||||||
if (pos.x < varying_tex_coord_min.x ||
|
if (pos.x < varying_tex_coord_min.x ||
|
||||||
@ -111,7 +115,6 @@ void main(void) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(FILTER_LINEAR)
|
#if defined(FILTER_LINEAR)
|
||||||
pos = roundTexel(pos);
|
|
||||||
highp vec2 texel_size = 1.0 / source_size;
|
highp vec2 texel_size = 1.0 / source_size;
|
||||||
|
|
||||||
highp vec2 p0 = pos - texel_size / 2.0;
|
highp vec2 p0 = pos - texel_size / 2.0;
|
||||||
@ -142,7 +145,6 @@ void main(void) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(FILTER_SCREEN)
|
#if defined(FILTER_SCREEN)
|
||||||
pos = roundTexel(pos);
|
|
||||||
highp vec2 texel_size = 1.0 / source_size;
|
highp vec2 texel_size = 1.0 / source_size;
|
||||||
pos -= texel_size / 2.0 / scale;
|
pos -= texel_size / 2.0 / scale;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user