Initial commit

This commit is contained in:
Stillkill committed 2026-03-08 15:37:55 -05:00
commit bd6318027f
4937 files changed
+194287

No files matched your search

+153
View File
@@ -0,0 +1,153 @@
// __multiversion__
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
// To use centroid sampling we need to have version 300 es shaders, which requires changing:
// attribute to in
// varying to out when in vertex shaders or in when in fragment shaders
// defining an out vec4 FragColor and replacing uses of gl_FragColor with FragColor
// texture2D to texture
#if __VERSION__ >= 300
#define attribute in
#define varying out
#ifdef MSAA_FRAMEBUFFER_ENABLED
#define _centroid centroid
#else
#define _centroid
#endif
_centroid out vec2 uv;
#else
varying vec2 uv;
#endif
uniform MAT4 WORLDVIEWPROJ;
uniform MAT4 WORLD;
uniform vec4 TILE_LIGHT_COLOR;
uniform vec4 OVERLAY_COLOR;
uniform vec4 CHANGE_COLOR;
uniform vec4 GLINT_COLOR;
uniform vec4 FOG_COLOR;
uniform vec2 FOG_CONTROL;
uniform float RENDER_DISTANCE;
uniform vec2 UV_ANIM;
uniform vec2 UV_OFFSET;
uniform vec2 UV_ROTATION;
uniform vec2 GLINT_UV_SCALE;
uniform vec3 PLAYER_POSITION;
uniform vec4 BLOOM_CONTROL;
varying vec4 bloomControl;
attribute mediump vec4 POSITION;
attribute vec2 TEXCOORD_0;
attribute vec4 NORMAL;
#ifdef COLOR_BASED
attribute vec4 COLOR;
#endif
varying vec4 light;
varying vec4 fogColor;
#ifdef USE_OVERLAY
varying vec4 overlayColor;
#endif
#if defined(USE_COLOR_MASK) || defined(ITEM_IN_HAND) || defined(COLOR_SECOND_TEXTURE)
varying vec4 changeColor;
#endif
#ifdef GLINT
varying vec2 layer1UV;
varying vec2 layer2UV;
varying vec4 tileLightColor;
varying vec4 glintColor;
#endif
const float AMBIENT = 0.45;
const float XFAC = -0.1;
const float ZFAC = 0.1;
float lightIntensity() {
#ifdef FANCY
vec3 N = normalize( WORLD * NORMAL ).xyz;
N.y *= TILE_LIGHT_COLOR.w; //TILE_LIGHT_COLOR.w contains the direction of the light
//take care of double sided polygons on materials without culling
#ifdef FLIP_BACKFACES
vec3 viewDir = normalize((WORLD * POSITION).xyz);
if( dot(N, viewDir) > 0.0 )
N *= -1.0;
#endif
float yLight = (1.0+N.y) * 0.5;
return yLight * (1.0-AMBIENT) + N.x*N.x * XFAC + N.z*N.z * ZFAC + AMBIENT;
#else
return 1.0;
#endif
}
#ifdef GLINT
vec2 calculateLayerUV(float offset, float rotation) {
vec2 uv = TEXCOORD_0;
uv -= 0.5;
float rsin = sin(rotation);
float rcos = cos(rotation);
uv = mat2(rcos, -rsin, rsin, rcos) * uv;
uv.x += offset;
uv += 0.5;
return uv * GLINT_UV_SCALE;
}
#endif
void main()
{
POS4 pos = WORLDVIEWPROJ * POSITION;
gl_Position = pos;
float L = lightIntensity();
#ifdef USE_OVERLAY
L += OVERLAY_COLOR.a * 0.35;
overlayColor = OVERLAY_COLOR;
#endif
#if defined(USE_COLOR_MASK) || defined(ITEM_IN_HAND) || defined(COLOR_SECOND_TEXTURE)
changeColor = CHANGE_COLOR;
#endif
light = vec4(vec3(L) * TILE_LIGHT_COLOR.xyz, 1.0);
bloomControl = BLOOM_CONTROL;
float d = length(PLAYER_POSITION - (WORLD * POSITION).xyz) / BLOOM_CONTROL.z; // 0.06 dist
d = (1.0 - min(d, 1.0)) * BLOOM_CONTROL.w; // strength
light = min(mix(light, light * 2.0, d), vec4(1.0));
#ifdef COLOR_BASED
light *= COLOR;
#endif
#ifndef NO_TEXTURE
uv = TEXCOORD_0;
#endif
#ifdef USE_UV_ANIM
uv.xy += UV_ANIM.xy;
#endif
#ifdef GLINT
glintColor = GLINT_COLOR;
layer1UV = calculateLayerUV(UV_OFFSET.x, UV_ROTATION.x);
layer2UV = calculateLayerUV(UV_OFFSET.y, UV_ROTATION.y);
tileLightColor = TILE_LIGHT_COLOR;
#endif
//fog
fogColor.rgb = FOG_COLOR.rgb;
fogColor.a = clamp(((length(PLAYER_POSITION - (WORLD * POSITION).xyz) / RENDER_DISTANCE) - FOG_CONTROL.x) / (FOG_CONTROL.y - FOG_CONTROL.x), 0.0, FOG_COLOR.a);
}