Initial commit

This commit is contained in:
2026-02-02 04:50:13 +01:00
commit 5b11698731
22592 changed files with 7677434 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
in vec2 Texcoord;
in vec4 Color;
uniform sampler2D tex;
uniform UBOOL textured;
uniform float alphaRef;
uniform float meshAlpha;
OUTPUT
void main() {
outColor = Color;
if (UBOOL_TEST(textured)) {
vec4 texColor = texture(tex, Texcoord);
outColor.rgba *= texColor.rgba;
outColor.a *= meshAlpha;
if (outColor.a < alphaRef)
discard;
}
}

View File

@@ -0,0 +1,65 @@
in vec3 position;
in vec2 texcoord;
in vec4 color;
in vec3 normal;
uniform highp mat4 modelMatrix;
uniform highp mat4 viewMatrix;
uniform highp mat4 projMatrix;
uniform highp mat4 extraMatrix;
uniform highp mat4 normalMatrix;
uniform highp vec3 cameraPos;
uniform UBOOL textured;
uniform UBOOL useVertexAlpha;
uniform vec4 uniformColor;
struct shadow_info {
UBOOL _active;
vec3 _color;
vec3 _light;
vec3 _point;
vec3 _normal;
};
uniform shadow_info shadow;
out vec2 Texcoord;
out vec4 Color;
void main() {
vec4 pos = vec4(position, 1.0);
pos = modelMatrix * pos;
// See http://en.wikipedia.org/wiki/Line-plane_intersection
if (UBOOL_TEST(shadow._active)) {
pos /= pos.w;
vec3 l = pos.xyz - shadow._light;
float d = dot(shadow._point - shadow._light, shadow._normal) / dot(l, shadow._normal);
vec3 p = shadow._light + d * l;
pos = vec4(p, 1.0);
}
pos -= vec4(cameraPos * pos.w, 0.0);
pos = viewMatrix * pos;
pos /= pos.w;
pos.z *= -1.0;
vec4 projectedPos = projMatrix * pos;
gl_Position = projectedPos;
if (UBOOL_TEST(shadow._active)) {
Color = vec4(shadow._color, 1.0);
} else {
Color = color;
}
if (!UBOOL_TEST(useVertexAlpha))
Color.a = 1.0;
Color *= uniformColor;
if (UBOOL_TEST(textured)) {
Texcoord = texcoord;
} else {
Texcoord = vec2(0.0, 0.0);
}
}

View File

@@ -0,0 +1,20 @@
in vec2 Texcoord;
in vec4 Color;
uniform sampler2D tex;
uniform UBOOL textured;
uniform float alphaRef;
uniform float meshAlpha;
OUTPUT
void main() {
outColor = Color;
if (UBOOL_TEST(textured)) {
vec4 texColor = texture(tex, Texcoord);
outColor.rgba *= texColor.rgba;
outColor.a *= meshAlpha;
if (outColor.a < alphaRef)
discard;
}
}

View File

