Code (cpp):
#version 120
/*
This shaderpack was made by Avalon.
Don't plagiarize this pack.
Place two leading Slashes in front of the following '#define' lines in order to disable an option. (It can provoke some bugs and I don't recommend to do this)
*/
varying vec4 texcoord;
varying vec3 sunlight;
varying vec3 lightVector;
varying vec3 ambient_color;
varying vec3 sunVec;
varying vec3 upVec;
varying float SdotU;
varying float sunVisibility;
uniform int worldTime;
uniform float rainStrength;
uniform vec3 sunPosition;
uniform vec3 moonPosition;
uniform vec3 upPosition;
const ivec4 ToD[25] = ivec4[25](ivec4(0,10,15,30),
ivec4(1,10,15,30),
ivec4(2,10,15,30),
ivec4(3,10,15,30),
ivec4(4,10,15,30),
ivec4(5,10,15,30),
ivec4(6,255,190,70),
ivec4(7,255,195,80),
ivec4(8,255,200,97),
ivec4(9,255,200,110),
ivec4(10,255,205,125),
ivec4(11,255,215,140),
ivec4(12,255,215,140),
ivec4(13,255,215,140),
ivec4(14,255,205,125),
ivec4(15,255,200,110),
ivec4(16,255,200,97),
ivec4(17,255,195,80),
ivec4(18,255,190,70),
ivec4(19,77,67,194),
ivec4(20,10,15,30),
ivec4(21,10,15,30),
ivec4(22,10,15,30),
ivec4(23,10,15,30),
ivec4(24,10,15,30));
const ivec4 ToD2[25] = ivec4[25](ivec4(0,10,20,45),
ivec4(1,10,20,45),
ivec4(2,10,20,45),
ivec4(3,10,20,45),
ivec4(4,10,20,45),
ivec4(5,60,120,180),
ivec4(6,160,200,255),
ivec4(7,160,205,255),
ivec4(8,160,210,260),
ivec4(9,165,220,270),
ivec4(10,190,235,280),
ivec4(11,205,250,290),
ivec4(12,220,250,300),
ivec4(13,205,250,290),
ivec4(14,190,235,280),
ivec4(15,165,220,270),
ivec4(16,150,210,260),
ivec4(17,140,200,255),
ivec4(18,120,140,220),
ivec4(19,50,55,110),
ivec4(20,10,20,45),
ivec4(21,10,20,45),
ivec4(22,10,20,45),
ivec4(23,10,20,45),
ivec4(24,10,20,45));
void main() {
if (worldTime < 12700 || worldTime > 23250) {
lightVector = normalize(sunPosition);
} else {
lightVector = normalize(moonPosition);
}
gl_Position = ftransform();
texcoord = gl_MultiTexCoord0;
sunVec = normalize(sunPosition);
upVec = normalize(upPosition);
SdotU = dot(sunVec,upVec);
sunVisibility = pow(clamp(SdotU+0.1,0.0,0.1)/0.1,2.0);
float hour = worldTime/1000.0+6.0;
if (hour > 24.0) hour = hour - 24.0;
ivec4 temp = ToD[int(floor(hour))];
ivec4 temp2 = ToD[int(floor(hour)) + 1];
sunlight = mix(vec3(temp.yzw),vec3(temp2.yzw),(hour-float(temp.x))/float(temp2.x-temp.x))/255.0f;
ivec4 tempa = ToD2[int(floor(hour))];
ivec4 tempa2 = ToD2[int(floor(hour)) + 1];
ambient_color = mix(vec3(tempa.yzw),vec3(tempa2.yzw),(hour-float(tempa.x))/float(tempa2.x-tempa.x))/255.0f;
}