mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
shader: Allow to mix an int and a float in a binary expression
Updates #1190
This commit is contained in:
parent
eb136daa39
commit
40e581c19f
@ -35,8 +35,8 @@ var Time float
|
||||
|
||||
func Vertex(position vec2, texCoord vec2, color vec4) vec4 {
|
||||
return mat4(
|
||||
2.0/viewportSize().x, 0, 0, 0,
|
||||
0, 2.0/viewportSize().y, 0, 0,
|
||||
2/viewportSize().x, 0, 0, 0,
|
||||
0, 2/viewportSize().y, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
-1, -1, 0, 1,
|
||||
) * vec4(position, 0, 1)
|
||||
@ -45,11 +45,11 @@ func Vertex(position vec2, texCoord vec2, color vec4) vec4 {
|
||||
func Fragment(position vec4) vec4 {
|
||||
pos := position.xy / viewportSize()
|
||||
color := 0.0
|
||||
color += sin(pos.x * cos(Time / 15.0) * 80.0) + cos(pos.y * cos(Time / 15.0) * 10.0)
|
||||
color += sin(pos.y * sin(Time / 10.0) * 40.0) + cos(pos.x * sin(Time / 25.0) * 40.0)
|
||||
color += sin(pos.x * sin(Time / 5.0) * 10.0) + sin(pos.y * sin(Time / 35.0) * 80.0)
|
||||
color *= sin(Time / 10.0) * 0.5
|
||||
return vec4(color, color * 0.5, sin(color + Time / 3.0 ) * 0.75, 1.0)
|
||||
color += sin(pos.x * cos(Time / 15) * 80) + cos(pos.y * cos(Time / 15) * 10)
|
||||
color += sin(pos.y * sin(Time / 10) * 40) + cos(pos.x * sin(Time / 25) * 40)
|
||||
color += sin(pos.x * sin(Time / 5) * 10) + sin(pos.y * sin(Time / 35) * 80)
|
||||
color *= sin(Time / 10) * 0.5
|
||||
return vec4(color, color * 0.5, sin(color + Time / 3 ) * 0.75, 1)
|
||||
}`
|
||||
|
||||
type Game struct {
|
||||
|
@ -879,6 +879,8 @@ func (cs *compileState) parseExpr(block *block, expr ast.Expr) ([]shaderir.Expr,
|
||||
t = lhst
|
||||
} else if lhst.Main == shaderir.Float || lhst.Main == shaderir.Int {
|
||||
switch rhst.Main {
|
||||
case shaderir.Int:
|
||||
t = lhst
|
||||
case shaderir.Float, shaderir.Vec2, shaderir.Vec3, shaderir.Vec4, shaderir.Mat2, shaderir.Mat3, shaderir.Mat4:
|
||||
t = rhst
|
||||
default:
|
||||
@ -887,6 +889,8 @@ func (cs *compileState) parseExpr(block *block, expr ast.Expr) ([]shaderir.Expr,
|
||||
}
|
||||
} else if rhst.Main == shaderir.Float || rhst.Main == shaderir.Int {
|
||||
switch lhst.Main {
|
||||
case shaderir.Int:
|
||||
t = rhst
|
||||
case shaderir.Float, shaderir.Vec2, shaderir.Vec3, shaderir.Vec4, shaderir.Mat2, shaderir.Mat3, shaderir.Mat4:
|
||||
t = lhst
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user