@@ -0,0 +1,115 @@
in vec3 position;
in vec2 texcoord;
in vec4 color;
in vec3 normal;
uniform highp mat4 modelMatrix;
uniform highp mat4 viewMatrix;
uniform highp mat4 projMatrix;
uniform highp mat4 extraMatrix;
uniform highp mat4 normalMatrix;
uniform highp vec3 cameraPos;
uniform UBOOL textured;
uniform UBOOL useVertexAlpha;
uniform vec4 uniformColor;
uniform UBOOL hasAmbient;
const int maxLights = 8;
uniform vec4 lightsPosition[maxLights];
uniform vec4 lightsDirection[maxLights];
uniform vec4 lightsColor[maxLights];
uniform vec4 lightsParams[maxLights];
struct shadow_info {
UBOOL _active;
vec3 _color;
vec3 _light;
vec3 _point;
vec3 _normal;
};
uniform shadow_info shadow;
out vec2 Texcoord;
out vec4 Color;
void main() {
vec4 pos = vec4(position, 1.0);
pos = modelMatrix * pos;
// See http://en.wikipedia.org/wiki/Line-plane_intersection
if (UBOOL_TEST(shadow._active)) {
pos /= pos.w;
vec3 l = pos.xyz - shadow._light;
float d = dot(shadow._point - shadow._light, shadow._normal) / dot(l, shadow._normal);
vec3 p = shadow._light + d * l;
pos = vec4(p, 1.0);
}
pos -= vec4(cameraPos * pos.w, 0.0);
pos = viewMatrix * pos;
pos /= pos.w;
pos.z *= -1.0;
vec4 projectedPos = projMatrix * pos;
gl_Position = projectedPos;
if (UBOOL_TEST(shadow._active)) {
Color = vec4(shadow._color, 1.0);
} else {
Color = color;
}
if (!UBOOL_TEST(useVertexAlpha))
Color.a = 1.0;
Color *= uniformColor;
if (UBOOL_TEST(textured)) {
Texcoord = texcoord;
} else {
Texcoord = vec2(0.0, 0.0);
}
vec3 light = vec3(0.0, 0.0, 0.0);
vec3 normalEye = normalize((normalMatrix * vec4(normal, 1.0)).xyz);
for (int i = 0; i < maxLights; ++i) {
float intensity = lightsColor[i].w;
float light_type = lightsPosition[i].w;
if (light_type >= 0.0) { // Not ambient
vec3 vertexToLight;
if (light_type > 0.0) { // positional light
float falloffNear = lightsParams[i].x;
float falloffFar = max(falloffNear, lightsParams[i].y);
vertexToLight = lightsPosition[i].xyz - pos.xyz;
float dist = length(vertexToLight);
if (falloffFar == falloffNear) {
intensity = 0.0;
} else {
intensity *= clamp(1.0 - (dist - falloffNear) / (falloffFar - falloffNear), 0.0, 1.0);
}
if (lightsDirection[i].w > -1.0) { // Spotlight
// See DirectX spotlight documentation
float cosAngle = -dot(normalize(vertexToLight), normalize(lightsDirection[i].xyz)); // rho
float cosPenumbra = clamp(lightsParams[i].w, 0.0, 1.0); // cos(theta / 2)
float cosUmbra = clamp(lightsParams[i].z, 0.0, cosPenumbra); // cos(phi / 2)
if (cosAngle <= cosPenumbra) {
if (cosAngle < cosUmbra || cosPenumbra == cosUmbra) {
intensity = 0.0;
} else {
intensity *= (cosAngle - cosUmbra) / (cosPenumbra - cosUmbra);
}
}
}
} else { // directional light
vertexToLight = -lightsPosition[i].xyz;
}
intensity *= max(0.0, dot(normalEye, normalize(vertexToLight)));
}
light += lightsColor[i].xyz * intensity;
}
if (!UBOOL_TEST(hasAmbient))
light += vec3(0.5, 0.5, 0.5);
light /= max(1.0, max(max(light.x, light.y), light.z));
Color *= vec4(light, 1.0);
}

View File

@@ -0,0 +1,9 @@
in vec2 Texcoord;
OUTPUT
uniform sampler2D tex;
void main() {
outColor = texture(tex, Texcoord);
}

View File

@@ -0,0 +1,9 @@
in vec2 position;
in vec2 texcoord;
out vec2 Texcoord;
void main() {
Texcoord = texcoord;
gl_Position = vec4(position, 0.0, 1.0);
}

View File

@@ -0,0 +1,7 @@
OUTPUT
uniform float dim;
void main() {
outColor = vec4(0.0, 0.0, 0.0, dim);
}

View File

@@ -0,0 +1,10 @@
in vec2 position;
void main() {
// Coordinates are [0.0;1.0], transform to [-1.0; 1.0]
vec2 pos = position;
pos.x = pos.x * 2.0 - 1.0;
pos.y = pos.y * 2.0 - 1.0;
gl_Position = vec4(pos, 0.0, 1.0);
}

View File

@@ -0,0 +1,20 @@
in vec2 Texcoord;
in vec4 Color;
uniform sampler2D tex;
uniform UBOOL textured;
uniform float alphaRef;
uniform float meshAlpha;
OUTPUT
void main() {
outColor = Color;
if (UBOOL_TEST(textured)) {
vec4 texColor = texture(tex, Texcoord);
outColor.rgba *= texColor.rgba;
outColor.a *= meshAlpha;
if (outColor.a < alphaRef)
discard;
}
}

View File

