mirror of
https://github.com/X0nk/Bliss-Shader.git
synced 2025-06-22 00:37:35 +08:00
Balance cloud lighting. remake altocumulus shapes. Add daily weather profiles. Add rainy weather. clean vl fog code and fix atmospheric haze contribution to bloomy fog. add motion blur. add new composite pass dedicated to post processing effects (damage effects, motion blur, whatever). fix waving for tall plants. fix broken lighting when HQ ambient light is enabled. improve screenspace SSS on DH chunks. add more DH settings. add "large waves" setting for water. make moonlight slightly darker. improve cave fog. remade cave detection. fix upscaling scaling issues
This commit is contained in:
@ -101,7 +101,13 @@ uniform vec3 cameraPosition;
|
||||
void main() {
|
||||
|
||||
#ifdef DH_OVERDRAW_PREVENTION
|
||||
if(clamp(1.0-length(pos.xyz)/max(far - 32.0,32.0),0.0,1.0) > 0.0 ){
|
||||
#if OVERDRAW_MAX_DISTANCE == 0
|
||||
float maxOverdrawDistance = far;
|
||||
#else
|
||||
float maxOverdrawDistance = OVERDRAW_MAX_DISTANCE;
|
||||
#endif
|
||||
|
||||
if(clamp(1.0-length(pos.xyz)/clamp(far - 32.0,32.0,maxOverdrawDistance),0.0,1.0) > 0.0 ){
|
||||
discard;
|
||||
return;
|
||||
}
|
||||
|
@ -80,8 +80,10 @@ void main() {
|
||||
if(dhMaterialId == DH_BLOCK_ILLUMINATED || gl_MultiTexCoord1.x >= 0.95) EMISSIVE = 0.5;
|
||||
|
||||
SSSAMOUNT = 0.0;
|
||||
if (dhMaterialId == DH_BLOCK_LEAVES) SSSAMOUNT = 1.0;
|
||||
if (dhMaterialId == DH_BLOCK_SNOW) SSSAMOUNT = 0.5;
|
||||
#if defined DH_SUBSURFACE_SCATTERING
|
||||
if (dhMaterialId == DH_BLOCK_LEAVES) SSSAMOUNT = 1.0;
|
||||
if (dhMaterialId == DH_BLOCK_SNOW) SSSAMOUNT = 0.5;
|
||||
#endif
|
||||
|
||||
// a mask for DH terrain in general.
|
||||
float MATERIALS = 0.65;
|
||||
|
@ -252,7 +252,6 @@ vec3 applyBump(mat3 tbnMatrix, vec3 bump, float puddle_values){
|
||||
return normalize(bump*tbnMatrix);
|
||||
}
|
||||
|
||||
varying vec4 tangent;
|
||||
|
||||
/* RENDERTARGETS:2,7 */
|
||||
void main() {
|
||||
@ -269,11 +268,16 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
||||
float transition = exp(-25* pow(clamp(1.0 - length(playerPos)/(far-8),0.0,1.0),2));
|
||||
|
||||
#ifdef DH_OVERDRAW_PREVENTION
|
||||
if(length(playerPos) < max(far-16*4,16) ){ discard; return;}
|
||||
#if OVERDRAW_MAX_DISTANCE == 0
|
||||
float maxOverdrawDistance = far;
|
||||
#else
|
||||
float maxOverdrawDistance = OVERDRAW_MAX_DISTANCE;
|
||||
#endif
|
||||
|
||||
if(length(playerPos) < clamp(far-16*4, 16, maxOverdrawDistance) ){ discard; return;}
|
||||
#endif
|
||||
|
||||
|
||||
if(iswater){
|
||||
if(iswater && abs(normals.y) > 0.0){
|
||||
vec3 posxz = playerPos+cameraPosition;
|
||||
|
||||
vec3 bump = normalize(getWaveNormal(posxz, true));
|
||||
@ -388,7 +392,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
||||
#ifdef SNELLS_WINDOW
|
||||
if(isEyeInWater == 1) fresnel = pow(clamp(1.5 + normalDotEye,0.0,1.0), 25.0);
|
||||
#endif
|
||||
#ifdef SCREENSPACE_REFLECTIONS
|
||||
#if defined SCREENSPACE_REFLECTIONS && defined DH_SCREENSPACE_REFLECTIONS
|
||||
vec3 rtPos = rayTrace(reflectedVector, viewPos, interleaved_gradientNoise(), fresnel, false);
|
||||
if (rtPos.z < 1.){
|
||||
vec3 previousPosition = mat3(gbufferModelViewInverse) * DH_toScreenSpace(rtPos) + gbufferModelViewInverse[3].xyz + cameraPosition-previousCameraPosition;
|
||||
@ -401,7 +405,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
||||
}
|
||||
#endif
|
||||
#ifdef WATER_BACKGROUND_SPECULAR
|
||||
BackgroundReflection = skyCloudsFromTex(mat3(gbufferModelViewInverse) * reflectedVector, colortex4).rgb / 30.0;
|
||||
BackgroundReflection = skyCloudsFromTex(mat3(gbufferModelViewInverse) * reflectedVector, colortex4).rgb / 30.0;
|
||||
#endif
|
||||
#ifdef WATER_SUN_SPECULAR
|
||||
SunReflection = Direct_lighting * GGX(normalize(normals), -normalize(viewPos), normalize(WsunVec2), roughness, f0) * (1.0-Reflections.a);
|
||||
@ -424,7 +428,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
||||
#endif
|
||||
|
||||
#ifdef DH_OVERDRAW_PREVENTION
|
||||
float distancefade = min(max(1.0 - length(playerPos)/max(far-16*4,16),0.0)*5,1.0);
|
||||
float distancefade = min(max(1.0 - length(playerPos)/clamp(far-16*4, 16, maxOverdrawDistance),0.0)*5,1.0);
|
||||
|
||||
if(texture2D(depthtex0, gl_FragCoord.xy*texelSize).x < 1.0 || distancefade > 0.0){
|
||||
gl_FragData[0].a = 0.0;
|
||||
|
@ -96,8 +96,8 @@ void main() {
|
||||
averageSkyCol_Clouds = texelFetch2D(colortex4,ivec2(0,37),0).rgb;
|
||||
#ifdef OVERWORLD_SHADER
|
||||
#if defined Daily_Weather
|
||||
dailyWeatherParams0 = vec4(texelFetch2D(colortex4,ivec2(1,1),0).rgb/150.0, 0.0);
|
||||
dailyWeatherParams1 = vec4(texelFetch2D(colortex4,ivec2(2,1),0).rgb/150.0, 0.0);
|
||||
dailyWeatherParams0 = vec4((texelFetch2D(colortex4,ivec2(1,1),0).rgb/150.0)/2.0, 0.0);
|
||||
dailyWeatherParams1 = vec4((texelFetch2D(colortex4,ivec2(2,1),0).rgb/150.0)/2.0, 0.0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -228,7 +228,7 @@ vec3 toClipSpace3(vec3 viewSpacePosition) {
|
||||
return projMAD(gbufferProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5;
|
||||
}
|
||||
|
||||
flat varying vec3 WsunVec2;
|
||||
flat varying vec3 WsunVec2;
|
||||
const float mincoord = 1.0/4096.0;
|
||||
const float maxcoord = 1.0-mincoord;
|
||||
|
||||
@ -245,6 +245,7 @@ const float maxcoord = 1.0-mincoord;
|
||||
return texture2DGradARB(texture,fract(coord)*vtexcoordam.pq+vtexcoordam.st,dcdx,dcdy);
|
||||
}
|
||||
#endif
|
||||
|
||||
uniform float near;
|
||||
// uniform float far;
|
||||
float ld(float dist) {
|
||||
@ -368,7 +369,7 @@ void main() {
|
||||
#endif
|
||||
|
||||
#ifdef Hand_Held_lights
|
||||
lightmap.x = max(lightmap.x, HELD_ITEM_BRIGHTNESS * clamp( pow(max(1.0-length(viewPos)/HANDHELD_LIGHT_RANGE,0.0),1.5),0.0,1.0));
|
||||
lightmap.x = max(lightmap.x, HELD_ITEM_BRIGHTNESS * clamp( pow(max(1.0-length(feetPlayerPos)/HANDHELD_LIGHT_RANGE,0.0),1.5),0.0,1.0));
|
||||
#endif
|
||||
|
||||
#ifdef WEATHER
|
||||
@ -422,7 +423,12 @@ void main() {
|
||||
#endif
|
||||
|
||||
AmbientLightColor = averageSkyCol_Clouds / 30.0;
|
||||
AmbientLightColor *= 2.5;
|
||||
#ifdef IS_IRIS
|
||||
AmbientLightColor *= 2.5;
|
||||
#else
|
||||
AmbientLightColor *= 0.5;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef IS_LPV_ENABLED
|
||||
|
@ -105,7 +105,7 @@ void main() {
|
||||
HELD_ITEM_BRIGHTNESS = 0.0;
|
||||
|
||||
#ifdef Hand_Held_lights
|
||||
if(heldItemId == ITEM_LIGHT_SOURCES || heldItemId2 == ITEM_LIGHT_SOURCES) HELD_ITEM_BRIGHTNESS = 0.9;
|
||||
if(heldItemId > 999 || heldItemId2 > 999) HELD_ITEM_BRIGHTNESS = 0.9;
|
||||
#endif
|
||||
|
||||
|
||||
@ -147,8 +147,8 @@ void main() {
|
||||
|
||||
WsunVec = lightCol.a * normalize(mat3(gbufferModelViewInverse) * sunPosition);
|
||||
#if defined Daily_Weather
|
||||
dailyWeatherParams0 = vec4(texelFetch2D(colortex4,ivec2(1,1),0).rgb/150.0, 0.0);
|
||||
dailyWeatherParams1 = vec4(texelFetch2D(colortex4,ivec2(2,1),0).rgb/150.0, 0.0);
|
||||
dailyWeatherParams0 = vec4((texelFetch2D(colortex4,ivec2(1,1),0).rgb/150.0) / 2.0, 0.0);
|
||||
dailyWeatherParams1 = vec4((texelFetch2D(colortex4,ivec2(2,1),0).rgb/150.0) / 2.0, 0.0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -313,23 +313,25 @@ void main() {
|
||||
float torchlightmap = lmtexcoord.z;
|
||||
|
||||
#ifdef Hand_Held_lights
|
||||
if(HELD_ITEM_BRIGHTNESS > 0.0) torchlightmap = max(torchlightmap, HELD_ITEM_BRIGHTNESS * clamp( pow(max(1.0-length(fragpos)/HANDHELD_LIGHT_RANGE,0.0),1.5),0.0,1.0));
|
||||
if(HELD_ITEM_BRIGHTNESS > 0.0) torchlightmap = max(torchlightmap, HELD_ITEM_BRIGHTNESS * clamp( pow(max(1.0-length(worldpos-cameraPosition)/HANDHELD_LIGHT_RANGE,0.0),1.5),0.0,1.0));
|
||||
|
||||
#ifdef HAND
|
||||
torchlightmap *= 0.9;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
float lightmap = clamp( (lmtexcoord.w-0.8) * 10.0,0.,1.);
|
||||
float lightmap = clamp( (lmtexcoord.w-0.9) * 10.0,0.,1.);
|
||||
|
||||
float rainfall = rainStrength * noPuddleAreas;
|
||||
float Puddle_shape = 0.;
|
||||
float rainfall = 0.0;
|
||||
float Puddle_shape = 0.0;
|
||||
|
||||
#if defined Puddles && defined WORLD && !defined ENTITIES && !defined HAND
|
||||
Puddle_shape = (1.0 - clamp(exp(-15 * pow(texture2D(noisetex, worldpos.xz * (0.020 * Puddle_Size) ).b ,5)),0,1)) * lightmap ;
|
||||
Puddle_shape *= clamp( viewToWorld(normal).y*0.5+0.5 ,0.0,1.0);
|
||||
Puddle_shape *= rainfall;
|
||||
rainfall = rainStrength * noPuddleAreas * lightmap;
|
||||
|
||||
Puddle_shape = clamp(lightmap - exp(-15.0 * pow(texture2D(noisetex, worldpos.xz * (0.020 * Puddle_Size) ).b,5.0)),0.0,1.0);
|
||||
Puddle_shape *= clamp( viewToWorld(normal).y*0.5+0.5,0.0,1.0);
|
||||
Puddle_shape *= rainStrength * noPuddleAreas ;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -446,12 +448,12 @@ void main() {
|
||||
#ifdef HAND
|
||||
if (Albedo.a > 0.1){
|
||||
Albedo.a = 0.75;
|
||||
gl_FragData[3] = vec4(0.0);
|
||||
} else {
|
||||
Albedo.a = 1.0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined HAND || defined ENTITIES || defined BLOCKENTITIES
|
||||
#if defined PARTICLE_RENDERING_FIX && (defined ENTITIES || defined BLOCKENTITIES)
|
||||
gl_FragData[3] = vec4(0.0);
|
||||
#endif
|
||||
|
||||
@ -472,16 +474,7 @@ void main() {
|
||||
NormalTex.xy = NormalTex.xy * 2.0-1.0;
|
||||
NormalTex.z = sqrt(max(1.0 - dot(NormalTex.xy, NormalTex.xy), 0.0));
|
||||
|
||||
// #if defined HEIGTHMAP_DEPTH_OFFSET && !defined HAND
|
||||
// gl_FragDepth = gl_FragCoord.z;
|
||||
// vec3 truePos = fragpos;
|
||||
// truePos.z -= Heightmap * POM_DEPTH * (1.0 + ld(truePos.z));
|
||||
|
||||
// gl_FragDepth = toClipSpace3(truePos).z;
|
||||
// #endif
|
||||
|
||||
normal = applyBump(tbnMatrix, NormalTex.xyz, mix(1.0,1-Puddle_shape,rainfall) );
|
||||
// normal = applyBump(tbnMatrix, NormalTex.xyz, 0.0);
|
||||
normal = applyBump(tbnMatrix, NormalTex.xyz, 1.0-Puddle_shape);
|
||||
#endif
|
||||
|
||||
//////////////////////////////// ////////////////////////////////
|
||||
@ -491,8 +484,8 @@ void main() {
|
||||
#ifdef WORLD
|
||||
vec4 SpecularTex = texture2D_POMSwitch(specular, adjustedTexCoord.xy, vec4(dcdx,dcdy), ifPOM,textureLOD);
|
||||
|
||||
SpecularTex.r = max(SpecularTex.r, Puddle_shape);
|
||||
SpecularTex.g = max(SpecularTex.g, Puddle_shape*0.02);
|
||||
SpecularTex.r = max(SpecularTex.r, rainfall);
|
||||
SpecularTex.g = max(SpecularTex.g, max(Puddle_shape*0.02,0.02));
|
||||
|
||||
gl_FragData[1].rg = SpecularTex.rg;
|
||||
|
||||
@ -548,12 +541,13 @@ void main() {
|
||||
//////////////////////////////// ////////////////////////////////
|
||||
|
||||
#ifdef WORLD
|
||||
|
||||
#ifdef Puddles
|
||||
float porosity = 0.4;
|
||||
|
||||
#ifdef Porosity
|
||||
porosity = SpecularTex.z >= 64.5/255.0 ? 0.0 : (SpecularTex.z*255.0/64.0)*0.65;
|
||||
#endif
|
||||
|
||||
if(SpecularTex.g < 229.5/255.0) Albedo.rgb = mix(Albedo.rgb, vec3(0), Puddle_shape*porosity);
|
||||
#endif
|
||||
|
||||
@ -561,9 +555,8 @@ void main() {
|
||||
vec2 PackLightmaps = vec2(torchlightmap, lmtexcoord.w);
|
||||
|
||||
vec4 data1 = clamp( encode(viewToWorld(normal), PackLightmaps), 0.0, 1.0);
|
||||
// gl_FragData[0] = vec4(.0);
|
||||
gl_FragData[0] = vec4(encodeVec2(Albedo.x,data1.x), encodeVec2(Albedo.y,data1.y), encodeVec2(Albedo.z,data1.z), encodeVec2(data1.w,Albedo.w));
|
||||
|
||||
gl_FragData[0] = vec4(encodeVec2(Albedo.x,data1.x), encodeVec2(Albedo.y,data1.y), encodeVec2(Albedo.z,data1.z), encodeVec2(data1.w,Albedo.w));
|
||||
|
||||
gl_FragData[2] = vec4(FlatNormals * 0.5 + 0.5, VanillaAO);
|
||||
#endif
|
||||
|
@ -72,6 +72,7 @@ uniform float viewHeight;
|
||||
uniform float viewWidth;
|
||||
uniform int hideGUI;
|
||||
uniform float screenBrightness;
|
||||
uniform int isEyeInWater;
|
||||
|
||||
flat varying float SSSAMOUNT;
|
||||
flat varying float EMISSIVE;
|
||||
@ -178,7 +179,13 @@ float densityAtPos(in vec3 pos){
|
||||
float luma(vec3 color) {
|
||||
return dot(color,vec3(0.21, 0.72, 0.07));
|
||||
}
|
||||
|
||||
vec3 viewToWorld(vec3 viewPos) {
|
||||
vec4 pos;
|
||||
pos.xyz = viewPos;
|
||||
pos.w = 0.0;
|
||||
pos = gbufferModelViewInverse * pos;
|
||||
return pos.xyz;
|
||||
}
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
@ -225,7 +232,7 @@ void main() {
|
||||
blockID = mc_Entity.x;
|
||||
// velocity = at_velocity;
|
||||
|
||||
if(mc_Entity.x == BLOCK_GROUND_WAVING_VERTICAL || mc_Entity.x == BLOCK_GRASS_SHORT) normalMat.a = 0.60;
|
||||
if(mc_Entity.x == BLOCK_GROUND_WAVING_VERTICAL || mc_Entity.x == BLOCK_GRASS_SHORT || mc_Entity.x == BLOCK_GRASS_TALL_LOWER || mc_Entity.x == BLOCK_GRASS_TALL_UPPER ) normalMat.a = 0.60;
|
||||
|
||||
|
||||
PORTAL = 0;
|
||||
@ -238,7 +245,6 @@ void main() {
|
||||
#endif
|
||||
|
||||
NameTags = 0;
|
||||
|
||||
|
||||
#ifdef ENTITIES
|
||||
// disallow POM to work on item frames.
|
||||
@ -260,6 +266,11 @@ void main() {
|
||||
LIGHTNING = 0;
|
||||
// if(NameTags > 0) EMISSIVE = 0.9;
|
||||
|
||||
HELD_ITEM_BRIGHTNESS = 0.0;
|
||||
#ifdef Hand_Held_lights
|
||||
if(heldItemId > 999 || heldItemId2 > 999 ) HELD_ITEM_BRIGHTNESS = 0.9;
|
||||
#endif
|
||||
|
||||
// normal block lightsources
|
||||
if(mc_Entity.x >= 100 && mc_Entity.x < 300) EMISSIVE = 0.5;
|
||||
|
||||
@ -274,13 +285,6 @@ void main() {
|
||||
/////// ----- SSS STUFF ----- ///////
|
||||
SSSAMOUNT = 0.0;
|
||||
|
||||
HELD_ITEM_BRIGHTNESS = 0.0;
|
||||
|
||||
#ifdef Hand_Held_lights
|
||||
if(heldItemId == ITEM_LIGHT_SOURCES || heldItemId2 == ITEM_LIGHT_SOURCES) HELD_ITEM_BRIGHTNESS = 0.9;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef WORLD
|
||||
/////// ----- SSS ON BLOCKS ----- ///////
|
||||
// strong
|
||||
@ -331,26 +335,35 @@ if(heldItemId == ITEM_LIGHT_SOURCES || heldItemId2 == ITEM_LIGHT_SOURCES) HELD_I
|
||||
|
||||
|
||||
#ifdef WAVY_PLANTS
|
||||
bool istopv = gl_MultiTexCoord0.t < mc_midTexCoord.t;
|
||||
// also use normal, so up/down facing geometry does not get detatched from its model parts.
|
||||
bool InterpolateFromBase = gl_MultiTexCoord0.t < max(mc_midTexCoord.t, abs(viewToWorld(FlatNormals).y));
|
||||
|
||||
if (
|
||||
if(
|
||||
(
|
||||
mc_Entity.x == BLOCK_GROUND_WAVING || mc_Entity.x == BLOCK_GROUND_WAVING_VERTICAL ||
|
||||
mc_Entity.x == BLOCK_GRASS_SHORT || mc_Entity.x == BLOCK_GRASS_TALL_UPPER ||
|
||||
mc_Entity.x == BLOCK_SAPLING
|
||||
) && istopv && abs(position.z) < 64.0
|
||||
) {
|
||||
vec3 worldpos = mat3(gbufferModelViewInverse) * position + gbufferModelViewInverse[3].xyz + cameraPosition;
|
||||
worldpos.xyz += calcMovePlants(worldpos.xyz)*lmtexcoord.w - cameraPosition;
|
||||
position = mat3(gbufferModelView) * worldpos + gbufferModelView[3].xyz;
|
||||
}
|
||||
// these wave off of the ground. the area connected to the ground does not wave.
|
||||
(InterpolateFromBase && (mc_Entity.x == BLOCK_GRASS_TALL_LOWER || mc_Entity.x == BLOCK_GROUND_WAVING || mc_Entity.x == BLOCK_GRASS_SHORT || mc_Entity.x == BLOCK_SAPLING || mc_Entity.x == BLOCK_GROUND_WAVING_VERTICAL))
|
||||
|
||||
// these wave off of the ceiling. the area connected to the ceiling does not wave.
|
||||
|| (!InterpolateFromBase && (mc_Entity.x == 17))
|
||||
|
||||
// these wave off of the air. they wave uniformly
|
||||
|| (mc_Entity.x == BLOCK_GRASS_TALL_UPPER || mc_Entity.x == BLOCK_AIR_WAVING)
|
||||
|
||||
) && abs(position.z) < 64.0
|
||||
){
|
||||
vec3 worldpos = mat3(gbufferModelViewInverse) * position + gbufferModelViewInverse[3].xyz;
|
||||
vec3 UnalteredWorldpos = worldpos;
|
||||
|
||||
// apply displacement for waving plant blocks
|
||||
worldpos += calcMovePlants(worldpos + cameraPosition) * max(lmtexcoord.w,0.5);
|
||||
|
||||
// apply displacement for waving leaf blocks specifically, overwriting the other waving mode. these wave off of the air. they wave uniformly
|
||||
if(mc_Entity.x == BLOCK_AIR_WAVING) worldpos = UnalteredWorldpos + calcMoveLeaves(worldpos + cameraPosition, 0.0040, 0.0064, 0.0043, 0.0035, 0.0037, 0.0041, vec3(1.0,0.2,1.0), vec3(0.5,0.1,0.5))*lmtexcoord.w;
|
||||
|
||||
if (mc_Entity.x == BLOCK_AIR_WAVING && abs(position.z) < 64.0) {
|
||||
vec3 worldpos = mat3(gbufferModelViewInverse) * position + gbufferModelViewInverse[3].xyz + cameraPosition;
|
||||
worldpos.xyz += calcMoveLeaves(worldpos.xyz, 0.0040, 0.0064, 0.0043, 0.0035, 0.0037, 0.0041, vec3(1.0,0.2,1.0), vec3(0.5,0.1,0.5))*lmtexcoord.w - cameraPosition;
|
||||
position = mat3(gbufferModelView) * worldpos + gbufferModelView[3].xyz;
|
||||
position = mat3(gbufferModelView) * worldpos + gbufferModelView[3].xyz;
|
||||
}
|
||||
#endif
|
||||
|
||||
gl_Position = toClipSpace3(position);
|
||||
#endif
|
||||
|
||||
|
@ -66,6 +66,9 @@ varying vec4 tangent;
|
||||
varying vec4 normalMat;
|
||||
varying vec3 binormal;
|
||||
varying vec3 flatnormal;
|
||||
#ifdef LARGE_WAVE_DISPLACEMENT
|
||||
varying vec3 shitnormal;
|
||||
#endif
|
||||
|
||||
|
||||
flat varying float exposure;
|
||||
@ -580,9 +583,20 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
vec3 normal = normalMat.xyz; // in viewSpace
|
||||
|
||||
#ifdef LARGE_WAVE_DISPLACEMENT
|
||||
if (isWater){
|
||||
normal = viewToWorld(normal) ;
|
||||
normal.xz = shitnormal.xy;
|
||||
normal = worldToView(normal);
|
||||
}
|
||||
#endif
|
||||
|
||||
vec3 worldSpaceNormal = viewToWorld(normal).xyz;
|
||||
vec2 TangentNormal = vec2(0); // for refractions
|
||||
|
||||
|
||||
|
||||
vec3 tangent2 = normalize(cross(tangent.rgb,normal)*tangent.w);
|
||||
mat3 tbnMatrix = mat3(tangent.x, tangent2.x, normal.x,
|
||||
tangent.y, tangent2.y, normal.y,
|
||||
@ -638,7 +652,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
||||
#endif
|
||||
|
||||
#ifdef Hand_Held_lights
|
||||
lightmap.x = max(lightmap.x, HELD_ITEM_BRIGHTNESS*clamp( pow(max(1.0-length(viewPos)/HANDHELD_LIGHT_RANGE,0.0),1.5),0.0,1.0));
|
||||
lightmap.x = max(lightmap.x, HELD_ITEM_BRIGHTNESS*clamp( pow(max(1.0-length(feetPlayerPos)/HANDHELD_LIGHT_RANGE,0.0),1.5),0.0,1.0));
|
||||
#endif
|
||||
|
||||
vec3 Indirect_lighting = vec3(0.0);
|
||||
|
@ -17,6 +17,7 @@ varying vec4 lmtexcoord;
|
||||
varying vec4 color;
|
||||
|
||||
uniform sampler2D colortex4;
|
||||
uniform sampler2D noisetex;
|
||||
flat varying float exposure;
|
||||
|
||||
#ifdef OVERWORLD_SHADER
|
||||
@ -35,7 +36,12 @@ varying vec3 binormal;
|
||||
varying vec4 tangent;
|
||||
varying vec3 flatnormal;
|
||||
|
||||
#ifdef LARGE_WAVE_DISPLACEMENT
|
||||
varying vec3 shitnormal;
|
||||
#endif
|
||||
|
||||
uniform mat4 gbufferModelViewInverse;
|
||||
uniform mat4 gbufferModelView;
|
||||
varying vec3 viewVector;
|
||||
|
||||
flat varying int glass;
|
||||
@ -45,6 +51,7 @@ attribute vec4 mc_Entity;
|
||||
|
||||
|
||||
uniform vec3 sunPosition;
|
||||
uniform vec3 cameraPosition;
|
||||
uniform float sunElevation;
|
||||
|
||||
varying vec4 tangent_other;
|
||||
@ -80,6 +87,28 @@ vec4 toClipSpace3(vec3 viewSpacePosition) {
|
||||
return vec4(projMAD(gl_ProjectionMatrix, viewSpacePosition),-viewSpacePosition.z);
|
||||
}
|
||||
|
||||
|
||||
float getWave (vec3 pos, float range){
|
||||
return pow(1.0-texture2D(noisetex, (pos.xz + frameTimeCounter * WATER_WAVE_SPEED)/150.0).b,2) * WATER_WAVE_STRENGTH / range;
|
||||
}
|
||||
vec3 getWaveNormal(vec3 posxz, float range){
|
||||
|
||||
float deltaPos = 0.5;
|
||||
|
||||
vec3 coord = posxz;
|
||||
|
||||
float h0 = getWave(coord,range);
|
||||
float h1 = getWave(coord - vec3(deltaPos,0.0,0.0),range);
|
||||
float h3 = getWave(coord - vec3(0.0,0.0,deltaPos),range);
|
||||
|
||||
|
||||
float xDelta = (h1-h0)/deltaPos*1.5;
|
||||
float yDelta = (h3-h0)/deltaPos*1.5;
|
||||
|
||||
vec3 wave = normalize(vec3(xDelta, yDelta, 1.0-pow(abs(xDelta+yDelta),2.0)));
|
||||
|
||||
return wave;
|
||||
}
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
@ -95,17 +124,28 @@ void main() {
|
||||
|
||||
vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz;
|
||||
|
||||
#ifdef LARGE_WAVE_DISPLACEMENT
|
||||
if(mc_Entity.x == 8.0) {
|
||||
vec3 displacedPos = mat3(gbufferModelViewInverse) * position + gbufferModelViewInverse[3].xyz + cameraPosition;
|
||||
#ifdef DISTANT_HORIZONS
|
||||
float range = min(1.0 + pow(length(displacedPos - cameraPosition) / min(far,256.0),2.0), 256.0);
|
||||
#else
|
||||
float range = min(1.0 + pow(length(displacedPos - cameraPosition) / 256,2.0), 256.0);
|
||||
#endif
|
||||
|
||||
displacedPos.y -= (1.0-getWave(displacedPos, range)) * 0.5 - 0.2;
|
||||
shitnormal = getWaveNormal(displacedPos, range);
|
||||
position = mat3(gbufferModelView) * (displacedPos - cameraPosition) + gbufferModelView[3].xyz;
|
||||
}
|
||||
#endif
|
||||
gl_Position = toClipSpace3(position);
|
||||
|
||||
|
||||
HELD_ITEM_BRIGHTNESS = 0.0;
|
||||
|
||||
|
||||
#ifdef Hand_Held_lights
|
||||
if(heldItemId == ITEM_LIGHT_SOURCES || heldItemId2 == ITEM_LIGHT_SOURCES) HELD_ITEM_BRIGHTNESS = 0.9;
|
||||
if(heldItemId > 999 || heldItemId2 > 999) HELD_ITEM_BRIGHTNESS = 0.9;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// 1.0 = water mask
|
||||
// 0.9 = entity mask
|
||||
// 0.8 = reflective entities
|
||||
@ -141,7 +181,8 @@ void main() {
|
||||
|
||||
flatnormal = normalMat.xyz;
|
||||
|
||||
viewVector = ( gl_ModelViewMatrix * gl_Vertex).xyz;
|
||||
viewVector = position.xyz;
|
||||
// viewVector = (gl_ModelViewMatrix * gl_Vertex).xyz;
|
||||
viewVector = normalize(tbnMatrix * viewVector);
|
||||
|
||||
|
||||
@ -158,8 +199,8 @@ void main() {
|
||||
// WsunVec = normalize(LightDir);
|
||||
|
||||
#if defined Daily_Weather
|
||||
dailyWeatherParams0 = vec4(texelFetch2D(colortex4,ivec2(1,1),0).rgb/150.0, 0.0);
|
||||
dailyWeatherParams1 = vec4(texelFetch2D(colortex4,ivec2(2,1),0).rgb/150.0, 0.0);
|
||||
dailyWeatherParams0 = vec4((texelFetch2D(colortex4,ivec2(1,1),0).rgb/150.0)/2.0, 0.0);
|
||||
dailyWeatherParams1 = vec4((texelFetch2D(colortex4,ivec2(2,1),0).rgb/150.0)/2.0, 0.0);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -1,5 +1,9 @@
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
#ifndef DH_AMBIENT_OCCLUSION
|
||||
#undef DISTANT_HORIZONS
|
||||
#endif
|
||||
|
||||
|
||||
flat varying vec3 WsunVec;
|
||||
flat varying vec2 TAA_Offset;
|
||||
|
@ -158,10 +158,10 @@ vec3 toScreenSpace(vec3 p) {
|
||||
|
||||
|
||||
|
||||
#define TESTTHINGYG
|
||||
|
||||
#include "/lib/color_transforms.glsl"
|
||||
#include "/lib/waterBump.glsl"
|
||||
#include "/lib/sky_gradient.glsl"
|
||||
|
||||
#include "/lib/Shadow_Params.glsl"
|
||||
#include "/lib/Shadows.glsl"
|
||||
@ -187,6 +187,7 @@ float ld(float dist) {
|
||||
return (2.0 * near) / (far + near - dist * (far - near));
|
||||
}
|
||||
|
||||
#include "/lib/sky_gradient.glsl"
|
||||
vec3 decode (vec2 encn){
|
||||
vec3 n = vec3(0.0);
|
||||
encn = encn * 2.0 - 1.0;
|
||||
@ -231,7 +232,9 @@ vec3 normVec (vec3 vec){
|
||||
float lengthVec (vec3 vec){
|
||||
return sqrt(dot(vec,vec));
|
||||
}
|
||||
#define fsign(a) (clamp((a)*1e35,0.,1.)*2.-1.)
|
||||
|
||||
// #define fsign(a) (clamp((a)*1e35,0.,1.)*2.-1.)
|
||||
|
||||
float triangularize(float dither)
|
||||
{
|
||||
float center = dither*2.0-1.0;
|
||||
@ -362,7 +365,7 @@ vec3 worldToView(vec3 worldPos) {
|
||||
}
|
||||
|
||||
vec2 SSRT_Shadows(vec3 viewPos, bool depthCheck, vec3 lightDir, float noise, bool isSSS, bool hand){
|
||||
|
||||
|
||||
float handSwitch = hand ? 1.0 : 0.0;
|
||||
|
||||
float steps = 16.0;
|
||||
@ -385,41 +388,29 @@ vec2 SSRT_Shadows(vec3 viewPos, bool depthCheck, vec3 lightDir, float noise, boo
|
||||
vec3 direction = toClipSpace3_DH(viewPos + lightDir*rayLength, depthCheck) - clipPosition; //convert to clip space
|
||||
direction.xyz = direction.xyz / max(abs(direction.x)/texelSize.x, abs(direction.y)/texelSize.y); //fixed step size
|
||||
|
||||
float Stepmult = depthCheck ? (isSSS ? 0.5 : 6.0) : (isSSS ? 1.0 : 3.0);
|
||||
float Stepmult = depthCheck ? (isSSS ? 1.0 : 6.0) : (isSSS ? 1.0 : 3.0);
|
||||
|
||||
// Stepmult = depthCheck ? 0.5 : 1.0;
|
||||
|
||||
|
||||
vec3 rayDir = direction * Stepmult * vec3(RENDER_SCALE,1.0);
|
||||
|
||||
vec3 screenPos = clipPosition * vec3(RENDER_SCALE,1.0) + rayDir*noise;
|
||||
if(isSSS) screenPos -= rayDir*0.9;
|
||||
vec3 rayDir = direction * Stepmult * vec3(RENDER_SCALE,1.0) ;
|
||||
vec3 screenPos = clipPosition * vec3(RENDER_SCALE,1.0) + rayDir * noise;
|
||||
|
||||
for (int i = 0; i < int(steps); i++) {
|
||||
|
||||
screenPos += rayDir;
|
||||
|
||||
|
||||
float samplePos = convertHandDepth_2(texture2D(depthtex1, screenPos.xy).x, hand);
|
||||
|
||||
#ifdef DISTANT_HORIZONS
|
||||
if(depthCheck) samplePos = texture2D(dhDepthTex1, screenPos.xy).x;
|
||||
#endif
|
||||
|
||||
if(samplePos <= screenPos.z) {
|
||||
if(samplePos < screenPos.z) {
|
||||
vec2 linearZ = vec2(linearizeDepthFast(screenPos.z, _near, _far), linearizeDepthFast(samplePos, _near, _far));
|
||||
float calcthreshold = abs(linearZ.x - linearZ.y) / linearZ.x;
|
||||
|
||||
bool depthThreshold1 = calcthreshold < mix(0.015, 0.035, handSwitch);
|
||||
bool depthThreshold2 = calcthreshold < 0.05;
|
||||
|
||||
if (depthThreshold1) Shadow = 0.0;
|
||||
|
||||
if (depthThreshold2) SSS = i/steps;
|
||||
|
||||
if (calcthreshold < 0.035) Shadow = 0.0;
|
||||
if (calcthreshold < (depthCheck ? 1.0 : 0.035)) SSS = i/steps;
|
||||
}
|
||||
}
|
||||
|
||||
return vec2(Shadow, SSS);
|
||||
}
|
||||
|
||||
@ -641,7 +632,7 @@ float CustomPhase(float LightPos){
|
||||
return Final;
|
||||
}
|
||||
|
||||
vec3 SubsurfaceScattering_sun(vec3 albedo, float Scattering, float Density, float lightPos, float shadows){
|
||||
vec3 SubsurfaceScattering_sun(vec3 albedo, float Scattering, float Density, float lightPos, float shadows, bool distantSSS){
|
||||
|
||||
Scattering *= sss_density_multiplier;
|
||||
|
||||
@ -650,6 +641,8 @@ vec3 SubsurfaceScattering_sun(vec3 albedo, float Scattering, float Density, floa
|
||||
float scatterDepth = max(1.0 - Scattering/density,0.0);
|
||||
scatterDepth = exp((1.0-scatterDepth) * -7.0);
|
||||
|
||||
if(distantSSS) scatterDepth = exp(Scattering * -10.0);
|
||||
|
||||
// this is for SSS when there is no shadow blocker depth
|
||||
#if defined BASIC_SHADOW_FILTER && defined Variable_Penumbra_Shadows
|
||||
scatterDepth = max(scatterDepth, pow(shadows, 0.5 + (1.0-Density) * 2.0) );
|
||||
@ -657,7 +650,6 @@ vec3 SubsurfaceScattering_sun(vec3 albedo, float Scattering, float Density, floa
|
||||
scatterDepth = exp(-7.0 * pow(1.0-shadows,3.0))*min(2.0-sss_density_multiplier,1.0);
|
||||
#endif
|
||||
|
||||
|
||||
// PBR at its finest :clueless:
|
||||
vec3 absorbColor = exp(max(luma(albedo) - albedo*vec3(1.0,1.1,1.2), 0.0) * -(20.0 - 19*scatterDepth) * sss_absorbance_multiplier);
|
||||
|
||||
@ -855,21 +847,14 @@ void main() {
|
||||
vec3 filteredShadow = vec3(1.412,1.0,0.0);
|
||||
vec2 SSAO_SSS = vec2(1.0);
|
||||
|
||||
#ifdef DISTANT_HORIZONS
|
||||
#if defined DISTANT_HORIZONS && defined DH_AMBIENT_OCCLUSION
|
||||
BilateralUpscale_REUSE_Z(colortex3, colortex14, colortex12, gl_FragCoord.xy, DH_mixedLinearZ, SSAO_SSS, filteredShadow, hand);
|
||||
#else
|
||||
BilateralUpscale_REUSE_Z(colortex3, colortex14, depthtex0, gl_FragCoord.xy, ld(z0), SSAO_SSS, filteredShadow, hand);
|
||||
#endif
|
||||
|
||||
// SSAO_SSS = texture2D(colortex14,texcoord).xy;
|
||||
// filteredShadow = texture2D(colortex3,texcoord).xyz;
|
||||
// filteredShadow.rgb = vec3(filteredShadow.x, temporallyReprojectedData.gb);
|
||||
// SSAO_SSS.x = temporallyReprojectedData.a;
|
||||
|
||||
float ShadowBlockerDepth = filteredShadow.y;
|
||||
// Shadows = vec3(clamp(1.0-filteredShadow.b,0.0,1.0));
|
||||
// shadowMap = vec3(Shadows);
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////// START DRAW ////////////////////////////////////////
|
||||
@ -881,7 +866,7 @@ void main() {
|
||||
#if RESOURCEPACK_SKY == 1 || RESOURCEPACK_SKY == 0
|
||||
// vec3 orbitstar = vec3(feetPlayerPos_normalized.x,abs(feetPlayerPos_normalized.y),feetPlayerPos_normalized.z); orbitstar.x -= WsunVec.x*0.2;
|
||||
|
||||
vec3 orbitstar = normalize(mat3(gbufferModelViewInverse) * toScreenSpace(vec3(texcoord,1.0)));
|
||||
vec3 orbitstar = normalize(mat3(gbufferModelViewInverse) * toScreenSpace(vec3(texcoord/RENDER_SCALE,1.0)));
|
||||
float radiance = 2.39996 - (worldTime + worldDay*24000.0) / 24000.0;
|
||||
// float radiance = 2.39996 + frameTimeCounter;
|
||||
mat2 rotationMatrix = mat2(vec2(cos(radiance), -sin(radiance)), vec2(sin(radiance), cos(radiance)));
|
||||
@ -905,7 +890,7 @@ void main() {
|
||||
|
||||
Background *= 1.0 - exp2(-50.0 * pow(clamp(feetPlayerPos_normalized.y+0.025,0.0,1.0),2.0) ); // darken the ground in the sky.
|
||||
|
||||
vec3 Sky = skyFromTex(feetPlayerPos_normalized, colortex4)/30.0;
|
||||
vec3 Sky = skyFromTex(feetPlayerPos_normalized, colortex4)/30.0 * Sky_Brightness;
|
||||
Background += Sky;
|
||||
|
||||
#if defined VOLUMETRIC_CLOUDS && !defined CLOUDS_INTERSECT_TERRAIN
|
||||
@ -1002,12 +987,9 @@ void main() {
|
||||
|
||||
float depthfalloff = 1.0 - clamp(exp(-0.1*estimatedDepth),0.0,1.0);
|
||||
|
||||
|
||||
float estimatedSunDepth = Vdiff; //assuming water plane
|
||||
Absorbtion = mix(exp(-2.0 * totEpsilon * estimatedDepth), exp(-8.0 * totEpsilon), depthfalloff);
|
||||
|
||||
// DirectLightColor *= Absorbtion;
|
||||
|
||||
// apply caustics to the lighting, and make sure they dont look weird
|
||||
DirectLightColor *= mix(1.0, waterCaustics(feetPlayerPos + cameraPosition, WsunVec)*WATER_CAUSTICS_BRIGHTNESS + 0.25, clamp(estimatedDepth,0,1));
|
||||
}
|
||||
@ -1039,9 +1021,9 @@ void main() {
|
||||
vec3 ambientcoefs = slopednormal / allDirections;
|
||||
float SkylightDir = ambientcoefs.y*1.5;
|
||||
|
||||
if(isGrass) SkylightDir = 1.25;
|
||||
if(isGrass) SkylightDir = 1.5;
|
||||
|
||||
float skylight = max(pow(viewToWorld(FlatNormals).y*0.5+0.5,0.1) + SkylightDir, 0.2 + (1-lightmap.y)*0.8) ;
|
||||
float skylight = max(pow(viewToWorld(FlatNormals).y*0.5+0.5,0.1) + SkylightDir, 0.2 + (1-lightmap.y)*0.8*0) ;
|
||||
|
||||
#if indirect_effect == 1
|
||||
skylight = min(skylight, mix(0.95, 2.5, pow(1-pow(1-SSAO_SSS.x, 0.5),2.0) ));
|
||||
@ -1082,6 +1064,9 @@ void main() {
|
||||
const vec3 lpvPos = vec3(0.0);
|
||||
#endif
|
||||
|
||||
// little highlight effect just to make caves look a little less flat.
|
||||
MinimumLightColor = MinimumLightColor + MinimumLightColor*dot(feetPlayerPos_normalized, slopednormal)*0.7;
|
||||
|
||||
Indirect_lighting = DoAmbientLightColor(feetPlayerPos, lpvPos, Indirect_lighting, MinimumLightColor, vec3(TORCH_R,TORCH_G,TORCH_B) , lightmap.xy, exposure);
|
||||
|
||||
#ifdef OVERWORLD_SHADER
|
||||
@ -1181,9 +1166,11 @@ void main() {
|
||||
|
||||
// combine shadowmap blocker depth with a minumum determined by the screenspace shadows, starting after the shadowmap ends
|
||||
ShadowBlockerDepth = mix(SS_directLight.g, ShadowBlockerDepth, shadowMapFalloff2);
|
||||
// ShadowBlockerDepth = SS_directLight.g;
|
||||
#endif
|
||||
|
||||
Direct_SSS = SubsurfaceScattering_sun(albedo, ShadowBlockerDepth, sunSSS_density, clamp(dot(feetPlayerPos_normalized, WsunVec),0.0,1.0), SSS_shadow);
|
||||
|
||||
Direct_SSS = SubsurfaceScattering_sun(albedo, ShadowBlockerDepth, sunSSS_density, clamp(dot(feetPlayerPos_normalized, WsunVec),0.0,1.0), SSS_shadow, shadowMapFalloff2 < 1.0);
|
||||
Direct_SSS *= mix(LM_shadowMapFallback, 1.0, shadowMapFalloff2);
|
||||
if (isEyeInWater == 0) Direct_SSS *= lightLeakFix;
|
||||
|
||||
@ -1211,6 +1198,7 @@ void main() {
|
||||
|
||||
#ifdef OVERWORLD_SHADER
|
||||
Direct_lighting = max(DirectLightColor * NdotL * Shadows, DirectLightColor * Direct_SSS);
|
||||
// Direct_lighting = 0.5 + DirectLightColor * exp(-7*SS_directLight.g);
|
||||
#endif
|
||||
|
||||
gl_FragData[0].rgb = (Indirect_lighting + Direct_lighting) * albedo;
|
||||
@ -1239,7 +1227,7 @@ void main() {
|
||||
}
|
||||
|
||||
#if defined VOLUMETRIC_CLOUDS && defined CLOUDS_INTERSECT_TERRAIN
|
||||
vec4 Clouds = texture2D_bicubic_offset(colortex0, texcoord*CLOUDS_QUALITY, noise, RENDER_SCALE.x);
|
||||
vec4 Clouds = texture2D_bicubic_offset(colortex0, ((gl_FragCoord.xy + 0.5)*texelSize)*CLOUDS_QUALITY, noise, RENDER_SCALE.x);
|
||||
// vec4 Clouds = BilateralUpscale_REUSE_Z_clouds(colortex0, colortex12, DH_mixedLinearZ, gl_FragCoord.xy*CLOUDS_QUALITY, texcoord*CLOUDS_QUALITY);
|
||||
|
||||
gl_FragData[1] = texture2D(colortex2, texcoord);
|
||||
@ -1279,6 +1267,9 @@ void main() {
|
||||
if(hideGUI == 0) gl_FragData[0].rgb = vec3(1) * (1.0 - SSAO_SSS.x);
|
||||
// if(hideGUI == 0) gl_FragData[0].rgb = vec3(1) * filteredShadow.z;//exp(-7*(1-clamp(1.0 - filteredShadow.x,0.0,1.0)));
|
||||
#endif
|
||||
|
||||
// gl_FragData[0].rgb = vec3(1) * ld(texture2D(depthtex1, texcoord).r);
|
||||
// if(texcoord.x > 0.5 )gl_FragData[0].rgb = vec3(1) * ld(texture2D(depthtex0, texcoord).r);
|
||||
|
||||
/* DRAWBUFFERS:3 */
|
||||
}
|
@ -65,8 +65,8 @@ void main() {
|
||||
exposure = texelFetch2D(colortex4,ivec2(10,37),0).r;
|
||||
|
||||
#if defined Daily_Weather
|
||||
dailyWeatherParams0 = vec4(texelFetch2D(colortex4,ivec2(1,1),0).rgb/150.0, 0.0);
|
||||
dailyWeatherParams1 = vec4(texelFetch2D(colortex4,ivec2(2,1),0).rgb/150.0, 0.0);
|
||||
dailyWeatherParams0 = vec4((texelFetch2D(colortex4,ivec2(1,1),0).rgb/150.0)/2.0, 0.0);
|
||||
dailyWeatherParams1 = vec4((texelFetch2D(colortex4,ivec2(2,1),0).rgb/150.0)/2.0, 0.0);
|
||||
#endif
|
||||
|
||||
#ifdef TAA
|
||||
|
158
shaders/dimensions/composite12.fsh
Normal file
158
shaders/dimensions/composite12.fsh
Normal file
@ -0,0 +1,158 @@
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
varying vec2 texcoord;
|
||||
|
||||
uniform sampler2D colortex7;
|
||||
uniform sampler2D colortex14;
|
||||
uniform sampler2D depthtex0;
|
||||
uniform vec2 texelSize;
|
||||
uniform float frameTimeCounter;
|
||||
uniform float viewHeight;
|
||||
uniform float viewWidth;
|
||||
uniform float aspectRatio;
|
||||
|
||||
uniform sampler2D shadow;
|
||||
uniform sampler2D shadowcolor0;
|
||||
uniform sampler2D shadowcolor1;
|
||||
uniform sampler2D shadowtex0;
|
||||
uniform sampler2D shadowtex1;
|
||||
uniform sampler2D noisetex;
|
||||
|
||||
uniform vec3 previousCameraPosition;
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
#include "/lib/color_transforms.glsl"
|
||||
#include "/lib/color_dither.glsl"
|
||||
#include "/lib/res_params.glsl"
|
||||
|
||||
uniform int hideGUI;
|
||||
|
||||
vec4 SampleTextureCatmullRom(sampler2D tex, vec2 uv, vec2 texSize )
|
||||
{
|
||||
// We're going to sample a a 4x4 grid of texels surrounding the target UV coordinate. We'll do this by rounding
|
||||
// down the sample location to get the exact center of our "starting" texel. The starting texel will be at
|
||||
// location [1, 1] in the grid, where [0, 0] is the top left corner.
|
||||
vec2 samplePos = uv * texSize;
|
||||
vec2 texPos1 = floor(samplePos - 0.5) + 0.5;
|
||||
|
||||
// Compute the fractional offset from our starting texel to our original sample location, which we'll
|
||||
// feed into the Catmull-Rom spline function to get our filter weights.
|
||||
vec2 f = samplePos - texPos1;
|
||||
|
||||
// Compute the Catmull-Rom weights using the fractional offset that we calculated earlier.
|
||||
// These equations are pre-expanded based on our knowledge of where the texels will be located,
|
||||
// which lets us avoid having to evaluate a piece-wise function.
|
||||
vec2 w0 = f * ( -0.5 + f * (1.0 - 0.5*f));
|
||||
vec2 w1 = 1.0 + f * f * (-2.5 + 1.5*f);
|
||||
vec2 w2 = f * ( 0.5 + f * (2.0 - 1.5*f) );
|
||||
vec2 w3 = f * f * (-0.5 + 0.5 * f);
|
||||
|
||||
// Work out weighting factors and sampling offsets that will let us use bilinear filtering to
|
||||
// simultaneously evaluate the middle 2 samples from the 4x4 grid.
|
||||
vec2 w12 = w1 + w2;
|
||||
vec2 offset12 = w2 / (w1 + w2);
|
||||
|
||||
// Compute the final UV coordinates we'll use for sampling the texture
|
||||
vec2 texPos0 = texPos1 - vec2(1.0);
|
||||
vec2 texPos3 = texPos1 + vec2(2.0);
|
||||
vec2 texPos12 = texPos1 + offset12;
|
||||
|
||||
texPos0 *= texelSize;
|
||||
texPos3 *= texelSize;
|
||||
texPos12 *= texelSize;
|
||||
|
||||
vec4 result = vec4(0.0);
|
||||
result += texture2D(tex, vec2(texPos0.x, texPos0.y)) * w0.x * w0.y;
|
||||
result += texture2D(tex, vec2(texPos12.x, texPos0.y)) * w12.x * w0.y;
|
||||
result += texture2D(tex, vec2(texPos3.x, texPos0.y)) * w3.x * w0.y;
|
||||
|
||||
result += texture2D(tex, vec2(texPos0.x, texPos12.y)) * w0.x * w12.y;
|
||||
result += texture2D(tex, vec2(texPos12.x, texPos12.y)) * w12.x * w12.y;
|
||||
result += texture2D(tex, vec2(texPos3.x, texPos12.y)) * w3.x * w12.y;
|
||||
|
||||
result += texture2D(tex, vec2(texPos0.x, texPos3.y)) * w0.x * w3.y;
|
||||
result += texture2D(tex, vec2(texPos12.x, texPos3.y)) * w12.x * w3.y;
|
||||
result += texture2D(tex, vec2(texPos3.x, texPos3.y)) * w3.x * w3.y;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// 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) * contrast + 0.5;
|
||||
}
|
||||
|
||||
float lowerCurve(float x) {
|
||||
float y = 16 * x * (0.5 - x) * 0.1;
|
||||
return clamp(y, 0.0, 1.0);
|
||||
}
|
||||
float upperCurve(float x) {
|
||||
float y = 16 * (0.5 - x) * (x - 1.0) * 0.1;
|
||||
return clamp(y, 0.0, 1.0);
|
||||
}
|
||||
vec3 toneCurve(vec3 color){
|
||||
color.r += LOWER_CURVE * lowerCurve(color.r) + UPPER_CURVE * upperCurve(color.r);
|
||||
color.g += LOWER_CURVE * lowerCurve(color.g) + UPPER_CURVE * upperCurve(color.g);
|
||||
color.b += LOWER_CURVE * lowerCurve(color.b) + UPPER_CURVE * upperCurve(color.b);
|
||||
return color;
|
||||
}
|
||||
|
||||
vec3 colorGrading(vec3 color) {
|
||||
float grade_luma = dot(color, vec3(1.0 / 3.0));
|
||||
float shadows_amount = saturate(-6.0 * grade_luma + 2.75);
|
||||
float mids_amount = saturate(-abs(6.0 * grade_luma - 3.0) + 1.25);
|
||||
float highlights_amount = saturate(6.0 * grade_luma - 3.25);
|
||||
|
||||
vec3 graded_shadows = color * SHADOWS_TARGET * SHADOWS_GRADE_MUL * 1.7320508076;
|
||||
vec3 graded_mids = color * MIDS_TARGET * MIDS_GRADE_MUL * 1.7320508076;
|
||||
vec3 graded_highlights = color * HIGHLIGHTS_TARGET * HIGHLIGHTS_GRADE_MUL * 1.7320508076;
|
||||
|
||||
return saturate(graded_shadows * shadows_amount + graded_mids * mids_amount + graded_highlights * highlights_amount);
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
/* DRAWBUFFERS:7 */
|
||||
|
||||
#ifdef BICUBIC_UPSCALING
|
||||
vec3 col = SampleTextureCatmullRom(colortex7,texcoord,1.0/texelSize).rgb;
|
||||
#else
|
||||
vec3 col = texture2D(colortex7,texcoord).rgb;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CONTRAST_ADAPTATIVE_SHARPENING
|
||||
//Weights : 1 in the center, 0.5 middle, 0.25 corners
|
||||
vec3 albedoCurrent1 = texture2D(colortex7, texcoord + vec2(texelSize.x,texelSize.y)/MC_RENDER_QUALITY*0.5).rgb;
|
||||
vec3 albedoCurrent2 = texture2D(colortex7, texcoord + vec2(texelSize.x,-texelSize.y)/MC_RENDER_QUALITY*0.5).rgb;
|
||||
vec3 albedoCurrent3 = texture2D(colortex7, texcoord + vec2(-texelSize.x,-texelSize.y)/MC_RENDER_QUALITY*0.5).rgb;
|
||||
vec3 albedoCurrent4 = texture2D(colortex7, texcoord + vec2(-texelSize.x,texelSize.y)/MC_RENDER_QUALITY*0.5).rgb;
|
||||
|
||||
vec3 m1 = -0.5/3.5*col + albedoCurrent1/3.5 + albedoCurrent2/3.5 + albedoCurrent3/3.5 + albedoCurrent4/3.5;
|
||||
vec3 std = abs(col - m1) + abs(albedoCurrent1 - m1) + abs(albedoCurrent2 - m1) +
|
||||
|
||||
abs(albedoCurrent3 - m1) + abs(albedoCurrent3 - m1) + abs(albedoCurrent4 - m1);
|
||||
|
||||
float contrast = 1.0 - luma(std)/5.0;
|
||||
col = col*(1.0+(SHARPENING+UPSCALING_SHARPNENING)*contrast)
|
||||
- (SHARPENING+UPSCALING_SHARPNENING)/(1.0-0.5/3.5)*contrast*(m1 - 0.5/3.5*col);
|
||||
#endif
|
||||
|
||||
float lum = luma(col);
|
||||
vec3 diff = col-lum;
|
||||
col = col + diff*(-lum*CROSSTALK + SATURATION);
|
||||
|
||||
vec3 FINAL_COLOR = clamp(int8Dither(col,texcoord),0.0,1.0);
|
||||
|
||||
#ifdef TONE_CURVE
|
||||
FINAL_COLOR = toneCurve(FINAL_COLOR);
|
||||
#endif
|
||||
|
||||
#ifdef COLOR_GRADING_ENABLED
|
||||
FINAL_COLOR = colorGrading(FINAL_COLOR);
|
||||
#endif
|
||||
|
||||
applyContrast(FINAL_COLOR, CONTRAST); // for fun
|
||||
|
||||
gl_FragData[0].rgb = FINAL_COLOR;
|
||||
}
|
15
shaders/dimensions/composite12.vsh
Normal file
15
shaders/dimensions/composite12.vsh
Normal file
@ -0,0 +1,15 @@
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
varying vec2 texcoord;
|
||||
|
||||
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
|
||||
void main() {
|
||||
gl_Position = ftransform();
|
||||
texcoord = gl_MultiTexCoord0.xy;
|
||||
}
|
@ -38,6 +38,7 @@ uniform int isEyeInWater;
|
||||
uniform float rainStrength;
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
uniform float eyeAltitude;
|
||||
uniform float caveDetection;
|
||||
|
||||
#define DHVLFOG
|
||||
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
|
||||
@ -397,7 +398,7 @@ void main() {
|
||||
vec3 indirectLightColor_dynamic = averageSkyCol_Clouds/30.0;
|
||||
|
||||
#ifdef OVERWORLD_SHADER
|
||||
vec4 VolumetricFog = GetVolumetricFog(viewPos0, vec2(noise_1,noise_2), directLightColor, indirectLightColor);
|
||||
vec4 VolumetricFog = GetVolumetricFog(viewPos0, vec2(noise_1,noise_2), directLightColor, indirectLightColor, averageSkyCol_Clouds/30.0);
|
||||
#endif
|
||||
|
||||
#if defined NETHER_SHADER || defined END_SHADER
|
||||
|
@ -16,7 +16,6 @@ flat varying vec3 averageSkyCol_Clouds;
|
||||
flat varying vec3 WsunVec;
|
||||
flat varying vec3 refractedSunVec;
|
||||
|
||||
flat varying float tempOffsets;
|
||||
uniform vec2 texelSize;
|
||||
|
||||
uniform sampler2D colortex4;
|
||||
@ -44,11 +43,11 @@ void main() {
|
||||
// gl_Position.xy = (gl_Position.xy*0.5+0.5)*0.51*2.0-1.0;
|
||||
gl_Position.xy = (gl_Position.xy*0.5+0.5)*(0.01+VL_RENDER_RESOLUTION)*2.0-1.0;
|
||||
|
||||
#ifdef TAA
|
||||
tempOffsets = HaltonSeq2(frameCounter%10000);
|
||||
#else
|
||||
tempOffsets = 0.0;
|
||||
#endif
|
||||
// #ifdef TAA
|
||||
// tempOffsets = HaltonSeq2(frameCounter%10000);
|
||||
// #else
|
||||
// tempOffsets = 0.0;
|
||||
// #endif
|
||||
|
||||
#ifdef OVERWORLD_SHADER
|
||||
lightCol.rgb = texelFetch2D(colortex4,ivec2(6,37),0).rgb;
|
||||
@ -56,11 +55,11 @@ void main() {
|
||||
averageSkyCol_Clouds = texelFetch2D(colortex4,ivec2(0,37),0).rgb;
|
||||
|
||||
#if defined Daily_Weather
|
||||
dailyWeatherParams0 = vec4(texelFetch2D(colortex4,ivec2(1,1),0).rgb/150.0, 0.0);
|
||||
dailyWeatherParams1 = vec4(texelFetch2D(colortex4,ivec2(2,1),0).rgb/150.0, 0.0);
|
||||
dailyWeatherParams0 = vec4((texelFetch2D(colortex4,ivec2(1,1),0).rgb/150.0)/2.0, 0.0);
|
||||
dailyWeatherParams1 = vec4((texelFetch2D(colortex4,ivec2(2,1),0).rgb/150.0)/2.0, 0.0);
|
||||
|
||||
dailyWeatherParams0.a = texelFetch2D(colortex4,ivec2(3,1),0).x/150.0;
|
||||
dailyWeatherParams1.a = texelFetch2D(colortex4,ivec2(3,1),0).y/150.0;
|
||||
dailyWeatherParams0.a = (texelFetch2D(colortex4,ivec2(3,1),0).x/150.0)/2.0;
|
||||
dailyWeatherParams1.a = (texelFetch2D(colortex4,ivec2(3,1),0).y/150.0)/2.0;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -3,7 +3,11 @@
|
||||
flat varying vec3 zMults;
|
||||
|
||||
flat varying vec2 TAA_Offset;
|
||||
flat varying vec3 skyGroundColor;
|
||||
flat varying vec3 WsunVec;
|
||||
|
||||
#ifdef OVERWORLD_SHADER
|
||||
flat varying vec3 skyGroundColor;
|
||||
#endif
|
||||
|
||||
uniform sampler2D noisetex;
|
||||
uniform sampler2D depthtex0;
|
||||
@ -32,8 +36,6 @@ uniform vec2 texelSize;
|
||||
|
||||
uniform sampler2D colortex4;
|
||||
|
||||
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;
|
||||
@ -60,7 +62,7 @@ uniform float rainStrength;
|
||||
uniform float blindness;
|
||||
uniform float darknessFactor;
|
||||
uniform float darknessLightFactor;
|
||||
|
||||
uniform float caveDetection;
|
||||
|
||||
#include "/lib/waterBump.glsl"
|
||||
#include "/lib/res_params.glsl"
|
||||
@ -250,18 +252,23 @@ void main() {
|
||||
vec3 fragpos = toScreenSpace_DH(texcoord/RENDER_SCALE-vec2(TAA_Offset)*texelSize*0.5, z, DH_depth0);
|
||||
|
||||
// vec3 fragpos = toScreenSpace(vec3(texcoord/RENDER_SCALE-vec2(TAA_Offset)*texelSize*0.5,z));
|
||||
vec3 p3 = mat3(gbufferModelViewInverse) * fragpos;
|
||||
vec3 p3 = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz;
|
||||
vec3 np3 = normVec(p3);
|
||||
|
||||
float linearDistance = length(p3);
|
||||
float linearDistance_cylinder = length(p3.xz);
|
||||
|
||||
// vec3 fragpos_NODH = toScreenSpace(texcoord/RENDER_SCALE-vec2(TAA_Offset)*texelSize*0.5, z);
|
||||
|
||||
// float linearDistance_NODH = length(p3);
|
||||
|
||||
|
||||
float lightleakfix = clamp(pow(eyeBrightnessSmooth.y/240.,2) ,0.0,1.0);
|
||||
float lightleakfixfast = clamp(eyeBrightness.y/240.,0.0,1.0);
|
||||
|
||||
////// --------------- UNPACK TRANSLUCENT GBUFFERS --------------- //////
|
||||
vec4 data = texture2D(colortex11,texcoord).rgba;
|
||||
vec4 unpack0 = vec4(decodeVec2(data.r),decodeVec2(data.g)) ;
|
||||
vec4 unpack0 = vec4(decodeVec2(data.r),decodeVec2(data.g)) ;
|
||||
vec4 unpack1 = vec4(decodeVec2(data.b),0,0) ;
|
||||
|
||||
vec4 albedo = vec4(unpack0.ba,unpack1.rg);
|
||||
@ -282,7 +289,6 @@ void main() {
|
||||
bool isReflective = abs(translucentMasks - 0.7) < 0.01 || isWater || isReflectiveEntity;
|
||||
bool isEntity = abs(translucentMasks - 0.9) < 0.01 || isReflectiveEntity;
|
||||
|
||||
|
||||
////// --------------- get volumetrics
|
||||
#ifdef TOGGLE_VL_FOG
|
||||
#ifdef DISTANT_HORIZONS
|
||||
@ -307,7 +313,7 @@ void main() {
|
||||
vec3 color = texture2D(colortex3, refractedCoord).rgb;
|
||||
|
||||
// apply block breaking effect.
|
||||
if(albedo.a > 0.01 && !isWater && TranslucentShader.a <= 0.0) color = mix(color*6.0, color, luma(albedo.rgb)) * albedo.rgb;
|
||||
if(albedo.a > 0.01 && !isWater && TranslucentShader.a <= 0.0 && !isEntity) color = mix(color*6.0, color, luma(albedo.rgb)) * albedo.rgb;
|
||||
|
||||
////// --------------- BLEND TRANSLUCENT GBUFFERS
|
||||
//////////// and do border fog on opaque and translucents
|
||||
@ -323,7 +329,7 @@ void main() {
|
||||
|
||||
if(swappedDepth >= 1.0 || isEyeInWater != 0) fog = 0.0;
|
||||
|
||||
if(lightleakfixfast < 1.0) fog *= lightleakfix;
|
||||
// fog *= lightleakfix;
|
||||
|
||||
#ifdef SKY_GROUND
|
||||
vec3 borderFogColor = skyGroundColor;
|
||||
@ -352,21 +358,21 @@ void main() {
|
||||
//////////// blindness, nightvision, liquid fogs and misc fogs
|
||||
|
||||
#if defined OVERWORLD_SHADER && defined CAVE_FOG
|
||||
if (isEyeInWater == 0 && eyeAltitude < 1500 && lightleakfix < 1.0){
|
||||
if (isEyeInWater == 0 && eyeAltitude < 1500){
|
||||
|
||||
float cavefog = clamp( pow(linearDistance / far, CaveFogFallOff) ,0.0,1.0);
|
||||
cavefog = cavefog*0.95 + clamp( pow(1.0 - exp((linearDistance / far) * -5), 2.0) ,0.0,1.0)*0.05;
|
||||
float cavefog = pow(1.0 - max(1.0 - linearDistance/far,0.0),2.0);
|
||||
|
||||
vec3 cavefogCol = vec3(CaveFogColor_R, CaveFogColor_G, CaveFogColor_B) * cavefog;
|
||||
|
||||
cavefog *= exp(-30.0*(pow(clamp(np3.y-0.5,0.0,1.0),2.0))); // create a hole in the fog above, so the sky is a little visible.
|
||||
|
||||
vec3 cavefogCol = vec3(CaveFogColor_R, CaveFogColor_G, CaveFogColor_B);
|
||||
cavefogCol *= clamp( exp(clamp(np3.y * 0.5 + 0.5,0,1) * -3.0) ,0.0,1.0); // apply a vertical gradient to the fog color
|
||||
cavefogCol *= exp(-7.0*clamp(normalize(np3).y*0.5+0.5,0.0,1.0)) * 0.999 + 0.001;
|
||||
|
||||
#ifdef PER_BIOME_ENVIRONMENT
|
||||
BiomeFogColor(cavefogCol);
|
||||
#endif
|
||||
|
||||
color.rgb = mix(color.rgb, cavefogCol, cavefog * (1.0-lightleakfix));
|
||||
float skyhole = pow(clamp(1.0-pow(max(np3.y - 0.6,0.0)*5.0,2.0),0.0,1.0),2);
|
||||
|
||||
color.rgb = mix(color.rgb + cavefogCol * caveDetection, cavefogCol, swappedDepth >= 1.0 ? skyhole * caveDetection : 0.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -408,9 +414,12 @@ void main() {
|
||||
|
||||
////// --------------- BLEND FOG INTO SCENE
|
||||
//////////// apply VL fog over opaque and translucents
|
||||
|
||||
// color += skyGroundColor * (1.0 - pow(max(1.0 - linearDistance/far,0.0),3.0)) * rainStrength;
|
||||
|
||||
color *= vl.a;
|
||||
color += vl.rgb;
|
||||
bloomyFogMult *= vl.a;
|
||||
bloomyFogMult *= mix(vl.a,vl.a*0.5 + 0.5, rainStrength);
|
||||
|
||||
////// --------------- VARIOUS FOG EFFECTS (in front of volumetric fog)
|
||||
//////////// blindness, nightvision, liquid fogs and misc fogs
|
||||
@ -448,12 +457,11 @@ void main() {
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
gl_FragData[0].r = bloomyFogMult; // pass fog alpha so bloom can do bloomy fog
|
||||
gl_FragData[1].rgb = clamp(color.rgb, 0.0,68000.0);
|
||||
|
||||
// gl_FragData[1].rgb = vec3(tangentNormals.xy,0.0) ;
|
||||
// gl_FragData[1].rgb = vec3(1.0) * ld( (data.a > 0.0 ? data.a : texture2D(depthtex0, texcoord).x ) ) ;
|
||||
// gl_FragData[1].rgb = vec3(tangentNormals.xy,0.0) ;
|
||||
// gl_FragData[1].rgb = vec3(1.0) * ld( (data.a > 0.0 ? data.a : texture2D(depthtex0, texcoord).x ) ) ;
|
||||
// gl_FragData[1].rgb = gl_FragData[1].rgb * (1.0-TranslucentShader.a) + TranslucentShader.rgb*10.0;
|
||||
// gl_FragData[1].rgb = 1-(texcoord.x > 0.5 ? vec3(TranslucentShader.a) : vec3(data.a));
|
||||
|
||||
|
@ -2,6 +2,12 @@
|
||||
|
||||
varying vec2 texcoord;
|
||||
flat varying vec3 zMults;
|
||||
|
||||
#ifdef BorderFog
|
||||
uniform sampler2D colortex4;
|
||||
flat varying vec3 skyGroundColor;
|
||||
#endif
|
||||
|
||||
flat varying vec3 WsunVec;
|
||||
|
||||
uniform float far;
|
||||
@ -24,11 +30,9 @@ const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
|
||||
vec2(7.,-7.)/8.);
|
||||
|
||||
|
||||
#ifdef BorderFog
|
||||
uniform sampler2D colortex4;
|
||||
flat varying vec3 skyGroundColor;
|
||||
#endif
|
||||
#ifdef OVERWORLD_SHADER
|
||||
|
||||
#endif
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
//////////////////////////////VOID MAIN//////////////////////////////
|
||||
@ -37,8 +41,11 @@ const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
|
||||
|
||||
void main() {
|
||||
|
||||
#ifdef BorderFog
|
||||
skyGroundColor = texelFetch2D(colortex4,ivec2(1,37),0).rgb / 30.0;
|
||||
#ifdef OVERWORLD_SHADER
|
||||
#ifdef BorderFog
|
||||
skyGroundColor = texelFetch2D(colortex4,ivec2(1,37),0).rgb / 30.0 * Sky_Brightness;
|
||||
#endif
|
||||
WsunVec = normalize(mat3(gbufferModelViewInverse) * sunPosition);
|
||||
#endif
|
||||
|
||||
#ifdef TAA
|
||||
@ -46,13 +53,8 @@ void main() {
|
||||
#else
|
||||
TAA_Offset = vec2(0.0);
|
||||
#endif
|
||||
|
||||
float lightCola = float(sunElevation > 1e-5)*2.0 - 1.0;
|
||||
WsunVec = normalize(mat3(gbufferModelViewInverse) * sunPosition);
|
||||
|
||||
zMults = vec3(1.0/(far * near),far+near,far-near);
|
||||
|
||||
gl_Position = ftransform();
|
||||
texcoord = gl_MultiTexCoord0.xy;
|
||||
|
||||
}
|
||||
|
@ -403,10 +403,6 @@ vec4 TAA_hq(bool hand){
|
||||
float isclamped = distance(albedoPrev,finalcAcc)/luma(albedoPrev) * 0.5;
|
||||
float movementRejection = (0.12+isclamped)*clamp(length(velocity/texelSize),0.0,1.0);
|
||||
|
||||
|
||||
// float depthDiff = texture2D(colortex14, previousPosition.xy).a;
|
||||
// movementRejection = mix( 0.0, 1.0, depthDiff);
|
||||
|
||||
if(hand) movementRejection *= 5.0;
|
||||
|
||||
//Blend current pixel with clamped history, apply fast tonemap beforehand to reduce flickering
|
||||
@ -442,13 +438,16 @@ void main() {
|
||||
gl_FragData[0].a = 1.0;
|
||||
|
||||
#ifdef TAA
|
||||
float dataUnpacked = decodeVec2(texture2D(colortex1,texcoord).w).y;
|
||||
bool hand = abs(dataUnpacked-0.75) < 0.01 && texture2D(depthtex1,texcoord).x < 1.0;
|
||||
|
||||
vec2 taauTC = clamp(texcoord*RENDER_SCALE, vec2(0.0), RENDER_SCALE - texelSize*2.0);
|
||||
|
||||
float dataUnpacked = decodeVec2(texture2D(colortex1,taauTC).w).y;
|
||||
bool hand = abs(dataUnpacked-0.75) < 0.01 && texture2D(depthtex1,taauTC).x < 1.0;
|
||||
|
||||
vec4 color = TAA_hq(hand);
|
||||
|
||||
#if DEBUG_VIEW == debug_TEMPORAL_REPROJECTION
|
||||
color.rgb = texture2D(colortex3, texcoord).rgb;
|
||||
color.rgb = texture2D(colortex3, taauTC).rgb;
|
||||
#endif
|
||||
|
||||
#ifdef SCREENSHOT_MODE
|
||||
@ -457,7 +456,7 @@ void main() {
|
||||
gl_FragData[0] = clamp(fp10Dither(color, triangularize(interleaved_gradientNoise())), 0.0, 65000.0);
|
||||
#endif
|
||||
#else
|
||||
vec3 color = clamp(fp10Dither(vec4(texture2D(colortex3,texcoord).rgb,1.0), triangularize(interleaved_gradientNoise())).rgb,0.0,65000.);
|
||||
vec3 color = clamp(fp10Dither(vec4(texture2D(colortex3,taauTC).rgb,1.0), triangularize(interleaved_gradientNoise())).rgb,0.0,65000.);
|
||||
gl_FragData[0].rgb = color;
|
||||
#endif
|
||||
}
|
@ -44,6 +44,7 @@ uniform vec3 sunPosition;
|
||||
uniform vec3 cameraPosition;
|
||||
// uniform float far;
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
uniform float caveDetection;
|
||||
|
||||
|
||||
vec4 lightCol = vec4(lightSourceColor, float(sunElevation > 1e-5)*2-1.);
|
||||
@ -190,19 +191,15 @@ if (gl_FragCoord.x > pixelPos6.x && gl_FragCoord.x < pixelPos6.x + 1 && gl_FragC
|
||||
ivec2 pixelPos = ivec2(0,0);
|
||||
if (gl_FragCoord.x > 1 && gl_FragCoord.x < 4 && gl_FragCoord.y > 1 && gl_FragCoord.y < 2){
|
||||
|
||||
mixhistory = 0.01;
|
||||
mixhistory = 0.005;
|
||||
|
||||
if(gl_FragCoord.x < 2) gl_FragData[0] = vec4(dailyWeatherParams0.rgb,1.0);
|
||||
if(gl_FragCoord.x > 2) gl_FragData[0] = vec4(dailyWeatherParams1.rgb,1.0);
|
||||
if(gl_FragCoord.x > 3) gl_FragData[0] = vec4(dailyWeatherParams0.a, dailyWeatherParams1.a, 0.0, 1.0);
|
||||
if(gl_FragCoord.x < 2) gl_FragData[0] = vec4(dailyWeatherParams0.rgb * 2.0,1.0);
|
||||
if(gl_FragCoord.x > 2) gl_FragData[0] = vec4(dailyWeatherParams1.rgb * 2.0,1.0);
|
||||
if(gl_FragCoord.x > 3) gl_FragData[0] = vec4(dailyWeatherParams0.a * 2.0, dailyWeatherParams1.a * 2.0, 0.0, 1.0);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////
|
||||
/// --- STORE COLOR LUT --- ///
|
||||
///////////////////////////////
|
||||
@ -213,7 +210,6 @@ if (gl_FragCoord.x > pixelPos6.x && gl_FragCoord.x < pixelPos6.x + 1 && gl_FragC
|
||||
vec3 skyGroundCol = skyFromTex(vec3(0, -1 ,0), colortex4).rgb;// * clamp(WsunVec.y*2.0,0.2,1.0);
|
||||
|
||||
|
||||
|
||||
/// --- Save light values
|
||||
if (gl_FragCoord.x < 1. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 )
|
||||
gl_FragData[0] = vec4(averageSkyCol_Clouds * AmbientLightTint,1.0);
|
||||
@ -248,19 +244,16 @@ if (gl_FragCoord.x > pixelPos6.x && gl_FragCoord.x < pixelPos6.x + 1 && gl_FragC
|
||||
|
||||
/// --- Sky only
|
||||
if (gl_FragCoord.x > 18. && gl_FragCoord.y > 1. && gl_FragCoord.x < 18+257){
|
||||
|
||||
|
||||
vec2 p = clamp(floor(gl_FragCoord.xy-vec2(18.,1.))/256.+tempOffsets/256.,0.0,1.0);
|
||||
vec3 viewVector = cartToSphere(p);
|
||||
|
||||
vec2 planetSphere = vec2(0.0);
|
||||
vec3 sky = vec3(0.0);
|
||||
vec3 skyAbsorb = vec3(0.0);
|
||||
|
||||
// float GroundDarkening = (exp2(-15 * clamp(-viewVector.y,0.0,1.0)) * 0.7+0.3); // darken the ground in the sky.
|
||||
sky = calculateAtmosphere((averageSkyCol*4000./2.0) , viewVector, vec3(0.0,1.0,0.0), WsunVec, -WsunVec, planetSphere, skyAbsorb, 10, blueNoise());
|
||||
|
||||
// sky = mix(sky, (averageSkyCol + skyAbsorb)*4000./2.0, (1.0 - exp(pow(clamp(-viewVector.y+0.5,0.0,1.0),2) * -25)));
|
||||
|
||||
vec3 mC = vec3(fog_coefficientMieR*1e-6, fog_coefficientMieG*1e-6, fog_coefficientMieB*1e-6);
|
||||
|
||||
sky = calculateAtmosphere((averageSkyCol*4000./2.0), viewVector, vec3(0.0,1.0,0.0), WsunVec, -WsunVec, planetSphere, skyAbsorb, 10, blueNoise());
|
||||
|
||||
// fade atmosphere conditions for rain away when you pass above the cloud plane.
|
||||
float heightRelativeToClouds = clamp(1.0 - max(eyeAltitude - CloudLayer0_height,0.0) / 200.0 ,0.0,1.0);
|
||||
@ -270,7 +263,7 @@ if (gl_FragCoord.x > 18. && gl_FragCoord.y > 1. && gl_FragCoord.x < 18+257){
|
||||
sky *= vec3(0.0, 0.18, 0.35);
|
||||
#endif
|
||||
|
||||
gl_FragData[0] = vec4(sky / 4000.0 * Sky_Brightness, 1.0);
|
||||
gl_FragData[0] = vec4(sky / 4000.0, 1.0);
|
||||
}
|
||||
|
||||
/// --- Sky + clouds + fog
|
||||
@ -278,7 +271,7 @@ if (gl_FragCoord.x > 18.+257. && gl_FragCoord.y > 1. && gl_FragCoord.x < 18+257+
|
||||
vec2 p = clamp(floor(gl_FragCoord.xy-vec2(18.+257,1.))/256.+tempOffsets/256.,0.0,1.0);
|
||||
vec3 viewVector = cartToSphere(p);
|
||||
|
||||
WsunVec = normalize(mat3(gbufferModelViewInverse) * sunPosition) * ( float(sunElevation > 1e-5)*2.0-1.0 );
|
||||
WsunVec = normalize(mat3(gbufferModelViewInverse) * sunPosition) ;// * ( float(sunElevation > 1e-5)*2.0-1.0 );
|
||||
|
||||
vec3 sky = texelFetch2D(colortex4,ivec2(gl_FragCoord.xy)-ivec2(257,0),0).rgb/150.0;
|
||||
|
||||
@ -291,8 +284,8 @@ if (gl_FragCoord.x > 18.+257. && gl_FragCoord.y > 1. && gl_FragCoord.x < 18+257+
|
||||
vec4 clouds = renderClouds(mat3(gbufferModelView)*viewVector*1024., vec2(fract(frameCounter/1.6180339887),1-fract(frameCounter/1.6180339887)), suncol*2.0, skyGroundCol/30.0);
|
||||
sky = sky*clouds.a + clouds.rgb / 5.0;
|
||||
|
||||
sky = mix(dot(sky,vec3(0.333)) * vec3(0.5), sky, pow(clamp(viewVector.y+1.0,0.0,1.0),5));
|
||||
vec4 VL_Fog = GetVolumetricFog(mat3(gbufferModelView)*viewVector*1024., vec2(fract(frameCounter/1.6180339887),1-fract(frameCounter/1.6180339887)), suncol*1.75, skyGroundCol/30.0);
|
||||
sky = mix(dot(sky, vec3(0.333)) * vec3(0.5), sky, pow(clamp(viewVector.y+1.0,0.0,1.0),5));
|
||||
vec4 VL_Fog = GetVolumetricFog(mat3(gbufferModelView)*viewVector*1024., vec2(fract(frameCounter/1.6180339887),1-fract(frameCounter/1.6180339887)), suncol*1.75, skyGroundCol/30.0, averageSkyCol_Clouds/30.0);
|
||||
|
||||
sky = sky * VL_Fog.a + VL_Fog.rgb / 5.0;
|
||||
|
||||
|
@ -143,14 +143,10 @@ void main() {
|
||||
averageSkyCol_Clouds += 1.5 * (skyCloudsFromTex(pos,colortex4).rgb/maxIT/150.0);
|
||||
averageSkyCol += 1.5 * (skyFromTex(pos,colortex4).rgb/maxIT/150.0);
|
||||
}
|
||||
|
||||
// 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( normalize(averageSkyCol_Clouds) * min(luma(averageSkyCol_Clouds) * 3.0,2.5), minimumlight);
|
||||
vec3 minimumlight = vec3(0.5,0.75,1.0) * (MIN_LIGHT_AMOUNT*0.001 + nightVision);
|
||||
averageSkyCol_Clouds = max( normalize(averageSkyCol_Clouds) * min(luma(averageSkyCol_Clouds) * 3.0,2.5) * (1.0-rainStrength*0.3), minimumlight);
|
||||
averageSkyCol = max(averageSkyCol * PLANET_GROUND_BRIGHTNESS, minimumlight);
|
||||
|
||||
////////////////////////////////////////
|
||||
@ -181,7 +177,7 @@ void main() {
|
||||
// as the day counter changes, switch to a different set of stored values.
|
||||
|
||||
#ifdef CHOOSE_RANDOM_WEATHER_PROFILE
|
||||
int dayCounter = clamp(int(hash11(float(mod(worldDay, 1000))) * 11.0), 0,10);
|
||||
int dayCounter = int(clamp(hash11(float(mod(worldDay, 1000))) * 10.0, 0,10));
|
||||
#else
|
||||
int dayCounter = int(mod(worldDay, 10));
|
||||
#endif
|
||||
@ -217,6 +213,7 @@ void main() {
|
||||
|
||||
dailyWeatherParams0 = weatherParameters_A[dayCounter];
|
||||
dailyWeatherParams1 = weatherParameters_B[dayCounter];
|
||||
|
||||
#endif
|
||||
|
||||
//////////////////////////////
|
||||
|
@ -23,6 +23,7 @@ uniform sampler2D noisetex;
|
||||
uniform sampler2D colortex12;
|
||||
|
||||
flat varying vec3 WsunVec;
|
||||
uniform float sunElevation;
|
||||
uniform vec3 sunVec;
|
||||
uniform vec2 texelSize;
|
||||
uniform float frameTimeCounter;
|
||||
@ -124,17 +125,20 @@ void main() {
|
||||
/* DRAWBUFFERS:0 */
|
||||
#if defined OVERWORLD_SHADER && defined VOLUMETRIC_CLOUDS
|
||||
vec2 halfResTC = vec2(floor(gl_FragCoord.xy)/CLOUDS_QUALITY/RENDER_SCALE+0.5+offsets[framemod8]*CLOUDS_QUALITY*RENDER_SCALE*0.5);
|
||||
|
||||
float depth = texture2D(depthtex0, halfResTC*texelSize).x;
|
||||
|
||||
|
||||
// vec3 viewPos = toScreenSpace(vec3(halfResTC*texelSize, depth));
|
||||
vec2 halfResTC2 = vec2(floor(gl_FragCoord.xy)/CLOUDS_QUALITY+0.5+offsets[framemod8]*CLOUDS_QUALITY*0.5);
|
||||
|
||||
#ifdef DISTANT_HORIZONS
|
||||
float DH_depth = texture2D(dhDepthTex, halfResTC*texelSize).x;
|
||||
vec3 viewPos = toScreenSpace_DH(halfResTC*texelSize, depth, DH_depth);
|
||||
#ifdef CLOUDS_INTERSECT_TERRAIN
|
||||
float depth = texture2D(depthtex0, halfResTC2*texelSize).x;
|
||||
|
||||
#ifdef DISTANT_HORIZONS
|
||||
float DH_depth = texture2D(dhDepthTex, halfResTC2*texelSize).x;
|
||||
vec3 viewPos = toScreenSpace_DH(halfResTC*texelSize, depth, DH_depth);
|
||||
#else
|
||||
vec3 viewPos = toScreenSpace(vec3(halfResTC*texelSize, depth));
|
||||
#endif
|
||||
#else
|
||||
vec3 viewPos = toScreenSpace(vec3(halfResTC*texelSize, depth));
|
||||
vec3 viewPos = toScreenSpace(vec3(halfResTC*texelSize, 1.0));
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -31,8 +31,8 @@ void main() {
|
||||
gl_Position.xy = (gl_Position.xy*0.5+0.5)*clamp(CLOUDS_QUALITY+0.01,0.0,1.0)*2.0-1.0;
|
||||
|
||||
#if defined Daily_Weather
|
||||
dailyWeatherParams0 = vec4(texelFetch2D(colortex4,ivec2(1,1),0).rgb/150.0, 0.0);
|
||||
dailyWeatherParams1 = vec4(texelFetch2D(colortex4,ivec2(2,1),0).rgb/150.0, 0.0);
|
||||
dailyWeatherParams0 = vec4((texelFetch2D(colortex4,ivec2(1,1),0).rgb/150.0)/2.0, 0.0);
|
||||
dailyWeatherParams1 = vec4((texelFetch2D(colortex4,ivec2(2,1),0).rgb/150.0)/2.0, 0.0);
|
||||
#endif
|
||||
|
||||
averageSkyCol = texelFetch2D(colortex4,ivec2(1,37),0).rgb;
|
||||
@ -43,7 +43,7 @@ void main() {
|
||||
// moonColor = texelFetch2D(colortex4,ivec2(9,37),0).rgb;
|
||||
|
||||
|
||||
WsunVec = normalize(mat3(gbufferModelViewInverse) * sunPosition) * (float(sunElevation > 1e-5)*2.0-1.0);
|
||||
WsunVec = normalize(mat3(gbufferModelViewInverse) * sunPosition);// * (float(sunElevation > 1e-5)*2.0-1.0);
|
||||
// WsunVec = normalize(LightDir);
|
||||
|
||||
tempOffsets = HaltonSeq2(frameCounter%10000);
|
||||
|
@ -1,114 +1,24 @@
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
varying vec2 texcoord;
|
||||
|
||||
uniform sampler2D colortex7;
|
||||
uniform sampler2D colortex14;
|
||||
uniform sampler2D depthtex0;
|
||||
uniform sampler2D depthtex2;
|
||||
uniform sampler2D noisetex;
|
||||
|
||||
varying vec2 texcoord;
|
||||
uniform vec2 texelSize;
|
||||
uniform float frameTimeCounter;
|
||||
uniform float viewHeight;
|
||||
uniform float viewWidth;
|
||||
uniform float aspectRatio;
|
||||
|
||||
uniform sampler2D shadow;
|
||||
uniform sampler2D shadowcolor0;
|
||||
uniform sampler2D shadowcolor1;
|
||||
uniform sampler2D shadowtex0;
|
||||
uniform sampler2D shadowtex1;
|
||||
uniform sampler2D noisetex;
|
||||
|
||||
uniform vec3 previousCameraPosition;
|
||||
uniform vec3 cameraPosition;
|
||||
uniform int hideGUI;
|
||||
|
||||
#include "/lib/color_transforms.glsl"
|
||||
#include "/lib/color_dither.glsl"
|
||||
#include "/lib/res_params.glsl"
|
||||
|
||||
uniform int hideGUI;
|
||||
|
||||
vec4 SampleTextureCatmullRom(sampler2D tex, vec2 uv, vec2 texSize )
|
||||
{
|
||||
// We're going to sample a a 4x4 grid of texels surrounding the target UV coordinate. We'll do this by rounding
|
||||
// down the sample location to get the exact center of our "starting" texel. The starting texel will be at
|
||||
// location [1, 1] in the grid, where [0, 0] is the top left corner.
|
||||
vec2 samplePos = uv * texSize;
|
||||
vec2 texPos1 = floor(samplePos - 0.5) + 0.5;
|
||||
|
||||
// Compute the fractional offset from our starting texel to our original sample location, which we'll
|
||||
// feed into the Catmull-Rom spline function to get our filter weights.
|
||||
vec2 f = samplePos - texPos1;
|
||||
|
||||
// Compute the Catmull-Rom weights using the fractional offset that we calculated earlier.
|
||||
// These equations are pre-expanded based on our knowledge of where the texels will be located,
|
||||
// which lets us avoid having to evaluate a piece-wise function.
|
||||
vec2 w0 = f * ( -0.5 + f * (1.0 - 0.5*f));
|
||||
vec2 w1 = 1.0 + f * f * (-2.5 + 1.5*f);
|
||||
vec2 w2 = f * ( 0.5 + f * (2.0 - 1.5*f) );
|
||||
vec2 w3 = f * f * (-0.5 + 0.5 * f);
|
||||
|
||||
// Work out weighting factors and sampling offsets that will let us use bilinear filtering to
|
||||
// simultaneously evaluate the middle 2 samples from the 4x4 grid.
|
||||
vec2 w12 = w1 + w2;
|
||||
vec2 offset12 = w2 / (w1 + w2);
|
||||
|
||||
// Compute the final UV coordinates we'll use for sampling the texture
|
||||
vec2 texPos0 = texPos1 - vec2(1.0);
|
||||
vec2 texPos3 = texPos1 + vec2(2.0);
|
||||
vec2 texPos12 = texPos1 + offset12;
|
||||
|
||||
texPos0 *= texelSize;
|
||||
texPos3 *= texelSize;
|
||||
texPos12 *= texelSize;
|
||||
|
||||
vec4 result = vec4(0.0);
|
||||
result += texture2D(tex, vec2(texPos0.x, texPos0.y)) * w0.x * w0.y;
|
||||
result += texture2D(tex, vec2(texPos12.x, texPos0.y)) * w12.x * w0.y;
|
||||
result += texture2D(tex, vec2(texPos3.x, texPos0.y)) * w3.x * w0.y;
|
||||
|
||||
result += texture2D(tex, vec2(texPos0.x, texPos12.y)) * w0.x * w12.y;
|
||||
result += texture2D(tex, vec2(texPos12.x, texPos12.y)) * w12.x * w12.y;
|
||||
result += texture2D(tex, vec2(texPos3.x, texPos12.y)) * w3.x * w12.y;
|
||||
|
||||
result += texture2D(tex, vec2(texPos0.x, texPos3.y)) * w0.x * w3.y;
|
||||
result += texture2D(tex, vec2(texPos12.x, texPos3.y)) * w12.x * w3.y;
|
||||
result += texture2D(tex, vec2(texPos3.x, texPos3.y)) * w3.x * w3.y;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// 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) * contrast + 0.5;
|
||||
}
|
||||
|
||||
float lowerCurve(float x) {
|
||||
float y = 16 * x * (0.5 - x) * 0.1;
|
||||
return clamp(y, 0.0, 1.0);
|
||||
}
|
||||
float upperCurve(float x) {
|
||||
float y = 16 * (0.5 - x) * (x - 1.0) * 0.1;
|
||||
return clamp(y, 0.0, 1.0);
|
||||
}
|
||||
vec3 toneCurve(vec3 color){
|
||||
color.r += LOWER_CURVE * lowerCurve(color.r) + UPPER_CURVE * upperCurve(color.r);
|
||||
color.g += LOWER_CURVE * lowerCurve(color.g) + UPPER_CURVE * upperCurve(color.g);
|
||||
color.b += LOWER_CURVE * lowerCurve(color.b) + UPPER_CURVE * upperCurve(color.b);
|
||||
return color;
|
||||
}
|
||||
|
||||
vec3 colorGrading(vec3 color) {
|
||||
float grade_luma = dot(color, vec3(1.0 / 3.0));
|
||||
float shadows_amount = saturate(-6.0 * grade_luma + 2.75);
|
||||
float mids_amount = saturate(-abs(6.0 * grade_luma - 3.0) + 1.25);
|
||||
float highlights_amount = saturate(6.0 * grade_luma - 3.25);
|
||||
|
||||
vec3 graded_shadows = color * SHADOWS_TARGET * SHADOWS_GRADE_MUL * 1.7320508076;
|
||||
vec3 graded_mids = color * MIDS_TARGET * MIDS_GRADE_MUL * 1.7320508076;
|
||||
vec3 graded_highlights = color * HIGHLIGHTS_TARGET * HIGHLIGHTS_GRADE_MUL * 1.7320508076;
|
||||
|
||||
return saturate(graded_shadows * shadows_amount + graded_mids * mids_amount + graded_highlights * highlights_amount);
|
||||
}
|
||||
|
||||
float interleaved_gradientNoise(){
|
||||
vec2 coord = gl_FragCoord.xy;
|
||||
@ -116,10 +26,8 @@ float interleaved_gradientNoise(){
|
||||
return noise;
|
||||
}
|
||||
|
||||
|
||||
#include "/lib/gameplay_effects.glsl"
|
||||
|
||||
|
||||
void doCameraGridLines(inout vec3 color, vec2 UV){
|
||||
|
||||
float lineThicknessY = 0.001;
|
||||
@ -137,62 +45,65 @@ void doCameraGridLines(inout vec3 color, vec2 UV){
|
||||
color = mix(color, vec3(1.0), gridLines);
|
||||
}
|
||||
|
||||
uniform vec3 previousCameraPosition;
|
||||
// uniform vec3 cameraPosition;
|
||||
uniform mat4 gbufferPreviousModelView;
|
||||
// uniform mat4 gbufferModelViewInverse;
|
||||
// uniform mat4 gbufferModelView;
|
||||
|
||||
#include "/lib/util.glsl"
|
||||
#include "/lib/projections.glsl"
|
||||
|
||||
vec3 doMotionBlur(vec2 texcoord, float depth, float noise){
|
||||
|
||||
float samples = 4.0;
|
||||
vec3 color = vec3(0.0);
|
||||
|
||||
float blurMult = 1.0;
|
||||
if(depth < 0.56) blurMult = 0.0;
|
||||
|
||||
vec3 viewPos = toScreenSpace(vec3(texcoord, depth));
|
||||
viewPos = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz + (cameraPosition - previousCameraPosition);
|
||||
|
||||
vec3 previousPosition = mat3(gbufferPreviousModelView) * viewPos + gbufferPreviousModelView[3].xyz;
|
||||
previousPosition = toClipSpace3(previousPosition);
|
||||
|
||||
vec2 velocity = texcoord - previousPosition.xy;
|
||||
|
||||
// thank you Capt Tatsu for letting me use these
|
||||
velocity = (velocity / (1.0 + length(velocity))) * 0.05 * blurMult * MOTION_BLUR_STRENGTH;
|
||||
texcoord = texcoord - velocity*(samples*0.5 + noise);
|
||||
vec2 screenEdges = 2.0/vec2(viewWidth, viewHeight);
|
||||
|
||||
for (int i = 0; i < int(samples); i++) {
|
||||
|
||||
texcoord += velocity;
|
||||
color += texture2D(colortex7, clamp(texcoord, screenEdges, 1.0-screenEdges)).rgb;
|
||||
|
||||
}
|
||||
// return vec3(texcoord,0.0);
|
||||
return color / samples;
|
||||
}
|
||||
|
||||
void main() {
|
||||
#ifdef BICUBIC_UPSCALING
|
||||
vec3 col = SampleTextureCatmullRom(colortex7,texcoord,1.0/texelSize).rgb;
|
||||
#else
|
||||
vec3 col = texture2D(colortex7,texcoord).rgb;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CONTRAST_ADAPTATIVE_SHARPENING
|
||||
//Weights : 1 in the center, 0.5 middle, 0.25 corners
|
||||
vec3 albedoCurrent1 = texture2D(colortex7, texcoord + vec2(texelSize.x,texelSize.y)/MC_RENDER_QUALITY*0.5).rgb;
|
||||
vec3 albedoCurrent2 = texture2D(colortex7, texcoord + vec2(texelSize.x,-texelSize.y)/MC_RENDER_QUALITY*0.5).rgb;
|
||||
vec3 albedoCurrent3 = texture2D(colortex7, texcoord + vec2(-texelSize.x,-texelSize.y)/MC_RENDER_QUALITY*0.5).rgb;
|
||||
vec3 albedoCurrent4 = texture2D(colortex7, texcoord + vec2(-texelSize.x,texelSize.y)/MC_RENDER_QUALITY*0.5).rgb;
|
||||
|
||||
|
||||
vec3 m1 = -0.5/3.5*col + albedoCurrent1/3.5 + albedoCurrent2/3.5 + albedoCurrent3/3.5 + albedoCurrent4/3.5;
|
||||
vec3 std = abs(col - m1) + abs(albedoCurrent1 - m1) + abs(albedoCurrent2 - m1) +
|
||||
abs(albedoCurrent3 - m1) + abs(albedoCurrent3 - m1) + abs(albedoCurrent4 - m1);
|
||||
float contrast = 1.0 - luma(std)/5.0;
|
||||
col = col*(1.0+(SHARPENING+UPSCALING_SHARPNENING)*contrast)
|
||||
- (SHARPENING+UPSCALING_SHARPNENING)/(1.0-0.5/3.5)*contrast*(m1 - 0.5/3.5*col);
|
||||
#endif
|
||||
|
||||
float lum = luma(col);
|
||||
vec3 diff = col-lum;
|
||||
col = col + diff*(-lum*CROSSTALK + SATURATION);
|
||||
|
||||
|
||||
|
||||
vec3 FINAL_COLOR = clamp(int8Dither(col,texcoord),0.0,1.0);
|
||||
|
||||
#ifdef TONE_CURVE
|
||||
FINAL_COLOR = toneCurve(FINAL_COLOR);
|
||||
#endif
|
||||
|
||||
#ifdef COLOR_GRADING_ENABLED
|
||||
FINAL_COLOR = colorGrading(FINAL_COLOR);
|
||||
#endif
|
||||
|
||||
applyContrast(FINAL_COLOR, CONTRAST); // for fun
|
||||
|
||||
float depth = texture2D(depthtex0,texcoord*RENDER_SCALE).r;
|
||||
float noise = interleaved_gradientNoise();
|
||||
|
||||
#ifdef MOTION_BLUR
|
||||
vec3 COLOR = doMotionBlur(texcoord, depth, noise);
|
||||
#else
|
||||
vec3 COLOR = texture2D(colortex7,texcoord).rgb;
|
||||
#endif
|
||||
|
||||
#if defined LOW_HEALTH_EFFECT || defined DAMAGE_TAKEN_EFFECT || defined WATER_ON_CAMERA_EFFECT
|
||||
// for making the fun, more fun
|
||||
applyGameplayEffects(FINAL_COLOR, texcoord, interleaved_gradientNoise());
|
||||
applyGameplayEffects(COLOR, texcoord, noise);
|
||||
#endif
|
||||
|
||||
#ifdef CAMERA_GRIDLINES
|
||||
doCameraGridLines(FINAL_COLOR, texcoord);
|
||||
doCameraGridLines(COLOR, texcoord);
|
||||
#endif
|
||||
|
||||
gl_FragColor.rgb = FINAL_COLOR;
|
||||
|
||||
#if DEBUG_VIEW == debug_SHADOWMAP
|
||||
if(texcoord.x < 0.25 && texcoord.y < 0.5) gl_FragColor.rgb = texture2D(shadowcolor0, (texcoord * vec2(2.0, 1.0) * 2 - vec2(0.0, 0.0)) ).rgb;
|
||||
#endif
|
||||
gl_FragColor.rgb = COLOR;
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ uniform int isEyeInWater;
|
||||
uniform float rainStrength;
|
||||
uniform ivec2 eyeBrightnessSmooth;
|
||||
uniform float eyeAltitude;
|
||||
uniform float caveDetection;
|
||||
|
||||
#define DHVLFOG
|
||||
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
|
||||
@ -366,7 +367,7 @@ void main() {
|
||||
|
||||
vec4 VolumetricFog2 = vec4(0,0,0,1);
|
||||
#ifdef OVERWORLD_SHADER
|
||||
if(!iswater) VolumetricFog2 = GetVolumetricFog(viewPos1, vec2(noise_1, noise_2), directLightColor, indirectLightColor);
|
||||
if(!iswater) VolumetricFog2 = GetVolumetricFog(viewPos1, vec2(noise_1, noise_2), directLightColor, indirectLightColor,indirectLightColor_dynamic);
|
||||
#endif
|
||||
|
||||
vec4 underwaterVlFog = vec4(0,0,0,1);
|
||||
|
@ -14,7 +14,7 @@ flat varying vec3 averageSkyCol_Clouds;
|
||||
flat varying vec3 WsunVec;
|
||||
flat varying vec3 refractedSunVec;
|
||||
|
||||
flat varying float tempOffsets;
|
||||
// flat varying float tempOffsets;
|
||||
|
||||
uniform sampler2D colortex4;
|
||||
flat varying float exposure;
|
||||
@ -44,11 +44,11 @@ void main() {
|
||||
// gl_Position.xy = (gl_Position.xy*0.5+0.5)*0.51*2.0-1.0;
|
||||
gl_Position.xy = (gl_Position.xy*0.5+0.5)*(0.01+VL_RENDER_RESOLUTION)*2.0-1.0;
|
||||
|
||||
#ifdef TAA
|
||||
tempOffsets = HaltonSeq2(frameCounter%10000);
|
||||
#else
|
||||
tempOffsets = 0.0;
|
||||
#endif
|
||||
// #ifdef TAA
|
||||
// tempOffsets = HaltonSeq2(frameCounter%10000);
|
||||
// #else
|
||||
// tempOffsets = 0.0;
|
||||
// #endif
|
||||
|
||||
#ifdef OVERWORLD_SHADER
|
||||
lightCol.rgb = texelFetch2D(colortex4,ivec2(6,37),0).rgb;
|
||||
@ -56,11 +56,11 @@ void main() {
|
||||
averageSkyCol_Clouds = texelFetch2D(colortex4,ivec2(0,37),0).rgb;
|
||||
|
||||
#if defined Daily_Weather
|
||||
dailyWeatherParams0 = vec4(texelFetch2D(colortex4,ivec2(1,1),0).rgb/150.0, 0.0);
|
||||
dailyWeatherParams1 = vec4(texelFetch2D(colortex4,ivec2(2,1),0).rgb/150.0, 0.0);
|
||||
dailyWeatherParams0 = vec4((texelFetch2D(colortex4,ivec2(1,1),0).rgb/150.0)/2.0, 0.0);
|
||||
dailyWeatherParams1 = vec4((texelFetch2D(colortex4,ivec2(2,1),0).rgb/150.0)/2.0, 0.0);
|
||||
|
||||
dailyWeatherParams0.a = texelFetch2D(colortex4,ivec2(3,1),0).x/150.0;
|
||||
dailyWeatherParams1.a = texelFetch2D(colortex4,ivec2(3,1),0).y/150.0;
|
||||
dailyWeatherParams0.a = (texelFetch2D(colortex4,ivec2(3,1),0).x/150.0)/2.0;
|
||||
dailyWeatherParams1.a = (texelFetch2D(colortex4,ivec2(3,1),0).y/150.0)/2.0;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user