Better Organized Generated Normal stuff

This commit is contained in:
Rbanh 2024-06-22 17:05:41 -04:00
parent 0f859671ea
commit 16d5613af1
25 changed files with 1204 additions and 497 deletions

View File

@ -14,6 +14,7 @@ screen.SHADOW_CONFIG=More Shadow Config
screen.MCBL=Colored Blocklight Config screen.MCBL=Colored Blocklight Config
screen.MATERIAL=Material screen.MATERIAL=Material
screen.INTEGRATED=Integrated PBR Settings
screen.SPECULAR=Specular & Reflections screen.SPECULAR=Specular & Reflections
screen.NORMALS=Normals & Parallax screen.NORMALS=Normals & Parallax
@ -174,7 +175,7 @@ option.MATERIAL_FORMAT=Material Format*
option.MATERIAL_FORMAT.comment=Determines the specular and normal map format used by the resource pack. §e[*]§rTexture artists usually tell which format is used in their resource pack, using the wrong format may give weird results. option.MATERIAL_FORMAT.comment=Determines the specular and normal map format used by the resource pack. §e[*]§rTexture artists usually tell which format is used in their resource pack, using the wrong format may give weird results.
value.MATERIAL_FORMAT.0=SEUS/Old PBR value.MATERIAL_FORMAT.0=SEUS/Old PBR
value.MATERIAL_FORMAT.1=labPBR 1.3 value.MATERIAL_FORMAT.1=labPBR 1.3
value.MATERIAL_FORMAT.2=Generated value.MATERIAL_FORMAT.2=§bIntegrated PBR
option.SSS=Subsurface Scattering* option.SSS=Subsurface Scattering*
option.SSS.comment=Allows light to penetrate and scatter through blocks. §a[+]§rThis effect benefits from TAA. option.SSS.comment=Allows light to penetrate and scatter through blocks. §a[+]§rThis effect benefits from TAA.
@ -306,8 +307,9 @@ value.DIRECTIONAL_LIGHTMAP_STRENGTH.0.5=Very High
option.NORMAL_DAMPENING=Normal Dampening* option.NORMAL_DAMPENING=Normal Dampening*
option.NORMAL_DAMPENING.comment=Reduces normal map strength to prevent reflections being too noisy. option.NORMAL_DAMPENING.comment=Reduces normal map strength to prevent reflections being too noisy.
option.GENERATED_NORMALS=Generated Normals
option.GENERATED_NORMALS.comment=Enables procedural-generated normal mapping for blocks. option.GENERATED_NORMALS=Generated Normals*
option.GENERATED_NORMALS.comment=Enables procedural-generated normal mapping for blocks. (Requres Integrated PBR format)
option.GENERATED_NORMAL_MULT=Generated Normal Intensity option.GENERATED_NORMAL_MULT=Generated Normal Intensity
option.GENERATED_NORMAL_MULT.comment=Adjusts the intensity of generated normal mapping. option.GENERATED_NORMAL_MULT.comment=Adjusts the intensity of generated normal mapping.
option.GENERATED_NORMAL_THRESHOLD=Generated Normal Threshold option.GENERATED_NORMAL_THRESHOLD=Generated Normal Threshold
@ -317,6 +319,9 @@ option.GENERATED_NORMAL_CLAMP.comment=Clamps the generated normal mapping to pre
option.GENERATED_NORMAL_RESOLUTION=Generated Normal Resolution option.GENERATED_NORMAL_RESOLUTION=Generated Normal Resolution
option.GENERATED_NORMAL_RESOLUTION.comment=Adjusts the resolution of generated normal maps. option.GENERATED_NORMAL_RESOLUTION.comment=Adjusts the resolution of generated normal maps.
option.INTEGRATED_SPECULAR=Integrated Speculars*
option.INTEGRATED_SPECULAR.comment=Use hardcoded internal speculars for certain blocks. §e[*]§rRequires Integrated PBR format.
option.NORMAL_PLANTS=Up-facing Plants option.NORMAL_PLANTS=Up-facing Plants
option.NORMAL_PLANTS.comment=Adjusts plant shading. §e[*]§rDisable this if non-flat plant model is used or normal map applied on plants. option.NORMAL_PLANTS.comment=Adjusts plant shading. §e[*]§rDisable this if non-flat plant model is used or normal map applied on plants.

View File

