disallow POM on signs, sample sky color (the one without clouds) to get an average color, it was too blue for me...clean up gbuffer program for my own convenience,

This commit is contained in:
Xonk 2023-06-27 00:18:41 -04:00
parent 6ed56f9f9a
commit d46a423c50
10 changed files with 224 additions and 334 deletions

View File

@ -11,7 +11,6 @@ const bool colortex12MipmapEnabled = true;
const bool shadowHardwareFiltering = true; const bool shadowHardwareFiltering = true;
flat varying vec3 averageSkyCol_Clouds; flat varying vec3 averageSkyCol_Clouds;
flat varying vec3 averageSkyCol;
flat varying vec4 lightCol; flat varying vec4 lightCol;
flat varying vec3 WsunVec; flat varying vec3 WsunVec;
@ -295,7 +294,7 @@ void waterVolumetrics(inout vec3 inColor, vec3 rayStart, vec3 rayEnd, float estE
#endif #endif
vec3 ambientMul = exp(-max(estEndDepth * d,0.0) * waterCoefs ); vec3 ambientMul = exp(-max(estEndDepth * d,0.0) * waterCoefs ) * 1.5;
vec3 sunMul = exp(-max(estSunDepth * d,0.0) * waterCoefs); vec3 sunMul = exp(-max(estSunDepth * d,0.0) * waterCoefs);
vec3 light = (sh * lightSource * phase * sunMul + (ambientMul*ambient) )*scatterCoef; vec3 light = (sh * lightSource * phase * sunMul + (ambientMul*ambient) )*scatterCoef;
@ -994,12 +993,13 @@ void main() {
float skylight = clamp(abs(ambientCoefs.y + 1.0),0.35,2.0); float skylight = clamp(abs(ambientCoefs.y + 1.0),0.35,2.0);
#if indirect_effect == 2 || indirect_effect == 3 || indirect_effect == 4 #if indirect_effect == 2 || indirect_effect == 3 || indirect_effect == 4
if (!hand) skylight = 1.0; if (!hand) skylight = 1.0;
#endif #endif
// do this to make underwater shading easier. // do this to make underwater shading easier.
vec2 newLightmap = lightmap.xy; vec2 newLightmap = lightmap.xy;
if((isEyeInWater == 0 && iswater) || (isEyeInWater == 1 && !iswater)) newLightmap.y = min(newLightmap.y+0.1,1.0);
if((isEyeInWater == 0 && iswater) || (isEyeInWater == 1 && !iswater)) newLightmap.y = clamp(newLightmap.y,0,1);
@ -1169,8 +1169,8 @@ void main() {
float custom_lightmap_T = pow(texture2D(colortex14, texcoord).a,1.5); float custom_lightmap_T = pow(texture2D(colortex14, texcoord).a,1.5);
vec3 ambientColVol = (averageSkyCol_Clouds * 8./150./1.5) * max(custom_lightmap_T,MIN_LIGHT_AMOUNT*0.001); vec3 ambientColVol = (averageSkyCol_Clouds*8./150./1.5) * max(custom_lightmap_T,MIN_LIGHT_AMOUNT*0.0015);
vec3 lightColVol = (lightCol.rgb / 80.) ; vec3 lightColVol = (lightCol.rgb / 80.);
if (isEyeInWater == 0) waterVolumetrics(gl_FragData[0].rgb, fragpos0, fragpos, estimatedDepth , estimatedSunDepth, Vdiff, noise, totEpsilon, scatterCoef, ambientColVol, lightColVol, dot(np3, WsunVec)); if (isEyeInWater == 0) waterVolumetrics(gl_FragData[0].rgb, fragpos0, fragpos, estimatedDepth , estimatedSunDepth, Vdiff, noise, totEpsilon, scatterCoef, ambientColVol, lightColVol, dot(np3, WsunVec));
} }

View File

@ -3,8 +3,6 @@
#include "lib/settings.glsl" #include "lib/settings.glsl"
flat varying vec3 averageSkyCol_Clouds; flat varying vec3 averageSkyCol_Clouds;
flat varying vec3 averageSkyCol;
flat varying vec4 lightCol; flat varying vec4 lightCol;
flat varying vec3 WsunVec; flat varying vec3 WsunVec;
@ -63,7 +61,7 @@ void main() {
#endif #endif
averageSkyCol_Clouds = texelFetch2D(colortex4,ivec2(0,37),0).rgb; averageSkyCol_Clouds = texelFetch2D(colortex4,ivec2(0,37),0).rgb;
averageSkyCol = texelFetch2D(colortex4,ivec2(1,37),0).rgb; // averageSkyCol = texelFetch2D(colortex4,ivec2(1,37),0).rgb;
// sunColor = texelFetch2D(colortex4,ivec2(6,37),0).rgb; // sunColor = texelFetch2D(colortex4,ivec2(6,37),0).rgb;
// moonColor = texelFetch2D(colortex4,ivec2(13,37),0).rgb; // moonColor = texelFetch2D(colortex4,ivec2(13,37),0).rgb;

View File

@ -303,9 +303,11 @@ void main() {
float estEyeDepth = clamp((14.0-eyeBrightnessSmooth.y/255.0*16.0)/14.0,0.,1.0); float estEyeDepth = clamp((14.0-eyeBrightnessSmooth.y/255.0*16.0)/14.0,0.,1.0);
estEyeDepth *= estEyeDepth*estEyeDepth*34.0; estEyeDepth *= estEyeDepth*estEyeDepth*34.0;
vec3 ambientColVol = max(averageSkyCol_Clouds*8./150./1.5,MIN_LIGHT_AMOUNT*0.0015);
vec3 lightColVol = (lightCol.rgb / 80.);
estEyeDepth = max(Water_Top_Layer - cameraPosition.y,0.0); estEyeDepth = max(Water_Top_Layer - cameraPosition.y,0.0);
waterVolumetrics(vl, vec3(0.0), fragpos, estEyeDepth, estEyeDepth, length(fragpos), noise, totEpsilon, scatterCoef, (averageSkyCol_Clouds*8./150./3.*0.5) , lightCol.rgb*8./150./3.0*(1.0-pow(1.0-sunElevation*lightCol.a,5.0)), dot(normalize(fragpos), normalize(sunVec) )); waterVolumetrics(vl, vec3(0.0), fragpos, estEyeDepth, estEyeDepth, length(fragpos), noise, totEpsilon, scatterCoef, ambientColVol, lightColVol*(1.0-pow(1.0-sunElevation*lightCol.a,5.0)) , dot(normalize(fragpos), normalize(sunVec) ));
gl_FragData[0] = clamp(vec4(vl,1.0),0.000001,65000.); gl_FragData[0] = clamp(vec4(vl,1.0),0.000001,65000.);
} }
} }

