2020-05-24 13:15:07 +02:00
|
|
|
// Copyright 2020 The Ebiten Authors
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package testing
|
|
|
|
|
|
|
|
import (
|
2020-06-20 19:26:59 +02:00
|
|
|
"go/constant"
|
|
|
|
|
2020-10-03 19:35:13 +02:00
|
|
|
"github.com/hajimehoshi/ebiten/v2/internal/graphics"
|
|
|
|
"github.com/hajimehoshi/ebiten/v2/internal/shaderir"
|
2020-05-24 13:15:07 +02:00
|
|
|
)
|
|
|
|
|
2022-02-27 12:11:27 +01:00
|
|
|
func projectionMatrix(invertY bool) shaderir.Expr {
|
|
|
|
m11s := 1
|
|
|
|
if invertY {
|
|
|
|
m11s = -1
|
|
|
|
}
|
|
|
|
m31 := -1
|
|
|
|
if invertY {
|
|
|
|
m31 = 1
|
|
|
|
}
|
|
|
|
|
|
|
|
return shaderir.Expr{
|
2020-05-24 13:15:07 +02:00
|
|
|
Type: shaderir.Call,
|
|
|
|
Exprs: []shaderir.Expr{
|
|
|
|
{
|
|
|
|
Type: shaderir.BuiltinFuncExpr,
|
|
|
|
BuiltinFunc: shaderir.Mat4F,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: shaderir.Binary,
|
|
|
|
Op: shaderir.Div,
|
|
|
|
Exprs: []shaderir.Expr{
|
|
|
|
{
|
2020-06-20 19:26:59 +02:00
|
|
|
Type: shaderir.NumberExpr,
|
|
|
|
Const: constant.MakeFloat64(2),
|
|
|
|
ConstType: shaderir.ConstTypeFloat,
|
2020-05-24 13:15:07 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: shaderir.FieldSelector,
|
|
|
|
Exprs: []shaderir.Expr{
|
|
|
|
{
|
|
|
|
Type: shaderir.UniformVariable,
|
|
|
|
Index: 0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: shaderir.SwizzlingExpr,
|
|
|
|
Swizzling: "x",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2020-06-20 19:26:59 +02:00
|
|
|
Type: shaderir.NumberExpr,
|
|
|
|
Const: constant.MakeFloat64(0),
|
|
|
|
ConstType: shaderir.ConstTypeFloat,
|
2020-05-24 13:15:07 +02:00
|
|
|
},
|
|
|
|
{
|
2020-06-20 19:26:59 +02:00
|
|
|
Type: shaderir.NumberExpr,
|
|
|
|
Const: constant.MakeFloat64(0),
|
|
|
|
ConstType: shaderir.ConstTypeFloat,
|
2020-05-24 13:15:07 +02:00
|
|
|
},
|
|
|
|
{
|
2020-06-20 19:26:59 +02:00
|
|
|
Type: shaderir.NumberExpr,
|
|
|
|
Const: constant.MakeFloat64(0),
|
|
|
|
ConstType: shaderir.ConstTypeFloat,
|
2020-05-24 13:15:07 +02:00
|
|
|
},
|
|
|
|
{
|
2020-06-20 19:26:59 +02:00
|
|
|
Type: shaderir.NumberExpr,
|
|
|
|
Const: constant.MakeFloat64(0),
|
|
|
|
ConstType: shaderir.ConstTypeFloat,
|
2020-05-24 13:15:07 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: shaderir.Binary,
|
|
|
|
Op: shaderir.Div,
|
|
|
|
Exprs: []shaderir.Expr{
|
|
|
|
{
|
2020-06-20 19:26:59 +02:00
|
|
|
Type: shaderir.NumberExpr,
|
2022-02-27 12:11:27 +01:00
|
|
|
Const: constant.MakeFloat64(float64(m11s) * 2),
|
2020-06-20 19:26:59 +02:00
|
|
|
ConstType: shaderir.ConstTypeFloat,
|
2020-05-24 13:15:07 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: shaderir.FieldSelector,
|
|
|
|
Exprs: []shaderir.Expr{
|
|
|
|
{
|
|
|
|
Type: shaderir.UniformVariable,
|
|
|
|
Index: 0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: shaderir.SwizzlingExpr,
|
|
|
|
Swizzling: "y",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2020-06-20 19:26:59 +02:00
|
|
|
Type: shaderir.NumberExpr,
|
|
|
|
Const: constant.MakeFloat64(0),
|
|
|
|
ConstType: shaderir.ConstTypeFloat,
|
2020-05-24 13:15:07 +02:00
|
|
|
},
|
|
|
|
{
|
2020-06-20 19:26:59 +02:00
|
|
|
Type: shaderir.NumberExpr,
|
|
|
|
Const: constant.MakeFloat64(0),
|
|
|
|
ConstType: shaderir.ConstTypeFloat,
|
2020-05-24 13:15:07 +02:00
|
|
|
},
|
|
|
|
{
|
2020-06-20 19:26:59 +02:00
|
|
|
Type: shaderir.NumberExpr,
|
|
|
|
Const: constant.MakeFloat64(0),
|
|
|
|
ConstType: shaderir.ConstTypeFloat,
|
2020-05-24 13:15:07 +02:00
|
|
|
},
|
|
|
|
{
|
2020-06-20 19:26:59 +02:00
|
|
|
Type: shaderir.NumberExpr,
|
|
|
|
Const: constant.MakeFloat64(0),
|
|
|
|
ConstType: shaderir.ConstTypeFloat,
|
2020-05-24 13:15:07 +02:00
|
|
|
},
|
|
|
|
{
|
2020-06-20 19:26:59 +02:00
|
|
|
Type: shaderir.NumberExpr,
|
|
|
|
Const: constant.MakeFloat64(1),
|
|
|
|
ConstType: shaderir.ConstTypeFloat,
|
2020-05-24 13:15:07 +02:00
|
|
|
},
|
|
|
|
{
|
2020-06-20 19:26:59 +02:00
|
|
|
Type: shaderir.NumberExpr,
|
|
|
|
Const: constant.MakeFloat64(0),
|
|
|
|
ConstType: shaderir.ConstTypeFloat,
|
2020-05-24 13:15:07 +02:00
|
|
|
},
|
|
|
|
{
|
2020-06-20 19:26:59 +02:00
|
|
|
Type: shaderir.NumberExpr,
|
|
|
|
Const: constant.MakeFloat64(-1),
|
|
|
|
ConstType: shaderir.ConstTypeFloat,
|
2020-05-24 13:15:07 +02:00
|
|
|
},
|
|
|
|
{
|
2020-06-20 19:26:59 +02:00
|
|
|
Type: shaderir.NumberExpr,
|
2022-02-27 12:11:27 +01:00
|
|
|
Const: constant.MakeFloat64(float64(m31)),
|
2020-06-20 19:26:59 +02:00
|
|
|
ConstType: shaderir.ConstTypeFloat,
|
2020-05-24 13:15:07 +02:00
|
|
|
},
|
|
|
|
{
|
2020-06-20 19:26:59 +02:00
|
|
|
Type: shaderir.NumberExpr,
|
|
|
|
Const: constant.MakeFloat64(0),
|
|
|
|
ConstType: shaderir.ConstTypeFloat,
|
2020-05-24 13:15:07 +02:00
|
|
|
},
|
|
|
|
{
|
2020-06-20 19:26:59 +02:00
|
|
|
Type: shaderir.NumberExpr,
|
|
|
|
Const: constant.MakeFloat64(1),
|
|
|
|
ConstType: shaderir.ConstTypeFloat,
|
2020-05-24 13:15:07 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2022-02-27 12:11:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func vertexPosition() shaderir.Expr {
|
|
|
|
return shaderir.Expr{
|
2020-05-24 13:15:07 +02:00
|
|
|
Type: shaderir.Call,
|
|
|
|
Exprs: []shaderir.Expr{
|
|
|
|
{
|
|
|
|
Type: shaderir.BuiltinFuncExpr,
|
|
|
|
BuiltinFunc: shaderir.Vec4F,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: shaderir.LocalVariable,
|
|
|
|
Index: 0,
|
|
|
|
},
|
|
|
|
{
|
2020-06-20 19:26:59 +02:00
|
|
|
Type: shaderir.NumberExpr,
|
|
|
|
Const: constant.MakeFloat64(0),
|
|
|
|
ConstType: shaderir.ConstTypeFloat,
|
2020-05-24 13:15:07 +02:00
|
|
|
},
|
|
|
|
{
|
2020-06-20 19:26:59 +02:00
|
|
|
Type: shaderir.NumberExpr,
|
|
|
|
Const: constant.MakeFloat64(1),
|
|
|
|
ConstType: shaderir.ConstTypeFloat,
|
2020-05-24 13:15:07 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2022-02-27 12:11:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func defaultVertexFunc(invertY bool) shaderir.VertexFunc {
|
|
|
|
return shaderir.VertexFunc{
|
2020-08-09 08:55:59 +02:00
|
|
|
Block: &shaderir.Block{
|
2020-09-07 20:01:27 +02:00
|
|
|
LocalVarIndexOffset: 4 + 1,
|
2020-05-24 15:15:50 +02:00
|
|
|
Stmts: []shaderir.Stmt{
|
|
|
|
{
|
|
|
|
Type: shaderir.Assign,
|
|
|
|
Exprs: []shaderir.Expr{
|
|
|
|
{
|
|
|
|
Type: shaderir.LocalVariable,
|
2020-08-08 10:42:54 +02:00
|
|
|
Index: 4, // the varying variable
|
2020-05-24 10:14:37 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: shaderir.LocalVariable,
|
|
|
|
Index: 1, // the 2nd attribute variable
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: shaderir.Assign,
|
|
|
|
Exprs: []shaderir.Expr{
|
|
|
|
{
|
|
|
|
Type: shaderir.LocalVariable,
|
2020-08-08 10:42:54 +02:00
|
|
|
Index: 3, // gl_Position in GLSL
|
2020-05-24 15:15:50 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: shaderir.Binary,
|
2022-03-13 11:17:44 +01:00
|
|
|
Op: shaderir.MatrixMul,
|
2020-05-24 15:15:50 +02:00
|
|
|
Exprs: []shaderir.Expr{
|
2022-02-27 12:11:27 +01:00
|
|
|
projectionMatrix(invertY),
|
|
|
|
vertexPosition(),
|
2020-05-24 15:15:50 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2022-02-27 12:11:27 +01:00
|
|
|
}
|
2020-05-24 10:14:37 +02:00
|
|
|
|
2022-02-27 12:11:27 +01:00
|
|
|
func defaultProgram(invertY bool) shaderir.Program {
|
2020-07-18 12:56:22 +02:00
|
|
|
p := shaderir.Program{
|
2020-05-24 15:15:50 +02:00
|
|
|
Attributes: []shaderir.Type{
|
2020-05-24 10:14:37 +02:00
|
|
|
{Main: shaderir.Vec2}, // Local var (0) in the vertex shader
|
|
|
|
{Main: shaderir.Vec2}, // Local var (1) in the vertex shader
|
|
|
|
{Main: shaderir.Vec4}, // Local var (2) in the vertex shader
|
|
|
|
},
|
|
|
|
Varyings: []shaderir.Type{
|
2020-08-07 05:26:00 +02:00
|
|
|
{Main: shaderir.Vec2}, // Local var (4) in the vertex shader, (1) in the fragment shader
|
2020-05-24 15:15:50 +02:00
|
|
|
},
|
2022-02-27 12:11:27 +01:00
|
|
|
VertexFunc: defaultVertexFunc(invertY),
|
2020-05-24 15:15:50 +02:00
|
|
|
}
|
2020-07-18 12:56:22 +02:00
|
|
|
|
|
|
|
p.Uniforms = make([]shaderir.Type, graphics.PreservedUniformVariablesNum)
|
2020-08-01 09:20:49 +02:00
|
|
|
// Destination texture size
|
|
|
|
p.Uniforms[0] = shaderir.Type{Main: shaderir.Vec2}
|
|
|
|
// Source texture sizes
|
|
|
|
p.Uniforms[1] = shaderir.Type{
|
|
|
|
Main: shaderir.Array,
|
|
|
|
Length: graphics.ShaderImageNum,
|
|
|
|
Sub: []shaderir.Type{{Main: shaderir.Vec2}},
|
|
|
|
}
|
2020-12-09 03:52:45 +01:00
|
|
|
// Destination region origin
|
|
|
|
p.Uniforms[2] = shaderir.Type{Main: shaderir.Vec2}
|
|
|
|
// Destination region size
|
|
|
|
p.Uniforms[3] = shaderir.Type{Main: shaderir.Vec2}
|
2020-08-01 09:20:49 +02:00
|
|
|
// Source texture offsets
|
2020-12-09 03:52:45 +01:00
|
|
|
p.Uniforms[4] = shaderir.Type{
|
2020-08-01 09:20:49 +02:00
|
|
|
Main: shaderir.Array,
|
|
|
|
Length: graphics.ShaderImageNum - 1,
|
|
|
|
Sub: []shaderir.Type{{Main: shaderir.Vec2}},
|
2020-07-18 12:56:22 +02:00
|
|
|
}
|
2020-08-10 18:11:19 +02:00
|
|
|
// Source region origin
|
2020-12-09 03:52:45 +01:00
|
|
|
p.Uniforms[5] = shaderir.Type{Main: shaderir.Vec2}
|
2020-08-10 20:42:21 +02:00
|
|
|
// Source region size
|
2020-12-09 03:52:45 +01:00
|
|
|
p.Uniforms[6] = shaderir.Type{Main: shaderir.Vec2}
|
2020-07-18 12:56:22 +02:00
|
|
|
return p
|
2020-05-24 10:14:37 +02:00
|
|
|
}
|
2020-05-24 15:15:50 +02:00
|
|
|
|
|
|
|
// ShaderProgramFill returns a shader intermediate representation to fill the frambuffer.
|
|
|
|
//
|
2020-05-26 15:50:33 +02:00
|
|
|
// Uniform variable's index and its value are:
|
2020-05-24 15:15:50 +02:00
|
|
|
//
|
2020-05-24 10:14:37 +02:00
|
|
|
// 0: the framebuffer size (Vec2)
|
2022-02-27 12:11:27 +01:00
|
|
|
func ShaderProgramFill(invertY bool, r, g, b, a byte) shaderir.Program {
|
2020-05-24 13:15:07 +02:00
|
|
|
clr := shaderir.Expr{
|
|
|
|
Type: shaderir.Call,
|
|
|
|
Exprs: []shaderir.Expr{
|
|
|
|
{
|
|
|
|
Type: shaderir.BuiltinFuncExpr,
|
|
|
|
BuiltinFunc: shaderir.Vec4F,
|
|
|
|
},
|
|
|
|
{
|
2020-06-20 19:26:59 +02:00
|
|
|
Type: shaderir.NumberExpr,
|
|
|
|
Const: constant.MakeFloat64(float64(r) / 0xff),
|
|
|
|
ConstType: shaderir.ConstTypeFloat,
|
2020-05-24 13:15:07 +02:00
|
|
|
},
|
|
|
|
{
|
2020-06-20 19:26:59 +02:00
|
|
|
Type: shaderir.NumberExpr,
|
|
|
|
Const: constant.MakeFloat64(float64(g) / 0xff),
|
|
|
|
ConstType: shaderir.ConstTypeFloat,
|
2020-05-24 13:15:07 +02:00
|
|
|
},
|
|
|
|
{
|
2020-06-20 19:26:59 +02:00
|
|
|
Type: shaderir.NumberExpr,
|
|
|
|
Const: constant.MakeFloat64(float64(b) / 0xff),
|
|
|
|
ConstType: shaderir.ConstTypeFloat,
|
2020-05-24 13:15:07 +02:00
|
|
|
},
|
|
|
|
{
|
2020-06-20 19:26:59 +02:00
|
|
|
Type: shaderir.NumberExpr,
|
|
|
|
Const: constant.MakeFloat64(float64(a) / 0xff),
|
|
|
|
ConstType: shaderir.ConstTypeFloat,
|
2020-05-24 13:15:07 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2022-02-27 12:11:27 +01:00
|
|
|
p := defaultProgram(invertY)
|
2020-05-24 15:15:50 +02:00
|
|
|
p.FragmentFunc = shaderir.FragmentFunc{
|
2020-08-09 08:55:59 +02:00
|
|
|
Block: &shaderir.Block{
|
2020-09-07 20:01:27 +02:00
|
|
|
LocalVarIndexOffset: 2 + 1,
|
2020-05-24 15:15:50 +02:00
|
|
|
Stmts: []shaderir.Stmt{
|
|
|
|
{
|
|
|
|
Type: shaderir.Assign,
|
|
|
|
Exprs: []shaderir.Expr{
|
|
|
|
{
|
|
|
|
Type: shaderir.LocalVariable,
|
2020-05-24 10:14:37 +02:00
|
|
|
Index: 2,
|
2020-05-24 13:15:07 +02:00
|
|
|
},
|
2020-05-24 15:15:50 +02:00
|
|
|
clr,
|
2020-05-24 13:15:07 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2020-05-24 15:15:50 +02:00
|
|
|
|
|
|
|
return p
|
2020-05-24 13:15:07 +02:00
|
|
|
}
|
2020-05-24 10:14:37 +02:00
|
|
|
|
|
|
|
// ShaderProgramImages returns a shader intermediate representation to render the frambuffer with the given images.
|
|
|
|
//
|
2020-05-26 15:50:33 +02:00
|
|
|
// Uniform variables's indices and their values are:
|
2020-05-24 10:14:37 +02:00
|
|
|
//
|
2020-06-29 17:44:05 +02:00
|
|
|
// 0: the framebuffer size (Vec2)
|
2020-05-24 10:14:37 +02:00
|
|
|
//
|
|
|
|
// The size and region values are actually not used in this shader so far.
|
2022-02-27 12:11:27 +01:00
|
|
|
func ShaderProgramImages(invertY bool, imageNum int) shaderir.Program {
|
2020-05-24 10:14:37 +02:00
|
|
|
if imageNum <= 0 {
|
|
|
|
panic("testing: imageNum must be >= 1")
|
|
|
|
}
|
|
|
|
|
2022-02-27 12:11:27 +01:00
|
|
|
p := defaultProgram(invertY)
|
2020-07-05 20:36:15 +02:00
|
|
|
p.TextureNum = imageNum
|
2020-05-24 10:14:37 +02:00
|
|
|
|
|
|
|
// In the fragment shader, local variables are:
|
|
|
|
//
|
2020-06-02 19:01:50 +02:00
|
|
|
// 0: gl_FragCoord
|
|
|
|
// 1: Varying variables (vec2)
|
2020-05-24 10:14:37 +02:00
|
|
|
// 2: gl_FragColor
|
|
|
|
// 3: Actual local variables in the main function
|
|
|
|
|
|
|
|
local := shaderir.Expr{
|
|
|
|
Type: shaderir.LocalVariable,
|
|
|
|
Index: 3,
|
|
|
|
}
|
|
|
|
fragColor := shaderir.Expr{
|
|
|
|
Type: shaderir.LocalVariable,
|
|
|
|
Index: 2,
|
|
|
|
}
|
|
|
|
texPos := shaderir.Expr{
|
|
|
|
Type: shaderir.LocalVariable,
|
2020-06-02 19:01:50 +02:00
|
|
|
Index: 1,
|
2020-05-24 10:14:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var stmts []shaderir.Stmt
|
|
|
|
for i := 0; i < imageNum; i++ {
|
|
|
|
var rhs shaderir.Expr
|
|
|
|
if i == 0 {
|
|
|
|
rhs = shaderir.Expr{
|
|
|
|
Type: shaderir.Call,
|
|
|
|
Exprs: []shaderir.Expr{
|
|
|
|
{
|
|
|
|
Type: shaderir.BuiltinFuncExpr,
|
2020-05-30 10:48:56 +02:00
|
|
|
BuiltinFunc: shaderir.Texture2DF,
|
2020-05-24 10:14:37 +02:00
|
|
|
},
|
|
|
|
{
|
2020-07-05 20:36:15 +02:00
|
|
|
Type: shaderir.TextureVariable,
|
|
|
|
Index: 0,
|
2020-05-24 10:14:37 +02:00
|
|
|
},
|
|
|
|
texPos,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
} else {
|
2020-07-18 12:56:22 +02:00
|
|
|
texPos2 := shaderir.Expr{
|
|
|
|
Type: shaderir.Binary,
|
|
|
|
Op: shaderir.Add,
|
|
|
|
Exprs: []shaderir.Expr{
|
|
|
|
texPos,
|
|
|
|
{
|
2020-08-01 09:20:49 +02:00
|
|
|
Type: shaderir.Index,
|
|
|
|
Exprs: []shaderir.Expr{
|
|
|
|
{
|
|
|
|
Type: shaderir.UniformVariable,
|
2020-08-10 18:11:19 +02:00
|
|
|
Index: graphics.TextureSourceOffsetsUniformVariableIndex,
|
2020-08-01 09:20:49 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: shaderir.NumberExpr,
|
|
|
|
Const: constant.MakeInt64(int64(i - 1)),
|
|
|
|
ConstType: shaderir.ConstTypeInt,
|
|
|
|
},
|
|
|
|
},
|
2020-07-18 12:56:22 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2020-05-24 10:14:37 +02:00
|
|
|
rhs = shaderir.Expr{
|
|
|
|
Type: shaderir.Binary,
|
|
|
|
Op: shaderir.Add,
|
|
|
|
Exprs: []shaderir.Expr{
|
|
|
|
local,
|
|
|
|
{
|
|
|
|
Type: shaderir.Call,
|
|
|
|
Exprs: []shaderir.Expr{
|
|
|
|
{
|
|
|
|
Type: shaderir.BuiltinFuncExpr,
|
2020-05-30 10:48:56 +02:00
|
|
|
BuiltinFunc: shaderir.Texture2DF,
|
2020-05-24 10:14:37 +02:00
|
|
|
},
|
|
|
|
{
|
2020-07-05 20:36:15 +02:00
|
|
|
Type: shaderir.TextureVariable,
|
|
|
|
Index: i,
|
2020-05-24 10:14:37 +02:00
|
|
|
},
|
2020-07-18 12:56:22 +02:00
|
|
|
texPos2,
|
2020-05-24 10:14:37 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stmts = append(stmts, shaderir.Stmt{
|
|
|
|
Type: shaderir.Assign,
|
|
|
|
Exprs: []shaderir.Expr{
|
|
|
|
local,
|
|
|
|
rhs,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
stmts = append(stmts, shaderir.Stmt{
|
|
|
|
Type: shaderir.Assign,
|
|
|
|
Exprs: []shaderir.Expr{
|
|
|
|
fragColor,
|
|
|
|
local,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
p.FragmentFunc = shaderir.FragmentFunc{
|
2020-08-09 08:55:59 +02:00
|
|
|
Block: &shaderir.Block{
|
2020-05-24 10:14:37 +02:00
|
|
|
LocalVars: []shaderir.Type{
|
|
|
|
{Main: shaderir.Vec4},
|
|
|
|
},
|
2020-09-07 20:01:27 +02:00
|
|
|
LocalVarIndexOffset: 2 + 1,
|
2020-08-09 16:40:41 +02:00
|
|
|
Stmts: stmts,
|
2020-05-24 10:14:37 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
return p
|
|
|
|
}
|