This repository has been archived by the owner on Apr 25, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
final.vsh
228 lines (157 loc) · 6.67 KB
/
final.vsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
/*
_______ _________ _______ _______ _
( ____ \\__ __/( ___ )( ____ )( )
| ( \/ ) ( | ( ) || ( )|| |
| (_____ | | | | | || (____)|| |
(_____ ) | | | | | || _____)| |
) | | | | | | || ( (_)
/\____) | | | | (___) || ) _
\_______) )_( (_______)|/ (_)
This shader is for use with the Optifine Mod. This shader will not work correctly when used with the GLSL Shaders Mod.
This shader was orignally made by MiningGodBruce, and modified heavily by RYRY1002.
Make sure to follow our license when copying, modifying, merging, publishing and/or distributing our work.
(See our license at https://github.com/RYRY1002/acid-interstate-v4/blob/main/LICENSE.md)
This shader is super broken, and should not be used for normal play.
I'm not going to help you if you can't get this shader to work, because I don't care.
If you want to make a video using this shader, go for it!
I'm not going to tell you how, but I'm happy for you to make something with it.
Thanks to [MiningGodBruce](https://www.youtube.com/user/MiningGodBruce) (BruceKnowsHow)
For helping me fix some bugs, and creating the shader that this shader is based on and inspire me to continue developing this video.
I'd appreciate if you shared the original video, it's cool when people enjoy it.
Also check out my stuff, I'd appreciate it.
https://links.riley.technology/
*/
#version 450 compatibility
uniform mat4 shadowModelViewInverse;
uniform vec3 sunPosition;
uniform vec3 moonPosition;
uniform vec3 upPosition;
uniform float rainStrength;
uniform float sunAngle;
uniform float far;
out vec3 worldLightVector;
out vec3 lightVector;
out vec3 upVector;
out vec3 colorSunlight;
out vec3 colorSkylight;
out vec3 colorSunglow;
out vec3 colorBouncedSunlight;
out vec3 colorScatteredSunlight;
out vec3 colorTorchlight;
out vec3 colorWaterMurk;
out vec3 colorWaterBlue;
out vec3 colorSkyTint;
out vec2 texcoord;
out float timeNoon;
out float timeMidnight;
out float timeSunriseSunset;
out float horizonTime;
out float timeSun;
out float timeMoon;
out float fogEnabled;
const float rayleigh = 0.02;
float CubicSmooth(in float x) {
return x * x * (3.0 - 2.0 * x);
}
float clamp01(float x) {
return clamp(x, 0.0, 1.0);
}
void main() {
texcoord = gl_MultiTexCoord0.st;
gl_Position = ftransform();
if (sunAngle < 0.5) {
lightVector = normalize(sunPosition);
} else {
lightVector = normalize(moonPosition);
}
upVector = normalize(upPosition);
worldLightVector = normalize((shadowModelViewInverse * vec4(0.0, 0.0, 0.0, 1.0)).xyz);
vec3 sunVector = normalize(sunPosition);
float LdotUp = dot(upVector, sunVector);
float LdotDown = dot(-upVector, sunVector);
float timePow = 4.0;
horizonTime = CubicSmooth(clamp01((1.0 - abs(LdotUp)) * 4.0 - 3.0));
timeNoon = 1.0 - pow(1.0 - clamp01(LdotUp), timePow);
timeMidnight = 1.0 - pow(1.0 - clamp01(LdotDown), timePow);
timeMidnight = 1.0 - pow(1.0 - timeMidnight, 2.0);
timeSunriseSunset = 1.0 - timeNoon;
timeSunriseSunset *= 1.0 - timeMidnight;
timeSun = float(timeNoon > 0.0);
timeMoon = float(timeMidnight > 0.0);
colorWaterMurk = vec3(0.2, 0.5, 0.95);
colorWaterBlue = vec3(0.2, 0.5, 0.95);
colorWaterBlue = mix(colorWaterBlue, vec3(1.0), vec3(0.5));
//colors for shadows/sunlight and sky
vec3 sunrise_sun;
sunrise_sun.r = 1.00;
sunrise_sun.g = 0.58;
sunrise_sun.b = 0.00;
sunrise_sun *= 0.65 * 0.5 * timeSun;
vec3 sunrise_amb;
sunrise_amb.r = 0.30;
sunrise_amb.g = 0.595;
sunrise_amb.b = 0.70;
vec3 noon_sun;
noon_sun.r = mix(1.00, 1.00, rayleigh);
noon_sun.g = mix(1.00, 0.75, rayleigh);
noon_sun.b = mix(1.00, 0.00, rayleigh);
vec3 noon_amb;
noon_amb.r = 0.0 ;
noon_amb.g = 0.3 ;
noon_amb.b = 0.999;
vec3 midnight_sun;
midnight_sun.r = 0.3;
midnight_sun.g = 0.3;
midnight_sun.b = 0.3;
vec3 midnight_amb;
midnight_amb.r = 0.0 ;
midnight_amb.g = 0.23;
midnight_amb.b = 0.99;
colorSunlight = sunrise_sun * timeSunriseSunset + noon_sun * timeNoon + midnight_sun * timeMidnight;
sunrise_amb = vec3(0.19, 0.35, 0.7) * 0.15 * 2.0;
noon_amb = vec3(0.15, 0.29, 0.99);
midnight_amb = vec3(0.005, 0.01, 0.02) * 0.025;
colorSkylight = sunrise_amb * timeSunriseSunset + noon_amb * timeNoon + midnight_amb * timeMidnight;
vec3 colorSunglow_sunrise;
colorSunglow_sunrise.r = 1.00 * timeSunriseSunset;
colorSunglow_sunrise.g = 0.46 * timeSunriseSunset;
colorSunglow_sunrise.b = 0.00 * timeSunriseSunset;
vec3 colorSunglow_noon;
colorSunglow_noon.r = 1.0 * timeNoon;
colorSunglow_noon.g = 1.0 * timeNoon;
colorSunglow_noon.b = 1.0 * timeNoon;
vec3 colorSunglow_midnight;
colorSunglow_midnight.r = 0.05 * 0.8 * 0.0055 * timeMidnight;
colorSunglow_midnight.g = 0.20 * 0.8 * 0.0055 * timeMidnight;
colorSunglow_midnight.b = 0.90 * 0.8 * 0.0055 * timeMidnight;
colorSunglow = colorSunglow_sunrise + colorSunglow_noon + colorSunglow_midnight;
vec3 colorSkylight_rain = vec3(2.0, 2.0, 2.38) * 0.25 * (1.0 - timeMidnight * 0.995); //rain
colorSkylight = mix(colorSkylight, colorSkylight_rain, rainStrength); //rain
//Saturate sunlight colors
colorSunlight = pow(colorSunlight, vec3(4.2));
colorSunlight *= 1.0 - horizonTime;
colorBouncedSunlight = mix(colorSunlight, colorSkylight, 0.15);
colorScatteredSunlight = mix(colorSunlight, colorSkylight, 0.15);
colorSunglow = pow(colorSunglow, vec3(2.5));
//Make sunlight darker when not day time
//colorSunlight = mix(colorSunlight, colorSunlight * 0.5, timeSunriseSunset);
//colorSunlight = mix(colorSunlight, colorSunlight * 1.0, timeNoon);
//colorSunlight = mix(colorSunlight, colorSunlight * 0.0002, timeMidnight);
//Make reflected light darker when not day time
colorBouncedSunlight = mix(colorBouncedSunlight, colorBouncedSunlight * 0.5, timeSunriseSunset);
colorBouncedSunlight = mix(colorBouncedSunlight, colorBouncedSunlight * 1.0, timeNoon);
colorBouncedSunlight = mix(colorBouncedSunlight, colorBouncedSunlight * 0.000015, timeMidnight);
//Make scattered light darker when not day time
colorScatteredSunlight = mix(colorScatteredSunlight, colorScatteredSunlight * 0.5, timeSunriseSunset);
colorScatteredSunlight = mix(colorScatteredSunlight, colorScatteredSunlight * 1.0, timeNoon);
colorScatteredSunlight = mix(colorScatteredSunlight, colorScatteredSunlight * 0.000015, timeMidnight);
float colorSunlightLum = colorSunlight.r + colorSunlight.g + colorSunlight.b;
colorSunlightLum /= 3.0;
colorSunlight = mix(colorSunlight, vec3(colorSunlightLum), vec3(rainStrength));
//Torchlight color
float torchWhiteBalance = 0.05;
colorTorchlight = vec3(1.00, 0.22, 0.00);
colorTorchlight = mix(colorTorchlight, vec3(1.0), vec3(torchWhiteBalance));
colorTorchlight = pow(colorTorchlight, vec3(0.99));
fogEnabled = float(gl_Fog.start / far < 0.65);
}