@@ -0,0 +1,60 @@
in vec3 position;
in vec2 texcoord;
in vec4 color;
in vec3 normal;
uniform highp mat4 modelMatrix;
uniform highp mat4 viewMatrix;
uniform highp mat4 projMatrix;
uniform highp mat4 extraMatrix;
uniform highp mat4 normalMatrix;
uniform highp vec3 cameraPos;
uniform UBOOL textured;
uniform UBOOL useVertexAlpha;
uniform vec4 uniformColor;
uniform vec4 spriteColor;
struct shadow_info {
UBOOL _active;
vec3 _color;
vec3 _light;
vec3 _point;
vec3 _normal;
};
uniform shadow_info shadow;
out vec2 Texcoord;
out vec4 Color;
void main() {
vec4 pos = vec4(position, 1.0);
vec4 offset = modelMatrix * vec4(0.0, 0.0, 0.0, 1.0);
offset -= vec4(cameraPos * offset.w, 0.0);
offset = viewMatrix * offset;
pos = extraMatrix * pos;
pos += vec4(offset.xyz * pos.w, 0.0);
pos /= pos.w;
pos.z *= -1.0;
vec4 projectedPos = projMatrix * pos;
gl_Position = projectedPos;
if (UBOOL_TEST(shadow._active)) {
Color = vec4(shadow._color, 1.0);
} else {
Color = color;
}
if (!UBOOL_TEST(useVertexAlpha))
Color.a = 1.0;
Color *= uniformColor;
Color *= spriteColor;
if (UBOOL_TEST(textured)) {
Texcoord = texcoord;
} else {
Texcoord = vec2(0.0, 0.0);
}
}

View File

@@ -0,0 +1,35 @@
in vec2 Texcoord;
in vec4 Color;
uniform sampler2D tex;
uniform sampler2D texZBuf;
uniform UBOOL textured;
uniform UBOOL hasZBuffer;
uniform vec2 texcropZBuf;
uniform vec2 screenSize;
uniform float alphaRef;
const float offsetY = 0.0;
OUTPUT
void checkZBuffer() {
vec2 zCoord = vec2((gl_FragCoord.x - 0.5) / screenSize.x, 1.0 - (gl_FragCoord.y - offsetY - 0.5) / screenSize.y);
vec2 sampled = texture(texZBuf, zCoord * texcropZBuf).ra;
float sceneZ = sampled.y + sampled.x / 256.0;
if (gl_FragCoord.z * 1.0039 > sceneZ)
discard;
}
void main() {
if (UBOOL_TEST(hasZBuffer))
checkZBuffer();
outColor = Color;
if (UBOOL_TEST(textured)) {
outColor *= texture(tex, Texcoord);
}
if (outColor.a < alphaRef)
discard;
}

View File

@@ -0,0 +1,57 @@
const float CONSTANT_ATTENUATION = 1.0;
const float LINEAR_ATTENUATION = 0.0;
const float QUADRATIC_ATTENUATION = 1.0;
in vec3 position;
in vec2 texcoord;
in vec4 color;
in vec3 normal;
uniform highp mat4 modelMatrix;
uniform highp mat4 viewMatrix;
uniform highp mat4 projMatrix;
uniform highp mat4 extraMatrix;
uniform UBOOL textured;
uniform UBOOL lightsEnabled;
uniform highp vec2 texScale;
struct shadow_info {
UBOOL _active;
vec3 _color;
vec3 _light;
vec3 _point;
vec3 _normal;
};
uniform shadow_info shadow;
out vec2 Texcoord;
out vec4 Color;
void main() {
vec4 pos = modelMatrix * extraMatrix * vec4(position, 1.0);
// See http://en.wikipedia.org/wiki/Line-plane_intersection
if (UBOOL_TEST(shadow._active)) {
pos /= pos.w;
vec3 l = pos.xyz - shadow._light;
float d = dot(shadow._point - shadow._light, shadow._normal) / dot(l, shadow._normal);
vec3 p = shadow._light + d * l;
pos = vec4(p, 1.0);
}
vec4 positionView = viewMatrix * pos;
gl_Position = projMatrix * positionView;
if (UBOOL_TEST(shadow._active)) {
Color = vec4(shadow._color, 1.0);
} else {
Color = color;
}
if (UBOOL_TEST(textured)) {
Texcoord = vec2(0.0, 1.0) + (texcoord / texScale);
} else {
Texcoord = vec2(0.0, 0.0);
}
}

View File

@@ -0,0 +1,35 @@
in vec2 Texcoord;
in vec4 Color;
uniform sampler2D tex;
uniform sampler2D texZBuf;
uniform UBOOL textured;
uniform UBOOL hasZBuffer;
uniform vec2 texcropZBuf;
uniform vec2 screenSize;
uniform float alphaRef;
const float offsetY = 0.0;
OUTPUT
void checkZBuffer() {
vec2 zCoord = vec2((gl_FragCoord.x - 0.5) / screenSize.x, 1.0 - (gl_FragCoord.y - offsetY - 0.5) / screenSize.y);
vec2 sampled = texture(texZBuf, zCoord * texcropZBuf).ra;
float sceneZ = sampled.y + sampled.x / 256.0;
if (gl_FragCoord.z * 1.0039 > sceneZ)
discard;
}
void main() {
if (UBOOL_TEST(hasZBuffer))
checkZBuffer();
outColor = Color;
if (UBOOL_TEST(textured)) {
outColor *= texture(tex, Texcoord);
}
if (outColor.a < alphaRef)
discard;
}

