bring translucent shaders for nether and end up to speed

This commit is contained in:
Xonk
2023-08-02 21:43:18 -04:00
parent 7c5a4b39bd
commit cfc8722bc8
14 changed files with 862 additions and 654 deletions

View File

@ -254,6 +254,7 @@ vec3 worldToView(vec3 worldPos) {
}
void waterVolumetrics(inout vec3 inColor, vec3 rayStart, vec3 rayEnd, float estEndDepth, float estSunDepth, float rayLength, float dither, vec3 waterCoefs, vec3 scatterCoef, vec3 ambient){
inColor *= exp(-rayLength * waterCoefs); //No need to take the integrated value
int spCount = rayMarchSampleCount;
vec3 start = toShadowSpaceProjected(rayStart);
vec3 end = toShadowSpaceProjected(rayEnd);
@ -262,31 +263,38 @@ void waterVolumetrics(inout vec3 inColor, vec3 rayStart, vec3 rayEnd, float estE
//you can't see above this anyway
float maxZ = min(rayLength,12.0)/(1e-8+rayLength);
dV *= maxZ;
vec3 dVWorld = -mat3(gbufferModelViewInverse) * (rayEnd - rayStart) * maxZ;
rayLength *= maxZ;
float dY = normalize(mat3(gbufferModelViewInverse) * rayEnd).y * rayLength;
estEndDepth *= maxZ;
estSunDepth *= maxZ;
vec3 wpos = mat3(gbufferModelViewInverse) * rayStart + gbufferModelViewInverse[3].xyz;
vec3 dVWorld = (wpos-gbufferModelViewInverse[3].xyz);
vec3 absorbance = vec3(1.0);
vec3 vL = vec3(0.0);
float expFactor = 11.0;
vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition;
for (int i=0;i<spCount;i++) {
float d = (pow(expFactor, float(i+dither)/float(spCount))/expFactor - 1.0/expFactor)/(1-1.0/expFactor);
float dd = pow(expFactor, float(i+dither)/float(spCount)) * log(expFactor) / float(spCount)/(expFactor-1.0);
vec3 spPos = start.xyz + dV*d;
progressW = gbufferModelViewInverse[3].xyz+cameraPosition + d*dVWorld;
vec3 ambientMul = exp(-max(estEndDepth * d,0.0) * waterCoefs);
vec3 progressW = start.xyz+cameraPosition+dVWorld;
vec3 light = (ambientMul*ambient) * scatterCoef;
vec3 ambientMul = exp(-max(estEndDepth * d,0.0) * waterCoefs );
vec3 Indirectlight = ambientMul*ambient;
vL += (light - light * exp(-waterCoefs * dd * rayLength)) / waterCoefs *absorbance;
vec3 light = Indirectlight * scatterCoef;
vL += (light - light * exp(-waterCoefs * dd * rayLength)) / waterCoefs * absorbance;
absorbance *= exp(-dd * rayLength * waterCoefs);
}
inColor += vL;
}
void Emission(
@ -562,6 +570,8 @@ void main() {
bool hand = abs(dataUnpacked1.w-0.75) < 0.01;
// bool blocklights = abs(dataUnpacked1.w-0.8) <0.01;
vec3 waterAmbientLightCol = vec3(0.0);
if (z >=1.0) {
vec3 color = clamp(gl_Fog.color.rgb*pow(luma(gl_Fog.color.rgb),-0.75)*0.65,0.0,1.0)*0.02;
@ -580,6 +590,8 @@ void main() {
vec3 up = skyCloudsFromTexLOD2(vec3( 0, 1, 0), colortex4, 6).rgb / 10;
vec3 down = skyCloudsFromTexLOD2(vec3( 0,-1, 0), colortex4, 6).rgb / 10;
waterAmbientLightCol = down;
up *= pow( max( slopednormal.y, 0), 2);
down *= pow( max(-slopednormal.y, 0), 2);
AmbientLightColor += up + down;
@ -619,38 +631,21 @@ void main() {
// gl_FragData[0].rgb = AmbientLightColor;
}
// ////// border Fog
// if(Translucent_Programs > 0.0){
// vec3 fragpos = toScreenSpace(vec3(texcoord-vec2(0.0)*texelSize*0.5,z));
// float fogdistfade = 1.0 - clamp( exp(-pow(length(fragpos / far),2.)*5.0) ,0.0,1.0);
// gl_FragData[0].rgb = mix(gl_FragData[0].rgb, gl_Fog.color.rgb*0.5*NetherFog_brightness, fogdistfade) ;
// }
////// Water Fog
if ((isEyeInWater == 0 && iswater) || (isEyeInWater == 1 && !iswater)){
vec3 fragpos0 = toScreenSpace(vec3(texcoord-vec2(tempOffset)*texelSize*0.5,z0));
if (iswater && isEyeInWater == 0){
vec3 fragpos0 = toScreenSpace(vec3(texcoord/RENDER_SCALE-TAA_Offset*texelSize*0.5,z0));
float Vdiff = distance(fragpos,fragpos0);
if(isEyeInWater == 1) Vdiff = (length(fragpos));
float VdotU = np3.y;
float estimatedDepth = Vdiff; //assuming water plane
float estimatedSunDepth = estimatedDepth; //assuming water plane
float estimatedDepth = Vdiff * abs(VdotU) ; //assuming water plane
vec3 ambientColVol = vec3(1.0,0.25,0.5) * 0.33 ;
vec3 ambientColVol = max(vec3(1.0,0.5,1.0) * 0.3, vec3(0.2,0.4,1.0) * (MIN_LIGHT_AMOUNT*0.01 + nightVision));
waterVolumetrics(gl_FragData[0].rgb, fragpos0, fragpos, estimatedDepth , estimatedSunDepth, Vdiff, noise, totEpsilon, scatterCoef, ambientColVol);
waterVolumetrics(gl_FragData[0].rgb, fragpos0, fragpos, estimatedDepth , estimatedDepth, Vdiff, noise, totEpsilon, scatterCoef, ambientColVol);
}
// gl_FragData[0].rgb = SubsurfaceScattering_sky(albedo, Indirect_SSS, 1.0) * vec3(1);
/* DRAWBUFFERS:3 */
}

View File

@ -5,6 +5,7 @@
#include "/lib/settings.glsl"
flat varying float tempOffsets;
flat varying vec2 TAA_Offset;
uniform sampler2D noisetex;
uniform sampler2D depthtex0;
@ -42,6 +43,51 @@ float blueNoise(){
return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter);
}
void waterVolumetrics(inout vec3 inColor, vec3 rayStart, vec3 rayEnd, float estEndDepth, float estSunDepth, float rayLength, float dither, vec3 waterCoefs, vec3 scatterCoef, vec3 ambient){
inColor *= exp(-rayLength * waterCoefs); //No need to take the integrated value
int spCount = rayMarchSampleCount;
vec3 start = toShadowSpaceProjected(rayStart);
vec3 end = toShadowSpaceProjected(rayEnd);
vec3 dV = (end-start);
//limit ray length at 32 blocks for performance and reducing integration error
//you can't see above this anyway
float maxZ = min(rayLength,12.0)/(1e-8+rayLength);
dV *= maxZ;
rayLength *= maxZ;
float dY = normalize(mat3(gbufferModelViewInverse) * rayEnd).y * rayLength;
estEndDepth *= maxZ;
estSunDepth *= maxZ;
vec3 wpos = mat3(gbufferModelViewInverse) * rayStart + gbufferModelViewInverse[3].xyz;
vec3 dVWorld = (wpos-gbufferModelViewInverse[3].xyz);
vec3 absorbance = vec3(1.0);
vec3 vL = vec3(0.0);
float expFactor = 11.0;
for (int i=0;i<spCount;i++) {
float d = (pow(expFactor, float(i+dither)/float(spCount))/expFactor - 1.0/expFactor)/(1-1.0/expFactor);
float dd = pow(expFactor, float(i+dither)/float(spCount)) * log(expFactor) / float(spCount)/(expFactor-1.0);
vec3 spPos = start.xyz + dV*d;
vec3 progressW = start.xyz+cameraPosition+dVWorld;
vec3 ambientMul = exp(-max(estEndDepth * d,0.0) * waterCoefs );
vec3 Indirectlight = ambientMul*ambient;
vec3 light = Indirectlight * scatterCoef;
vL += (light - light * exp(-waterCoefs * dd * rayLength)) / waterCoefs * absorbance;
absorbance *= exp(-dd * rayLength * waterCoefs);
}
inColor += vL;
}
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
@ -54,16 +100,30 @@ float blueNoise(){
void main() {
/* DRAWBUFFERS:0 */
// if (isEyeInWater == 0){
vec2 tc = floor(gl_FragCoord.xy)*2.0*texelSize+0.5*texelSize;
float z = texture2D(depthtex0,tc).x;
vec3 fragpos = toScreenSpace(vec3(tc,z));
vec2 tc = floor(gl_FragCoord.xy)*2.0*texelSize+0.5*texelSize;
float z = texture2D(depthtex0,tc).x;
vec3 fragpos = toScreenSpace(vec3(tc,z));
if (isEyeInWater == 0){
vec4 VolumetricFog = GetVolumetricFog(fragpos, blueNoise());
gl_FragData[0] = clamp(VolumetricFog, 0.0, 65000.0);
// } else {
// gl_FragData[0] = vec4(0.0);
// }
} else {
float dirtAmount = Dirt_Amount;
vec3 waterEpsilon = vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B);
vec3 dirtEpsilon = vec3(Dirt_Absorb_R, Dirt_Absorb_G, Dirt_Absorb_B);
vec3 totEpsilon = dirtEpsilon*dirtAmount + waterEpsilon;
vec3 scatterCoef = dirtAmount * vec3(Dirt_Scatter_R, Dirt_Scatter_G, Dirt_Scatter_B) / 3.14;
vec3 fragpos0 = toScreenSpace(vec3(texcoord - TAA_Offset*texelSize*0.5,z));
vec3 ambientColVol = max(vec3(1.0,0.5,1.0) * 0.6, vec3(0.2,0.4,1.0) * MIN_LIGHT_AMOUNT*0.01);
gl_FragData[0].a = 1;
waterVolumetrics(gl_FragData[0].rgb, fragpos0, fragpos, 1 , 1, 1, blueNoise(), totEpsilon, scatterCoef, ambientColVol);
}
}

View File

@ -7,6 +7,16 @@ uniform int frameCounter;
#include "/lib/util.glsl"
flat varying vec2 TAA_Offset;
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//////////////////////////////
@ -17,6 +27,11 @@ void main() {
gl_Position = ftransform();
tempOffsets = HaltonSeq2(frameCounter%10000);
TAA_Offset = offsets[frameCounter%8];
#ifndef TAA
TAA_Offset = vec2(0.0);
#endif
gl_Position.xy = (gl_Position.xy*0.5+0.5)*0.51*2.0-1.0;
}

View File

@ -1,81 +1,121 @@
#version 120
//Horizontal bilateral blur for volumetric fog + Forward rendered objects + Draw volumetric fog
//#extension GL_EXT_gpu_shader4 : disable
#include "/lib/settings.glsl"
varying vec2 texcoord;
flat varying vec3 zMults;
flat varying vec2 TAA_Offset;
uniform sampler2D noisetex;
uniform sampler2D depthtex0;
uniform sampler2D depthtex1;
uniform sampler2D colortex13;
uniform sampler2D colortex11;
uniform sampler2D colortex7;
uniform sampler2D colortex3;
uniform sampler2D colortex4;
uniform sampler2D colortex2;
uniform sampler2D colortex0;
uniform sampler2D noisetex;
uniform sampler2D colortex1;
uniform sampler2D colortex2;
uniform sampler2D colortex3;
// uniform sampler2D colortex4;
uniform sampler2D colortex5;
uniform sampler2D colortex6;
uniform sampler2D colortex7;
uniform sampler2D colortex8;
uniform sampler2D colortex9;
uniform sampler2D colortex11;
uniform sampler2D colortex13;
uniform sampler2D colortex15;
uniform vec2 texelSize;
flat varying vec3 noooormal;
flat varying vec4 lightCol; //main light source color (rgb),used light source(1=sun,-1=moon)
flat varying vec3 WsunVec;
uniform vec3 sunVec;
uniform float frameTimeCounter;
uniform int frameCounter;
uniform float far;
uniform float near;
uniform mat4 gbufferModelViewInverse;
uniform mat4 gbufferProjectionInverse;
uniform mat4 gbufferModelView;
uniform vec2 texelSize;
uniform mat4 gbufferPreviousModelView;
uniform mat4 gbufferProjectionInverse;
uniform mat4 gbufferProjection;
uniform mat4 gbufferPreviousProjection;
uniform vec3 cameraPosition;
uniform vec3 previousCameraPosition;
uniform int isEyeInWater;
uniform ivec2 eyeBrightnessSmooth;
uniform float rainStrength;
uniform float blindness;
uniform float darknessFactor;
uniform float darknessLightFactor;
#include "/lib/waterBump.glsl"
#include "/lib/res_params.glsl"
#include "/lib/sky_gradient.glsl"
#include "/lib/volumetricClouds.glsl"
// #include "/lib/biome_specifics.glsl"
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz)
float ld(float depth) {
return 1.0 / (zMults.y - depth * zMults.z); // (-depth * (far - near)) = (2.0 * near)/ld - far - near
}
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz)
float luma(vec3 color) {
return dot(color,vec3(0.21, 0.72, 0.07));
}
vec3 toLinear(vec3 sRGB){
return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878);
}
vec3 toScreenSpace(vec3 p) {
vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw);
vec3 p3 = p * 2. - 1.;
vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3];
return fragposition.xyz / fragposition.w;
}
vec4 BilateralUpscale(sampler2D tex, sampler2D depth,vec2 coord,float frDepth){
// #include "/lib/specular.glsl"
vec4 BilateralUpscale(sampler2D tex, sampler2D depth,vec2 coord,float frDepth, vec2 distort){
coord = coord;
vec4 vl = vec4(0.0);
float sum = 0.0;
mat3x3 weights;
ivec2 posD = ivec2(coord/2.0)*2;
ivec2 posVl = ivec2(coord/2.0);
const ivec2 scaling = ivec2(1.0/VL_RENDER_RESOLUTION);
ivec2 posD = ivec2(coord*VL_RENDER_RESOLUTION + distort)*scaling;
ivec2 posVl = ivec2(coord*VL_RENDER_RESOLUTION + distort);
float dz = zMults.x;
ivec2 pos = (ivec2(gl_FragCoord.xy+frameCounter) % 2 )*2;
//pos = ivec2(1,-1);
ivec2 tcDepth = posD + ivec2(-4,-4) + pos*2;
ivec2 tcDepth = posD + ivec2(-2,-2) * scaling + pos * scaling;
float dsample = ld(texelFetch2D(depth,tcDepth,0).r);
float w = abs(dsample-frDepth) < dz ? 1.0 : 1e-5;
vl += texelFetch2D(tex,posVl+ivec2(-2)+pos,0)*w;
sum += w;
tcDepth = posD + ivec2(-4,0) + pos*2;
tcDepth = posD + ivec2(-2,0) * scaling + pos * scaling;
dsample = ld(texelFetch2D(depth,tcDepth,0).r);
w = abs(dsample-frDepth) < dz ? 1.0 : 1e-5;
vl += texelFetch2D(tex,posVl+ivec2(-2,0)+pos,0)*w;
sum += w;
tcDepth = posD + ivec2(0) + pos*2;
tcDepth = posD + ivec2(0) + pos * scaling;
dsample = ld(texelFetch2D(depth,tcDepth,0).r);
w = abs(dsample-frDepth) < dz ? 1.0 : 1e-5;
vl += texelFetch2D(tex,posVl+ivec2(0)+pos,0)*w;
sum += w;
tcDepth = posD + ivec2(0,-4) + pos*2;
tcDepth = posD + ivec2(0,-2) * scaling + pos * scaling;
dsample = ld(texelFetch2D(depth,tcDepth,0).r);
w = abs(dsample-frDepth) < dz ? 1.0 : 1e-5;
vl += texelFetch2D(tex,posVl+ivec2(0,-2)+pos,0)*w;
@ -92,7 +132,6 @@ vec3 decode (vec2 encn){
n.xy = n.z <= 0.0 ? (1.0 - n.yx) * sign(encn) : encn;
return clamp(normalize(n.xyz),-1.0,1.0);
}
vec2 decodeVec2(float a){
const vec2 constant1 = 65535. / vec2( 256., 65536.);
const float constant2 = 256. / 255.;
@ -104,100 +143,167 @@ vec3 worldToView(vec3 worldPos) {
pos = gbufferModelView * pos;
return pos.xyz;
}
float luma(vec3 color) {
return dot(color,vec3(0.21, 0.72, 0.07));
float blueNoise(){
return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter);
}
vec4 blueNoise(vec2 coord){
return texelFetch2D(colortex6, ivec2(coord )%512 , 0);
}
vec3 normVec (vec3 vec){
return vec*inversesqrt(dot(vec,vec));
}
float interleaved_gradientNoise(){
vec2 coord = gl_FragCoord.xy;
float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y));
return noise;
}
vec3 viewToWorld(vec3 viewPosition) {
vec4 pos;
pos.xyz = viewPosition;
pos.w = 0.0;
pos = gbufferModelViewInverse * pos;
return pos.xyz;
}
/// thanks stackoverflow https://stackoverflow.com/questions/944713/help-with-pixel-shader-effect-for-brightness-and-contrast#3027595
void applyContrast(inout vec3 color, float contrast){
color = ((color - 0.5) * max(contrast, 0.0)) + 0.5;
}
void main() {
/* DRAWBUFFERS:73 */
vec2 texcoord = gl_FragCoord.xy*texelSize;
vec4 trpData = texture2D(colortex7,texcoord);
bool iswater = trpData.a > 0.99;
float translucentAlpha = trpData.a;
// vec4 speculartex = texture2D(colortex8,texcoord); // translucents
// float sunlight = speculartex.b;
//3x3 bilateral upscale from half resolution
float z = texture2D(depthtex0,texcoord).x;
float z2 = texture2D(depthtex1,texcoord).x;
float frDepth = ld(z);
float glassdepth = clamp((ld(z2) - ld(z)) * 0.5,0.0,0.15);
float frDepth = ld(z2);
// vec4 vl = BilateralUpscale(colortex0,depthtex0,gl_FragCoord.xy,frDepth);
// vec4 vl = texture2D(colortex0,texcoord * 0.5);
////// --------------- UNPACK OPAQUE GBUFFERS --------------- //////
vec4 data_opaque = texture2D(colortex1,texcoord);
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 --------------- //////
vec3 data = texture2D(colortex11,texcoord).rgb;
vec4 unpack0 = vec4(decodeVec2(data.r),decodeVec2(data.g)) ;
vec4 unpack1 = vec4(decodeVec2(data.b),0,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(pow(eyeBrightnessSmooth.y/240.,2) ,0.0,1.0);
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);
vec2 refractedCoord = texcoord;
/// --- REFRACTION --- ///
#ifdef Refraction
refractedCoord += (tangentNormals * clamp((ld(z2) - ld(z)) * 0.5,0.0,0.15)) * RENDER_SCALE;
// refractedCoord += tangentNormals * 0.1 * RENDER_SCALE;
float refractedalpha = decodeVec2(texture2D(colortex11,refractedCoord).b).g;
float refractedalpha2 = texture2D(colortex7,refractedCoord).a;
if( refractedalpha <= 0.001 ||z < 0.56) refractedCoord = texcoord; // remove refracted coords on solids
#endif
/// --- MAIN COLOR BUFFER --- ///
// it is sampled with distorted texcoords
vec3 color = texture2D(colortex3,refractedCoord).rgb;
vec4 vl = BilateralUpscale(colortex0, depthtex1, gl_FragCoord.xy, frDepth, vec2(0.0));
float bloomyFogMult = 1.0;
vec4 Translucent_Programs = texture2D(colortex2,texcoord); // the shader for all translucent progams.
vec4 trpData = texture2D(colortex7,texcoord);
bool iswater = trpData.a > 0.99;
vec2 refractedCoord = texcoord;
vec2 data = texture2D(colortex11,texcoord).xy; // translucents
vec4 dataUnpacked0 = vec4(decodeVec2(data.x),decodeVec2(data.y));
vec3 normals = mat3(gbufferModelViewInverse) * worldToView(decode(dataUnpacked0.yw) );
vec4 vl = BilateralUpscale(colortex0,depthtex0,gl_FragCoord.xy,frDepth);
#ifdef Refraction
refractedCoord += normals.xy * glassdepth;
float refractedalpha = texture2D(colortex13,refractedCoord).a;
if(refractedalpha <= 0.0) refractedCoord = texcoord; // remove refracted coords on solids
#endif
vec3 color = texture2D(colortex3,refractedCoord).rgb;
if (Translucent_Programs.a > 0.0){
if (TranslucentShader.a > 0.0){
#ifdef Glass_Tint
vec3 GlassAlbedo = texture2D(colortex13,texcoord).rgb * 5.0;
color = color*GlassAlbedo.rgb + color * clamp(pow(1.0-luma(GlassAlbedo.rgb),10.),0.0,1.0);
if(albedo.a > 0.2) color = color*albedo.rgb + color * clamp(pow(1.0-luma(albedo.rgb),20.),0.0,1.0);
#endif
color = color*(1.0-Translucent_Programs.a) + Translucent_Programs.rgb;
color = color*(1.0-TranslucentShader.a) + TranslucentShader.rgb;
}
// if (isEyeInWater == 0){
// vec3 fragpos = toScreenSpace(vec3(texcoord-vec2(0.0)*texelSize*0.5,z));
// float fogdistfade = 1.0 - clamp( exp(-pow(length(fragpos / far),2.)*5.0) ,0.0,1.0);
// bloomyFogMult = 1.0 - fogdistfade*0.5 ;
// color.rgb = mix(color.rgb, gl_Fog.color.rgb*0.5*NetherFog_brightness, fogdistfade) ;
// }
color *= vl.a;
color += vl.rgb;
// underwater fog
if (isEyeInWater == 1){
vec3 fragpos = toScreenSpace(vec3(texcoord-vec2(0.0)*texelSize*0.5,z));
float fogfade = clamp(exp(-length(fragpos) /5. ) ,0.0,1.0);
bloomyFogMult *= fogfade*0.70+0.3 ;
float dirtAmount = Dirt_Amount;
vec3 waterEpsilon = vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B);
vec3 dirtEpsilon = vec3(Dirt_Absorb_R, Dirt_Absorb_G, Dirt_Absorb_B);
vec3 totEpsilon = dirtEpsilon*dirtAmount + waterEpsilon;
// float fogfade = clamp( exp(length(fragpos) / -20) ,0.0,1.0);
// vec3 fogfade = clamp( exp( (length(fragpos) / -4) * totEpsilon ) ,0.0,1.0);
vec3 fogfade = clamp( exp( (-length(fragpos)) * totEpsilon ) ,0.0,1.0);
fogfade *= 1.0 - clamp( length(fragpos) / far,0.0,1.0);
color.rgb *= fogfade ;
bloomyFogMult *= 0.4;
}
// apply VL fog to the scene
color *= vl.a;
color += vl.rgb;
// bloomy rain effect
float rainDrops = clamp(texture2D(colortex9,texcoord).a, 0.0,1.0);
if(rainDrops > 0.0) bloomyFogMult *= clamp(1.0 - pow(rainDrops*5.0,2),0.0,1.0);
/// lava.
if (isEyeInWater == 2){
color.rgb = vec3(4.0,0.5,0.1);
}
/// powdered snow
if (isEyeInWater == 3){
vec3 fragpos = toScreenSpace(vec3(texcoord-vec2(0.0)*texelSize*0.5,z));
color.rgb = mix(color.rgb,vec3(10,15,20),clamp(length(fragpos)*0.5,0.,1.));
bloomyFogMult = 0.0;
}
// blidnesss
if (blindness > 0.0){
vec3 fragpos = toScreenSpace(vec3(texcoord-vec2(0.0)*texelSize*0.5,z));
color.rgb *= mix(1.0,clamp( exp(pow(length(fragpos)*(blindness*0.2),2) * -5),0.,1.) , blindness);
}
color.rgb *= mix(1.0,clamp( exp(pow(length(fragpos)*(blindness*0.2),2) * -1),0.,1.) , blindness);
// darkness effect
if(darknessFactor > 0.0){
vec3 fragpos = toScreenSpace(vec3(texcoord-vec2(0.0)*texelSize*0.5,z2));
color.rgb *= mix(1.0, (1.0-darknessLightFactor*2.0) * clamp(1.0-pow(length(fragpos)*(darknessFactor*0.07),2.0),0.0,1.0), darknessFactor);
}
gl_FragData[0].r = vl.a * bloomyFogMult;
color.rgb *= mix(1.0, (1.0-darknessLightFactor*2.0) * clamp(1.0-pow(length(fragpos2)*(darknessFactor*0.07),2.0),0.0,1.0), darknessFactor);
#ifdef display_LUT
vec2 movedTC = texcoord;
vec3 thingy = texture2D(colortex4,movedTC).rgb / 150. * 5.0;
if(luma(thingy) > 0.0 ) color.rgb = thingy;
#endif
gl_FragData[1].rgb = clamp(color,6.11*1e-5,65000.0);
}
gl_FragData[0].r = vl.a * bloomyFogMult; // pass fog alpha so bloom can do bloomy fog
gl_FragData[1].rgb = clamp(color.rgb,0.0,68000.0);
}

View File

@ -1,3 +1,4 @@
#version 120
#define NETHER
#include "/programs/all_translucent.fsh"