Bliss-Shader/shaders/lib/diffuse_lighting.glsl
2024-05-02 13:06:48 -04:00

45 lines
1.7 KiB
GLSL

vec3 DoAmbientLightColor(
vec3 lpvPos,
vec3 SkyColor,
vec3 MinimumColor,
vec3 TorchColor,
vec2 Lightmap
){
float LightLevelZero = clamp(pow(eyeBrightnessSmooth.y/240. + Lightmap.y,2.0) ,0.0,1.0);
// do sky lighting.
float skyLM = (pow(Lightmap.y,15.0)*2.0 + pow(Lightmap.y,2.5))*0.5;
vec3 MinimumLight = MinimumColor * (MIN_LIGHT_AMOUNT*0.01 + nightVision);
vec3 IndirectLight = max(SkyColor * ambient_brightness * skyLM, MinimumLight);
// do torch lighting.
// 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)));
#if defined IS_LPV_ENABLED && defined MC_GL_EXT_shader_image_load_store
vec4 lpvSample = SampleLpvLinear(lpvPos);
vec3 LpvTorchLight = GetLpvBlockLight(lpvSample);
// 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);
#endif
return IndirectLight + TorchLight;
}
vec4 RT_AmbientLight(
vec3 TorchColor,
vec2 Lightmap
){
float skyLM = (pow(Lightmap.y,15.0)*2.0 + pow(Lightmap.y,2.5))*0.5;
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;
return vec4(TorchLight, skyLM);
}