Fix Emissives in end/nether. fix tiny labSSS curve issue

This commit is contained in:
Xonk
2023-07-01 15:53:13 -04:00
parent 825819c0cb
commit 08ff5ab8bb
12 changed files with 602 additions and 374 deletions

View File

@ -353,33 +353,49 @@ void main() {
float noise = blueNoise();
vec3 fragpos = toScreenSpace(vec3(texcoord-vec2(tempOffset)*texelSize*0.5,z));
vec3 fragpos_RTSHADOW = toScreenSpace(vec3(texcoord,z));
vec3 p3 = mat3(gbufferModelViewInverse) * fragpos;
vec3 np3 = normVec(p3);
vec4 trpData = texture2D(colortex7,texcoord);
bool iswater = trpData.a > 0.99;
vec4 SpecularTex = texture2D(colortex8,texcoord);
bool isEntities = texture2D(colortex10,texcoord).x > 0.0;
vec4 data = texture2D(colortex1,texcoord); // terraom
vec4 dataUnpacked0 = vec4(decodeVec2(data.x),decodeVec2(data.y));
vec4 dataUnpacked1 = vec4(decodeVec2(data.z),decodeVec2(data.w));
////// --------------- UNPACK OPAQUE GBUFFERS --------------- //////
float Translucent_Programs = texture2D(colortex2,texcoord).a; // the shader for all translucent progams.
// Normal //
vec3 normal = decode(dataUnpacked0.yw) ;
vec4 data = texture2D(colortex1,texcoord);
vec4 dataUnpacked0 = vec4(decodeVec2(data.x),decodeVec2(data.y)); // albedo, masks
vec4 dataUnpacked1 = vec4(decodeVec2(data.z),decodeVec2(data.w)); // normals, lightmaps
// vec4 dataUnpacked2 = vec4(decodeVec2(data.z),decodeVec2(data.w));
vec3 albedo = toLinear(vec3(dataUnpacked0.xz,dataUnpacked1.x));
vec2 lightmap = dataUnpacked1.yz;
vec3 normal = decode(dataUnpacked0.yw);
////// --------------- UNPACK MISC --------------- //////
vec4 SpecularTex = texture2D(colortex8,texcoord);
float LabSSS = clamp((-65.0 + SpecularTex.z * 255.0) / 190.0 ,0.0,1.0);
vec4 normalAndAO = texture2D(colortex15,texcoord);
vec3 FlatNormals = normalAndAO.rgb * 2.0 - 1.0;
float vanilla_AO = 1.0 - exp2(-5 * pow(1-normalAndAO.a,3)) ;
vec3 slopednormal = normal;
#ifdef POM
#ifdef Horrible_slope_normals
vec3 ApproximatedFlatNormal = normalize(cross(dFdx(p3), dFdy(p3))); // it uses depth that has POM written to it.
slopednormal = normalize(clamp(normal, ApproximatedFlatNormal*2.0 - 1.0, ApproximatedFlatNormal*2.0 + 1.0) );
#endif
#endif
vec3 albedo = toLinear(vec3(dataUnpacked0.xz,dataUnpacked1.x));
float vanilla_AO = normalAndAO.a;
normalAndAO.a = clamp(pow(normalAndAO.a*5,4),0,1);
vec2 lightmap = dataUnpacked1.yz;
bool translucent = abs(dataUnpacked1.w-0.5) <0.01;
bool hand = abs(dataUnpacked1.w-0.75) <0.01;
bool iswater = texture2D(colortex7,texcoord).a > 0.99;
bool lightningBolt = abs(dataUnpacked1.w-0.5) <0.01;
bool isLeaf = abs(dataUnpacked1.w-0.55) <0.01;
bool entities = abs(dataUnpacked1.w-0.45) < 0.01;
bool hand = abs(dataUnpacked1.w-0.75) < 0.01;
// bool blocklights = abs(dataUnpacked1.w-0.8) <0.01;
if (z >= 1.0) {
@ -390,6 +406,8 @@ void main() {
p3 += gbufferModelViewInverse[3].xyz;
// do all ambient lighting stuff
vec3 AO = vec3( exp( (vanilla_AO*vanilla_AO) * -5) ) ;
vec3 Indirect_lighting = DoAmbientLighting_End(gl_Fog.color.rgb, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, normal, np3) ;
// Indirect_lighting = vec3(TORCH_R,TORCH_G,TORCH_B) * curveinvert(clamp(lightmap.x,0.0,1.0),2);
@ -436,24 +454,26 @@ void main() {
gl_FragData[0].rgb = (Indirect_lighting + LightSource) * albedo;
#ifdef Specular_Reflections
MaterialReflections_E(gl_FragData[0].rgb, SpecularTex.r, SpecularTex.ggg, albedo, normal, np3, fragpos, vec3(blueNoise(gl_FragCoord.xy).rg,noise), hand, LightColor * LightFalloff, normalize(-LightPos), isEntities);
MaterialReflections_E(gl_FragData[0].rgb, SpecularTex.r, SpecularTex.ggg, albedo, normal, np3, fragpos, vec3(blueNoise(gl_FragCoord.xy).rg,noise), hand, LightColor * LightFalloff, normalize(-LightPos), entities);
#endif
if(!hand) gl_FragData[0].rgb *= ssao(fragpos,noise,FlatNormals) * vanilla_AO;
if(!hand) gl_FragData[0].rgb *= ssao(fragpos,noise,FlatNormals) * AO;
// if(lightningBolt) albedo.rgb += vec3(Lightning_R,Lightning_G,Lightning_B) ;
LabEmission(gl_FragData[0].rgb, albedo, SpecularTex.a);
#ifdef LabPBR_Emissives
LabEmission(gl_FragData[0].rgb, albedo, SpecularTex.a);
#endif
}
////// border Fog
if(Translucent_Programs > 0.0){
vec3 fragpos = toScreenSpace(vec3(texcoord-vec2(0.0)*texelSize*0.5,z));
float fogdistfade = 1.0 - clamp( exp(-pow(length(fragpos / far),2.)*5.0) ,0.0,1.0);
// ////// border Fog
// if(Translucent_Programs > 0.0){
// vec3 fragpos = toScreenSpace(vec3(texcoord-vec2(0.0)*texelSize*0.5,z));
// float fogdistfade = 1.0 - clamp( exp(-pow(length(fragpos / far),2.)*5.0) ,0.0,1.0);
gl_FragData[0].rgb = mix(gl_FragData[0].rgb, gl_Fog.color.rgb*0.5*NetherFog_brightness, fogdistfade) ;
}
// gl_FragData[0].rgb = mix(gl_FragData[0].rgb, gl_Fog.color.rgb*0.5*NetherFog_brightness, fogdistfade) ;
// }
////// Water Fog

View File

@ -1,4 +1,6 @@
#version 120
#define WORLD
#define HAND
#include "/programs/all_solid.fsh"

View File

@ -1,32 +1,55 @@
#version 120
/*
!! DO NOT REMOVE !!
This code is from Chocapic13' shaders
Read the terms of modification and sharing before changing something below please !
!! DO NOT REMOVE !!
*/
varying vec4 color;
varying vec2 texcoord;
uniform sampler2D texture;
//faster and actually more precise than pow 2.2
vec3 toLinear(vec3 sRGB){
return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878);
}
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));
}
//encoding by jodie
float encodeVec2(vec2 a){
const vec2 constant1 = vec2( 1., 256.) / 65535.;
vec2 temp = floor( a * 255. );
return temp.x*constant1.x+temp.y*constant1.y;
}
float encodeVec2(float x,float y){
return encodeVec2(vec2(x,y));
}
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
/* DRAWBUFFERS:28 */
void main() {
vec4 albedo = texture2D(texture, texcoord);
albedo *= color;
albedo.rgb = toLinear(albedo.rgb)*0.33;
/* DRAWBUFFERS:2 */
gl_FragData[0] = albedo;
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);
gl_FragData[0] = Albedo;
gl_FragData[1] = vec4(0.0,0.0,0.0,0.5);
}

View File

@ -1,5 +1,8 @@
#version 120
#define TAA
#extension GL_EXT_gpu_shader4 : enable
#include "/lib/settings.glsl"
#include "/lib/res_params.glsl"
/*
!! DO NOT REMOVE !!
@ -13,24 +16,28 @@ 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//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
//////////////////////////////VOID MAIN//////////////////////////////
void main() {
gl_Position = ftransform();
texcoord = (gl_MultiTexCoord0).xy;
color = gl_Color;
gl_Position = ftransform();
#ifdef TAA
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
#endif
}
}