Re-written flat render pipeline to support transforms

FlatRender now supports arbitrary transforms
GLSL 1.40 is now used in shaders
This commit is contained in:
2020-08-03 21:44:36 +03:00
parent da61f834e5
commit 7dee1eb95f
31 changed files with 812 additions and 264 deletions

View File

@@ -1,13 +1,26 @@
#version 120
#version 140
uniform ivec2 maskStart;
uniform ivec2 maskEnd;
uniform int maskCount;
uniform vec2 masks[3 * 2 * 16];
bool isInMaskPrimitive(int primitive) {
vec2 origin = masks[3 * primitive + 0];
vec2 width = masks[3 * primitive + 1];
vec2 height = masks[3 * primitive + 2];
vec2 current = gl_FragCoord.xy - origin;
mat2 matrix = mat2(width, height);
vec2 relative = inverse(matrix) * current;
return relative.x >= 0 && relative.y >= 0 && relative.x + relative.y <= 1;
}
void applyMask() {
if (
gl_FragCoord.x < maskStart.x || gl_FragCoord.x >= maskEnd.x ||
gl_FragCoord.y < maskStart.y || gl_FragCoord.y >= maskEnd.y
) {
discard;
for (int i = 0; i < maskCount; ++i) {
if (!(isInMaskPrimitive(2 * i + 0) || isInMaskPrimitive(2 * i + 1))) {
discard;
}
}
}
}

View File

@@ -1,4 +1,4 @@
#version 120
#version 140
void flatTransferToFragment() {
shapeTransferToFragment();

View File

@@ -1,4 +1,4 @@
#version 120
#version 140
void main(void) {
applyTexture();

View File

@@ -1,4 +1,4 @@
#version 120
#version 140
void main(void) {
gl_Position = applyFinalTransform(vec4(inputPositions, 1.0));

View File

@@ -1,4 +1,4 @@
#version 120
#version 140
varying vec3 varyingColorMultiplier;
varying vec2 varyingTextureCoords;

View File

@@ -1,4 +1,4 @@
#version 120
#version 140
attribute vec3 inputPositions;

View File

@@ -1,4 +1,4 @@
#version 120
#version 140
varying vec3 varyingNormals;

View File

@@ -1,4 +1,4 @@
#version 120
#version 140
attribute vec3 inputNormals;
varying vec3 varyingNormals;

View File

@@ -1,4 +1,4 @@
#version 120
#version 140
void main(void) {
applyTexture();

View File

@@ -1,4 +1,4 @@
#version 120
#version 140
void main(void) {
gl_Position = applyFinalTransform(vec4(inputPositions, 1.0));

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B