View File

@ -92,11 +92,13 @@ void main() {
pos.xy += normalize(sample3x3[i] * vec2(0.5,0.5)); pos.xy += normalize(sample3x3[i] * vec2(0.5,0.5));
averageSkyCol_Clouds += 2.0*skyCloudsFromTex(pos,colortex4).rgb/maxIT/150.; averageSkyCol_Clouds += 2.0*skyCloudsFromTex(pos,colortex4).rgb/maxIT/150.;
averageSkyCol += 1.5*skyFromTex(pos,colortex4).rgb/maxIT/150.; // please dont do an infinite feedback loop....
pos = normalize(vec3(0,1,0)); pos = normalize(vec3(0,1,0));
} }
// only need to sample one spot for this // // only need to sample one spot for this
averageSkyCol += 2.0*skyFromTex(normalize(vec3(0.0,1.0,0.0)),colortex4).rgb/150.; // averageSkyCol += 2.0*skyFromTex(normalize(vec3(0.0,1.0,0.0)),colortex4).rgb/150.;

View File

@ -32,11 +32,13 @@ const int MAX_OCCLUSION_POINTS = MAX_ITERATIONS;
uniform vec2 texelSize; uniform vec2 texelSize;
uniform int framemod8; uniform int framemod8;
#ifdef POM // #ifdef POM
varying vec4 vtexcoordam; // .st for add, .pq for mul varying vec4 vtexcoordam; // .st for add, .pq for mul
varying vec4 vtexcoord; varying vec4 vtexcoord;
#endif
vec2 dcdx = dFdx(vtexcoord.st*vtexcoordam.pq)*exp2(Texture_MipMap_Bias);
vec2 dcdy = dFdy(vtexcoord.st*vtexcoordam.pq)*exp2(Texture_MipMap_Bias);
// #endif
#include "/lib/res_params.glsl" #include "/lib/res_params.glsl"
varying vec4 lmtexcoord; varying vec4 lmtexcoord;
@ -61,11 +63,6 @@ varying vec4 normalMat;
uniform sampler2D specular; uniform sampler2D specular;
// #endif
#ifdef POM
vec2 dcdx = dFdx(vtexcoord.st*vtexcoordam.pq)*exp2(Texture_MipMap_Bias);
vec2 dcdy = dFdy(vtexcoord.st*vtexcoordam.pq)*exp2(Texture_MipMap_Bias);
#endif
uniform sampler2D texture; uniform sampler2D texture;
uniform sampler2D colortex1;//albedo(rgb),material(alpha) RGBA16 uniform sampler2D colortex1;//albedo(rgb),material(alpha) RGBA16
@ -195,10 +192,6 @@ vec3 toClipSpace3(vec3 viewSpacePosition) {
{ {
return texture2DGradARB(texture,fract(coord)*vtexcoordam.pq+vtexcoordam.st,dcdx,dcdy); return texture2DGradARB(texture,fract(coord)*vtexcoordam.pq+vtexcoordam.st,dcdx,dcdy);
} }
vec4 readNoise(in vec2 coord)
{
return texture2DGradARB(noisetex,(coord)*vtexcoordam.pq+vtexcoordam.st,dcdx,dcdy);
}
#endif #endif
@ -249,6 +242,95 @@ uniform float near;
float ld(float dist) { float ld(float dist) {
return (2.0 * near) / (far + near - dist * (far - near)); return (2.0 * near) / (far + near - dist * (far - near));
} }
// float EndPortalEffect(
// inout vec4 ALBEDO,
// vec3 FragPos,
// vec3 WorldPos,
// mat3 tbnMatrix
// ){
// float endportalGLow = 0.0;
// vec3 viewVec = normalize(tbnMatrix*FragPos);
// if (length(FragPos) < MAX_OCCLUSION_DISTANCE) {
// ALBEDO = vec4(0,0,0,1);
// float depth = 0.2;
// if ( viewVec.z < 0.0) {
// float noise = interleaved_gradientNoise_temp();
// vec3 interval = (viewVec.xyz /-viewVec.z/MAX_OCCLUSION_POINTS * POM_DEPTH) * 0.6 ;
// vec3 coord = vec3((lmtexcoord.st)/4, 1.0);
// coord += interval * noise;
// float sumVec = noise;
// for (int loopCount = 0; (loopCount < MAX_OCCLUSION_POINTS) && (1.0 - depth + depth * (1-readNoise(coord.st).r - readNoise((-coord.st*3 )).b*0.2) ) < coord.p && coord.p >= 0.0; ++loopCount) {
// coord = coord+interval ;
// sumVec += 1.0 ;
// endportalGLow += 0.01*0.6;
// }
// ALBEDO.rgb = vec3(0.5,0.75,1.0) * sqrt(endportalGLow);
// return clamp(pow(endportalGLow*3.5,5),0,1);
// }
// }
// }
vec4 readNoise(in vec2 coord){
return texture2D(noisetex,coord*vtexcoordam.pq + vtexcoordam.st);
}
float EndPortalEffect(
inout vec4 ALBEDO,
vec3 FragPos,
vec3 WorldPos,
mat3 tbnMatrix
){
int maxdist = 25;
int quality = 35;
vec3 viewVec = normalize(tbnMatrix*FragPos);
if ( viewVec.z < 0.0 && length(FragPos) < maxdist) {
float endportalGLow = 0.0;
float Depth = 0.3;
vec3 interval = (viewVec.xyz /-viewVec.z/quality*Depth) * (0.7 + (blueNoise()-0.5)*0.1);
vec3 coord = vec3(-(abs(WorldPos.zx + WorldPos.zx))/4, 1.0);
coord += interval;
for (int loopCount = 0; (loopCount < quality) && (1.0 - Depth + Depth * ( 1.0-readNoise(coord.st).r - readNoise(-coord.st*3).b*0.2 ) ) < coord.p && coord.p >= 0.0; ++loopCount) {
coord = coord+interval ;
endportalGLow += (0.3/quality);
}
ALBEDO.rgb = vec3(0.5,0.75,1.0) * sqrt(endportalGLow);
return clamp(pow(endportalGLow*3.5,3),0,1);
}
}
float bias(){
return Texture_MipMap_Bias + (blueNoise()-0.5)*0.5;
}
vec4 texture2D_POMSwitch(
sampler2D sampler,
vec2 lightmapCoord,
vec4 dcdxdcdy,
bool ifPOM
){
if(ifPOM){
return texture2DGradARB(sampler, lightmapCoord, dcdxdcdy.xy, dcdxdcdy.zw);
}else{
return texture2D(sampler, lightmapCoord, bias());
}
}
//////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN//////////////////////////////
@ -258,9 +340,15 @@ float ld(float dist) {
/* RENDERTARGETS: 1,7,8,15 */ /* RENDERTARGETS: 1,7,8,15 */
void main() { void main() {
bool ifPOM = false;
#ifdef POM
ifPOM = true;
#endif
if(SIGN > 0) ifPOM = false;
vec3 normal = normalMat.xyz; vec3 normal = normalMat.xyz;
#ifdef MC_NORMAL_MAP #ifdef MC_NORMAL_MAP
@ -273,19 +361,16 @@ void main() {
vec2 tempOffset=offsets[framemod8]; vec2 tempOffset=offsets[framemod8];
vec3 fragpos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0)); 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; vec3 worldpos = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz + cameraPosition;
float torchlightmap = lmtexcoord.z; float torchlightmap = lmtexcoord.z;
#ifdef Hand_Held_lights #ifdef Hand_Held_lights
// if(HELD_ITEM_BRIGHTNESS > 0.0) torchlightmap = mix(torchlightmap, HELD_ITEM_BRIGHTNESS, clamp( max(1.0-length(fragpos)/10,0.0) ,0.0,1.0));
if(HELD_ITEM_BRIGHTNESS > 0.0) torchlightmap = max(torchlightmap, HELD_ITEM_BRIGHTNESS * clamp( pow(max(1.0-length(fragpos)/10,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(fragpos)/10,0.0),1.5),0.0,1.0));
#endif #endif
float lightmap = clamp( (lmtexcoord.w-0.8) * 10.0,0.,1.); float lightmap = clamp( (lmtexcoord.w-0.8) * 10.0,0.,1.);
float rainfall = rainStrength * noPuddleAreas; float rainfall = rainStrength * noPuddleAreas;
float Puddle_shape = 0.; float Puddle_shape = 0.;
@ -300,36 +385,39 @@ void main() {
#endif #endif
#endif #endif
#endif #endif
vec2 adjustedTexCoord = lmtexcoord.xy;
#ifdef POM #ifdef POM
// vec2 tempOffset=offsets[framemod8]; #ifdef WORLD
vec2 adjustedTexCoord = fract(vtexcoord.st)*vtexcoordam.pq+vtexcoordam.st; // vec2 tempOffset=offsets[framemod8];
// vec3 fragpos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0)); adjustedTexCoord = fract(vtexcoord.st)*vtexcoordam.pq+vtexcoordam.st;
vec3 viewVector = normalize(tbnMatrix*fragpos); // vec3 fragpos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0));
float dist = length(fragpos); vec3 viewVector = normalize(tbnMatrix*fragpos);
float dist = length(fragpos);
gl_FragDepth = gl_FragCoord.z; gl_FragDepth = gl_FragCoord.z;
#ifdef WORLD
if (dist < MAX_OCCLUSION_DISTANCE) { if (dist < MAX_OCCLUSION_DISTANCE) {
float depthmap = readNormal(vtexcoord.st).a; float depthmap = readNormal(vtexcoord.st).a;
float used_POM_DEPTH = 1.0; float used_POM_DEPTH = 1.0;
if ( viewVector.z < 0.0 && depthmap < 0.9999 && depthmap > 0.00001) { if ( viewVector.z < 0.0 && depthmap < 0.9999 && depthmap > 0.00001) {
float noise = interleaved_gradientNoise_temp(); // float noise = interleaved_gradientNoise_temp();
#ifdef Adaptive_Step_length #ifdef Adaptive_Step_length
vec3 interval = (viewVector.xyz /-viewVector.z/MAX_OCCLUSION_POINTS * POM_DEPTH) * clamp(1.0-pow(depthmap,2),0.1,1.0) ; vec3 interval = (viewVector.xyz /-viewVector.z/MAX_OCCLUSION_POINTS * POM_DEPTH) * clamp(1.0-pow(depthmap,2),0.1,1.0);
used_POM_DEPTH = 1.0; used_POM_DEPTH = 1.0;
#else #else
vec3 interval = viewVector.xyz /-viewVector.z/MAX_OCCLUSION_POINTS*POM_DEPTH; vec3 interval = viewVector.xyz /-viewVector.z/MAX_OCCLUSION_POINTS*POM_DEPTH;
#endif #endif
vec3 coord = vec3(vtexcoord.st, 1.0); vec3 coord = vec3(vtexcoord.st , 1.0);
coord += (interval ) * used_POM_DEPTH; coord += interval * used_POM_DEPTH;
float sumVec = 0.5; float sumVec = 0.5;
for (int loopCount = 0; (loopCount < MAX_OCCLUSION_POINTS) && (1.0 - POM_DEPTH + POM_DEPTH * readNormal(coord.st).a ) < coord.p && coord.p >= 0.0; ++loopCount) { for (int loopCount = 0; (loopCount < MAX_OCCLUSION_POINTS) && (1.0 - POM_DEPTH + POM_DEPTH * readNormal(coord.st).a ) < coord.p && coord.p >= 0.0; ++loopCount) {
coord = coord+interval * used_POM_DEPTH; coord = coord + interval * used_POM_DEPTH;
sumVec += 1.0 * used_POM_DEPTH; sumVec += 1.0 * used_POM_DEPTH;
} }
@ -339,6 +427,7 @@ void main() {
discard; discard;
} }
} }
adjustedTexCoord = mix(fract(coord.st)*vtexcoordam.pq+vtexcoordam.st, adjustedTexCoord, max(dist-MIX_OCCLUSION_DISTANCE,0.0)/(MAX_OCCLUSION_DISTANCE-MIX_OCCLUSION_DISTANCE)); adjustedTexCoord = mix(fract(coord.st)*vtexcoordam.pq+vtexcoordam.st, adjustedTexCoord, max(dist-MIX_OCCLUSION_DISTANCE,0.0)/(MAX_OCCLUSION_DISTANCE-MIX_OCCLUSION_DISTANCE));
vec3 truePos = fragpos + sumVec*inverse(tbnMatrix)*interval; vec3 truePos = fragpos + sumVec*inverse(tbnMatrix)*interval;
@ -347,233 +436,93 @@ void main() {
// #endif // #endif
} }
} }
#endif
#endif
if(!ifPOM) adjustedTexCoord = lmtexcoord.xy;
#endif
////////////////////////////////
//////////////////////////////// ALBEDO
////////////////////////////////
vec4 Albedo = texture2DGradARB(texture, adjustedTexCoord.xy, dcdx,dcdy) * color;
float endportalGLow = 0;
// if (dist < MAX_OCCLUSION_DISTANCE && PORTAL > 0) {
// Albedo = vec4(0,0,0,1);
// float used_POM_DEPTH = 1.0;
// float depth = 0.2;
// if ( viewVector.z < 0.0) {
// float noise = interleaved_gradientNoise_temp();
// vec3 interval = (viewVector.xyz /-viewVector.z/MAX_OCCLUSION_POINTS * POM_DEPTH) * 0.6 ;
// used_POM_DEPTH = 1.0;
// vec3 coord = vec3(-abs(worldpos.zx)/4, 1.0); //////////////////////////////// ////////////////////////////////
//////////////////////////////// ALBEDO ////////////////////////////////
// coord += interval * noise; //////////////////////////////// ////////////////////////////////
// float sumVec = noise;
// for (int loopCount = 0; (loopCount < MAX_OCCLUSION_POINTS) && (1.0 - depth + depth * (1-readNoise(coord.st).r - readNoise((-coord.st*3 )).b*0.2) ) < coord.p && coord.p >= 0.0; ++loopCount) {
// coord = coord+interval ;
// sumVec += 1.0 ;
// endportalGLow += 0.01*0.6;
// }
// vec3 truePos = fragpos + sumVec*inverse(tbnMatrix)*interval;
// Albedo.rgb += vec3(0.5,0.75,1.0) * sqrt(endportalGLow);
// endportalGLow = clamp(pow(endportalGLow*3.5,5),0,1);
// }
// }
#ifdef ENTITIES
if(NameTags == 1) Albedo = texture2D(texture, lmtexcoord.xy, Texture_MipMap_Bias) * color;
#endif
#ifdef AEROCHROME_MODE
vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631), AEROCHROME_PINKNESS);
float gray = dot(Albedo.rgb, vec3(0.2, 01.0, 0.07));
if(blockID == 10001 || blockID == 10003 || blockID == 10004 || blockID == 10006) {
// IR Reflective (Pink-red)
Albedo.rgb = mix(vec3(gray), aerochrome_color, 0.7);
}
else if(blockID == 10008) {
// Special handling for grass block
float strength = 1.0 - color.b;
Albedo.rgb = mix(Albedo.rgb, aerochrome_color, strength);
}
#ifdef AEROCHROME_WOOL_ENABLED
else if(blockID == 200) {
// Wool
Albedo.rgb = mix(Albedo.rgb, aerochrome_color, 0.3);
}
#endif
else if(blockID == 8 || blockID == 10002)
{
// IR Absorbsive? Dark.
Albedo.rgb = mix(Albedo.rgb, vec3(0.01, 0.08, 0.15), 0.5);
}
#endif
#ifdef WhiteWorld
Albedo.rgb = vec3(1.0);
#endif
#ifdef DISABLE_ALPHA_MIPMAPS
Albedo.a = texture2DGradARB(texture, adjustedTexCoord.xy,vec2(0.),vec2(0.0)).a;
#endif
#ifdef WORLD
if (Albedo.a > 0.1) Albedo.a = normalMat.a;
else Albedo.a = 0.0;
#endif
#ifdef HAND
if (Albedo.a > 0.1) Albedo.a = 0.75;
else Albedo.a = 0.0;
#endif
////////////////////////////////
//////////////////////////////// NORMAL
////////////////////////////////
#ifdef MC_NORMAL_MAP
vec3 NormalTex = texture2DGradARB(normals, adjustedTexCoord.xy, dcdx,dcdy).rgb;
NormalTex.xy = NormalTex.xy*2.0-1.0;
NormalTex.z = clamp(sqrt(1.0 - dot(NormalTex.xy, NormalTex.xy)),0.0,1.0);
normal = applyBump(tbnMatrix,NormalTex, mix(1.0,1.0-Puddle_shape,rainfall));
// #ifdef ENTITIES
// if(NameTags == 1) normal = vec3(1);
// #endif
#endif
////////////////////////////////
//////////////////////////////// SPECULAR
////////////////////////////////
vec4 SpecularTex = texture2DGradARB(specular, adjustedTexCoord.xy,dcdx,dcdy);
SpecularTex.r = max(SpecularTex.r, Puddle_shape);
SpecularTex.g = max(SpecularTex.g, Puddle_shape*0.04);
// #ifdef ENTITIES
// if(NameTags == 1) SpecularTex = vec4(0.0);
// #endif
gl_FragData[2].rg = SpecularTex.rg;
#ifdef LabPBR_Emissives
gl_FragData[2].a = SpecularTex.a;
#else
gl_FragData[2].a = EMISSIVE;
#endif
if(PORTAL > 0) gl_FragData[2].a = clamp(endportalGLow * 0.9 ,0,0.9);
#if SSS_TYPE == 0
gl_FragData[2].b = 0.0;
#endif
#if SSS_TYPE == 1
gl_FragData[2].b = SSSAMOUNT;
#endif
#if SSS_TYPE == 2
gl_FragData[2].b = SpecularTex.b;
if(SpecularTex.b < 65.0/255.0) gl_FragData[2].b = SSSAMOUNT;
#endif
#if SSS_TYPE == 3
gl_FragData[2].b = SpecularTex.b;
#endif
////////////////////////////////
//////////////////////////////// FINALIZE
////////////////////////////////
#ifdef Puddles
float porosity = 0.35;
#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
vec4 data1 = clamp(encode(viewToWorld(normal), (blueNoise()*vec2(torchlightmap,lmtexcoord.w)/(30.0 * (1+ (1-RENDER_SCALE.x)))) + vec2(torchlightmap,lmtexcoord.w)),0.,1.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[1].a = 0.0;
#else
float bias = Texture_MipMap_Bias - blueNoise()*0.5;
////////////////////////////////
//////////////////////////////// NORMAL
////////////////////////////////
vec4 Albedo = texture2D_POMSwitch(texture, adjustedTexCoord.xy, vec4(dcdx,dcdy), ifPOM) * color;
// float ENDPORTAL_EFFECT = PORTAL > 0 ? EndPortalEffect(Albedo, fragpos, worldpos, tbnMatrix) : 0;
#ifdef WhiteWorld
Albedo.rgb = vec3(1.0);
#endif
#ifdef AEROCHROME_MODE
vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631), AEROCHROME_PINKNESS);
float gray = dot(Albedo.rgb, vec3(0.2, 01.0, 0.07));
if(blockID == 10001 || blockID == 10003 || blockID == 10004 || blockID == 10006) {
// IR Reflective (Pink-red)
Albedo.rgb = mix(vec3(gray), aerochrome_color, 0.7);
}
else if(blockID == 10008) {
// Special handling for grass block
float strength = 1.0 - color.b;
Albedo.rgb = mix(Albedo.rgb, aerochrome_color, strength);
}
#ifdef AEROCHROME_WOOL_ENABLED
else if(blockID == 200) {
// Wool
Albedo.rgb = mix(Albedo.rgb, aerochrome_color, 0.3);
}
#endif
else if(blockID == 8 || blockID == 10002)
{
// IR Absorbsive? Dark.
Albedo.rgb = mix(Albedo.rgb, vec3(0.01, 0.08, 0.15), 0.5);
}
#endif
#ifdef WORLD
if (Albedo.a > 0.1) Albedo.a = normalMat.a;
else Albedo.a = 0.0;
#endif
#ifdef HAND
if (Albedo.a > 0.1) Albedo.a = 0.75;
else Albedo.a = 0.0;
#endif
//////////////////////////////// ////////////////////////////////
//////////////////////////////// NORMAL ////////////////////////////////
//////////////////////////////// ////////////////////////////////
#ifdef WORLD #ifdef WORLD
#ifdef MC_NORMAL_MAP #ifdef MC_NORMAL_MAP
vec4 NormalTex = texture2D(normals, lmtexcoord.xy, bias).rgba;
vec4 NormalTex = texture2D_POMSwitch(normals, adjustedTexCoord.xy, vec4(dcdx,dcdy), ifPOM);
NormalTex.xy = NormalTex.xy*2.0-1.0; NormalTex.xy = NormalTex.xy*2.0-1.0;
NormalTex.z = clamp(sqrt(1.0 - dot(NormalTex.xy, NormalTex.xy)),0.0,1.0) ; NormalTex.z = clamp(sqrt(1.0 - dot(NormalTex.xy, NormalTex.xy)),0.0,1.0) ;
if(PHYSICSMOD_SNOW < 1)normal = applyBump(tbnMatrix, NormalTex.xyz, mix(1.0,1-Puddle_shape,rainfall) ); if(PHYSICSMOD_SNOW < 1) normal = applyBump(tbnMatrix, NormalTex.xyz, mix(1.0,1-Puddle_shape,rainfall) );
// #ifdef ENTITIES
// if(NameTags == 1) normal = vec3(1);
// #endif
// #ifdef ENTITY_PHYSICSMOD_SNOW
// normal = FlatNormals;
// #endif
#endif #endif
#endif #endif
//////////////////////////////// //////////////////////////////// ////////////////////////////////
//////////////////////////////// SPECULAR //////////////////////////////// SPECULAR ////////////////////////////////
//////////////////////////////// //////////////////////////////// ////////////////////////////////
#ifdef WORLD #ifdef WORLD
vec4 SpecularTex = texture2D(specular, lmtexcoord.xy, bias); vec4 SpecularTex = texture2D_POMSwitch(specular, adjustedTexCoord.xy, vec4(dcdx,dcdy), ifPOM);
SpecularTex.r = max(SpecularTex.r, Puddle_shape); SpecularTex.r = max(SpecularTex.r, Puddle_shape);
SpecularTex.g = max(SpecularTex.g, Puddle_shape*0.02); SpecularTex.g = max(SpecularTex.g, Puddle_shape*0.02);
// #ifdef ENTITIES
// if(NameTags == 1) SpecularTex = vec4(0.0);
// #endif
gl_FragData[2].rg = SpecularTex.rg; gl_FragData[2].rg = SpecularTex.rg;
// #ifdef LabPBR_Emissives
// gl_FragData[2].a = SpecularTex.a;
// if(SpecularTex.a <= 0.0) gl_FragData[2].a = EMISSIVE;
// #else
// gl_FragData[2].a = SpecularTex.a;
// if(SpecularTex.a <= 0.0) gl_FragData[2].a = EMISSIVE;
// // gl_FragData[2].a = EMISSIVE;
// #endif
#if EMISSIVE_TYPE == 0 #if EMISSIVE_TYPE == 0
gl_FragData[2].a = 0.0; gl_FragData[2].a = 0.0;
#endif #endif
#if EMISSIVE_TYPE == 1 #if EMISSIVE_TYPE == 1
gl_FragData[2].a = EMISSIVE gl_FragData[2].a = EMISSIVE;
#endif #endif
#if EMISSIVE_TYPE == 2 #if EMISSIVE_TYPE == 2
@ -585,8 +534,6 @@ void main() {
gl_FragData[2].a = SpecularTex.a; gl_FragData[2].a = SpecularTex.a;
#endif #endif
#if SSS_TYPE == 0 #if SSS_TYPE == 0
gl_FragData[2].b = 0.0; gl_FragData[2].b = 0.0;
#endif #endif
@ -604,56 +551,18 @@ void main() {
gl_FragData[2].b = SpecularTex.b; gl_FragData[2].b = SpecularTex.b;
#endif #endif
// if(PORTAL > 0){
// gl_FragData[2].rgb = vec3(0);
// gl_FragData[2].a = clamp(ENDPORTAL_EFFECT * 0.9, 0,0.9);
// }
#endif #endif
// #ifdef ENTITIES //////////////////////////////// ////////////////////////////////
// if(LIGHTNING > 0) gl_FragData[2].a = 0.9; //////////////////////////////// FINALIZE ////////////////////////////////
// #endif //////////////////////////////// ////////////////////////////////
////////////////////////////////
//////////////////////////////// ALBEDO
////////////////////////////////
#ifdef WORLD #ifdef WORLD
vec4 Albedo = texture2D(texture, lmtexcoord.xy, bias) * color;
#ifdef WhiteWorld
Albedo.rgb = vec3(1.0);
#endif
if(LIGHTNING > 0) Albedo = vec4(1);
#ifdef AEROCHROME_MODE
vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631), AEROCHROME_PINKNESS);
float gray = dot(Albedo.rgb, vec3(0.2, 01.0, 0.07));
if(blockID == 10001 || blockID == 10003 || blockID == 10004 || blockID == 10006) {
// IR Reflective (Pink-red)
Albedo.rgb = mix(vec3(gray), aerochrome_color, 0.7);
}
else if(blockID == 10008) {
// Special handling for grass block
float strength = 1.0 - color.b;
Albedo.rgb = mix(Albedo.rgb, aerochrome_color, strength);
}
#ifdef AEROCHROME_WOOL_ENABLED
else if(blockID == 200) {
// Wool
Albedo.rgb = mix(Albedo.rgb, aerochrome_color, 0.3);
}
#endif
else if(blockID == 8 || blockID == 10002)
{
// IR Absorbsive? Dark.
Albedo.rgb = mix(Albedo.rgb, vec3(0.01, 0.08, 0.15), 0.5);
}
#endif
#ifdef DISABLE_ALPHA_MIPMAPS
Albedo.a = texture2DLod(texture,lmtexcoord.xy,0).a;
#endif
#ifdef Puddles #ifdef Puddles
float porosity = 0.35; float porosity = 0.35;
@ -662,23 +571,7 @@ void main() {
#endif #endif
if(SpecularTex.g < 229.5/255.0) Albedo.rgb = mix(Albedo.rgb, vec3(0), Puddle_shape*porosity); if(SpecularTex.g < 229.5/255.0) Albedo.rgb = mix(Albedo.rgb, vec3(0), Puddle_shape*porosity);
#endif #endif
#ifdef WORLD
if (Albedo.a > 0.1) Albedo.a = normalMat.a;
else Albedo.a = 0.0;
#endif
#ifdef HAND
if (Albedo.a > 0.1) Albedo.a = 0.75;
else Albedo.a = 0.0;
#endif
////////////////////////////////
//////////////////////////////// FINALIZE
////////////////////////////////
// vec4 data1 = clamp( encode(viewToWorld(normal), (blueNoise()*lmtexcoord.zw/30.0) + lmtexcoord.zw), 0.0, 1.0);
vec4 data1 = clamp( encode(viewToWorld(normal), (blueNoise()*vec2(torchlightmap,lmtexcoord.w) / (30.0 * (1+ (1-RENDER_SCALE.x))) ) + vec2(torchlightmap,lmtexcoord.w)), 0.0, 1.0); vec4 data1 = clamp( encode(viewToWorld(normal), (blueNoise()*vec2(torchlightmap,lmtexcoord.w) / (30.0 * (1+ (1-RENDER_SCALE.x))) ) + vec2(torchlightmap,lmtexcoord.w)), 0.0, 1.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));
@ -686,15 +579,15 @@ void main() {
gl_FragData[1].a = 0.0; gl_FragData[1].a = 0.0;
#endif #endif
#endif
#ifdef WORLD #ifdef WORLD
gl_FragData[5].x = 0; gl_FragData[5].x = 0;
#ifdef ENTITIES #ifdef ENTITIES
gl_FragData[5].xyz = velocity *0.5+0.5; gl_FragData[5].xyz = velocity *0.5+0.5;
#endif #endif
gl_FragData[3] = vec4(FlatNormals * 0.5 + 0.5,VanillaAO); gl_FragData[3] = vec4(FlatNormals * 0.5 + 0.5,VanillaAO);
#endif #endif
} }