View File

@@ -0,0 +1,96 @@
const float CONSTANT_ATTENUATION = 1.0;
const float LINEAR_ATTENUATION = 0.0;
const float QUADRATIC_ATTENUATION = 1.0;
in vec3 position;
in vec2 texcoord;
in vec4 color;
in vec3 normal;
uniform highp mat4 modelMatrix;
uniform highp mat4 viewMatrix;
uniform highp mat4 projMatrix;
uniform highp mat4 extraMatrix;
uniform UBOOL textured;
uniform UBOOL lightsEnabled;
uniform highp vec2 texScale;
const int maxLights = 8;
uniform vec4 lightsPosition[maxLights];
uniform vec4 lightsDirection[maxLights];
uniform vec4 lightsColor[maxLights];
uniform vec4 lightsParams[maxLights];
struct shadow_info {
UBOOL _active;
vec3 _color;
vec3 _light;
vec3 _point;
vec3 _normal;
};
uniform shadow_info shadow;
out vec2 Texcoord;
out vec4 Color;
void main() {
vec4 pos = modelMatrix * extraMatrix * vec4(position, 1.0);
// See http://en.wikipedia.org/wiki/Line-plane_intersection
if (UBOOL_TEST(shadow._active)) {
pos /= pos.w;
vec3 l = pos.xyz - shadow._light;
float d = dot(shadow._point - shadow._light, shadow._normal) / dot(l, shadow._normal);
vec3 p = shadow._light + d * l;
pos = vec4(p, 1.0);
}
vec4 positionView = viewMatrix * pos;
gl_Position = projMatrix * positionView;
if (UBOOL_TEST(shadow._active)) {
Color = vec4(shadow._color, 1.0);
} else {
Color = color;
}
if (UBOOL_TEST(textured)) {
Texcoord = vec2(0.0, 1.0) + (texcoord / texScale);
} else {
Texcoord = vec2(0.0, 0.0);
}
vec3 light = vec3(0.0, 0.0, 0.0);
vec3 normalEye = normalize((viewMatrix * (modelMatrix * extraMatrix * vec4(normal, 0.0))).xyz);
for (int i = 0; i < maxLights; ++i) {
float intensity = lightsColor[i].w;
float light_type = lightsPosition[i].w;
if (light_type >= 0.0) { // Not ambient
vec3 vertexToLight = lightsPosition[i].xyz;
if (light_type > 0.0) { // positional light
vertexToLight -= positionView.xyz;
float dist = length(vertexToLight);
intensity /= CONSTANT_ATTENUATION + dist * (LINEAR_ATTENUATION + dist * QUADRATIC_ATTENUATION);
if (lightsDirection[i].w > -1.0) { // Spotlight
// See DirectX spotlight documentation
float cosAngle = -dot(normalize(vertexToLight), normalize(lightsDirection[i].xyz)); // rho
float cosPenumbra = clamp(lightsParams[i].w, 0.0, 1.0); // cos(theta / 2)
float cosUmbra = clamp(lightsParams[i].z, 0.0, cosPenumbra); // cos(phi / 2)
if (cosAngle <= cosPenumbra) {
if (cosAngle < cosUmbra || cosPenumbra == cosUmbra) {
intensity = 0.0;
} else {
intensity *= (cosAngle - cosUmbra) / (cosPenumbra - cosUmbra);
}
}
}
}
intensity *= max(0.0, dot(normalEye, normalize(vertexToLight)));
}
light += lightsColor[i].xyz * intensity;
}
light /= max(1.0, max(max(light.x, light.y), light.z));
Color *= vec4(light, 1.0);
}

View File

@@ -0,0 +1,9 @@
in vec2 Texcoord;
OUTPUT
uniform sampler2D tex;
void main() {
outColor = texture(tex, Texcoord);
}

View File

@@ -0,0 +1,18 @@
in vec2 position;
in vec2 texcoord;
uniform vec2 texcrop;
uniform vec2 offsetXY;
uniform vec2 sizeWH;
out vec2 Texcoord;
void main() {
Texcoord = texcoord * texcrop;
// Coordinates are [0.0;1.0], transform [-1.0; 1.0] and flip Y
vec2 pos = offsetXY + position * sizeWH;
pos.x = pos.x * 2.0 - 1.0;
pos.y = -1.0 * (pos.y * 2.0 - 1.0);
gl_Position = vec4(pos, 0.0, 1.0);
}

