graphics: Allow a little margin for edge pixels

This commit is contained in:
Hajime Hoshi 2018-05-13 23:00:06 +09:00
parent a1dd7b39a3
commit d7d892f2d6
2 changed files with 8 additions and 8 deletions

View File

@ -541,11 +541,11 @@ func TestImageEdge(t *testing.T) {
transparent := color.RGBA{0, 0, 0, 0} transparent := color.RGBA{0, 0, 0, 0}
angles := []float64{} angles := []float64{}
for a := 0; a < 360; a++ { for a := 0; a < 1440; a++ {
angles = append(angles, float64(a)/360*2*math.Pi) angles = append(angles, float64(a)/1440*2*math.Pi)
} }
for a := 0; a < 256; a++ { for a := 0; a < 4096; a++ {
angles = append(angles, float64(a)/256*2*math.Pi) angles = append(angles, float64(a)/4096*2*math.Pi)
} }
for _, f := range []Filter{FilterNearest, FilterLinear} { for _, f := range []Filter{FilterNearest, FilterLinear} {

View File

@ -94,8 +94,8 @@ void main(void) {
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 ||
pos.y < varying_tex_coord_min.y || pos.y < varying_tex_coord_min.y ||
(varying_tex_coord_max.x - texel_size.x / 256.0) <= pos.x || (varying_tex_coord_max.x - texel_size.x / 512.0) <= pos.x ||
(varying_tex_coord_max.y - texel_size.y / 256.0) <= pos.y) { (varying_tex_coord_max.y - texel_size.y / 512.0) <= pos.y) {
color = vec4(0, 0, 0, 0); color = vec4(0, 0, 0, 0);
} }
#endif #endif
@ -115,11 +115,11 @@ void main(void) {
c0 = vec4(0, 0, 0, 0); c0 = vec4(0, 0, 0, 0);
c1 = vec4(0, 0, 0, 0); c1 = vec4(0, 0, 0, 0);
} }
if ((varying_tex_coord_max.x - texel_size.x / 256.0) <= p1.x) { if ((varying_tex_coord_max.x - texel_size.x / 512.0) <= p1.x) {
c1 = vec4(0, 0, 0, 0); c1 = vec4(0, 0, 0, 0);
c3 = vec4(0, 0, 0, 0); c3 = vec4(0, 0, 0, 0);
} }
if ((varying_tex_coord_max.y - texel_size.y / 256.0) <= p1.y) { if ((varying_tex_coord_max.y - texel_size.y / 512.0) <= p1.y) {
c2 = vec4(0, 0, 0, 0); c2 = vec4(0, 0, 0, 0);
c3 = vec4(0, 0, 0, 0); c3 = vec4(0, 0, 0, 0);
} }