added a contrast setting. make beacon beams and enchantment glint work in the end and nether. tweak lighting in the end and nether.

This commit is contained in:
Xonk
2023-07-06 20:47:26 -04:00
parent 4ec1a86639
commit b62cb8aa4b
36 changed files with 262 additions and 616 deletions

View File

@ -448,7 +448,9 @@ void main() {
p3 += gbufferModelViewInverse[3].xyz + cameraPosition;
vec3 FogColor = (gl_Fog.color.rgb / pow(0.00001 + dot(gl_Fog.color.rgb,vec3(0.3333)),1.0) ) * 0.2;
// vec3 FogColor = (gl_Fog.color.rgb / pow(0.00001 + dot(gl_Fog.color.rgb,vec3(0.3333)),1.0) ) * 0.2;
// vec3 fogColor = (gl_Fog.color.rgb / max(pow(dot(gl_Fog.color.rgb,vec3(0.3333)),1.1),0.01) ) ;
vec3 FogColor = (gl_Fog.color.rgb / max(dot(gl_Fog.color.rgb,vec3(0.3333)),0.01) );
// do all ambient lighting stuff
vec3 Indirect_lighting = DoAmbientLighting_Nether(FogColor, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, normal, np3, p3 );
@ -457,31 +459,9 @@ void main() {
if(!hand) Indirect_lighting *= ssao(fragpos,noise,FlatNormals) * AO;
// ScreenSpace_SSS(Indirect_SSS, fragpos, vec2(R2_dither()), FlatNormals);
// Indirect_lighting *= 1 + SubsurfaceScattering_sky(albedo, Indirect_SSS, LabSSS) * 5;
vec3 LightColor = LightSourceColor();
float SdotV = dot(normalize(viewspace_sunvec), normalize(fragpos));
float OrbMie = max(exp((p3.y - 60) / -30.),0);
// 0.5 added because lightsources are always high radius.
float NdotL = clamp( dot(normal,normalize(WsunVec)) + 0.25,0.0,1.0);
vec3 LightSource = LightColor * NdotL * OrbMie ;
// LightSource *= rayTraceShadow(worldToView(normalize(-LightPos)), fragpos, interleaved_gradientNoise());
// LightSource *= GetCloudShadow(p3, WsunVec, blueNoise());
// finalize
gl_FragData[0].rgb = Indirect_lighting * albedo;
// gl_FragData[0].rgb = LightSource * albedo;
#ifdef Specular_Reflections
MaterialReflections_N(gl_FragData[0].rgb, SpecularTex.r, SpecularTex.ggg, albedo, normal, np3, fragpos, vec3(blueNoise(gl_FragCoord.xy).rg,noise), hand);

View File

@ -5,12 +5,12 @@
#include "/lib/settings.glsl"
flat varying vec4 lightCol;
flat varying vec3 ambientUp;
flat varying vec3 ambientLeft;
flat varying vec3 ambientRight;
flat varying vec3 ambientB;
flat varying vec3 ambientF;
flat varying vec3 ambientDown;
// flat varying vec3 ambientUp;
// flat varying vec3 ambientLeft;
// flat varying vec3 ambientRight;
// flat varying vec3 ambientB;
// flat varying vec3 ambientF;
// flat varying vec3 ambientDown;
flat varying float tempOffsets;
flat varying float fogAmount;
flat varying float VFAmount;

View File

@ -5,12 +5,12 @@
#include "/lib/settings.glsl"
flat varying vec3 ambientUp;
flat varying vec3 ambientLeft;
flat varying vec3 ambientRight;
flat varying vec3 ambientB;
flat varying vec3 ambientF;
flat varying vec3 ambientDown;
// flat varying vec3 ambientUp;
// flat varying vec3 ambientLeft;
// flat varying vec3 ambientRight;
// flat varying vec3 ambientB;
// flat varying vec3 ambientF;
// flat varying vec3 ambientDown;
flat varying vec3 lightSourceColor;
flat varying vec3 sunColor;
flat varying vec3 sunColorCloud;

View File

@ -3,12 +3,12 @@
#include "/lib/settings.glsl"
flat varying vec3 ambientUp;
flat varying vec3 ambientLeft;
flat varying vec3 ambientRight;
flat varying vec3 ambientB;
flat varying vec3 ambientF;
flat varying vec3 ambientDown;
// flat varying vec3 ambientUp;
// flat varying vec3 ambientLeft;
// flat varying vec3 ambientRight;
// flat varying vec3 ambientB;
// flat varying vec3 ambientF;
// flat varying vec3 ambientDown;
flat varying vec3 zenithColor;
flat varying vec3 sunColor;
flat varying vec3 sunColorCloud;

View File

@ -69,6 +69,11 @@ vec4 SampleTextureCatmullRom(sampler2D tex, vec2 uv, vec2 texSize )
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;
}
void main() {
#ifdef BICUBIC_UPSCALING
vec3 col = SampleTextureCatmullRom(colortex7,texcoord,1.0/texelSize).rgb;
@ -96,6 +101,9 @@ void main() {
vec3 diff = col-lum;
col = col + diff*(-lum*CROSSTALK + SATURATION);
//col = -vec3(-lum*CROSSFADING + SATURATION);
applyContrast(col, CONTRAST);
gl_FragColor.rgb = clamp(int8Dither(col,texcoord),0.0,1.0);
//gl_FragColor.rgb = vec3(contrast);
}

View File

@ -1,81 +1,25 @@
#version 120
//#extension GL_EXT_gpu_shader4 : disable
#include "/lib/settings.glsl"
varying vec4 lmtexcoord;
varying vec4 color;
varying vec4 normalMat;
uniform sampler2D texture;
uniform sampler2D gaux1;
uniform vec4 lightCol;
uniform vec3 sunVec;
uniform vec2 texelSize;
uniform float skyIntensityNight;
uniform float skyIntensity;
uniform float sunElevation;
uniform mat4 gbufferProjectionInverse;
uniform mat4 gbufferModelViewInverse;
uniform mat4 shadowModelView;
uniform mat4 shadowProjection;
//faster and actually more precise than pow 2.2
vec3 toLinear(vec3 sRGB){
return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878);
}
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz)
vec3 toScreenSpace(vec3 p) {
vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw);
vec3 p3 = p * 2. - 1.;
vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3];
return fragposition.xyz / fragposition.w;
}
float interleaved_gradientNoise(){
vec2 coord = gl_FragCoord.xy;
float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y));
return noise;
}
float facos(float sx){
float x = clamp(abs( sx ),0.,1.);
float a = sqrt( 1. - x ) * ( -0.16882 * x + 1.56734 );
return sx > 0. ? a : 3.14159265359 - a;
}
#define SHADOW_MAP_BIAS 0.8
float calcDistort(vec2 worlpos){
vec2 pos = worlpos * 1.165;
vec2 posSQ = pos*pos;
float distb = pow(posSQ.x*posSQ.x*posSQ.x + posSQ.y*posSQ.y*posSQ.y, 1.0 / 6.0);
return 1.08695652/((1.0 - SHADOW_MAP_BIAS) + distb * SHADOW_MAP_BIAS);
}
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
/* DRAWBUFFERS:2 */
void main() {
gl_FragData[0] = texture2D(texture, lmtexcoord.xy);
vec3 albedo = toLinear(gl_FragData[0].rgb*color.rgb);
float exposure = texelFetch2D(gaux1,ivec2(10,37),0).r;
vec3 col = albedo*exp(-exposure*3.);
gl_FragData[0].rgb = col*color.a;
gl_FragData[0].a = gl_FragData[0].a*0.1;
gl_FragData[0] = vec4(toLinear( texture2D(texture, lmtexcoord.xy).rgb * color.rgb), 0.1);
}

