From 82668ef211ec50edd665fc758c51bcfd479149ac Mon Sep 17 00:00:00 2001 From: Xonk Date: Tue, 9 May 2023 16:16:41 -0400 Subject: [PATCH] Refraction fix fix the refraction. hopefully. --- shaders/composite1.fsh | 2 +- shaders/composite3.fsh | 18 +++++++++++++----- shaders/entity.properties | 2 +- shaders/gbuffers_all_solid.fsh | 19 ++++++++++--------- shaders/gbuffers_all_translucent.fsh | 6 ++++-- shaders/lib/stars.glsl | 2 +- shaders/shaders.properties | 2 ++ 7 files changed, 32 insertions(+), 19 deletions(-) diff --git a/shaders/composite1.fsh b/shaders/composite1.fsh index 78c8c2a..485e94b 100644 --- a/shaders/composite1.fsh +++ b/shaders/composite1.fsh @@ -869,7 +869,7 @@ void main() { if ( z >= 1.) { //sky vec3 background = vec3(0.0); - background += stars(vec3(np3.x,abs(np3.y),np3.z)) * 5.0; + background += stars(vec3(np3.x,abs(np3.y),np3.z)) * 5.0 ; #ifndef ambientLight_only background += drawSun(dot(lightCol.a * WsunVec, np3),0, DirectLightColor,vec3(0.0)) ; // sun diff --git a/shaders/composite3.fsh b/shaders/composite3.fsh index 2aea533..5a7af71 100644 --- a/shaders/composite3.fsh +++ b/shaders/composite3.fsh @@ -194,9 +194,14 @@ void main() { vec4 unpack0 = vec4(decodeVec2(data.r),decodeVec2(data.g)) ; vec4 unpack1 = vec4(decodeVec2(data.b),0,0) ; - vec2 tangentNormals = unpack0.xy*2.0-1.0; + + vec4 albedo = vec4(unpack0.ba,unpack1.rg); + vec2 tangentNormals = unpack0.xy*2.0-1.0; + + if(albedo.a <= 0.0) tangentNormals = vec2(0.0); + vec4 TranslucentShader = texture2D(colortex2,texcoord); float lightleakfix = clamp((eyeBrightnessSmooth.y )/240.0,0.0,1.0); @@ -213,9 +218,12 @@ void main() { /// --- REFRACTION --- /// #ifdef Refraction - refractedCoord += (tangentNormals * clamp((ld(z2) - ld(z)) * 0.5,0.0,0.15)) * RENDER_SCALE; + // refractedCoord += (tangentNormals * clamp((ld(z2) - ld(z)) * 0.5,0.0,0.15)) * RENDER_SCALE; + refractedCoord += tangentNormals * 0.1 * RENDER_SCALE; - if( texture2D(colortex7,refractedCoord).a < 0.95 && decodeVec2(texture2D(colortex11,refractedCoord).b).g < 0.01 ) refractedCoord = texcoord; // remove refracted coords on solids + float refractedalpha = decodeVec2(texture2D(colortex11,refractedCoord).b).g; + float refractedalpha2 = texture2D(colortex7,refractedCoord).a; + if( refractedalpha <= 0.0 ) refractedCoord = texcoord; // remove refracted coords on solids #endif /// --- MAIN COLOR BUFFER --- /// @@ -297,7 +305,7 @@ void main() { gl_FragData[1].rgb = clamp(color.rgb,0.0,68000.0); - // gl_FragData[1].rgb = vec3(albedo.rgb*albedo.a); - // if(texcoord.x > 0.5) gl_FragData[1].rgb = vec3(tangentNormals,0.0); + // gl_FragData[1].rgb = vec3(albedo.a); +// gl_FragData[1].rgb = vec3(tangentNormals,0.0); } \ No newline at end of file diff --git a/shaders/entity.properties b/shaders/entity.properties index f70ca74..fa49e10 100644 --- a/shaders/entity.properties +++ b/shaders/entity.properties @@ -8,7 +8,7 @@ entity.1100 = slime giant ender_dragon ghast #weak sss (same as weak sss for blocks) entity.1200 = player frog sheep chicken snow_golem polar_bear zombie_horse armor_stand arrow squid bat cat cod cow donkey fox horse mooshroom mule ocelot parrot pig piglin polar_bear pufferfish rabbit salmon strider tropical_fish turtle villager wandering_trader bee cave_spider dolphin enderman llama panda spider wolf zombified_piglin blaze creeper drowned elder_gaurdian endermite evoker guardian hoglin husk magma_cube phantom piglin_brute pillager ravager silverfish stray vex vindicator witch zoglin zombie zombie_villager wither trader_llama -entity.5000 = lightning_bolt +entity.12345=minecraft:lightning_bolt # entity.9001 = minecraft:boat diff --git a/shaders/gbuffers_all_solid.fsh b/shaders/gbuffers_all_solid.fsh index 5ceca40..df14fe8 100644 --- a/shaders/gbuffers_all_solid.fsh +++ b/shaders/gbuffers_all_solid.fsh @@ -300,7 +300,7 @@ void main() { float depthmap = readNormal(vtexcoord.st).a; float used_POM_DEPTH = 1.0; - if ( viewVector.z < 0.0 && depthmap < 0.9999 && depthmap > 0.00001) { + if ( viewVector.z < 0.0 && depthmap < 0.9999 && depthmap > 0.00001) { float noise = interleaved_gradientNoise_temp(); #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) ; @@ -310,9 +310,9 @@ void main() { #endif vec3 coord = vec3(vtexcoord.st, 1.0); - coord += (interval * noise) * used_POM_DEPTH; + coord += (interval ) * used_POM_DEPTH; - float sumVec = noise; + float sumVec = 0.5; 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; @@ -340,6 +340,7 @@ void main() { vec4 Albedo = texture2DGradARB(texture, adjustedTexCoord.xy, dcdx,dcdy) * color; + #ifdef ENTITIES if(NameTags == 1) Albedo = texture2D(texture, lmtexcoord.xy, Texture_MipMap_Bias) * color; #endif @@ -398,9 +399,9 @@ void main() { normal = applyBump(tbnMatrix,NormalTex, mix(1.0,Puddle_shape,rainfall)); - #ifdef ENTITIES - if(NameTags == 1) normal = vec3(1); - #endif + // #ifdef ENTITIES + // if(NameTags == 1) normal = vec3(1); + // #endif #endif //////////////////////////////// @@ -433,9 +434,9 @@ void main() { normal = applyBump(tbnMatrix, NormalTex.xyz, 1 ); - #ifdef ENTITIES - if(NameTags == 1) normal = vec3(1); - #endif + // #ifdef ENTITIES + // if(NameTags == 1) normal = vec3(1); + // #endif // #ifdef ENTITY_PHYSICSMOD_SNOW // normal = FlatNormals; diff --git a/shaders/gbuffers_all_translucent.fsh b/shaders/gbuffers_all_translucent.fsh index c388bcd..55a7138 100644 --- a/shaders/gbuffers_all_translucent.fsh +++ b/shaders/gbuffers_all_translucent.fsh @@ -270,6 +270,8 @@ if (gl_FragCoord.x * texelSize.x < RENDER_SCALE.x && gl_FragCoord.y * texelSize gl_FragData[0] = texture2D(texture, lmtexcoord.xy, Texture_MipMap_Bias) * color; vec3 Albedo = toLinear(gl_FragData[0].rgb); + float UnchangedAlpha = gl_FragData[0].a; + float iswater = normalMat.w; #ifdef HAND @@ -291,7 +293,7 @@ if (gl_FragCoord.x * texelSize.x < RENDER_SCALE.x && gl_FragCoord.y * texelSize #endif - vec4 COLORTEST = vec4(Albedo,gl_FragData[0].a); + vec4 COLORTEST = vec4(Albedo,UnchangedAlpha); vec3 p3 = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz; @@ -356,7 +358,7 @@ if (gl_FragCoord.x * texelSize.x < RENDER_SCALE.x && gl_FragCoord.y * texelSize } // cannot encode alpha or it will shit its pants - gl_FragData[2] = vec4(encodeVec2(TangentNormal), encodeVec2(COLORTEST.rg), encodeVec2(COLORTEST.ba), 1.0); + gl_FragData[2] = vec4(encodeVec2(TangentNormal), encodeVec2(COLORTEST.rg), encodeVec2(COLORTEST.ba), UnchangedAlpha); float NdotL = clamp(lightSign*dot(normal,sunVec) ,0.0,1.0); diff --git a/shaders/lib/stars.glsl b/shaders/lib/stars.glsl index c018c07..44d42e7 100644 --- a/shaders/lib/stars.glsl +++ b/shaders/lib/stars.glsl @@ -44,5 +44,5 @@ float stars(vec3 fragpos){ float elevation = clamp(fragpos.y,0.,1.); vec2 uv = fragpos.xz/(1.5+elevation); - return StableStarField(uv*1500.,0.999)*0.5*(0.3-0.3*rainStrength); + return StableStarField(uv*1000.,0.999)*0.5*(0.3-0.3*rainStrength); } diff --git a/shaders/shaders.properties b/shaders/shaders.properties index fa14281..32fada2 100644 --- a/shaders/shaders.properties +++ b/shaders/shaders.properties @@ -30,6 +30,8 @@ blend.gbuffers_basic= off blend.gbuffers_damagedblock= SRC_ALPHA ONE_MINUS_SRC_ALPHA ONE_MINUS_DST_ALPHA ONE blend.gbuffers_skytextured=off +blend.gbuffers_water.colortex11 = off + alphaTest.gbuffers_armor_glint=false alphaTest.gbuffers_entities=GREATER 0.1 alphaTest.gbuffers_weather=false