mirror of
https://github.com/X0nk/Bliss-Shader.git
synced 2025-06-19 23:57:22 +08:00
FIX stochastic shadows on IRIS. add filter option for SSAO and all SSS types. imrpove fog upsampling (even when DH is being used). ambient light is more consistent across all types of weather. tweak cloud lighting.
This commit is contained in:
parent
f99a3c33b5
commit
088b8206c1
@ -233,6 +233,7 @@ float ld(float dist) {
|
||||
/* RENDERTARGETS:2,7 */
|
||||
void main() {
|
||||
|
||||
if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) {
|
||||
bool iswater = isWater > 0;
|
||||
|
||||
vec3 normals = normals_and_materials.xyz;
|
||||
@ -263,10 +264,12 @@ void main() {
|
||||
|
||||
vec4 COLORTEST = gl_FragData[0];
|
||||
|
||||
#ifndef Vanilla_like_water
|
||||
if(iswater){
|
||||
Albedo = vec3(0.0);
|
||||
gl_FragData[0].a = 1.0/255.0;
|
||||
}
|
||||
#endif
|
||||
|
||||
// diffuse
|
||||
vec3 Direct_lighting = lightCol.rgb/80.0;
|
||||
@ -351,8 +354,9 @@ void main() {
|
||||
|
||||
float material = 1.0;
|
||||
#ifdef DH_OVERDRAW_PREVENTION
|
||||
float distancefade = min(max(1.0 - length(pos.xz)/far,0.0)*2.0,1.0);
|
||||
float distancefade = min(max(1.0 - length(pos.xz)/max(far-16.0,0.0),0.0)*2.0,1.0);
|
||||
gl_FragData[0].a = mix(gl_FragData[0].a, 0.0, distancefade);
|
||||
|
||||
material = distancefade < 1.0 ? 1.0 : 0.0;
|
||||
|
||||
if(texture2D(depthtex1, gl_FragCoord.xy*texelSize).x < 1.0){
|
||||
@ -360,10 +364,12 @@ void main() {
|
||||
material = 0.0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if DEBUG_VIEW == debug_DH_WATER_BLENDING
|
||||
|
||||
|
||||
#if DEBUG_VIEW == debug_DH_WATER_BLENDING
|
||||
if(gl_FragCoord.x*texelSize.x > 0.53) gl_FragData[0] = vec4(0.0);
|
||||
#endif
|
||||
|
||||
|
||||
gl_FragData[1] = vec4(Albedo, material);
|
||||
}
|
||||
}
|
@ -16,10 +16,11 @@ flat varying vec4 lightCol;
|
||||
varying mat4 normalmatrix;
|
||||
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform mat4 gbufferModelView;
|
||||
|
||||
flat varying vec3 WsunVec;
|
||||
flat varying vec3 WsunVec2;
|
||||
|
||||
uniform mat4 dhProjection;
|
||||
uniform vec3 sunPosition;
|
||||
uniform float sunElevation;
|
||||
|
||||
@ -34,17 +35,36 @@ const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
|
||||
vec2(-7.,-1.)/8.,
|
||||
vec2(3,7.)/8.,
|
||||
vec2(7.,-7.)/8.);
|
||||
|
||||
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
|
||||
#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz)
|
||||
vec4 toClipSpace3(vec3 viewSpacePosition) {
|
||||
return vec4(projMAD(dhProjection, viewSpacePosition),-viewSpacePosition.z);
|
||||
}
|
||||
|
||||
void main() {
|
||||
gl_Position = ftransform();
|
||||
|
||||
vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz;
|
||||
|
||||
pos = gl_ModelViewMatrix * gl_Vertex;
|
||||
|
||||
|
||||
isWater = 0;
|
||||
if (dhMaterialId == DH_BLOCK_WATER){
|
||||
isWater = 1;
|
||||
gl_Position.y -= 6.0/16.0;
|
||||
gl_Position.z -= 1e-4;
|
||||
|
||||
// offset water to not look like a full cube
|
||||
vec3 worldpos = mat3(gbufferModelViewInverse) * position + gbufferModelViewInverse[3].xyz ;
|
||||
worldpos.y -= 1.8/16.0;
|
||||
position = mat3(gbufferModelView) * worldpos + gbufferModelView[3].xyz;
|
||||
|
||||
}
|
||||
|
||||
gl_Position = toClipSpace3(position);
|
||||
|
||||
normals_and_materials = vec4(normalize(gl_Normal), 1.0);
|
||||
|
||||
gcolor = gl_Color;
|
||||
@ -73,5 +93,4 @@ void main() {
|
||||
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
|
||||
#endif
|
||||
|
||||
pos = gl_ModelViewMatrix * gl_Vertex;
|
||||
}
|
@ -95,11 +95,8 @@ uniform float noPuddleAreas;
|
||||
// float interleaved_gradientNoise(){
|
||||
// return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y)+frameTimeCounter*51.9521);
|
||||
// }
|
||||
float interleaved_gradientNoise_temp(){
|
||||
vec2 alpha = vec2(0.75487765, 0.56984026);
|
||||
vec2 coord = vec2(alpha.x * gl_FragCoord.x,alpha.y * gl_FragCoord.y)+ 1.0/1.6180339887 * frameCounter;
|
||||
float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y));
|
||||
return noise;
|
||||
float interleaved_gradientNoise_temporal(){
|
||||
return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y)+frameTimeCounter*51.9521);
|
||||
}
|
||||
float interleaved_gradientNoise(){
|
||||
vec2 coord = gl_FragCoord.xy;
|
||||
@ -281,13 +278,15 @@ vec4 texture2D_POMSwitch(
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
varying vec3 pos;
|
||||
#ifdef HAND
|
||||
/* RENDERTARGETS: 1,7,8,15,2 */
|
||||
#else
|
||||
/* RENDERTARGETS: 1,7,8,15 */
|
||||
#endif
|
||||
void main() {
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
bool ifPOM = false;
|
||||
|
||||
@ -311,6 +310,14 @@ void main() {
|
||||
vec3 fragpos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0));
|
||||
vec3 worldpos = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz + cameraPosition;
|
||||
|
||||
// #ifdef DH_OVERDRAW_PREVENTION
|
||||
// // overdraw prevention
|
||||
// if(clamp(1.0-length(pos.xyz)/max(far,0.0),0.0,1.0) <= 0.0 ){
|
||||
// discard;
|
||||
// return;
|
||||
// }
|
||||
// #endif
|
||||
|
||||
float torchlightmap = lmtexcoord.z;
|
||||
|
||||
#ifdef Hand_Held_lights
|
||||
|
@ -182,6 +182,7 @@ float luma(vec3 color) {
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
|
||||
varying vec3 pos;
|
||||
void main() {
|
||||
|
||||
gl_Position = ftransform();
|
||||
@ -189,6 +190,7 @@ void main() {
|
||||
|
||||
vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz;
|
||||
|
||||
pos = position;
|
||||
/////// ----- COLOR STUFF ----- ///////
|
||||
color = gl_Color;
|
||||
|
||||
|
@ -30,6 +30,9 @@ const bool colortex4MipmapEnabled = true;
|
||||
uniform sampler2D noisetex;
|
||||
uniform sampler2D depthtex1;
|
||||
uniform sampler2D depthtex0;
|
||||
uniform sampler2D dhDepthTex1;
|
||||
uniform sampler2D colortex12;
|
||||
uniform sampler2D colortex14;
|
||||
uniform sampler2D colortex5;
|
||||
|
||||
uniform sampler2D texture;
|
||||
@ -307,8 +310,11 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
||||
//////////////////////////////// ALBEDO
|
||||
////////////////////////////////
|
||||
|
||||
|
||||
|
||||
gl_FragData[0] = texture2D(texture, lmtexcoord.xy, Texture_MipMap_Bias) * color;
|
||||
|
||||
|
||||
|
||||
|
||||
vec3 Albedo = toLinear(gl_FragData[0].rgb);
|
||||
float UnchangedAlpha = gl_FragData[0].a;
|
||||
@ -607,17 +613,22 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
||||
gl_FragData[0].a = mix(gl_FragData[0].a, 1.0, fresnel);
|
||||
#endif
|
||||
|
||||
#ifdef DISTANT_HORIZONS
|
||||
gl_FragData[0].a = mix(gl_FragData[0].a, 0.0, 1.0-min(max(1.0 - length(feetPlayerPos.xz)/far,0.0)*2.0,1.0) );
|
||||
#endif
|
||||
|
||||
} else {
|
||||
|
||||
gl_FragData[0].rgb = FinalColor;
|
||||
}
|
||||
|
||||
#else
|
||||
gl_FragData[0].rgb = FinalColor;
|
||||
#endif
|
||||
|
||||
// gl_FragData[0].rgb = vec3(1) * (texelFetch2D(depthtex0,ivec2(gl_FragCoord.xy),0).x - texelFetch2D(dhDepthTex1,ivec2(gl_FragCoord.xy),0).x);
|
||||
|
||||
|
||||
#if defined DISTANT_HORIZONS && defined DH_OVERDRAW_PREVENTION
|
||||
gl_FragData[0].a = mix(gl_FragData[0].a, 0.0, 1.0-min(max(1.0 - length(feetPlayerPos.xz)/max(far,0.0),0.0)*2.0,1.0) );
|
||||
#endif
|
||||
|
||||
#ifndef HAND
|
||||
gl_FragData[1] = vec4(Albedo, iswater);
|
||||
|
@ -13,6 +13,7 @@ uniform sampler2D dhDepthTex1;
|
||||
uniform sampler2D colortex1;
|
||||
uniform sampler2D colortex6; // Noise
|
||||
uniform sampler2D colortex8; // Noise
|
||||
uniform sampler2D colortex14; // Noise
|
||||
uniform sampler2D colortex15; // Noise
|
||||
uniform sampler2D shadow;
|
||||
uniform sampler2D noisetex;
|
||||
@ -77,12 +78,13 @@ vec2 tapLocation2(int sampleNumber, int nb, float jitter){
|
||||
|
||||
return vec2(cos_v, sin_v)*sqrt(alpha);
|
||||
}
|
||||
float interleaved_gradientNoise_temporal(){
|
||||
return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y)+frameTimeCounter*51.9521);
|
||||
}
|
||||
float interleaved_gradientNoise(){
|
||||
vec2 coord = gl_FragCoord.xy + (frameCounter%40000);
|
||||
// vec2 coord = gl_FragCoord.xy + frameTimeCounter;
|
||||
// vec2 coord = gl_FragCoord.xy;
|
||||
float noise = fract( 52.9829189 * fract( (coord.x * 0.06711056) + (coord.y * 0.00583715)) );
|
||||
return noise ;
|
||||
vec2 coord = gl_FragCoord.xy;
|
||||
float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y));
|
||||
return noise;
|
||||
}
|
||||
vec3 decode (vec2 encn){
|
||||
vec3 n = vec3(0.0);
|
||||
@ -136,12 +138,15 @@ vec2 tapLocation_simple(
|
||||
|
||||
return vec2(cos_v, sin_v) * sqrt(alpha);
|
||||
}
|
||||
|
||||
vec2 SpiralSample(
|
||||
int samples, int totalSamples, float rotation, float Xi
|
||||
){
|
||||
Xi = max(Xi,0.0015);
|
||||
|
||||
float alpha = float(samples + Xi) * (1.0 / float(totalSamples));
|
||||
|
||||
float theta = 3.14159265359 * alpha * rotation ;
|
||||
float theta = (2.0 *3.14159265359) * alpha * rotation;
|
||||
|
||||
float r = sqrt(Xi);
|
||||
float x = r * sin(theta);
|
||||
@ -150,6 +155,23 @@ vec2 SpiralSample(
|
||||
return vec2(x, y);
|
||||
}
|
||||
|
||||
vec3 cosineHemisphereSample(vec2 Xi){
|
||||
float theta = 2.0 * 3.14159265359 * Xi.y;
|
||||
|
||||
float r = sqrt(Xi.x);
|
||||
float x = r * cos(theta);
|
||||
float y = r * sin(theta);
|
||||
|
||||
return vec3(x, y, sqrt(clamp(1.0 - Xi.x,0.,1.)));
|
||||
}
|
||||
|
||||
vec3 rodSample(vec2 Xi)
|
||||
{
|
||||
float r = sqrt(Xi.x);
|
||||
float phi = 2 * 3.14159265359 * Xi.y;
|
||||
|
||||
return normalize(vec3(cos(phi) * r, sin(phi) * r, sqrt(clamp(1.0 - Xi.x,0.,1.)))).xzy;
|
||||
}
|
||||
|
||||
|
||||
#include "/lib/DistantHorizons_projections.glsl"
|
||||
@ -165,16 +187,105 @@ float linearizeDepthFast(const in float depth, const in float near, const in flo
|
||||
return (near * far) / (depth * (near - far) + far);
|
||||
}
|
||||
|
||||
vec2 SSAO(
|
||||
vec3 viewPos, vec3 normal, bool hand, bool leaves, float noise
|
||||
){
|
||||
if(hand) return vec2(1.0,0.0);
|
||||
int samples = 7;
|
||||
float occlusion = 0.0;
|
||||
float sss = 0.0;
|
||||
|
||||
|
||||
/* DRAWBUFFERS:3 */
|
||||
void main() {
|
||||
vec2 texcoord = gl_FragCoord.xy*texelSize;
|
||||
float dist = 1.0 + clamp(viewPos.z*viewPos.z/50.0,0,5); // shrink sample size as distance increases
|
||||
float mulfov2 = gbufferProjection[1][1]/(3 * dist);
|
||||
float maxR2 = viewPos.z*viewPos.z*mulfov2*2.*5/50.0;
|
||||
|
||||
#ifdef Ambient_SSS
|
||||
float maxR2_2 = viewPos.z*viewPos.z*mulfov2*2.*2./50.0;
|
||||
|
||||
float dist3 = clamp(1-exp( viewPos.z*viewPos.z / -50),0,1);
|
||||
if(leaves) maxR2_2 = mix(10, maxR2_2, dist3);
|
||||
#endif
|
||||
|
||||
vec2 acc = -(TAA_Offset*(texelSize/2))*RENDER_SCALE ;
|
||||
|
||||
|
||||
int n = 0;
|
||||
for (int i = 0; i < samples; i++) {
|
||||
|
||||
vec2 sampleOffset = SpiralSample(i, 7, 8, noise) * clamp(0.05 + i*0.095, 0.0,0.3) * mulfov2;
|
||||
|
||||
ivec2 offset = ivec2(gl_FragCoord.xy + sampleOffset*vec2(viewWidth,viewHeight*aspectRatio)*RENDER_SCALE);
|
||||
|
||||
if (offset.x >= 0 && offset.y >= 0 && offset.x < viewWidth*RENDER_SCALE.x && offset.y < viewHeight*RENDER_SCALE.y ) {
|
||||
#ifdef DISTANT_HORIZONS
|
||||
float dhdepth = texelFetch2D(dhDepthTex1, offset,0).x;
|
||||
#else
|
||||
float dhdepth = 0.0;
|
||||
#endif
|
||||
|
||||
vec3 t0 = toScreenSpace_DH((offset*texelSize+acc+0.5*texelSize) * (1.0/RENDER_SCALE), texelFetch2D(depthtex1, offset,0).x, dhdepth);
|
||||
vec3 vec = (t0.xyz - viewPos);
|
||||
float dsquared = dot(vec, vec);
|
||||
|
||||
if (dsquared > 1e-5){
|
||||
if (dsquared < maxR2){
|
||||
float NdotV = clamp(dot(vec*inversesqrt(dsquared), normalize(normal)),0.,1.);
|
||||
occlusion += NdotV * clamp(1.0-dsquared/maxR2,0.0,1.0);
|
||||
}
|
||||
|
||||
#ifdef Ambient_SSS
|
||||
if(dsquared > maxR2_2){
|
||||
float NdotV = 1.0 - clamp(dot(vec*dsquared, normalize(normal)),0.,1.);
|
||||
sss += max((NdotV - (1.0-NdotV)) * clamp(1.0-maxR2_2/dsquared,0.0,1.0) ,0.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
n += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return max(1.0 - vec2(occlusion, sss)/n, 0.0);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
float z = texture2D(depthtex1,texcoord).x;
|
||||
float DH_depth1 = texture2D(depthtex1,texcoord).x;
|
||||
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));
|
||||
}
|
||||
|
||||
// #include "/lib/indirect_lighting_effects.glsl"
|
||||
|
||||
#ifdef DENOISE_SSS_AND_SSAO
|
||||
/* RENDERTARGETS:3,14,12*/
|
||||
#else
|
||||
/* RENDERTARGETS:3*/
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
float noise = R2_dither();
|
||||
|
||||
vec2 texcoord = gl_FragCoord.xy*texelSize;
|
||||
|
||||
float z = texture2D(depthtex1,texcoord).x;
|
||||
float DH_depth1 = texture2D(dhDepthTex1,texcoord).x;
|
||||
|
||||
vec3 viewPos = toScreenSpace_DH(texcoord/RENDER_SCALE - TAA_Offset*texelSize*0.5, z, DH_depth1);
|
||||
|
||||
|
||||
vec2 tempOffset=TAA_Offset;
|
||||
|
||||
vec4 data = texture2D(colortex1,texcoord);
|
||||
vec4 dataUnpacked0 = vec4(decodeVec2(data.x),decodeVec2(data.y));
|
||||
@ -183,35 +294,66 @@ void main() {
|
||||
vec2 lightmap = dataUnpacked1.yz;
|
||||
|
||||
|
||||
|
||||
|
||||
// bool lightningBolt = abs(dataUnpacked1.w-0.5) <0.01;
|
||||
// bool isLeaf = abs(dataUnpacked1.w-0.55) <0.01;
|
||||
bool isLeaf = abs(dataUnpacked1.w-0.55) <0.01;
|
||||
// bool translucent2 = abs(dataUnpacked1.w-0.6) <0.01; // Weak translucency
|
||||
// bool translucent4 = abs(dataUnpacked1.w-0.65) <0.01; // Weak translucency
|
||||
bool entities = abs(dataUnpacked1.w-0.45) < 0.01;
|
||||
bool hand = abs(dataUnpacked1.w-0.75) < 0.01;
|
||||
// bool blocklights = abs(dataUnpacked1.w-0.8) <0.01;
|
||||
|
||||
|
||||
#ifdef DENOISE_SSS_AND_SSAO
|
||||
float depth = z;
|
||||
|
||||
#ifdef DISTANT_HORIZONS
|
||||
float _near = near;
|
||||
float _far = far*4.0;
|
||||
if (depth >= 1.0) {
|
||||
depth = DH_depth1;
|
||||
_near = dhNearPlane;
|
||||
_far = dhFarPlane;
|
||||
}
|
||||
|
||||
depth = linearizeDepthFast(depth, _near, _far);
|
||||
depth = depth / dhFarPlane;
|
||||
#endif
|
||||
|
||||
if(depth < 1.0)
|
||||
gl_FragData[2] = vec4(vec3(0.0), depth * depth * 65000.0);
|
||||
else
|
||||
gl_FragData[2] = vec4(vec3(0.0), 65000.0);
|
||||
|
||||
|
||||
vec3 FlatNormals = texture2D(colortex15,texcoord).rgb * 2.0 - 1.0;
|
||||
|
||||
if(z >= 1.0){
|
||||
FlatNormals = worldToView(normal);
|
||||
}
|
||||
|
||||
|
||||
gl_FragData[1] = vec4(0.0,0.0,0.0,texture2D(colortex14,texcoord).a);
|
||||
gl_FragData[1].xy = SSAO(viewPos, FlatNormals, hand, isLeaf, noise);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
float SpecularTex = texture2D(colortex8,texcoord).z;
|
||||
float LabSSS = clamp((-64.0 + SpecularTex * 255.0) / 191.0 ,0.0,1.0);
|
||||
|
||||
float NdotL = clamp(dot(normal,WsunVec),0.0,1.0);
|
||||
float vanillAO = clamp(texture2D(colortex15,texcoord).a,0.0,1.0) ;
|
||||
|
||||
float minshadowfilt = Min_Shadow_Filter_Radius;
|
||||
float maxshadowfilt = Max_Shadow_Filter_Radius;
|
||||
|
||||
float NdotL = clamp(dot(normal,WsunVec),0.0,1.0);
|
||||
|
||||
// vec4 normalAndAO = texture2D(colortex15,texcoord);
|
||||
// vec3 FlatNormals = normalAndAO.rgb * 2.0 - 1.0;
|
||||
// float vanillAO = clamp(normalAndAO.a,0.0,1.0) ;
|
||||
|
||||
float vanillAO = clamp(texture2D(colortex15,texcoord).a,0.0,1.0) ;
|
||||
|
||||
if(lightmap.y < 0.1 && !entities){
|
||||
// minshadowfilt *= vanillAO;
|
||||
maxshadowfilt = mix(minshadowfilt, maxshadowfilt, vanillAO);
|
||||
}
|
||||
|
||||
|
||||
float SpecularTex = texture2D(colortex8,texcoord).z;
|
||||
float LabSSS = clamp((-64.0 + SpecularTex * 255.0) / 191.0 ,0.0,1.0);
|
||||
|
||||
#ifndef Variable_Penumbra_Shadows
|
||||
if (LabSSS > 0.0 && !hand && NdotL < 0.001) minshadowfilt += 50;
|
||||
#endif
|
||||
@ -219,15 +361,14 @@ void main() {
|
||||
if (z < 1.0 && !hand){
|
||||
|
||||
gl_FragData[0] = vec4(minshadowfilt, 0.1, 0.0, 0.0);
|
||||
gl_FragData[0].y = 0;
|
||||
gl_FragData[0].a = 0;
|
||||
|
||||
// vec3 viewPos = toScreenSpace(vec3(texcoord/RENDER_SCALE-vec2(tempOffset)*texelSize*0.5,z));
|
||||
|
||||
vec3 viewPos = toScreenSpace_DH(texcoord/RENDER_SCALE-vec2(tempOffset)*texelSize*0.5, z, DH_depth1);
|
||||
|
||||
#ifdef Variable_Penumbra_Shadows
|
||||
|
||||
if (LabSSS > 0.0) {
|
||||
if (LabSSS > 0.0 || NdotL > 0.0001) {
|
||||
|
||||
|
||||
vec3 feetPlayerPos = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz;
|
||||
@ -258,13 +399,9 @@ void main() {
|
||||
float diffthreshM = diffthresh*mult*d0*k/20.;
|
||||
float avgDepth = 0.0;
|
||||
|
||||
// int seed = (frameCounter%40000) + frameCounter*2;
|
||||
// float noise = fract(R2_samples(seed).y + blueNoise(gl_FragCoord.xy).y);
|
||||
float noise = R2_dither();
|
||||
|
||||
for(int i = 0; i < VPS_Search_Samples; i++){
|
||||
|
||||
vec2 offsetS = SpiralSample(i, 7, 8, noise);
|
||||
vec2 offsetS = SpiralSample(i, 7, 8, noise) * 0.5;
|
||||
|
||||
|
||||
float weight = 3.0 + (i+noise) *rdMul/SHADOW_FILTER_SAMPLE_COUNT*shadowMapResolution*distortFactor/2.7;
|
||||
@ -281,6 +418,7 @@ void main() {
|
||||
|
||||
gl_FragData[0].g = avgDepth / VPS_Search_Samples;
|
||||
gl_FragData[0].b = blockerCount / VPS_Search_Samples;
|
||||
|
||||
if (blockerCount >= 0.9){
|
||||
avgBlockerDepth /= blockerCount;
|
||||
float ssample = max(projectedShadowPosition.z - avgBlockerDepth,0.0)*1500.0;
|
||||
|
@ -607,6 +607,46 @@ vec3 getViewPos() {
|
||||
}
|
||||
|
||||
|
||||
vec4 BilateralUpscale_DH(sampler2D tex, sampler2D depth, vec2 coord, float referenceDepth, bool depthCheck){
|
||||
|
||||
const ivec2 scaling = ivec2(1.0);
|
||||
ivec2 posDepth = ivec2(coord)*scaling;
|
||||
ivec2 posColor = ivec2(coord);
|
||||
|
||||
// vec2 pos = mod(coord,2)*2 - 1;
|
||||
ivec2 pos = ivec2(coord*texelSize) + 1;
|
||||
// ivec2 pos = (ivec2(gl_FragCoord.xy) % 2 )*2;
|
||||
|
||||
ivec2 getRadius[4] = ivec2[](
|
||||
ivec2(-2,-2),
|
||||
ivec2(-2, 0),
|
||||
ivec2( 0, 0),
|
||||
ivec2( 0,-2)
|
||||
);
|
||||
|
||||
// float diffThreshold = referenceDepth;
|
||||
|
||||
float diffThreshold = 0.0002;
|
||||
|
||||
vec4 RESULT = vec4(0.0);
|
||||
float SUM = 0.0;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
|
||||
ivec2 radius = getRadius[i];
|
||||
|
||||
float offsetDepth = sqrt(texelFetch2D(depth, (posDepth + radius * scaling + pos * scaling),0).a/65000.0);
|
||||
|
||||
float EDGES = abs(offsetDepth - referenceDepth) < diffThreshold ? 1.0 : 1e-5;
|
||||
|
||||
RESULT += texelFetch2D(tex, (posColor + radius + pos),0) * EDGES;
|
||||
|
||||
SUM += EDGES;
|
||||
}
|
||||
|
||||
return RESULT / SUM;
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
vec3 DEBUG = vec3(1.0);
|
||||
@ -768,8 +808,15 @@ void main() {
|
||||
|
||||
|
||||
vec3 filteredShadow = vec3(1.412,1.0,0.0);
|
||||
if (!hand) filteredShadow = texture2D(colortex3,texcoord).rgb;
|
||||
|
||||
#ifdef DENOISE_SSS_AND_SSAO
|
||||
if (!hand) filteredShadow = BilateralUpscale_SSAO(colortex3, depthtex0, gl_FragCoord.xy, ld(z0)).rgb;
|
||||
#else
|
||||
if (!hand) filteredShadow = texture2D(colortex3,texcoord).rgb;
|
||||
#endif
|
||||
|
||||
float ShadowBlockerDepth = filteredShadow.y;
|
||||
|
||||
|
||||
Shadows = clamp(1.0 - filteredShadow.b,0.0,1.0);
|
||||
shadowMap = Shadows;
|
||||
@ -873,6 +920,8 @@ void main() {
|
||||
projectedShadowPosition = projectedShadowPosition * vec3(0.5,0.5,0.5/6.0) + vec3(0.5);
|
||||
|
||||
float biasOffset = 0.0;
|
||||
if(hand) biasOffset = -0.00035;
|
||||
|
||||
#ifdef BASIC_SHADOW_FILTER
|
||||
float rdMul = filteredShadow.x*distortFactor*d0*k/shadowMapResolution;
|
||||
|
||||
@ -967,7 +1016,15 @@ void main() {
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if indirect_effect == 1
|
||||
vec2 SSAO_SSS = SSAO(viewPos, FlatNormals, hand, isLeaf, noise);
|
||||
#ifdef DENOISE_SSS_AND_SSAO
|
||||
#ifdef DISTANT_HORIZONS
|
||||
vec2 SSAO_SSS = BilateralUpscale_DH(colortex14, colortex12, gl_FragCoord.xy, sqrt(texture2D(colortex12,texcoord).a/65000.0), z >= 1.0).xy;
|
||||
#else
|
||||
vec2 SSAO_SSS = BilateralUpscale_SSAO(colortex14, depthtex0, gl_FragCoord.xy, ld(z)).xy;
|
||||
#endif
|
||||
#else
|
||||
vec2 SSAO_SSS = SSAO(viewPos, FlatNormals, hand, isLeaf, noise_2);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined OVERWORLD_SHADER && (indirect_effect == 0 || indirect_effect == 1)
|
||||
@ -1053,7 +1110,8 @@ void main() {
|
||||
|
||||
#if indirect_effect == 1
|
||||
vec3 AO = vec3( exp( (vanilla_AO*vanilla_AO) * -3) );
|
||||
AO *= SSAO_SSS.x*SSAO_SSS.x;
|
||||
|
||||
AO *= SSAO_SSS.x*SSAO_SSS.x*SSAO_SSS.x;
|
||||
SkySSS = SSAO_SSS.y;
|
||||
|
||||
Indirect_lighting *= AO;
|
||||
@ -1167,7 +1225,7 @@ void main() {
|
||||
|
||||
|
||||
vec3 lightningColor = (lightningEffect / 3) * (max(eyeBrightnessSmooth.y,0)/240.);
|
||||
vec3 ambientColVol = max((averageSkyCol_Clouds / 30.0) * custom_lightmap_T, vec3(0.2,0.4,1.0) * (MIN_LIGHT_AMOUNT*0.01 + nightVision)) ;
|
||||
vec3 ambientColVol = max((averageSkyCol_Clouds / 30.0) * custom_lightmap_T , vec3(0.2,0.4,1.0) * (MIN_LIGHT_AMOUNT*0.01 + nightVision)) ;
|
||||
|
||||
waterVolumetrics(gl_FragData[0].rgb, viewPos0, viewPos, estimatedDepth, estimatedSunDepth, Vdiff, noise_2, totEpsilon, scatterCoef, ambientColVol, lightColVol, dot(feetPlayerPos_normalized, WsunVec));
|
||||
}
|
||||
@ -1184,8 +1242,7 @@ void main() {
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// gl_FragData[0].rgb = vec3(1) * (abs(ld(texture2D(depthtex0,texcoord + vec2(0.001,0)).r) - ld(z0)) < (1.0/(far * near))*0.1 ? 1.0 : 1e-5 );
|
||||
|
||||
//////// DEBUG VIEW STUFF
|
||||
#if DEBUG_VIEW == debug_SHADOWMAP
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
flat varying vec3 zMults;
|
||||
flat varying vec3 zMults_DH;
|
||||
|
||||
flat varying vec2 TAA_Offset;
|
||||
flat varying vec3 skyGroundColor;
|
||||
@ -9,6 +10,7 @@ uniform sampler2D noisetex;
|
||||
uniform sampler2D depthtex0;
|
||||
uniform sampler2D depthtex1;
|
||||
uniform sampler2D dhDepthTex;
|
||||
uniform sampler2D dhDepthTex1;
|
||||
|
||||
|
||||
uniform sampler2D colortex0;
|
||||
@ -22,7 +24,7 @@ uniform sampler2D colortex8;
|
||||
uniform sampler2D colortex9;
|
||||
uniform sampler2D colortex10;
|
||||
uniform sampler2D colortex11;
|
||||
// uniform sampler2D colortex12;
|
||||
uniform sampler2D colortex12;
|
||||
uniform sampler2D colortex13;
|
||||
uniform sampler2D colortex15;
|
||||
uniform vec2 texelSize;
|
||||
@ -109,45 +111,121 @@ float linearizeDepthFast(const in float depth, const in float near, const in flo
|
||||
|
||||
|
||||
|
||||
vec4 BilateralUpscale(sampler2D tex, sampler2D depth,vec2 coord,float frDepth){
|
||||
coord = coord;
|
||||
vec4 vl = vec4(0.0);
|
||||
float sum = 0.0;
|
||||
mat3x3 weights;
|
||||
const ivec2 scaling = ivec2(1.0/VL_RENDER_RESOLUTION);
|
||||
ivec2 posD = ivec2(coord*VL_RENDER_RESOLUTION)*scaling;
|
||||
ivec2 posVl = ivec2(coord*VL_RENDER_RESOLUTION);
|
||||
float dz = zMults.x;
|
||||
ivec2 pos = (ivec2(gl_FragCoord.xy) % 2 )*2;
|
||||
//pos = ivec2(1,-1);
|
||||
vec4 BilateralUpscale(sampler2D tex, sampler2D depth, vec2 coord, float referenceDepth){
|
||||
|
||||
const ivec2 scaling = ivec2(1.0/VL_RENDER_RESOLUTION);
|
||||
ivec2 posDepth = ivec2(coord*VL_RENDER_RESOLUTION)*scaling;
|
||||
ivec2 posColor = ivec2(coord*VL_RENDER_RESOLUTION);
|
||||
|
||||
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;
|
||||
// vec2 pos = mod(coord,2)*2 - 1;
|
||||
ivec2 pos = ivec2((coord*texelSize) + 1.0);
|
||||
// ivec2 pos = (ivec2(gl_FragCoord.xy) % 2 )*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;
|
||||
ivec2 getRadius[4] = ivec2[](
|
||||
ivec2(-2,-2),
|
||||
ivec2(-2, 0),
|
||||
ivec2( 0, 0),
|
||||
ivec2( 0,-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;
|
||||
float diffThreshold = zMults.x;
|
||||
|
||||
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;
|
||||
sum += w;
|
||||
vec4 RESULT = vec4(0.0);
|
||||
float SUM = 0.0;
|
||||
|
||||
return vl/sum;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
|
||||
ivec2 radius = getRadius[i];
|
||||
|
||||
float offsetDepth = ld(texelFetch2D(depth, (posDepth + radius * scaling + pos * scaling),0).r);
|
||||
|
||||
float EDGES = abs(offsetDepth - referenceDepth) < diffThreshold ? 1.0 : 1e-5;
|
||||
|
||||
RESULT += texelFetch2D(tex, (posColor + radius + pos),0) * EDGES;
|
||||
|
||||
SUM += EDGES;
|
||||
}
|
||||
|
||||
return RESULT / SUM;
|
||||
|
||||
|
||||
// coord = coord;
|
||||
// vec4 vl = vec4(0.0);
|
||||
// float sum = 0.0;
|
||||
// mat3x3 weights;
|
||||
// const ivec2 scaling = ivec2(1.0/VL_RENDER_RESOLUTION);
|
||||
// ivec2 posD = ivec2(coord*VL_RENDER_RESOLUTION)*scaling;
|
||||
// ivec2 posVl = ivec2(coord*VL_RENDER_RESOLUTION);
|
||||
// float dz = zMults.x;
|
||||
// ivec2 pos = (ivec2(gl_FragCoord.xy) % 2 )*2;
|
||||
// //pos = ivec2(1,-1);
|
||||
|
||||
// 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(-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 * 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,-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;
|
||||
// sum += w;
|
||||
|
||||
// return vl/sum;
|
||||
}
|
||||
|
||||
vec4 BilateralUpscale_DH(sampler2D tex, sampler2D depth, vec2 coord, float referenceDepth, bool depthCheck){
|
||||
|
||||
const ivec2 scaling = ivec2(1.0/VL_RENDER_RESOLUTION);
|
||||
ivec2 posDepth = ivec2(coord*VL_RENDER_RESOLUTION)*scaling;
|
||||
ivec2 posColor = ivec2(coord*VL_RENDER_RESOLUTION);
|
||||
|
||||
// vec2 pos = mod(coord,2)*2 - 1;
|
||||
ivec2 pos = ivec2(coord*texelSize) + 1;
|
||||
// ivec2 pos = (ivec2(gl_FragCoord.xy) % 2 )*2;
|
||||
|
||||
ivec2 getRadius[4] = ivec2[](
|
||||
ivec2(-2,-2),
|
||||
ivec2(-2, 0),
|
||||
ivec2( 0, 0),
|
||||
ivec2( 0,-2)
|
||||
);
|
||||
|
||||
// float diffThreshold = referenceDepth;
|
||||
|
||||
float diffThreshold = zMults_DH.x;
|
||||
|
||||
vec4 RESULT = vec4(0.0);
|
||||
float SUM = 0.0;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
|
||||
ivec2 radius = getRadius[i];
|
||||
|
||||
float offsetDepth = sqrt(texelFetch2D(depth, (posDepth + radius * scaling + pos * scaling),0).a/65000.0);
|
||||
|
||||
float EDGES = abs(offsetDepth - referenceDepth) < diffThreshold ? 1.0 : 1e-5;
|
||||
|
||||
RESULT += texelFetch2D(tex, (posColor + radius + pos),0) * EDGES;
|
||||
|
||||
SUM += EDGES;
|
||||
}
|
||||
|
||||
return RESULT / SUM;
|
||||
}
|
||||
vec3 decode (vec2 encn){
|
||||
vec3 n = vec3(0.0);
|
||||
encn = encn * 2.0 - 1.0;
|
||||
@ -222,24 +300,24 @@ void main() {
|
||||
float frDepth = ld(z2);
|
||||
|
||||
float swappedDepth = z;
|
||||
|
||||
#ifdef DISTANT_HORIZONS
|
||||
float DH_depth0 = texture2D(dhDepthTex,texcoord).x;
|
||||
float depthOpaque = z;
|
||||
float depthOpaqueL = linearizeDepthFast(depthOpaque, near, farPlane);
|
||||
|
||||
#ifdef DISTANT_HORIZONS
|
||||
float dhDepthOpaque = DH_depth0;
|
||||
float dhDepthOpaqueL = linearizeDepthFast(dhDepthOpaque, dhNearPlane, dhFarPlane);
|
||||
if (depthOpaque >= 1.0 || (dhDepthOpaqueL < depthOpaqueL && dhDepthOpaque > 0.0)){
|
||||
depthOpaque = dhDepthOpaque;
|
||||
depthOpaqueL = dhDepthOpaqueL;
|
||||
}
|
||||
#endif
|
||||
float dhDepthOpaque = DH_depth0;
|
||||
float dhDepthOpaqueL = linearizeDepthFast(dhDepthOpaque, dhNearPlane, dhFarPlane);
|
||||
if (depthOpaque >= 1.0 || (dhDepthOpaqueL < depthOpaqueL && dhDepthOpaque > 0.0)){
|
||||
depthOpaque = dhDepthOpaque;
|
||||
depthOpaqueL = dhDepthOpaqueL;
|
||||
}
|
||||
|
||||
swappedDepth = depthOpaque;
|
||||
#else
|
||||
float DH_depth0 = 0.0;
|
||||
#endif
|
||||
swappedDepth = depthOpaque;
|
||||
|
||||
#else
|
||||
float DH_depth0 = 0.0;
|
||||
#endif
|
||||
|
||||
vec3 fragpos = toScreenSpace_DH(texcoord/RENDER_SCALE-vec2(TAA_Offset)*texelSize*0.5, z, DH_depth0);
|
||||
|
||||
@ -274,7 +352,12 @@ void main() {
|
||||
float translucentAlpha = trpData;
|
||||
|
||||
////// --------------- get volumetrics
|
||||
vec4 vl = BilateralUpscale(colortex0, depthtex1, gl_FragCoord.xy, frDepth);
|
||||
#ifdef DISTANT_HORIZONS
|
||||
vec4 vl = BilateralUpscale_DH(colortex0, colortex12, gl_FragCoord.xy, sqrt(texture2D(colortex12,texcoord).a/65000.0), z >= 1.0);
|
||||
#else
|
||||
vec4 vl = BilateralUpscale(colortex0, depthtex0, gl_FragCoord.xy, frDepth);
|
||||
#endif
|
||||
|
||||
float bloomyFogMult = 1.0;
|
||||
|
||||
////// --------------- distort texcoords as a refraction effect
|
||||
@ -410,6 +493,7 @@ void main() {
|
||||
vl.a = 1.0;
|
||||
}
|
||||
#endif
|
||||
// color.rgb = vec3(1) * sqrt(texture2D(colortex12,texcoord).a/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);
|
||||
|
@ -2,8 +2,11 @@
|
||||
|
||||
varying vec2 texcoord;
|
||||
flat varying vec3 zMults;
|
||||
flat varying vec3 zMults_DH;
|
||||
uniform float far;
|
||||
uniform float near;
|
||||
uniform float dhFarPlane;
|
||||
uniform float dhNearPlane;
|
||||
|
||||
flat varying vec2 TAA_Offset;
|
||||
uniform int framemod8;
|
||||
@ -37,6 +40,8 @@ void main() {
|
||||
TAA_Offset = offsets[framemod8];
|
||||
|
||||
zMults = vec3(1.0/(far * near),far+near,far-near);
|
||||
zMults_DH = vec3(1.0/(dhFarPlane * dhNearPlane),dhFarPlane+dhNearPlane,dhFarPlane-dhNearPlane);
|
||||
|
||||
gl_Position = ftransform();
|
||||
texcoord = gl_MultiTexCoord0.xy;
|
||||
|
||||
|
@ -16,7 +16,7 @@ const int colortex11Format = RGBA16; // unchanged translucents albedo, alpha
|
||||
|
||||
const int colortex12Format = RGBA16F; // DISTANT HORIZONS + VANILLA MIXED DEPTHs
|
||||
|
||||
const int colortex14Format = RGBA8; // a = skylightmap for translucents.
|
||||
const int colortex14Format = RGBA8; // rg = SSAO and SS-SSS. a = skylightmap for translucents.
|
||||
const int colortex15Format = RGBA8; // flat normals and vanilla AO
|
||||
*/
|
||||
|
||||
@ -35,7 +35,7 @@ const bool colortex10Clear = true;
|
||||
const bool colortex11Clear = true;
|
||||
const bool colortex12Clear = false;
|
||||
const bool colortex13Clear = false;
|
||||
const bool colortex14Clear = true;
|
||||
const bool colortex14Clear = false;
|
||||
const bool colortex15Clear = false;
|
||||
|
||||
|
||||
|
@ -137,9 +137,13 @@ void main() {
|
||||
}
|
||||
|
||||
// only need to sample one spot for this
|
||||
// averageSkyCol_Clouds = max(averageSkyCol_Clouds * (1.0/(luma(averageSkyCol_Clouds)*0.25+0.75)), minimumlight);
|
||||
// averageSkyCol = max(averageSkyCol*PLANET_GROUND_BRIGHTNESS, minimumlight);
|
||||
|
||||
// maximum control of color and luminance
|
||||
vec3 minimumlight = vec3(0.2,0.4,1.0) * (MIN_LIGHT_AMOUNT*0.003 + nightVision);
|
||||
averageSkyCol_Clouds = max(averageSkyCol_Clouds * (1.0/(luma(averageSkyCol_Clouds)*0.25+0.75)), minimumlight);
|
||||
averageSkyCol = max(averageSkyCol*PLANET_GROUND_BRIGHTNESS, minimumlight);
|
||||
averageSkyCol_Clouds = max( normalize(averageSkyCol_Clouds) * min(luma(averageSkyCol_Clouds) * 3.0,3.0), minimumlight);
|
||||
averageSkyCol = max( normalize(averageSkyCol) * min(luma(averageSkyCol) * 3.0,3.0) * PLANET_GROUND_BRIGHTNESS, minimumlight);
|
||||
|
||||
////////////////////////////////////////
|
||||
/// --- SUNLIGHT/MOONLIGHT STUFF --- ///
|
||||
|
@ -102,6 +102,7 @@ void main() {
|
||||
|
||||
vec4 VolumetricClouds = renderClouds(viewPos, vec2(R2_dither(),blueNoise2()), sunColor/80.0, averageSkyCol/30.0);
|
||||
|
||||
// gl_FragData[0] = vec4(0.0,0.0,0.0,1.0);
|
||||
gl_FragData[0] = VolumetricClouds;
|
||||
|
||||
|
||||
|
@ -20,13 +20,14 @@ vec3 TangentToWorld(vec3 N, vec3 H, float roughness){
|
||||
|
||||
return vec3((T * H.x) + (B * H.y) + (N * H.z));
|
||||
}
|
||||
|
||||
vec2 SpiralSample(
|
||||
int samples, int totalSamples, float rotation, float Xi
|
||||
){
|
||||
Xi = max(Xi,0.0015);
|
||||
|
||||
float alpha = float(samples + Xi) * (1.0 / float(totalSamples));
|
||||
|
||||
float theta = 3.14159265359 * alpha * rotation ;
|
||||
float theta = (2.0 *3.14159265359) * alpha * rotation;
|
||||
|
||||
float r = sqrt(Xi);
|
||||
float x = r * sin(theta);
|
||||
@ -39,6 +40,42 @@ vec2 SpiralSample(
|
||||
///////////////////////////// SSAO ////////////////////////
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
vec4 BilateralUpscale_SSAO(sampler2D tex, sampler2D depth, vec2 coord, float referenceDepth){
|
||||
const ivec2 scaling = ivec2(1.0);
|
||||
ivec2 posDepth = ivec2(coord)*scaling;
|
||||
ivec2 posColor = ivec2(coord);
|
||||
|
||||
ivec2 pos = ivec2(coord*texelSize);
|
||||
|
||||
ivec2 getRadius[4] = ivec2[](
|
||||
ivec2(-2,-2),
|
||||
ivec2(-2, 0),
|
||||
ivec2( 0, 0),
|
||||
ivec2( 0,-2)
|
||||
);
|
||||
|
||||
float diffThreshold = 0.005;
|
||||
|
||||
vec4 RESULT = vec4(0.0);
|
||||
float SUM = 0.0;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
|
||||
ivec2 radius = getRadius[i];
|
||||
|
||||
float offsetDepth = ld(texelFetch2D(depth, (posDepth + radius * scaling + pos * scaling),0).r);
|
||||
|
||||
float EDGES = abs(offsetDepth - referenceDepth) < diffThreshold ? 1.0 : 1e-5;
|
||||
|
||||
RESULT += texelFetch2D(tex, (posColor + radius + pos),0) * EDGES;
|
||||
|
||||
SUM += EDGES;
|
||||
}
|
||||
|
||||
return RESULT / SUM;
|
||||
|
||||
}
|
||||
|
||||
vec2 SSAO(
|
||||
vec3 viewPos, vec3 normal, bool hand, bool leaves, float noise
|
||||
){
|
||||
@ -64,7 +101,9 @@ vec2 SSAO(
|
||||
int n = 0;
|
||||
for (int i = 0; i < samples; i++) {
|
||||
|
||||
vec2 sampleOffset = SpiralSample(i, 7, 8, noise) * 0.2 * mulfov2;
|
||||
// vec2 sampleOffset = SpiralSample(i, 7, 8, noise) * 0.2 * mulfov2;
|
||||
|
||||
vec2 sampleOffset = SpiralSample(i, 7, 8, noise) * clamp(0.05 + i*0.095, 0.0,0.3) * mulfov2;
|
||||
|
||||
ivec2 offset = ivec2(gl_FragCoord.xy + sampleOffset*vec2(viewWidth,viewHeight*aspectRatio)*RENDER_SCALE);
|
||||
|
||||
|
@ -165,13 +165,16 @@ vec4 GetVolumetricFog(
|
||||
float mieDayMulti = (phaseg(SdotV, 0.35) + phaseg(-SdotV, 0.35) * 0.5) ;
|
||||
|
||||
vec3 directScattering = LightSourceColor * mieDay * 3.14;
|
||||
vec3 directMultiScattering = LightSourceColor * mieDayMulti * 4.0;
|
||||
vec3 directMultiScattering = LightSourceColor * mieDayMulti * 3.14;
|
||||
|
||||
vec3 sunIndirectScattering = LightSourceColor * phaseg(dot(mat3(gbufferModelView)*vec3(0,1,0),normalize(viewPosition)), 0.5) * 3.14;
|
||||
#endif
|
||||
float RLmult = 3.0;
|
||||
|
||||
|
||||
#ifdef DISTANT_HORIZONS
|
||||
RLmult = 1.0;
|
||||
float atmosphereMult = 1.0;
|
||||
#else
|
||||
float atmosphereMult = 2.0;
|
||||
#endif
|
||||
|
||||
float expFactor = 11.0;
|
||||
@ -181,6 +184,8 @@ vec4 GetVolumetricFog(
|
||||
progress = start.xyz + d*dV;
|
||||
progressW = gbufferModelViewInverse[3].xyz+cameraPosition + d*dVWorld;
|
||||
|
||||
// float curvature = 1-exp(-25*pow(clamp(1.0 - length(progressW - cameraPosition)/(32*80),0.0,1.0),2));
|
||||
|
||||
//project into biased shadowmap space
|
||||
#ifdef DISTORT_SHADOWMAP
|
||||
float distortFactor = calcDistort(progress.xy);
|
||||
@ -198,6 +203,7 @@ vec4 GetVolumetricFog(
|
||||
float sh2 = sh;
|
||||
|
||||
#ifdef VL_CLOUDS_SHADOWS
|
||||
// if(clamp(progressW.y - CloudLayer1_height,0.0,1.0) < 1.0 && clamp(progressW.y-50,0.0,1.0) > 0.0)
|
||||
sh *= GetCloudShadow_VLFOG(progressW, WsunVec);
|
||||
#endif
|
||||
|
||||
@ -214,18 +220,18 @@ vec4 GetVolumetricFog(
|
||||
///// ----- main fog lighting
|
||||
|
||||
//Just air
|
||||
vec2 airCoef = exp(-max(progressW.y - SEA_LEVEL, 0.0) / vec2(8.0e3, 1.2e3) * vec2(6.,7.0)) * 24.0 * Haze_amount * clamp(CloudLayer0_height - progressW.y + max(eyeAltitude-(CloudLayer0_height-50),0),0.0,1.0);
|
||||
vec2 airCoef = exp(-max(progressW.y - SEA_LEVEL, 0.0) / vec2(8.0e3, 1.2e3) * vec2(6.,7.0)) * (atmosphereMult * 24.0) * Haze_amount * clamp(CloudLayer0_height - progressW.y + max(eyeAltitude-(CloudLayer0_height-50),0),0.0,1.0);
|
||||
|
||||
//Pbr for air, yolo mix between mie and rayleigh for water droplets
|
||||
vec3 rL = rC*airCoef.x;
|
||||
vec3 m = (airCoef.y+density) * mC;
|
||||
|
||||
#ifdef PER_BIOME_ENVIRONMENT
|
||||
vec3 Atmosphere = mix(skyLightPhased, biomeDirect, maxDistance) * (rL*RLmult + m); // not pbr so just make the atmosphere also dense fog heh
|
||||
vec3 DirectLight = mix(LightSourcePhased, biomeIndirect, maxDistance) * sh * ((rL*RLmult)*rayL + m);
|
||||
vec3 Atmosphere = mix(skyLightPhased, biomeDirect, maxDistance) * (rL + m); // not pbr so just make the atmosphere also dense fog heh
|
||||
vec3 DirectLight = mix(LightSourcePhased, biomeIndirect, maxDistance) * sh * (rL*rayL + m);
|
||||
#else
|
||||
vec3 Atmosphere = skyLightPhased * (rL*RLmult + m); // not pbr so just make the atmosphere also dense fog heh
|
||||
vec3 DirectLight = LightSourcePhased * sh * ((rL*RLmult)*rayL + m);
|
||||
vec3 Atmosphere = skyLightPhased * (rL + m); // not pbr so just make the atmosphere also dense fog heh
|
||||
vec3 DirectLight = LightSourcePhased * sh * (rL*rayL + m);
|
||||
#endif
|
||||
vec3 Lightning = Iris_Lightningflash_VLfog(progressW-cameraPosition, lightningBoltPosition.xyz) * (rL + m);
|
||||
|
||||
@ -240,51 +246,57 @@ vec4 GetVolumetricFog(
|
||||
//////////////////////////////////////////
|
||||
///// ----- cloud part
|
||||
//////////////////////////////////////////
|
||||
// curvature = clamp(1.0 - length(progressW - cameraPosition)/(32*128),0.0,1.0);
|
||||
|
||||
|
||||
float otherlayer = max(progressW.y - (CloudLayer0_height+99.5), 0.0) > 0.0 ? 0.0 : 1.0;
|
||||
|
||||
float DUAL_MIN_HEIGHT = otherlayer > 0.0 ? CloudLayer0_height : CloudLayer1_height;
|
||||
float DUAL_MAX_HEIGHT = DUAL_MIN_HEIGHT + 100.0;
|
||||
|
||||
float DUAL_DENSITY = otherlayer > 0.0 ? CloudLayer0_density : CloudLayer1_density;
|
||||
|
||||
|
||||
float Density = otherlayer > 0.0 ? CloudLayer0_density : CloudLayer1_density;
|
||||
|
||||
float cumulus = GetCumulusDensity(-1, progressW, 1, DUAL_MIN_HEIGHT, DUAL_MAX_HEIGHT);
|
||||
if(clamp(progressW.y - DUAL_MAX_HEIGHT,0.0,1.0) < 1.0 && clamp(progressW.y - DUAL_MIN_HEIGHT,0.0,1.0) > 0.0){
|
||||
|
||||
float BASE_FADE = Density * clamp(exp( (progressW.y - (DUAL_MAX_HEIGHT - 75)) / 9.0 ),0.0,1.0);
|
||||
float DUAL_MIN_HEIGHT_2 = otherlayer > 0.0 ? CloudLayer0_height : CloudLayer1_height;
|
||||
float DUAL_MAX_HEIGHT_2 = DUAL_MIN_HEIGHT + 100.0;
|
||||
|
||||
if(cumulus > 1e-5){
|
||||
float muE = cumulus * BASE_FADE ;
|
||||
float directLight = 0.0;
|
||||
for (int j=0; j < 3; j++){
|
||||
float cumulus = GetCumulusDensity(-1, progressW, 1, CloudLayer0_height, CloudLayer1_height);
|
||||
float fadedDensity = DUAL_DENSITY * clamp(exp( (progressW.y - (DUAL_MAX_HEIGHT - 75)) / 9.0 ),0.0,1.0);
|
||||
|
||||
vec3 shadowSamplePos = progressW + dV_Sun * (0.1 + j * (0.1 + dither.y*0.05));
|
||||
float shadow = GetCumulusDensity(-1, shadowSamplePos, 0, DUAL_MIN_HEIGHT, DUAL_MAX_HEIGHT) * Density;
|
||||
float muE = cumulus*fadedDensity;
|
||||
float directLight = 0.0;
|
||||
for (int j=0; j < 3; j++){
|
||||
vec3 shadowSamplePos = progressW + dV_Sun * (0.1 + j * (0.1 + dither.y*0.05));
|
||||
float shadow = GetCumulusDensity(-1, shadowSamplePos, 0, DUAL_MIN_HEIGHT, DUAL_MAX_HEIGHT) * DUAL_DENSITY;
|
||||
|
||||
directLight += shadow;
|
||||
}
|
||||
|
||||
#if defined CloudLayer1 && defined CloudLayer0
|
||||
if(otherlayer > 0) directLight += CloudLayer1_density * 2.0 * GetCumulusDensity(1, progressW + dV_Sun/abs(dV_Sun.y) * max(((CloudLayer1_height+100)-70) - progressW.y,0.0), 0, CloudLayer1_height, CloudLayer1_height+100);
|
||||
#endif
|
||||
|
||||
#if defined CloudLayer1 && defined CloudLayer0
|
||||
float upperLayerOcclusion = otherlayer < 1 ? CloudLayer1_density * 2.0 * GetCumulusDensity(1, progressW + vec3(0.0,1.0,0.0) * max(((CloudLayer1_height+100)-70) - progressW.y,0.0), 0, CloudLayer1_height, CloudLayer1_height+100) : 0.0;
|
||||
float skylightOcclusion = max(exp2((upperLayerOcclusion*upperLayerOcclusion) * -5), 0.75);
|
||||
#else
|
||||
float skylightOcclusion = 1.0;
|
||||
#endif
|
||||
|
||||
float skyScatter = clamp((DUAL_MAX_HEIGHT - 20 - progressW.y) / 275.0,0.0,1.0);
|
||||
vec3 cloudlighting = DoCloudLighting(muE, cumulus, AmbientColor*skylightOcclusion, skyScatter, directLight, directScattering*sh2, directMultiScattering*sh2, 1.0);
|
||||
|
||||
#if defined CloudLayer1 && defined CloudLayer0
|
||||
// a horrible approximation of direct light indirectly hitting the lower layer of clouds after scattering through/bouncing off the upper layer.
|
||||
cloudlighting += sunIndirectScattering * exp((skyScatter*skyScatter) * cumulus * -35.0) * upperLayerOcclusion * exp(-20.0 * pow(abs(upperLayerOcclusion - 0.3),2));
|
||||
#endif
|
||||
|
||||
color += max(cloudlighting - cloudlighting*exp(-muE*dd*dL),0.0) * absorbance;
|
||||
absorbance *= max(exp(-muE*dd*dL),0.0);
|
||||
directLight += shadow;
|
||||
}
|
||||
|
||||
/// shadows cast from one layer to another
|
||||
/// large cumulus -> small cumulus
|
||||
#if defined CloudLayer1 && defined CloudLayer0
|
||||
if(otherlayer > 0.0) directLight += LAYER1_DENSITY * 2.0 * GetCumulusDensity(1, progressW + dV_Sun/abs(dV_Sun.y) * max((LAYER1_minHEIGHT+70*dither.y) - progressW.y,0.0), 0, LAYER1_minHEIGHT, LAYER1_maxHEIGHT);
|
||||
#endif
|
||||
// // altostratus -> cumulus
|
||||
// #ifdef CloudLayer2
|
||||
// vec3 HighAlt_shadowPos = rayProgress + dV_Sun/abs(dV_Sun.y) * max(LAYER2_HEIGHT - rayProgress.y,0.0);
|
||||
// float HighAlt_shadow = GetAltostratusDensity(HighAlt_shadowPos) * CloudLayer2_density;
|
||||
// directLight += HighAlt_shadow;
|
||||
// #endif
|
||||
|
||||
|
||||
float skyScatter = clamp(((DUAL_MAX_HEIGHT - 20 - progressW.y) / 275.0) * (0.5+DUAL_DENSITY),0.0,1.0);
|
||||
float distantfade = 1- exp( -10*pow(clamp(1.0 - length(progressW - cameraPosition)/(32*65),0.0,1.0),2));
|
||||
vec3 cloudlighting = DoCloudLighting(muE, cumulus, SkyLightColor, skyScatter, directLight, directScattering*sh2, directMultiScattering*sh2, 1);
|
||||
|
||||
color += max(cloudlighting - cloudlighting*exp(-muE*dd*dL),0.0) * absorbance;
|
||||
absorbance *= max(exp(-muE*dd*dL),0.0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (min(dot(absorbance,vec3(0.335)),1.0) < 1e-5) break;
|
||||
}
|
||||
return vec4(color, min(dot(absorbance,vec3(0.335)),1.0));
|
||||
}
|
@ -492,7 +492,7 @@ uniform int moonPhase;
|
||||
#define TAA
|
||||
// #define SCREENSHOT_MODE
|
||||
// #define TAA_UPSCALING
|
||||
#define BLEND_FACTOR 0.05 // [0.01 0.02 0.03 0.04 0.05 0.06 0.08 0.1 0.12 0.14 0.16]
|
||||
#define BLEND_FACTOR 0.16 // [0.01 0.02 0.03 0.04 0.05 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.20 0.30 0.40 0.50 0.60 0.70 0.80 0.90 1.00]
|
||||
#define CLOSEST_VELOCITY
|
||||
//#define NO_CLIP
|
||||
|
||||
@ -595,9 +595,9 @@ uniform int moonPhase;
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// ----- MISC/DEBUG RELATED SETTINGS ----- //
|
||||
/////////////////////////////////////////////
|
||||
///////////////////////////////
|
||||
// ----- MISC SETTINGS ----- //
|
||||
///////////////////////////////
|
||||
|
||||
// #define Glass_Tint // multiply the background through glass by the color of the glass for a strong tint.
|
||||
// #define ambientLight_only // THIS IS A DEBUG VIEW. turn the sunlight off. DOES NOT increase performance, the shadows are still working in the background
|
||||
@ -628,6 +628,13 @@ uniform int moonPhase;
|
||||
|
||||
#define TRANSLUCENT_ENTITIES
|
||||
|
||||
#define DENOISE_SSS_AND_SSAO
|
||||
|
||||
///////////////////////////////////////////
|
||||
// ----- DISTANT HORIZONS SETTINGS ----- //
|
||||
///////////////////////////////////////////
|
||||
|
||||
/// distant horizons stuff
|
||||
#define DISTORT_SHADOWMAP
|
||||
// #define DISTANT_HORIZONS_SHADOWMAP
|
||||
#ifdef DISTANT_HORIZONS_SHADOWMAP
|
||||
@ -640,6 +647,15 @@ uniform int moonPhase;
|
||||
|
||||
// #define DH_SHADOWPROJECTIONTWEAK
|
||||
|
||||
#define DH_OVERDRAW_PREVENTION
|
||||
#define DH_KNOWN_ISSUES 0 // [0 1 2 3 4 5]
|
||||
|
||||
|
||||
////////////////////////////////
|
||||
// ----- DEBUG SETTINGS ----- //
|
||||
////////////////////////////////
|
||||
|
||||
|
||||
#define debug_OFF 0
|
||||
#define debug_SHADOWMAP 1
|
||||
#define debug_NORMALS 2
|
||||
@ -650,13 +666,14 @@ uniform int moonPhase;
|
||||
#define debug_DH_WATER_BLENDING 7
|
||||
#define DEBUG_VIEW debug_OFF // [debug_OFF debug_SHADOWMAP debug_NORMALS debug_SPECULAR debug_INDIRECT debug_DIRECT debug_VIEW_POSITION debug_DH_WATER_BLENDING]
|
||||
|
||||
/////////////////////////////////
|
||||
// ----- RANDOM SETTINGS ----- //
|
||||
/////////////////////////////////
|
||||
|
||||
// #define BLOOMY_PARTICLES
|
||||
// #define ORIGINAL_CHOCAPIC_SKY
|
||||
// #define CLOUDS_INFRONT_OF_WORLD
|
||||
|
||||
#define DH_OVERDRAW_PREVENTION
|
||||
#define DH_KNOWN_ISSUES 0 // [0 1 2 3 4 5]
|
||||
|
||||
// fix settings
|
||||
#if RESOURCEPACK_SKY == 0
|
||||
#endif
|
||||
|
@ -49,7 +49,6 @@ float LAYER0_DENSITY = dailyWeatherParams1.x;
|
||||
float LAYER1_DENSITY = dailyWeatherParams1.y;
|
||||
float LAYER2_DENSITY = dailyWeatherParams1.z;
|
||||
|
||||
|
||||
float rainCloudwetness = rainStrength;
|
||||
// float cloud_movement = frameTimeCounter * Cloud_Speed ;
|
||||
// float cloud_movement = abs((12000 - worldTime) * Cloud_Speed ) * 0.05;
|
||||
@ -97,84 +96,82 @@ float GetAltostratusDensity(vec3 pos){
|
||||
|
||||
float cloudCov(int layer, in vec3 pos, vec3 samplePos, float minHeight, float maxHeight){
|
||||
float FinalCloudCoverage = 0.0;
|
||||
|
||||
float coverage = 0.0;
|
||||
float Topshape = 0.0;
|
||||
float Baseshape = 0.0;
|
||||
|
||||
// float curvature = 1-exp(-25*pow(clamp(1.0 - length(pos - cameraPosition)/(32*80),0.0,1.0),2));
|
||||
// curvature = clamp(1.0 - length(pos - cameraPosition)/(32*128),0.0,1.0);
|
||||
float LAYER0_minHEIGHT_FOG = CloudLayer0_height;
|
||||
float LAYER0_maxHEIGHT_FOG = 100 + LAYER0_minHEIGHT_FOG;
|
||||
float LAYER1_minHEIGHT_FOG = max(CloudLayer1_height, LAYER0_maxHEIGHT);
|
||||
float LAYER1_maxHEIGHT_FOG = 100 + LAYER1_minHEIGHT_FOG;
|
||||
|
||||
|
||||
vec2 SampleCoords0 = vec2(0.0); vec2 SampleCoords1 = vec2(0.0);
|
||||
|
||||
float CloudSmall = 0.0;
|
||||
if(layer == 0){
|
||||
SampleCoords0 = (samplePos.xz + cloud_movement) / 5000;
|
||||
SampleCoords1 = (samplePos.xz - cloud_movement) / 500;
|
||||
CloudSmall = texture2D(noisetex, SampleCoords1 ).r;
|
||||
}
|
||||
|
||||
if(layer == 1){
|
||||
SampleCoords0 = -( (samplePos.zx + cloud_movement*2) / 15000);
|
||||
SampleCoords1 = -( (samplePos.zx - cloud_movement*2) / 2500);
|
||||
CloudSmall = texture2D(noisetex, SampleCoords1 ).b;
|
||||
}
|
||||
|
||||
if(layer == -1){
|
||||
float otherlayer = max(pos.y - (CloudLayer0_height+99.5), 0.0) > 0 ? 0.0 : 1.0;
|
||||
float otherlayer = max(pos.y - (LAYER0_minHEIGHT_FOG+99.5), 0.0) > 0 ? 0.0 : 1.0;
|
||||
if(otherlayer > 0.0){
|
||||
SampleCoords0 = (samplePos.xz + cloud_movement) / 5000;
|
||||
SampleCoords1 = (samplePos.xz - cloud_movement) / 500;
|
||||
CloudSmall = texture2D(noisetex, SampleCoords1 ).r;
|
||||
}else{
|
||||
SampleCoords0 = -( (samplePos.zx + cloud_movement*2) / 15000);
|
||||
SampleCoords1 = -( (samplePos.zx - cloud_movement*2) / 1500);
|
||||
CloudSmall = texture2D(noisetex, SampleCoords1 ).b;
|
||||
}
|
||||
}
|
||||
float CloudSmall = 0;
|
||||
if(layer == 0) CloudSmall = texture2D(noisetex, SampleCoords1 ).r;
|
||||
if(layer == 1) CloudSmall = texture2D(noisetex, SampleCoords1 ).b;
|
||||
|
||||
float CloudLarge = texture2D(noisetex, SampleCoords0 ).b;
|
||||
|
||||
float coverage = 0.0;// abs(CloudLarge*2.0 - 1.2)*0.5 - (1.0-CloudSmall);
|
||||
|
||||
float Topshape = 0.0;
|
||||
float Baseshape = 0.0;
|
||||
|
||||
if(layer == 0){
|
||||
coverage = abs(CloudLarge*2.0 - 1.2)*0.5 - (1.0-CloudSmall);
|
||||
// coverage = 1.0 - pow(abs(abs(CloudLarge * 2.0 - 1.0) * 2.0 - 1.0), 4.0);
|
||||
|
||||
float layer0 = min(min(coverage + dailyWeatherParams0.x, clamp(maxHeight - pos.y,0,1)), 1.0 - clamp(minHeight - pos.y,0,1));
|
||||
float layer0 = min(min(coverage + dailyWeatherParams0.x, clamp(LAYER0_maxHEIGHT_FOG - pos.y,0,1)), 1.0 - clamp(LAYER0_minHEIGHT_FOG - pos.y,0,1));
|
||||
|
||||
Topshape = max(pos.y - (maxHeight - 75),0.0) / 200.0;
|
||||
Topshape += max(pos.y - (maxHeight - 10),0.0) / 50.0;
|
||||
Topshape = max(pos.y - (LAYER0_maxHEIGHT_FOG - 75),0.0) / 200.0;
|
||||
Topshape += max(pos.y - (LAYER0_maxHEIGHT_FOG - 10),0.0) / 15.0;
|
||||
Baseshape = max(LAYER0_minHEIGHT_FOG + 12.5 - pos.y, 0.0) / 50.0;
|
||||
|
||||
Baseshape = max(minHeight + 12.5 - pos.y, 0.0) / 50.0;
|
||||
|
||||
FinalCloudCoverage = max(layer0 - Topshape - Baseshape,0.0);
|
||||
FinalCloudCoverage = max(layer0 - Topshape - Baseshape * rainStrength,0.0);
|
||||
}
|
||||
|
||||
if(layer == 1){
|
||||
|
||||
coverage = (1.0-abs(CloudLarge-0.3)) * abs(CloudSmall-0.8);
|
||||
// coverage = ((1.0-abs(CloudLarge-0.3)) + abs(CloudSmall-0.8))/2;
|
||||
|
||||
// coverage = pow(abs(abs(CloudLarge * 2.0 - 1.0) * 2.0 - 1.0), 2.0);
|
||||
// coverage = 1- ((1.0 - pow(abs(abs(CloudLarge * 2.0 - 1.0) * 2.0 - 1.0), 4.0)) - (pow(abs(abs(CloudLarge * 2.0 - 1.0) * 2.0 - 1.0), 2.0)));
|
||||
|
||||
|
||||
coverage *= coverage;
|
||||
|
||||
float layer1 = min(min(coverage + dailyWeatherParams0.y - 0.5,clamp(maxHeight - pos.y,0,1)), 1.0 - clamp(minHeight - pos.y,0,1));
|
||||
float layer1 = min(min(coverage + dailyWeatherParams0.y - 0.5,clamp(LAYER1_maxHEIGHT_FOG - pos.y,0,1)), 1.0 - clamp(LAYER1_minHEIGHT_FOG - pos.y,0,1));
|
||||
|
||||
Topshape = max(pos.y - (maxHeight - 75), 0.0) / 200;
|
||||
Topshape += max(pos.y - (maxHeight - 10 ), 0.0) / 50;
|
||||
Baseshape = max(minHeight + 12.5 - pos.y, 0.0) / 50.0;
|
||||
Topshape = max(pos.y - (LAYER1_maxHEIGHT_FOG - 75),0.0) / 200.0;
|
||||
Topshape += max(pos.y - (LAYER1_maxHEIGHT_FOG - 10), 0.0) / 15.0;
|
||||
Baseshape = max(LAYER1_minHEIGHT_FOG + 15.5 - pos.y, 0.0) / 50.0;
|
||||
|
||||
FinalCloudCoverage = max(layer1 - Topshape - Baseshape, 0.0);
|
||||
FinalCloudCoverage = max(layer1 - Topshape - Baseshape * rainStrength, 0.0);
|
||||
}
|
||||
|
||||
|
||||
if(layer == -1){
|
||||
float LAYER0_minHEIGHT_FOG = CloudLayer0_height;
|
||||
float LAYER0_maxHEIGHT_FOG = 100 + LAYER0_minHEIGHT_FOG;
|
||||
|
||||
|
||||
float LAYER1_minHEIGHT_FOG = max(CloudLayer1_height,LAYER0_maxHEIGHT);
|
||||
float LAYER1_maxHEIGHT_FOG = 100 + LAYER1_minHEIGHT_FOG;
|
||||
|
||||
#ifdef CloudLayer0
|
||||
float layer0 = min(min(coverage + LAYER0_COVERAGE, clamp(LAYER0_maxHEIGHT_FOG - pos.y,0,1)), 1.0 - clamp(LAYER0_minHEIGHT_FOG - pos.y,0,1));
|
||||
float layer0_coverage = abs(CloudLarge*2.0 - 1.2)*0.5 - (1.0-CloudSmall);
|
||||
float layer0 = min(min(layer0_coverage + dailyWeatherParams0.x, clamp(LAYER0_maxHEIGHT_FOG - pos.y,0,1)), 1.0 - clamp(LAYER0_minHEIGHT_FOG - pos.y,0,1));
|
||||
|
||||
Topshape = max(pos.y - (LAYER0_maxHEIGHT_FOG - 75),0.0) / 200.0;
|
||||
Topshape += max(pos.y - (LAYER0_maxHEIGHT_FOG - 10),0.0) / 50.0;
|
||||
@ -183,8 +180,10 @@ float cloudCov(int layer, in vec3 pos, vec3 samplePos, float minHeight, float ma
|
||||
FinalCloudCoverage += max(layer0 - Topshape - Baseshape,0.0);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CloudLayer1
|
||||
float layer1 = min(min(coverage + LAYER1_COVERAGE, clamp(LAYER1_maxHEIGHT - pos.y,0,1)), 1.0 - clamp(LAYER1_minHEIGHT_FOG - pos.y,0,1));
|
||||
float layer1_coverage = (1.0-abs(CloudLarge-0.3)) * abs(CloudSmall-0.8);
|
||||
float layer1 = min(min(layer1_coverage + dailyWeatherParams0.y - 0.5,clamp(LAYER1_maxHEIGHT_FOG - pos.y,0,1)), 1.0 - clamp(LAYER1_minHEIGHT_FOG - pos.y,0,1));
|
||||
|
||||
Topshape = max(pos.y - (LAYER1_maxHEIGHT_FOG - 75), 0.0) / 200;
|
||||
Topshape += max(pos.y - (LAYER1_maxHEIGHT_FOG - 10 ), 0.0) / 50;
|
||||
@ -199,6 +198,11 @@ float cloudCov(int layer, in vec3 pos, vec3 samplePos, float minHeight, float ma
|
||||
|
||||
//Erode cloud with 3d Perlin-worley noise, actual cloud value
|
||||
float cloudVol(int layer, in vec3 pos, in vec3 samplePos, in float cov, in int LoD, float minHeight, float maxHeight){
|
||||
|
||||
// float curvature = 1-exp(-25*pow(clamp(1.0 - length(pos - cameraPosition)/(32*80),0.0,1.0),2));
|
||||
// curvature = clamp(1.0 - length(pos - cameraPosition)/(32*128),0.0,1.0);
|
||||
|
||||
|
||||
float otherlayer = max(pos.y - (CloudLayer0_height+99.5), 0.0) > 0 ? 0.0 : 1.0;
|
||||
float upperPlane = otherlayer;
|
||||
|
||||
@ -209,9 +213,10 @@ float cloudVol(int layer, in vec3 pos, in vec3 samplePos, in float cov, in int L
|
||||
|
||||
samplePos.xz -= cloud_movement/4;
|
||||
|
||||
if(layer == 0 || layer == 1) samplePos.xz += pow( max(pos.y - (minHeight+20), 0.0) / 20.0,1.50);
|
||||
// if(layer == 0 || layer == 1) samplePos.xz += pow( max(pos.y - (minHeight+20), 0.0) / 20.0,1.50);
|
||||
// if(layer == -1) samplePos.xz += pow( max(pos.y - (minHeight+20), 0.0) / 20.0,1.50) * upperPlane;
|
||||
|
||||
if(layer == -1) samplePos.xz += pow( max(pos.y - (minHeight+20), 0.0) / 20.0,1.50) * upperPlane;
|
||||
samplePos.xz += pow( max(pos.y - (minHeight+20), 0.0) / 20.0,1.50) * upperPlane;
|
||||
|
||||
noise += (1.0-densityAtPos(samplePos * mix(100.0,200.0,upperPlane)) ) * mix(2.0,1.0,upperPlane);
|
||||
|
||||
@ -271,7 +276,7 @@ vec3 DoCloudLighting(
|
||||
float powder = 1.0 - exp(-10.0 * densityFaded);
|
||||
float lesspowder = powder*0.4+0.6;
|
||||
|
||||
float indirectScatter = exp( -10 * sqrt((skyScatter*skyScatter*skyScatter) * densityFaded)) * lesspowder;
|
||||
float indirectScatter = exp2( -15 * sqrt((skyScatter*skyScatter*skyScatter) * densityFaded)) * lesspowder;
|
||||
|
||||
vec3 indirectLight = skyLightCol * mix(1.0, indirectScatter, distantfog);
|
||||
|
||||
@ -371,42 +376,45 @@ if(layer == 2){
|
||||
|
||||
/// avoid overdraw
|
||||
if(notVisible) break;
|
||||
|
||||
// do not sample anything unless within a clouds bounding box
|
||||
if(clamp(rayProgress.y - maxHeight,0.0,1.0) < 1.0 && clamp(rayProgress.y - minHeight,0.0,1.0) > 0.0){
|
||||
float cumulus = GetCumulusDensity(layer, rayProgress, 1, minHeight, maxHeight);
|
||||
|
||||
float cumulus = GetCumulusDensity(layer, rayProgress, 1, minHeight, maxHeight);
|
||||
|
||||
float fadedDensity = cloudDensity * clamp(exp( (rayProgress.y - (maxHeight - 75)) / 9.0 ),0.0,1.0);
|
||||
float fadedDensity = cloudDensity * clamp(exp( (rayProgress.y - (maxHeight - 75)) / 9.0 ),0.0,1.0);
|
||||
|
||||
if(cumulus > 1e-5 && clamp(rayProgress.y - maxHeight,0.0,1.0) < 1.0 && clamp(rayProgress.y - minHeight,0.0,1.0) > 0.0){ // make sure no work is done on pixels with no densities
|
||||
float muE = cumulus * fadedDensity;
|
||||
if(cumulus > 1e-5 ){ // make sure no work is done on pixels with no densities
|
||||
float muE = cumulus * fadedDensity;
|
||||
|
||||
float directLight = 0.0;
|
||||
for (int j=0; j < 3; j++){
|
||||
vec3 shadowSamplePos = rayProgress + dV_Sun * (0.1 + j * (0.1 + dither*0.05));
|
||||
float shadow = GetCumulusDensity(layer, shadowSamplePos, 0, minHeight, maxHeight) * cloudDensity;
|
||||
float directLight = 0.0;
|
||||
for (int j=0; j < 3; j++){
|
||||
vec3 shadowSamplePos = rayProgress + dV_Sun * (0.1 + j * (0.1 + dither*0.05));
|
||||
float shadow = GetCumulusDensity(layer, shadowSamplePos, 0, minHeight, maxHeight) * cloudDensity;
|
||||
|
||||
directLight += shadow;
|
||||
directLight += shadow;
|
||||
}
|
||||
|
||||
/// shadows cast from one layer to another
|
||||
/// large cumulus -> small cumulus
|
||||
#if defined CloudLayer1 && defined CloudLayer0
|
||||
if(layer == 0) directLight += LAYER1_DENSITY * 2.0 * GetCumulusDensity(1, rayProgress + dV_Sun/abs(dV_Sun.y) * max((LAYER1_minHEIGHT+70*dither) - rayProgress.y,0.0), 0, LAYER1_minHEIGHT, LAYER1_maxHEIGHT);
|
||||
#endif
|
||||
// altostratus -> cumulus
|
||||
#ifdef CloudLayer2
|
||||
vec3 HighAlt_shadowPos = rayProgress + dV_Sun/abs(dV_Sun.y) * max(LAYER2_HEIGHT - rayProgress.y,0.0);
|
||||
float HighAlt_shadow = GetAltostratusDensity(HighAlt_shadowPos) * CloudLayer2_density;
|
||||
directLight += HighAlt_shadow;
|
||||
#endif
|
||||
float skyScatter = clamp(((maxHeight - 20 - rayProgress.y) / 275.0) * (0.5+cloudDensity),0.0,1.0);
|
||||
vec3 lighting = DoCloudLighting(muE, cumulus, skyLightCol * skylightOcclusion, skyScatter, directLight, sunScatter, sunMultiScatter, distantfog);
|
||||
|
||||
|
||||
|
||||
COLOR += max(lighting - lighting*exp(-mult*muE),0.0) * TOTAL_EXTINCTION;
|
||||
TOTAL_EXTINCTION *= max(exp(-mult*muE),0.0);
|
||||
|
||||
if (TOTAL_EXTINCTION < 1e-5) break;
|
||||
}
|
||||
|
||||
/// shadows cast from one layer to another
|
||||
/// large cumulus -> small cumulus
|
||||
#if defined CloudLayer1 && defined CloudLayer0
|
||||
if(layer == 0) directLight += LAYER1_DENSITY * 2.0 * GetCumulusDensity(1, rayProgress + dV_Sun/abs(dV_Sun.y) * max((LAYER1_minHEIGHT+70*dither) - rayProgress.y,0.0), 0, LAYER1_minHEIGHT, LAYER1_maxHEIGHT);
|
||||
#endif
|
||||
// altostratus -> cumulus
|
||||
#ifdef CloudLayer2
|
||||
vec3 HighAlt_shadowPos = rayProgress + dV_Sun/abs(dV_Sun.y) * max(LAYER2_HEIGHT - rayProgress.y,0.0);
|
||||
float HighAlt_shadow = GetAltostratusDensity(HighAlt_shadowPos) * CloudLayer2_density;
|
||||
directLight += HighAlt_shadow;
|
||||
#endif
|
||||
float skyScatter = clamp(((maxHeight - 20 - rayProgress.y) / 275.0) * (0.5+cloudDensity),0.0,1.0);
|
||||
vec3 lighting = DoCloudLighting(muE, cumulus, skyLightCol * skylightOcclusion, skyScatter, directLight, sunScatter, sunMultiScatter, distantfog);
|
||||
|
||||
|
||||
|
||||
COLOR += max(lighting - lighting*exp(-mult*muE),0.0) * TOTAL_EXTINCTION;
|
||||
TOTAL_EXTINCTION *= max(exp(-mult*muE),0.0);
|
||||
|
||||
if (TOTAL_EXTINCTION < 1e-5) break;
|
||||
}
|
||||
rayProgress += dV_view;
|
||||
}
|
||||
@ -458,11 +466,13 @@ vec4 renderClouds(
|
||||
// maxIT_clouds = 15;
|
||||
|
||||
vec3 dV_view = normalize(viewPos.xyz);
|
||||
vec3 dV_viewTEST = viewPos.xyz;
|
||||
|
||||
// this is the cloud curvature.
|
||||
dV_view.y += 0.025 * heightRelativeToClouds;
|
||||
|
||||
vec3 dV_view_Alto = dV_view;
|
||||
|
||||
dV_view_Alto *= 100/abs(dV_view_Alto.y)/15;
|
||||
float mult_alto = length(dV_view_Alto);
|
||||
|
||||
@ -529,6 +539,7 @@ vec4 renderClouds(
|
||||
|
||||
bool altoNotVisible = false;
|
||||
|
||||
|
||||
#ifdef CloudLayer0
|
||||
vec3 layer0_start = layerStartingPosition(dV_view, cameraPosition, Dither.y, MinHeight, MaxHeight);
|
||||
#endif
|
||||
@ -635,7 +646,7 @@ float GetCloudShadow(vec3 feetPlayerPos){
|
||||
|
||||
shadow = clamp(shadow,0.0,1.0);
|
||||
|
||||
shadow = exp2((shadow*shadow) * -150.0);
|
||||
shadow = exp2((shadow*shadow) * -100.0);
|
||||
|
||||
return mix(1.0, shadow, CLOUD_SHADOW_STRENGTH);
|
||||
|
||||
@ -652,7 +663,44 @@ float GetCloudShadow_VLFOG(vec3 WorldPos, vec3 WorldSpace_sunVec){
|
||||
|
||||
#ifdef CloudLayer0
|
||||
vec3 lowShadowStart = WorldPos + (WorldSpace_sunVec / max(abs(WorldSpace_sunVec.y),0.0)) * max((CloudLayer0_height + 30) - WorldPos.y,0.0) ;
|
||||
shadow += GetCumulusDensity(0, lowShadowStart, 0, CloudLayer0_height,CloudLayer0_height+100)*LAYER0_DENSITY;
|
||||
shadow += max(GetCumulusDensity(0, lowShadowStart, 0, CloudLayer0_height,CloudLayer0_height+100),0.0)*LAYER0_DENSITY;
|
||||
#endif
|
||||
#ifdef CloudLayer1
|
||||
vec3 higherShadowStart = WorldPos + (WorldSpace_sunVec / max(abs(WorldSpace_sunVec.y),0.0)) * max((CloudLayer1_height + 30) - WorldPos.y,0.0) ;
|
||||
shadow += max(GetCumulusDensity(1,higherShadowStart, 0, CloudLayer1_height,CloudLayer1_height+100) ,0.0)*LAYER1_DENSITY;
|
||||
#endif
|
||||
#ifdef CloudLayer2
|
||||
vec3 highShadowStart = WorldPos + (WorldSpace_sunVec / max(abs(WorldSpace_sunVec.y),0.0)) * max(CloudLayer2_height - WorldPos.y,0.0);
|
||||
shadow += GetAltostratusDensity(highShadowStart)*LAYER2_DENSITY * 0.5;
|
||||
#endif
|
||||
|
||||
shadow = clamp(shadow,0.0,1.0);
|
||||
|
||||
shadow = exp((shadow*shadow) * -100.0);
|
||||
|
||||
return mix(1.0, shadow, CLOUD_SHADOW_STRENGTH);
|
||||
|
||||
#else
|
||||
return 1.0;
|
||||
#endif
|
||||
}
|
||||
|
||||
float GetCloudShadow_VLFOG_DITHER(vec3 WorldPos, vec3 WorldSpace_sunVec, float dither){
|
||||
#ifdef CLOUDS_SHADOWS
|
||||
|
||||
float shadow = 0.0;
|
||||
|
||||
#ifdef CloudLayer0
|
||||
// vec3 lowShadowStart = WorldPos + (WorldSpace_sunVec / max(abs(WorldSpace_sunVec.y),0.0)) * max((CloudLayer0_height + 30) - WorldPos.y,0.0) ;
|
||||
// shadow += GetCumulusDensity(0, lowShadowStart, 0, CloudLayer0_height,CloudLayer0_height+100)*LAYER0_DENSITY;
|
||||
|
||||
for (int j=0; j < 8; j++){
|
||||
vec3 lowShadowStart = WorldPos + WorldSpace_sunVec * ( j * 50 + dither*50);
|
||||
shadow += GetCumulusDensity(0, lowShadowStart, 0, CloudLayer0_height, CloudLayer0_height+100)*LAYER0_DENSITY;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
#ifdef CloudLayer1
|
||||
vec3 higherShadowStart = WorldPos + (WorldSpace_sunVec / max(abs(WorldSpace_sunVec.y),0.0)) * max((CloudLayer1_height + 50) - WorldPos.y,0.0) ;
|
||||
@ -665,7 +713,7 @@ float GetCloudShadow_VLFOG(vec3 WorldPos, vec3 WorldSpace_sunVec){
|
||||
|
||||
shadow = clamp(shadow,0.0,1.0);
|
||||
|
||||
shadow = exp((shadow*shadow) * -150.0);
|
||||
shadow = exp((shadow*shadow) * -100.0);
|
||||
|
||||
return mix(1.0, shadow, CLOUD_SHADOW_STRENGTH);
|
||||
|
||||
|
@ -289,7 +289,7 @@ BLISS_SHADERS <empty> \
|
||||
|
||||
|
||||
######## MISC SETTINGS
|
||||
screen.Misc_Settings = DEBUG_VIEW [the_orb] display_LUT WhiteWorld SSS_view ambientLight_only Glass_Tint LIGHTNING_FLASH HURT_AND_DEATH_EFFECT LIT_PARTICLE_BRIGHTNESS PLANET_GROUND_BRIGHTNESS BLOOMY_PARTICLES ORIGINAL_CHOCAPIC_SKY BIOME_TINT_WATER CLOUDS_INFRONT_OF_WORLD SELECT_BOX
|
||||
screen.Misc_Settings = DEBUG_VIEW [the_orb] display_LUT WhiteWorld SSS_view ambientLight_only Glass_Tint LIGHTNING_FLASH HURT_AND_DEATH_EFFECT LIT_PARTICLE_BRIGHTNESS PLANET_GROUND_BRIGHTNESS BLOOMY_PARTICLES ORIGINAL_CHOCAPIC_SKY BIOME_TINT_WATER CLOUDS_INFRONT_OF_WORLD SELECT_BOX DENOISE_SSS_AND_SSAO
|
||||
|
||||
screen.the_orb.columns = 1
|
||||
screen.the_orb = THE_ORB ORB_X ORB_Y ORB_Z ORB_ColMult ORB_R ORB_G ORB_B
|
||||
|
@ -19,6 +19,11 @@ uniform int frameCounter;
|
||||
float blueNoise(){
|
||||
return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 );
|
||||
}
|
||||
// float R2_dither(){
|
||||
// vec2 coord = gl_FragCoord.xy;
|
||||
// vec2 alpha = vec2(0.75487765, 0.56984026);
|
||||
// return fract(alpha.x * coord.x + alpha.y * coord.y ) ;
|
||||
// }
|
||||
void main() {
|
||||
gl_FragData[0] = texture2D(tex,texcoord.xy);
|
||||
|
||||
@ -26,10 +31,10 @@ void main() {
|
||||
gl_FragData[0].a = texture2DLod(tex,texcoord.xy, 0).a;
|
||||
#endif
|
||||
|
||||
#ifdef Stochastic_Transparent_Shadows
|
||||
if(gl_FragData[0].a < blueNoise()) { discard; return;}
|
||||
#endif
|
||||
|
||||
#ifdef RENDER_ENTITY_SHADOWS
|
||||
#endif
|
||||
|
||||
#ifdef Stochastic_Transparent_Shadows
|
||||
gl_FragData[0].a = float(gl_FragData[0].a >= blueNoise());
|
||||
#endif
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
#version 120
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
|
||||
|
||||
@ -8,7 +9,6 @@ This code is from Chocapic13' shaders
|
||||
Read the terms of modification and sharing before changing something below please !
|
||||
!! DO NOT REMOVE !!
|
||||
*/
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
#define SHADOW_MAP_BIAS 0.5
|
||||
const float PI = 3.1415927;
|
||||
@ -37,7 +37,7 @@ uniform vec3 shadowCamera;
|
||||
uniform vec3 shadowLightVec;
|
||||
uniform float shadowMaxProj;
|
||||
attribute vec4 mc_midTexCoord;
|
||||
// varying vec4 color;
|
||||
varying vec4 color;
|
||||
|
||||
attribute vec4 mc_Entity;
|
||||
uniform int blockEntityId;
|
||||
@ -116,7 +116,7 @@ vec4 toClipSpace3(vec3 viewSpacePosition) {
|
||||
|
||||
void main() {
|
||||
texcoord.xy = gl_MultiTexCoord0.xy;
|
||||
// color = gl_Color;
|
||||
color = gl_Color;
|
||||
|
||||
vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user