add MaskColor uniform

This commit is contained in:
faiface 2016-12-03 15:48:40 +01:00
parent a3e7656922
commit fc96ec3a06
2 changed files with 6 additions and 2 deletions

View File

@ -18,6 +18,8 @@ const (
TexCoord
// Transform is an object transformation matrix
Transform
// MaskColor is a masking color. When drawing, each color gets multiplied by this color.
MaskColor
// IsTexture signals, whether a texture is present.
IsTexture
// NumStandardAttrPurposes is the number of standard attribute purposes

View File

@ -333,6 +333,7 @@ var defaultVertexFormat = pixelgl.VertexFormat{
}
var defaultUniformFormat = pixelgl.UniformFormat{
"maskColor": {Purpose: pixelgl.MaskColor, Type: pixelgl.Vec4},
"transform": {Purpose: pixelgl.Transform, Type: pixelgl.Mat3},
"isTexture": {Purpose: pixelgl.IsTexture, Type: pixelgl.Int},
}
@ -364,14 +365,15 @@ in vec2 TexCoord;
out vec4 color;
uniform vec4 maskColor;
uniform int isTexture;
uniform sampler2D tex;
void main() {
if (isTexture != 0) {
color = Color * texture(tex, vec2(TexCoord.x, 1 - TexCoord.y));
color = maskColor * Color * texture(tex, vec2(TexCoord.x, 1 - TexCoord.y));
} else {
color = Color;
color = maskColor * Color;
}
}
`