// __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 vec2 UV_OFFSET; uniform vec2 UV_ROTATION; uniform vec2 GLINT_UV_SCALE; uniform vec4 FOG_COLOR; uniform vec2 FOG_CONTROL; uniform float RENDER_DISTANCE; uniform vec3 PLAYER_POSITION; attribute mediump vec4 POSITION; attribute vec4 COLOR; attribute vec2 TEXCOORD_0; varying vec4 color; #ifdef ENABLE_FOG varying vec4 fogColor; #endif #ifdef GLINT varying vec2 layer1UV; varying vec2 layer2UV; 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() { gl_Position = WORLDVIEWPROJ * POSITION; color = COLOR; uv = TEXCOORD_0; #ifdef ENABLE_FOG //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); #endif #ifdef GLINT layer1UV = calculateLayerUV(UV_OFFSET.x, UV_ROTATION.x); layer2UV = calculateLayerUV(UV_OFFSET.y, UV_ROTATION.y); #endif }