View File

@@ -0,0 +1,13 @@
in vec2 Texcoord;
OUTPUT
uniform sampler2D tex;
void main() {
vec4 c = texture(tex, Texcoord);
float val = (c.r + c.g + c.b) / 10.0;
outColor = vec4(val, val, val, 1);
}

View File

@@ -0,0 +1,16 @@
in vec2 position;
in vec2 texcoord;
uniform vec2 scaleWH;
out vec2 Texcoord;
void main() {
Texcoord = texcoord;
// Coordinates are [0.0;1.0], transform to [-1.0; 1.0]
vec2 pos = position * scaleWH;
pos.x = pos.x * 2.0 - 1.0;
pos.y = pos.y * 2.0 - 1.0;
gl_Position = vec4(pos, 0.0, 1.0);
}

View File

@@ -0,0 +1,10 @@
in vec2 Texcoord;
OUTPUT
uniform sampler2D tex;
uniform vec3 color;
void main() {
outColor = vec4(color, texture(tex, Texcoord).a);
}

View File

@@ -0,0 +1,21 @@
in vec2 position;
in vec2 texcoord;
uniform vec2 sizeWH;
uniform vec2 offsetXY;
uniform vec2 texOffsetXY;
uniform vec2 texScale;
out vec2 Texcoord;
void main() {
vec2 tex = texcoord;
tex.y = 1.0 - tex.y;
tex *= texScale;
Texcoord = texOffsetXY + tex;
vec2 pos = offsetXY + position * sizeWH;
pos.x = pos.x * 2.0 - 1.0;
pos.y = -1.0 * (pos.y * 2.0 - 1.0);
gl_Position = vec4(pos, 0.0, 1.0);
}

View File

@@ -0,0 +1,7 @@
OUTPUT
uniform vec3 color;
void main() {
outColor = vec4(color, 1.0);
}

View File

@@ -0,0 +1,12 @@
in vec2 position;
uniform vec2 scaleWH;
void main() {
// Coordinates are [0.0;1.0], transform to [-1.0; 1.0]
vec2 pos = position * scaleWH;
pos.x = pos.x * 2.0 - 1.0;
pos.y = -1.0 * (pos.y * 2.0 - 1.0);
gl_Position = vec4(pos, 0.0, 1.0);
}

View File

@@ -0,0 +1,5 @@
OUTPUT
void main() {
outColor = vec4(1.0, 1.0, 1.0, 1.0);
}

View File

@@ -0,0 +1,9 @@
in vec3 position;
uniform highp mat4 projMatrix;
uniform highp mat4 viewMatrix;
void main() {
vec4 pos = vec4(position, 1.0);
gl_Position = projMatrix * viewMatrix * pos;
}

View File

@@ -0,0 +1,10 @@
in vec2 Texcoord;
OUTPUT
uniform sampler2D tex;
void main() {
vec4 color = texture(tex, Texcoord);
outColor = vec4(color.rgb, 1.0);
}

View File

@@ -0,0 +1,19 @@
in vec2 position;
in vec2 texcoord;
uniform vec2 scale;
uniform vec2 offset;
uniform vec2 texcrop;
out vec2 Texcoord;
void main() {
Texcoord = texcoord * texcrop;
vec2 pos = scale * position + offset;
// Coordinates are [0.0;1.0], transform [-1.0; 1.0] and flip Y
pos.x = (pos.x * 2.0 - 1.0);
pos.y = -1.0 * (pos.y * 2.0 - 1.0);
gl_Position = vec4(pos, 0.0, 1.0);
}

View File

@@ -0,0 +1,10 @@
in vec2 Texcoord;
OUTPUT
uniform sampler2D tex;
uniform vec3 color;
void main() {
outColor = texture(tex, Texcoord) * vec4(color, 1.0);
}

View File

@@ -0,0 +1,15 @@
in vec2 position;
in vec2 texcoord;
out vec2 Texcoord;
void main() {
Texcoord = texcoord;
// Coordinates are [0.0;1.0], transform to [-1.0; 1.0]
vec2 pos = position;
pos.x = pos.x * 2.0 - 1.0;
pos.y = -1.0 * (pos.y * 2.0 - 1.0);
gl_Position = vec4(pos, 0.0, 1.0);
}