#version 140 #define DB_GRADIENT_MAX 16 #define DB_COMMAND_MAX 64 #define CMD_POINT 1 #define CMD_LINE 2 #define CMD_RECT 3 #define CMD_TEXT 4 #define STRIKE_INSET -1 #define STRIKE_CENTER 0 #define STRIKE_OUTSET 1 in vec3 v_v3Position; in vec2 v_v2TexCoords; in int v_iCmdIndex; out vec4 f_Color; uniform sampler2D txForeground; uniform sampler2D txBackground; uniform sampler2DArray txCharacters; struct Gradient_t { float fPosition; float pad0; float pad1; float pad2; vec4 v4Color; }; uniform GradientBlock { Gradient_t vstGradientStops[DB_GRADIENT_MAX]; }; vec4 getGradientColor(float position, int index, int count) { position = clamp(position, 0, 1); int i0 = 0; float p0 = vstGradientStops[index + i0].fPosition; int i1 = count - 1; float p1 = vstGradientStops[index + i1].fPosition; for (int i = 0; i < count; i++) { float px = vstGradientStops[index + i].fPosition; if (px > p0 && px <= position) { p0 = px; i0 = i; } if (px < p1 && px >= position) { p1 = px; i1 = i; } } vec4 c0 = vstGradientStops[index + i0].v4Color; vec4 c1 = vstGradientStops[index + i1].v4Color; float l = p1 - p0; float w = (l > 0) ? (position - p0) / (p1 - p0) : 0; return mix(c0, c1, w); } struct CommandCommon { int iCommand; int iStrikeKind; float fBorderRadius; int _padding; int iFgGradientIndex; int iFgGradientCount; int iBgGradientIndex; int iBgGradientCount; vec4 v4FillColor; vec4 v4BorderColor; }; uniform CommandBlock { CommandCommon vstCommands[DB_COMMAND_MAX]; }; void main(void) { }