FIX block breaking effect on iris. FIX glowing water in some scenarios,. FIX clouds blipping at the end of a day. IMPROVE hand lighting (better specular and diffuse)

This commit is contained in:
Xonk 2024-03-30 23:20:34 -04:00
parent 1637a994ec
commit 92e766e853
19 changed files with 205 additions and 82 deletions

View File

@ -89,13 +89,28 @@ float phaseg(float x, float g){
return (gg * -0.25 + 0.25) * pow(-2.0 * (g * x) + (gg + 1.0), -1.5) / 3.14;
}
//encoding by jodie
float encodeVec2(vec2 a){
const vec2 constant1 = vec2( 1., 256.) / 65535.;
vec2 temp = floor( a * 255. );
return temp.x*constant1.x+temp.y*constant1.y;
}
float encodeVec2(float x,float y){
return encodeVec2(vec2(x,y));
}
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
/* DRAWBUFFERS:29 */
#ifdef DAMAGE_BLOCK_EFFECT
/* RENDERTARGETS:11 */
#else
/* DRAWBUFFERS:29 */
#endif
void main() {
@ -111,6 +126,9 @@ void main() {
vec3 feetPlayerPos_normalized = normalize(feetPlayerPos);
vec4 TEXTURE = texture2D(texture, lmtexcoord.xy)*color;
vec3 Albedo = toLinear(TEXTURE.rgb);
@ -215,6 +233,11 @@ void main() {
#else
gl_FragData[0].rgb = (Indirect_lighting + Direct_lighting) * Albedo;
#endif
#ifdef DAMAGE_BLOCK_EFFECT
gl_FragData[0] = vec4(0.0, encodeVec2(TEXTURE.rg), encodeVec2(vec2(TEXTURE.b,0.0)), TEXTURE.a);
#endif
// distance fade targeting the world border...
if(TEXTURE.a < 0.7 && TEXTURE.a > 0.2) gl_FragData[0] *= clamp(1.0 - length(feetPlayerPos) / 100.0 ,0.0,1.0);

View File

@ -62,7 +62,7 @@ vec4 toClipSpace3(vec3 viewSpacePosition) {
void main() {
lmtexcoord.xy = (gl_MultiTexCoord0).xy;
vec2 lmcoord = gl_MultiTexCoord1.xy / 255.0; // is this even correct? lol'
vec2 lmcoord = gl_MultiTexCoord1.xy / 240.0; // is this even correct? lol'
lmtexcoord.zw = lmcoord;

View File

@ -75,6 +75,7 @@ uniform float rainStrength;
uniform sampler2D noisetex;//depth
uniform sampler2D depthtex0;
uniform vec4 entityColor;
// in vec3 velocity;
@ -289,7 +290,6 @@ varying vec3 pos;
void main() {
bool ifPOM = false;
#ifdef POM
@ -365,7 +365,7 @@ void main() {
float used_POM_DEPTH = 1.0;
if ( viewVector.z < 0.0 && depthmap < 0.9999 && depthmap > 0.00001) {
// float noise = interleaved_gradientNoise_temp();
float noise = blueNoise();
#ifdef Adaptive_Step_length
vec3 interval = (viewVector.xyz /-viewVector.z/MAX_OCCLUSION_POINTS * POM_DEPTH) * clamp(1.0-pow(depthmap,2),0.1,1.0);
used_POM_DEPTH = 1.0;
@ -374,12 +374,12 @@ void main() {
#endif
vec3 coord = vec3(vtexcoord.st , 1.0);
coord += interval * used_POM_DEPTH;
coord += interval * noise * used_POM_DEPTH;
float sumVec = 0.5;
float sumVec = noise;
for (int loopCount = 0; (loopCount < MAX_OCCLUSION_POINTS) && (1.0 - POM_DEPTH + POM_DEPTH * readNormal(coord.st).a ) < coord.p && coord.p >= 0.0; ++loopCount) {
coord = coord + interval * used_POM_DEPTH;
sumVec += 1.0 * used_POM_DEPTH;
sumVec += used_POM_DEPTH;
}
if (coord.t < mincoord) {
@ -408,6 +408,7 @@ void main() {
float textureLOD = bias();
vec4 Albedo = texture2D_POMSwitch(texture, adjustedTexCoord.xy, vec4(dcdx,dcdy), ifPOM, textureLOD) * color;
#if defined HAND
if (Albedo.a < 0.1) discard;
#endif
@ -488,6 +489,7 @@ void main() {
normal = applyBump(tbnMatrix, NormalTex.xyz, mix(1.0,1-Puddle_shape,rainfall) );
// normal = applyBump(tbnMatrix, NormalTex.xyz, 0.0);
#endif
//////////////////////////////// ////////////////////////////////

View File

@ -190,8 +190,9 @@ void main() {
vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz;
pos = position;
/////// ----- COLOR STUFF ----- ///////
color = gl_Color;

View File

@ -312,6 +312,20 @@ uniform float dhFarPlane;
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
float darkSpecularHighlight(vec3 playerPos, vec3 normal, float roughness, float f0){
roughness = max(pow(1.0 - roughness, 2.0),0.002);
float distanceFalloff = clamp( exp(-7.0 * (length(playerPos) / 16.0)) ,0.0,1.0);
float NdotP = clamp(1.0 + dot(normal, normalize(playerPos)),0.0,1.0);
float specularHighlight = exp( -(1.0 / roughness) * NdotP ) * f0;
return specularHighlight * distanceFalloff;
}
uniform vec4 entityColor;
/* RENDERTARGETS:2,7,11,14 */
void main() {
@ -586,7 +600,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
float f0 = SpecularTex.g;
// roughness = 0.1;
// f0 = 1.0;
// f0 = 0.1;
if (iswater > 0.0 && gl_FragData[0].a < 0.9999999){
vec3 Reflections_Final = vec3(0.0);
@ -641,9 +655,12 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
#ifdef OVERWORLD_SHADER
if(isEyeInWater == 1 && iswater > 0.9){
SkyReflection.rgb = exp(-8.0 * vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B)) * clamp(WsunVec.y*lightCol.a,0,1) ;
SkyReflection.rgb = exp(-8.0 * vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B)) * clamp(WsunVec.y*lightCol.a,0,1);
}
// if(iswater > 0.9) SkyReflection.rgb = mix(vec3(CaveFogColor_R, CaveFogColor_G, CaveFogColor_B)*0.1, SkyReflection.rgb*indoors, clamp(pow(eyeBrightnessSmooth.y/240. + lightmap.y,2.0),0.0,1.0));
#endif
float visibilityFactor = clamp(exp2((pow(roughness,3.0) / f0) * -4),0,1);
#ifdef ENTITIES
@ -655,6 +672,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
Reflections_Final += SunReflection * Metals;
// Reflections_Final += vec3(CaveFogColor_R, CaveFogColor_G, CaveFogColor_B)*0.1 * darkSpecularHighlight(feetPlayerPos, viewToWorld(normal), 0.9, 0.1);
gl_FragData[0].rgb = Reflections_Final ;

View File

@ -82,7 +82,7 @@ varying vec4 pos;
void main() {
lmtexcoord.xy = (gl_MultiTexCoord0).xy;
vec2 lmcoord = gl_MultiTexCoord1.xy / 255.0; // is this even correct? lol
vec2 lmcoord = gl_MultiTexCoord1.xy / 240.0; // is this even correct? lol
lmtexcoord.zw = lmcoord;
vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz;

View File

@ -57,7 +57,7 @@ uniform int hideGUI;
uniform sampler2D noisetex; //noise
uniform sampler2D depthtex0;
uniform sampler2D depthtex1;
// uniform sampler2D depthtex2;
uniform sampler2D depthtex2;
// #ifdef DISTANT_HORIZONS
uniform sampler2D dhDepthTex;
@ -132,6 +132,13 @@ void convertHandDepth(inout float depth) {
ndcDepth /= MC_HAND_DEPTH;
depth = ndcDepth * 0.5 + 0.5;
}
float convertHandDepth_2(in float depth, bool hand) {
if(!hand) return depth;
float ndcDepth = depth * 2.0 - 1.0;
ndcDepth /= MC_HAND_DEPTH;
return ndcDepth * 0.5 + 0.5;
}
vec3 toScreenSpace(vec3 p) {
vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw);
@ -228,7 +235,7 @@ vec2 decodeVec2(float a){
vec2 tapLocation(int sampleNumber,int nb, float nbRot,float jitter,float distort)
{
float alpha0 = sampleNumber/nb;
float alpha0 = sampleNumber/nb;
float alpha = (sampleNumber+jitter)/nb;
float angle = jitter*6.28 + alpha * 4.0 * 6.28;
@ -427,9 +434,11 @@ void waterVolumetrics(inout vec3 inColor, vec3 rayStart, vec3 rayEnd, float estE
#endif
vec2 SSRT_Shadows(vec3 viewPos, bool depthCheck, vec3 lightDir, float noise, bool isSSS){
vec2 SSRT_Shadows(vec3 viewPos, bool depthCheck, vec3 lightDir, float noise, bool isSSS, bool hand){
float handSwitch = hand ? 1.0 : 0.0;
float steps = 16.0;
float Shadow = 1.0;
float SSS = 0.0;
@ -439,8 +448,8 @@ vec2 SSRT_Shadows(vec3 viewPos, bool depthCheck, vec3 lightDir, float noise, boo
_near = dhNearPlane;
_far = dhFarPlane;
}
vec3 clipPosition = toClipSpace3_DH(viewPos, depthCheck);
vec3 clipPosition = toClipSpace3_DH(viewPos, depthCheck);
//prevents the ray from going behind the camera
float rayLength = ((viewPos.z + lightDir.z * _far*sqrt(3.)) > -_near) ?
@ -451,7 +460,7 @@ vec2 SSRT_Shadows(vec3 viewPos, bool depthCheck, vec3 lightDir, float noise, boo
float Stepmult = depthCheck ? (isSSS ? 0.5 : 6.0) : (isSSS ? 1.0 : 3.0);
vec3 rayDir = direction * Stepmult * vec3(RENDER_SCALE,1.0);
vec3 rayDir = direction * Stepmult * vec3(RENDER_SCALE,1.0);
vec3 screenPos = clipPosition * vec3(RENDER_SCALE,1.0) + rayDir*noise;
if(isSSS) screenPos -= rayDir*0.9;
@ -460,7 +469,7 @@ vec2 SSRT_Shadows(vec3 viewPos, bool depthCheck, vec3 lightDir, float noise, boo
screenPos += rayDir;
float samplePos = texture2D(depthtex1, screenPos.xy).x;
float samplePos = convertHandDepth_2(texture2D(depthtex1, screenPos.xy).x, hand);
#ifdef DISTANT_HORIZONS
if(depthCheck) samplePos = texture2D(dhDepthTex1, screenPos.xy).x;
@ -470,7 +479,7 @@ vec2 SSRT_Shadows(vec3 viewPos, bool depthCheck, vec3 lightDir, float noise, boo
vec2 linearZ = vec2(linearizeDepthFast(screenPos.z, _near, _far), linearizeDepthFast(samplePos, _near, _far));
float calcthreshold = abs(linearZ.x - linearZ.y) / linearZ.x;
bool depthThreshold1 = calcthreshold < 0.015;
bool depthThreshold1 = calcthreshold < mix(0.015, 0.035, handSwitch);
bool depthThreshold2 = calcthreshold < 0.05;
if (depthThreshold1) Shadow = 0.0;
@ -737,6 +746,23 @@ vec3 ColorBoost(vec3 COLOR, float saturation){
return COLOR + difference*(-luminance + saturation);
}
float darkSpecularHighlight(vec3 playerPos, vec3 normal, float roughness, float f0){
roughness = max(pow(1.0 - roughness, 2.0),0.002);
float distanceFalloff = clamp( exp(-7.0 * (length(playerPos) / 16.0)) ,0.0,1.0);
float NdotP = clamp(1.0 + dot(normal, normalize(playerPos)),0.0,1.0);
float specularHighlight = exp( -(1.0 / roughness) * NdotP ) * f0;
return specularHighlight * distanceFalloff;
}
void main() {
vec3 DEBUG = vec3(1.0);
@ -834,11 +860,14 @@ void main() {
bool entities = abs(dataUnpacked1.w-0.45) < 0.01;
// bool isBoss = abs(dataUnpacked1.w-0.60) < 0.01;
bool isGrass = abs(dataUnpacked1.w-0.60) < 0.01;
bool hand = abs(dataUnpacked1.w-0.75) < 0.01 && z0 < 1.0;
bool hand = abs(dataUnpacked1.w-0.75) < 0.01 && z < 1.0;
// bool blocklights = abs(dataUnpacked1.w-0.8) <0.01;
if(hand) convertHandDepth(z);
if(hand){
convertHandDepth(z);
convertHandDepth(z0);
}
#ifdef DISTANT_HORIZONS
vec3 viewPos = toScreenSpace_DH(texcoord/RENDER_SCALE-TAA_Offset*texelSize*0.5, z, DH_depth1);
@ -997,7 +1026,7 @@ void main() {
vec3 shadowPlayerPos = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz;
// if(!entities) if(!hand)
GriAndEminShadowFix(shadowPlayerPos, viewToWorld(FlatNormals), vanilla_AO, lightmap.y);
if(!hand) GriAndEminShadowFix(shadowPlayerPos, viewToWorld(FlatNormals), vanilla_AO, lightmap.y);
vec3 projectedShadowPosition = mat3(shadowModelView) * shadowPlayerPos + shadowModelView[3].xyz;
projectedShadowPosition = diagonal3(shadowProjection) * projectedShadowPosition + shadowProjection[3].xyz;
@ -1093,7 +1122,7 @@ void main() {
vec3 viewPos0 = toScreenSpace(vec3(texcoord/RENDER_SCALE-TAA_Offset*texelSize*0.5,z0));
#endif
float Vdiff = distance(viewPos, viewPos0)*2.0;
float Vdiff = distance(viewPos, viewPos0)*mix(5.0,2.0,clamp(pow(eyeBrightnessSmooth.y/240. + lightmap.y,2.0) ,0.0,1.0));
float estimatedDepth = Vdiff * abs(feetPlayerPos_normalized.y); //assuming water plane
// make it such that the estimated depth flips to be correct when entering water.
@ -1109,7 +1138,6 @@ void main() {
Absorbtion = mix(exp(-2.0 * totEpsilon * estimatedDepth), exp(-8.0 * totEpsilon), depthfalloff);
DirectLightColor *= Absorbtion;
AmbientLightColor *= Absorbtion;
// apply caustics to the lighting, and make sure they dont look weird
DirectLightColor *= mix(1.0, waterCaustics(feetPlayerPos + cameraPosition, WsunVec)*WATER_CAUSTICS_BRIGHTNESS + 0.25, clamp(estimatedDepth,0,1));
@ -1136,14 +1164,15 @@ void main() {
float sunSSS_density = LabSSS;
#ifndef RENDER_ENTITY_SHADOWS
if(entities) sunSSS_density = 0.0;
#endif
if (!hand){
// if (!hand){
#ifdef SCREENSPACE_CONTACT_SHADOWS
vec2 SS_directLight = SSRT_Shadows(toScreenSpace_DH(texcoord/RENDER_SCALE, z, DH_depth1), isDHrange, normalize(WsunVec*mat3(gbufferModelViewInverse)), interleaved_gradientNoise(), sunSSS_density > 0.0);
vec2 SS_directLight = SSRT_Shadows(toScreenSpace_DH(texcoord/RENDER_SCALE, z, DH_depth1), isDHrange, normalize(WsunVec*mat3(gbufferModelViewInverse)), interleaved_gradientNoise(), sunSSS_density > 0.0, hand);
Shadows = min(Shadows, SS_directLight.r);
ShadowBlockerDepth = mix(SS_directLight.g, ShadowBlockerDepth, shadowMapFalloff);
@ -1156,7 +1185,7 @@ void main() {
Direct_SSS *= mix(LM_shadowMapFallback, 1.0, shadowMapFalloff);
if (isEyeInWater == 0) Direct_SSS *= clamp(pow(eyeBrightnessSmooth.y/240. + lightmap.y,2.0) ,0.0,1.0); // light leak fix
}
// }
#endif
#ifdef CLOUDS_SHADOWS
@ -1217,8 +1246,7 @@ void main() {
// Indirect_lighting += up + down;
Indirect_lighting = vec3(0.1);
Indirect_lighting *= Absorbtion;
#endif
#ifdef END_SHADER
@ -1226,11 +1254,11 @@ void main() {
Indirect_lighting *= clamp(1.5 + dot(normal, feetPlayerPos_normalized)*0.5,0,2);
Indirect_lighting *= Absorbtion;
#endif
Indirect_lighting = DoAmbientLightColor(Indirect_lighting, MinimumLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.xy);
Indirect_lighting *= Absorbtion;
#ifdef OVERWORLD_SHADER
Indirect_lighting += LightningFlashLighting;
#endif
@ -1326,12 +1354,16 @@ void main() {
vec2 specularNoises = vec2(noise, R2_dither());
DoSpecularReflections(gl_FragData[0].rgb, viewPos, feetPlayerPos_normalized, WsunVec, specularNoises, normal, SpecularTex.r, SpecularTex.g, albedo, DirectLightColor*Shadows*NdotL, lightmap.y, hand);
#endif
// gl_FragData[0].rgb += vec3(CaveFogColor_R, CaveFogColor_G, CaveFogColor_B)*0.1 * darkSpecularHighlight(feetPlayerPos, normal, SpecularTex.r, SpecularTex.g);
Emission(gl_FragData[0].rgb, albedo, SpecularTex.a);
if(lightningBolt) gl_FragData[0].rgb = vec3(77.0, 153.0, 255.0);
}
if(translucent_alpha > 0.0 ){
#ifdef DISTANT_HORIZONS
@ -1371,6 +1403,10 @@ void main() {
gl_FragData[0].rgb = FilteredDebug;
#endif
#ifdef CLOUDS_INFRONT_OF_WORLD
gl_FragData[1] = texture2D(colortex2, texcoord);
if(heightRelativeToClouds > 0.0 && !hand){

View File

@ -269,7 +269,7 @@ void main() {
vec4 TranslucentShader = texture2D(colortex2, texcoord);
////// --------------- UNPACK MISC --------------- //////
float trpData = texture2D(colortex7,texcoord).a;
float trpData = texture2D(colortex7, texcoord).a;
////// --------------- MASKS/BOOLEANS --------------- //////
bool iswater = trpData > 0.99;
@ -325,12 +325,17 @@ void main() {
color.rgb = mix(color.rgb, borderFogColor, fog);
#endif
if (albedo.a > 0.0 || TranslucentShader.a > 0.0){
if (TranslucentShader.a > 0.0){
#ifdef Glass_Tint
if(!iswater) color *= normalize(albedo.rgb+0.0001)*0.9+0.1;
#ifdef Glass_Tint
if(!iswater && TranslucentShader.a > 0.0) color *= normalize(albedo.rgb+0.0001)*0.9+0.1;
#endif
// block breaking effect.
if(!iswater && TranslucentShader.a <= 0.0) color *= albedo.rgb;
color = color*(1.0-TranslucentShader.a) + TranslucentShader.rgb;
#ifdef BorderFog
@ -438,6 +443,7 @@ void main() {
}
#endif
// color.rgb = vec3(1) * sqrt(texture2D(colortex12,texcoord).a/65000.0);
gl_FragData[0].r = bloomyFogMult; // pass fog alpha so bloom can do bloomy fog
gl_FragData[1].rgb = clamp(color.rgb, 0.0,68000.0);

View File

@ -53,12 +53,14 @@ const bool colortex15Clear = false;
varying vec2 texcoord;
flat varying float tempOffsets;
uniform sampler2D colortex0;
uniform sampler2D colortex1;
uniform sampler2D colortex3;
uniform sampler2D colortex5;
uniform sampler2D colortex6;
uniform sampler2D colortex10;
uniform sampler2D colortex12;
uniform sampler2D depthtex0;
uniform sampler2D depthtex1;
uniform vec2 texelSize;
uniform float frameTimeCounter;
@ -170,23 +172,36 @@ vec3 tonemap(vec3 col){
vec3 invTonemap(vec3 col){
return col/(1-luma(col));
}
void convertHandDepth(inout float depth) {
float ndcDepth = depth * 2.0 - 1.0;
ndcDepth /= MC_HAND_DEPTH;
depth = ndcDepth * 0.5 + 0.5;
}
vec3 closestToCamera5taps(vec2 texcoord, sampler2D depth)
vec3 closestToCamera5taps(vec2 texcoord, sampler2D depth, bool hand)
{
vec2 du = vec2(texelSize.x*2., 0.0);
vec2 dv = vec2(0.0, texelSize.y*2.);
vec3 dtl = vec3(texcoord,0.) + vec3(-texelSize, texture2D(depth, texcoord - dv - du).x);
vec3 dtr = vec3(texcoord,0.) + vec3( texelSize.x, -texelSize.y, texture2D(depth, texcoord - dv + du).x);
vec3 dmc = vec3(texcoord,0.) + vec3( 0.0, 0.0, texture2D(depth, texcoord).x);
vec3 dbl = vec3(texcoord,0.) + vec3(-texelSize.x, texelSize.y, texture2D(depth, texcoord + dv - du).x);
vec3 dbr = vec3(texcoord,0.) + vec3( texelSize.x, texelSize.y, texture2D(depth, texcoord + dv + du).x);
vec3 dtl = vec3(texcoord,0.) + vec3(-texelSize, texture2D(depth, texcoord - dv - du).x);
vec3 dtr = vec3(texcoord,0.) + vec3( texelSize.x, -texelSize.y, texture2D(depth, texcoord - dv + du).x);
vec3 dmc = vec3(texcoord,0.) + vec3( 0.0, 0.0, texture2D(depth, texcoord).x);
vec3 dbl = vec3(texcoord,0.) + vec3(-texelSize.x, texelSize.y, texture2D(depth, texcoord + dv - du).x);
vec3 dbr = vec3(texcoord,0.) + vec3( texelSize.x, texelSize.y, texture2D(depth, texcoord + dv + du).x);
if(hand){
convertHandDepth(dtl.z);
convertHandDepth(dtr.z);
convertHandDepth(dmc.z);
convertHandDepth(dbl.z);
convertHandDepth(dbr.z);
}
vec3 dmin = dmc;
dmin = dmin.z > dtr.z? dtr : dmin;
dmin = dmin.z > dtl.z? dtl : dmin;
dmin = dmin.z > dbl.z? dbl : dmin;
dmin = dmin.z > dbr.z? dbr : dmin;
dmin = dmin.z > dtr.z ? dtr : dmin;
dmin = dmin.z > dtl.z ? dtl : dmin;
dmin = dmin.z > dbl.z ? dbl : dmin;
dmin = dmin.z > dbr.z ? dbr : dmin;
#ifdef TAA_UPSCALING
dmin.xy = dmin.xy/RENDER_SCALE;
@ -195,9 +210,7 @@ vec3 closestToCamera5taps(vec2 texcoord, sampler2D depth)
return dmin;
}
vec3 closestToCamera5taps_DH(vec2 texcoord, sampler2D depth, sampler2D dhDepth, bool depthCheck)
vec3 closestToCamera5taps_DH(vec2 texcoord, sampler2D depth, sampler2D dhDepth, bool depthCheck, bool hand)
{
vec2 du = vec2(texelSize.x*2., 0.0);
vec2 dv = vec2(0.0, texelSize.y*2.);
@ -214,11 +227,19 @@ vec3 closestToCamera5taps_DH(vec2 texcoord, sampler2D depth, sampler2D dhDepth,
dbl += vec3(-texelSize.x, texelSize.y, depthCheck ? texture2D(dhDepth, texcoord + dv - du).x : texture2D(depth, texcoord + dv - du).x);
dbr += vec3( texelSize.x, texelSize.y, depthCheck ? texture2D(dhDepth, texcoord + dv + du).x : texture2D(depth, texcoord + dv + du).x);
if(hand){
convertHandDepth(dtl.z);
convertHandDepth(dtr.z);
convertHandDepth(dmc.z);
convertHandDepth(dbl.z);
convertHandDepth(dbr.z);
}
vec3 dmin = dmc;
dmin = dmin.z > dtr.z? dtr : dmin;
dmin = dmin.z > dtl.z? dtl : dmin;
dmin = dmin.z > dbl.z? dbl : dmin;
dmin = dmin.z > dbr.z? dbr : dmin;
dmin = dmin.z > dtr.z ? dtr : dmin;
dmin = dmin.z > dtl.z ? dtl : dmin;
dmin = dmin.z > dbl.z ? dbl : dmin;
dmin = dmin.z > dbr.z ? dbr : dmin;
#ifdef TAA_UPSCALING
dmin.xy = dmin.xy/RENDER_SCALE;
@ -298,7 +319,7 @@ const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec4 TAA_hq(){
vec4 TAA_hq(bool hand){
#ifdef TAA_UPSCALING
vec2 adjTC = clamp(texcoord*RENDER_SCALE, vec2(0.0), RENDER_SCALE - texelSize*2.0);
@ -311,9 +332,9 @@ vec4 TAA_hq(){
//use velocity from the nearest texel from camera in a 3x3 box in order to improve edge quality in motion
#ifdef CLOSEST_VELOCITY
#ifdef DISTANT_HORIZONS
vec3 closestToCamera = closestToCamera5taps_DH(adjTC, depthtex0, dhDepthTex, depthCheck);
vec3 closestToCamera = closestToCamera5taps_DH(adjTC, depthtex0, dhDepthTex, depthCheck, hand);
#else
vec3 closestToCamera = closestToCamera5taps(adjTC,depthtex0);
vec3 closestToCamera = closestToCamera5taps(adjTC,depthtex0, hand);
#endif
#endif
@ -368,8 +389,11 @@ vec4 TAA_hq(){
//Increases blending factor when far from AABB and in motion, reduces ghosting
float isclamped = distance(albedoPrev,finalcAcc)/luma(albedoPrev) * 0.5;
float movementRejection = (0.12+isclamped)*clamp(length(velocity/texelSize),0.0,1.0);
if(hand) movementRejection *= 5.0;
//Blend current pixel with clamped history, apply fast tonemap beforehand to reduce flickering
vec4 supersampled = vec4(invTonemap(mix(tonemap(finalcAcc), tonemap(albedoCurrent0), clamp(BLEND_FACTOR + movementRejection, 0.0,1.0))), 1.0);
@ -386,13 +410,26 @@ vec4 TAA_hq(){
#endif
}
vec2 decodeVec2(float a){
const vec2 constant1 = 65535. / vec2( 256., 65536.);
const float constant2 = 256. / 255.;
return fract( a * constant1 ) * constant2 ;
}
void main() {
/* DRAWBUFFERS:5 */
gl_FragData[0].a = 1.0;
#ifdef TAA
vec4 color = TAA_hq();
float dataUnpacked = decodeVec2(texture2D(colortex1,texcoord).w).y;
bool hand = abs(dataUnpacked-0.75) < 0.01 && texture2D(depthtex1,texcoord).x < 1.0;
vec4 color = TAA_hq(hand);
#ifdef SCREENSHOT_MODE
gl_FragData[0] = clamp(color, 0.0, 65000.0);

View File

@ -197,7 +197,8 @@ vec4 waterVolumetrics_test( vec3 rayStart, vec3 rayEnd, float estEndDepth, float
#endif
vec3 absorbance = vec3(1.0);
vec3 vL = vec3(0.0);
ambient = max(ambient* (normalize(wpos).y*0.3+0.7),0.0);
float expFactor = 11.0;
for (int i=0;i<spCount;i++) {
@ -243,7 +244,7 @@ vec4 waterVolumetrics_test( vec3 rayStart, vec3 rayEnd, float estEndDepth, float
vec3 ambientMul = exp(-estEndDepth * d * waterCoefs );
vec3 Directlight = ((lightSource * sh) * phase * sunMul) ;
vec3 Indirectlight = max(ambient * ambientMul, vec3(0.01,0.2,0.4) * ambientMul * 0.1) ;
vec3 Indirectlight = max(ambient * ambientMul, vec3(0.01,0.2,0.4) * ambientMul * 0.05) ;
vec3 light = (Indirectlight + Directlight) * scatterCoef;
@ -310,14 +311,14 @@ void main() {
#ifdef OVERWORLD_SHADER
float lightmap = texture2D(colortex14,tc).a;
if(z >= 1.0 ) lightmap = 1.0;
if(z >= 1.0) lightmap = 1.0;
#else
float lightmap = 1.0;
#endif
float Vdiff = distance(viewPos1, viewPos0);
float Vdiff = distance(viewPos1, viewPos0) * 2.0;
float VdotU = playerPos.y;
float estimatedDepth = Vdiff * abs(VdotU) ; //assuming water plane
float estimatedSunDepth = estimatedDepth/abs(WsunVec.y); //assuming water plane
float estimatedSunDepth = estimatedDepth / abs(WsunVec.y); //assuming water plane
vec4 VolumetricFog2 = vec4(0,0,0,1);
#ifdef OVERWORLD_SHADER
@ -325,7 +326,7 @@ void main() {
#endif
vec4 underwaterVlFog = vec4(0,0,0,1);
if(iswater)underwaterVlFog = waterVolumetrics_test(viewPos0, viewPos1, estimatedDepth, estimatedSunDepth, Vdiff, noise_1, totEpsilon, scatterCoef, indirectLightColor_dynamic * max(lightmap,0.0), directLightColor, dot(normalize(viewPos1), normalize(sunVec*lightCol.a)) );
if(iswater) underwaterVlFog = waterVolumetrics_test(viewPos0, viewPos1, estimatedDepth, estimatedSunDepth, Vdiff, noise_1, totEpsilon, scatterCoef, indirectLightColor_dynamic * max(lightmap,0.0), directLightColor, dot(normalize(viewPos1), normalize(sunVec*lightCol.a)) );
vec4 fogFinal = vec4(underwaterVlFog.rgb * VolumetricFog2.a + VolumetricFog2.rgb, VolumetricFog2.a * underwaterVlFog.a);

View File

@ -86,19 +86,17 @@ vec3 rayTraceSpeculars(vec3 dir, vec3 position, float dither, float quality, boo
float dist = 1.0 + clamp(position.z*position.z/50.0,0.0,2.0); // shrink sample size as distance increases
for (int i = 0; i <= int(quality); i++) {
vec2 scaleUV = hand ? spos.xy*texelSize : spos.xy/texelSize/4.0; // fix for ssr on hand
float sp = sqrt(texelFetch2D(colortex4,ivec2(scaleUV),0).a/65000.0);
sp = invLinZ(sp);
float sp = invLinZ(sqrt(texelFetch2D(colortex4,ivec2(spos.xy/texelSize/4.0),0).a/65000.0));
if(sp <= max(maxZ,minZ) && sp >= min(maxZ,minZ) ) return vec3(spos.xy/RENDER_SCALE,sp);
spos += stepv;
//small bias
float biasamount = (0.0002 + 0.0015*pow(depthcancleoffset,5) ) / dist;
// float biasamount = 0.0002 / dist;
if(hand) biasamount = 0.01;
if(hand) biasamount = 0.00035;
minZ = maxZ-biasamount / ld(spos.z);
maxZ += stepv.z;
@ -193,7 +191,7 @@ void DoSpecularReflections(
Roughness = 1.0 - Roughness; Roughness *= Roughness;
F0 = F0 == 0.0 ? 0.02 : F0;
// Roughness = 0.1;
// Roughness = 0.0;
// F0 = 0.9;
mat3 Basis = CoordBase(Normal);
@ -201,7 +199,7 @@ void DoSpecularReflections(
#ifdef Rough_reflections
vec3 SamplePoints = SampleVNDFGGX(ViewDir, vec2(Roughness), Noise.x);
if(Hand) SamplePoints = normalize(vec3(0.0,0.0,1.0));
if(Hand) SamplePoints = vec3(0.0,0.0,1.0);
#else
vec3 SamplePoints = vec3(0.0,0.0,1.0);
#endif
@ -214,7 +212,7 @@ void DoSpecularReflections(
float RayContribution = lerp(F0, 1.0, Fresnel); // ensure that when the angle is 0 that the correct F0 is used.
#ifdef Rough_reflections
if(Hand) RayContribution = RayContribution * pow(1.0-Roughness,3.0);
if(Hand) RayContribution = RayContribution * pow(1.0-Roughness,F0 > 229.5/255.0 ? 1.0 : 3.0);
#else
RayContribution = RayContribution * pow(1.0-Roughness,3.0);
#endif

View File

@ -52,7 +52,9 @@ float LAYER2_DENSITY = dailyWeatherParams1.z;
float rainCloudwetness = rainStrength;
// float cloud_movement = frameTimeCounter * Cloud_Speed ;
// float cloud_movement = abs((12000 - worldTime) * Cloud_Speed ) * 0.05;
float cloud_movement = (worldTime / 24.0) * Cloud_Speed;
// float cloud_movement = (worldTime / 24.0) * Cloud_Speed;
uniform int worldDay;
float cloud_movement = (worldTime + worldDay*24000.0) / 24.0 * Cloud_Speed;
//3D noise from 2d texture
float densityAtPos(in vec3 pos){

View File

@ -62,7 +62,6 @@ program.composite5.enabled = TAA_UPSCALING
# terrible blending for shadows on purpose
blend.shadow = SRC_COLOR ZERO ONE ZERO
blend.gbuffers_water = SRC_ALPHA ONE_MINUS_SRC_ALPHA ONE_MINUS_DST_ALPHA ONE
blend.gbuffers_hand_water = SRC_ALPHA ONE_MINUS_SRC_ALPHA ONE_MINUS_DST_ALPHA ONE
blend.gbuffers_textured = SRC_ALPHA ONE_MINUS_SRC_ALPHA ONE_MINUS_DST_ALPHA ONE
@ -72,7 +71,7 @@ blend.gbuffers_basic = SRC_ALPHA ONE_MINUS_SRC_ALPHA ONE_MINUS_DST_ALPHA ONE
blend.gbuffers_weather = SRC_ALPHA ONE_MINUS_SRC_ALPHA ONE_MINUS_DST_ALPHA ONE
blend.gbuffers_armor_glint = ONE ONE ONE ZERO
blend.gbuffers_skytextured = ONE ONE ONE ZERO
blend.gbuffers_damagedblock = ONE ONE ONE ZERO
blend.gbuffers_damagedblock = SRC_ALPHA ONE_MINUS_SRC_ALPHA ONE_MINUS_DST_ALPHA ONE
# Disable blending
blend.gbuffers_terrain = off

View File

@ -3,4 +3,4 @@
#define DAMAGE_BLOCK_EFFECT
#define NETHER_SHADER
#include "/dimensions/all_translucent.fsh"
#include "/dimensions/all_particles.fsh"

View File

@ -3,4 +3,4 @@
#define DAMAGE_BLOCK_EFFECT
#define NETHER_SHADER
#include "/dimensions/all_translucent.vsh"
#include "/dimensions/all_particles.vsh"

View File

@ -3,4 +3,4 @@
#define OVERWORLD_SHADER
#define DAMAGE_BLOCK_EFFECT
#include "/dimensions/all_translucent.fsh"
#include "/dimensions/all_particles.fsh"

View File

@ -3,4 +3,4 @@
#define OVERWORLD_SHADER
#define DAMAGE_BLOCK_EFFECT
#include "/dimensions/all_translucent.vsh"
#include "/dimensions/all_particles.vsh"

View File

@ -3,4 +3,4 @@
#define END_SHADER
#define DAMAGE_BLOCK_EFFECT
#include "/dimensions/all_translucent.fsh"
#include "/dimensions/all_particles.fsh"

View File

@ -3,4 +3,4 @@
#define END_SHADER
#define DAMAGE_BLOCK_EFFECT
#include "/dimensions/all_translucent.vsh"
#include "/dimensions/all_particles.fsh"