2023-10-18 17:43:29 -04:00
|
|
|
vec3 DoAmbientLightColor(
|
2024-05-02 12:43:30 -04:00
|
|
|
vec3 lpvPos,
|
2024-03-01 22:48:09 -05:00
|
|
|
vec3 SkyColor,
|
|
|
|
vec3 MinimumColor,
|
2023-10-18 17:43:29 -04:00
|
|
|
vec3 TorchColor,
|
|
|
|
vec2 Lightmap
|
|
|
|
){
|
2024-03-22 22:11:43 -04:00
|
|
|
float LightLevelZero = clamp(pow(eyeBrightnessSmooth.y/240. + Lightmap.y,2.0) ,0.0,1.0);
|
|
|
|
|
2023-10-18 17:43:29 -04:00
|
|
|
// do sky lighting.
|
|
|
|
float skyLM = (pow(Lightmap.y,15.0)*2.0 + pow(Lightmap.y,2.5))*0.5;
|
2024-03-01 22:48:09 -05:00
|
|
|
vec3 MinimumLight = MinimumColor * (MIN_LIGHT_AMOUNT*0.01 + nightVision);
|
2024-03-22 22:11:43 -04:00
|
|
|
vec3 IndirectLight = max(SkyColor * ambient_brightness * skyLM, MinimumLight);
|
|
|
|
|
2023-10-18 17:43:29 -04:00
|
|
|
// do torch lighting.
|
2024-05-02 13:06:48 -04:00
|
|
|
// float TorchLM = 10.0 - ( 1.0 / (pow(exp(-0.5*inversesqrt(Lightmap.x)),5.0)+0.1));
|
|
|
|
// TorchLM = pow(TorchLM/4,10) + pow(Lightmap.x,1.5)*0.5;
|
|
|
|
|
|
|
|
float TorchLM = pow(Lightmap.x,10.0)*5.0 + pow(Lightmap.x,1.5);
|
|
|
|
vec3 TorchLight = TorchColor * TORCH_AMOUNT * TorchLM * (1.0 + LightLevelZero*dot(SkyColor * ambient_brightness,vec3(0.3333)));
|
|
|
|
|
2024-05-02 12:43:30 -04:00
|
|
|
#if defined IS_LPV_ENABLED && defined MC_GL_EXT_shader_image_load_store
|
2024-05-02 13:00:51 -04:00
|
|
|
vec4 lpvSample = SampleLpvLinear(lpvPos);
|
2024-05-02 13:06:48 -04:00
|
|
|
vec3 LpvTorchLight = GetLpvBlockLight(lpvSample);
|
2024-03-23 18:29:25 -04:00
|
|
|
|
2024-05-02 13:06:48 -04:00
|
|
|
// TODO: needs work, just binary transition for now
|
|
|
|
float LpvFadeF = clamp(lpvPos, vec3(0.0), LpvSize3 - 1.0) == lpvPos ? 1.0 : 0.0;
|
|
|
|
TorchLight = mix(TorchLight, LpvTorchLight, LpvFadeF);
|
2024-05-02 12:43:30 -04:00
|
|
|
#endif
|
2024-03-23 18:29:25 -04:00
|
|
|
|
2023-10-18 17:43:29 -04:00
|
|
|
return IndirectLight + TorchLight;
|
2023-07-31 23:31:56 -04:00
|
|
|
}
|
2023-10-20 20:26:41 -04:00
|
|
|
|
2023-10-18 17:43:29 -04:00
|
|
|
vec4 RT_AmbientLight(
|
|
|
|
vec3 TorchColor,
|
|
|
|
vec2 Lightmap
|
|
|
|
){
|
|
|
|
float skyLM = (pow(Lightmap.y,15.0)*2.0 + pow(Lightmap.y,2.5))*0.5;
|
2023-07-31 23:31:56 -04:00
|
|
|
|
2023-10-18 17:43:29 -04:00
|
|
|
float TorchLM = 10.0 - ( 1.0 / (pow(exp(-0.5*inversesqrt(Lightmap.x)),5.0)+0.1));
|
|
|
|
TorchLM = pow(TorchLM/4,10) + pow(Lightmap.x,1.5)*0.5;
|
|
|
|
vec3 TorchLight = TorchColor * TORCH_AMOUNT * TorchLM;
|
2023-04-16 16:18:26 -04:00
|
|
|
|
2023-10-18 17:43:29 -04:00
|
|
|
return vec4(TorchLight, skyLM);
|
2023-10-20 20:26:41 -04:00
|
|
|
}
|