mirror of
https://github.com/X0nk/Bliss-Shader.git
synced 2025-06-22 00:37:35 +08:00
ADD Colored shadows
This commit is contained in:
@ -11,6 +11,12 @@ varying vec4 color;
|
||||
#ifdef OVERWORLD_SHADER
|
||||
const bool shadowHardwareFiltering = true;
|
||||
uniform sampler2DShadow shadow;
|
||||
|
||||
#ifdef TRANSLUCENT_COLORED_SHADOWS
|
||||
uniform sampler2D shadowcolor0;
|
||||
uniform sampler2DShadow shadowtex0;
|
||||
uniform sampler2DShadow shadowtex1;
|
||||
#endif
|
||||
|
||||
flat varying vec3 WsunVec;
|
||||
|
||||
@ -147,7 +153,7 @@ void main() {
|
||||
if(lightmap.x >= 0.9) Torch_Color *= LIT_PARTICLE_BRIGHTNESS;
|
||||
|
||||
#ifdef OVERWORLD_SHADER
|
||||
float Shadows = 1.0;
|
||||
vec3 Shadows = vec3(1.0);
|
||||
|
||||
vec3 feetPlayerPos_shadow = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz;
|
||||
vec3 projectedShadowPosition = mat3(shadowModelView) * feetPlayerPos_shadow + shadowModelView[3].xyz;
|
||||
@ -163,10 +169,21 @@ void main() {
|
||||
|
||||
//do shadows only if on shadow map
|
||||
if (abs(projectedShadowPosition.x) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.y) < 1.0-1.5/shadowMapResolution){
|
||||
Shadows = vec3(0.0);
|
||||
|
||||
projectedShadowPosition = projectedShadowPosition * vec3(0.5,0.5,0.5/6.0) + vec3(0.5);
|
||||
|
||||
Shadows = shadow2D(shadow, projectedShadowPosition).x;
|
||||
#ifdef TRANSLUCENT_COLORED_SHADOWS
|
||||
float opaqueShadow = shadow2D(shadowtex0, projectedShadowPosition).x;
|
||||
Shadows += vec3(opaqueShadow);
|
||||
|
||||
if(shadow2D(shadowtex1, projectedShadowPosition).x > projectedShadowPosition.z){
|
||||
vec4 translucentShadow = texture2D(shadowcolor0, projectedShadowPosition.xy);
|
||||
if(translucentShadow.a < 0.9) Shadows += normalize(translucentShadow.rgb+0.0001) * (1.0-opaqueShadow);
|
||||
}
|
||||
#else
|
||||
Shadows = vec3(shadow2D(shadow, projectedShadowPosition).x);
|
||||
#endif
|
||||
}
|
||||
|
||||
float cloudShadow = GetCloudShadow(feetPlayerPos);
|
||||
|
@ -7,6 +7,12 @@ varying vec4 color;
|
||||
#ifdef OVERWORLD_SHADER
|
||||
const bool shadowHardwareFiltering = true;
|
||||
uniform sampler2DShadow shadow;
|
||||
|
||||
#ifdef TRANSLUCENT_COLORED_SHADOWS
|
||||
uniform sampler2D shadowcolor0;
|
||||
uniform sampler2DShadow shadowtex0;
|
||||
uniform sampler2DShadow shadowtex1;
|
||||
#endif
|
||||
|
||||
uniform float lightSign;
|
||||
flat varying vec3 WsunVec;
|
||||
@ -350,6 +356,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
||||
|
||||
|
||||
vec4 COLORTEST = vec4(Albedo, UnchangedAlpha);
|
||||
if (iswater > 0.95) COLORTEST = vec4(0.0);
|
||||
|
||||
#ifdef BIOME_TINT_WATER
|
||||
if (iswater > 0.95) COLORTEST.rgb = color.rgb;
|
||||
@ -418,7 +425,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
||||
|
||||
#ifdef OVERWORLD_SHADER
|
||||
float NdotL = clamp(dot(normal, normalize(WsunVec*mat3(gbufferModelViewInverse))),0.0,1.0); NdotL = clamp((-15 + NdotL*255.0) / 240.0 ,0.0,1.0);
|
||||
float Shadows = 0.0;
|
||||
vec3 Shadows = vec3(0.0);
|
||||
bool inShadowmapBounds = false;
|
||||
|
||||
vec3 feetPlayerPos_shadow = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz;
|
||||
@ -444,7 +451,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
||||
// sample shadows only if on shadow map
|
||||
if(ShadowBounds){
|
||||
if (NdotL > 0.0){
|
||||
Shadows = 0.0;
|
||||
Shadows = vec3(0.0);
|
||||
projectedShadowPosition = projectedShadowPosition * vec3(0.5,0.5,0.5/6.0) + vec3(0.5);
|
||||
|
||||
#ifndef HAND
|
||||
@ -458,25 +465,52 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
||||
|
||||
int SampleCount = 7;
|
||||
for(int i = 0; i < SampleCount; i++){
|
||||
// vec2 offsetS = tapLocation(i,SampleCount,1.618,noise,0.0);
|
||||
vec2 offsetS = tapLocation_simple(i, 7, 9, noise) * 0.5;
|
||||
|
||||
float weight = 1.0+(i+noise)*rdMul/9.0*shadowMapResolution;
|
||||
float isShadow = shadow2D(shadow, projectedShadowPosition + vec3(rdMul*offsetS, -diffthresh*weight)).x / SampleCount;
|
||||
Shadows += isShadow;
|
||||
}
|
||||
|
||||
#ifdef TRANSLUCENT_COLORED_SHADOWS
|
||||
vec3 shadowProjOffsets = projectedShadowPosition + vec3(rdMul*offsetS, -diffthresh*weight);
|
||||
|
||||
float opaqueShadow = shadow2D(shadowtex0, shadowProjOffsets).x;
|
||||
Shadows += vec3(opaqueShadow/SampleCount);
|
||||
|
||||
if(shadow2D(shadowtex1, shadowProjOffsets).x > shadowProjOffsets.z){
|
||||
vec4 translucentShadow = texture2D(shadowcolor0, shadowProjOffsets.xy);
|
||||
if(translucentShadow.a < 0.9) Shadows += (normalize(translucentShadow.rgb+0.0001) * clamp(1.0-opaqueShadow,0.0,1.0)) / SampleCount;
|
||||
}
|
||||
|
||||
#else
|
||||
Shadows += vec3(shadow2D(shadow, projectedShadowPosition + vec3(rdMul*offsetS, -diffthresh*weight)).x / SampleCount);
|
||||
#endif
|
||||
|
||||
}
|
||||
#else
|
||||
Shadows = shadow2D(shadow, projectedShadowPosition - vec3(0.0,0.0,0.0001)).x;
|
||||
|
||||
#ifdef TRANSLUCENT_COLORED_SHADOWS
|
||||
projectedShadowPosition -= vec3(0.0,0.0,0.0001);
|
||||
Shadows = vec3(shadow2D(shadowtex0, projectedShadowPosition ).x);
|
||||
|
||||
if(shadow2D(shadowtex1, projectedShadowPosition).x > projectedShadowPosition.z){
|
||||
vec4 shadowLightColor = texture2D(shadowcolor0, projectedShadowPosition.xy);
|
||||
if(shadowLightColor.a < 0.9) Shadows += normalize(shadowLightColor.rgb+0.0001);
|
||||
}
|
||||
#else
|
||||
Shadows = vec3(shadow2D(shadow, projectedShadowPosition - vec3(0.0,0.0,0.0001)).x);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#else
|
||||
Shadows = shadow2D(shadow, projectedShadowPosition - vec3(0.0,0.0,0.0005)).x;
|
||||
Shadows = vec3(shadow2D(shadow, projectedShadowPosition - vec3(0.0,0.0,0.0005)).x);
|
||||
#endif
|
||||
}
|
||||
inShadowmapBounds = true;
|
||||
}
|
||||
|
||||
if(!inShadowmapBounds) Shadows = 1.0;
|
||||
if(!inShadowmapBounds) Shadows = vec3(1.0);
|
||||
|
||||
Shadows *= GetCloudShadow(feetPlayerPos);
|
||||
|
||||
@ -529,9 +563,9 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
||||
|
||||
vec3 FinalColor = (Indirect_lighting + Direct_lighting) * Albedo;
|
||||
|
||||
#ifdef Glass_Tint
|
||||
FinalColor *= min(pow(gl_FragData[0].a,2.0),1.0);
|
||||
#endif
|
||||
// #ifdef Glass_Tint
|
||||
// FinalColor *= min(pow(gl_FragData[0].a,2.0),1.0);
|
||||
// #endif
|
||||
|
||||
////////////////////////////////
|
||||
//////////////////////////////// SPECULAR
|
||||
@ -548,8 +582,8 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
||||
float roughness = max(pow(1.0-SpecularTex.r,2.0),0.05);
|
||||
float f0 = SpecularTex.g;
|
||||
|
||||
// roughness = 0.0;
|
||||
// f0 = 0.9;
|
||||
// roughness = 0.1;
|
||||
// f0 = 1.0;
|
||||
|
||||
if (iswater > 0.0 && gl_FragData[0].a < 0.9999999){
|
||||
vec3 Reflections_Final = vec3(0.0);
|
||||
@ -571,20 +605,20 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
||||
|
||||
fresnel = mix(f0, 1.0, fresnel);
|
||||
|
||||
vec3 Metals = f0 > 229.5/255.0 ? mix(normalize(Albedo+1e-7) * (dot(Albedo,vec3(0.21, 0.72, 0.07)) * 0.7 + 0.3), vec3(1.0), fresnel * pow(1.0-roughness,25.0)) : vec3(1.0);
|
||||
vec3 Metals = f0 > 229.5/255.0 ? normalize(Albedo+1e-7) * (dot(Albedo,vec3(0.21, 0.72, 0.07)) * 0.7 + 0.3) : vec3(1.0);
|
||||
|
||||
|
||||
// Sun, Sky, and screen-space reflections
|
||||
#ifdef OVERWORLD_SHADER
|
||||
#ifdef WATER_SUN_SPECULAR
|
||||
SunReflection = Direct_lighting * GGX(normal, -normalize(viewPos), WsunVec*mat3(gbufferModelViewInverse), roughness, vec3(f0)) * Metals;
|
||||
SunReflection = Direct_lighting * GGX(normal, -normalize(viewPos), WsunVec*mat3(gbufferModelViewInverse), roughness, vec3(f0)) ;
|
||||
#endif
|
||||
#ifdef WATER_BACKGROUND_SPECULAR
|
||||
if(isEyeInWater == 0) SkyReflection = skyCloudsFromTex(mat3(gbufferModelViewInverse) * reflectedVector, colortex4).rgb / 30.0 *Metals;
|
||||
if(isEyeInWater == 0) SkyReflection = skyCloudsFromTex(mat3(gbufferModelViewInverse) * reflectedVector, colortex4).rgb / 30.0 ;
|
||||
#endif
|
||||
#else
|
||||
#ifdef WATER_BACKGROUND_SPECULAR
|
||||
if(isEyeInWater == 0) SkyReflection = skyCloudsFromTexLOD2(mat3(gbufferModelViewInverse) * reflectedVector, colortex4, 0).rgb / 30.0 * Metals;
|
||||
if(isEyeInWater == 0) SkyReflection = skyCloudsFromTexLOD2(mat3(gbufferModelViewInverse) * reflectedVector, colortex4, 0).rgb / 30.0 ;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef SCREENSPACE_REFLECTIONS
|
||||
@ -596,7 +630,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
||||
previousPosition.xy = projMAD(gbufferPreviousProjection, previousPosition).xy / -previousPosition.z * 0.5 + 0.5;
|
||||
if (previousPosition.x > 0.0 && previousPosition.y > 0.0 && previousPosition.x < 1.0 && previousPosition.x < 1.0) {
|
||||
Reflections.a = 1.0;
|
||||
Reflections.rgb = texture2D(colortex5,previousPosition.xy).rgb * Metals;
|
||||
Reflections.rgb = texture2D(colortex5,previousPosition.xy).rgb ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -613,10 +647,10 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
||||
Reflections_Final = FinalColor;
|
||||
#else
|
||||
Reflections_Final = mix(SkyReflection*indoors, Reflections.rgb, Reflections.a);
|
||||
Reflections_Final = mix(FinalColor, Reflections_Final, fresnel);
|
||||
Reflections_Final = mix(FinalColor, Reflections_Final * Metals, fresnel);
|
||||
#endif
|
||||
|
||||
Reflections_Final += SunReflection;
|
||||
Reflections_Final += SunReflection * Metals;
|
||||
|
||||
|
||||
gl_FragData[0].rgb = Reflections_Final ;
|
||||
|
@ -2,14 +2,28 @@
|
||||
#include "/lib/res_params.glsl"
|
||||
|
||||
|
||||
vec3 saturation(inout vec3 color, float saturation){
|
||||
|
||||
|
||||
float luminance = dot(color, vec3(0.21, 0.72, 0.07));
|
||||
|
||||
vec3 difference = color - luminance;
|
||||
|
||||
return color = color + difference*saturation;
|
||||
}
|
||||
|
||||
const bool colortex5MipmapEnabled = true;
|
||||
|
||||
#ifdef OVERWORLD_SHADER
|
||||
const bool shadowHardwareFiltering = true;
|
||||
uniform sampler2DShadow shadow;
|
||||
|
||||
|
||||
#ifdef TRANSLUCENT_COLORED_SHADOWS
|
||||
uniform sampler2D shadowcolor0;
|
||||
uniform sampler2DShadow shadowtex0;
|
||||
uniform sampler2DShadow shadowtex1;
|
||||
#endif
|
||||
|
||||
flat varying vec3 averageSkyCol_Clouds;
|
||||
flat varying vec4 lightCol;
|
||||
|
||||
@ -844,19 +858,20 @@ void main() {
|
||||
vec3 Direct_lighting = vec3(0.0);
|
||||
vec3 Direct_SSS = vec3(0.0);
|
||||
float cloudShadow = 1.0;
|
||||
float Shadows = 1.0;
|
||||
vec3 Shadows = vec3(1.0);
|
||||
float NdotL = 1.0;
|
||||
|
||||
|
||||
|
||||
float shadowMap = 1.0;
|
||||
vec3 shadowMap = vec3(1.0);
|
||||
#ifdef DISTANT_HORIZONS_SHADOWMAP
|
||||
float shadowMapFalloff = pow(1.0-pow(1.0-min(max(1.0 - length(vec3(feetPlayerPos.x,feetPlayerPos.y/1.5,feetPlayerPos.z)) / min(shadowDistance, dhFarPlane),0.0)*5.0,1.0),2.0),2.0);
|
||||
#else
|
||||
float shadowMapFalloff = pow(1.0-pow(1.0-min(max(1.0 - length(vec3(feetPlayerPos.x,feetPlayerPos.y/1.5,feetPlayerPos.z)) / shadowDistance,0.0)*5.0,1.0),2.0),2.0);
|
||||
#endif
|
||||
float shadowMapFalloff2 = pow(1.0-pow(1.0-min(max(1.0 - length(vec3(feetPlayerPos.x,feetPlayerPos.y/1.5,feetPlayerPos.z)) / min(shadowDistance,far),0.0)*5.0,1.0),2.0),2.0);
|
||||
|
||||
// shadowMapFalloff = 0;
|
||||
// shadowMapFalloff2 = 0;
|
||||
float LM_shadowMapFallback = min(max(lightmap.y-0.8, 0.0) * 25,1.0);
|
||||
|
||||
#ifdef OVERWORLD_SHADER
|
||||
@ -895,8 +910,8 @@ void main() {
|
||||
#endif
|
||||
|
||||
float ShadowBlockerDepth = filteredShadow.y;
|
||||
Shadows = clamp(1.0 - filteredShadow.b,0.0,1.0);
|
||||
shadowMap = Shadows;
|
||||
Shadows = vec3(clamp(1.0 - filteredShadow.b,0.0,1.0));
|
||||
shadowMap = vec3(Shadows);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -948,7 +963,7 @@ void main() {
|
||||
} else {
|
||||
|
||||
feetPlayerPos += gbufferModelViewInverse[3].xyz;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////// UNDER WATER SHADING ////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -1019,7 +1034,8 @@ void main() {
|
||||
if(shadowDistanceRenderMul < 0.0) shadowMapFalloff = abs(projectedShadowPosition.x) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.y) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.z) < 6.0 ? 1.0 : 0.0;
|
||||
|
||||
if(shadowMapFalloff > 0.0){
|
||||
shadowMap = 0.0;
|
||||
shadowMap = vec3(0.0);
|
||||
vec3 ShadowColor = vec3(0.0);
|
||||
|
||||
projectedShadowPosition = projectedShadowPosition * vec3(0.5,0.5,0.5/6.0) + vec3(0.5);
|
||||
|
||||
@ -1032,22 +1048,52 @@ void main() {
|
||||
for(int i = 0; i < SHADOW_FILTER_SAMPLE_COUNT; i++){
|
||||
vec2 offsetS = tapLocation_simple(i, 7, 9, noise_2) * 0.5;
|
||||
|
||||
shadowMap += shadow2D(shadow, projectedShadowPosition + vec3(rdMul*offsetS, biasOffset) ).x/SHADOW_FILTER_SAMPLE_COUNT;
|
||||
projectedShadowPosition += vec3(rdMul*offsetS, biasOffset);
|
||||
|
||||
|
||||
#ifdef TRANSLUCENT_COLORED_SHADOWS
|
||||
float opaqueShadow = shadow2D(shadowtex0, projectedShadowPosition).x;
|
||||
ShadowColor += vec3(opaqueShadow/SHADOW_FILTER_SAMPLE_COUNT);
|
||||
|
||||
if(shadow2D(shadowtex1, projectedShadowPosition).x > projectedShadowPosition.z){
|
||||
vec4 translucentShadow = texture2D(shadowcolor0, projectedShadowPosition.xy);
|
||||
if(translucentShadow.a < 0.9) ShadowColor += (normalize(translucentShadow.rgb+0.0001) * clamp(1.0-opaqueShadow,0.0,1.0)) / SHADOW_FILTER_SAMPLE_COUNT;
|
||||
}
|
||||
#else
|
||||
ShadowColor += vec3(shadow2D(shadow, projectedShadowPosition).x/SHADOW_FILTER_SAMPLE_COUNT);
|
||||
#endif
|
||||
}
|
||||
|
||||
shadowMap = ShadowColor;
|
||||
|
||||
#else
|
||||
shadowMap = shadow2D(shadow, projectedShadowPosition + vec3(0.0,0.0, biasOffset)).x;
|
||||
#ifdef TRANSLUCENT_COLORED_SHADOWS
|
||||
|
||||
float OPAQUESHADOW = shadow2D(shadowtex0, projectedShadowPosition).x;
|
||||
shadowMap += vec3(OPAQUESHADOW);
|
||||
|
||||
if(shadow2D(shadowtex1, projectedShadowPosition).x > projectedShadowPosition.z){
|
||||
vec4 shadowLightColor = texture2D(shadowcolor0, projectedShadowPosition.xy);
|
||||
if(shadowLightColor.a < 0.9) shadowMap += normalize(shadowLightColor.rgb+0.0001) * (1.0-OPAQUESHADOW);
|
||||
}
|
||||
#else
|
||||
shadowMap += vec3(shadow2D(shadow, projectedShadowPosition).x);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Shadows = shadowMap;
|
||||
|
||||
// if(shadow2D(shadowtex0, projectedShadowPosition).x < projectedShadowPosition.z) DirectLightColor *= shadow2D(shadowtex1, projectedShadowPosition).x * waterCaustics(feetPlayerPos + cameraPosition, WsunVec)*WATER_CAUSTICS_BRIGHTNESS + 0.25;
|
||||
|
||||
}
|
||||
|
||||
if(!iswater) Shadows = mix(LM_shadowMapFallback, Shadows, shadowMapFalloff2);
|
||||
if(!iswater) Shadows = mix(vec3(LM_shadowMapFallback), Shadows, shadowMapFalloff2);
|
||||
|
||||
#ifdef OLD_LIGHTLEAK_FIX
|
||||
if (isEyeInWater == 0) Shadows *= clamp(pow(eyeBrightnessSmooth.y/240. + lightmap.y,2.0) ,0.0,1.0); // light leak fix
|
||||
if (isEyeInWater == 0) Shadows *= clamp(pow(eyeBrightnessSmooth.y/240. + lightmap.y,2.0) ,0.0,1.0); // light leak fix
|
||||
#endif
|
||||
// }
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////// SUN SSS ////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -1064,7 +1110,7 @@ void main() {
|
||||
#endif
|
||||
|
||||
#if !defined Variable_Penumbra_Shadows
|
||||
ShadowBlockerDepth = pow(1.0 - Shadows,2.0);
|
||||
ShadowBlockerDepth = pow(1.0 - clamp(dot(Shadows,vec3(0.33333)),0,1),2.0);
|
||||
#endif
|
||||
|
||||
|
||||
@ -1273,11 +1319,11 @@ void main() {
|
||||
|
||||
|
||||
//////// DEBUG VIEW STUFF
|
||||
#if DEBUG_VIEW == debug_SHADOWMAP
|
||||
vec3 OutsideShadowMap_and_DH_shadow = (shadowMapFalloff > 0.0 && z >= 1.0) ? vec3(0.25,1.0,0.25) : vec3(1.0,0.25,0.25);
|
||||
vec3 Normal_Shadowmap = z < 1.0 ? vec3(0.25,0.25,1.0) : OutsideShadowMap_and_DH_shadow;
|
||||
gl_FragData[0].rgb = mix(vec3(0.1) * (normal.y * 0.1 +0.9), Normal_Shadowmap, shadowMap);
|
||||
#endif
|
||||
// #if DEBUG_VIEW == debug_SHADOWMAP
|
||||
// vec3 OutsideShadowMap_and_DH_shadow = (shadowMapFalloff > 0.0 && z >= 1.0) ? vec3(0.25,1.0,0.25) : vec3(1.0,0.25,0.25);
|
||||
// vec3 Normal_Shadowmap = z < 1.0 ? vec3(0.25,0.25,1.0) : OutsideShadowMap_and_DH_shadow;
|
||||
// gl_FragData[0].rgb = mix(vec3(0.1) * (normal.y * 0.1 +0.9), Normal_Shadowmap, shadowMap) * 30.0;
|
||||
// #endif
|
||||
#if DEBUG_VIEW == debug_NORMALS
|
||||
gl_FragData[0].rgb = FlatNormals;
|
||||
#endif
|
||||
@ -1293,7 +1339,6 @@ void main() {
|
||||
#if DEBUG_VIEW == debug_VIEW_POSITION
|
||||
gl_FragData[0].rgb = viewPos * 0.001;
|
||||
#endif
|
||||
|
||||
#if DEBUG_VIEW == debug_FILTERED_STUFF
|
||||
vec3 FilteredDebug = vec3(15.0) * exp(-1.0 * vec3(1.0,0.5,1.0) * filteredShadow.y);
|
||||
FilteredDebug += vec3(15.0) * exp(-7.0 * vec3(1.0,1.0,0.5) * pow(SSAO_SSS.x,2));
|
||||
|
@ -65,7 +65,11 @@ float linearizeDepthFast(const in float depth, const in float near, const in flo
|
||||
#ifdef OVERWORLD_SHADER
|
||||
const bool shadowHardwareFiltering = true;
|
||||
uniform sampler2DShadow shadow;
|
||||
|
||||
#ifdef TRANSLUCENT_COLORED_SHADOWS
|
||||
uniform sampler2D shadowcolor0;
|
||||
uniform sampler2DShadow shadowtex0;
|
||||
uniform sampler2DShadow shadowtex1;
|
||||
#endif
|
||||
flat varying vec3 refractedSunVec;
|
||||
|
||||
#define TIMEOFDAYFOG
|
||||
@ -263,7 +267,7 @@ void waterVolumetrics(inout vec3 inColor, vec3 rayStart, vec3 rayEnd, float estE
|
||||
|
||||
progressW = gbufferModelViewInverse[3].xyz+cameraPosition + d*dVWorld;
|
||||
|
||||
float sh = 1.0;
|
||||
vec3 sh = vec3(1.0);
|
||||
#ifdef OVERWORLD_SHADER
|
||||
vec3 spPos = start.xyz + dV*d;
|
||||
|
||||
@ -276,7 +280,16 @@ void waterVolumetrics(inout vec3 inColor, vec3 rayStart, vec3 rayEnd, float estE
|
||||
vec3 pos = vec3(spPos.xy*distortFactor, spPos.z);
|
||||
if (abs(pos.x) < 1.0-0.5/2048. && abs(pos.y) < 1.0-0.5/2048){
|
||||
pos = pos*vec3(0.5,0.5,0.5/6.0)+0.5;
|
||||
sh = shadow2D( shadow, pos).x;
|
||||
// sh = shadow2D( shadow, pos).x;
|
||||
#ifdef TRANSLUCENT_COLORED_SHADOWS
|
||||
sh = vec3(shadow2D(shadowtex0, pos).x);
|
||||
|
||||
if(shadow2D(shadowtex1, pos).x > pos.z && sh.x < 1.0){
|
||||
sh = normalize(texture2D(shadowcolor0, pos.xy).rgb+0.0001);
|
||||
}
|
||||
#else
|
||||
sh = vec3(shadow2D(shadow, pos).x);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef VL_CLOUDS_SHADOWS
|
||||
@ -291,7 +304,7 @@ void waterVolumetrics(inout vec3 inColor, vec3 rayStart, vec3 rayEnd, float estE
|
||||
float sunCaustics = (waterCaustics(progressW, WsunVec)) * mix(0.25,10.0,bubble) + 0.75;
|
||||
|
||||
vec3 sunMul = exp(-1 * d * waterCoefs * 1.1);
|
||||
vec3 Directlight = (lightSource * phase * sunMul * sunCaustics) * sh * lowlightlevel * pow(abs(WsunVec.y),1);
|
||||
vec3 Directlight = ((lightSource* sh) * phase * sunMul * sunCaustics) * lowlightlevel * pow(abs(WsunVec.y),1);
|
||||
#else
|
||||
vec3 Directlight = vec3(0.0);
|
||||
#endif
|
||||
|
@ -328,7 +328,7 @@ void main() {
|
||||
|
||||
if (TranslucentShader.a > 0.0){
|
||||
#ifdef Glass_Tint
|
||||
if(albedo.a > 0.2 && !iswater) color = color*albedo.rgb + color * clamp(pow(1.0-luma(albedo.rgb),20.),0.0,1.0);
|
||||
if(albedo.a > 0.01) color *= normalize(albedo.rgb+0.0001)*0.9+0.1;
|
||||
#endif
|
||||
|
||||
color = color*(1.0-TranslucentShader.a) + TranslucentShader.rgb;
|
||||
|
@ -127,8 +127,15 @@ float linearizeDepthFast(const in float depth, const in float near, const in flo
|
||||
// uniform sampler2D colortex12;
|
||||
// const bool shadowHardwareFiltering = true;
|
||||
uniform sampler2DShadow shadow;
|
||||
uniform sampler2DShadow shadowtex0;
|
||||
uniform sampler2DShadow shadowtex1;
|
||||
|
||||
// #undef TRANSLUCENT_COLORED_SHADOWS
|
||||
|
||||
#ifdef TRANSLUCENT_COLORED_SHADOWS
|
||||
uniform sampler2D shadowcolor0;
|
||||
uniform sampler2DShadow shadowtex0;
|
||||
uniform sampler2DShadow shadowtex1;
|
||||
#endif
|
||||
|
||||
#define TEST
|
||||
#define TIMEOFDAYFOG
|
||||
#include "/lib/lightning_stuff.glsl"
|
||||
|
@ -67,12 +67,20 @@ float linearizeDepthFast(const in float depth, const in float near, const in flo
|
||||
const bool shadowHardwareFiltering = true;
|
||||
uniform sampler2DShadow shadow;
|
||||
|
||||
|
||||
#ifdef TRANSLUCENT_COLORED_SHADOWS
|
||||
uniform sampler2D shadowcolor0;
|
||||
uniform sampler2DShadow shadowtex0;
|
||||
uniform sampler2DShadow shadowtex1;
|
||||
#endif
|
||||
flat varying vec3 refractedSunVec;
|
||||
|
||||
|
||||
#define TIMEOFDAYFOG
|
||||
#include "/lib/lightning_stuff.glsl"
|
||||
#include "/lib/volumetricClouds.glsl"
|
||||
#include "/lib/overworld_fog.glsl"
|
||||
|
||||
#endif
|
||||
#ifdef NETHER_SHADER
|
||||
uniform sampler2D colortex4;
|
||||
@ -145,124 +153,6 @@ void waterVolumetrics_notoverworld(inout vec3 inColor, vec3 rayStart, vec3 rayEn
|
||||
inColor += vL;
|
||||
|
||||
}
|
||||
|
||||
#ifdef OVERWORLD_SHADER
|
||||
// float waterCaustics(vec3 wPos, vec3 lightSource) { // water waves
|
||||
|
||||
// vec2 pos = wPos.xz + (lightSource.xz/lightSource.y*wPos.y);
|
||||
// if(isEyeInWater==1) pos = wPos.xz - (lightSource.xz/lightSource.y*wPos.y); // fix the fucky
|
||||
// vec2 movement = vec2(-0.035*frameTimeCounter);
|
||||
// float caustic = 0.0;
|
||||
// float weightSum = 0.0;
|
||||
// float radiance = 2.39996;
|
||||
// mat2 rotationMatrix = mat2(vec2(cos(radiance), -sin(radiance)), vec2(sin(radiance), cos(radiance)));
|
||||
|
||||
// const vec2 wave_size[4] = vec2[](
|
||||
// vec2(64.),
|
||||
// vec2(32.,16.),
|
||||
// vec2(16.,32.),
|
||||
// vec2(48.)
|
||||
// );
|
||||
|
||||
// for (int i = 0; i < 4; i++){
|
||||
// pos = rotationMatrix * pos;
|
||||
|
||||
// vec2 speed = movement;
|
||||
// float waveStrength = 1.0;
|
||||
|
||||
// if( i == 0) {
|
||||
// speed *= 0.15;
|
||||
// waveStrength = 2.0;
|
||||
// }
|
||||
|
||||
// float small_wave = texture2D(noisetex, pos / wave_size[i] + speed ).b * waveStrength;
|
||||
|
||||
// caustic += max( 1.0-sin( 1.0-pow( 0.5+sin( small_wave*3.0 )*0.5, 25.0) ), 0);
|
||||
|
||||
// weightSum -= exp2(caustic*0.1);
|
||||
// }
|
||||
// return caustic / weightSum;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// void waterVolumetrics(inout vec3 inColor, vec3 rayStart, vec3 rayEnd, float estEyeDepth, float estSunDepth, float rayLength, float dither, vec3 waterCoefs, vec3 scatterCoef, vec3 ambient, vec3 lightSource, float VdotL){
|
||||
// int spCount = 8;
|
||||
|
||||
// vec3 start = toShadowSpaceProjected(rayStart);
|
||||
// vec3 end = toShadowSpaceProjected(rayEnd);
|
||||
// vec3 dV = (end-start);
|
||||
|
||||
// //limit ray length at 32 blocks for performance and reducing integration error
|
||||
// //you can't see above this anyway
|
||||
// float maxZ = min(rayLength,32.0)/(1e-8+rayLength);
|
||||
// dV *= maxZ;
|
||||
// vec3 dVWorld = mat3(gbufferModelViewInverse) * (rayEnd - rayStart) * maxZ;
|
||||
// rayLength *= maxZ;
|
||||
// float dY = normalize(mat3(gbufferModelViewInverse) * rayEnd).y * rayLength;
|
||||
|
||||
// vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition;
|
||||
|
||||
// float phase = fogPhase(VdotL) * 5.0;
|
||||
// vec3 absorbance = vec3(1.0);
|
||||
// vec3 vL = vec3(0.0);
|
||||
|
||||
// float YFade = pow(normalize(dVWorld).y*0.5+0.6,1.5);
|
||||
// // float YFade = pow(max(normalize(dVWorld).y,0.0)*0.5+0.5,2);
|
||||
|
||||
// float lowlightlevel = clamp(eyeBrightnessSmooth.y/240.0,0.2,1.0);
|
||||
// float lowlightlevel2 = clamp(eyeBrightnessSmooth.y/240.0,0.02,1.0);
|
||||
// // lowlightlevel = pow(lowlightlevel,0.5);
|
||||
|
||||
// float expFactor = 11.0;
|
||||
// for (int i=0;i<spCount;i++) {
|
||||
// float d = (pow(expFactor, float(i+dither)/float(spCount))/expFactor - 1.0/expFactor)/(1-1.0/expFactor); // exponential step position (0-1)
|
||||
// float dd = pow(expFactor, float(i+dither)/float(spCount)) * log(expFactor) / float(spCount)/(expFactor-1.0); //step length (derivative)
|
||||
// vec3 spPos = start.xyz + dV*d;
|
||||
// progressW = gbufferModelViewInverse[3].xyz+cameraPosition + d*dVWorld;
|
||||
// //project into biased shadowmap space
|
||||
// #ifdef DISTORT_SHADOWMAP
|
||||
// float distortFactor = calcDistort(spPos.xy);
|
||||
// #else
|
||||
// float distortFactor = 1.0;
|
||||
// #endif
|
||||
// vec3 pos = vec3(spPos.xy*distortFactor, spPos.z);
|
||||
// float sh = 1.0;
|
||||
// if (abs(pos.x) < 1.0-0.5/2048. && abs(pos.y) < 1.0-0.5/2048){
|
||||
// pos = pos*vec3(0.5,0.5,0.5/6.0)+0.5;
|
||||
// sh = shadow2D( shadow, pos).x;
|
||||
// }
|
||||
|
||||
// #ifdef VL_CLOUDS_SHADOWS
|
||||
// sh *= GetCloudShadow_VLFOG(progressW,WsunVec);
|
||||
// #endif
|
||||
|
||||
// // float bubble = 1.0 - pow(1.0-pow(1.0-min(max(1.0 - length(d*dVWorld) / (16),0.0)*5.0,1.0),2.0),2.0);
|
||||
// float bubble = exp( -7.0 * clamp(1.0 - length(d*dVWorld) / 16.0, 0.0,1.0) );
|
||||
// float bubble2 = max(pow(length(d*dVWorld)/24,5)*100.0,0.0) + 1;
|
||||
|
||||
|
||||
// float sunCaustics = (waterCaustics(progressW, WsunVec)) * mix(0.25,10.0,bubble) + 0.75;
|
||||
|
||||
// vec3 sunMul = exp(-1 * d * waterCoefs * 1.1);
|
||||
// vec3 ambientMul = exp(-1 * d * waterCoefs);
|
||||
|
||||
// vec3 Directlight = (lightSource * phase * sunMul * sunCaustics) * sh * lowlightlevel * pow(abs(WsunVec.y),1);
|
||||
// vec3 Indirectlight = ambient * ambientMul * lowlightlevel;
|
||||
|
||||
// // vec3 Indirectlight = max(ambient * ambientMul * lowlightlevel, vec3(0.01,0.2,0.4) * YFade * exp(-1.0 * d * waterCoefs));
|
||||
|
||||
// vec3 light = (Indirectlight + Directlight) * scatterCoef;
|
||||
|
||||
// vL += (light - light * exp(-waterCoefs * dd * rayLength)) / waterCoefs * absorbance;
|
||||
// absorbance *= exp(-waterCoefs * dd * rayLength);
|
||||
// }
|
||||
// inColor += vL;
|
||||
// }
|
||||
#endif
|
||||
|
||||
vec4 blueNoise(vec2 coord){
|
||||
return texelFetch2D(colortex6, ivec2(coord)%512 , 0) ;
|
||||
}
|
||||
@ -316,7 +206,7 @@ vec4 waterVolumetrics_test( vec3 rayStart, vec3 rayEnd, float estEndDepth, float
|
||||
|
||||
vec3 progressW = start.xyz+cameraPosition+dVWorld;
|
||||
|
||||
float sh = 1.0;
|
||||
vec3 sh = vec3(1.0);
|
||||
#ifdef OVERWORLD_SHADER
|
||||
vec3 spPos = start.xyz + dV*d;
|
||||
|
||||
@ -330,7 +220,18 @@ vec4 waterVolumetrics_test( vec3 rayStart, vec3 rayEnd, float estEndDepth, float
|
||||
vec3 pos = vec3(spPos.xy*distortFactor, spPos.z);
|
||||
if (abs(pos.x) < 1.0-0.5/2048. && abs(pos.y) < 1.0-0.5/2048){
|
||||
pos = pos*vec3(0.5,0.5,0.5/6.0)+0.5;
|
||||
sh = shadow2D( shadow, pos).x;
|
||||
// sh = shadow2D( shadow, pos).x;
|
||||
|
||||
#ifdef TRANSLUCENT_COLORED_SHADOWS
|
||||
sh = vec3(shadow2D(shadowtex0, pos).x);
|
||||
|
||||
if(shadow2D(shadowtex1, pos).x > pos.z && sh.x < 1.0){
|
||||
vec4 translucentShadow = texture2D(shadowcolor0, pos.xy);
|
||||
if(translucentShadow.a < 0.9) sh = normalize(translucentShadow.rgb+0.0001);
|
||||
}
|
||||
#else
|
||||
sh = vec3(shadow2D(shadow, pos).x);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef VL_CLOUDS_SHADOWS
|
||||
@ -341,7 +242,7 @@ vec4 waterVolumetrics_test( vec3 rayStart, vec3 rayEnd, float estEndDepth, float
|
||||
vec3 sunMul = exp(-estSunDepth * d * waterCoefs * 1.1);
|
||||
vec3 ambientMul = exp(-estEndDepth * d * waterCoefs );
|
||||
|
||||
vec3 Directlight = (lightSource * phase * sunMul) * sh;
|
||||
vec3 Directlight = ((lightSource * sh) * phase * sunMul) ;
|
||||
vec3 Indirectlight = max(ambient * ambientMul, vec3(0.01,0.2,0.4) * ambientMul * 0.1) ;
|
||||
|
||||
vec3 light = (Indirectlight + Directlight) * scatterCoef;
|
||||
|
Reference in New Issue
Block a user