diff --git a/shaders/composite3.fsh b/shaders/composite3.fsh index f3cfded..1897fb0 100644 --- a/shaders/composite3.fsh +++ b/shaders/composite3.fsh @@ -211,10 +211,11 @@ void main() { vec2 refractedCoord = texcoord; + /// --- REFRACTION --- /// #ifdef Refraction refractedCoord += (tangentNormals * clamp((ld(z2) - ld(z)) * 0.5,0.0,0.15)) * RENDER_SCALE; - if(decodeVec2(texture2D(colortex11,refractedCoord).b).g < 0.01 ) refractedCoord = texcoord; // remove refracted coords on solids + if( texture2D(colortex7,refractedCoord).a < 0.95 && decodeVec2(texture2D(colortex11,refractedCoord).b).g < 0.01 ) refractedCoord = texcoord; // remove refracted coords on solids #endif /// --- MAIN COLOR BUFFER --- /// diff --git a/shaders/gbuffers_all_particles.fsh b/shaders/gbuffers_all_particles.fsh index 8311cf5..0b6e99b 100644 --- a/shaders/gbuffers_all_particles.fsh +++ b/shaders/gbuffers_all_particles.fsh @@ -102,7 +102,7 @@ void main() { #endif #ifndef WEATHER - gl_FragData[1].a = pow(1.0-TEXTURE.a,2.0); // for bloomy rain + gl_FragData[1].a = 0.0; // for bloomy rain gl_FragData[0] = TEXTURE; vec3 Albedo = toLinear(gl_FragData[0].rgb); diff --git a/shaders/gbuffers_all_solid.fsh b/shaders/gbuffers_all_solid.fsh index fba5c46..e37efe9 100644 --- a/shaders/gbuffers_all_solid.fsh +++ b/shaders/gbuffers_all_solid.fsh @@ -3,8 +3,6 @@ #include "/lib/settings.glsl" - - flat varying int NameTags; #ifndef USE_LUMINANCE_AS_HEIGHTMAP @@ -80,6 +78,12 @@ in vec3 velocity; flat varying float blockID; flat varying int EMISSIVE; +#ifdef ENTITIES + #define ENTITY_PHYSICSMOD_SNOW 829925 +#endif + + + // float interleaved_gradientNoise(){ // return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y)+frameTimeCounter*51.9521); // } @@ -425,15 +429,20 @@ void main() { NormalTex.xy = NormalTex.xy*2.0-1.0; NormalTex.z = clamp(sqrt(1.0 - dot(NormalTex.xy, NormalTex.xy)),0.0,1.0) ; - normal = applyBump(tbnMatrix, NormalTex.xyz, mix(1.0,1.0-Puddle_shape,rainfall) ); + normal = applyBump(tbnMatrix, NormalTex.xyz, 1 ); #ifdef ENTITIES if(NameTags == 1) normal = vec3(1); #endif + #ifdef ENTITY_PHYSICSMOD_SNOW + normal = FlatNormals; + #endif + #endif #endif + //////////////////////////////// //////////////////////////////// SPECULAR //////////////////////////////// @@ -449,11 +458,20 @@ void main() { if(NameTags == 1) SpecularTex = vec4(0.0); #endif + #ifdef ENTITY_PHYSICSMOD_SNOW + SpecularTex.rg = vec2(0.0); + #endif + gl_FragData[2] = SpecularTex; #endif if(EMISSIVE > 0) gl_FragData[2].a = 0.9; - + + + + + + //////////////////////////////// //////////////////////////////// ALBEDO //////////////////////////////// diff --git a/shaders/gbuffers_all_solid.vsh b/shaders/gbuffers_all_solid.vsh index 5060c11..8f89ab9 100644 --- a/shaders/gbuffers_all_solid.vsh +++ b/shaders/gbuffers_all_solid.vsh @@ -131,12 +131,14 @@ vec3 blackbody2(float Temp) #define SEASONS_VSH #include "/lib/climate_settings.glsl" + //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// + void main() { gl_Position = ftransform(); @@ -148,9 +150,9 @@ void main() { // emission and shit... EMISSIVE = 0; - #ifndef LabPBR_Emissives - if(mc_Entity.x == 10005) EMISSIVE = 1; - #endif + // #ifndef LabPBR_Emissives + // if(mc_Entity.x == 10005) EMISSIVE = 1; + // #endif lmtexcoord.xy = (gl_MultiTexCoord0).xy; @@ -194,7 +196,7 @@ void main() { // normalMat.a = 0.45; - + // try and single out nametag text and then discard nametag background @@ -240,9 +242,14 @@ void main() { normalMat.a = 0.9; } + + + + gl_Position = toClipSpace3(position); #endif + NoSeasonCol.rgb = gl_Color.rgb; #ifdef Seasons diff --git a/shaders/gbuffers_all_translucent.fsh b/shaders/gbuffers_all_translucent.fsh index 91fb0e5..4b21f64 100644 --- a/shaders/gbuffers_all_translucent.fsh +++ b/shaders/gbuffers_all_translucent.fsh @@ -71,7 +71,6 @@ flat varying vec3 avgAmbient; #include "lib/diffuse_lighting.glsl" - float blueNoise(){ return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter); } @@ -151,6 +150,7 @@ vec3 viewToWorld(vec3 viewPosition) { pos = gbufferModelViewInverse * pos; return pos.xyz; } + vec3 worldToView(vec3 worldPos) { vec4 pos = vec4(worldPos, 0.0); pos = gbufferModelView * pos; @@ -290,6 +290,7 @@ if (gl_FragCoord.x * texelSize.x < RENDER_SCALE.x && gl_FragCoord.y * texelSize } #endif + vec4 COLORTEST = vec4(Albedo,gl_FragData[0].a); @@ -304,7 +305,18 @@ if (gl_FragCoord.x * texelSize.x < RENDER_SCALE.x && gl_FragCoord.y * texelSize tangent.z, tangent2.z, normal.z); - if (iswater > 0.4){ + + + /// ------ NORMALS ------ /// + + vec4 NormalTex = texture2D(normals, lmtexcoord.xy, Texture_MipMap_Bias).rgba; + NormalTex.xy = NormalTex.xy*2.0-1.0; + NormalTex.z = clamp(sqrt(1.0 - dot(NormalTex.xy, NormalTex.xy)),0.0,1.0) ; + TangentNormal = NormalTex.xy*0.5+0.5; + + normal = applyBump(tbnMatrix, NormalTex.xyz, 1.0); + + if (iswater > 0.95){ if(physics_iterationsNormal < 1.0){ float bumpmult = 1.; @@ -321,29 +333,26 @@ if (gl_FragCoord.x * texelSize.x < RENDER_SCALE.x && gl_FragCoord.y * texelSize bump = bump * vec3(bumpmult, bumpmult, bumpmult) + vec3(0.0f, 0.0f, 1.0f - bumpmult); normal = normalize(bump * tbnMatrix); - }else{ - vec3 PhysicsMod_normal = physics_waveNormal(physics_localPosition.xz, physics_localWaviness, physics_gameTime); + }else{ + /// ------ PHYSICS MOD OCEAN SHIT ------ /// - normal = normalize(worldToView(PhysicsMod_normal) + mix(normal, vec3(0.0), clamp(physics_localWaviness,0.0,1.0))); + WavePixelData wave = physics_wavePixel(physics_localPosition.xz, physics_localWaviness, physics_iterationsNormal, physics_gameTime); + // float Foam = wave.foam; - vec3 worldSpaceNormal = normal.xyz; + // Albedo = mix(Albedo,vec3(1),Foam); + // gl_FragData[0].a = Foam; + + + normal = normalize(worldToView(wave.normal) + mix(normal, vec3(0.0), clamp(physics_localWaviness,0.0,1.0))); + + vec3 worldSpaceNormal = normal; vec3 bitangent = normalize(cross(tangent.xyz, worldSpaceNormal)); mat3 tbn_new = mat3(tangent.xyz, binormal, worldSpaceNormal); vec3 tangentSpaceNormal = worldSpaceNormal * tbn_new; - TangentNormal = tangentSpaceNormal.xy ; + TangentNormal = tangentSpaceNormal.xy * 0.5 + 0.5; } - - }else{ - - vec4 NormalTex = texture2D(normals, lmtexcoord.xy, Texture_MipMap_Bias).rgba; - NormalTex.xy = NormalTex.xy*2.0-1.0; - NormalTex.z = clamp(sqrt(1.0 - dot(NormalTex.xy, NormalTex.xy)),0.0,1.0) ; - - TangentNormal = NormalTex.xy*0.5+0.5; - - normal = applyBump(tbnMatrix, NormalTex.xyz, 1.0); } // cannot encode alpha or it will shit its pants @@ -405,12 +414,19 @@ if (gl_FragCoord.x * texelSize.x < RENDER_SCALE.x && gl_FragCoord.y * texelSize vec2 SpecularTex = texture2D(specular, lmtexcoord.xy, Texture_MipMap_Bias).rg; - SpecularTex = (iswater > 0.0 && iswater < 0.9) && SpecularTex.r > 0.0 && SpecularTex.g < 0.9 ? SpecularTex : vec2(1.0,0.02); + + // SpecularTex = (iswater > 0.0 && iswater < 0.9) && SpecularTex.r > 0.0 && SpecularTex.g < 0.9 ? SpecularTex : vec2(1.0,0.1); - if (iswater > 0.0 && (SpecularTex.g > 0.0 || SpecularTex.r > 0.0)){ + + float roughness = max(pow(1.0-SpecularTex.r,2.0),0.05); + float f0 = SpecularTex.g; + + roughness = iswater > 0.95 ? 0.05 : roughness; + f0 = iswater > 0.95 ? 0.1 : f0; + + if (iswater > 0.0 ){ vec3 Reflections_Final = vec3(0.0); - float roughness = max(pow(1.0-SpecularTex.r,2.0),0.05); - float f0 = SpecularTex.g; + float F0 = f0; @@ -458,7 +474,7 @@ if (gl_FragCoord.x * texelSize.x < RENDER_SCALE.x && gl_FragCoord.y * texelSize //correct alpha channel with fresnel float alpha0 = gl_FragData[0].a; - gl_FragData[0].a = -gl_FragData[0].a*fresnel+gl_FragData[0].a+fresnel; + gl_FragData[0].a = mix(alpha0, 1.0, fresnel); if (gl_FragData[0].r > 65000.) gl_FragData[0].rgba = vec4(0.); diff --git a/shaders/gbuffers_all_translucent.vsh b/shaders/gbuffers_all_translucent.vsh index c61f3a0..5683f53 100644 --- a/shaders/gbuffers_all_translucent.vsh +++ b/shaders/gbuffers_all_translucent.vsh @@ -97,11 +97,11 @@ void main() { float mat = 0.0; - if(mc_Entity.x == 8.0 || mc_Entity.x == 9.0) { - mat = 1.0; + if(mc_Entity.x == 8.0) { + mat = 1.0; - gl_Position.z -= 1e-4; - } + gl_Position.z -= 1e-4; + } if (mc_Entity.x == 10002) mat = 0.2; if (mc_Entity.x == 72) mat = 0.5; diff --git a/shaders/gbuffers_spidereyes.fsh b/shaders/gbuffers_spidereyes.fsh index 56c23ac..a88dc73 100644 --- a/shaders/gbuffers_spidereyes.fsh +++ b/shaders/gbuffers_spidereyes.fsh @@ -20,7 +20,7 @@ vec3 toLinear(vec3 sRGB){ void main() { - vec3 albedo = (texture2D(texture, texcoord).rgb * color.rgb); + vec3 albedo = texture2D(texture, texcoord).rgb * color.rgb; gl_FragData[0].rgb = albedo; diff --git a/shaders/lib/oceans.glsl b/shaders/lib/oceans.glsl index 7a7f8c8..778a59a 100644 --- a/shaders/lib/oceans.glsl +++ b/shaders/lib/oceans.glsl @@ -5,8 +5,8 @@ // your shaderpack. It replaces this define statement (before compilation) with #define PHYSICS_OCEAN // so you can use -// #ifdef PHYSICS_OCEAN -// #endif +#ifdef PHYSICS_OCEAN +#endif // to customize the water for the physics ocean // just some basic consts for the wave function based on afl_ext's shader https://www.shadertoy.com/view/Xdlczl @@ -42,7 +42,20 @@ uniform float physics_oceanHeight; uniform sampler2D physics_waviness; // basic scale for the horizontal size of the waves uniform float physics_oceanWaveHorizontalScale; - +// used to offset the model to know the ripple position +uniform vec3 physics_modelOffset; +// used for offsetting the ripple texture +uniform float physics_rippleRange; +// controlling how much foam generates on the ocean +uniform float physics_foamAmount; +// controlling the opacity of the foam +uniform float physics_foamOpacity; +// texture containing the ripples (basic bump map) +uniform sampler2D physics_ripples; +// foam noise +uniform sampler3D physics_foam; +// just the generic minecraft lightmap, you can remove this and use the one supplied by Optifine/Iris +uniform sampler2D physics_lightmap; #ifdef PHYSICSMOD_VERTEX // for the vertex shader stage out vec3 physics_localPosition; @@ -54,6 +67,7 @@ uniform float physics_oceanWaveHorizontalScale; in vec3 physics_localPosition; in float physics_localWaviness; #endif + float physics_waveHeight(vec2 position, int iterations, float factor, float time) { position = (position - physics_waveOffset) * PHYSICS_XZ_SCALE * physics_oceanWaveHorizontalScale; float iter = 0.0; @@ -112,9 +126,98 @@ vec2 physics_waveDirection(vec2 position, int iterations, float time) { return vec2(dx / pow(waveSum, 1.0 - PHYSICS_W_DETAIL)); } -vec3 physics_waveNormal(vec2 position, float factor, float time) { +// vec3 physics_waveNormal(vec2 position, float factor, float time) { +// vec2 wave = -physics_waveDirection(position.xy, physics_iterationsNormal, time); +// float oceanHeightFactor = physics_oceanHeight / 13.0; +// float totalFactor = oceanHeightFactor * factor; +// return normalize(vec3(wave.x * totalFactor, PHYSICS_NORMAL_STRENGTH, wave.y * totalFactor)); +// } + +// thank you Null. not sure if this is legal though lmfao +vec3 physics_waveNormal_ripples(vec2 position, float factor, float time) { vec2 wave = -physics_waveDirection(position.xy, physics_iterationsNormal, time); float oceanHeightFactor = physics_oceanHeight / 13.0; float totalFactor = oceanHeightFactor * factor; - return normalize(vec3(wave.x * totalFactor, PHYSICS_NORMAL_STRENGTH, wave.y * totalFactor)); + vec3 waveNormal = normalize(vec3(wave.x * totalFactor, PHYSICS_NORMAL_STRENGTH, wave.y * totalFactor)); + + vec2 eyePosition = position + physics_modelOffset.xz; + vec2 rippleFetch = (eyePosition + vec2(physics_rippleRange)) / (physics_rippleRange * 2.0); + vec2 rippleTexelSize = vec2(2.0 / textureSize(physics_ripples, 0).x, 0.0); + float left = texture(physics_ripples, rippleFetch - rippleTexelSize.xy).r; + float right = texture(physics_ripples, rippleFetch + rippleTexelSize.xy).r; + float top = texture(physics_ripples, rippleFetch - rippleTexelSize.yx).r; + float bottom = texture(physics_ripples, rippleFetch + rippleTexelSize.yx).r; + float totalEffect = left + right + top + bottom; + + float normalx = left - right; + float normalz = top - bottom; + vec3 rippleNormal = normalize(vec3(normalx, 1.0, normalz)); + waveNormal = normalize(mix(waveNormal, rippleNormal, pow(totalEffect, 0.5))); + + return waveNormal; +} + + +struct WavePixelData { + vec2 direction; + vec2 worldPos; + vec3 normal; + float foam; + float height; +} wave; + +WavePixelData physics_wavePixel(const in vec2 position, const in float factor, const in float iterations, const in float time) { + vec2 wavePos = (position.xy - physics_waveOffset) * PHYSICS_XZ_SCALE * physics_oceanWaveHorizontalScale; + float iter = 0.0; + float frequency = PHYSICS_FREQUENCY; + float speed = PHYSICS_SPEED; + float weight = 1.0; + float height = 0.0; + float waveSum = 0.0; + float modifiedTime = time * PHYSICS_TIME_MULTIPLICATOR; + vec2 dx = vec2(0.0); + + for (int i = 0; i < iterations; i++) { + vec2 direction = vec2(sin(iter), cos(iter)); + float x = dot(direction, wavePos) * frequency + modifiedTime * speed; + float wave = exp(sin(x) - 1.0); + float result = wave * cos(x); + vec2 force = result * weight * direction; + + dx += force / pow(weight, PHYSICS_W_DETAIL); + wavePos -= force * PHYSICS_DRAG_MULT; + height += wave * weight; + iter += PHYSICS_ITER_INC; + waveSum += weight; + weight *= PHYSICS_WEIGHT; + frequency *= PHYSICS_FREQUENCY_MULT; + speed *= PHYSICS_SPEED_MULT; + } + + + WavePixelData data; + data.direction = -vec2(dx / pow(waveSum, 1.0 - PHYSICS_W_DETAIL)); + data.worldPos = wavePos / physics_oceanWaveHorizontalScale / PHYSICS_XZ_SCALE; + data.height = height / waveSum * physics_oceanHeight * factor - physics_oceanHeight * factor * 0.5; + data.normal = physics_waveNormal_ripples(position, factor, time); + + float waveAmplitude = data.height * pow(max(data.normal.y, 0.0), 4.0); + vec2 waterUV = mix(position - physics_waveOffset, data.worldPos, clamp(factor * 2.0, 0.2, 1.0)); + + vec2 s1 = textureLod(physics_foam, vec3(waterUV * 0.26, vec3(time) / 360.0), 0).rg; + vec2 s2 = textureLod(physics_foam, vec3(waterUV * 0.02, vec3(time) / 360.0 + 0.5), 0).rg; + vec2 s3 = textureLod(physics_foam, vec3(waterUV * 0.1, vec3(time) / 360.0 + 1.0), 0).rg; + + float waterSurfaceNoise = s1.r * s2.r * s3.r * 2.8 * physics_foamAmount; + waveAmplitude = clamp(waveAmplitude * 1.2, 0.0, 1.0); + waterSurfaceNoise = (1.0 - waveAmplitude) * waterSurfaceNoise + waveAmplitude * physics_foamAmount; + + float worleyNoise = 0.2 + 0.8 * s1.g * (1.0 - s2.g); + float waterFoamMinSmooth = 0.45; + float waterFoamMaxSmooth = 2.0; + waterSurfaceNoise = smoothstep(waterFoamMinSmooth, 1.0, waterSurfaceNoise) * worleyNoise; + + data.foam = clamp(waterFoamMaxSmooth * waterSurfaceNoise * physics_foamOpacity, 0.0, 1.0); + + return data; } \ No newline at end of file diff --git a/shaders/lib/volumetricClouds.glsl b/shaders/lib/volumetricClouds.glsl index 068e465..f11a4f3 100644 --- a/shaders/lib/volumetricClouds.glsl +++ b/shaders/lib/volumetricClouds.glsl @@ -323,7 +323,8 @@ float GetCloudShadow(vec3 eyePlayerPos){ shadow += GetAltostratusDensity(highShadowStart) * Alto_density; #endif - shadow = clamp(exp(-shadow*10.0),0.0,1.0); + shadow = shadow/2.0; // perhaps i should average the 2 shadows being added.... + shadow = clamp(exp(-shadow*15.0),0.0,1.0); return shadow; } @@ -342,6 +343,8 @@ float GetCloudShadow_VLFOG(vec3 WorldPos){ shadow += GetAltostratusDensity(highShadowStart) * Alto_density; #endif + // shadow = shadow/2.0; // perhaps i should average the 2 shadows being added.... + shadow = clamp(exp(-shadow*15.0),0.0,1.0); // do not allow it to exist above the lowest cloud plane