mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-27 03:02:49 +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 {
|
func Vertex(position vec2, texCoord vec2, color vec4) vec4 {
|
||||||
return mat4(
|
return mat4(
|
||||||
2.0/viewportSize().x, 0, 0, 0,
|
2/viewportSize().x, 0, 0, 0,
|
||||||
0, 2.0/viewportSize().y, 0, 0,
|
0, 2/viewportSize().y, 0, 0,
|
||||||
0, 0, 1, 0,
|
0, 0, 1, 0,
|
||||||
-1, -1, 0, 1,
|
-1, -1, 0, 1,
|
||||||
) * vec4(position, 0, 1)
|
) * vec4(position, 0, 1)
|
||||||
@ -45,11 +45,11 @@ func Vertex(position vec2, texCoord vec2, color vec4) vec4 {
|
|||||||
func Fragment(position vec4) vec4 {
|
func Fragment(position vec4) vec4 {
|
||||||
pos := position.xy / viewportSize()
|
pos := position.xy / viewportSize()
|
||||||
color := 0.0
|
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.x * cos(Time / 15) * 80) + cos(pos.y * cos(Time / 15) * 10)
|
||||||
color += sin(pos.y * sin(Time / 10.0) * 40.0) + cos(pos.x * sin(Time / 25.0) * 40.0)
|
color += sin(pos.y * sin(Time / 10) * 40) + cos(pos.x * sin(Time / 25) * 40)
|
||||||
color += sin(pos.x * sin(Time / 5.0) * 10.0) + sin(pos.y * sin(Time / 35.0) * 80.0)
|
color += sin(pos.x * sin(Time / 5) * 10) + sin(pos.y * sin(Time / 35) * 80)
|
||||||
color *= sin(Time / 10.0) * 0.5
|
color *= sin(Time / 10) * 0.5
|
||||||
return vec4(color, color * 0.5, sin(color + Time / 3.0 ) * 0.75, 1.0)
|
return vec4(color, color * 0.5, sin(color + Time / 3 ) * 0.75, 1)
|
||||||
}`
|
}`
|
||||||
|
|
||||||
type Game struct {
|
type Game struct {
|
||||||
|
@ -879,6 +879,8 @@ func (cs *compileState) parseExpr(block *block, expr ast.Expr) ([]shaderir.Expr,
|
|||||||
t = lhst
|
t = lhst
|
||||||
} else if lhst.Main == shaderir.Float || lhst.Main == shaderir.Int {
|
} else if lhst.Main == shaderir.Float || lhst.Main == shaderir.Int {
|
||||||
switch rhst.Main {
|
switch rhst.Main {
|
||||||
|
case shaderir.Int:
|
||||||
|
t = lhst
|
||||||
case shaderir.Float, shaderir.Vec2, shaderir.Vec3, shaderir.Vec4, shaderir.Mat2, shaderir.Mat3, shaderir.Mat4:
|
case shaderir.Float, shaderir.Vec2, shaderir.Vec3, shaderir.Vec4, shaderir.Mat2, shaderir.Mat3, shaderir.Mat4:
|
||||||
t = rhst
|
t = rhst
|
||||||
default:
|
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 {
|
} else if rhst.Main == shaderir.Float || rhst.Main == shaderir.Int {
|
||||||
switch lhst.Main {
|
switch lhst.Main {
|
||||||
|
case shaderir.Int:
|
||||||
|
t = rhst
|
||||||
case shaderir.Float, shaderir.Vec2, shaderir.Vec3, shaderir.Vec4, shaderir.Mat2, shaderir.Mat3, shaderir.Mat4:
|
case shaderir.Float, shaderir.Vec2, shaderir.Vec3, shaderir.Vec4, shaderir.Mat2, shaderir.Mat3, shaderir.Mat4:
|
||||||
t = lhst
|
t = lhst
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user