Improve SSR with Voxy/DH, add option to use full resolution depth for SSR, merge xonk's latest commits

This commit is contained in:
Merlin1809
2025-11-23 18:27:23 +01:00
parent 745ddbe207
commit ae42f40033
36 changed files with 233 additions and 181 deletions
+2
View File
@@ -222,6 +222,8 @@ void main() {
gl_FragData[0] = vec4(encodeVec2(Albedo.x,data1.x), encodeVec2(Albedo.y,data1.y), encodeVec2(Albedo.z,data1.z), encodeVec2(data1.w, materials));
gl_FragData[1].a = 0.0;
gl_FragData[2] = vec4(0.0,0.0,0.0,0.0);
#if EMISSIVE_TYPE == 0
gl_FragData[2].a = 0.0;
+7 -3
View File
@@ -109,7 +109,7 @@ float ld(float dist) {
// }
float DH_ld(float dist) {
return (2.0 * near) / (dhVoxyFarPlane + near - dist * (dhVoxyFarPlane - near));
return (2.0 * dhVoxyNearPlane) / (dhVoxyFarPlane + dhVoxyNearPlane - dist * (dhVoxyFarPlane - dhVoxyNearPlane));
}
float DH_inv_ld (float lindepth){
return -((2.0*dhVoxyNearPlane/lindepth)-dhVoxyFarPlane-dhVoxyNearPlane)/(dhVoxyFarPlane-dhVoxyNearPlane);
@@ -200,8 +200,12 @@ vec3 rayTrace(vec3 dir, vec3 position, float dither, float fresnel) {
if(spos.x < 0 || spos.x > 1 || spos.y < 0 || spos.y > 1) return vec3(1.1);
#endif
float sampleDepth = sqrt(texelFetch2D(colortex12, ivec2(spos.xy / (texelSize * 4.0)), 0).a / 65000.0);
float sp = invLdFast(sampleDepth*dhVoxyFarPlane);
#ifdef QUARTER_RES_SSR
float sampleDepth = sqrt(texelFetch2D(colortex12, ivec2(spos.xy / (texelSize * 4.0)), 0).a / 65000.0);
float sp = DH_inv_ld(sampleDepth);
#else
float sp = texelFetch2D(dhDepthTex, ivec2(spos.xy /texelSize), 0).r;
#endif
if (sp < max(minZ, maxZ) && sp > min(minZ, maxZ)) {
return vec3(spos.xy / RENDER_SCALE, sp);
+3 -4
View File
@@ -1,5 +1,5 @@
#ifdef IS_LPV_ENABLED
#extension GL_EXT_shader_image_load_store: enable
#extension GL_ARB_shader_image_load_store: enable
#extension GL_ARB_shading_language_packing: enable
#endif
@@ -10,7 +10,6 @@
#if defined CUMULONIMBUS_LIGHTNING && CUMULONIMBUS > 0 && defined OVERWORLD_SHADER && defined COLORWHEEL
#extension GL_NV_gpu_shader5 : enable
#extension GL_ARB_shader_image_load_store : enable
#extension GL_EXT_shader_image_load_store : enable
#endif
#include "/lib/settings.glsl"
@@ -244,8 +243,8 @@ float ComputeShadowMap(inout vec3 directLightColor, vec3 playerPos, float maxDis
varying vec4 vtexcoordam; // .st for add, .pq for mul
varying vec2 vtexcoord;
vec2 dcdx = dFdx(vtexcoord.st*vtexcoordam.pq)*exp2(Texture_MipMap_Bias);
vec2 dcdy = dFdy(vtexcoord.st*vtexcoordam.pq)*exp2(Texture_MipMap_Bias);
vec2 dcdx = dFdx(vtexcoord.st*vtexcoordam.pq);
vec2 dcdy = dFdy(vtexcoord.st*vtexcoordam.pq);
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz)
+9 -4
View File
@@ -54,8 +54,8 @@ uniform vec2 texelSize;
uniform int framemod8;
#if defined POM && (defined WORLD && !defined ENTITIES && !defined HAND || defined COLORWHEEL)
vec2 dcdx = dFdx(data_in.texcoord.st*data_in.texcoordam.pq)*exp2(Texture_MipMap_Bias);
vec2 dcdy = dFdy(data_in.texcoord.st*data_in.texcoordam.pq)*exp2(Texture_MipMap_Bias);
vec2 dcdx = dFdx(data_in.texcoord.st*data_in.texcoordam.pq);
vec2 dcdy = dFdy(data_in.texcoord.st*data_in.texcoordam.pq);
#else
const vec2 dcdx = vec2(0.0);
const vec2 dcdy = vec2(0.0);
@@ -283,8 +283,12 @@ float ld(float dist) {
// }
float bias(){
// return (Texture_MipMap_Bias + (blueNoise-0.5)*0.5) - (1.0-RENDER_SCALE.x) * 2.0;
return Texture_MipMap_Bias - (1.0-RENDER_SCALE.x) * 2.0;
// bias mipmapping as window resolution and / or render scale changes.
#ifdef TAA_UPSCALING
return (1.0 - texelSize.x * 2560.0) + (0.0 - (1.0-RENDER_SCALE.x) * 2.0);
#else
return 1.0 - texelSize.x * 2560.0;
#endif
}
vec4 texture2D_POMSwitch(
sampler2D sampler,
@@ -774,6 +778,7 @@ void main() {
// SpecularTex.r = max(SpecularTex.r, rainfall);
// SpecularTex.g = max(SpecularTex.g, max(Puddle_shape*0.02,0.02));
gl_FragData[1] = vec4(0.0,0.0,0.0,0.0);
gl_FragData[1].rg = SpecularTex.rg;
#if EMISSIVE_TYPE == 2
+15 -6
View File
@@ -1,12 +1,11 @@
#ifdef IS_LPV_ENABLED
#extension GL_EXT_shader_image_load_store: enable
#extension GL_ARB_shader_image_load_store: enable
#extension GL_ARB_shading_language_packing: enable
#endif
#if defined CUMULONIMBUS_LIGHTNING && CUMULONIMBUS > 0 && defined OVERWORLD_SHADER && defined COLORWHEEL
#extension GL_NV_gpu_shader5 : enable
#extension GL_ARB_shader_image_load_store : enable
#extension GL_EXT_shader_image_load_store : enable
#endif
#include "/lib/settings.glsl"
@@ -466,6 +465,15 @@ void Emission(
if( Emission < 254.5/255.0) Lighting = mix(Lighting, Albedo * 5.0 * Emissive_Brightness, pow(Emission, Emissive_Curve));
}
float bias(){
// bias mipmapping as window resolution and / or render scale changes.
#ifdef TAA_UPSCALING
return (1.0 - texelSize.x * 2560.0) + (0.0 - (1.0-RENDER_SCALE.x) * 2.0);
#else
return 1.0 - texelSize.x * 2560.0;
#endif
}
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
@@ -479,6 +487,7 @@ void main() {
if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) {
vec3 FragCoord = gl_FragCoord.xyz;
float mipmapBias = bias();
#ifdef TAA
vec2 tempOffset = offsets[framemod8];
@@ -521,9 +530,9 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
vec2 lightmap = lmtexcoord.zw;
#ifndef COLORWHEEL
gl_FragData[0] = texture2D(gtexture, lmtexcoord.xy, Texture_MipMap_Bias) * color;
gl_FragData[0] = texture2D(gtexture, lmtexcoord.xy, mipmapBias) * color;
#else
vec4 _color = texture2D(gtexture, lmtexcoord.xy, Texture_MipMap_Bias);
vec4 _color = texture2D(gtexture, lmtexcoord.xy, mipmapBias);
float ao;
vec4 overlayColor;
@@ -628,7 +637,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
tangent.z, tangent2.z, normal.z);
vec3 NormalTex = vec3(texture2D(normals, lmtexcoord.xy, Texture_MipMap_Bias).xy,0.0);
vec3 NormalTex = vec3(texture2D(normals, lmtexcoord.xy, mipmapBias).xy,0.0);
NormalTex.xy = NormalTex.xy*2.0-1.0;
NormalTex.z = clamp(sqrt(1.0 - dot(NormalTex.xy, NormalTex.xy)),0.0,1.0);
@@ -762,7 +771,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
////////////////////////////////////////////////////////////////////////////////
vec3 SpecularTex = texture2D(specular, lmtexcoord.xy, Texture_MipMap_Bias).rga;
vec3 SpecularTex = texture2D(specular, lmtexcoord.xy, mipmapBias).rga;
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////// DIFFUSE LIGHTING //////////////////////////////
////////////////////////////////////////////////////////////////////////////////
+1 -1
View File
@@ -17,7 +17,7 @@ vec3 toLinear(vec3 sRGB){
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
/* DRAWBUFFERS:2 */
/* RENDERTARGETS:2 */
void main() {
+2 -8
View File
@@ -314,11 +314,7 @@ vec2 SSAO(
occlusion += max(0.0, dot(normViewPosDiff, normal) - preAo) * threshHold;
#ifdef Ambient_SSS
#ifdef OLD_INDIRECT_SSS
sss += clamp(-dot(normViewPosDiff, flatnormal),0.0,1.0) * exp(-10*occlusion);
#else
sss += clamp(-dot(normViewPosDiff, flatnormal) - occlusion/n,0.0,1.0) * 0.25 + (normalize(mat3(gbufferModelViewInverse) * -viewPosDiff).y - occlusion/n) * threshHold;
#endif
sss += clamp(-dot(normViewPosDiff, flatnormal) - occlusion/n,0.0,1.0) * 0.25 + (normalize(mat3(gbufferModelViewInverse) * -viewPosDiff).y - occlusion/n) * threshHold;
#endif
}
@@ -440,9 +436,7 @@ void main() {
vec2 SSAO_SSS = SSAO(viewPos, worldToView(normal),worldToView(FlatNormals), hand, noise);
#ifndef OLD_INDIRECT_SSS
SSAO_SSS.y = clamp(SSAO_SSS.y + 0.5 * lightmap.y*lightmap.y,0.0,1.0);
#endif
SSAO_SSS.y = clamp(SSAO_SSS.y + 0.5 * lightmap.y*lightmap.y,0.0,1.0);
if(swappedDepth >= 1.0) SSAO_SSS = vec2(1.0,0.0);
+5 -10
View File
@@ -798,17 +798,12 @@ vec3 SubsurfaceScattering_sun(vec3 albedo, float Scattering, float Density, floa
vec3 SubsurfaceScattering_sky(vec3 albedo, float Scattering, float Density){
// Density = 1.0;
#ifdef OLD_INDIRECT_SSS
float scatterDepth = 1.0 - pow(1.0-Scattering, 0.5 + Density * 2.5);
vec3 absorbColor = vec3(1.0) * exp(-(15.0 - 10.0*scatterDepth) * sss_absorbance_multiplier * 0.01);
vec3 scatter = scatterDepth * absorbColor * pow(Density, LabSSS_Curve);
#else
float scatterDepth = pow(Scattering,3.5);
scatterDepth = 1.0-pow(1.0-scatterDepth,5.0);
vec3 absorbColor = exp(max(luma(albedo) - albedo*vec3(1.0,1.1,1.2), 0.0) * -20.0 * sss_absorbance_multiplier);
vec3 scatter = scatterDepth * mix(absorbColor, vec3(1.0), scatterDepth) * pow(Density, LabSSS_Curve);
#endif
float scatterDepth = pow(Scattering,3.5);
scatterDepth = 1.0-pow(1.0-scatterDepth,5.0);
vec3 absorbColor = exp(max(luma(albedo) - albedo*vec3(1.0,1.1,1.2), 0.0) * -20.0 * sss_absorbance_multiplier);
vec3 scatter = scatterDepth * mix(absorbColor, vec3(1.0), scatterDepth) * pow(Density, LabSSS_Curve);
// scatter *= 1.0 + exp(-7.0*(-playerPosNormalized.y*0.5+0.5));
+1 -1
View File
@@ -211,7 +211,7 @@ vec3 blackbody(float Temp)
}
void main() {
/* DRAWBUFFERS:7 */
/* RENDERTARGETS:7 */
float vignette = (1.5-dot(texcoord-0.5,texcoord-0.5)*2.);
vec3 col = texture2D(colortex5,texcoord).rgb;
+2 -2
View File
@@ -163,7 +163,7 @@ vec3 chromaticAberration(vec2 UV){
void main() {
/* DRAWBUFFERS:7 */
/* RENDERTARGETS:7 */
#ifdef CHROMATIC_ABERRATION
vec3 color = chromaticAberration(texcoord);
@@ -185,5 +185,5 @@ void main() {
color = colorGrading(color);
#endif
gl_FragData[0].rgb = clamp(int8Dither(color, texcoord),0.0,1.0);
gl_FragData[0] = vec4(clamp(int8Dither(color, texcoord),0.0,1.0), 0.0);
}
+1 -1
View File
@@ -941,7 +941,7 @@ void main() {
#endif
#endif
gl_FragData[0].r = bloomyFogMult; // pass fog alpha so bloom can do bloomy fog
gl_FragData[0] = vec4(bloomyFogMult,0.0,0.0,1.0); // pass fog alpha so bloom can do bloomy fog
gl_FragData[1].rgb = clamp(color.rgb, 0.0,68000.0);
// gl_FragData[1].rgb = vec3(tangentNormals.xy,0.0) * 0.1 ;
+1 -1
View File
@@ -18,7 +18,7 @@ uniform float viewWidth;
//////////////////////////////VOID MAIN//////////////////////////////
void main() {
/* DRAWBUFFERS:06 */
/* RENDERTARGETS:0,6 */
vec2 screenEdges = 2.0/vec2(viewWidth, viewHeight);
vec2 jitter = offsets[framemod8]*texelSize*0.5;
ivec2 center = ivec2(clamp(gl_FragCoord.xy*texelSize, screenEdges, 1.0-screenEdges)/texelSize);
+1 -1
View File
@@ -430,7 +430,7 @@ vec4 computeTAA(vec2 texcoord, bool hand){
void main() {
/* DRAWBUFFERS:5 */
/* RENDERTARGETS:5 */
#ifdef TAA
vec2 taauTC = clamp(texcoord*RENDER_SCALE, vec2(0.0), RENDER_SCALE - texelSize*2.0);
+1 -1
View File
@@ -22,7 +22,7 @@ vec2 decodeVec2(float a){
void main() {
/* DRAWBUFFERS:3 */
/* RENDERTARGETS:3 */
vec2 resScale = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.))/vec2(1920.,1080.);
vec2 quarterResTC = gl_FragCoord.xy*2.0*resScale*texelSize;
+1 -1
View File
@@ -10,7 +10,7 @@ uniform float viewHeight;
void main() {
/* DRAWBUFFERS:6 */
/* RENDERTARGETS:6 */
vec2 resScale = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.))/vec2(1920.,1080.);
vec2 quarterResTC = gl_FragCoord.xy*2.*texelSize;
+1 -1
View File
@@ -24,7 +24,7 @@ vec3 gauss1D(vec2 coord,vec2 dir,float alpha,int maxIT){
//////////////////////////////VOID MAIN//////////////////////////////
void main() {
/* DRAWBUFFERS:6 */
/* RENDERTARGETS:6 */
vec2 texcoord = (gl_FragCoord.xy*vec2(2.0,4.0))*texelSize;
vec2 gaussDir = vec2(1.0,0.0);
+1 -1
View File
@@ -23,7 +23,7 @@ vec3 gauss1D(vec2 coord,vec2 dir,float alpha,int maxIT){
//////////////////////////////VOID MAIN//////////////////////////////
void main() {
/* DRAWBUFFERS:6 */
/* RENDERTARGETS:6 */
vec2 texcoord = (gl_FragCoord.xy*vec2(2.0,4.0))*texelSize;
vec2 gaussDir = vec2(0.0,1.0);
+1 -1
View File
@@ -224,7 +224,7 @@ uniform int hideGUI;
#endif
void main() {
/* DRAWBUFFERS:4 */
/* RENDERTARGETS:4 */
gl_FragData[0] = vec4(0.0);
+13 -44
View File
@@ -29,7 +29,7 @@ uniform float dhVoxyNearPlane;
float linZ(float depth) {
return (2.0 * near) / (far + near - depth * (far - near));
}
float DH_ld(float dist) {
float DH_linZ(float dist) {
return (2.0 * dhVoxyNearPlane) / (dhVoxyFarPlane + dhVoxyNearPlane - dist * (dhVoxyFarPlane - dhVoxyNearPlane));
}
float DH_invLinZ (float lindepth){
@@ -59,52 +59,21 @@ vec2 decodeVec2(float a){
void main() {
/* RENDERTARGETS:4,12 */
vec3 oldTex = texelFetch2D(colortex4, ivec2(gl_FragCoord.xy), 0).xyz;
float newTex = texelFetch2D(depthtex1, ivec2(gl_FragCoord.xy*4.), 0).x;
float newTex = texelFetch2D(depthtex1, ivec2(gl_FragCoord.xy*4), 0).x;
float dataUnpacked = decodeVec2(texelFetch2D(colortex1,ivec2(gl_FragCoord.xy*4.),0).w).y;
float dataUnpacked = decodeVec2(texelFetch2D(colortex1,ivec2(gl_FragCoord.xy*4),0).w).y;
bool hand = abs(dataUnpacked-0.75) < 0.01;
if(hand) convertHandDepth(newTex);
#if defined DISTANT_HORIZONS || defined VOXY
float QuarterResDepth = texelFetch2D(dhVoxyDepthTex, ivec2(gl_FragCoord.xy*4), 0).x;
if(newTex == 1.0) {
float depth = DH_ld(QuarterResDepth);
gl_FragData[0] = vec4(oldTex, 650000.0);
} else {
float depth = linZ(newTex);
gl_FragData[0] = vec4(oldTex, depth * depth * 65000.0);
}
// sky
if (newTex == 1.0 && QuarterResDepth == 1.0) {
gl_FragData[0] = vec4(oldTex, 65000.0);
}
float depth = newTex;
float _near = near;
float _far = far*4.0;
if (depth >= 1.0) {
depth = QuarterResDepth;
_near = dhVoxyNearPlane;
_far = dhVoxyFarPlane;
}
depth = linearizeDepthFast(depth, _near, _far);
depth = depth / dhVoxyFarPlane;
if(depth < 1.0) {
gl_FragData[1].a = depth * depth * 65000.0;
} else {
gl_FragData[1].a = 66000.0;
}
#else
if(newTex < 1.0) {
float depth = linZ(newTex);
gl_FragData[0] = vec4(oldTex, depth * depth * 65000.0);
} else {
// sky
gl_FragData[0] = vec4(oldTex, 65000.0);
}
#endif
#if defined DISTANT_HORIZONS || defined VOXY
float QuarterResDepth = texelFetch2D(dhVoxyDepthTex, ivec2(gl_FragCoord.xy*4), 0).x;
QuarterResDepth = DH_linZ(QuarterResDepth);
gl_FragData[1].a = QuarterResDepth*QuarterResDepth*65000.0;
if(QuarterResDepth >= 1.0) gl_FragData[1].a = 66000.0;
#endif
newTex = linZ(newTex);
gl_FragData[0] = vec4(oldTex, newTex*newTex*65000.0);
if(newTex >= 1.0) gl_FragData[0].a = 66000.0;
}
-1
View File
@@ -17,7 +17,6 @@ uniform sampler2D shadowcolor1;
#if DEBUG_VIEW == debug_CLOUDDEPTHTEX && defined CUMULONIMBUS_LIGHTNING && CUMULONIMBUS > 0
#extension GL_NV_gpu_shader5 : enable
#extension GL_ARB_shader_image_load_store : enable
#extension GL_EXT_shader_image_load_store : enable
layout (rgba16f) uniform image2D cloudDepthTex;
#endif
+2 -1
View File
@@ -1,6 +1,6 @@
option.SHADER_VERSION_LABEL = §d§lECLIPSE§r - A Bliss Edit
prefix.SHADER_VERSION_LABEL = V
value.SHADER_VERSION_LABEL.482 = 5.3.2
value.SHADER_VERSION_LABEL.482 = 5.4.0
# if you're here to translate, this is not a joke, these do what they say
profile.POTATO=§4Potato
@@ -818,6 +818,7 @@ screen.Resource_Pack_Support = Materials / Resource Pack Support
suffix.SUN_SPECULAR_MULT =x brighter
option.ROUGHNESS_THRESHOLD = Reflection Visibilty Threshold
value.ROUGHNESS_THRESHOLD.0.0 = no threshold
option.QUARTER_RES_SSR = Sample 1/4 resolution depth
screen.Emissives = Emissives / Glowing Textures
option.Emissive_Brightness = Emission Multiplier
+1 -2
View File
@@ -1,6 +1,6 @@
option.SHADER_VERSION_LABEL = §d§lECLIPSE§r - Bliss 编辑版
prefix.SHADER_VERSION_LABEL = 版本
value.SHADER_VERSION_LABEL.482 = 5.3.2
value.SHADER_VERSION_LABEL.482 = 5.4.0
# 如果你是来翻译的,这不是玩笑,这些选项的功能正如其名
profile.POTATO=§4土豆 (极低配置)
@@ -113,7 +113,6 @@ screen.LEGACY_STUFF = 旧版设置
option.ORIGINAL_CHOCAPIC_SKY = Chocapic天空
option.OLD_BLOOM = 旧版泛光
option.OLD_CAVE_DETECTION = 旧版洞穴检测
option.OLD_INDIRECT_SSS = 旧版间接屏幕光照
option.CLOUD_PHASE = 云相
option.OLD_STARS = 旧版星星
+1 -1
View File
@@ -110,7 +110,7 @@ vec3 doBlockLightLighting(
float lightmapCurve = mix(lightmapLight, 2.5, lightmapBrightspot);
vec3 blockLight = lightmapCurve * lightColor;
#if defined IS_LPV_ENABLED && defined MC_GL_EXT_shader_image_load_store
#if defined IS_LPV_ENABLED && defined MC_GL_ARB_shader_image_load_store
vec4 lpvSample = SampleLpvLinear(lpvPos);
#ifdef VANILLA_LIGHTMAP_MASK
lpvSample.rgb *= lightmapCurve;
+2 -5
View File
@@ -285,6 +285,7 @@ const float entityShadowDistanceMul = 0.25; // [0.01 0.02 0.03 0.04 0.05 0.10 0.
#define SUN_SPECULAR_MULT 1 // [0 1 2 3 4 5 6 7 8 9 10]
#define ROUGHNESS_THRESHOLD 0.3 // [0.0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.00]
#define QUARTER_RES_SSR
#ifdef Specular_Reflections
#define LIGHTSOURCE_REFLECTION
@@ -919,8 +920,6 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631)
// #define SSS_view
// #define BIOME_TINT_WATER
#define Texture_MipMap_Bias 0.0 // [-5.00 -4.75 -4.50 -4.25 -4.00 -3.75 -3.50 -3.25 -3.00 -2.75 -2.50 -2.25 -2.00 -1.75 -1.50 -1.25 -1.00 -0.75 -0.50 -0.25 0.00 0.25 0.50 0.75 1.00 1.25 1.50 1.75 2.00 2.25 2.50 2.75 3.00 3.25 3.50 3.75 4.00 4.25 4.50 4.75 5.00]
#define PLANET_GROUND_BRIGHTNESS 1.0 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 ]
// #define OLD_LIGHTLEAK_FIX
@@ -934,7 +933,7 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631)
#define RESOURCEPACK_SKY 0 // [0 1 2 3]
#ifdef IS_IRIS
#define TRANSLUCENT_ENTITIES
// #define TRANSLUCENT_ENTITIES
#endif
#define WATER_CAUSTICS_BRIGHTNESS 1.0 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0]
@@ -971,8 +970,6 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631)
#undef PLANET_CURVATURE
#endif
// #define OLD_INDIRECT_SSS
// #define SHADER_GRASS
#ifdef SHADER_GRASS
+133 -44
View File
@@ -2,10 +2,18 @@ float invLinZ (float lindepth){
return -((2.0*near/lindepth)-far-near)/(far-near);
}
float DH_invLinZ (float lindepth){
return -((2.0*dhVoxyNearPlane/lindepth)-dhVoxyFarPlane-dhVoxyNearPlane)/(dhVoxyFarPlane-dhVoxyNearPlane);
}
float linZ(float depth) {
return (2.0 * near) / (far + near - depth * (far - near));
}
float linZ2(float depth, float near, float far) {
return (2.0 * near) / (far + near - depth * (far - near));
}
void frisvad(in vec3 n, out vec3 f, out vec3 r){
if(n.z < -0.9) {
f = vec3(0.,-1,0);
@@ -97,35 +105,21 @@ float shlickFresnelRoughness(float XdotN, float roughness){
return shlickFresnel;
}
#if defined DISTANT_HORIZONS && defined DH_SCREENSPACE_REFLECTIONS
uniform vec4 combined_projection_matrix_0;
uniform vec4 combined_projection_matrix_1;
uniform vec4 combined_projection_matrix_2;
uniform vec4 combined_projection_matrix_3;
#define combined_projection_matrix mat4(combined_projection_matrix_0, combined_projection_matrix_1, combined_projection_matrix_2, combined_projection_matrix_3)
float invertLinearizeDepthFast(const in float z) {
return (dhVoxyFarPlane * (z - near)) / (z * (dhVoxyFarPlane - near));
}
#endif
vec3 toClipSpace3_DH(vec3 viewSpacePosition) {
#if defined DISTANT_HORIZONS && defined DH_SCREENSPACE_REFLECTIONS
mat4 matrix = combined_projection_matrix;
#else
mat4 matrix = gbufferProjection;
#endif
return projMAD(matrix, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5;
float invertLinearizeDepthFast(const in float z) {
return (far * (z - near)) / (z * (far - near));
}
vec3 rayTraceSpeculars(vec3 dir, vec3 position, float dither, float quality, bool hand, inout float reflectionLength){
float biasAmount = 0.00003;
vec3 rayTraceSpeculars(vec3 dir, vec3 position, float dither, float quality, bool hand, inout float reflectionLength, inout bool depthCheck){
vec3 clipPosition = toClipSpace3_DH(position);
float rayLength = ((position.z + dir.z * far*sqrt(3.)) > -near) ? (-near -position.z) / dir.z : far*sqrt(3.);
const float biasAmount = 0.00003;
vec3 direction = toClipSpace3_DH(position + dir*rayLength) - clipPosition; //convert to clip space
float _near = near; float _far = far;
vec3 clipPosition = toClipSpace3_DH(position, false);
float rayLength = ((position.z + dir.z * _far*sqrt(3.)) > -_near) ? (-_near -position.z) / dir.z : _far*sqrt(3.);
vec3 direction = toClipSpace3_DH(position + dir*rayLength, false) - clipPosition; //convert to clip space
vec3 reflectedTC = vec3((direction.xy + clipPosition.xy) * RENDER_SCALE, 0.999999);
#if FORWARD_SSR_QUALITY == 1
@@ -147,40 +141,113 @@ vec3 rayTraceSpeculars(vec3 dir, vec3 position, float dither, float quality, boo
spos.xy += TAA_Offset*texelSize*0.5/RENDER_SCALE;
#endif
float minZ = spos.z - 0.00025 / linZ(spos.z);
float minZ = spos.z - 0.00025 / linZ2(spos.z, _near, _far);
float maxZ = spos.z;
#if (defined VOXY && defined VOXY_REFLECTIONS) || (defined DISTANT_HORIZONS && defined DH_SCREENSPACE_REFLECTIONS)
const float biasAmount2 = 0.000015;
_near = dhVoxyNearPlane;
_far = dhVoxyFarPlane;
vec3 clipPosition2 = toClipSpace3_DH(position, true);
float rayLength2 = ((position.z + dir.z * _far*sqrt(3.)) > -_near) ? (-_near -position.z) / dir.z : _far*sqrt(3.);
vec3 direction2 = toClipSpace3_DH(position + dir*rayLength, true) - clipPosition2; //convert to clip space
vec3 reflectedTC2 = vec3((direction2.xy + clipPosition2.xy) * RENDER_SCALE, 0.999999);
#if FORWARD_SSR_QUALITY == 1
return reflectedTC2;
#endif
//get at which length the ray intersects with the edge of the screen
vec3 maxLengths2 = (step(0.0, direction2) - clipPosition2) / direction2;
float mult2 = min(min(maxLengths2.x, maxLengths2.y), maxLengths2.z);
vec3 stepv2 = direction2 * mult2 / quality;
clipPosition2.xy *= RENDER_SCALE;
stepv2.xy *= RENDER_SCALE;
vec3 spos2 = clipPosition2 + stepv2*dither;
spos2 += stepv2*0.5 + vec3(0.5*texelSize,0.0); // small offsets to reduce artifacts from precision differences.
#if defined DEFERRED_SPECULAR && defined TAA
spos2.xy += TAA_Offset*texelSize*0.5/RENDER_SCALE;
#endif
float minZ2 = spos2.z - 0.00025 / linZ2(spos2.z, _near, _far);
float maxZ2 = spos2.z;
#endif
vec3 hitPos = vec3(1.1);
for (int i = 0; i <= int(quality); i++) {
#if DEFERRED_SSR_QUALITY != 1
#if (defined VOXY && defined VOXY_REFLECTIONS) || (defined DISTANT_HORIZONS && defined DH_SCREENSPACE_REFLECTIONS)
if(!hand && (spos.x < 0 || spos.x > 1 || spos.y < 0 || spos.y > 1) && (spos2.x < 0 || spos2.x > 1 || spos2.y < 0 || spos2.y > 1)) return vec3(1.1);
#else
if(!hand && (spos.x < 0 || spos.x > 1 || spos.y < 0 || spos.y > 1)) return vec3(1.1);
#endif
#endif
#if defined DISTANT_HORIZONS && defined DH_SCREENSPACE_REFLECTIONS
#ifdef FULLRESDEPTH
// buffer is full res after first composite pass
float sampleDepth = texelFetch2D(colortex12, ivec2(spos.xy/texelSize),0).b/65000.0;
#else
float sampleDepth = texelFetch2D(colortex12, ivec2(spos.xy/texelSize/4.0),0).a/65000.0;
#endif
float sp = invertLinearizeDepthFast(sqrt(sampleDepth)*dhVoxyFarPlane);
#else
float sampleDepth = texelFetch2D(colortex4, ivec2(spos.xy/texelSize/4.0),0).a/65000.0;
#ifdef QUARTER_RES_SSR
float sampleDepth = texelFetch(colortex4, ivec2(spos.xy/texelSize/4.0),0).a/65000.0;
float sp = invLinZ(sqrt(sampleDepth));
#else
#ifdef FULLRESDEPTH
float sp = texelFetch(depthtex0, ivec2(spos.xy/texelSize),0).r;
#else
float sp = texelFetch(depthtex1, ivec2(spos.xy/texelSize),0).r;
#endif
#endif
if(sp < max(minZ, maxZ) && sp > min(minZ, maxZ)) {
hitPos = vec3(spos.xy/RENDER_SCALE, sp);
break;
#if (defined VOXY && defined VOXY_REFLECTIONS) || (defined DISTANT_HORIZONS && defined DH_SCREENSPACE_REFLECTIONS)
bool DHrange = sp >= 1.0;
if (DHrange){
#ifdef QUARTER_RES_SSR
#ifdef FULLRESDEPTH
sp = texelFetch(dhVoxyDepthTex, ivec2(spos2.xy/texelSize),0).r;
#else
sampleDepth = texelFetch(colortex12, ivec2(spos2.xy/texelSize/4.0),0).a/65000.0;
sp = DH_invLinZ(sqrt(sampleDepth));
#endif
#else
#ifdef FULLRESDEPTH
sp = texelFetch(dhVoxyDepthTex, ivec2(spos2.xy/texelSize),0).r;
#else
sp = texelFetch(dhVoxyDepthTex1, ivec2(spos2.xy/texelSize),0).r;
#endif
#endif
if(sp < max(minZ2, maxZ2) && sp > min(minZ2, maxZ2)) {
hitPos = vec3(spos2.xy/RENDER_SCALE, sp);
depthCheck = true;
break;
}
} else
#endif
{
if(sp < max(minZ, maxZ) && sp > min(minZ, maxZ)) {
hitPos = vec3(spos.xy/RENDER_SCALE, sp);
break;
}
}
minZ = maxZ - biasAmount / linZ(spos.z);
minZ = maxZ - biasAmount / linZ2(spos.z, near, far);
maxZ += stepv.z;
spos += stepv;
#if (defined VOXY && defined VOXY_REFLECTIONS) || (defined DISTANT_HORIZONS && defined DH_SCREENSPACE_REFLECTIONS)
minZ2 = maxZ2 - biasAmount2 / linZ2(spos2.z, dhVoxyNearPlane, dhVoxyFarPlane);
maxZ2 += stepv2.z;
spos2 += stepv2;
#endif
reflectionLength += 1.0 / quality;
}
@@ -192,6 +259,19 @@ vec3 rayTraceSpeculars(vec3 dir, vec3 position, float dither, float quality, boo
return hitPos;
}
vec3 toScreenSpace2(vec3 p, bool depthCheck) {
#if (defined VOXY && defined VOXY_REFLECTIONS) || (defined DISTANT_HORIZONS && defined DH_SCREENSPACE_REFLECTIONS)
mat4 matrix = gbufferProjectionInverse;
if(depthCheck) matrix = dhVoxyProjectionInverse;
#else
mat4 matrix = gbufferProjectionInverse;
#endif
vec4 iProjDiag = vec4(matrix[0].x, matrix[1].y, matrix[2].zw);
vec3 p3 = p * 2. - 1.;
vec4 fragposition = iProjDiag * p3.xyzz + matrix[3];
return fragposition.xyz / fragposition.w;
}
vec4 screenSpaceReflections(
vec3 reflectedVector,
vec3 viewPos,
@@ -215,7 +295,9 @@ vec4 screenSpaceReflections(
quality = float(DEFERRED_SSR_QUALITY);
#endif
vec3 raytracePos = rayTraceSpeculars(reflectedVector, viewPos, noise, quality, isHand, reflectionLength);
bool depthCheck = false;
vec3 raytracePos = rayTraceSpeculars(reflectedVector, viewPos, noise, quality, isHand, reflectionLength, depthCheck);
if (raytracePos.z > 1.0) return reflection;
// use higher LOD as the reflection goes on, to blur it. this helps denoise a little.
@@ -224,9 +306,16 @@ vec4 screenSpaceReflections(
float LOD = mix(0.0, 6.0*(1.0-exp(-15.0*sqrt(roughness))), 1.0-pow(1.0-reflectionLength,5.0));
vec3 previousPosition = mat3(gbufferModelViewInverse) * toScreenSpace(raytracePos) + gbufferModelViewInverse[3].xyz + (cameraPosition - previousCameraPosition);
#if (defined VOXY && defined VOXY_REFLECTIONS) || (defined DISTANT_HORIZONS && defined DH_SCREENSPACE_REFLECTIONS)
mat4 projMatrix = gbufferPreviousProjection;
if(depthCheck) projMatrix = dhVoxyProjectionPrev;
#else
mat4 projMatrix = gbufferPreviousProjection;
#endif
vec3 previousPosition = mat3(gbufferModelViewInverse) * toScreenSpace2(raytracePos, depthCheck) + gbufferModelViewInverse[3].xyz + (cameraPosition - previousCameraPosition);
previousPosition = mat3(gbufferPreviousModelView) * previousPosition + gbufferPreviousModelView[3].xyz;
previousPosition.xy = projMAD(gbufferPreviousProjection, previousPosition).xy / -previousPosition.z * 0.5 + 0.5;
previousPosition.xy = projMAD(projMatrix, previousPosition).xy / -previousPosition.z * 0.5 + 0.5;
if (previousPosition.x > 0.0 && previousPosition.y > 0.0 && previousPosition.x < 1.0 && previousPosition.y < 1.0) {
if(raytracePos.z > 0.9999999) backgroundReflectMask = 1.0;
-1
View File
@@ -38,7 +38,6 @@ float lightningFlash = mix(0.1, 2.5, randomSeed);
#if !defined COLORWHEEL && !defined VOXY_PROGRAM
#extension GL_NV_gpu_shader5 : enable
#extension GL_ARB_shader_image_load_store : enable
#extension GL_EXT_shader_image_load_store : enable
#endif
#ifndef VOXY_PROGRAM
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -45,7 +45,7 @@ Read the terms of modification and sharing before changing something below pleas
void main() {
#if defined IS_LPV_ENABLED && defined MC_GL_EXT_shader_image_load_store
#if defined IS_LPV_ENABLED && defined MC_GL_ARB_shader_image_load_store
#ifdef LPV_NOSHADOW_HACK
vec3 playerpos = gl_Vertex.xyz;
#else
+1 -1
View File
@@ -40,7 +40,7 @@ Read the terms of modification and sharing before changing something below pleas
void main() {
#if defined IS_LPV_ENABLED && defined MC_GL_EXT_shader_image_load_store
#if defined IS_LPV_ENABLED && defined MC_GL_ARB_shader_image_load_store
#ifdef LPV_NOSHADOW_HACK
vec3 playerpos = gl_Vertex.xyz;
#else
+1 -1
View File
@@ -213,7 +213,7 @@ void main() {
playerpos = mat3(shadowModelViewInverse) * position + shadowModelViewInverse[3].xyz;
// #endif
#if defined IS_LPV_ENABLED && defined MC_GL_EXT_shader_image_load_store
#if defined IS_LPV_ENABLED && defined MC_GL_ARB_shader_image_load_store
PopulateShadowVoxel(playerpos);
#endif
+1 -1
View File
@@ -211,7 +211,7 @@ void main() {
playerpos = mat3(shadowModelViewInverse) * position + shadowModelViewInverse[3].xyz;
// #endif
#if defined IS_LPV_ENABLED && defined MC_GL_EXT_shader_image_load_store || WATER_INTERACTION == 2 || defined SHADER_GRASS
#if defined IS_LPV_ENABLED && defined MC_GL_ARB_shader_image_load_store || WATER_INTERACTION == 2 || defined SHADER_GRASS
PopulateShadowVoxel(playerpos);
#endif
+1 -1
View File
@@ -202,7 +202,7 @@ void main() {
vec3 playerpos = mat3(shadowModelViewInverse) * position + shadowModelViewInverse[3].xyz;
// #endif
#if defined IS_LPV_ENABLED && defined MC_GL_EXT_shader_image_load_store
#if defined IS_LPV_ENABLED && defined MC_GL_ARB_shader_image_load_store
PopulateShadowVoxel(playerpos);
#endif
@@ -202,7 +202,7 @@ void main() {
vec3 playerpos = mat3(shadowModelViewInverse) * position + shadowModelViewInverse[3].xyz;
// #endif
#if defined IS_LPV_ENABLED && defined MC_GL_EXT_shader_image_load_store
#if defined IS_LPV_ENABLED && defined MC_GL_ARB_shader_image_load_store
PopulateShadowVoxel(playerpos);
#endif
+2 -2
View File
@@ -60,12 +60,12 @@ varying vec2 texcoord;
void main() {
#if defined END_ISLAND_LIGHT || (defined IS_LPV_ENABLED && defined MC_GL_EXT_shader_image_load_store)
#if defined END_ISLAND_LIGHT || (defined IS_LPV_ENABLED && defined MC_GL_ARB_shader_image_load_store)
vec3 shadowViewPos = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz;
vec3 feetPlayerPos = mat3(shadowModelViewInverse) * shadowViewPos + shadowModelViewInverse[3].xyz;
#endif
#if defined IS_LPV_ENABLED && defined MC_GL_EXT_shader_image_load_store
#if defined IS_LPV_ENABLED && defined MC_GL_ARB_shader_image_load_store
#ifdef LPV_NOSHADOW_HACK
vec3 playerpos = gl_Vertex.xyz;
#else
+1 -1
View File
@@ -36,7 +36,7 @@ vec3 toScreenSpaceVector(vec3 p) {
//////////////////////////////VOID MAIN//////////////////////////////
void main() {
/* DRAWBUFFERS:2 */
/* RENDERTARGETS:2 */
gl_FragData[0] = texture2D(gtexture, lmtexcoord.xy)*color;
gl_FragData[0].a = clamp(gl_FragData[0].a -0.1,0.0,1.0)*0.5;
vec3 albedo = toLinear(gl_FragData[0].rgb*color.rgb);
+2 -2
View File
@@ -57,12 +57,12 @@ varying vec2 texcoord;
void main() {
#if defined END_ISLAND_LIGHT || (defined IS_LPV_ENABLED && defined MC_GL_EXT_shader_image_load_store)
#if defined END_ISLAND_LIGHT || (defined IS_LPV_ENABLED && defined MC_GL_ARB_shader_image_load_store)
vec3 shadowViewPos = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz;
vec3 feetPlayerPos = mat3(shadowModelViewInverse) * shadowViewPos + shadowModelViewInverse[3].xyz;
#endif
#if defined IS_LPV_ENABLED && defined MC_GL_EXT_shader_image_load_store || WATER_INTERACTION == 2 || defined SHADER_GRASS
#if defined IS_LPV_ENABLED && defined MC_GL_ARB_shader_image_load_store || WATER_INTERACTION == 2 || defined SHADER_GRASS
#ifdef LPV_NOSHADOW_HACK
vec3 playerpos = gl_Vertex.xyz;
#else