View File

@ -1,5 +1,6 @@
#version 120
//#extension GL_EXT_gpu_shader4 : disable
#include "/lib/settings.glsl"
#include "/lib/res_params.glsl"
/*
@ -11,26 +12,17 @@ Read the terms of modification and sharing before changing something below pleas
varying vec4 lmtexcoord;
varying vec4 color;
varying vec4 normalMat;
#ifdef MC_NORMAL_MAP
varying vec4 tangent;
attribute vec4 at_tangent;
#endif
uniform vec2 texelSize;
uniform int framemod8;
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-1.,3.)/8.,
vec2(5.0,1.)/8.,
vec2(-3,-5.)/8.,
vec2(-5.,5.)/8.,
vec2(-7.,-1.)/8.,
vec2(3,7.)/8.,
vec2(7.,-7.)/8.);
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz)
vec4 toClipSpace3(vec3 viewSpacePosition) {
return vec4(projMAD(gl_ProjectionMatrix, viewSpacePosition),-viewSpacePosition.z);
}
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-1.,3.)/8.,
vec2(5.0,1.)/8.,
vec2(-3,-5.)/8.,
vec2(-5.,5.)/8.,
vec2(-7.,-1.)/8.,
vec2(3,7.)/8.,
vec2(7.,-7.)/8.);
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
@ -39,27 +31,17 @@ vec4 toClipSpace3(vec3 viewSpacePosition) {
//////////////////////////////VOID MAIN//////////////////////////////
void main() {
gl_Position = ftransform();
lmtexcoord.xy = (gl_TextureMatrix[0] * gl_MultiTexCoord0).st;
vec2 lmcoord = gl_MultiTexCoord1.xy/255.;
lmtexcoord.zw = lmcoord*lmcoord;
vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz;
color = gl_Color;
gl_Position = toClipSpace3(position);
#ifdef MC_NORMAL_MAP
tangent = vec4(normalize(gl_NormalMatrix *at_tangent.rgb),at_tangent.w);
#endif
normalMat = vec4(normalize(gl_NormalMatrix *gl_Normal),1.0);
// #ifdef TAA_UPSCALING
// gl_Position.xy = gl_Position.xy * RENDER_SCALE + RENDER_SCALE * gl_Position.w - gl_Position.w;
// #endif
color = gl_Color;
#ifdef TAA
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
#endif
}

View File

@ -1,64 +1,32 @@
#version 120
//#extension GL_EXT_gpu_shader4 : disable
varying vec4 lmtexcoord;
varying vec4 color;
varying vec4 normalMat;
#define SHADOW_MAP_BIAS 0.8
varying vec2 texcoord;
uniform sampler2D texture;
uniform vec4 lightCol;
uniform vec3 sunVec;
uniform vec3 upVec;
uniform vec2 texelSize;
uniform float skyIntensityNight;
uniform float skyIntensity;
uniform float sunElevation;
uniform float rainStrength;
uniform mat4 gbufferProjectionInverse;
uniform mat4 gbufferModelViewInverse;
uniform mat4 shadowModelView;
uniform mat4 shadowProjection;
//faster and actually more precise than pow 2.2
vec3 toLinear(vec3 sRGB){
return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878);
}
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz)
vec3 toScreenSpace(vec3 p) {
vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw);
vec3 p3 = p * 2. - 1.;
vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3];
return fragposition.xyz / fragposition.w;
}
float interleaved_gradientNoise(){
vec2 coord = gl_FragCoord.xy;
float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y));
return noise;
vec4 encode (vec3 n, vec2 lightmaps){
n.xy = n.xy / dot(abs(n), vec3(1.0));
n.xy = n.z <= 0.0 ? (1.0 - abs(n.yx)) * sign(n.xy) : n.xy;
vec2 encn = clamp(n.xy * 0.5 + 0.5,-1.0,1.0);
return vec4(encn,vec2(lightmaps.x,lightmaps.y));
}
float facos(float sx){
float x = clamp(abs( sx ),0.,1.);
float a = sqrt( 1. - x ) * ( -0.16882 * x + 1.56734 );
return sx > 0. ? a : 3.14159265359 - a;
//encoding by jodie
float encodeVec2(vec2 a){
const vec2 constant1 = vec2( 1., 256.) / 65535.;
vec2 temp = floor( a * 255. );
return temp.x*constant1.x+temp.y*constant1.y;
}
#define SHADOW_MAP_BIAS 0.8
float calcDistort(vec2 worlpos){
vec2 pos = worlpos * 1.165;
vec2 posSQ = pos*pos;
float distb = pow(posSQ.x*posSQ.x*posSQ.x + posSQ.y*posSQ.y*posSQ.y, 1.0 / 6.0);
return 1.08695652/((1.0 - SHADOW_MAP_BIAS) + distb * SHADOW_MAP_BIAS);
float encodeVec2(float x,float y){
return encodeVec2(vec2(x,y));
}
//////////////////////////////VOID MAIN//////////////////////////////
@ -66,25 +34,14 @@ float calcDistort(vec2 worlpos){
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
/* DRAWBUFFERS:2 */
/* DRAWBUFFERS:28 */
void main() {
vec4 Albedo = vec4(texture2D(texture, texcoord).rgb*5.0,1.0);
Albedo *= color;
Albedo.rgb = toLinear(Albedo.rgb);
gl_FragData[0] = texture2D(texture, lmtexcoord.xy)*color;
gl_FragData[0].a = 1.0;
vec3 albedo = toLinear(gl_FragData[0].rgb);
float torch_lightmap = lmtexcoord.z;
vec3 diffuseLight = torch_lightmap*vec3(20.,30.,50.)*2./10. ;
vec3 color = diffuseLight*albedo;
gl_FragData[0].rgb = color*0.01;
}
gl_FragData[0] = Albedo;
gl_FragData[1] = vec4(0.0,0.0,0.0,0.9);
}

