internal/builtinshader: bug fix: wrong blending rate

The blending rate of colors in a square vertices should be calculated
by the lower-right point, not the upper-left point.

mix(a, b, rate) function calculates (1-rate)*a + rate*b, so a should
be weighted if rate is close to 0, and b should be weighted if rate
is close to 1. The current implementation was opposite.

Rendering results don't seem to be changed so much actually, but the
current implementation doesn't make sense.
This commit is contained in:
Hajime Hoshi 2023-08-31 15:06:09 +09:00
parent 9ad9bc9ed9
commit 7ed2d73406

View File

@ -97,7 +97,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
c3 := imageSrc0At(p1)
{{end}}
rate := fract(p0)
rate := fract(p1)
clr := mix(mix(c0, c1, rate.x), mix(c2, c3, rate.x), rate.y)
{{end}}