mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +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:
|
||||
nv := len(p.Varyings)
|
||||
switch {
|
||||
case idx < nv:
|
||||
return fmt.Sprintf("V%d", idx)
|
||||
case idx == nv:
|
||||
case idx == 0:
|
||||
return "gl_FragCoord"
|
||||
case idx < nv+1:
|
||||
return fmt.Sprintf("V%d", idx-1)
|
||||
case idx == nv+1:
|
||||
return "gl_FragColor"
|
||||
default:
|
||||
|
@ -711,20 +711,19 @@ varying vec2 V1;`,
|
||||
FragmentFunc: FragmentFunc{
|
||||
Block: block(
|
||||
[]Type{
|
||||
{Main: Vec2},
|
||||
{Main: Vec4},
|
||||
{Main: Float},
|
||||
{Main: Vec2},
|
||||
},
|
||||
assignStmt(
|
||||
localVariableExpr(5),
|
||||
localVariableExpr(3),
|
||||
localVariableExpr(0),
|
||||
),
|
||||
assignStmt(
|
||||
localVariableExpr(3),
|
||||
localVariableExpr(4),
|
||||
localVariableExpr(1),
|
||||
),
|
||||
assignStmt(
|
||||
localVariableExpr(4),
|
||||
localVariableExpr(5),
|
||||
localVariableExpr(2),
|
||||
),
|
||||
),
|
||||
@ -747,12 +746,11 @@ varying float V0;
|
||||
varying vec2 V1;
|
||||
|
||||
void main(void) {
|
||||
vec2 l0 = vec2(0.0);
|
||||
vec4 l1 = vec4(0.0);
|
||||
float l2 = 0.0;
|
||||
l1 = V0;
|
||||
gl_FragColor = V1;
|
||||
l0 = gl_FragCoord;
|
||||
float l0 = 0.0;
|
||||
vec2 l1 = vec2(0.0);
|
||||
gl_FragColor = gl_FragCoord;
|
||||
l0 = V0;
|
||||
l1 = V1;
|
||||
}`,
|
||||
},
|
||||
}
|
||||
|
@ -46,7 +46,8 @@ type VertexFunc struct {
|
||||
}
|
||||
|
||||
// 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).
|
||||
type FragmentFunc struct {
|
||||
Block Block
|
||||
|
@ -288,8 +288,8 @@ func ShaderProgramImages(imageNum int) shaderir.Program {
|
||||
|
||||
// In the fragment shader, local variables are:
|
||||
//
|
||||
// 0: Varying variables (vec2)
|
||||
// 1: gl_FragCoord
|
||||
// 0: gl_FragCoord
|
||||
// 1: Varying variables (vec2)
|
||||
// 2: gl_FragColor
|
||||
// 3: Actual local variables in the main function
|
||||
|
||||
@ -303,7 +303,7 @@ func ShaderProgramImages(imageNum int) shaderir.Program {
|
||||
}
|
||||
texPos := shaderir.Expr{
|
||||
Type: shaderir.LocalVariable,
|
||||
Index: 0,
|
||||
Index: 1,
|
||||
}
|
||||
|
||||
var stmts []shaderir.Stmt
|
||||
|
Loading…
Reference in New Issue
Block a user