add MaskColor uniform
This commit is contained in:
parent
a3e7656922
commit
fc96ec3a06
|
@ -18,6 +18,8 @@ const (
|
||||||
TexCoord
|
TexCoord
|
||||||
// Transform is an object transformation matrix
|
// Transform is an object transformation matrix
|
||||||
Transform
|
Transform
|
||||||
|
// MaskColor is a masking color. When drawing, each color gets multiplied by this color.
|
||||||
|
MaskColor
|
||||||
// IsTexture signals, whether a texture is present.
|
// IsTexture signals, whether a texture is present.
|
||||||
IsTexture
|
IsTexture
|
||||||
// NumStandardAttrPurposes is the number of standard attribute purposes
|
// NumStandardAttrPurposes is the number of standard attribute purposes
|
||||||
|
|
|
@ -333,6 +333,7 @@ var defaultVertexFormat = pixelgl.VertexFormat{
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaultUniformFormat = pixelgl.UniformFormat{
|
var defaultUniformFormat = pixelgl.UniformFormat{
|
||||||
|
"maskColor": {Purpose: pixelgl.MaskColor, Type: pixelgl.Vec4},
|
||||||
"transform": {Purpose: pixelgl.Transform, Type: pixelgl.Mat3},
|
"transform": {Purpose: pixelgl.Transform, Type: pixelgl.Mat3},
|
||||||
"isTexture": {Purpose: pixelgl.IsTexture, Type: pixelgl.Int},
|
"isTexture": {Purpose: pixelgl.IsTexture, Type: pixelgl.Int},
|
||||||
}
|
}
|
||||||
|
@ -364,14 +365,15 @@ in vec2 TexCoord;
|
||||||
|
|
||||||
out vec4 color;
|
out vec4 color;
|
||||||
|
|
||||||
|
uniform vec4 maskColor;
|
||||||
uniform int isTexture;
|
uniform int isTexture;
|
||||||
uniform sampler2D tex;
|
uniform sampler2D tex;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
if (isTexture != 0) {
|
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 {
|
} else {
|
||||||
color = Color;
|
color = maskColor * Color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
Loading…
Reference in New Issue