make handheld lights work on particles and translucents. make lit particle brightness work again. exclude hand from bloom. extend bloom mulitplier slider.

This commit is contained in:
Xonk
2023-10-30 16:07:38 -04:00
parent 6fdc95dff4
commit 8f5111d82d
15 changed files with 135 additions and 47 deletions

View File

@ -33,6 +33,7 @@ uniform vec2 texelSize;
uniform ivec2 eyeBrightnessSmooth;
uniform float rainStrength;
flat varying float HELD_ITEM_BRIGHTNESS;
#ifndef OVERWORLD_SHADER
uniform float nightVision;
@ -99,6 +100,13 @@ void main() {
#ifndef OVERWORLD_SHADER
lightmap.y = 1.0;
#endif
#ifdef Hand_Held_lights
lightmap.x = max(lightmap.x, HELD_ITEM_BRIGHTNESS * clamp( pow(max(1.0-length(viewPos)/10,0.0),1.5),0.0,1.0));
#endif
#ifdef WEATHER
gl_FragData[1].a = TEXTURE.a; // for bloomy rain and stuff
#endif
@ -117,9 +125,8 @@ void main() {
vec3 Indirect_lighting = vec3(0.0);
vec3 Torch_Color = vec3(TORCH_R,TORCH_G,TORCH_B);
#ifdef LIT
Torch_Color *= LIT_PARTICLE_BRIGHTNESS;
#endif
if(lightmap.x >= 0.9) Torch_Color *= LIT_PARTICLE_BRIGHTNESS;
#ifdef OVERWORLD_SHADER
float Shadows = 1.0;
@ -161,7 +168,7 @@ void main() {
vec3 AmbientLightColor = vec3(1.0);
#endif
Indirect_lighting = DoAmbientLightColor(AmbientLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), clamp(lightmap.xy,0,1));
Indirect_lighting = DoAmbientLightColor(AmbientLightColor, Torch_Color, clamp(lightmap.xy,0,1));
#ifdef LINES
gl_FragData[0].rgb = (Indirect_lighting + Direct_lighting) * toLinear(color.rgb);

View File

@ -29,6 +29,10 @@ uniform mat4 gbufferModelViewInverse;
uniform mat4 gbufferModelView;
uniform ivec2 eyeBrightnessSmooth;
uniform int heldItemId;
uniform int heldItemId2;
flat varying float HELD_ITEM_BRIGHTNESS;
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-1.,3.)/8.,
vec2(5.0,1.)/8.,
@ -55,6 +59,14 @@ void main() {
vec2 lmcoord = gl_MultiTexCoord1.xy / 255.0; // is this even correct? lol'
lmtexcoord.zw = lmcoord;
HELD_ITEM_BRIGHTNESS = 0.0;
#ifdef Hand_Held_lights
if(heldItemId == 100 || heldItemId2 == 100) HELD_ITEM_BRIGHTNESS = 0.9;
#endif
#ifdef WEATHER
vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz;

View File

@ -311,7 +311,13 @@ 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)/10,0.0),1.5),0.0,1.0));
#ifdef HAND
torchlightmap = 0.7;
#endif
#endif
float lightmap = clamp( (lmtexcoord.w-0.8) * 10.0,0.,1.);
@ -435,7 +441,7 @@ void main() {
else Albedo.a = 0.0;
#endif
#if defined HAND
#ifdef HAND
if (Albedo.a > 0.1) Albedo.a = 0.75;
else Albedo.a = 0.0;
#endif

View File

@ -15,6 +15,7 @@ varying vec4 color;
flat varying vec4 lightCol;
#endif
flat varying float HELD_ITEM_BRIGHTNESS;
const bool colortex4MipmapEnabled = true;
uniform sampler2D noisetex;
@ -372,6 +373,10 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
#ifndef OVERWORLD_SHADER
lightmap.y = 1.0;
#endif
#ifdef Hand_Held_lights
lightmap.x = max(lightmap.x, HELD_ITEM_BRIGHTNESS*clamp( pow(max(1.0-length(viewPos)/10,0.0),1.5),0.0,1.0));
#endif
vec3 Indirect_lighting = vec3(0.0);
vec3 Direct_lighting = vec3(0.0);

View File

@ -49,6 +49,10 @@ uniform float viewWidth;
uniform int hideGUI;
uniform float screenBrightness;
uniform int heldItemId;
uniform int heldItemId2;
flat varying float HELD_ITEM_BRIGHTNESS;
uniform vec2 texelSize;
uniform int framemod8;
@ -85,7 +89,12 @@ void main() {
vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz;
gl_Position = toClipSpace3(position);
HELD_ITEM_BRIGHTNESS = 0.0;
#ifdef Hand_Held_lights
if(heldItemId == 100 || heldItemId2 == 100) HELD_ITEM_BRIGHTNESS = 0.9;
#endif
float mat = 0.0;
if(mc_Entity.x == 8.0) {

View File

@ -38,7 +38,13 @@ uniform sampler2D colortex4;
flat varying float exposure;
void main() {
color = gl_Color;
#ifdef ENCHANT_GLINT
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).st;
#else
texcoord = (gl_MultiTexCoord0).xy;
#endif
#if defined ENCHANT_GLINT || defined SPIDER_EYES
exposure = texelFetch2D(colortex4,ivec2(10,37),0).r;
@ -49,19 +55,12 @@ void main() {
gl_Position = ftransform();
#endif
texcoord = (gl_MultiTexCoord0).xy;
#ifdef ENCHANT_GLINT
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).st;
// float exposure = texelFetch2D(colortex4, ivec2(10,37),0).r;
#endif
color = gl_Color;
#ifdef BEACON_BEAM
if(gl_Color.a < 1.0) gl_Position = vec4(10,10,10,0);
#endif
#ifdef TAA_UPSCALING
gl_Position.xy = gl_Position.xy * RENDER_SCALE + RENDER_SCALE * gl_Position.w - gl_Position.w;
#endif

View File

@ -37,7 +37,7 @@ const bool colortex5MipmapEnabled = true;
// #define LIGHTSOURCE_REFLECTION
#endif
uniform int hideGUI;
uniform sampler2D noisetex; //noise
uniform sampler2D depthtex0; //depth
uniform sampler2D depthtex1; //depth
@ -420,18 +420,14 @@ void SSRT_Shadows(vec3 viewPos, vec3 lightDir, float noise, bool isSSS, bool ins
vec3 rayDir = direction * (isSSS ? 1.5 : 3.0) * vec3(RENDER_SCALE,1.0);
vec3 screenPos = clipPosition*vec3(RENDER_SCALE,1.0) + rayDir*noise;
vec3 screenPos = clipPosition * vec3(RENDER_SCALE,1.0) + rayDir*noise;
if(isSSS)screenPos -= rayDir*0.9;
if(isSSS) screenPos -= rayDir*0.9;
float shadowgradient = 0;
for (int i = 0; i < int(steps); i++) {
screenPos += rayDir;
float shadowGradient = i/steps;
float samplePos = texture2D(depthtex1, screenPos.xy).x;
float samplePos = texture2D(depthtex2, screenPos.xy).x;
if(samplePos <= screenPos.z) {
vec2 linearZ = vec2(linZ(screenPos.z), linZ(samplePos));
float calcthreshold = abs(linearZ.x - linearZ.y) / linearZ.x;
@ -439,10 +435,9 @@ void SSRT_Shadows(vec3 viewPos, vec3 lightDir, float noise, bool isSSS, bool ins
bool depthThreshold1 = calcthreshold < 0.015;
bool depthThreshold2 = calcthreshold < 0.05;
// if (depthThreshold1) Shadow = inshadowmap ? shadowGradient : 0.0;
if (depthThreshold1) Shadow = 0.0;
if (depthThreshold2) SSS = shadowGradient;
if (depthThreshold2) SSS = i/steps;
}
}
@ -509,8 +504,11 @@ vec3 SubsurfaceScattering_sky(vec3 albedo, float Scattering, float Density){
#include "/lib/indirect_lighting_effects.glsl"
#include "/lib/PhotonGTAO.glsl"
void main() {
vec3 DEBUG =vec3( 1.0);
////// --------------- SETUP STUFF --------------- //////
vec2 texcoord = gl_FragCoord.xy*texelSize;
@ -527,6 +525,8 @@ void main() {
vec3 feetPlayerPos = mat3(gbufferModelViewInverse) * viewPos;
vec3 feetPlayerPos_normalized = normVec(feetPlayerPos);
////// --------------- UNPACK OPAQUE GBUFFERS --------------- //////
vec4 data = texture2D(colortex1,texcoord);
@ -570,7 +570,7 @@ void main() {
bool entities = abs(dataUnpacked1.w-0.45) < 0.01;
// bool isBoss = abs(dataUnpacked1.w-0.60) < 0.01;
bool isGrass = abs(dataUnpacked1.w-0.60) < 0.01;
bool hand = abs(dataUnpacked1.w-0.75) < 0.01;
bool hand = abs(dataUnpacked1.w-0.75) < 0.01 && z0 < 1.0;
// bool blocklights = abs(dataUnpacked1.w-0.8) <0.01;
@ -674,8 +674,10 @@ void main() {
#endif
vec3 feetPlayerPos_shadow = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz;
if(!hand) GriAndEminShadowFix(feetPlayerPos_shadow, viewToWorld(FlatNormals), vanilla_AO, lightmap.y, entities);
if(!entities){
if(!hand) GriAndEminShadowFix(feetPlayerPos_shadow, viewToWorld(FlatNormals), vanilla_AO, lightmap.y, entities);
}
// mat4 Custom_ViewMatrix = BuildShadowViewMatrix(LightDir);
// vec3 projectedShadowPosition = mat3(Custom_ViewMatrix) * feetPlayerPos_shadow + Custom_ViewMatrix[3].xyz;
@ -697,13 +699,15 @@ void main() {
if (shadowNDOTL >= -0.001){
Shadows = 0.0;
int samples = SHADOW_FILTER_SAMPLE_COUNT;
float smallbias = 0;
float smallbias = 0.0;
if(hand){
samples = 1;
smallbias = -0.0005;
noise = 0.5;
smallbias = -0.0004;
}
if(entities) smallbias = -0.0001;
projectedShadowPosition = projectedShadowPosition * vec3(0.5,0.5,0.5/6.0) + vec3(0.5);
@ -768,7 +772,10 @@ void main() {
Shadows = min(Shadows, SS_shadow);
if (!inShadowmapBounds) ShadowBlockerDepth = max(ShadowBlockerDepth, SS_shadowSSS);
if (!inShadowmapBounds) ShadowBlockerDepth = max(ShadowBlockerDepth, clamp(SS_shadowSSS,0.0,1.0));
// DEBUG = 1.0-SS_shadowSSS;
#else
if (!inShadowmapBounds) Direct_SSS = vec3(0.0);
@ -782,7 +789,7 @@ void main() {
if (!inShadowmapBounds){
Direct_SSS *= lightmapAsShadows;
Direct_SSS *= 1.0-NdotL;
// Direct_SSS *= 1.0-NdotL;
}
#endif
@ -1020,8 +1027,7 @@ void main() {
waterVolumetrics_notoverworld(gl_FragData[0].rgb, viewPos0, viewPos, estimatedDepth , estimatedDepth, Vdiff, noise_2, totEpsilon, scatterCoef, ambientColVol);
}
#endif
// gl_FragData[0].rgb = vec3(hand);
/* DRAWBUFFERS:3 */
}

View File

@ -264,7 +264,7 @@ vec4 TAA_hq(){
vec4 albedoPrev = texture2D(colortex5, previousPosition.xy);
vec3 supersampled = albedoPrev.rgb * albedoPrev.a + albedoCurrent0;
if (length(velocity) > 1e-6 || hideGUI < 1) return vec4(albedoCurrent0,1.0);
if ( hideGUI < 1) return vec4(albedoCurrent0,1.0);
return vec4(supersampled/(albedoPrev.a+1.0), albedoPrev.a+1.0);
#endif
}

View File

@ -1,7 +1,24 @@
uniform sampler2D depthtex1;
uniform sampler2D colortex1;
uniform sampler2D colortex5;
uniform vec2 texelSize;
uniform float viewWidth;
uniform float viewHeight;
vec3 decode (vec2 encn){
vec3 n = vec3(0.0);
encn = encn * 2.0 - 1.0;
n.xy = abs(encn);
n.z = 1.0 - n.x - n.y;
n.xy = n.z <= 0.0 ? (1.0 - n.yx) * sign(encn) : encn;
return clamp(normalize(n.xyz),-1.0,1.0);
}
vec2 decodeVec2(float a){
const vec2 constant1 = 65535. / vec2( 256., 65536.);
const float constant2 = 256. / 255.;
return fract( a * constant1 ) * constant2 ;
}
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
@ -15,6 +32,11 @@ void main() {
vec2 resScale = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.))/vec2(1920.,1080.);
vec2 quarterResTC = gl_FragCoord.xy*2.*resScale*texelSize;
vec4 data = texture2D(colortex1,quarterResTC);
vec4 dataUnpacked1 = vec4(decodeVec2(data.z),decodeVec2(data.w));
float depth = texture2D(depthtex1,quarterResTC).x;
bool hand = abs(dataUnpacked1.w-0.75) < 0.01 && depth < 1.0;
//0.5
gl_FragData[0] = texture2D(colortex5,quarterResTC-1.0*vec2(texelSize.x,texelSize.y))/4.*0.5;
gl_FragData[0] += texture2D(colortex5,quarterResTC+1.0*vec2(texelSize.x,texelSize.y))/4.*0.5;
@ -37,7 +59,7 @@ vec2 quarterResTC = gl_FragCoord.xy*2.*resScale*texelSize;
gl_FragData[0] += texture2D(colortex5,quarterResTC)*0.125;
gl_FragData[0].rgb = clamp(gl_FragData[0].rgb,0.0,65000.);
if (quarterResTC.x > 1.0 - 3.5*texelSize.x || quarterResTC.y > 1.0 -3.5*texelSize.y || quarterResTC.x < 3.5*texelSize.x || quarterResTC.y < 3.5*texelSize.y) gl_FragData[0].rgb = vec3(0.0);
if (hand || quarterResTC.x > 1.0 - 3.5*texelSize.x || quarterResTC.y > 1.0 -3.5*texelSize.y || quarterResTC.x < 3.5*texelSize.x || quarterResTC.y < 3.5*texelSize.y) gl_FragData[0].rgb = vec3(0.0);
}

View File

@ -2,6 +2,7 @@
uniform sampler2D colortex4;
uniform sampler2D depthtex1;
uniform sampler2D depthtex2;
uniform float near;
uniform float far;

View File

@ -169,6 +169,13 @@ void main() {
// uniform sampler2D shadowcolor0;
// uniform sampler2D shadowtex0;
// uniform sampler2D shadowtex1;
// vec2 coord = gl_FragCoord.xy;
// int invertChecker = int(mod(coord.x,2)) * int(mod(coord.y,2));
// int checker = int(mod(coord.x*coord.y,2));
// int checker2 = int(mod(coord.x*coord.y+1,2));
// gl_FragColor.rgb = vec3(0.2) * checker * checker2;
// if( hideGUI == 1){