mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 20:18:59 +01:00
shaderir: Change the param order of fragment shaders
This commit is contained in:
parent
cd3d396975
commit
39c09a4f88
@ -262,10 +262,10 @@ func (p *Program) glslBlock(b *Block, level int, localVarIndex int) []string {
|
|||||||
case &p.FragmentFunc.Block:
|
case &p.FragmentFunc.Block:
|
||||||
nv := len(p.Varyings)
|
nv := len(p.Varyings)
|
||||||
switch {
|
switch {
|
||||||
case idx < nv:
|
case idx == 0:
|
||||||
return fmt.Sprintf("V%d", idx)
|
|
||||||
case idx == nv:
|
|
||||||
return "gl_FragCoord"
|
return "gl_FragCoord"
|
||||||
|
case idx < nv+1:
|
||||||
|
return fmt.Sprintf("V%d", idx-1)
|
||||||
case idx == nv+1:
|
case idx == nv+1:
|
||||||
return "gl_FragColor"
|
return "gl_FragColor"
|
||||||
default:
|
default:
|
||||||
|
@ -711,20 +711,19 @@ varying vec2 V1;`,
|
|||||||
FragmentFunc: FragmentFunc{
|
FragmentFunc: FragmentFunc{
|
||||||
Block: block(
|
Block: block(
|
||||||
[]Type{
|
[]Type{
|
||||||
{Main: Vec2},
|
|
||||||
{Main: Vec4},
|
|
||||||
{Main: Float},
|
{Main: Float},
|
||||||
|
{Main: Vec2},
|
||||||
},
|
},
|
||||||
assignStmt(
|
assignStmt(
|
||||||
localVariableExpr(5),
|
localVariableExpr(3),
|
||||||
localVariableExpr(0),
|
localVariableExpr(0),
|
||||||
),
|
),
|
||||||
assignStmt(
|
assignStmt(
|
||||||
localVariableExpr(3),
|
localVariableExpr(4),
|
||||||
localVariableExpr(1),
|
localVariableExpr(1),
|
||||||
),
|
),
|
||||||
assignStmt(
|
assignStmt(
|
||||||
localVariableExpr(4),
|
localVariableExpr(5),
|
||||||
localVariableExpr(2),
|
localVariableExpr(2),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -747,12 +746,11 @@ varying float V0;
|
|||||||
varying vec2 V1;
|
varying vec2 V1;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
vec2 l0 = vec2(0.0);
|
float l0 = 0.0;
|
||||||
vec4 l1 = vec4(0.0);
|
vec2 l1 = vec2(0.0);
|
||||||
float l2 = 0.0;
|
gl_FragColor = gl_FragCoord;
|
||||||
l1 = V0;
|
l0 = V0;
|
||||||
gl_FragColor = V1;
|
l1 = V1;
|
||||||
l0 = gl_FragCoord;
|
|
||||||
}`,
|
}`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,8 @@ type VertexFunc struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FragmentFunc takes pseudo params, and the number is len(varyings) + 2.
|
// FragmentFunc takes pseudo params, and the number is len(varyings) + 2.
|
||||||
// If index == len(varyings), the param represents the coordinate of the fragment (gl_FragCoord in GLSL).
|
// If index == 0, the param represents the coordinate of the fragment (gl_FragCoord in GLSL).
|
||||||
|
// If index == len(varyings), the param represents (index-1)th verying variable.
|
||||||
// If index == len(varyings)+1, the param is an out-param representing the color of the pixel (gl_FragColor in GLSL).
|
// If index == len(varyings)+1, the param is an out-param representing the color of the pixel (gl_FragColor in GLSL).
|
||||||
type FragmentFunc struct {
|
type FragmentFunc struct {
|
||||||
Block Block
|
Block Block
|
||||||
|
@ -288,8 +288,8 @@ func ShaderProgramImages(imageNum int) shaderir.Program {
|
|||||||
|
|
||||||
// In the fragment shader, local variables are:
|
// In the fragment shader, local variables are:
|
||||||
//
|
//
|
||||||
// 0: Varying variables (vec2)
|
// 0: gl_FragCoord
|
||||||
// 1: gl_FragCoord
|
// 1: Varying variables (vec2)
|
||||||
// 2: gl_FragColor
|
// 2: gl_FragColor
|
||||||
// 3: Actual local variables in the main function
|
// 3: Actual local variables in the main function
|
||||||
|
|
||||||
@ -303,7 +303,7 @@ func ShaderProgramImages(imageNum int) shaderir.Program {
|
|||||||
}
|
}
|
||||||
texPos := shaderir.Expr{
|
texPos := shaderir.Expr{
|
||||||
Type: shaderir.LocalVariable,
|
Type: shaderir.LocalVariable,
|
||||||
Index: 0,
|
Index: 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
var stmts []shaderir.Stmt
|
var stmts []shaderir.Stmt
|
||||||
|
Loading…
Reference in New Issue
Block a user