Added GUI render and support for faces without textures

- Added FlatRenderProgram to render 2D graphics
  - Can be used as-is
  - Supports rectangular coordinate-aligned nested masks
- Added AssembledFlatLayer to cache 2D graphics
  - Use RenderTarget for add elements during reassembly
- ShapeRenderProgram now allows null textures (defaults to white BG)
- Sprite now deduces size based on primitive's content size
  - unless given size explicitly
- ShapeRenderHelper.*WorldTransform methods renamed to .*Transform
This commit is contained in:
2020-08-01 16:23:31 +03:00
parent 47ea102ed7
commit 1ed8f93af4
25 changed files with 678 additions and 27 deletions

View File

@@ -0,0 +1,13 @@
#version 120
uniform ivec2 maskStart;
uniform ivec2 maskEnd;
void applyMask() {
if (
gl_FragCoord.x < maskStart.x || gl_FragCoord.x >= maskEnd.x ||
gl_FragCoord.y < maskStart.y || gl_FragCoord.y >= maskEnd.y
) {
discard;
}
}

View File

@@ -0,0 +1,5 @@
#version 120
void flatTransferToFragment() {
shapeTransferToFragment();
}

View File

@@ -0,0 +1,8 @@
#version 120
void main(void) {
applyTexture();
applyColorMultiplier();
applyAlpha();
applyMask();
}

View File

@@ -0,0 +1,6 @@
#version 120
void main(void) {
gl_Position = applyFinalTransform(vec4(inputPositions, 1.0));
flatTransferToFragment();
}

View File

@@ -7,14 +7,20 @@ uniform sampler2D textureSlot;
uniform vec2 textureStart;
uniform vec2 textureSize;
uniform bool useTexture;
void applyTexture() {
gl_FragColor = texture2D(
textureSlot,
vec2(
varyingTextureCoords[0] * textureSize[0] + textureStart[0],
varyingTextureCoords[1] * textureSize[1] + textureStart[1]
)
);
if (!useTexture) {
gl_FragColor = vec4(1, 1, 1, 1);
} else {
gl_FragColor = texture2D(
textureSlot,
vec2(
varyingTextureCoords[0] * textureSize[0] + textureStart[0],
varyingTextureCoords[1] * textureSize[1] + textureStart[1]
)
);
}
}
void multiply(inout vec4 vector, float scalar) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB