surprise commit

new stuff

reworked clouds, general lighting, end and nether shaders still WIP

lighting is more balanced in general.
This commit is contained in:
Xonk
2023-04-16 16:18:26 -04:00
parent 7fc3d17c05
commit 2ee6634935
223 changed files with 8807 additions and 16872 deletions

View File

@ -2,15 +2,21 @@
varying vec4 lmtexcoord;
varying vec4 color;
flat varying vec4 lightCol; //main light source color (rgb),used light source(1=sun,-1=moon)
flat varying vec3 avgAmbient;
uniform vec3 sunVec;
flat varying vec3 WsunVec;
uniform sampler2D texture;
uniform sampler2DShadow shadow;
uniform sampler2D gaux1;
uniform sampler2D noisetex;
uniform vec3 sunVec;
flat varying vec3 WsunVec;
uniform float frameTimeCounter;
uniform ivec2 eyeBrightnessSmooth;
uniform float far;
uniform float near;
uniform vec2 texelSize;
uniform float rainStrength;
uniform mat4 gbufferProjectionInverse;
@ -19,12 +25,16 @@ uniform mat4 gbufferModelView;
uniform mat4 shadowModelView;
uniform mat4 shadowProjection;
uniform vec3 cameraPosition;
#include "lib/settings.glsl"
#include "lib/Shadow_Params.glsl"
#include "/lib/res_params.glsl"
#include "lib/sky_gradient.glsl"
#include "lib/volumetricClouds.glsl"
#include "lib/diffuse_lighting.glsl"
//faster and actually more precise than pow 2.2
vec3 toLinear(vec3 sRGB){
return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878);
@ -72,23 +82,11 @@ float shadow2D_bicubic(sampler2DShadow tex, vec3 sc)
g1(fuv.y) * (g0x * shadow2D(tex, vec3(p2,sc.z)).x +
g1x * shadow2D(tex, vec3(p3,sc.z)).x);
}
float luma(vec3 color) {
return dot(color,vec3(0.299, 0.587, 0.114));
}
vec3 normVec (vec3 vec){
return vec*inversesqrt(dot(vec,vec));
}
float GetCloudShadow(vec3 eyePlayerPos){
vec3 worldPos = (eyePlayerPos + cameraPosition) - Cloud_Height;
vec3 cloudPos = worldPos*Cloud_Size + WsunVec/abs(WsunVec.y) * ((3250 - 3250*0.35) - worldPos.y*Cloud_Size) ;
float shadow = getCloudDensity(cloudPos, 1);
// float shadow = (getCloudDensity(cloudPos, 1) + HighAltitudeClouds(cloudPos)) / 2.0;
shadow = clamp(exp(-shadow*15),0.0,1.0);
return shadow ;
}
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
@ -104,50 +102,43 @@ void main() {
#endif
#ifndef WEATHER
gl_FragData[1].a = 0.0; // for bloomy rain
gl_FragData[0] = TEXTURE;
vec2 tempOffset = offsets[framemod8];
float avgBlockLum = luma(texture2DLod(texture, lmtexcoord.xy,128).rgb*color.rgb);
gl_FragData[0].rgb = clamp((gl_FragData[0].rgb)*pow(avgBlockLum,-0.33)*0.85,0.0,1.0);
vec3 albedo = toLinear(gl_FragData[0].rgb);
vec3 Albedo = toLinear(gl_FragData[0].rgb);
vec2 tempOffset = offsets[framemod8];
vec3 fragpos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0));
vec3 p3 = mat3(gbufferModelViewInverse) * fragpos;
vec3 np3 = normVec(p3);
vec3 DirectLightCol = texelFetch2D(gaux1,ivec2(6,37),0).rgb / 127.0;
DirectLightCol *= GetCloudShadow(p3);
vec3 AmbientLight = texture2D(gaux1,(lmtexcoord.zw*15.+0.5)*texelSize).rgb * 8.0/150.0/3.0;
float Shadows = 0.0;
vec3 p3_shadow = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz;
vec3 projectedShadowPosition = mat3(shadowModelView) * p3_shadow + shadowModelView[3].xyz;
projectedShadowPosition = diagonal3(shadowProjection) * projectedShadowPosition + shadowProjection[3].xyz;
//compute shadows only if not backface
float diffuseSun = 0.712;
if (diffuseSun > 0.001) {
vec3 p3 = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz;
vec3 projectedShadowPosition = mat3(shadowModelView) * p3 + shadowModelView[3].xyz;
projectedShadowPosition = diagonal3(shadowProjection) * projectedShadowPosition + shadowProjection[3].xyz;
//apply distortion
float distortFactor = calcDistort(projectedShadowPosition.xy);
projectedShadowPosition.xy *= distortFactor;
//do shadows only if on shadow map
if (abs(projectedShadowPosition.x) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.y) < 1.0-1.5/shadowMapResolution){
//apply distortion
float distortFactor = calcDistort(projectedShadowPosition.xy);
projectedShadowPosition.xy *= distortFactor;
//do shadows only if on shadow map
if (abs(projectedShadowPosition.x) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.y) < 1.0-1.5/shadowMapResolution){
float diffthresh = 0.0002;
projectedShadowPosition = projectedShadowPosition * vec3(0.5,0.5,0.5/6.0) + vec3(0.5,0.5,0.5);
float diffthresh = 0.0002;
projectedShadowPosition = projectedShadowPosition * vec3(0.5,0.5,0.5/6.0) + vec3(0.5,0.5,0.5);
float shading = shadow2D_bicubic(shadow,vec3(projectedShadowPosition + vec3(0.0,0.0,-diffthresh*1.2)));
DirectLightCol *= shading;
}
Shadows += shadow2D_bicubic(shadow,vec3(projectedShadowPosition + vec3(0.0,0.0,-diffthresh*1.2)));
}
#ifdef CLOUDS_SHADOWS
Shadows *= GetCloudShadow(p3);
#endif
float phase = phaseg(clamp(dot(np3, WsunVec),0.0,1.0), 0.7) + 0.05 ;
float lightleakfix = clamp(eyeBrightnessSmooth.y/240.0,0.0,1.0);
vec3 DirectLight = DirectLightCol * phase * lightleakfix;
gl_FragData[0].rgb = (AmbientLight + DirectLight) * albedo;
float phase = phaseg(clamp(dot(np3, WsunVec),0.0,1.0), 0.7) + 1.0 ;
vec3 Direct_lighting = DoDirectLighting(lightCol.rgb/80., Shadows, 1.0, 0.0) * phase * lightleakfix;
vec3 Indirect_lighting = DoAmbientLighting(avgAmbient, vec3(TORCH_R,TORCH_G,TORCH_B), lmtexcoord.zw, 5.0);
gl_FragData[0].rgb = (Direct_lighting + Indirect_lighting) * Albedo;
#endif
}