Refraction fix

fix the refraction. hopefully.
This commit is contained in:
Xonk 2023-05-09 16:16:41 -04:00
parent 52466e8e35
commit 82668ef211
7 changed files with 32 additions and 19 deletions

View File

@ -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

View File

@ -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);
}

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

@ -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);
}

View File

@ -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