@ -7,7 +7,7 @@ vec3 GetSkyColor(vec3 viewPos, bool isReflection) {
float groundDensity = 0.1 * (4.0 - 3.0 * sunVisibility) * float groundDensity = 0.1 * (4.0 - 3.0 * sunVisibility) *
(10.0 * rainStrength * rainStrength + 1.0); (10.0 * rainStrength * rainStrength + 1.0);
float exposure = exp2(timeBrightness * 0.75 - 0.75 + SKY_EXPOSURE_D); float exposure = exp2(timeBrightness * 0.75 - 0.75 + SKY_EXPOSURE_D);
float nightExposure = exp2(-3.5 + SKY_EXPOSURE_N); float nightExposure = exp2(-3.5 + SKY_EXPOSURE_N);
float weatherExposure = exp2(SKY_EXPOSURE_W); float weatherExposure = exp2(SKY_EXPOSURE_W);
@ -42,8 +42,8 @@ vec3 GetSkyColor(vec3 viewPos, bool isReflection) {
lightSky = lightSky / (1.0 + lightSky * rainStrength); lightSky = lightSky / (1.0 + lightSky * rainStrength);
sky = mix( sky = mix(
sqrt(sky * (1.0 - lightMix)), sqrt(sky * (1.0 - lightMix)),
sqrt(lightSky), sqrt(lightSky),
lightMix lightMix
); );
sky *= sky; sky *= sky;

109
shaders/lib/common.glsl Normal file
View File

@ -0,0 +1,109 @@
// Only allow generated normals for material format 2 aka Integrated
#if MATERIAL_FORMAT != 2
#ifdef GENERATED_NORMALS
#undef GENERATED_NORMALS
#endif
#endif
//Common Functions//
float GetLuminance(vec3 color) {
return dot(color,vec3(0.299, 0.587, 0.114));
}
float pow2(float x) {
return x * x;
}
vec2 pow2(vec2 x) {
return x * x;
}
vec3 pow2(vec3 x) {
return x * x;
}
float pow1_5(float x) { // Faster pow(x, 1.5) approximation (that isn't accurate at all) if x is between 0 and 1
return x - x * pow2(1.0 - x); // Thanks to SixthSurge
}
vec2 pow1_5(vec2 x) {
return x - x * pow2(1.0 - x);
}
vec3 pow1_5(vec3 x) {
return x - x * pow2(1.0 - x);
}
bool CheckForColor(vec3 albedo, vec3 check) { // Thanks to Builderb0y
vec3 dif = albedo - check * 0.003921568;
return dif == clamp(dif, vec3(-0.001), vec3(0.001));
}
float GetMaxColorDif(vec3 color) {
vec3 dif = abs(vec3(color.r - color.g, color.g - color.b, color.r - color.b));
return max(dif.r, max(dif.g, dif.b));
}
float smoothstep1(float x) {
return x * x * (3.0 - 2.0 * x);
}
vec2 smoothstep1(vec2 x) {
return x * x * (3.0 - 2.0 * x);
}
vec3 smoothstep1(vec3 x) {
return x * x * (3.0 - 2.0 * x);
}
float sqrt1(float x) { // Faster sqrt() approximation (that isn't accurate at all) if x is between 0 and 1
return x * (2.0 - x); // Thanks to Builderb0y
}
vec2 sqrt1(vec2 x) {
return x * (2.0 - x);
}
vec3 sqrt1(vec3 x) {
return x * (2.0 - x);
}
vec4 sqrt1(vec4 x) {
return x * (2.0 - x);
}
float sqrt3(float x) {
x = 1.0 - x;
x *= x;
x *= x;
x *= x;
return 1.0 - x;
}
vec2 sqrt3(vec2 x) {
x = 1.0 - x;
x *= x;
x *= x;
x *= x;
return 1.0 - x;
}
vec3 sqrt3(vec3 x) {
x = 1.0 - x;
x *= x;
x *= x;
x *= x;
return 1.0 - x;
}
vec4 sqrt3(vec4 x) {
x = 1.0 - x;
x *= x;
x *= x;
x *= x;
return 1.0 - x;
}
float min1(float x) {
return min(x, 1.0);
}
float max0(float x) {
return max(x, 0.0);
}
float clamp01(float x) {
return clamp(x, 0.0, 1.0);
}
vec2 clamp01(vec2 x) {
return clamp(x, vec2(0.0), vec2(1.0));
}
vec3 clamp01(vec3 x) {
return clamp(x, vec3(0.0), vec3(1.0));
}

View File

@ -2,6 +2,7 @@
#include "/lib/lighting/shadows.glsl" #include "/lib/lighting/shadows.glsl"
#endif #endif
void GetLighting(inout vec3 albedo, out vec3 shadow, vec3 viewPos, vec3 worldPos, vec3 normal, void GetLighting(inout vec3 albedo, out vec3 shadow, vec3 viewPos, vec3 worldPos, vec3 normal,
vec2 lightmap, float smoothLighting, float NoL, float vanillaDiffuse, vec2 lightmap, float smoothLighting, float NoL, float vanillaDiffuse,
float parallaxShadow, float emission, float subsurface, float basicSubsurface) { float parallaxShadow, float emission, float subsurface, float basicSubsurface) {

View File

@ -81,13 +81,16 @@ Please don't edit anything from Undefine section and onwards.
#define SELF_SHADOW_STRENGTH 16 //[4 8 16 32 64] #define SELF_SHADOW_STRENGTH 16 //[4 8 16 32 64]
//#define DIRECTIONAL_LIGHTMAP //#define DIRECTIONAL_LIGHTMAP
#define DIRECTIONAL_LIGHTMAP_STRENGTH 1.0 //[2.0 1.4 1.0 0.7 0.5] #define DIRECTIONAL_LIGHTMAP_STRENGTH 1.0 //[2.0 1.4 1.0 0.7 0.5]
#define NORMAL_DAMPENING
#define NORMAL_PLANTS
#define GENERATED_NORMALS #define GENERATED_NORMALS
#define GENERATED_NORMAL_MULT 100 //[25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 110 120 130 140 150 160 170 180 190 200 250 300 400] #define GENERATED_NORMAL_MULT 100 //[25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 110 120 130 140 150 160 170 180 190 200 250 300 400]
#define GENERATED_NORMAL_THRESHOLD 0.05 //[0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.20] #define GENERATED_NORMAL_THRESHOLD 0.05 //[0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.20]
#define GENERATED_NORMAL_CLAMP 0.20 //[0.02 0.04 0.06 0.08 0.10 0.12 0.14 0.16 0.18 0.20 0.22 0.24 0.26 0.28 0.30 0.32 0.34 0.36 0.38 0.40] #define GENERATED_NORMAL_CLAMP 0.20 //[0.02 0.04 0.06 0.08 0.10 0.12 0.14 0.16 0.18 0.20 0.22 0.24 0.26 0.28 0.30 0.32 0.34 0.36 0.38 0.40]
#define GENERATED_NORMAL_RESOLUTION 128 //[16 32 64 128 256 512] #define GENERATED_NORMAL_RESOLUTION 128 //[16 32 64 128 256 512]
#define NORMAL_DAMPENING #define INTEGRATED_SPECULAR
#define NORMAL_PLANTS
#define SSS #define SSS
#define BASIC_SSS #define BASIC_SSS

View File

@ -15,4 +15,6 @@ void GetMaterials(out float smoothness, out float skyOcclusion, out vec3 normal,
normal = DecodeNormal(texture2D(colortex6, coord).xy); normal = DecodeNormal(texture2D(colortex6, coord).xy);
fresnel3 = texture2D(colortex7, coord).rgb * smoothness; fresnel3 = texture2D(colortex7, coord).rgb * smoothness;
} }

View File

@ -1,3 +1,27 @@
struct Material {
vec3 albedo;
vec3 emission;
vec3 f0;
vec3 f82; // hardcoded metals only
float roughness;
float sss_amount;
float sheen_amount; // SSS "sheen" for tall grass
float porosity;
float ssr_multiplier;
float normal_multiplier; // normal map multiplier for generated normals
bool is_metal;
bool is_hardcoded_metal;
};
#ifdef GENERATED_NORMALS
#include "/lib/surface/generatedNormals.glsl"
#endif
void GetMaterials(out float smoothness, out float metalness, out float f0, inout float emission, void GetMaterials(out float smoothness, out float metalness, out float f0, inout float emission,
inout float subsurface, out float porosity, out float ao, out vec3 normalMap, inout float subsurface, out float porosity, out float ao, out vec3 normalMap,
vec2 newCoord, vec2 dcdx, vec2 dcdy) vec2 newCoord, vec2 dcdx, vec2 dcdy)
@ -127,4 +151,5 @@ void GetMaterials(out float smoothness, out float metalness, out float f0, inout
normalMap = normalize(mix(vec3(0.0, 0.0, 1.0), normalMap, 1.0 / exp2(miplevel))); normalMap = normalize(mix(vec3(0.0, 0.0, 1.0), normalMap, 1.0 / exp2(miplevel)));
#endif #endif
} }

View File

@ -1,105 +0,0 @@
// if (blockEntityId < 60028) {
// if (blockEntityId < 60012) {
// if (blockEntityId < 60004) {
// if (blockEntityId == 10548) { // Enchanting Table:Book
// smoothnessG = pow2(color.g) * 0.35;
// if (color.b < 0.0001 && color.r > color.g) {
// emission = color.g * 4.0;
// }
// } else if (blockEntityId == 60000) { //
// }
// } else {
// if (blockEntityId == 60004) { // Signs
// noSmoothLighting = true;
// if (glColor.r + glColor.g + glColor.b <= 2.99 || lmCoord.x > 0.999) { // Sign Text
// #include "/lib/materials/specificMaterials/others/signText.glsl"
// }
// #ifdef COATED_TEXTURES
// noiseFactor = 0.66;
// #endif
// } else /*if (blockEntityId == 60008)*/ { // Chest
// noSmoothLighting = true;
// smoothnessG = pow2(color.g);
// #ifdef COATED_TEXTURES
// noiseFactor = 0.66;
// #endif
// }
// }
// } else {
// if (blockEntityId < 60020) {
// if (blockEntityId == 60012) { // Ender Chest
// noSmoothLighting = true;
// float factor = min(pow2(color.g), 0.25);
// smoothnessG = factor * 2.0;
// if (color.g > color.r || color.b > color.g)
// emission = pow2(factor) * 20.0;
// emission += 0.35;
// #ifdef COATED_TEXTURES
// noiseFactor = 0.66;
// #endif
// } else /*if (blockEntityId == 60016)*/ { // Shulker Box+, Banner+, Head+, Bed+
// noSmoothLighting = true;
// #ifdef COATED_TEXTURES
// noiseFactor = 0.2;
// #endif
// }
// } else {
// if (blockEntityId == 60020) { // Conduit
// noSmoothLighting = true;
// lmCoordM.x = 0.9;
// if (color.b > color.r) { // Conduit:Wind, Conduit:Blue Pixels of The Eye
// emission = color.r * 16.0;
// } else if (color.r > color.b * 2.5) { // Conduit:Red Pixels of The Eye
// emission = 20.0;
// color.rgb *= vec3(1.0, 0.25, 0.1);
// }
// } else /*if (blockEntityId == 60024)*/ { // End Portal, End Gateway
// #include "/lib/materials/specificMaterials/others/endPortalEffect.glsl"
// }
// }
// }
// } else {
// if (blockEntityId < 60044) {
// if (blockEntityId < 60036) {
// if (blockEntityId == 60028) { //
// } else /*if (blockEntityId == 60032)*/ { // Bell
// if (color.r + color.g > color.b + 0.5) { // Bell:Golden Part
// #include "/lib/materials/specificMaterials/terrain/goldBlock.glsl"
// } else {
// #include "/lib/materials/specificMaterials/terrain/stone.glsl"
// }
// }
// } else {
// if (blockEntityId == 60036) { //
// } else /*if (blockEntityId == 60040)*/ { //
// }
// }
// } else {
// if (blockEntityId < 60052) {
// if (blockEntityId == 60044) { //
// } else /*if (blockEntityId == 60048)*/ { //
// }
// } else {
// if (blockEntityId == 60052) { //
// } else if (blockEntityId == 60056) { //
// }
// }
// }
// }

View File

@ -0,0 +1,697 @@
#if !defined INCLUDE_MISC_MATERIAL
#define INCLUDE_MISC_MATERIAL
const float air_n = 1.000293; // for 0°C and 1 atm
const float water_n = 1.333; // for 20°C
struct Material {
vec3 albedo;
vec3 emission;
vec3 f0;
vec3 f82; // hardcoded metals only
float roughness;
float sss_amount;
float sheen_amount; // SSS "sheen" for tall grass
float porosity;
float ssr_multiplier;
float normal_multiplier; // normal map multiplier for generated normals
bool is_metal;
bool is_hardcoded_metal;
};
const Material water_material = Material(vec3(0.0), vec3(0.0), vec3(0.02), vec3(0.0), 0.002, 1.0, 0.0, 0.0, 1.0, 1.0, false, false);
#if TEXTURE_FORMAT == TEXTURE_FORMAT_LAB
void decode_specular_map(vec4 specular_map, inout Material material) {
// f0 and f82 values for hardcoded metals from Jessie LC (https://github.com/Jessie-LC)
const vec3[] metal_f0 = vec3[](
vec3(0.78, 0.77, 0.74), // Iron
vec3(1.00, 0.90, 0.61), // Gold
vec3(1.00, 0.98, 1.00), // Aluminum
vec3(0.77, 0.80, 0.79), // Chrome
vec3(1.00, 0.89, 0.73), // Copper
vec3(0.79, 0.87, 0.85), // Lead
vec3(0.92, 0.90, 0.83), // Platinum
vec3(1.00, 1.00, 0.91) // Silver
);
const vec3[] metal_f82 = vec3[](
vec3(0.74, 0.76, 0.76),
vec3(1.00, 0.93, 0.73),
vec3(0.96, 0.97, 0.98),
vec3(0.74, 0.79, 0.78),
vec3(1.00, 0.90, 0.80),
vec3(0.83, 0.80, 0.83),
vec3(0.89, 0.87, 0.81),
vec3(1.00, 1.00, 0.95)
);
material.roughness = sqr(1.0 - specular_map.r);
material.emission = max(material.emission, material.albedo * specular_map.a * float(specular_map.a != 1.0));
if (specular_map.g < 229.5 / 255.0) {
#ifdef F0_FALLBACK
if (specular_map.g < 0.5 / 255.0) specular_map.g = 0.04;
#endif
// Dielectrics
material.f0 = max(material.f0, specular_map.g);
float has_sss = step(64.5 / 255.0, specular_map.b);
material.sss_amount = max(material.sss_amount, linear_step(64.0 / 255.0, 1.0, specular_map.b * has_sss));
material.porosity = linear_step(0.0, 64.0 / 255.0, max0(specular_map.b - specular_map.b * has_sss));
} else if (specular_map.g < 237.5 / 255.0) {
// Hardcoded metals
uint metal_id = clamp(uint(255.0 * specular_map.g) - 230u, 0u, 7u);
material.f0 = metal_f0[metal_id];
material.f82 = metal_f82[metal_id];
material.is_metal = true;
material.is_hardcoded_metal = true;
} else {
// Albedo metal
material.f0 = material.albedo;
material.is_metal = true;
}
material.ssr_multiplier = step(0.01, (material.f0.x - material.f0.x * material.roughness * SSR_ROUGHNESS_THRESHOLD)); // based on Kneemund's method
}
#elif TEXTURE_FORMAT == TEXTURE_FORMAT_OLD
void decode_specular_map(vec4 specular_map, inout Material material) {
material.roughness = sqr(1.0 - specular_map.r);
material.is_metal = specular_map.g > 0.5;
material.f0 = material.is_metal ? material.albedo : material.f0;
material.emission = max(material.emission, material.albedo * specular_map.b);
material.ssr_multiplier = step(0.01, (material.f0.x - material.f0.x * material.roughness * SSR_ROUGHNESS_THRESHOLD)); // based on Kneemund's method
}
#endif
void decode_specular_map(vec4 specular_map, inout Material material, out bool parallax_shadow) {
#if defined POM && defined POM_SHADOW
// Specular map alpha >= 0.5 => parallax shadow
parallax_shadow = specular_map.a >= 0.5;
specular_map.a = fract(specular_map.a * 2.0);
#endif
decode_specular_map(specular_map, material);
}
Material material_from(vec3 albedo_srgb, uint material_mask, vec3 world_pos, vec3 normal, inout vec2 light_levels) {
vec3 block_pos = fract(world_pos);
// Create material with default values
Material material;
material.albedo = srgb_eotf_inv(albedo_srgb) * rec709_to_rec2020;
material.emission = vec3(0.0);
material.f0 = vec3(0.0);
material.f82 = vec3(0.0);
material.roughness = 1.0;
material.sss_amount = 0.0;
material.sheen_amount = 0.0;
material.porosity = 0.0;
material.ssr_multiplier = 0.0;
material.normal_multiplier = 1.0;
material.is_metal = false;
material.is_hardcoded_metal = false;
// Hardcoded materials for specific blocks
// Using binary split search to minimise branches per fragment (TODO: measure impact)
vec3 hsl = rgb_to_hsl(albedo_srgb);
vec3 albedo_sqrt = sqrt(material.albedo);
if (material_mask < 32u) { // 0-32
if (material_mask < 16u) { // 0-16
if (material_mask < 8u) { // 0-8
if (material_mask < 4u) { // 0-4
if (material_mask >= 2u) { // 2-4
if (material_mask == 2u) { // 2
#ifdef HARDCODED_SSS
// Small plants
material.sss_amount = 0.5;
material.sheen_amount = 0.5;
#endif
} else { // 3
#ifdef HARDCODED_SSS
// Tall plants (lower half)
material.sss_amount = 0.5;
material.sheen_amount = 0.5;
#endif
}
}
} else { // 4-8
if (material_mask < 6u) { // 4-6
if (material_mask == 4u) { // 4
#ifdef HARDCODED_SSS
// Tall plants (upper half)
material.sss_amount = 0.5;
material.sheen_amount = 0.5;
#endif
} else { // 5
// Leaves
#ifdef HARDCODED_SPECULAR
float smoothness = 0.5 * smoothstep(0.16, 0.5, hsl.z);
material.roughness = sqr(1.0 - smoothness);
material.f0 = vec3(0.02);
material.sheen_amount = 0.5;
#endif
#ifdef HARDCODED_SSS
material.sss_amount = 1.0;
#endif
}
} else { // 6-8
if (material_mask == 6u) { // 6
#ifdef HARDCODED_SPECULAR
// Grass, stone, spruce and dark oak planks
float smoothness = 0.33 * smoothstep(0.2, 0.6, hsl.z);
material.roughness = sqr(1.0 - smoothness);
material.f0 = vec3(0.02);
#endif
#ifdef HARDCODED_POROSITY
material.porosity = 0.2;
#endif
} else { // 7
// Sand
#ifdef HARDCODED_SPECULAR
float smoothness = 0.8 * linear_step(0.81, 0.96, hsl.z);
material.roughness = sqr(1.0 - smoothness);
material.f0 = vec3(0.02);
#endif
#ifdef HARDCODED_POROSITY
material.porosity = 1.35;
#endif
}
}
}
} else { // 8-16
if (material_mask < 12u) { // 8-12
if (material_mask < 10u) { // 8-10
if (material_mask == 8u) { // 8
// Ice
#ifdef HARDCODED_SPECULAR
float smoothness = pow4(linear_step(0.4, 0.8, hsl.z)) * 0.6;
material.roughness = sqr(1.0 - smoothness);
material.f0 = vec3(0.02);
material.ssr_multiplier = 1.0;
#endif
#ifdef HARDCODED_SSS
// Strong SSS
material.sss_amount = 0.75;
#endif
#ifdef HARDCODED_POROSITY
material.porosity = 0.2;
#endif
} else { // 9
// Red sand, birch planks
#ifdef HARDCODED_SPECULAR
float smoothness = 0.4 * linear_step(0.61, 0.85, hsl.z);
material.roughness = sqr(1.0 - smoothness);
material.f0 = vec3(0.02);
#endif
#ifdef HARDCODED_POROSITY
material.porosity = 0.5;
#endif
}
} else { // 10-12
if (material_mask == 10u) { // 10
// Oak, jungle and acacia planks, granite and diorite
#ifdef HARDCODED_SPECULAR
float smoothness = 0.5 * linear_step(0.4, 0.8, hsl.z);
material.roughness = sqr(1.0 - smoothness);
material.f0 = vec3(0.02);
#endif
#ifdef HARDCODED_POROSITY
material.porosity = 0.2;
#endif
} else { // 11
// Obsidian, nether bricks
#ifdef HARDCODED_SPECULAR
float smoothness = linear_step(0.02, 0.4, hsl.z);
material.roughness = sqr(1.0 - smoothness);
material.f0 = vec3(0.02);
material.ssr_multiplier = 1.0;
#endif
}
}
} else { // 12-16
if (material_mask < 14u) { // 12-14
if (material_mask == 12u) { // 12
// Metals
#ifdef HARDCODED_SPECULAR
float smoothness = sqrt(linear_step(0.1, 0.9, hsl.z));
material.roughness = max(sqr(1.0 - smoothness), 0.04);
material.f0 = material.albedo;
material.is_metal = true;
material.ssr_multiplier = 1.0;
#endif
} else { // 13
// Gems
#ifdef HARDCODED_SPECULAR
float smoothness = sqrt(linear_step(0.1, 0.9, hsl.z));
material.roughness = max(sqr(1.0 - smoothness), 0.04);
material.f0 = vec3(0.25);
material.ssr_multiplier = 1.0;
#endif
}
} else { // 14-16
if (material_mask == 14u) { // 14
#ifdef HARDCODED_SSS
// Strong SSS
material.sss_amount = 0.6;
#endif
#ifdef HARDCODED_POROSITY
material.porosity = 0.5;
#endif
} else { // 15
#ifdef HARDCODED_SSS
// Weak SSS
material.sss_amount = 0.1;
#endif
#ifdef HARDCODED_POROSITY
material.porosity = 0.25;
#endif
}
}
}
}
} else { // 16-32
if (material_mask < 24u) { // 16-24
if (material_mask < 20u) { // 16-20
if (material_mask < 18u) { // 16-18
if (material_mask == 16u) { // 16
#ifdef HARDCODED_EMISSION
// Chorus plant
material.emission = 0.25 * albedo_sqrt * pow4(hsl.z);
#endif
} else { // 17
#ifdef HARDCODED_SPECULAR
// End stone
float smoothness = 0.4 * linear_step(0.61, 0.85, hsl.z);
material.roughness = sqr(1.0 - smoothness);
material.f0 = vec3(0.02);
material.ssr_multiplier = 1.0;
#endif
}
} else { // 18-20
if (material_mask == 18u) { // 18
// Metals
#ifdef HARDCODED_SPECULAR
float smoothness = sqrt(linear_step(0.1, 0.9, hsl.z));
material.roughness = max(sqr(1.0 - smoothness), 0.04);
material.f0 = material.albedo;
material.is_metal = true;
material.ssr_multiplier = 1.0;
#endif
} else { // 19
// Warped stem
#ifdef HARDCODED_EMISSION
float emission_amount = mix(
1.0,
float(any(lessThan(
vec4(block_pos.yz, 1.0 - block_pos.yz),
vec4(rcp(16.0) - 1e-3)
))),
step(0.5, abs(normal.x))
);
float blue = isolate_hue(hsl, 200.0, 60.0);
material.emission = albedo_sqrt * hsl.y * blue * emission_amount;
#endif
}
}
} else { // 20-24
if (material_mask < 22u) { // 20-22
if (material_mask == 20u) { // 20
// Warped stem
#ifdef HARDCODED_EMISSION
float emission_amount = mix(
1.0,
float(any(lessThan(
vec4(block_pos.xz, 1.0 - block_pos.xz),
vec4(rcp(16.0) - 1e-3)
))),
step(0.5, abs(normal.y))
);
float blue = isolate_hue(hsl, 200.0, 60.0);
material.emission = albedo_sqrt * hsl.y * blue * emission_amount;
#endif
} else { // 21
// Warped stem
#ifdef HARDCODED_EMISSION
float emission_amount = mix(
1.0,
float(any(lessThan(
vec4(block_pos.xy, 1.0 - block_pos.xy),
vec4(rcp(16.0) - 1e-3)
))),
step(0.5, abs(normal.z))
);
float blue = isolate_hue(hsl, 200.0, 60.0);
material.emission = albedo_sqrt * hsl.y * blue * emission_amount;
#endif
}
} else { // 22-24
if (material_mask == 22u) { // 22
// Warped hyphae
#ifdef HARDCODED_EMISSION
float blue = isolate_hue(hsl, 200.0, 60.0);
material.emission = albedo_sqrt * hsl.y * blue;
#endif
} else { // 23
// Crimson stem
#ifdef HARDCODED_EMISSION
float emission_amount = mix(
1.0,
float(any(lessThan(
vec4(block_pos.yz, 1.0 - block_pos.yz),
vec4(rcp(16.0) - 1e-3)
))),
step(0.5, abs(normal.x))
);
material.emission = albedo_sqrt * linear_step(0.33, 0.5, hsl.z) * emission_amount;
#endif
}
}
}
} else { // 24-32
if (material_mask < 28u) { // 24-28
if (material_mask < 26u) { // 24-26
if (material_mask == 24u) { // 24
// Crimson stem
#ifdef HARDCODED_EMISSION
float emission_amount = mix(
1.0,
float(any(lessThan(
vec4(block_pos.xz, 1.0 - block_pos.xz),
vec4(rcp(16.0) - 1e-3)
))),
step(0.5, abs(normal.y))
);
material.emission = albedo_sqrt * linear_step(0.33, 0.5, hsl.z) * emission_amount;
#endif
} else { // 25
// Crimson stem
#ifdef HARDCODED_EMISSION
float emission_amount = mix(
1.0,
float(any(lessThan(
vec4(block_pos.xy, 1.0 - block_pos.xy),
vec4(rcp(16.0) - 1e-3)
))),
step(0.5, abs(normal.z))
);
material.emission = albedo_sqrt * linear_step(0.33, 0.5, hsl.z) * emission_amount;
#endif
}
} else { // 26-28
if (material_mask == 26u) { // 26
// Crimson hyphae
#ifdef HARDCODED_EMISSION
material.emission = albedo_sqrt * linear_step(0.33, 0.5, hsl.z);
#endif
} else { // 27
}
}
} else { // 28-32
if (material_mask < 30) { // 28-30
if (material_mask == 28u) { // 28
} else { // 29
}
} else { // 30-32
if (material_mask == 30u) { // 30
} else { // 31
}
}
}
}
}
} else if (material_mask < 64u) { // 32-64
if (material_mask < 48u) { // 32-48
if (material_mask < 40u) { // 32-40
if (material_mask < 36u) { // 32-36
if (material_mask < 34u) { // 32-34
if (material_mask == 32u) { // 32
#ifdef HARDCODED_EMISSION
// Strong white light
material.emission = 1.00 * albedo_sqrt * (0.1 + 0.9 * cube(hsl.z));
#endif
} else { // 33
#ifdef HARDCODED_EMISSION
// Medium white light
material.emission = 0.66 * albedo_sqrt * linear_step(0.75, 0.9, hsl.z);
#endif
}
} else { // 34-36
if (material_mask == 34u) { // 34
#ifdef HARDCODED_EMISSION
// Weak white light
material.emission = 0.2 * albedo_sqrt * (0.1 + 0.9 * pow4(hsl.z));
#endif
} else { // 35
#ifdef HARDCODED_EMISSION
// Strong golden light
material.emission = 0.85 * albedo_sqrt * linear_step(0.4, 0.6, 0.2 * hsl.y + 0.55 * hsl.z);
#endif
}
}
} else { // 36-40
if (material_mask < 38u) { // 36-38
if (material_mask == 36u) { // 36
#ifdef HARDCODED_EMISSION
// Medium golden light
material.emission = 0.85 * albedo_sqrt * linear_step(0.78, 0.85, hsl.z);
#endif
} else { // 37
#ifdef HARDCODED_EMISSION
// Weak golden light
float blue = isolate_hue(hsl, 200.0, 30.0);
material.emission = 0.8 * albedo_sqrt * linear_step(0.47, 0.50, 0.2 * hsl.y + 0.5 * hsl.z + 0.1 * blue);
#endif
}
} else { // 38-40
if (material_mask == 38u) { // 38
#ifdef HARDCODED_EMISSION
// Redstone components
vec3 ap1 = material.albedo * rec2020_to_ap1_unlit;
float l = 0.5 * (min_of(ap1) + max_of(ap1));
float redness = ap1.r * rcp(ap1.g + ap1.b);
material.emission = 0.33 * material.albedo * step(0.45, redness * l);
#endif
} else { // 39
#ifdef HARDCODED_EMISSION
// Lava
material.emission = 4.0 * albedo_sqrt * (0.2 + 0.8 * isolate_hue(hsl, 30.0, 15.0)) * step(0.4, hsl.y);
#endif
}
}
}
} else { // 40-48
if (material_mask < 44u) { // 40-44
if (material_mask < 42u) { // 40-42
if (material_mask == 40u) { // 40
#ifdef HARDCODED_EMISSION
// Medium orange emissives
material.emission = 0.60 * albedo_sqrt * (0.1 + 0.9 * cube(hsl.z));
#endif
} else { // 41
#ifdef HARDCODED_EMISSION
// Brewing stand
material.emission = 0.85 * albedo_sqrt * linear_step(0.77, 0.85, hsl.z);
#endif
}
} else { // 42-44
if (material_mask == 42u) { // 42
#ifdef HARDCODED_EMISSION
// Jack o' Lantern
material.emission = 0.80 * albedo_sqrt * step(0.73, 0.1 * hsl.y + 0.7 * hsl.z);
#endif
} else { // 43
#ifdef HARDCODED_EMISSION
// Soul lights
float blue = isolate_hue(hsl, 200.0, 30.0);
material.emission = 0.66 * albedo_sqrt * linear_step(0.8, 1.0, blue + hsl.z);
#endif
}
}
} else { // 44-48
if (material_mask < 46u) { // 44-46
if (material_mask == 44u) { // 44
#ifdef HARDCODED_EMISSION
// Beacon
material.emission = step(0.2, hsl.z) * albedo_sqrt * step(max_of(abs(block_pos - 0.5)), 0.4);
#endif
} else { // 45
#ifdef HARDCODED_EMISSION
// End portal frame
material.emission = 0.33 * material.albedo * isolate_hue(hsl, 120.0, 50.0);
#endif
}
} else { // 46-48
if (material_mask == 46u) { // 46
#ifdef HARDCODED_EMISSION
// Sculk
material.emission = 0.2 * material.albedo * isolate_hue(hsl, 200.0, 40.0) * smoothstep(0.5, 0.7, hsl.z) * (1.0 - linear_step(0.0, 20.0, distance(world_pos, cameraPosition)));
#endif
} else { // 47
#ifdef HARDCODED_EMISSION
// Pink glow
material.emission = vec3(0.75) * isolate_hue(hsl, 310.0, 50.0);
#endif
}
}
}
}
} else { // 48-64
if (material_mask < 56u) { // 48-56
if (material_mask < 52u) { // 48-52
if (material_mask < 50u) { // 48-50
if (material_mask == 48u) { // 48
material.emission = 0.5 * albedo_sqrt * linear_step(0.5, 0.6, hsl.z);
} else { // 49
#ifdef HARDCODED_EMISSION
// Jack o' Lantern + nether mushrooms
material.emission = 0.80 * albedo_sqrt * step(0.73, 0.1 * hsl.y + 0.7 * hsl.z);
#endif
}
} else { // 50-52
if (material_mask == 50u) { // 50
#ifdef HARDCODED_EMISSION
// Candles
material.emission = vec3(0.2) * pow4(clamp01(block_pos.y * 2.0));
#endif
} else { // 51
#ifdef HARDCODED_EMISSION
// Ochre froglight
material.emission = 0.40 * albedo_sqrt * (0.1 + 0.9 * cube(hsl.z));
#endif
}
}
} else { // 52-56
if (material_mask < 54u) { // 52-54
if (material_mask == 52u) { // 52
#ifdef HARDCODED_EMISSION
// Verdant froglight
material.emission = 0.40 * albedo_sqrt * (0.1 + 0.9 * cube(hsl.z));
#endif
} else { // 53
#ifdef HARDCODED_EMISSION
// Pearlescent froglight
material.emission = 0.40 * albedo_sqrt * (0.1 + 0.9 * cube(hsl.z));
#endif
}
} else { // 54-56
if (material_mask == 54u) { // 54
} else { // 55
#ifdef HARDCODED_EMISSION
// Amethyst cluster
material.emission = vec3(0.20) * (0.1 + 0.9 * hsl.z);
#endif
}
}
}
} else { // 56-64
if (material_mask < 60u) { // 56-60
if (material_mask < 58u) { // 56-58
if (material_mask == 56u) { // 56
#ifdef HARDCODED_EMISSION
// Calibrated sculk sensor
material.emission = 0.2 * material.albedo * isolate_hue(hsl, 200.0, 40.0) * smoothstep(0.5, 0.7, hsl.z) * (1.0 - linear_step(0.0, 20.0, distance(world_pos, cameraPosition)));
material.emission += vec3(0.20) * (0.1 + 0.9 * hsl.z) * step(0.5, isolate_hue(hsl, 270.0, 50.0) + 0.55 * hsl.z);
#endif
} else { // 57
#ifdef HARDCODED_EMISSION
// Active sculk sensor
material.emission = vec3(0.20) * (0.1 + 0.9 * hsl.z);
#endif
}
} else { // 58-60
if (material_mask == 58u) { // 58
#ifdef HARDCODED_EMISSION
// Redstone block
material.emission = 0.33 * albedo_sqrt;
#endif
} else { // 59
#ifdef HARDCODED_EMISSION
// Emerald block
material.emission = 0.1 * albedo_sqrt;
#endif
}
}
} else { // 60-64
if (material_mask < 62u) { // 60-62
if (material_mask == 60u) { // 60
#ifdef HARDCODED_EMISSION
// Lapis block
material.emission = 0.33 * albedo_sqrt;
#endif
} else { // 61
}
} else { // 62-64
if (material_mask == 62u) { // 62
// Nether portal
material.emission = vec3(1.0);
} else { // 63
// End portal
material.emission = vec3(1.0);
}
}
}
}
}
} else if (material_mask < 264u) { // 64 - 264
if(material_mask == 80) { // 80
// Powered lightning rod
material.emission = vec3(1.0);
} /*else {
}*/
} else if (material_mask < 331u) { // 264 - 331
// Colored Candles
material.emission = vec3(0.2) * pow4(clamp01(block_pos.y * 2.0));
} /*else if (material_mask == PHYSICS_MOD_SNOW_ID) {
#ifdef HARDCODED_SPECULAR
material.f0 = vec3(0.02);
material.roughness = 0.5;
#endif
#ifdef HARDCODED_SSS
material.sss_amount = 1.0;
material.sheen_amount = 1.0;
#endif
}*/
if (164u <= material_mask && material_mask < 180u) {
// Stained glass, honey and slime
#ifdef HARDCODED_SPECULAR
material.f0 = vec3(0.04);
material.roughness = 0.1;
material.ssr_multiplier = 1.0;
#endif
#ifdef HARDCODED_SSS
material.sss_amount = 0.5;
#endif
}
return material;
}
#endif // INCLUDE_MISC_MATERIAL

View File

@ -1,15 +0,0 @@
float min1(float x) {
return min(x, 1.0);
}
float max0(float x) {
return max(x, 0.0);
}
float clamp01(float x) {
return clamp(x, 0.0, 1.0);
}
vec2 clamp01(vec2 x) {
return clamp(x, vec2(0.0), vec2(1.0));
}
vec3 clamp01(vec3 x) {
return clamp(x, vec3(0.0), vec3(1.0));
}

View File

@ -142,10 +142,6 @@ vec2 moonDiffuse[8] = vec2[8](
); );
//Common Functions// //Common Functions//
float GetLuminance(vec3 color) {
return dot(color,vec3(0.299, 0.587, 0.114));
}
float GetLinearDepth(float depth) { float GetLinearDepth(float depth) {
return (2.0 * near) / (far + near - depth * (far - near)); return (2.0 * near) / (far + near - depth * (far - near));
} }
@ -209,6 +205,7 @@ void GlowOutline(inout vec3 color){
} }
//Includes// //Includes//
#include "/lib/common.glsl"
#include "/lib/color/dimensionColor.glsl" #include "/lib/color/dimensionColor.glsl"
#include "/lib/color/skyColor.glsl" #include "/lib/color/skyColor.glsl"
#include "/lib/color/blocklightColor.glsl" #include "/lib/color/blocklightColor.glsl"
@ -220,6 +217,7 @@ void GlowOutline(inout vec3 color){
#include "/lib/atmospherics/clouds.glsl" #include "/lib/atmospherics/clouds.glsl"
#include "/lib/atmospherics/sunmoon.glsl" #include "/lib/atmospherics/sunmoon.glsl"
#ifdef OUTLINE_ENABLED #ifdef OUTLINE_ENABLED
#include "/lib/util/outlineOffset.glsl" #include "/lib/util/outlineOffset.glsl"
#include "/lib/util/outlineDepth.glsl" #include "/lib/util/outlineDepth.glsl"

View File

@ -1,7 +1,7 @@
/* /*
BSL Shaders v8 Series by Capt Tatsu BSL Shaders v8 Series by Capt Tatsu
https://bitslablab.com https://bitslablab.com
*/ */
//Settings// //Settings//
#include "/lib/settings.glsl" #include "/lib/settings.glsl"
@ -28,7 +28,7 @@ uniform float far;
uniform float frameTimeCounter; uniform float frameTimeCounter;
uniform float blindFactor, darknessFactor, nightVision; uniform float blindFactor, darknessFactor, nightVision;
uniform float rainStrength; uniform float rainStrength;
uniform float screenBrightness; uniform float screenBrightness;
uniform float shadowFade; uniform float shadowFade;
uniform float timeAngle, timeBrightness; uniform float timeAngle, timeBrightness;
uniform float viewWidth, viewHeight; uniform float viewWidth, viewHeight;
@ -65,9 +65,6 @@ vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.
mat4 gbufferProjectionInverse = dhProjectionInverse; mat4 gbufferProjectionInverse = dhProjectionInverse;
//Common Functions// //Common Functions//
float GetLuminance(vec3 color) {
return dot(color,vec3(0.299, 0.587, 0.114));
}
float GetBlueNoise3D(vec3 pos, vec3 normal) { float GetBlueNoise3D(vec3 pos, vec3 normal) {
pos = (floor(pos + 0.01) + 0.5) / 512.0; pos = (floor(pos + 0.01) + 0.5) / 512.0;
@ -88,6 +85,7 @@ float GetBlueNoise3D(vec3 pos, vec3 normal) {
} }
//Includes// //Includes//
#include "/lib/common.glsl"
#include "/lib/color/blocklightColor.glsl" #include "/lib/color/blocklightColor.glsl"
#include "/lib/color/dimensionColor.glsl" #include "/lib/color/dimensionColor.glsl"
#include "/lib/color/specularColor.glsl" #include "/lib/color/specularColor.glsl"
@ -96,6 +94,7 @@ float GetBlueNoise3D(vec3 pos, vec3 normal) {
#include "/lib/lighting/forwardLighting.glsl" #include "/lib/lighting/forwardLighting.glsl"
#include "/lib/surface/ggx.glsl" #include "/lib/surface/ggx.glsl"
#ifdef TAA #ifdef TAA
#include "/lib/util/jitter.glsl" #include "/lib/util/jitter.glsl"
#endif #endif
@ -107,7 +106,7 @@ void main() {
if (albedo.a > 0.001) { if (albedo.a > 0.001) {
vec2 lightmap = clamp(lmCoord, vec2(0.0), vec2(1.0)); vec2 lightmap = clamp(lmCoord, vec2(0.0), vec2(1.0));
float foliage = float(mat > 0.98 && mat < 1.02); float foliage = float(mat > 0.98 && mat < 1.02);
float leaves = float(mat > 1.98 && mat < 2.02); float leaves = float(mat > 1.98 && mat < 2.02);
float emissive = float(mat > 2.98 && mat < 3.02); float emissive = float(mat > 2.98 && mat < 3.02);
@ -119,9 +118,9 @@ void main() {
float subsurface = 0.0; float subsurface = 0.0;
float basicSubsurface = leaves * 0.5; float basicSubsurface = leaves * 0.5;
vec3 baseReflectance = vec3(0.04); vec3 baseReflectance = vec3(0.04);
emission *= pow(max(max(albedo.r, albedo.g), albedo.b), 4.0) * 0.4; emission *= pow(max(max(albedo.r, albedo.g), albedo.b), 4.0) * 0.4;
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z); vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z);
#ifdef TAA #ifdef TAA
vec3 viewPos = ToNDC(vec3(TAAJitter(screenPos.xy, -0.5), screenPos.z)); vec3 viewPos = ToNDC(vec3(TAAJitter(screenPos.xy, -0.5), screenPos.z));
@ -155,16 +154,16 @@ void main() {
#ifdef WHITE_WORLD #ifdef WHITE_WORLD
albedo.rgb = vec3(0.35); albedo.rgb = vec3(0.35);
#endif #endif
vec3 outNormal = newNormal; vec3 outNormal = newNormal;
float NoL = clamp(dot(newNormal, lightVec), 0.0, 1.0); float NoL = clamp(dot(newNormal, lightVec), 0.0, 1.0);
float NoU = clamp(dot(newNormal, upVec), -1.0, 1.0); float NoU = clamp(dot(newNormal, upVec), -1.0, 1.0);
float NoE = clamp(dot(newNormal, eastVec), -1.0, 1.0); float NoE = clamp(dot(newNormal, eastVec), -1.0, 1.0);
float vanillaDiffuse = (0.25 * NoU + 0.75) + (0.667 - abs(NoE)) * (1.0 - abs(NoU)) * 0.15; float vanillaDiffuse = (0.25 * NoU + 0.75) + (0.667 - abs(NoE)) * (1.0 - abs(NoU)) * 0.15;
vanillaDiffuse*= vanillaDiffuse; vanillaDiffuse*= vanillaDiffuse;
#ifndef NORMAL_PLANTS #ifndef NORMAL_PLANTS
if (foliage > 0.5) vanillaDiffuse *= 1.8; if (foliage > 0.5) vanillaDiffuse *= 1.8;
#endif #endif
@ -172,9 +171,9 @@ void main() {
float halfNoL = dot(newNormal, lightVec) * 0.5 + 0.5; float halfNoL = dot(newNormal, lightVec) * 0.5 + 0.5;
basicSubsurface *= halfNoL * step(length(albedo.rgb), 1.7); basicSubsurface *= halfNoL * step(length(albedo.rgb), 1.7);
} }
vec3 shadow = vec3(0.0); vec3 shadow = vec3(0.0);
GetLighting(albedo.rgb, shadow, viewPos, worldPos, normal, lightmap, 1.0, NoL, GetLighting(albedo.rgb, shadow, viewPos, worldPos, normal, lightmap, 1.0, NoL,
vanillaDiffuse, 1.0, emission, subsurface, basicSubsurface); vanillaDiffuse, 1.0, emission, subsurface, basicSubsurface);
#if ALPHA_BLEND == 0 #if ALPHA_BLEND == 0
@ -243,16 +242,16 @@ float frametime = frameTimeCounter * ANIMATION_SPEED;
//Program// //Program//
void main() { void main() {
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy; texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
lmCoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy; lmCoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
lmCoord = clamp((lmCoord - 0.03125) * 1.06667, vec2(0.0), vec2(0.9333, 1.0)); lmCoord = clamp((lmCoord - 0.03125) * 1.06667, vec2(0.0), vec2(0.9333, 1.0));
int blockID = dhMaterialId; int blockID = dhMaterialId;
normal = normalize(gl_NormalMatrix * gl_Normal); normal = normalize(gl_NormalMatrix * gl_Normal);
color = gl_Color; color = gl_Color;
mat = 0.0; mat = 0.0;
if (blockID == DH_BLOCK_LEAVES){ if (blockID == DH_BLOCK_LEAVES){
@ -281,7 +280,7 @@ void main() {
#endif #endif
gl_Position = dhProjection * gbufferModelView * position; gl_Position = dhProjection * gbufferModelView * position;
#ifdef TAA #ifdef TAA
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w); gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
#endif #endif

View File

@ -1,7 +1,7 @@
/* /*
BSL Shaders v8 Series by Capt Tatsu BSL Shaders v8 Series by Capt Tatsu
https://bitslablab.com https://bitslablab.com
*/ */
//Settings// //Settings//
#include "/lib/settings.glsl" #include "/lib/settings.glsl"
@ -31,7 +31,7 @@ uniform float dhFarPlane;
uniform float far, near; uniform float far, near;
uniform float frameTimeCounter; uniform float frameTimeCounter;
uniform float rainStrength; uniform float rainStrength;
uniform float screenBrightness; uniform float screenBrightness;
uniform float shadowFade, voidFade; uniform float shadowFade, voidFade;
uniform float timeAngle, timeBrightness; uniform float timeAngle, timeBrightness;
uniform float viewWidth, viewHeight; uniform float viewWidth, viewHeight;
@ -78,13 +78,10 @@ mat4 gbufferPreviousProjection = dhPreviousProjection;
mat4 gbufferProjectionInverse = dhProjectionInverse; mat4 gbufferProjectionInverse = dhProjectionInverse;
//Common Functions// //Common Functions//
float GetLuminance(vec3 color) {
return dot(color,vec3(0.299, 0.587, 0.114));
}
float GetWaterHeightMap(vec3 worldPos, vec2 offset) { float GetWaterHeightMap(vec3 worldPos, vec2 offset) {
float noise = 0.0; float noise = 0.0;
vec2 wind = vec2(frametime) * 0.5 * WATER_SPEED; vec2 wind = vec2(frametime) * 0.5 * WATER_SPEED;
worldPos.xz += worldPos.y * 0.2; worldPos.xz += worldPos.y * 0.2;
@ -99,7 +96,7 @@ float GetWaterHeightMap(vec3 worldPos, vec2 offset) {
float noiseB = texture2D(noisetex, (worldPos.xz + wind) / 96.0 + offset).r; float noiseB = texture2D(noisetex, (worldPos.xz + wind) / 96.0 + offset).r;
noiseA *= noiseA; noiseB *= noiseB; noiseA *= noiseA; noiseB *= noiseB;
#endif #endif
#if WATER_NORMALS > 0 #if WATER_NORMALS > 0
noise = mix(noiseA, noiseB, WATER_DETAIL); noise = mix(noiseA, noiseB, WATER_DETAIL);
#endif #endif
@ -109,7 +106,7 @@ float GetWaterHeightMap(vec3 worldPos, vec2 offset) {
vec3 GetParallaxWaves(vec3 worldPos, vec3 viewVector) { vec3 GetParallaxWaves(vec3 worldPos, vec3 viewVector) {
vec3 parallaxPos = worldPos; vec3 parallaxPos = worldPos;
for(int i = 0; i < 4; i++) { for(int i = 0; i < 4; i++) {
float height = -1.25 * GetWaterHeightMap(parallaxPos, vec2(0.0)) + 0.25; float height = -1.25 * GetWaterHeightMap(parallaxPos, vec2(0.0)) + 0.25;
parallaxPos.xz += height * viewVector.xy / dist; parallaxPos.xz += height * viewVector.xy / dist;
@ -129,7 +126,7 @@ vec3 GetWaterNormal(vec3 worldPos, vec3 viewPos, vec3 viewVector) {
#endif #endif
float normalOffset = WATER_SHARPNESS; float normalOffset = WATER_SHARPNESS;
float fresnel = pow(clamp(1.0 + dot(normalize(normal), normalize(viewPos)), 0.0, 1.0), 8.0); float fresnel = pow(clamp(1.0 + dot(normalize(normal), normalize(viewPos)), 0.0, 1.0), 8.0);
float normalStrength = 0.35 * (1.0 - fresnel); float normalStrength = 0.35 * (1.0 - fresnel);
@ -146,6 +143,7 @@ vec3 GetWaterNormal(vec3 worldPos, vec3 viewPos, vec3 viewVector) {
} }
//Includes// //Includes//
#include "/lib/common.glsl"
#include "/lib/color/blocklightColor.glsl" #include "/lib/color/blocklightColor.glsl"
#include "/lib/color/dimensionColor.glsl" #include "/lib/color/dimensionColor.glsl"
#include "/lib/color/skyColor.glsl" #include "/lib/color/skyColor.glsl"
@ -163,6 +161,7 @@ vec3 GetWaterNormal(vec3 worldPos, vec3 viewPos, vec3 viewVector) {
#include "/lib/reflections/simpleReflections.glsl" #include "/lib/reflections/simpleReflections.glsl"
#include "/lib/surface/ggx.glsl" #include "/lib/surface/ggx.glsl"
#ifdef TAA #ifdef TAA
#include "/lib/util/jitter.glsl" #include "/lib/util/jitter.glsl"
#endif #endif
@ -186,12 +185,12 @@ void main() {
if (albedo.a > 0.001) { if (albedo.a > 0.001) {
vec2 lightmap = clamp(lmCoord, vec2(0.0), vec2(1.0)); vec2 lightmap = clamp(lmCoord, vec2(0.0), vec2(1.0));
float water = float(mat > 0.98 && mat < 1.02); float water = float(mat > 0.98 && mat < 1.02);
float glass = float(mat > 1.98 && mat < 2.02); float glass = float(mat > 1.98 && mat < 2.02);
float translucent = float(mat > 2.98 && mat < 3.02); float translucent = float(mat > 2.98 && mat < 3.02);
float portal = float(mat > 3.98 && mat < 4.02); float portal = float(mat > 3.98 && mat < 4.02);
float metalness = 0.0; float metalness = 0.0;
float emission = portal; float emission = portal;
float subsurface = 0.0; float subsurface = 0.0;
@ -199,7 +198,7 @@ void main() {
vec3 baseReflectance = vec3(0.04); vec3 baseReflectance = vec3(0.04);
emission *= pow(max(max(albedo.r, albedo.g), albedo.b), 4.0) * 0.4; emission *= pow(max(max(albedo.r, albedo.g), albedo.b), 4.0) * 0.4;
#ifndef REFLECTION_TRANSLUCENT #ifndef REFLECTION_TRANSLUCENT
glass = 0.0; glass = 0.0;
translucent = 0.0; translucent = 0.0;
@ -213,7 +212,7 @@ void main() {
vec3 worldPos = ToWorld(viewPos); vec3 worldPos = ToWorld(viewPos);
float dither = Bayer8(gl_FragCoord.xy); float dither = Bayer8(gl_FragCoord.xy);
float viewLength = length(viewPos); float viewLength = length(viewPos);
float minDist = (dither - 1.0) * 16.0 + far; float minDist = (dither - 1.0) * 16.0 + far;
if (viewLength < minDist) { if (viewLength < minDist) {
@ -237,7 +236,7 @@ void main() {
#endif #endif
vec3 normalMap = vec3(0.0, 0.0, 1.0); vec3 normalMap = vec3(0.0, 0.0, 1.0);
mat3 tbnMatrix = mat3(tangent.x, binormal.x, normal.x, mat3 tbnMatrix = mat3(tangent.x, binormal.x, normal.x,
tangent.y, binormal.y, normal.y, tangent.y, binormal.y, normal.y,
tangent.z, binormal.z, normal.z); tangent.z, binormal.z, normal.z);
@ -261,13 +260,13 @@ void main() {
#endif #endif
albedo.rgb = pow(albedo.rgb, vec3(2.2)); albedo.rgb = pow(albedo.rgb, vec3(2.2));
vlAlbedo = albedo.rgb; vlAlbedo = albedo.rgb;
#ifdef WHITE_WORLD #ifdef WHITE_WORLD
albedo.rgb = vec3(0.35); albedo.rgb = vec3(0.35);
#endif #endif
if (water > 0.5) { if (water > 0.5) {
#if WATER_MODE == 0 #if WATER_MODE == 0
albedo.rgb = waterColor.rgb * waterColor.a; albedo.rgb = waterColor.rgb * waterColor.a;
@ -285,20 +284,20 @@ void main() {
vlAlbedo = sqrt(albedo.rgb); vlAlbedo = sqrt(albedo.rgb);
baseReflectance = vec3(0.02); baseReflectance = vec3(0.02);
} }
vlAlbedo = mix(vec3(1.0), vlAlbedo, sqrt(albedo.a)) * (1.0 - pow(albedo.a, 64.0)); vlAlbedo = mix(vec3(1.0), vlAlbedo, sqrt(albedo.a)) * (1.0 - pow(albedo.a, 64.0));
float NoL = clamp(dot(newNormal, lightVec), 0.0, 1.0); float NoL = clamp(dot(newNormal, lightVec), 0.0, 1.0);
float NoU = clamp(dot(newNormal, upVec), -1.0, 1.0); float NoU = clamp(dot(newNormal, upVec), -1.0, 1.0);
float NoE = clamp(dot(newNormal, eastVec), -1.0, 1.0); float NoE = clamp(dot(newNormal, eastVec), -1.0, 1.0);
float vanillaDiffuse = (0.25 * NoU + 0.75) + (0.667 - abs(NoE)) * (1.0 - abs(NoU)) * 0.15; float vanillaDiffuse = (0.25 * NoU + 0.75) + (0.667 - abs(NoE)) * (1.0 - abs(NoU)) * 0.15;
vanillaDiffuse*= vanillaDiffuse; vanillaDiffuse*= vanillaDiffuse;
vec3 shadow = vec3(0.0); vec3 shadow = vec3(0.0);
GetLighting(albedo.rgb, shadow, viewPos, worldPos, normal, lightmap, color.a, NoL, GetLighting(albedo.rgb, shadow, viewPos, worldPos, normal, lightmap, color.a, NoL,
vanillaDiffuse, 1.0, emission, subsurface, basicSubsurface); vanillaDiffuse, 1.0, emission, subsurface, basicSubsurface);
float fresnel = pow(clamp(1.0 + dot(newNormal, normalize(viewPos)), 0.0, 1.0), 5.0); float fresnel = pow(clamp(1.0 + dot(newNormal, normalize(viewPos)), 0.0, 1.0), 5.0);
if (water > 0.5 || ((translucent + glass) > 0.5 && albedo.a < 0.95)) { if (water > 0.5 || ((translucent + glass) > 0.5 && albedo.a < 0.95)) {
@ -306,21 +305,21 @@ void main() {
vec4 reflection = vec4(0.0); vec4 reflection = vec4(0.0);
vec3 skyReflection = vec3(0.0); vec3 skyReflection = vec3(0.0);
float reflectionMask = 0.0; float reflectionMask = 0.0;
fresnel = fresnel * 0.98 + 0.02; fresnel = fresnel * 0.98 + 0.02;
fresnel*= max(1.0 - isEyeInWater * 0.5 * water, 0.5); fresnel*= max(1.0 - isEyeInWater * 0.5 * water, 0.5);
// fresnel = 1.0; // fresnel = 1.0;
#if REFLECTION == 2 #if REFLECTION == 2
reflection = DHReflection(viewPos, newNormal, dither, reflectionMask); reflection = DHReflection(viewPos, newNormal, dither, reflectionMask);
reflection.rgb = pow(reflection.rgb * 2.0, vec3(8.0)); reflection.rgb = pow(reflection.rgb * 2.0, vec3(8.0));
#endif #endif
if (reflection.a < 1.0) { if (reflection.a < 1.0) {
#ifdef OVERWORLD #ifdef OVERWORLD
vec3 skyRefPos = reflect(normalize(viewPos), newNormal); vec3 skyRefPos = reflect(normalize(viewPos), newNormal);
skyReflection = GetSkyColor(skyRefPos, true); skyReflection = GetSkyColor(skyRefPos, true);
#ifdef AURORA #ifdef AURORA
skyReflection += DrawAurora(skyRefPos * 100.0, dither, 12); skyReflection += DrawAurora(skyRefPos * 100.0, dither, 12);
#endif #endif
@ -340,7 +339,7 @@ void main() {
#ifdef CLASSIC_EXPOSURE #ifdef CLASSIC_EXPOSURE
skyReflection *= 4.0 - 3.0 * eBS; skyReflection *= 4.0 - 3.0 * eBS;
#endif #endif
float waterSkyOcclusion = lightmap.y; float waterSkyOcclusion = lightmap.y;
#if REFLECTION_SKY_FALLOFF > 1 #if REFLECTION_SKY_FALLOFF > 1
waterSkyOcclusion = clamp(1.0 - (1.0 - waterSkyOcclusion) * REFLECTION_SKY_FALLOFF, 0.0, 1.0); waterSkyOcclusion = clamp(1.0 - (1.0 - waterSkyOcclusion) * REFLECTION_SKY_FALLOFF, 0.0, 1.0);
@ -359,7 +358,7 @@ void main() {
skyReflection *= clamp(1.0 - isEyeInWater, 0.0, 1.0); skyReflection *= clamp(1.0 - isEyeInWater, 0.0, 1.0);
} }
reflection.rgb = max(mix(skyReflection, reflection.rgb, reflection.a), vec3(0.0)); reflection.rgb = max(mix(skyReflection, reflection.rgb, reflection.a), vec3(0.0));
#if defined OVERWORLD || defined END #if defined OVERWORLD || defined END
@ -375,7 +374,7 @@ void main() {
reflection.rgb += specular * (1.0 - reflectionMask) / specularAlpha; reflection.rgb += specular * (1.0 - reflectionMask) / specularAlpha;
#endif #endif
albedo.rgb = mix(albedo.rgb, reflection.rgb, fresnel); albedo.rgb = mix(albedo.rgb, reflection.rgb, fresnel);
albedo.a = mix(albedo.a, 1.0, fresnel); albedo.a = mix(albedo.a, 1.0, fresnel);
#endif #endif
@ -458,11 +457,11 @@ float frametime = frameTimeCounter * ANIMATION_SPEED;
float WavingWater(vec3 worldPos) { float WavingWater(vec3 worldPos) {
worldPos += cameraPosition; worldPos += cameraPosition;
float fractY = fract(worldPos.y + 0.005); float fractY = fract(worldPos.y + 0.005);
float wave = sin(6.2831854 * (frametime * 0.7 + worldPos.x * 0.14 + worldPos.z * 0.07)) + float wave = sin(6.2831854 * (frametime * 0.7 + worldPos.x * 0.14 + worldPos.z * 0.07)) +
sin(6.2831854 * (frametime * 0.5 + worldPos.x * 0.10 + worldPos.z * 0.20)); sin(6.2831854 * (frametime * 0.5 + worldPos.x * 0.10 + worldPos.z * 0.20));
if (fractY > 0.01) return wave * 0.0125; if (fractY > 0.01) return wave * 0.0125;
return 0.0; return 0.0;
} }
@ -478,28 +477,28 @@ float WavingWater(vec3 worldPos) {
//Program// //Program//
void main() { void main() {
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy; texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
lmCoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy; lmCoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
lmCoord = clamp((lmCoord - 0.03125) * 1.06667, vec2(0.0), vec2(0.9333, 1.0)); lmCoord = clamp((lmCoord - 0.03125) * 1.06667, vec2(0.0), vec2(0.9333, 1.0));
int blockID = dhMaterialId; int blockID = dhMaterialId;
normal = normalize(gl_NormalMatrix * gl_Normal); normal = normalize(gl_NormalMatrix * gl_Normal);
binormal = normalize(gbufferModelView[2].xyz); binormal = normalize(gbufferModelView[2].xyz);
tangent = normalize(gbufferModelView[0].xyz); tangent = normalize(gbufferModelView[0].xyz);
mat3 tbnMatrix = mat3(tangent.x, binormal.x, normal.x, mat3 tbnMatrix = mat3(tangent.x, binormal.x, normal.x,
tangent.y, binormal.y, normal.y, tangent.y, binormal.y, normal.y,
tangent.z, binormal.z, normal.z); tangent.z, binormal.z, normal.z);
viewVector = tbnMatrix * (gl_ModelViewMatrix * gl_Vertex).xyz; viewVector = tbnMatrix * (gl_ModelViewMatrix * gl_Vertex).xyz;
dist = length(gl_ModelViewMatrix * gl_Vertex); dist = length(gl_ModelViewMatrix * gl_Vertex);
color = gl_Color; color = gl_Color;
mat = 0.0; mat = 0.0;
if (blockID == DH_BLOCK_WATER) mat = 1.0; if (blockID == DH_BLOCK_WATER) mat = 1.0;
const vec2 sunRotationData = vec2( const vec2 sunRotationData = vec2(
@ -514,7 +513,7 @@ void main() {
eastVec = tangent; eastVec = tangent;
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex; vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
#ifdef WAVING_WATER #ifdef WAVING_WATER
float istopv = gl_MultiTexCoord0.t < mc_midTexCoord.t ? 1.0 : 0.0; float istopv = gl_MultiTexCoord0.t < mc_midTexCoord.t ? 1.0 : 0.0;
if (blockID == 300 || blockID == 302 || blockID == 304) position.y += WavingWater(position.xyz); if (blockID == 300 || blockID == 302 || blockID == 304) position.y += WavingWater(position.xyz);
@ -526,7 +525,7 @@ void main() {
gl_Position = gl_ProjectionMatrix * gbufferModelView * position; gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
if (mat == 0.0) gl_Position.z -= 0.00001; if (mat == 0.0) gl_Position.z -= 0.00001;
#ifdef TAA #ifdef TAA
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w); gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
#endif #endif

View File

@ -1,7 +1,7 @@
/* /*
BSL Shaders v8 Series by Capt Tatsu BSL Shaders v8 Series by Capt Tatsu
https://bitslablab.com https://bitslablab.com
*/ */
//Settings// //Settings//
#include "/lib/settings.glsl" #include "/lib/settings.glsl"
@ -25,7 +25,7 @@ uniform int worldTime;
uniform float frameTimeCounter; uniform float frameTimeCounter;
uniform float nightVision; uniform float nightVision;
uniform float rainStrength; uniform float rainStrength;
uniform float screenBrightness; uniform float screenBrightness;
uniform float shadowFade; uniform float shadowFade;
uniform float timeAngle, timeBrightness; uniform float timeAngle, timeBrightness;
uniform float viewWidth, viewHeight; uniform float viewWidth, viewHeight;
@ -68,16 +68,15 @@ float frametime = frameTimeCounter * ANIMATION_SPEED;
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0); vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
//Common Functions// //Common Functions//
float GetLuminance(vec3 color) {
return dot(color,vec3(0.299, 0.587, 0.114));
}
//Includes// //Includes//
#include "/lib/common.glsl"
#include "/lib/color/blocklightColor.glsl" #include "/lib/color/blocklightColor.glsl"
#include "/lib/color/dimensionColor.glsl" #include "/lib/color/dimensionColor.glsl"
#include "/lib/util/spaceConversion.glsl" #include "/lib/util/spaceConversion.glsl"
#include "/lib/lighting/forwardLighting.glsl" #include "/lib/lighting/forwardLighting.glsl"
#ifdef TAA #ifdef TAA
#include "/lib/util/jitter.glsl" #include "/lib/util/jitter.glsl"
#endif #endif
@ -100,7 +99,7 @@ void main() {
vec3 viewPos = ToNDC(screenPos); vec3 viewPos = ToNDC(screenPos);
#endif #endif
vec3 worldPos = ToWorld(viewPos); vec3 worldPos = ToWorld(viewPos);
#ifdef DYNAMIC_HANDLIGHT #ifdef DYNAMIC_HANDLIGHT
float heldLightValue = max(float(heldBlockLightValue), float(heldBlockLightValue2)); float heldLightValue = max(float(heldBlockLightValue), float(heldBlockLightValue2));
float handlight = clamp((heldLightValue - 2.0 * length(viewPos)) / 15.0, 0.0, 0.9333); float handlight = clamp((heldLightValue - 2.0 * length(viewPos)) / 15.0, 0.0, 0.9333);
@ -129,9 +128,9 @@ void main() {
#ifdef MULTICOLORED_BLOCKLIGHT #ifdef MULTICOLORED_BLOCKLIGHT
blocklightCol = ApplyMultiColoredBlocklight(blocklightCol, screenPos); blocklightCol = ApplyMultiColoredBlocklight(blocklightCol, screenPos);
#endif #endif
vec3 shadow = vec3(0.0); vec3 shadow = vec3(0.0);
GetLighting(albedo.rgb, shadow, viewPos, worldPos, normal, lightmap, 1.0, NoL, GetLighting(albedo.rgb, shadow, viewPos, worldPos, normal, lightmap, 1.0, NoL,
vanillaDiffuse, 1.0, 0.0, 0.0, 0.0); vanillaDiffuse, 1.0, 0.0, 0.0, 0.0);
#if ALPHA_BLEND == 0 #if ALPHA_BLEND == 0
@ -215,12 +214,12 @@ float frametime = frameTimeCounter * ANIMATION_SPEED;
//Program// //Program//
void main() { void main() {
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy; texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
lmCoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy; lmCoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
lmCoord = clamp((lmCoord - 0.03125) * 1.06667, vec2(0.0), vec2(0.9333, 1.0)); lmCoord = clamp((lmCoord - 0.03125) * 1.06667, vec2(0.0), vec2(0.9333, 1.0));
normal = normalize(gl_NormalMatrix * gl_Normal); normal = normalize(gl_NormalMatrix * gl_Normal);
color = gl_Color; color = gl_Color;
const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994)); const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994));
@ -238,7 +237,7 @@ void main() {
#else #else
gl_Position = ftransform(); gl_Position = ftransform();
#endif #endif
#ifdef TAA #ifdef TAA
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w); gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
#endif #endif

View File

@ -5,7 +5,6 @@ https://bitslablab.com
//Settings// //Settings//
#include "/lib/settings.glsl" #include "/lib/settings.glsl"
#include "/lib/util/commonFunctions.glsl"
//Fragment Shader/////////////////////////////////////////////////////////////////////////////////// //Fragment Shader///////////////////////////////////////////////////////////////////////////////////
#ifdef FSH #ifdef FSH
@ -18,7 +17,7 @@ varying vec3 sunVec, upVec, eastVec;
varying vec4 color; varying vec4 color;
#if defined ADVANCED_MATERIALS || defined GENERATED_NORMALS #if defined ADVANCED_MATERIALS
varying float dist; varying float dist;
varying vec3 binormal, tangent; varying vec3 binormal, tangent;
@ -27,9 +26,17 @@ varying vec4 color;
varying vec4 vTexCoord, vTexCoordAM; varying vec4 vTexCoord, vTexCoordAM;
flat varying vec2 absMidCoordPos; #ifdef GENERATED_NORMALS
varying vec2 signMidCoordPos;
flat varying vec2 absMidCoordPos;
varying vec2 signMidCoordPos;
vec2 mipx;
vec2 mipy;
float mipDelta;
float miplevel;
#endif
#endif #endif
//Uniforms// //Uniforms//
@ -58,7 +65,7 @@ uniform mat4 shadowModelView;
uniform sampler2D texture; uniform sampler2D texture;
uniform sampler2D noisetex; uniform sampler2D noisetex;
#if defined ADVANCED_MATERIALS || defined GENERATED_NORMALS #if defined ADVANCED_MATERIALS
uniform ivec2 atlasSize; uniform ivec2 atlasSize;
vec2 atlasSizeM = atlasSize; vec2 atlasSizeM = atlasSize;
@ -90,34 +97,28 @@ float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
float frametime = frameTimeCounter * ANIMATION_SPEED; float frametime = frameTimeCounter * ANIMATION_SPEED;
#endif #endif
#if defined ADVANCED_MATERIALS || defined GENERATED_NORMALS #if defined ADVANCED_MATERIALS
vec2 dcdx = dFdx(texCoord); vec2 dcdx = dFdx(texCoord);
vec2 dcdy = dFdy(texCoord); vec2 dcdy = dFdy(texCoord);
vec2 mipx; #ifdef GENERATED_NORMALS
vec2 mipy; mat3 tbnMatrix = mat3(
float mipDelta; tangent.x, binormal.x, normal.x,
float miplevel; tangent.y, binormal.y, normal.y,
tangent.z, binormal.z, normal.z
);
vec2 midCoordPos = absMidCoordPos * signMidCoordPos;
#endif
#endif #endif
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0); vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
#if defined GENERATED_NORMALS
mat3 tbnMatrix = mat3(
tangent.x, binormal.x, normal.x,
tangent.y, binormal.y, normal.y,
tangent.z, binormal.z, normal.z
);
vec2 midCoordPos = absMidCoordPos * signMidCoordPos;
#endif
//Common Functions//
float GetLuminance(vec3 color) {
return dot(color,vec3(0.299, 0.587, 0.114));
}
//Includes// //Includes//
#include "/lib/common.glsl"
#include "/lib/color/blocklightColor.glsl" #include "/lib/color/blocklightColor.glsl"
#include "/lib/color/dimensionColor.glsl" #include "/lib/color/dimensionColor.glsl"
#include "/lib/color/specularColor.glsl" #include "/lib/color/specularColor.glsl"
@ -129,15 +130,12 @@ float GetLuminance(vec3 color) {
#include "/lib/util/jitter.glsl" #include "/lib/util/jitter.glsl"
#endif #endif
#if defined ADVANCED_MATERIALS || defined GENERATED_NORMALS #if defined ADVANCED_MATERIALS
#include "/lib/util/encode.glsl" #include "/lib/util/encode.glsl"
#include "/lib/reflections/complexFresnel.glsl" #include "/lib/reflections/complexFresnel.glsl"
#include "/lib/surface/materialGbuffers.glsl" #include "/lib/surface/materialGbuffers.glsl"
#include "/lib/surface/parallax.glsl" #include "/lib/surface/parallax.glsl"
#ifdef GENERATED_NORMALS
#include "/lib/surface/generatedNormals.glsl"
#endif
#endif #endif
@ -207,11 +205,8 @@ void main() {
#ifdef ADVANCED_MATERIALS #ifdef ADVANCED_MATERIALS
float f0 = 0.0, porosity = 0.5, ao = 1.0; float f0 = 0.0, porosity = 0.5, ao = 1.0;
vec3 normalMap = vec3(0.0, 0.0, 1.0); vec3 normalMap = vec3(0.0, 0.0, 1.0);
#ifdef GENERATED_NORMALS GetMaterials(smoothness, metalness, f0, emission, subsurface, porosity, ao, normalMap,
#include "/lib/surface/materialHandling/blockEntityMaterials.glsl" newCoord, dcdx, dcdy);
#else
GetMaterials(smoothness, metalness, f0, emission, subsurface, porosity, ao, normalMap,
newCoord, dcdx, dcdy);
#endif #endif
#ifdef NORMAL_SKIP #ifdef NORMAL_SKIP
@ -239,7 +234,8 @@ void main() {
albedo.rgb = pow(albedo.rgb, vec3(2.2)); albedo.rgb = pow(albedo.rgb, vec3(2.2));
#elif defined GENERATED_NORMALS #ifdef GENERATED_NORMALS
newNormal = normalMap;
GenerateNormals(newNormal, albedo.rgb); GenerateNormals(newNormal, albedo.rgb);
#endif #endif

View File

@ -1,7 +1,7 @@
/* /*
BSL Shaders v8 Series by Capt Tatsu BSL Shaders v8 Series by Capt Tatsu
https://bitslablab.com https://bitslablab.com
*/ */
//Settings// //Settings//
#include "/lib/settings.glsl" #include "/lib/settings.glsl"
@ -23,11 +23,11 @@ void main() {
#if ALPHA_BLEND == 1 #if ALPHA_BLEND == 1
albedo.rgb = pow(albedo.rgb,vec3(2.2)) * 2.25; albedo.rgb = pow(albedo.rgb,vec3(2.2)) * 2.25;
#endif #endif
#ifdef WHITE_WORLD #ifdef WHITE_WORLD
albedo.a = 0.0; albedo.a = 0.0;
#endif #endif
/* DRAWBUFFERS:0 */ /* DRAWBUFFERS:0 */
gl_FragData[0] = albedo; gl_FragData[0] = albedo;
} }
@ -70,7 +70,7 @@ void main() {
#else #else
gl_Position = ftransform(); gl_Position = ftransform();
#endif #endif
#ifdef TAA #ifdef TAA
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w); gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
#endif #endif

View File

@ -1,7 +1,7 @@
/* /*
BSL Shaders v8 Series by Capt Tatsu BSL Shaders v8 Series by Capt Tatsu
https://bitslablab.com https://bitslablab.com
*/ */
//Settings// //Settings//
#include "/lib/settings.glsl" #include "/lib/settings.glsl"
@ -9,6 +9,8 @@ https://bitslablab.com
//Fragment Shader/////////////////////////////////////////////////////////////////////////////////// //Fragment Shader///////////////////////////////////////////////////////////////////////////////////
#ifdef FSH #ifdef FSH
#define GBUFFERS_ENTITIES
//Varyings// //Varyings//
varying vec2 texCoord, lmCoord; varying vec2 texCoord, lmCoord;
@ -18,12 +20,25 @@ varying vec3 sunVec, upVec, eastVec;
varying vec4 color; varying vec4 color;
#ifdef ADVANCED_MATERIALS #ifdef ADVANCED_MATERIALS
varying float dist; varying float dist;
varying vec3 binormal, tangent; varying vec3 binormal, tangent;
varying vec3 viewVector; varying vec3 viewVector;
varying vec4 vTexCoord, vTexCoordAM;
#ifdef GENERATED_NORMALS
flat varying vec2 absMidCoordPos;
varying vec2 signMidCoordPos;
vec2 mipx;
vec2 mipy;
float mipDelta;
float miplevel;
#endif
varying vec4 vTexCoord, vTexCoordAM;
#endif #endif
//Uniforms// //Uniforms//
@ -35,7 +50,7 @@ uniform int worldTime;
uniform float frameTimeCounter; uniform float frameTimeCounter;
uniform float nightVision; uniform float nightVision;
uniform float rainStrength; uniform float rainStrength;
uniform float screenBrightness; uniform float screenBrightness;
uniform float shadowFade; uniform float shadowFade;
uniform float timeAngle, timeBrightness; uniform float timeAngle, timeBrightness;
uniform float viewWidth, viewHeight; uniform float viewWidth, viewHeight;
@ -56,6 +71,7 @@ uniform sampler2D noisetex;
#ifdef ADVANCED_MATERIALS #ifdef ADVANCED_MATERIALS
uniform ivec2 atlasSize; uniform ivec2 atlasSize;
vec2 atlasSizeM = atlasSize;
uniform sampler2D specular; uniform sampler2D specular;
uniform sampler2D normals; uniform sampler2D normals;
@ -86,18 +102,25 @@ float frametime = frameTimeCounter * ANIMATION_SPEED;
#endif #endif
#ifdef ADVANCED_MATERIALS #ifdef ADVANCED_MATERIALS
vec2 dcdx = dFdx(texCoord); vec2 dcdx = dFdx(texCoord);
vec2 dcdy = dFdy(texCoord); vec2 dcdy = dFdy(texCoord);
#ifdef GENERATED_NORMALS
mat3 tbnMatrix = mat3(
tangent.x, binormal.x, normal.x,
tangent.y, binormal.y, normal.y,
tangent.z, binormal.z, normal.z
);
vec2 midCoordPos = absMidCoordPos * signMidCoordPos;
#endif
#endif #endif
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0); vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
//Common Functions//
float GetLuminance(vec3 color) {
return dot(color,vec3(0.299, 0.587, 0.114));
}
//Includes// //Includes//
#include "/lib/common.glsl"
#include "/lib/color/blocklightColor.glsl" #include "/lib/color/blocklightColor.glsl"
#include "/lib/color/dimensionColor.glsl" #include "/lib/color/dimensionColor.glsl"
#include "/lib/color/specularColor.glsl" #include "/lib/color/specularColor.glsl"
@ -141,7 +164,7 @@ void main() {
float surfaceDepth = 1.0; float surfaceDepth = 1.0;
float parallaxFade = clamp((dist - PARALLAX_DISTANCE) / 32.0, 0.0, 1.0); float parallaxFade = clamp((dist - PARALLAX_DISTANCE) / 32.0, 0.0, 1.0);
float skipAdvMat = float(entityId == 10100); float skipAdvMat = float(entityId == 10100);
#ifdef PARALLAX #ifdef PARALLAX
if (skipAdvMat < 0.5) { if (skipAdvMat < 0.5) {
newCoord = GetParallaxCoord(texCoord, parallaxFade, surfaceDepth); newCoord = GetParallaxCoord(texCoord, parallaxFade, surfaceDepth);
@ -156,7 +179,7 @@ void main() {
#ifdef ENTITY_FLASH #ifdef ENTITY_FLASH
albedo.rgb = mix(albedo.rgb, entityColor.rgb, entityColor.a); albedo.rgb = mix(albedo.rgb, entityColor.rgb, entityColor.a);
#endif #endif
float lightningBolt = float(entityId == 10101); float lightningBolt = float(entityId == 10101);
if(lightningBolt > 0.5) { if(lightningBolt > 0.5) {
#ifdef OVERWORLD #ifdef OVERWORLD
@ -174,12 +197,12 @@ void main() {
if (albedo.a > 0.001 && lightningBolt < 0.5) { if (albedo.a > 0.001 && lightningBolt < 0.5) {
vec2 lightmap = clamp(lmCoord, vec2(0.0), vec2(1.0)); vec2 lightmap = clamp(lmCoord, vec2(0.0), vec2(1.0));
float metalness = 0.0; float metalness = 0.0;
float emission = float(entityColor.a > 0.05) * 0.125; float emission = float(entityColor.a > 0.05) * 0.125;
float subsurface = 0.0; float subsurface = 0.0;
vec3 baseReflectance = vec3(0.04); vec3 baseReflectance = vec3(0.04);
emission *= dot(albedo.rgb, albedo.rgb) * 0.333; emission *= dot(albedo.rgb, albedo.rgb) * 0.333;
#ifndef ENTITY_FLASH #ifndef ENTITY_FLASH
@ -197,14 +220,14 @@ void main() {
#ifdef ADVANCED_MATERIALS #ifdef ADVANCED_MATERIALS
float f0 = 0.0, porosity = 0.5, ao = 1.0; float f0 = 0.0, porosity = 0.5, ao = 1.0;
vec3 normalMap = vec3(0.0, 0.0, 1.0); vec3 normalMap = vec3(0.0, 0.0, 1.0);
GetMaterials(smoothness, metalness, f0, emission, subsurface, porosity, ao, normalMap, GetMaterials(smoothness, metalness, f0, emission, subsurface, porosity, ao, normalMap,
newCoord, dcdx, dcdy); newCoord, dcdx, dcdy);
#ifdef NORMAL_SKIP #ifdef NORMAL_SKIP
normalMap = vec3(0.0, 0.0, 1.0); normalMap = vec3(0.0, 0.0, 1.0);
#endif #endif
mat3 tbnMatrix = mat3(tangent.x, binormal.x, normal.x, mat3 tbnMatrix = mat3(tangent.x, binormal.x, normal.x,
tangent.y, binormal.y, normal.y, tangent.y, binormal.y, normal.y,
tangent.z, binormal.z, normal.z); tangent.z, binormal.z, normal.z);
@ -212,7 +235,7 @@ void main() {
if ((normalMap.x > -0.999 || normalMap.y > -0.999) && viewVector == viewVector && skipAdvMat < 0.5) if ((normalMap.x > -0.999 || normalMap.y > -0.999) && viewVector == viewVector && skipAdvMat < 0.5)
newNormal = clamp(normalize(normalMap * tbnMatrix), vec3(-1.0), vec3(1.0)); newNormal = clamp(normalize(normalMap * tbnMatrix), vec3(-1.0), vec3(1.0));
#endif #endif
#ifdef DYNAMIC_HANDLIGHT #ifdef DYNAMIC_HANDLIGHT
float heldLightValue = max(float(heldBlockLightValue), float(heldBlockLightValue2)); float heldLightValue = max(float(heldBlockLightValue), float(heldBlockLightValue2));
float handlight = clamp((heldLightValue - 2.0 * length(viewPos)) / 15.0, 0.0, 0.9333); float handlight = clamp((heldLightValue - 2.0 * length(viewPos)) / 15.0, 0.0, 0.9333);
@ -223,13 +246,13 @@ void main() {
lightmap = floor(lightmap * 14.999 * (0.75 + 0.25 * color.a)) / 14.0; lightmap = floor(lightmap * 14.999 * (0.75 + 0.25 * color.a)) / 14.0;
lightmap = clamp(lightmap, vec2(0.0), vec2(1.0)); lightmap = clamp(lightmap, vec2(0.0), vec2(1.0));
#endif #endif
albedo.rgb = pow(albedo.rgb, vec3(2.2)); albedo.rgb = pow(albedo.rgb, vec3(2.2));
#ifdef WHITE_WORLD #ifdef WHITE_WORLD
albedo.rgb = vec3(0.35); albedo.rgb = vec3(0.35);
#endif #endif
float NoL = clamp(dot(newNormal, lightVec), 0.0, 1.0); float NoL = clamp(dot(newNormal, lightVec), 0.0, 1.0);
float NoU = clamp(dot(newNormal, upVec), -1.0, 1.0); float NoU = clamp(dot(newNormal, upVec), -1.0, 1.0);
@ -254,7 +277,7 @@ void main() {
#ifdef END #ifdef END
doParallax = float(NoL > 0.0); doParallax = float(NoL > 0.0);
#endif #endif
if (doParallax > 0.5) { if (doParallax > 0.5) {
parallaxShadow = GetParallaxShadow(surfaceDepth, parallaxFade, newCoord, lightVec, parallaxShadow = GetParallaxShadow(surfaceDepth, parallaxFade, newCoord, lightVec,
tbnMatrix); tbnMatrix);
@ -265,9 +288,9 @@ void main() {
#ifdef MULTICOLORED_BLOCKLIGHT #ifdef MULTICOLORED_BLOCKLIGHT
blocklightCol = ApplyMultiColoredBlocklight(blocklightCol, screenPos); blocklightCol = ApplyMultiColoredBlocklight(blocklightCol, screenPos);
#endif #endif
vec3 shadow = vec3(0.0); vec3 shadow = vec3(0.0);
GetLighting(albedo.rgb, shadow, viewPos, worldPos, normal, lightmap, 1.0, NoL, GetLighting(albedo.rgb, shadow, viewPos, worldPos, normal, lightmap, 1.0, NoL,
vanillaDiffuse, parallaxShadow, emission, subsurface, 0.0); vanillaDiffuse, parallaxShadow, emission, subsurface, 0.0);
#ifdef ADVANCED_MATERIALS #ifdef ADVANCED_MATERIALS
@ -286,7 +309,7 @@ void main() {
#endif #endif
} }
#endif #endif
float aoSquared = ao * ao; float aoSquared = ao * ao;
shadow *= aoSquared; fresnel3 *= aoSquared; shadow *= aoSquared; fresnel3 *= aoSquared;
albedo.rgb = albedo.rgb * (1.0 - fresnel3 * smoothness * smoothness * (1.0 - metalness)); albedo.rgb = albedo.rgb * (1.0 - fresnel3 * smoothness * smoothness * (1.0 - metalness));
@ -294,7 +317,7 @@ void main() {
#if (defined OVERWORLD || defined END) && (defined ADVANCED_MATERIALS || defined SPECULAR_HIGHLIGHT_ROUGH) #if (defined OVERWORLD || defined END) && (defined ADVANCED_MATERIALS || defined SPECULAR_HIGHLIGHT_ROUGH)
vec3 specularColor = GetSpecularColor(lightmap.y, metalness, baseReflectance); vec3 specularColor = GetSpecularColor(lightmap.y, metalness, baseReflectance);
albedo.rgb += GetSpecularHighlight(newNormal, viewPos, smoothness, baseReflectance, albedo.rgb += GetSpecularHighlight(newNormal, viewPos, smoothness, baseReflectance,
specularColor, shadow * vanillaDiffuse, 1.0); specularColor, shadow * vanillaDiffuse, 1.0);
#endif #endif
@ -314,7 +337,7 @@ void main() {
#ifdef MULTICOLORED_BLOCKLIGHT #ifdef MULTICOLORED_BLOCKLIGHT
/* DRAWBUFFERS:08 */ /* DRAWBUFFERS:08 */
gl_FragData[1] = vec4(0.0,0.0,0.0,1.0); gl_FragData[1] = vec4(0.0,0.0,0.0,1.0);
#if defined TAA_SELECTIVE && !(defined ADVANCED_MATERIALS && defined REFLECTION_SPECULAR) #if defined TAA_SELECTIVE && !(defined ADVANCED_MATERIALS && defined REFLECTION_SPECULAR)
/* DRAWBUFFERS:083 */ /* DRAWBUFFERS:083 */
gl_FragData[2] = vec4(0.0, 0.0, 0.25, 1.0); gl_FragData[2] = vec4(0.0, 0.0, 0.25, 1.0);
@ -341,6 +364,8 @@ void main() {
#endif #endif
} }
#undef GBUFFERS_ENTITIES
#endif #endif
//Vertex Shader///////////////////////////////////////////////////////////////////////////////////// //Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
@ -406,7 +431,7 @@ float frametime = frameTimeCounter * ANIMATION_SPEED;
//Program// //Program//
void main() { void main() {
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy; texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
lmCoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy; lmCoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
lmCoord = clamp((lmCoord - 0.03125) * 1.06667, vec2(0.0), vec2(0.9333, 1.0)); lmCoord = clamp((lmCoord - 0.03125) * 1.06667, vec2(0.0), vec2(0.9333, 1.0));
@ -415,13 +440,13 @@ void main() {
#ifdef ADVANCED_MATERIALS #ifdef ADVANCED_MATERIALS
tangent = normalize(gl_NormalMatrix * at_tangent.xyz); tangent = normalize(gl_NormalMatrix * at_tangent.xyz);
binormal = normalize(gl_NormalMatrix * cross(at_tangent.xyz, gl_Normal.xyz) * at_tangent.w); binormal = normalize(gl_NormalMatrix * cross(at_tangent.xyz, gl_Normal.xyz) * at_tangent.w);
mat3 tbnMatrix = mat3(tangent.x, binormal.x, normal.x, mat3 tbnMatrix = mat3(tangent.x, binormal.x, normal.x,
tangent.y, binormal.y, normal.y, tangent.y, binormal.y, normal.y,
tangent.z, binormal.z, normal.z); tangent.z, binormal.z, normal.z);
viewVector = tbnMatrix * (gl_ModelViewMatrix * gl_Vertex).xyz; viewVector = tbnMatrix * (gl_ModelViewMatrix * gl_Vertex).xyz;
dist = length(gl_ModelViewMatrix * gl_Vertex); dist = length(gl_ModelViewMatrix * gl_Vertex);
vec2 midCoord = (gl_TextureMatrix[0] * mc_midTexCoord).st; vec2 midCoord = (gl_TextureMatrix[0] * mc_midTexCoord).st;
@ -432,7 +457,7 @@ void main() {
vTexCoord.xy = sign(texMinMidCoord) * 0.5 + 0.5; vTexCoord.xy = sign(texMinMidCoord) * 0.5 + 0.5;
#endif #endif
color = gl_Color; color = gl_Color;
const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994)); const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994));
@ -450,7 +475,7 @@ void main() {
#else #else
gl_Position = ftransform(); gl_Position = ftransform();
#endif #endif
#if defined TAA && !defined TAA_SELECTIVE #if defined TAA && !defined TAA_SELECTIVE
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w); gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
#endif #endif

View File

@ -18,12 +18,24 @@ varying vec3 sunVec, upVec, eastVec;
varying vec4 color; varying vec4 color;
#ifdef ADVANCED_MATERIALS #ifdef ADVANCED_MATERIALS
varying float dist; varying float dist;
varying vec3 binormal, tangent; varying vec3 binormal, tangent;
varying vec3 viewVector; varying vec3 viewVector;
varying vec4 vTexCoord, vTexCoordAM; varying vec4 vTexCoord, vTexCoordAM;
#ifdef GENERATED_NORMALS
flat varying vec2 absMidCoordPos;
varying vec2 signMidCoordPos;
vec2 mipx;
vec2 mipy;
float mipDelta;
float miplevel;
#endif
#endif #endif
//Uniforms// //Uniforms//
@ -86,18 +98,27 @@ float frametime = frameTimeCounter * ANIMATION_SPEED;
#endif #endif
#ifdef ADVANCED_MATERIALS #ifdef ADVANCED_MATERIALS
vec2 dcdx = dFdx(texCoord); vec2 dcdx = dFdx(texCoord);
vec2 dcdy = dFdy(texCoord); vec2 dcdy = dFdy(texCoord);
#ifdef GENERATED_NORMALS
mat3 tbnMatrix = mat3(
tangent.x, binormal.x, normal.x,
tangent.y, binormal.y, normal.y,
tangent.z, binormal.z, normal.z
);
vec2 midCoordPos = absMidCoordPos * signMidCoordPos;
#endif
#endif #endif
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0); vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
//Common Functions// //Common Functions//
float GetLuminance(vec3 color) {
return dot(color,vec3(0.299, 0.587, 0.114));
}
//Includes// //Includes//
#include "/lib/common.glsl"
#include "/lib/color/blocklightColor.glsl" #include "/lib/color/blocklightColor.glsl"
#include "/lib/color/dimensionColor.glsl" #include "/lib/color/dimensionColor.glsl"
#include "/lib/color/specularColor.glsl" #include "/lib/color/specularColor.glsl"

View File

@ -1,7 +1,7 @@
/* /*
BSL Shaders v8 Series by Capt Tatsu BSL Shaders v8 Series by Capt Tatsu
https://bitslablab.com https://bitslablab.com
*/ */
//Settings// //Settings//
#include "/lib/settings.glsl" #include "/lib/settings.glsl"
@ -20,12 +20,25 @@ varying vec3 sunVec, upVec, eastVec;
varying vec4 color; varying vec4 color;
#ifdef ADVANCED_MATERIALS #ifdef ADVANCED_MATERIALS
varying float dist; varying float dist;
varying vec3 binormal, tangent; varying vec3 binormal, tangent;
varying vec3 viewVector; varying vec3 viewVector;
varying vec4 vTexCoord, vTexCoordAM;
#ifdef GENERATED_NORMALS
flat varying vec2 absMidCoordPos;
varying vec2 signMidCoordPos;
vec2 mipx;
vec2 mipy;
float mipDelta;
float miplevel;
#endif
varying vec4 vTexCoord, vTexCoordAM;
#endif #endif
//Uniforms// //Uniforms//
@ -37,7 +50,7 @@ uniform int worldTime;
uniform float frameTimeCounter; uniform float frameTimeCounter;
uniform float nightVision; uniform float nightVision;
uniform float rainStrength; uniform float rainStrength;
uniform float screenBrightness; uniform float screenBrightness;
uniform float shadowFade; uniform float shadowFade;
uniform float timeAngle, timeBrightness; uniform float timeAngle, timeBrightness;
uniform float viewWidth, viewHeight; uniform float viewWidth, viewHeight;
@ -56,6 +69,7 @@ uniform sampler2D noisetex;
#ifdef ADVANCED_MATERIALS #ifdef ADVANCED_MATERIALS
uniform ivec2 atlasSize; uniform ivec2 atlasSize;
vec2 atlasSizeM = atlasSize;
uniform sampler2D specular; uniform sampler2D specular;
uniform sampler2D normals; uniform sampler2D normals;
@ -86,22 +100,31 @@ float frametime = frameTimeCounter * ANIMATION_SPEED;
#endif #endif
#ifdef ADVANCED_MATERIALS #ifdef ADVANCED_MATERIALS
vec2 dcdx = dFdx(texCoord); vec2 dcdx = dFdx(texCoord);
vec2 dcdy = dFdy(texCoord); vec2 dcdy = dFdy(texCoord);
#ifdef GENERATED_NORMALS
mat3 tbnMatrix = mat3(
tangent.x, binormal.x, normal.x,
tangent.y, binormal.y, normal.y,
tangent.z, binormal.z, normal.z
);
vec2 midCoordPos = absMidCoordPos * signMidCoordPos;
#endif
#endif #endif
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0); vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
//Common Functions// //Common Functions//
float GetLuminance(vec3 color) {
return dot(color,vec3(0.299, 0.587, 0.114));
}
float GetHandItem(int id) { float GetHandItem(int id) {
return float((heldItemId == id && isMainHand > 0.5) || (heldItemId2 == id && isMainHand < 0.5)); return float((heldItemId == id && isMainHand > 0.5) || (heldItemId2 == id && isMainHand < 0.5));
} }
//Includes// //Includes//
#include "/lib/common.glsl"
#include "/lib/color/blocklightColor.glsl" #include "/lib/color/blocklightColor.glsl"
#include "/lib/color/dimensionColor.glsl" #include "/lib/color/dimensionColor.glsl"
#include "/lib/color/specularColor.glsl" #include "/lib/color/specularColor.glsl"
@ -140,7 +163,7 @@ void main() {
vec2 newCoord = vTexCoord.st * vTexCoordAM.pq + vTexCoordAM.st; vec2 newCoord = vTexCoord.st * vTexCoordAM.pq + vTexCoordAM.st;
float surfaceDepth = 1.0; float surfaceDepth = 1.0;
float skipAdvMat = float(heldItemId == 358 || (heldItemId2 == 358 && isMainHand < 0.5)); float skipAdvMat = float(heldItemId == 358 || (heldItemId2 == 358 && isMainHand < 0.5));
#ifdef PARALLAX #ifdef PARALLAX
if (skipAdvMat < 0.5) { if (skipAdvMat < 0.5) {
newCoord = GetParallaxCoord(texCoord, 0.0, surfaceDepth); newCoord = GetParallaxCoord(texCoord, 0.0, surfaceDepth);
@ -162,12 +185,12 @@ void main() {
lightmap.x = max(lightmap.x, GetHandItem(213)); lightmap.x = max(lightmap.x, GetHandItem(213));
float emissive = (GetHandItem(50) + GetHandItem(89) + GetHandItem(213)); float emissive = (GetHandItem(50) + GetHandItem(89) + GetHandItem(213));
float metalness = 0.0; float metalness = 0.0;
float emission = emissive; float emission = emissive;
float subsurface = 0.0; float subsurface = 0.0;
vec3 baseReflectance = vec3(0.04); vec3 baseReflectance = vec3(0.04);
emission *= pow(max(max(albedo.r, albedo.g), albedo.b), 4.0) * 0.25; emission *= pow(max(max(albedo.r, albedo.g), albedo.b), 4.0) * 0.25;
vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z + 0.38); vec3 screenPos = vec3(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z + 0.38);
@ -181,14 +204,14 @@ void main() {
#ifdef ADVANCED_MATERIALS #ifdef ADVANCED_MATERIALS
float f0 = 0.0, porosity = 0.5, ao = 1.0; float f0 = 0.0, porosity = 0.5, ao = 1.0;
vec3 normalMap = vec3(0.0, 0.0, 1.0); vec3 normalMap = vec3(0.0, 0.0, 1.0);
GetMaterials(smoothness, metalness, f0, emission, subsurface, porosity, ao, normalMap, GetMaterials(smoothness, metalness, f0, emission, subsurface, porosity, ao, normalMap,
newCoord, dcdx, dcdy); newCoord, dcdx, dcdy);
#ifdef NORMAL_SKIP #ifdef NORMAL_SKIP
normalMap = vec3(0.0, 0.0, 1.0); normalMap = vec3(0.0, 0.0, 1.0);
#endif #endif
mat3 tbnMatrix = mat3(tangent.x, binormal.x, normal.x, mat3 tbnMatrix = mat3(tangent.x, binormal.x, normal.x,
tangent.y, binormal.y, normal.y, tangent.y, binormal.y, normal.y,
tangent.z, binormal.z, normal.z); tangent.z, binormal.z, normal.z);
@ -196,7 +219,7 @@ void main() {
if ((normalMap.x > -0.999 || normalMap.y > -0.999) && viewVector == viewVector) if ((normalMap.x > -0.999 || normalMap.y > -0.999) && viewVector == viewVector)
newNormal = clamp(normalize(normalMap * tbnMatrix), vec3(-1.0), vec3(1.0)); newNormal = clamp(normalize(normalMap * tbnMatrix), vec3(-1.0), vec3(1.0));
#endif #endif
#ifdef DYNAMIC_HANDLIGHT #ifdef DYNAMIC_HANDLIGHT
float heldLightValue = max(float(heldBlockLightValue), float(heldBlockLightValue2)); float heldLightValue = max(float(heldBlockLightValue), float(heldBlockLightValue2));
float handlight = clamp(heldLightValue / 15.0, 0.0, 0.9333); float handlight = clamp(heldLightValue / 15.0, 0.0, 0.9333);
@ -219,7 +242,7 @@ void main() {
albedo.rgb /= 0.7 * albedo.rgb + 0.7; albedo.rgb /= 0.7 * albedo.rgb + 0.7;
} }
#endif #endif
#ifdef MULTICOLORED_BLOCKLIGHT #ifdef MULTICOLORED_BLOCKLIGHT
lightAlbedo = albedo.rgb + 0.00001; lightAlbedo = albedo.rgb + 0.00001;
lightAlbedo = sqrt(normalize(lightAlbedo) * emission * emissive); lightAlbedo = sqrt(normalize(lightAlbedo) * emission * emissive);
@ -253,7 +276,7 @@ void main() {
#ifdef END #ifdef END
doParallax = float(NoL > 0.0); doParallax = float(NoL > 0.0);
#endif #endif
if (doParallax > 0.5 && skipAdvMat < 0.5) { if (doParallax > 0.5 && skipAdvMat < 0.5) {
parallaxShadow = GetParallaxShadow(surfaceDepth, 0.0, newCoord, lightVec, tbnMatrix); parallaxShadow = GetParallaxShadow(surfaceDepth, 0.0, newCoord, lightVec, tbnMatrix);
} }
@ -263,9 +286,9 @@ void main() {
#ifdef MULTICOLORED_BLOCKLIGHT #ifdef MULTICOLORED_BLOCKLIGHT
blocklightCol = ApplyMultiColoredBlocklight(blocklightCol, screenPos); blocklightCol = ApplyMultiColoredBlocklight(blocklightCol, screenPos);
#endif #endif
vec3 shadow = vec3(0.0); vec3 shadow = vec3(0.0);
GetLighting(albedo.rgb, shadow, viewPos, worldPos, vec3(0.0), lightmap, 1.0, NoL, GetLighting(albedo.rgb, shadow, viewPos, worldPos, vec3(0.0), lightmap, 1.0, NoL,
vanillaDiffuse, parallaxShadow, emission, subsurface, 0.0); vanillaDiffuse, parallaxShadow, emission, subsurface, 0.0);
#ifdef ADVANCED_MATERIALS #ifdef ADVANCED_MATERIALS
@ -284,7 +307,7 @@ void main() {
#endif #endif
} }
#endif #endif
float aoSquared = ao * ao; float aoSquared = ao * ao;
shadow *= aoSquared; fresnel3 *= aoSquared; shadow *= aoSquared; fresnel3 *= aoSquared;
albedo.rgb = albedo.rgb * (1.0 - fresnel3 * smoothness * smoothness * (1.0 - metalness)); albedo.rgb = albedo.rgb * (1.0 - fresnel3 * smoothness * smoothness * (1.0 - metalness));
@ -292,7 +315,7 @@ void main() {
#if (defined OVERWORLD || defined END) && (defined ADVANCED_MATERIALS || defined SPECULAR_HIGHLIGHT_ROUGH) #if (defined OVERWORLD || defined END) && (defined ADVANCED_MATERIALS || defined SPECULAR_HIGHLIGHT_ROUGH)
vec3 specularColor = GetSpecularColor(lightmap.y, metalness, baseReflectance); vec3 specularColor = GetSpecularColor(lightmap.y, metalness, baseReflectance);
albedo.rgb += GetSpecularHighlight(newNormal, viewPos, smoothness, baseReflectance, albedo.rgb += GetSpecularHighlight(newNormal, viewPos, smoothness, baseReflectance,
specularColor, shadow * vanillaDiffuse, 1.0); specularColor, shadow * vanillaDiffuse, 1.0);
#endif #endif
@ -312,7 +335,7 @@ void main() {
#ifdef MULTICOLORED_BLOCKLIGHT #ifdef MULTICOLORED_BLOCKLIGHT
/* DRAWBUFFERS:08 */ /* DRAWBUFFERS:08 */
gl_FragData[1] = vec4(lightAlbedo,1.0); gl_FragData[1] = vec4(lightAlbedo,1.0);
#if defined TAA_SELECTIVE && !(defined ADVANCED_MATERIALS && defined REFLECTION_SPECULAR) #if defined TAA_SELECTIVE && !(defined ADVANCED_MATERIALS && defined REFLECTION_SPECULAR)
/* DRAWBUFFERS:083 */ /* DRAWBUFFERS:083 */
gl_FragData[2] = vec4(0.0, 0.0, 0.25, 1.0); gl_FragData[2] = vec4(0.0, 0.0, 0.25, 1.0);
@ -408,7 +431,7 @@ float frametime = frameTimeCounter * ANIMATION_SPEED;
//Program// //Program//
void main() { void main() {
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy; texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
lmCoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy; lmCoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
lmCoord = clamp((lmCoord - 0.03125) * 1.06667, vec2(0.0), vec2(0.9333, 1.0)); lmCoord = clamp((lmCoord - 0.03125) * 1.06667, vec2(0.0), vec2(0.9333, 1.0));
@ -417,13 +440,13 @@ void main() {
#ifdef ADVANCED_MATERIALS #ifdef ADVANCED_MATERIALS
binormal = normalize(gl_NormalMatrix * cross(at_tangent.xyz, gl_Normal.xyz) * at_tangent.w); binormal = normalize(gl_NormalMatrix * cross(at_tangent.xyz, gl_Normal.xyz) * at_tangent.w);
tangent = normalize(gl_NormalMatrix * at_tangent.xyz); tangent = normalize(gl_NormalMatrix * at_tangent.xyz);
mat3 tbnMatrix = mat3(tangent.x, binormal.x, normal.x, mat3 tbnMatrix = mat3(tangent.x, binormal.x, normal.x,
tangent.y, binormal.y, normal.y, tangent.y, binormal.y, normal.y,
tangent.z, binormal.z, normal.z); tangent.z, binormal.z, normal.z);
viewVector = tbnMatrix * (gl_ModelViewMatrix * gl_Vertex).xyz; viewVector = tbnMatrix * (gl_ModelViewMatrix * gl_Vertex).xyz;
dist = length(gl_ModelViewMatrix * gl_Vertex); dist = length(gl_ModelViewMatrix * gl_Vertex);
vec2 midCoord = (gl_TextureMatrix[0] * mc_midTexCoord).st; vec2 midCoord = (gl_TextureMatrix[0] * mc_midTexCoord).st;
@ -431,10 +454,10 @@ void main() {
vTexCoordAM.pq = abs(texMinMidCoord) * 2; vTexCoordAM.pq = abs(texMinMidCoord) * 2;
vTexCoordAM.st = min(texCoord, midCoord - texMinMidCoord); vTexCoordAM.st = min(texCoord, midCoord - texMinMidCoord);
vTexCoord.xy = sign(texMinMidCoord) * 0.5 + 0.5; vTexCoord.xy = sign(texMinMidCoord) * 0.5 + 0.5;
#endif #endif
color = gl_Color; color = gl_Color;
isMainHand = float(gl_ModelViewMatrix[3][0] > 0.0); isMainHand = float(gl_ModelViewMatrix[3][0] > 0.0);
@ -454,11 +477,11 @@ void main() {
#else #else
gl_Position = ftransform(); gl_Position = ftransform();
#endif #endif
#if defined TAA && !defined TAA_SELECTIVE #if defined TAA && !defined TAA_SELECTIVE
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w); gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
#endif #endif
#if MC_VERSION >= 11500 #if MC_VERSION >= 11500
isMainHand = float(gl_Position.x > 0.0); isMainHand = float(gl_Position.x > 0.0);
#endif #endif

View File

@ -1,7 +1,7 @@
/* /*
BSL Shaders v8 Series by Capt Tatsu BSL Shaders v8 Series by Capt Tatsu
https://bitslablab.com https://bitslablab.com
*/ */
//Settings// //Settings//
#include "/lib/settings.glsl" #include "/lib/settings.glsl"
@ -74,12 +74,8 @@ vec2 moonDiffuse[8] = vec2[8](
vec2(-0.125, 1.0 ) vec2(-0.125, 1.0 )
); );
//Common Functions//
float GetLuminance(vec3 color) {
return dot(color,vec3(0.299, 0.587, 0.114));
}
//Includes// //Includes//
#include "/lib/common.glsl"
#include "/lib/color/dimensionColor.glsl" #include "/lib/color/dimensionColor.glsl"
#include "/lib/color/skyColor.glsl" #include "/lib/color/skyColor.glsl"
#include "/lib/util/dither.glsl" #include "/lib/util/dither.glsl"
@ -91,14 +87,14 @@ float GetLuminance(vec3 color) {
//Program// //Program//
void main() { void main() {
vec3 albedo = vec3(0.0); vec3 albedo = vec3(0.0);
#if defined OVERWORLD && !defined SKY_DEFERRED #if defined OVERWORLD && !defined SKY_DEFERRED
vec4 screenPos = vec4(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z, 1.0); vec4 screenPos = vec4(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z, 1.0);
vec4 viewPos = gbufferProjectionInverse * (screenPos * 2.0 - 1.0); vec4 viewPos = gbufferProjectionInverse * (screenPos * 2.0 - 1.0);
viewPos /= viewPos.w; viewPos /= viewPos.w;
albedo = GetSkyColor(viewPos.xyz, false); albedo = GetSkyColor(viewPos.xyz, false);
#ifdef ROUND_SUN_MOON #ifdef ROUND_SUN_MOON
vec3 lightMA = mix(lightMorning, lightEvening, mefade); vec3 lightMA = mix(lightMorning, lightEvening, mefade);
vec3 sunColor = mix(lightMA, sqrt(lightDay * lightMA * LIGHT_DI), timeBrightness); vec3 sunColor = mix(lightMA, sqrt(lightDay * lightMA * LIGHT_DI), timeBrightness);
@ -129,7 +125,7 @@ void main() {
albedo.rgb = albedo.rgb + dither / vec3(128.0); albedo.rgb = albedo.rgb + dither / vec3(128.0);
#endif #endif
#endif #endif
/* DRAWBUFFERS:0 */ /* DRAWBUFFERS:0 */
gl_FragData[0] = vec4(albedo, 1.0 - star); gl_FragData[0] = vec4(albedo, 1.0 - star);
} }
@ -157,7 +153,7 @@ void main() {
sunVec = normalize((gbufferModelView * vec4(vec3(-sin(ang), cos(ang) * sunRotationData) * 2000.0, 1.0)).xyz); sunVec = normalize((gbufferModelView * vec4(vec3(-sin(ang), cos(ang) * sunRotationData) * 2000.0, 1.0)).xyz);
upVec = normalize(gbufferModelView[1].xyz); upVec = normalize(gbufferModelView[1].xyz);
gl_Position = ftransform(); gl_Position = ftransform();
star = float(gl_Color.r == gl_Color.g && gl_Color.g == gl_Color.b && gl_Color.r > 0.0); star = float(gl_Color.r == gl_Color.g && gl_Color.g == gl_Color.b && gl_Color.r > 0.0);

View File

@ -1,7 +1,7 @@
/* /*
BSL Shaders v8 Series by Capt Tatsu BSL Shaders v8 Series by Capt Tatsu
https://bitslablab.com https://bitslablab.com
*/ */
//Settings// //Settings//
#include "/lib/settings.glsl" #include "/lib/settings.glsl"
@ -52,11 +52,9 @@ float sunVisibility = clamp((dot( sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
float moonVisibility = clamp((dot(-sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0); float moonVisibility = clamp((dot(-sunVec, upVec) + 0.05) * 10.0, 0.0, 1.0);
//Common Functions// //Common Functions//
float GetLuminance(vec3 color) {
return dot(color,vec3(0.299, 0.587, 0.114));
}
//Includes// //Includes//
#include "/lib/common.glsl"
#include "/lib/color/dimensionColor.glsl" #include "/lib/color/dimensionColor.glsl"
#include "/lib/util/dither.glsl" #include "/lib/util/dither.glsl"
@ -72,7 +70,7 @@ void main() {
vec4 screenPos = vec4(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z, 1.0); vec4 screenPos = vec4(gl_FragCoord.xy / vec2(viewWidth, viewHeight), gl_FragCoord.z, 1.0);
vec4 viewPos = gbufferProjectionInverse * (screenPos * 2.0 - 1.0); vec4 viewPos = gbufferProjectionInverse * (screenPos * 2.0 - 1.0);
viewPos /= viewPos.w; viewPos /= viewPos.w;
float VoU = dot(normalize(viewPos.xyz), upVec); float VoU = dot(normalize(viewPos.xyz), upVec);
float sunFade = smoothstep(0.0, 1.0, 1.0 - pow(1.0 - max(VoU * 0.975 + 0.025, 0.0), 8.0)); float sunFade = smoothstep(0.0, 1.0, 1.0 - pow(1.0 - max(VoU * 0.975 + 0.025, 0.0), 8.0));
@ -88,17 +86,17 @@ void main() {
if (renderStage == MC_RENDER_STAGE_MOON) { if (renderStage == MC_RENDER_STAGE_MOON) {
albedo.rgb *= MOON_INTENSITY * MOON_INTENSITY * sunFade; albedo.rgb *= MOON_INTENSITY * MOON_INTENSITY * sunFade;
} }
#else #else
albedo.rgb *= SKYBOX_INTENSITY * SKYBOX_INTENSITY; albedo.rgb *= SKYBOX_INTENSITY * SKYBOX_INTENSITY;
albedo.a *= SKYBOX_OPACITY; albedo.a *= SKYBOX_OPACITY;
#endif #endif
#ifdef ROUND_SUN_MOON #ifdef ROUND_SUN_MOON
if (renderStage == MC_RENDER_STAGE_SUN || renderStage == MC_RENDER_STAGE_MOON) { if (renderStage == MC_RENDER_STAGE_SUN || renderStage == MC_RENDER_STAGE_MOON) {
albedo *= 0.0; albedo *= 0.0;
} }
#endif #endif
#ifdef SKY_DESATURATION #ifdef SKY_DESATURATION
vec3 desat = GetLuminance(albedo.rgb) * pow(lightNight, vec3(1.6)) * 4.0; vec3 desat = GetLuminance(albedo.rgb) * pow(lightNight, vec3(1.6)) * 4.0;
albedo.rgb = mix(desat, albedo.rgb, sunVisibility); albedo.rgb = mix(desat, albedo.rgb, sunVisibility);
@ -122,7 +120,7 @@ void main() {
#if ALPHA_BLEND == 0 #if ALPHA_BLEND == 0
albedo.rgb = sqrt(max(albedo.rgb, vec3(0.0))); albedo.rgb = sqrt(max(albedo.rgb, vec3(0.0)));
#endif #endif
/* DRAWBUFFERS:0 */ /* DRAWBUFFERS:0 */
gl_FragData[0] = albedo; gl_FragData[0] = albedo;
} }
@ -157,16 +155,16 @@ void main() {
texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy; texCoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
color = gl_Color; color = gl_Color;
const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994)); const vec2 sunRotationData = vec2(cos(sunPathRotation * 0.01745329251994), -sin(sunPathRotation * 0.01745329251994));
float ang = fract(timeAngle - 0.25); float ang = fract(timeAngle - 0.25);
ang = (ang + (cos(ang * 3.14159265358979) * -0.5 + 0.5 - ang) / 3.0) * 6.28318530717959; ang = (ang + (cos(ang * 3.14159265358979) * -0.5 + 0.5 - ang) / 3.0) * 6.28318530717959;
sunVec = normalize((gbufferModelView * vec4(vec3(-sin(ang), cos(ang) * sunRotationData) * 2000.0, 1.0)).xyz); sunVec = normalize((gbufferModelView * vec4(vec3(-sin(ang), cos(ang) * sunRotationData) * 2000.0, 1.0)).xyz);
upVec = normalize(gbufferModelView[1].xyz); upVec = normalize(gbufferModelView[1].xyz);
gl_Position = ftransform(); gl_Position = ftransform();
#ifdef TAA #ifdef TAA
gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w); gl_Position.xy = TAAJitter(gl_Position.xy, gl_Position.w);
#endif #endif

View File

@ -21,7 +21,7 @@ varying vec4 color;
varying vec4 glColor; varying vec4 glColor;
#if defined ADVANCED_MATERIALS || defined GENERATED_NORMALS #if defined ADVANCED_MATERIALS
varying float dist; varying float dist;
varying vec3 binormal, tangent; varying vec3 binormal, tangent;
@ -30,8 +30,17 @@ varying vec4 glColor;
varying vec4 vTexCoord, vTexCoordAM; varying vec4 vTexCoord, vTexCoordAM;
flat varying vec2 absMidCoordPos; #ifdef GENERATED_NORMALS
varying vec2 signMidCoordPos;
flat varying vec2 absMidCoordPos;
varying vec2 signMidCoordPos;
vec2 mipx;
vec2 mipy;
float mipDelta;
float miplevel;
#endif
#endif #endif
@ -104,128 +113,32 @@ float frametime = float(worldTime) * 0.05 * ANIMATION_SPEED;
float frametime = frameTimeCounter * ANIMATION_SPEED; float frametime = frameTimeCounter * ANIMATION_SPEED;
#endif #endif
vec4 debugNormals; #if defined ADVANCED_MATERIALS
vec2 mipx;
vec2 mipy;
float mipDelta;
float miplevel;
#if defined ADVANCED_MATERIALS || defined GENERATED_NORMALS
vec2 dcdx = dFdx(texCoord); vec2 dcdx = dFdx(texCoord);
vec2 dcdy = dFdy(texCoord); vec2 dcdy = dFdy(texCoord);
#if defined GENERATED_NORMALS
mat3 tbnMatrix = mat3(
tangent.x, binormal.x, normal.x,
tangent.y, binormal.y, normal.y,
tangent.z, binormal.z, normal.z
);
vec2 midCoordPos = absMidCoordPos * signMidCoordPos;
#endif
#endif #endif
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0); vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
#if defined GENERATED_NORMALS
mat3 tbnMatrix = mat3(
tangent.x, binormal.x, normal.x,
tangent.y, binormal.y, normal.y,
tangent.z, binormal.z, normal.z
);
vec2 midCoordPos = absMidCoordPos * signMidCoordPos; // common functions
#endif
//Common Functions//
float GetLuminance(vec3 color) {
return dot(color,vec3(0.299, 0.587, 0.114));
}
float max0(float x) {
return max(x, 0.0);
}
float min1(float x) {
return min(x, 1.0);
}
float pow2(float x) {
return x * x;
}
vec2 pow2(vec2 x) {
return x * x;
}
vec3 pow2(vec3 x) {
return x * x;
}
float pow1_5(float x) { // Faster pow(x, 1.5) approximation (that isn't accurate at all) if x is between 0 and 1
return x - x * pow2(1.0 - x); // Thanks to SixthSurge
}
vec2 pow1_5(vec2 x) {
return x - x * pow2(1.0 - x);
}
vec3 pow1_5(vec3 x) {
return x - x * pow2(1.0 - x);
}
bool CheckForColor(vec3 albedo, vec3 check) { // Thanks to Builderb0y
vec3 dif = albedo - check * 0.003921568;
return dif == clamp(dif, vec3(-0.001), vec3(0.001));
}
float GetMaxColorDif(vec3 color) {
vec3 dif = abs(vec3(color.r - color.g, color.g - color.b, color.r - color.b));
return max(dif.r, max(dif.g, dif.b));
}
float smoothstep1(float x) {
return x * x * (3.0 - 2.0 * x);
}
vec2 smoothstep1(vec2 x) {
return x * x * (3.0 - 2.0 * x);
}
vec3 smoothstep1(vec3 x) {
return x * x * (3.0 - 2.0 * x);
}
float sqrt1(float x) { // Faster sqrt() approximation (that isn't accurate at all) if x is between 0 and 1
return x * (2.0 - x); // Thanks to Builderb0y
}
vec2 sqrt1(vec2 x) {
return x * (2.0 - x);
}
vec3 sqrt1(vec3 x) {
return x * (2.0 - x);
}
vec4 sqrt1(vec4 x) {
return x * (2.0 - x);
}
vec3 ViewToPlayer(vec3 pos) { vec3 ViewToPlayer(vec3 pos) {
return mat3(gbufferModelViewInverse) * pos + gbufferModelViewInverse[3].xyz; return mat3(gbufferModelViewInverse) * pos + gbufferModelViewInverse[3].xyz;
} }
float sqrt3(float x) {
x = 1.0 - x;
x *= x;
x *= x;
x *= x;
return 1.0 - x;
}
vec2 sqrt3(vec2 x) {
x = 1.0 - x;
x *= x;
x *= x;
x *= x;
return 1.0 - x;
}
vec3 sqrt3(vec3 x) {
x = 1.0 - x;
x *= x;
x *= x;
x *= x;
return 1.0 - x;
}
vec4 sqrt3(vec4 x) {
x = 1.0 - x;
x *= x;
x *= x;
x *= x;
return 1.0 - x;
}
//Includes// //Includes//
#include "/lib/common.glsl"
#include "/lib/color/blocklightColor.glsl" #include "/lib/color/blocklightColor.glsl"
#include "/lib/color/dimensionColor.glsl" #include "/lib/color/dimensionColor.glsl"
#include "/lib/color/specularColor.glsl" #include "/lib/color/specularColor.glsl"
@ -237,17 +150,13 @@ vec4 sqrt3(vec4 x) {
#include "/lib/util/jitter.glsl" #include "/lib/util/jitter.glsl"
#endif #endif
#if defined ADVANCED_MATERIALS || defined GENERATED_NORMALS #if defined ADVANCED_MATERIALS
#include "/lib/util/encode.glsl" #include "/lib/util/encode.glsl"
#include "/lib/reflections/complexFresnel.glsl" #include "/lib/reflections/complexFresnel.glsl"
#include "/lib/surface/directionalLightmap.glsl" #include "/lib/surface/directionalLightmap.glsl"
#include "/lib/surface/materialGbuffers.glsl" #include "/lib/surface/materialGbuffers.glsl"
#include "/lib/surface/parallax.glsl" #include "/lib/surface/parallax.glsl"
#ifdef GENERATED_NORMALS
#include "/lib/surface/generatedNormals.glsl"
#endif
#ifdef REFLECTION_RAIN #ifdef REFLECTION_RAIN
#include "/lib/reflections/rainPuddles.glsl" #include "/lib/reflections/rainPuddles.glsl"
#endif #endif
@ -335,7 +244,6 @@ void main() {
// #include "/lib/materials/materialHandling/terrainMaterials.glsl" // #include "/lib/materials/materialHandling/terrainMaterials.glsl"
GenerateNormals(newNormal, albedo.rgb); GenerateNormals(newNormal, albedo.rgb);
#endif #endif
debugNormals = vec4(newNormal , 1.0);
#ifdef DYNAMIC_HANDLIGHT #ifdef DYNAMIC_HANDLIGHT

View File

@ -78,9 +78,6 @@ float frametime = frameTimeCounter * ANIMATION_SPEED;
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0); vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
//Common Functions// //Common Functions//
float GetLuminance(vec3 color) {
return dot(color,vec3(0.299, 0.587, 0.114));
}
#ifdef SOFT_PARTICLES #ifdef SOFT_PARTICLES
float GetLinearDepth(float depth) { float GetLinearDepth(float depth) {
@ -89,6 +86,7 @@ float GetLinearDepth(float depth) {
#endif #endif
//Includes// //Includes//
#include "/lib/common.glsl"
#include "/lib/color/blocklightColor.glsl" #include "/lib/color/blocklightColor.glsl"
#include "/lib/color/dimensionColor.glsl" #include "/lib/color/dimensionColor.glsl"
#include "/lib/color/skyColor.glsl" #include "/lib/color/skyColor.glsl"

View File

@ -9,6 +9,8 @@ https://bitslablab.com
//Fragment Shader/////////////////////////////////////////////////////////////////////////////////// //Fragment Shader///////////////////////////////////////////////////////////////////////////////////
#ifdef FSH #ifdef FSH
#define GBUFFERS_WATER
//Varyings// //Varyings//
varying float mat; varying float mat;
varying float dist; varying float dist;
@ -22,7 +24,19 @@ varying vec3 viewVector;
varying vec4 color; varying vec4 color;
#ifdef ADVANCED_MATERIALS #ifdef ADVANCED_MATERIALS
varying vec4 vTexCoord, vTexCoordAM; varying vec4 vTexCoord, vTexCoordAM;
#ifdef GENERATED_NORMALS
flat varying vec2 absMidCoordPos;
varying vec2 signMidCoordPos;
vec2 mipx;
vec2 mipy;
float mipDelta;
float miplevel;
#endif
#endif #endif
//Uniforms// //Uniforms//
@ -56,6 +70,7 @@ uniform sampler2D noisetex;
#ifdef ADVANCED_MATERIALS #ifdef ADVANCED_MATERIALS
uniform ivec2 atlasSize; uniform ivec2 atlasSize;
vec2 atlasSizeM = atlasSize;
uniform sampler2D specular; uniform sampler2D specular;
uniform sampler2D normals; uniform sampler2D normals;
@ -95,16 +110,24 @@ float frametime = frameTimeCounter * ANIMATION_SPEED;
#endif #endif
#ifdef ADVANCED_MATERIALS #ifdef ADVANCED_MATERIALS
vec2 dcdx = dFdx(texCoord); vec2 dcdx = dFdx(texCoord);
vec2 dcdy = dFdy(texCoord); vec2 dcdy = dFdy(texCoord);
#ifdef GENERATED_NORMALS
mat3 tbnMatrix = mat3(
tangent.x, binormal.x, normal.x,
tangent.y, binormal.y, normal.y,
tangent.z, binormal.z, normal.z
);
vec2 midCoordPos = absMidCoordPos * signMidCoordPos;
#endif
#endif #endif
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0); vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
//Common Functions// //Common Functions//
float GetLuminance(vec3 color) {
return dot(color,vec3(0.299, 0.587, 0.114));
}
float GetWaterHeightMap(vec3 worldPos, vec2 offset) { float GetWaterHeightMap(vec3 worldPos, vec2 offset) {
float noise = 0.0; float noise = 0.0;
@ -170,6 +193,7 @@ vec3 GetWaterNormal(vec3 worldPos, vec3 viewPos, vec3 viewVector) {
} }
//Includes// //Includes//
#include "/lib/common.glsl"
#include "/lib/color/blocklightColor.glsl" #include "/lib/color/blocklightColor.glsl"
#include "/lib/color/dimensionColor.glsl" #include "/lib/color/dimensionColor.glsl"
#include "/lib/color/skyColor.glsl" #include "/lib/color/skyColor.glsl"
@ -630,6 +654,8 @@ void main() {
#endif #endif
} }
#undef GBUFFERS_WATER
#endif #endif
//Vertex Shader///////////////////////////////////////////////////////////////////////////////////// //Vertex Shader/////////////////////////////////////////////////////////////////////////////////////

View File

@ -24,17 +24,16 @@ screen.LIGHTING=<empty> <empty> SHADOW [SHADOW_CONFIG] shadowMapResolution shado
screen.SHADOW_CONFIG=<empty> <empty> SHADOW_ENTITY SHADOW_BLOCK_ENTITY SHADOW_VEGETATION SHADOW_CLOUD sunPathRotation SHADOW_BIAS SHADOW_PIXEL screen.SHADOW_CONFIG=<empty> <empty> SHADOW_ENTITY SHADOW_BLOCK_ENTITY SHADOW_VEGETATION SHADOW_CLOUD sunPathRotation SHADOW_BIAS SHADOW_PIXEL
screen.MCBL=<empty> <empty> MCBL_ANTI_BLEED MCBL_LEGACY_COLOR screen.MCBL=<empty> <empty> MCBL_ANTI_BLEED MCBL_LEGACY_COLOR
screen.MATERIAL=<empty> <empty> ADVANCED_MATERIALS MATERIAL_FORMAT <empty> <empty> [SPECULAR] [NORMALS] <empty> <empty> SSS BASIC_SSS EMISSIVE REFRACTION ALBEDO_BALANCING ALPHA_BLEND ENTITY_FLASH screen.MATERIAL=<empty> <empty> ADVANCED_MATERIALS MATERIAL_FORMAT <empty> [INTEGRATED] [SPECULAR] [NORMALS] <empty> <empty> SSS BASIC_SSS EMISSIVE REFRACTION ALBEDO_BALANCING ALPHA_BLEND ENTITY_FLASH
screen.SPECULAR=<empty> <empty> REFLECTION REFLECTION_TRANSLUCENT <empty> <empty> REFLECTION_SPECULAR REFLECTION_ROUGH REFLECTION_RAIN REFLECTION_RAIN_AMOUNT REFLECTION_PREVIOUS SPECULAR_HIGHLIGHT_ROUGH ALBEDO_METAL REFLECTION_MODE REFLECTION_SKY_FALLOFF REFLECTION_SKYBOX screen.SPECULAR=<empty> <empty> REFLECTION REFLECTION_TRANSLUCENT <empty> <empty> REFLECTION_SPECULAR REFLECTION_ROUGH REFLECTION_RAIN REFLECTION_RAIN_AMOUNT REFLECTION_PREVIOUS SPECULAR_HIGHLIGHT_ROUGH ALBEDO_METAL REFLECTION_MODE REFLECTION_SKY_FALLOFF REFLECTION_SKYBOX
screen.NORMALS=<empty> <empty> PARALLAX PARALLAX_DEPTH PARALLAX_QUALITY PARALLAX_DISTANCE SELF_SHADOW SELF_SHADOW_ANGLE SELF_SHADOW_QUALITY SELF_SHADOW_STRENGTH GENERATED_NORMALS [GENERATED_NORMAL_SETTINGS] <empty> <empty> DIRECTIONAL_LIGHTMAP DIRECTIONAL_LIGHTMAP_STRENGTH NORMAL_DAMPENING NORMAL_PLANTS screen.NORMALS=<empty> <empty> PARALLAX PARALLAX_DEPTH PARALLAX_QUALITY PARALLAX_DISTANCE SELF_SHADOW SELF_SHADOW_ANGLE SELF_SHADOW_QUALITY SELF_SHADOW_STRENGTH <empty> <empty> DIRECTIONAL_LIGHTMAP DIRECTIONAL_LIGHTMAP_STRENGTH NORMAL_DAMPENING NORMAL_PLANTS
screen.INTEGRATED=<empty> <empty> GENERATED_NORMALS GENERATED_NORMAL_MULT GENERATED_NORMAL_THRESHOLD GENERATED_NORMAL_CLAMP GENERATED_NORMAL_RESOLUTION <empty> INTEGRATED_SPECULAR
screen.GENERATED_NORMAL_SETTINGS=<empty> <empty> GENERATED_NORMAL_MULT GENERATED_NORMAL_THRESHOLD GENERATED_NORMAL_CLAMP GENERATED_NORMAL_RESOLUTION
screen.ATMOSPHERICS=<empty> <empty> [CLOUDS] [FOG] [SKY] [SKYBOX] <empty> <empty> LIGHT_SHAFT LIGHT_SHAFT_STRENGTH WEATHER_PERBIOME WEATHER_OPACITY screen.ATMOSPHERICS=<empty> <empty> [CLOUDS] [FOG] [SKY] [SKYBOX] <empty> <empty> LIGHT_SHAFT LIGHT_SHAFT_STRENGTH WEATHER_PERBIOME WEATHER_OPACITY
screen.SKY=<empty> <empty> SKY_DENSITY_D SKY_EXPOSURE_D SKY_DENSITY_N SKY_EXPOSURE_N SKY_DENSITY_W SKY_EXPOSURE_W SKY_HORIZON_N SKY_HORIZON_F <empty> <empty> SKY_DESATURATION SKY_GROUND UNDERGROUND_SKY SHADER_END_SKY SKY_DEFERRED screen.SKY=<empty> <empty> SKY_DENSITY_D SKY_EXPOSURE_D SKY_DENSITY_N SKY_EXPOSURE_N SKY_DENSITY_W SKY_EXPOSURE_W SKY_HORIZON_N SKY_HORIZON_F <empty> <empty> SKY_DESATURATION SKY_GROUND UNDERGROUND_SKY SHADER_END_SKY SKY_DEFERRED
screen.CLOUDS=<empty> <empty> CLOUDS CLOUD_BASE <empty> <empty> CLOUD_DENSITY CLOUD_AMOUNT CLOUD_HEIGHT CLOUD_THICKNESS CLOUD_DETAIL CLOUD_SPEED CLOUD_OPACITY CLOUD_BRIGHTNESS CLOUD_VOLUMETRIC_SCALE screen.CLOUDS=<empty> <empty> CLOUDS CLOUD_BASE <empty> <empty> CLOUD_DENSITY CLOUD_AMOUNT CLOUD_HEIGHT CLOUD_THICKNESS CLOUD_DETAIL CLOUD_SPEED CLOUD_OPACITY CLOUD_BRIGHTNESS CLOUD_VOLUMETRIC_SCALE
screen.FOG=<empty> <empty> FOG_DENSITY [FOG_DENSITY] FOG_HEIGHT [FOG_HEIGHT] FAR_VANILLA_FOG [FOG_VANILLA] screen.FOG=<empty> <empty> FOG_DENSITY [FOG_DENSITY] FOG_HEIGHT [FOG_HEIGHT] FAR_VANILLA_FOG [FOG_VANILLA]
screen.FOG_DENSITY=<empty> <empty> FOG_DENSITY_NIGHT FOG_DENSITY_WEATHER FOG_DENSITY_COLD FOG_DENSITY_DRY FOG_DENSITY_DAMP FOG_DENSITY_INDOOR FOG_DENSITY_DH screen.FOG_DENSITY=<empty> <empty> FOG_DENSITY_NIGHT FOG_DENSITY_WEATHER FOG_DENSITY_COLD FOG_DENSITY_DRY FOG_DENSITY_DAMP FOG_DENSITY_INDOOR FOG_DENSITY_DH
screen.FOG_HEIGHT=<empty> <empty> FOG_HEIGHT_Y FOG_HEIGHT_FALLOFF screen.FOG_HEIGHT=<empty> <empty> FOG_HEIGHT_Y FOG_HEIGHT_FALLOFF
screen.FOG_VANILLA=<empty> <empty> FAR_VANILLA_FOG_STYLE FOG_DENSITY_VANILLA FOG_VANILLA_CLOUD screen.FOG_VANILLA=<empty> <empty> FAR_VANILLA_FOG_STYLE FOG_DENSITY_VANILLA FOG_VANILLA_CLOUD
screen.SKYBOX=<empty> <empty> ROUND_SUN_MOON ROUND_SUN_MOON_SIZE STARS AURORA <empty> <empty> SKYBOX_INTENSITY SKYBOX_OPACITY SUN_INTENSITY MOON_INTENSITY screen.SKYBOX=<empty> <empty> ROUND_SUN_MOON ROUND_SUN_MOON_SIZE STARS AURORA <empty> <empty> SKYBOX_INTENSITY SKYBOX_OPACITY SUN_INTENSITY MOON_INTENSITY