Better Organized Generated Normal stuff
This commit is contained in:
parent
0f859671ea
commit
16d5613af1
@ -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.
|
||||||
|
109
shaders/lib/common.glsl
Normal file
109
shaders/lib/common.glsl
Normal 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));
|
||||||
|
}
|
@ -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) {
|
||||||
|
@ -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
|
||||||
|
@ -16,3 +16,5 @@ void GetMaterials(out float smoothness, out float skyOcclusion, out vec3 normal,
|
|||||||
|
|
||||||
fresnel3 = texture2D(colortex7, coord).rgb * smoothness;
|
fresnel3 = texture2D(colortex7, coord).rgb * smoothness;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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)
|
||||||
@ -128,3 +152,4 @@ void GetMaterials(out float smoothness, out float metalness, out float f0, inout
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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) { //
|
|
||||||
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
697
shaders/lib/surface/materialHandling/material.glsl
Normal file
697
shaders/lib/surface/materialHandling/material.glsl
Normal 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
|
@ -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));
|
|
||||||
}
|
|
@ -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"
|
||||||
|
@ -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
|
||||||
|
@ -78,9 +78,6 @@ 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;
|
||||||
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
#ifdef GENERATED_NORMALS
|
||||||
|
|
||||||
flat varying vec2 absMidCoordPos;
|
flat varying vec2 absMidCoordPos;
|
||||||
varying vec2 signMidCoordPos;
|
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,19 +97,11 @@ 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;
|
|
||||||
float mipDelta;
|
|
||||||
float miplevel;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
|
|
||||||
|
|
||||||
#if defined GENERATED_NORMALS
|
|
||||||
mat3 tbnMatrix = mat3(
|
mat3 tbnMatrix = mat3(
|
||||||
tangent.x, binormal.x, normal.x,
|
tangent.x, binormal.x, normal.x,
|
||||||
tangent.y, binormal.y, normal.y,
|
tangent.y, binormal.y, normal.y,
|
||||||
@ -110,14 +109,16 @@ vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.
|
|||||||
);
|
);
|
||||||
|
|
||||||
vec2 midCoordPos = absMidCoordPos * signMidCoordPos;
|
vec2 midCoordPos = absMidCoordPos * signMidCoordPos;
|
||||||
|
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Common Functions//
|
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
|
||||||
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,9 +205,6 @@ 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
|
|
||||||
#include "/lib/surface/materialHandling/blockEntityMaterials.glsl"
|
|
||||||
#else
|
|
||||||
GetMaterials(smoothness, metalness, f0, emission, subsurface, porosity, ao, normalMap,
|
GetMaterials(smoothness, metalness, f0, emission, subsurface, porosity, ao, normalMap,
|
||||||
newCoord, dcdx, dcdy);
|
newCoord, dcdx, dcdy);
|
||||||
#endif
|
#endif
|
||||||
@ -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
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
|
||||||
@ -24,6 +26,19 @@ 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//
|
||||||
@ -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;
|
||||||
@ -88,16 +104,23 @@ float frametime = frameTimeCounter * ANIMATION_SPEED;
|
|||||||
#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"
|
||||||
@ -341,6 +364,8 @@ void main() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef GBUFFERS_ENTITIES
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
|
//Vertex Shader/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -24,6 +24,18 @@ 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//
|
||||||
@ -88,16 +100,25 @@ float frametime = frameTimeCounter * ANIMATION_SPEED;
|
|||||||
#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"
|
||||||
|
@ -26,6 +26,19 @@ 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//
|
||||||
@ -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;
|
||||||
@ -88,20 +102,29 @@ float frametime = frameTimeCounter * ANIMATION_SPEED;
|
|||||||
#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"
|
||||||
|
@ -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"
|
||||||
|
@ -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"
|
||||||
|
|
||||||
|
@ -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,9 +30,18 @@ varying vec4 glColor;
|
|||||||
|
|
||||||
varying vec4 vTexCoord, vTexCoordAM;
|
varying vec4 vTexCoord, vTexCoordAM;
|
||||||
|
|
||||||
|
#ifdef GENERATED_NORMALS
|
||||||
|
|
||||||
flat varying vec2 absMidCoordPos;
|
flat varying vec2 absMidCoordPos;
|
||||||
varying vec2 signMidCoordPos;
|
varying vec2 signMidCoordPos;
|
||||||
|
|
||||||
|
vec2 mipx;
|
||||||
|
vec2 mipy;
|
||||||
|
float mipDelta;
|
||||||
|
float miplevel;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Uniforms//
|
//Uniforms//
|
||||||
@ -104,19 +113,9 @@ 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);
|
||||||
#endif
|
|
||||||
|
|
||||||
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
|
|
||||||
|
|
||||||
#if defined GENERATED_NORMALS
|
#if defined GENERATED_NORMALS
|
||||||
mat3 tbnMatrix = mat3(
|
mat3 tbnMatrix = mat3(
|
||||||
@ -126,106 +125,20 @@ vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.
|
|||||||
);
|
);
|
||||||
|
|
||||||
vec2 midCoordPos = absMidCoordPos * signMidCoordPos;
|
vec2 midCoordPos = absMidCoordPos * signMidCoordPos;
|
||||||
|
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Common Functions//
|
vec3 lightVec = sunVec * ((timeAngle < 0.5325 || timeAngle > 0.9675) ? 1.0 : -1.0);
|
||||||
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) {
|
// common functions
|
||||||
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
|
||||||
|
@ -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"
|
||||||
|
@ -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;
|
||||||
@ -23,6 +25,18 @@ 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;
|
||||||
@ -97,14 +112,22 @@ float frametime = frameTimeCounter * ANIMATION_SPEED;
|
|||||||
#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/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -24,11 +24,10 @@ 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
|
||||||
|
Loading…
Reference in New Issue
Block a user