View File

@ -31,10 +31,10 @@ varying float VanillaAO;
varying vec4 lmtexcoord; varying vec4 lmtexcoord;
varying vec4 normalMat; varying vec4 normalMat;
#ifdef POM // #ifdef POM
varying vec4 vtexcoordam; // .st for add, .pq for mul varying vec4 vtexcoordam; // .st for add, .pq for mul
varying vec4 vtexcoord; varying vec4 vtexcoord;
#endif // #endif
#ifdef MC_NORMAL_MAP #ifdef MC_NORMAL_MAP
varying vec4 tangent; varying vec4 tangent;
@ -194,13 +194,13 @@ void main() {
lmtexcoord.xy = (gl_MultiTexCoord0).xy; lmtexcoord.xy = (gl_MultiTexCoord0).xy;
#ifdef POM // #ifdef POM
vec2 midcoord = (gl_TextureMatrix[0] * mc_midTexCoord).st; vec2 midcoord = (gl_TextureMatrix[0] * mc_midTexCoord).st;
vec2 texcoordminusmid = lmtexcoord.xy-midcoord; vec2 texcoordminusmid = lmtexcoord.xy-midcoord;
vtexcoordam.pq = abs(texcoordminusmid)*2; vtexcoordam.pq = abs(texcoordminusmid)*2;
vtexcoordam.st = min(lmtexcoord.xy,midcoord-texcoordminusmid); vtexcoordam.st = min(lmtexcoord.xy,midcoord-texcoordminusmid);
vtexcoord.xy = sign(texcoordminusmid)*0.5+0.5; vtexcoord.xy = sign(texcoordminusmid)*0.5+0.5;
#endif // #endif
vec2 lmcoord = gl_MultiTexCoord1.xy / 255.0; // is this even correct? lol' vec2 lmcoord = gl_MultiTexCoord1.xy / 255.0; // is this even correct? lol'
lmtexcoord.zw = lmcoord; lmtexcoord.zw = lmcoord;
@ -244,7 +244,6 @@ void main() {
if(entityId == 1100 || entityId == 1200 || entityId == 2468) normalMat.a = 0.45; if(entityId == 1100 || entityId == 1200 || entityId == 2468) normalMat.a = 0.45;
#endif #endif
if(mc_Entity.x == 10003) normalMat.a = 0.55; if(mc_Entity.x == 10003) normalMat.a = 0.55;
@ -255,22 +254,19 @@ void main() {
// if(NameTags > 0) EMISSIVE = 0.9; // if(NameTags > 0) EMISSIVE = 0.9;
// normal block lightsources // normal block lightsources
if(mc_Entity.x == 10005) EMISSIVE = 0.9; if(mc_Entity.x == 10005) EMISSIVE = 0.5;
// special cases light lightning and beacon beams... // special cases light lightning and beacon beams...
#ifdef ENTITIES #ifdef ENTITIES
if(entityId == 12345){ if(entityId == 12345){
LIGHTNING = 1; LIGHTNING = 1;
normalMat.a = 0.5; normalMat.a = 0.5;
} }
#endif #endif
/////// ----- SSS STUFF ----- /////// /////// ----- SSS STUFF ----- ///////
SSSAMOUNT = 0.0; SSSAMOUNT = 0.0;
HELD_ITEM_BRIGHTNESS = 0.0; HELD_ITEM_BRIGHTNESS = 0.0;
#ifdef Hand_Held_lights #ifdef Hand_Held_lights

View File

@ -60,7 +60,7 @@ uniform ivec2 eyeBrightnessSmooth;
flat varying vec4 lightCol; //main light source color (rgb),used light source(1=sun,-1=moon) flat varying vec4 lightCol; //main light source color (rgb),used light source(1=sun,-1=moon)
flat varying vec3 averageSkyCol_Clouds; flat varying vec3 averageSkyCol_Clouds;
flat varying vec3 averageSkyCol; // flat varying vec3 averageSkyCol;
@ -462,6 +462,7 @@ if (gl_FragCoord.x * texelSize.x < RENDER_SCALE.x && gl_FragCoord.y * texelSize
// SSR, Sky, and Sun reflections // SSR, Sky, and Sun reflections
#ifdef WATER_BACKGROUND_SPECULAR #ifdef WATER_BACKGROUND_SPECULAR
SkyReflection = skyCloudsFromTex(wrefl,colortex4).rgb / 150. * 5.; SkyReflection = skyCloudsFromTex(wrefl,colortex4).rgb / 150. * 5.;
// SkyReflection = vec3(CaveFogColor_R,CaveFogColor_G,CaveFogColor_B)/
#endif #endif
#ifdef WATER_SUN_SPECULAR #ifdef WATER_SUN_SPECULAR
SunReflection = Direct_lighting * GGX(normal, -normalize(fragpos), lightSign*sunVec, roughness, vec3(f0)); SunReflection = Direct_lighting * GGX(normal, -normalize(fragpos), lightSign*sunVec, roughness, vec3(f0));

View File

@ -153,6 +153,6 @@ void main() {
WsunVec = lightCol.a*normalize(mat3(gbufferModelViewInverse) *sunPosition); WsunVec = lightCol.a*normalize(mat3(gbufferModelViewInverse) *sunPosition);
averageSkyCol_Clouds = texelFetch2D(colortex4,ivec2(0,37),0).rgb; averageSkyCol_Clouds = texelFetch2D(colortex4,ivec2(0,37),0).rgb;
averageSkyCol = texelFetch2D(colortex4,ivec2(1,37),0).rgb; // averageSkyCol = texelFetch2D(colortex4,ivec2(1,37),0).rgb;
} }

View File

@ -281,8 +281,7 @@ void MaterialReflections(
#endif #endif
if (hasReflections) { // Skip sky reflection and SSR if its just not very visible anyway if (hasReflections) { // Skip sky reflection and SSR if its just not very visible anyway
#ifdef Screen_Space_Reflections #ifdef Screen_Space_Reflections
float rayQuality = mix_float(reflection_quality,6.0,rayContribLuma); // Scale quality with ray contribution float rayQuality = mix_float(reflection_quality,6.0,rayContribLuma); // Scale quality with ray contribution
@ -294,7 +293,7 @@ void MaterialReflections(
noise.b = mix_float(noise.b, 0.5 + (noise.b-0.5),rayContribLuma); noise.b = mix_float(noise.b, 0.5 + (noise.b-0.5),rayContribLuma);
if(hand) {rayQuality = max(rayQuality,30.0); noise.b = 0.5 + (noise.b-0.5);} if(hand) {rayQuality = max(rayQuality,30.0); noise.b = 0.5 + (noise.b-0.5);}
vec3 rtPos = rayTraceSpeculars(mat3(gbufferModelView) * L, fragpos.xyz, noise.b, rayQuality, hand, reflectLength); vec3 rtPos = rayTraceSpeculars(mat3(gbufferModelView) * L, fragpos.xyz, (noise.b), rayQuality, hand, reflectLength);
float LOD = clamp(reflectLength * 6.0, 0.0,6.0); float LOD = clamp(reflectLength * 6.0, 0.0,6.0);
if(hand || isEntities) LOD = VisibilityFactor*6; if(hand || isEntities) LOD = VisibilityFactor*6;

View File

@ -146,8 +146,7 @@ vec3 Cloud_lighting(
float powder = 1.0 - exp(CloudShape * coeeff/3); float powder = 1.0 - exp(CloudShape * coeeff/3);
float lesspowder = powder*0.4+0.6; float lesspowder = powder*0.4+0.6;
vec3 skyLighting = SkyColors;
vec3 skyLighting = SkyColors; // skyLighting = vec3(0.0);
#ifdef Altostratus #ifdef Altostratus
/// a special conditon where scattered light exiting altocumulus clouds come down onto the cumulus clouds below. /// a special conditon where scattered light exiting altocumulus clouds come down onto the cumulus clouds below.