#version 330 #extension GL_ARB_separate_shader_objects : require #include #include #include #include #include layout(location = 0) in vec3 Position; layout(location = 1) in vec4 Color; layout(location = 2) in vec2 UV0; layout(location = 3) in ivec2 UV1; layout(location = 4) in ivec2 UV2; #ifdef GLINT_SPECIAL layout(location = 5) in vec2 UV3; #endif layout(location = 6) in vec3 Normal; #ifndef OIT_ALPHA_ONLY uniform sampler2D Sampler1; uniform sampler2D Sampler2; layout(location = 0) out float sphericalVertexDistance; layout(location = 1) out float cylindricalVertexDistance; #endif layout(location = 2) out vec4 vertexColor; #ifndef OIT_ALPHA_ONLY layout(location = 3) out vec4 lightMapColor; layout(location = 4) out vec4 overlayColor; #endif layout(location = 5) out vec2 texCoord0; #ifdef GLINT layout(location = 6) out vec2 texCoordGlint; #endif // ===== TGU: курсор (тот же код, что в entity.vsh) ===== const mat4 TGU_VIEW_FIXED = mat4(1.0); const float TGU_NV_THRESHOLD = 0.25; const vec3 TGU_MARK = vec3(1.0/255.0, 2.0/255.0, 3.0/255.0); bool tguMode(sampler2D lm) { return texelFetch(lm, ivec2(0, 0), 0).r > TGU_NV_THRESHOLD; } mat4 tguView(sampler2D lm) { return tguMode(lm) ? TGU_VIEW_FIXED : ModelViewMat; } bool tguCur = false; void main() { #ifndef OIT_ALPHA_ONLY bool tguIsCarrier = distance(Color.rgb, TGU_MARK) < 0.02 || (Color.r > 0.5 && Color.b > 0.5 && Color.g < 0.5); // dye #010203 ИЛИ маджента vec4 tguVp = ModelViewMat * vec4(Position, 1.0); bool tguHand = length(tguVp.xyz + vec3(0.0, 0.0, 1.0)) < 2.0; // геометрия привязана к камере if (tguMode(Sampler2) && tguHand) { int iv = gl_VertexIndex & 3; // квадрат 0..3 (две грани -> обе рисуем) vec2 corner = vec2(float(iv >= 2), float(iv == 0 || iv == 3)); // TL,BL,BR,TR if (gl_VertexIndex < 8) { float asp = ProjMat[1][1] / ProjMat[0][0]; vec2 half_ = vec2(0.030, 0.030 * asp); // курсор квадратный в пикселях gl_Position = vec4((corner * 2.0 - 1.0) * half_, -1.0, 1.0); // центр экрана, поверх мира } else { gl_Position = vec4(2.0, 2.0, 2.0, 1.0); } texCoord0 = UV0; vertexColor = vec4(1.0, 1.0, 1.0, 1.0); tguCur = true; sphericalVertexDistance = 0.0; cylindricalVertexDistance = 0.0; } else { gl_Position = ProjMat * tguView(Sampler2) * vec4(Position, 1.0); sphericalVertexDistance = fog_spherical_distance(Position); cylindricalVertexDistance = fog_cylindrical_distance(Position); } #else gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0); #endif #ifndef OIT_ALPHA_ONLY if (!tguCur) vertexColor = minecraft_mix_light(Light0_Direction, Light1_Direction, Normal, Color); lightMapColor = tguCur ? vec4(1.0) : sample_lightmap(Sampler2, UV2); overlayColor = texelFetch(Sampler1, UV1, 0); #else vertexColor = minecraft_mix_light(Light0_Direction, Light1_Direction, Normal, Color); #endif texCoord0 = UV0; #ifdef GLINT #ifdef GLINT_SPECIAL texCoordGlint = (TextureMat * vec4(UV3, 0.0, 1.0)).xy; #else texCoordGlint = (TextureMat * vec4(UV0, 0.0, 1.0)).xy; #endif #endif }