mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
internal/shader: bug fix: div between a matrix and a flaot failed
Closes #2719
This commit is contained in:
parent
6bb91433d7
commit
6fa8c02d4a
@ -196,6 +196,8 @@ func (cs *compileState) parseExpr(block *block, fname string, expr ast.Expr, mar
|
|||||||
t = lhst
|
t = lhst
|
||||||
case op2 == shaderir.MatrixMul && lhst.IsMatrix() && rhst.IsFloatVector():
|
case op2 == shaderir.MatrixMul && lhst.IsMatrix() && rhst.IsFloatVector():
|
||||||
t = rhst
|
t = rhst
|
||||||
|
case op2 == shaderir.Div && lhst.IsMatrix() && rhst.Main == shaderir.Float:
|
||||||
|
t = lhst
|
||||||
case lhst.Main == shaderir.Float && rhst.IsFloatVector():
|
case lhst.Main == shaderir.Float && rhst.IsFloatVector():
|
||||||
t = rhst
|
t = rhst
|
||||||
case lhst.Main == shaderir.Int && rhst.IsIntVector():
|
case lhst.Main == shaderir.Int && rhst.IsIntVector():
|
||||||
|
@ -2112,3 +2112,39 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Issue #2719
|
||||||
|
func TestShaderMatrixDivFloat(t *testing.T) {
|
||||||
|
const w, h = 16, 16
|
||||||
|
|
||||||
|
src := ebiten.NewImage(w, h)
|
||||||
|
src.Fill(color.RGBA{R: 0x10, G: 0x20, B: 0x30, A: 0xff})
|
||||||
|
|
||||||
|
dst := ebiten.NewImage(w, h)
|
||||||
|
s, err := ebiten.NewShader([]byte(`//kage:unit pixels
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||||
|
var x = 2.0
|
||||||
|
return mat4(3) / x * imageSrc0At(texCoord);
|
||||||
|
}
|
||||||
|
`))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
op := &ebiten.DrawRectShaderOptions{}
|
||||||
|
op.Images[0] = src
|
||||||
|
dst.DrawRectShader(w, h, s, op)
|
||||||
|
|
||||||
|
for j := 0; j < h; j++ {
|
||||||
|
for i := 0; i < w; i++ {
|
||||||
|
got := dst.At(i, j).(color.RGBA)
|
||||||
|
want := color.RGBA{R: 0x18, G: 0x30, B: 0x48, A: 0xff}
|
||||||
|
if !sameColors(got, want, 2) {
|
||||||
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user