From bd08dab55f66b04b9ed553bd4473ebc04cf783a0 Mon Sep 17 00:00:00 2001 From: Xonk Date: Fri, 30 Jun 2023 17:07:47 -0400 Subject: [PATCH] fix warden glowy parts --- shaders/composite1.fsh | 11 ++----- shaders/composite2.fsh | 2 +- shaders/composite3.fsh | 7 +++-- shaders/gbuffers_all_solid.fsh | 51 ++++++--------------------------- shaders/gbuffers_spidereyes.fsh | 39 +++++++++++++++++++++---- shaders/gbuffers_spidereyes.vsh | 22 ++++++-------- 6 files changed, 59 insertions(+), 73 deletions(-) diff --git a/shaders/composite1.fsh b/shaders/composite1.fsh index f60569f..8c67cb4 100644 --- a/shaders/composite1.fsh +++ b/shaders/composite1.fsh @@ -941,7 +941,7 @@ void main() { #ifdef Variable_Penumbra_Shadows SSS = SubsurfaceScattering_sun(albedo, SHADOWBLOCKERDEPTBH, LabSSS, clamp(dot(np3, WsunVec),0.0,1.0)) ; - + SSS *= DirectLightColor; if (isEyeInWater == 0) SSS *= lightleakfix; // light leak fix #endif @@ -1053,7 +1053,7 @@ void main() { #if indirect_effect != 1 ScreenSpace_SSS(SkySSS, fragpos, blueNoise(gl_FragCoord.xy).rg, FlatNormals, isLeaf); #endif - Indirect_lighting += SubsurfaceScattering_sky(albedo, SkySSS, LabSSS) * ((AmbientLightColor* 2.0 * ambient_brightness)* 8./150.) * pow(newLightmap.y,3) * pow(1.0-clamp(abs(ambientCoefs.y+0.5),0.0,1.0),0.1) ; + SSS += SubsurfaceScattering_sky(albedo, SkySSS, LabSSS) * ((AmbientLightColor* 2.0 * ambient_brightness)* 8./150.) * pow(newLightmap.y,3) * pow(1.0-clamp(abs(ambientCoefs.y+0.5),0.0,1.0),0.1) ; // Indirect_lighting += SubsurfaceScattering_sky(albedo, SkySSS, LabSSS) * ((AmbientLightColor* 2.0 * ambient_brightness)* 8./150.) * pow(newLightmap.y,3); } #endif @@ -1133,13 +1133,8 @@ void main() { Direct_lighting = DoDirectLighting(DirectLightColor, Shadows, NdotL, 0.0); //combine all light sources - vec3 FINAL_COLOR = Indirect_lighting + Direct_lighting; + vec3 FINAL_COLOR = Indirect_lighting + Direct_lighting + SSS; - - - #ifdef Variable_Penumbra_Shadows - FINAL_COLOR += SSS*DirectLightColor * lightleakfix; - #endif #ifndef ambientSSS_view FINAL_COLOR *= albedo; #endif diff --git a/shaders/composite2.fsh b/shaders/composite2.fsh index 6c3e307..76f9f52 100644 --- a/shaders/composite2.fsh +++ b/shaders/composite2.fsh @@ -310,7 +310,7 @@ void main() { float estEyeDepth = clamp((14.0-eyeBrightnessSmooth.y/255.0*16.0)/14.0,0.,1.0); estEyeDepth *= estEyeDepth*estEyeDepth*34.0; - vec3 ambientColVol = max(averageSkyCol_Clouds*8./150./1.5,MIN_LIGHT_AMOUNT*0.0015); + vec3 ambientColVol = averageSkyCol_Clouds*8./150./1.5; vec3 lightColVol = (lightCol.rgb / 80.); estEyeDepth = max(Water_Top_Layer - cameraPosition.y,0.0); diff --git a/shaders/composite3.fsh b/shaders/composite3.fsh index 875f71b..a79a09e 100644 --- a/shaders/composite3.fsh +++ b/shaders/composite3.fsh @@ -191,6 +191,7 @@ void main() { vec4 dataUnpacked1 = vec4(decodeVec2(data_opaque.z),decodeVec2(data_opaque.w)); // normals, lightmaps // vec4 dataUnpacked2 = vec4(decodeVec2(data.z),decodeVec2(data.w)); + bool hand = abs(dataUnpacked1.w-0.75) < 0.01; vec2 lightmap = dataUnpacked1.yz; ////// --------------- UNPACK TRANSLUCENT GBUFFERS --------------- ////// @@ -216,6 +217,8 @@ void main() { vec2 tempOffset = TAA_Offset; vec3 fragpos = toScreenSpace(vec3(texcoord/RENDER_SCALE-vec2(tempOffset)*texelSize*0.5,z)); vec3 fragpos2 = toScreenSpace(vec3(texcoord/RENDER_SCALE-vec2(tempOffset)*texelSize*0.5,z2)); + + vec3 p3 = mat3(gbufferModelViewInverse) * fragpos; vec3 np3 = normVec(p3); @@ -229,7 +232,7 @@ void main() { float refractedalpha = decodeVec2(texture2D(colortex11,refractedCoord).b).g; float refractedalpha2 = texture2D(colortex7,refractedCoord).a; - if( refractedalpha <= 0.001 ) refractedCoord = texcoord; // remove refracted coords on solids + if( refractedalpha <= 0.001 ||z < 0.56) refractedCoord = texcoord; // remove refracted coords on solids #endif /// --- MAIN COLOR BUFFER --- /// @@ -247,7 +250,7 @@ void main() { vec4 vl = BilateralUpscale(colortex0, depthtex1, gl_FragCoord.xy, frDepth, vec2(0.0)); - if (TranslucentShader.a > 0.0){ + if (TranslucentShader.a > 0.0 && !hand){ #ifdef Glass_Tint if(albedo.a > 0.2) color = color*albedo.rgb + color * clamp(pow(1.0-luma(albedo.rgb),20.),0.0,1.0); #endif diff --git a/shaders/gbuffers_all_solid.fsh b/shaders/gbuffers_all_solid.fsh index af47805..b1561b2 100644 --- a/shaders/gbuffers_all_solid.fsh +++ b/shaders/gbuffers_all_solid.fsh @@ -244,44 +244,9 @@ float ld(float dist) { } - -// float EndPortalEffect( -// inout vec4 ALBEDO, -// vec3 FragPos, -// vec3 WorldPos, -// mat3 tbnMatrix -// ){ -// float endportalGLow = 0.0; - -// vec3 viewVec = normalize(tbnMatrix*FragPos); - -// if (length(FragPos) < MAX_OCCLUSION_DISTANCE) { -// ALBEDO = vec4(0,0,0,1); -// float depth = 0.2; -// if ( viewVec.z < 0.0) { -// float noise = interleaved_gradientNoise_temp(); - -// vec3 interval = (viewVec.xyz /-viewVec.z/MAX_OCCLUSION_POINTS * POM_DEPTH) * 0.6 ; - -// vec3 coord = vec3((lmtexcoord.st)/4, 1.0); -// coord += interval * noise; -// float sumVec = noise; - -// for (int loopCount = 0; (loopCount < MAX_OCCLUSION_POINTS) && (1.0 - depth + depth * (1-readNoise(coord.st).r - readNoise((-coord.st*3 )).b*0.2) ) < coord.p && coord.p >= 0.0; ++loopCount) { -// coord = coord+interval ; -// sumVec += 1.0 ; -// endportalGLow += 0.01*0.6; -// } - -// ALBEDO.rgb = vec3(0.5,0.75,1.0) * sqrt(endportalGLow); - -// return clamp(pow(endportalGLow*3.5,5),0,1); -// } -// } -// } - vec4 readNoise(in vec2 coord){ - return texture2D(noisetex,coord*vtexcoordam.pq + vtexcoordam.st); + // return texture2D(noisetex,coord*vtexcoordam.pq+vtexcoord.st); + return texture2DGradARB(noisetex,coord*vtexcoordam.pq + vtexcoordam.st,dcdx,dcdy); } float EndPortalEffect( inout vec4 ALBEDO, @@ -299,7 +264,7 @@ float EndPortalEffect( float Depth = 0.3; vec3 interval = (viewVec.xyz /-viewVec.z/quality*Depth) * (0.7 + (blueNoise()-0.5)*0.1); - vec3 coord = vec3(-(abs(WorldPos.zx + WorldPos.zx))/4, 1.0); + vec3 coord = vec3(WorldPos.xz , 1.0); coord += interval; for (int loopCount = 0; (loopCount < quality) && (1.0 - Depth + Depth * ( 1.0-readNoise(coord.st).r - readNoise(-coord.st*3).b*0.2 ) ) < coord.p && coord.p >= 0.0; ++loopCount) { @@ -452,7 +417,7 @@ void main() { vec4 Albedo = texture2D_POMSwitch(texture, adjustedTexCoord.xy, vec4(dcdx,dcdy), ifPOM) * color; if(LIGHTNING > 0) Albedo = vec4(1); - // float ENDPORTAL_EFFECT = PORTAL > 0 ? EndPortalEffect(Albedo, fragpos, worldpos, tbnMatrix) : 0; + float ENDPORTAL_EFFECT = PORTAL > 0 ? EndPortalEffect(Albedo, fragpos, worldpos, tbnMatrix) : 0; #ifdef WhiteWorld Albedo.rgb = vec3(1.0); @@ -556,10 +521,10 @@ void main() { gl_FragData[2].b = SpecularTex.b; #endif - // if(PORTAL > 0){ - // gl_FragData[2].rgb = vec3(0); - // gl_FragData[2].a = clamp(ENDPORTAL_EFFECT * 0.9, 0,0.9); - // } + if(PORTAL > 0){ + gl_FragData[2].rgb = vec3(0); + gl_FragData[2].a = clamp(ENDPORTAL_EFFECT * 0.9, 0,0.9); + } #endif diff --git a/shaders/gbuffers_spidereyes.fsh b/shaders/gbuffers_spidereyes.fsh index a88dc73..07f3e98 100644 --- a/shaders/gbuffers_spidereyes.fsh +++ b/shaders/gbuffers_spidereyes.fsh @@ -11,18 +11,45 @@ vec3 toLinear(vec3 sRGB){ return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878); } +vec4 encode (vec3 n, vec2 lightmaps){ + n.xy = n.xy / dot(abs(n), vec3(1.0)); + n.xy = n.z <= 0.0 ? (1.0 - abs(n.yx)) * sign(n.xy) : n.xy; + vec2 encn = clamp(n.xy * 0.5 + 0.5,-1.0,1.0); + + return vec4(encn,vec2(lightmaps.x,lightmaps.y)); +} + +//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:18 */ +/* DRAWBUFFERS:28 */ void main() { - vec3 albedo = texture2D(texture, texcoord).rgb * color.rgb; - - gl_FragData[0].rgb = albedo; - - gl_FragData[1].a = 0.5; + vec4 Albedo = texture2D(texture, texcoord); + + // if (Albedo.a > 0.1) Albedo.a = 1.0; + // else Albedo.a = 0.0; + + // vec4 data1 = vec4(1); + // gl_FragData[0] = vec4(encodeVec2(Albedo.x,data1.x), encodeVec2(Albedo.y,data1.y), encodeVec2(Albedo.z,data1.z), encodeVec2(data1.w,Albedo.w)); + + Albedo *= color; + Albedo.rgb = toLinear(Albedo.rgb); + + gl_FragData[0] = Albedo; + + gl_FragData[1] = vec4(0.0,0.0,0.0,0.5); } \ No newline at end of file diff --git a/shaders/gbuffers_spidereyes.vsh b/shaders/gbuffers_spidereyes.vsh index f6ea3d9..a0779cc 100644 --- a/shaders/gbuffers_spidereyes.vsh +++ b/shaders/gbuffers_spidereyes.vsh @@ -11,23 +11,19 @@ Read the terms of modification and sharing before changing something below pleas !! DO NOT REMOVE !! */ -varying vec4 lmtexcoord; varying vec4 color; - - - varying vec2 texcoord; uniform vec2 texelSize; uniform int framemod8; - const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.), - vec2(-1.,3.)/8., - vec2(5.0,1.)/8., - vec2(-3,-5.)/8., - vec2(-5.,5.)/8., - vec2(-7.,-1.)/8., - vec2(3,7.)/8., - vec2(7.,-7.)/8.); +const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.), + vec2(-1.,3.)/8., + vec2(5.0,1.)/8., + vec2(-3,-5.)/8., + vec2(-5.,5.)/8., + vec2(-7.,-1.)/8., + vec2(3,7.)/8., + vec2(7.,-7.)/8.); //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// @@ -38,7 +34,7 @@ void main() { gl_Position = ftransform(); - // if(gl_Color.a < 1.0 ) gl_Position = vec4(10,10,10,1); + // if(gl_Color.a < 0.1 ) gl_Position = vec4(10,10,10,1); texcoord = (gl_MultiTexCoord0).xy; color = gl_Color;