View File

@ -1,6 +1,8 @@
#version 120
//#extension GL_EXT_gpu_shader4 : disable
#define TAA
#include "lib/settings.glsl"
#include "/lib/res_params.glsl"
/*
!! DO NOT REMOVE !!
@ -9,24 +11,19 @@ Read the terms of modification and sharing before changing something below pleas
!! DO NOT REMOVE !!
*/
varying vec4 lmtexcoord;
varying vec4 color;
varying vec4 normalMat;
#ifdef MC_NORMAL_MAP
varying vec4 tangent;
attribute vec4 at_tangent;
#endif
varying vec2 texcoord;
uniform vec2 texelSize;
uniform int framemod8;
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-1.,3.)/8.,
vec2(5.0,1.)/8.,
vec2(-3,-5.)/8.,
vec2(-5.,5.)/8.,
vec2(-7.,-1.)/8.,
vec2(3,7.)/8.,
vec2(7.,-7.)/8.);
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-1.,3.)/8.,
vec2(5.0,1.)/8.,
vec2(-3,-5.)/8.,
vec2(-5.,5.)/8.,
vec2(-7.,-1.)/8.,
vec2(3,7.)/8.,
vec2(7.,-7.)/8.);
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
@ -34,21 +31,18 @@ uniform int framemod8;
//////////////////////////////VOID MAIN//////////////////////////////
void main() {
lmtexcoord.xy = (gl_MultiTexCoord0).xy;
vec2 lmcoord = gl_MultiTexCoord1.xy/255.;
lmtexcoord.zw = lmcoord;
gl_Position = ftransform();
color = gl_Color;
#ifdef MC_NORMAL_MAP
tangent = vec4(normalize(gl_NormalMatrix *at_tangent.rgb),at_tangent.w);
#endif
normalMat = vec4(normalize(gl_NormalMatrix *gl_Normal),1.0);
#ifdef TAA
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
if(gl_Color.a < 1.0 ) gl_Position = vec4(10,10,10,1);
texcoord = (gl_MultiTexCoord0).xy;
color = gl_Color;
#ifdef TAA_UPSCALING
gl_Position.xy = gl_Position.xy * RENDER_SCALE + RENDER_SCALE * gl_Position.w - gl_Position.w;
#endif
}
#ifdef TAA
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
#endif
}

View File

@ -40,12 +40,6 @@ void main() {
vec4 Albedo = texture2D(texture, texcoord);
// if (Albedo.a > 0.1) Albedo.a = 1.0;
// else Albedo.a = 0.0;
// vec4 data1 = vec4(1);
// gl_FragData[0] = vec4(encodeVec2(Albedo.x,data1.x), encodeVec2(Albedo.y,data1.y), encodeVec2(Albedo.z,data1.z), encodeVec2(data1.w,Albedo.w));
Albedo *= color;
Albedo.rgb = toLinear(Albedo.rgb);

View File

@ -1,7 +1,7 @@
#version 120
//#extension GL_EXT_gpu_shader4 : disable
#include "/lib/settings.glsl"
#include "lib/settings.glsl"
#include "/lib/res_params.glsl"
/*
@ -34,9 +34,14 @@ void main() {
gl_Position = ftransform();
// if(gl_Color.a < 0.1 ) gl_Position = vec4(10,10,10,1);
texcoord = (gl_MultiTexCoord0).xy;
color = gl_Color;
#ifdef TAA_UPSCALING
gl_Position.xy = gl_Position.xy * RENDER_SCALE + RENDER_SCALE * gl_Position.w - gl_Position.w;
#endif
#ifdef TAA
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
#endif