This commit is contained in:
lucasdpt
2026-06-14 02:07:47 +02:00
parent 398e1e6ddf
commit 0129d81bd4
2475 changed files with 553889 additions and 553884 deletions
@@ -1,48 +1,48 @@
void ColorCodeProgram(inout vec4 color, int mat) {
// Hold spider eyes in both hands to disable the function
if (heldItemId == 40000 && heldItemId2 == 40000) return;
#if defined GBUFFERS_TERRAIN // Green
color.rgb = vec3(0.0, 1.0, 0.0);
#elif defined GBUFFERS_WATER // Dark Blue
color.rgb = vec3(0.0, 0.0, 1.0);
#elif defined GBUFFERS_SKYBASIC // Light Blue
color.rgb = vec3(0.0, 1.0, 2.0);
#elif defined GBUFFERS_WEATHER // Magenta
color.rgb = vec3(3.0, 0.0, 3.0);
#elif defined GBUFFERS_BLOCK // Yellow
color.rgb = vec3(1.5, 1.5, 0.0);
#elif defined GBUFFERS_HAND // Orange
color.rgb = vec3(1.5, 0.7, 0.0);
#elif defined GBUFFERS_ENTITIES // Red
color.rgb = vec3(1.5, 0.0, 0.0);
#elif defined GBUFFERS_BASIC // White
color.rgb = vec3(3.0, 3.0, 3.0);
#elif defined GBUFFERS_SPIDEREYES // Red-Blue Vertical Stripes
color.rgb = mix(vec3(2.0, 0.0, 0.0), vec3(0.0, 0.0, 2.0), mod(gl_FragCoord.x, 20.0) / 20.0);
#elif defined GBUFFERS_TEXTURED // Red-Blue Horizontal Stripes
color.rgb = mix(vec3(2.0, 0.0, 0.0), vec3(0.0, 0.0, 2.0), mod(gl_FragCoord.y, 20.0) / 20.0);
#elif defined GBUFFERS_CLOUDS // Red-Green Vertical Stripes
color.rgb = mix(vec3(2.0, 0.0, 0.0), vec3(0.0, 2.0, 0.0), mod(gl_FragCoord.x, 20.0) / 20.0);
#elif defined GBUFFERS_BEACONBEAM // Red-Green Horizontal Stripes
color.rgb = mix(vec3(2.0, 0.0, 0.0), vec3(0.0, 2.0, 0.0), mod(gl_FragCoord.y, 20.0) / 20.0);
#elif defined GBUFFERS_ARMOR_GLINT // Black-White Vertical Stripes
color.rgb = mix(vec3(0.0, 0.0, 0.0), vec3(1.5, 1.5, 1.5), mod(gl_FragCoord.x, 20.0) / 20.0);
#elif defined GBUFFERS_DAMAGEDBLOCK // Black-White Horizontal Stripes
color.rgb = mix(vec3(0.0, 0.0, 0.0), vec3(1.5, 1.5, 1.5), mod(gl_FragCoord.y, 20.0) / 20.0);
#elif defined GBUFFERS_SKYTEXTURED // Green-Blue Horizontal Stripes
color.rgb = mix(vec3(0.0, 2.0, 0.0), vec3(0.0, 0.0, 2.0), mod(gl_FragCoord.y, 20.0) / 20.0);
#elif defined GBUFFERS_LIGHTNING // Yellow-Blue Horizontal Stripes
color.rgb = mix(vec3(2.0, 2.0, 0.0), vec3(0.0, 0.0, 2.0), mod(gl_FragCoord.y, 20.0) / 20.0);
#endif
color.rgb *= 0.75;
// Hold spider eye in one hand to switch to ID=0 check mode
if (heldItemId == 40000 || heldItemId2 == 40000) {
if (mat == 0) // Magenta-Black Horizontal Stripes
color.rgb = mix(vec3(0.0, 0.0, 0.0), vec3(3.0, 0.0, 3.0), mod(gl_FragCoord.y, 20.0) / 20.0);
else
color.rgb = vec3(0.25);
}
}
void ColorCodeProgram(inout vec4 color, int mat) {
// Hold spider eyes in both hands to disable the function
if (heldItemId == 40000 && heldItemId2 == 40000) return;
#if defined GBUFFERS_TERRAIN // Green
color.rgb = vec3(0.0, 1.0, 0.0);
#elif defined GBUFFERS_WATER // Dark Blue
color.rgb = vec3(0.0, 0.0, 1.0);
#elif defined GBUFFERS_SKYBASIC // Light Blue
color.rgb = vec3(0.0, 1.0, 2.0);
#elif defined GBUFFERS_WEATHER // Magenta
color.rgb = vec3(3.0, 0.0, 3.0);
#elif defined GBUFFERS_BLOCK // Yellow
color.rgb = vec3(1.5, 1.5, 0.0);
#elif defined GBUFFERS_HAND // Orange
color.rgb = vec3(1.5, 0.7, 0.0);
#elif defined GBUFFERS_ENTITIES // Red
color.rgb = vec3(1.5, 0.0, 0.0);
#elif defined GBUFFERS_BASIC // White
color.rgb = vec3(3.0, 3.0, 3.0);
#elif defined GBUFFERS_SPIDEREYES // Red-Blue Vertical Stripes
color.rgb = mix(vec3(2.0, 0.0, 0.0), vec3(0.0, 0.0, 2.0), mod(gl_FragCoord.x, 20.0) / 20.0);
#elif defined GBUFFERS_TEXTURED // Red-Blue Horizontal Stripes
color.rgb = mix(vec3(2.0, 0.0, 0.0), vec3(0.0, 0.0, 2.0), mod(gl_FragCoord.y, 20.0) / 20.0);
#elif defined GBUFFERS_CLOUDS // Red-Green Vertical Stripes
color.rgb = mix(vec3(2.0, 0.0, 0.0), vec3(0.0, 2.0, 0.0), mod(gl_FragCoord.x, 20.0) / 20.0);
#elif defined GBUFFERS_BEACONBEAM // Red-Green Horizontal Stripes
color.rgb = mix(vec3(2.0, 0.0, 0.0), vec3(0.0, 2.0, 0.0), mod(gl_FragCoord.y, 20.0) / 20.0);
#elif defined GBUFFERS_ARMOR_GLINT // Black-White Vertical Stripes
color.rgb = mix(vec3(0.0, 0.0, 0.0), vec3(1.5, 1.5, 1.5), mod(gl_FragCoord.x, 20.0) / 20.0);
#elif defined GBUFFERS_DAMAGEDBLOCK // Black-White Horizontal Stripes
color.rgb = mix(vec3(0.0, 0.0, 0.0), vec3(1.5, 1.5, 1.5), mod(gl_FragCoord.y, 20.0) / 20.0);
#elif defined GBUFFERS_SKYTEXTURED // Green-Blue Horizontal Stripes
color.rgb = mix(vec3(0.0, 2.0, 0.0), vec3(0.0, 0.0, 2.0), mod(gl_FragCoord.y, 20.0) / 20.0);
#elif defined GBUFFERS_LIGHTNING // Yellow-Blue Horizontal Stripes
color.rgb = mix(vec3(2.0, 2.0, 0.0), vec3(0.0, 0.0, 2.0), mod(gl_FragCoord.y, 20.0) / 20.0);
#endif
color.rgb *= 0.75;
// Hold spider eye in one hand to switch to ID=0 check mode
if (heldItemId == 40000 || heldItemId2 == 40000) {
if (mat == 0) // Magenta-Black Horizontal Stripes
color.rgb = mix(vec3(0.0, 0.0, 0.0), vec3(3.0, 0.0, 3.0), mod(gl_FragCoord.y, 20.0) / 20.0);
else
color.rgb = vec3(0.25);
}
}
@@ -1,69 +1,69 @@
vec2 darkOutlineOffsets[12] = vec2[12](
vec2( 1.0,0.0),
vec2(-1.0,1.0),
vec2( 0.0,1.0),
vec2( 1.0,1.0),
vec2(-2.0,2.0),
vec2(-1.0,2.0),
vec2( 0.0,2.0),
vec2( 1.0,2.0),
vec2( 2.0,2.0),
vec2(-2.0,1.0),
vec2( 2.0,1.0),
vec2( 2.0,0.0)
);
void DoDarkOutline(inout vec3 color, float z0, float pixelFade, vec3 playerPos, float minecraft_far) {
float outlineFade = 1.0;
#ifdef DISTANT_HORIZONS
float horizontalDistance = length(playerPos.xz);
float verticalDistance = abs(playerPos.y);
float distanceToCamera = max(horizontalDistance, verticalDistance);
float fadeStart = minecraft_far * 0.7;
float fadeEnd = minecraft_far * 0.9;
if (fadeStart >= fadeEnd) {
fadeEnd = fadeStart + max(1.0, minecraft_far * 0.01);
}
outlineFade = (1.0 - smoothstep(fadeStart, fadeEnd, distanceToCamera)) * pixelFade;
if (outlineFade < 0.001) return;
#endif
vec2 scale = vec2(1.0 / view);
float outline = 1.0;
float z = GetLinearDepth(z0) * far * 2.0;
float minZ = 1.0, sampleZA = 0.0, sampleZB = 0.0;
#if DARK_OUTLINE_THICKNESS == 1
int sampleCount = 4;
#elif DARK_OUTLINE_THICKNESS == 2
int sampleCount = 12;
#endif
for (int i = 0; i < sampleCount; i++) {
vec2 offset = scale * darkOutlineOffsets[i];
sampleZA = texture2D(depthtex0, texCoord + offset).r;
sampleZB = texture2D(depthtex0, texCoord - offset).r;
float sampleZsum = GetLinearDepth(sampleZA) + GetLinearDepth(sampleZB);
outline *= clamp(1.0 - (z - sampleZsum * far), 0.0, 1.0);
minZ = min(minZ, min(sampleZA, sampleZB));
}
outline = mix(1.0, outline, outlineFade);
if (outline < 0.909091) {
vec4 viewPos = gbufferProjectionInverse * (vec4(texCoord, minZ, 1.0) * 2.0 - 1.0);
viewPos /= viewPos.w;
float lViewPos = length(viewPos.xyz);
vec3 playerPos = ViewToPlayer(viewPos.xyz);
vec3 nViewPos = normalize(viewPos.xyz);
float VdotU = dot(nViewPos, upVec);
float VdotS = dot(nViewPos, sunVec);
vec3 newColor = vec3(0.0);
color = mix(color, newColor, 1.0 - outline * 1.1);
}
}
vec2 darkOutlineOffsets[12] = vec2[12](
vec2( 1.0,0.0),
vec2(-1.0,1.0),
vec2( 0.0,1.0),
vec2( 1.0,1.0),
vec2(-2.0,2.0),
vec2(-1.0,2.0),
vec2( 0.0,2.0),
vec2( 1.0,2.0),
vec2( 2.0,2.0),
vec2(-2.0,1.0),
vec2( 2.0,1.0),
vec2( 2.0,0.0)
);
void DoDarkOutline(inout vec3 color, float z0, float pixelFade, vec3 playerPos, float minecraft_far) {
float outlineFade = 1.0;
#ifdef DISTANT_HORIZONS
float horizontalDistance = length(playerPos.xz);
float verticalDistance = abs(playerPos.y);
float distanceToCamera = max(horizontalDistance, verticalDistance);
float fadeStart = minecraft_far * 0.7;
float fadeEnd = minecraft_far * 0.9;
if (fadeStart >= fadeEnd) {
fadeEnd = fadeStart + max(1.0, minecraft_far * 0.01);
}
outlineFade = (1.0 - smoothstep(fadeStart, fadeEnd, distanceToCamera)) * pixelFade;
if (outlineFade < 0.001) return;
#endif
vec2 scale = vec2(1.0 / view);
float outline = 1.0;
float z = GetLinearDepth(z0) * far * 2.0;
float minZ = 1.0, sampleZA = 0.0, sampleZB = 0.0;
#if DARK_OUTLINE_THICKNESS == 1
int sampleCount = 4;
#elif DARK_OUTLINE_THICKNESS == 2
int sampleCount = 12;
#endif
for (int i = 0; i < sampleCount; i++) {
vec2 offset = scale * darkOutlineOffsets[i];
sampleZA = texture2D(depthtex0, texCoord + offset).r;
sampleZB = texture2D(depthtex0, texCoord - offset).r;
float sampleZsum = GetLinearDepth(sampleZA) + GetLinearDepth(sampleZB);
outline *= clamp(1.0 - (z - sampleZsum * far), 0.0, 1.0);
minZ = min(minZ, min(sampleZA, sampleZB));
}
outline = mix(1.0, outline, outlineFade);
if (outline < 0.909091) {
vec4 viewPos = gbufferProjectionInverse * (vec4(texCoord, minZ, 1.0) * 2.0 - 1.0);
viewPos /= viewPos.w;
float lViewPos = length(viewPos.xyz);
vec3 playerPos = ViewToPlayer(viewPos.xyz);
vec3 nViewPos = normalize(viewPos.xyz);
float VdotU = dot(nViewPos, upVec);
float VdotS = dot(nViewPos, sunVec);
vec3 newColor = vec3(0.0);
color = mix(color, newColor, 1.0 - outline * 1.1);
}
}
@@ -1,70 +1,70 @@
// Improved SSAO function for Distant Horizons
float DoAmbientOcclusionDH(float z0_raw, float linearZ0_current_context, sampler2D depthTextureToSample, float dither_static_per_pixel, float emission) {
float ao_accumulator = 0.0;
int num_directions = 4;
float scm = 0.8;
float current_near_plane = dhNearPlane;
float current_far_plane = dhFarPlane;
float current_far_minus_near = current_far_plane - current_near_plane;
float sampleDepthLin_neighbor = 0.0;
float fovScale = gbufferProjection[1][1];
float viewSpaceZ0 = linearZ0_current_context * current_far_plane;
float distScale = max(viewSpaceZ0, 1.0);
vec2 overall_scale = (vec2(scm / aspectRatio, scm) * fovScale / distScale);
float goldenAngle = 2.399963229728653f;
float baseAngleOffset = dither_static_per_pixel * 6.28318530718f;
for (int i = 0; i < num_directions; i++) {
float norm_i = (float(i) + dither_static_per_pixel) / float(num_directions);
vec2 sample_kernel_offset = OffsetDistImproved(norm_i, num_directions);
vec2 offset_unrotated = sample_kernel_offset * overall_scale;
float per_sample_static_rotation = float(i) * goldenAngle * 0.1f;
float total_static_rotation = baseAngleOffset + per_sample_static_rotation;
mat2 rotationMatrix = mat2(cos(total_static_rotation), -sin(total_static_rotation),
sin(total_static_rotation), cos(total_static_rotation));
vec2 final_offset = rotationMatrix * offset_unrotated;
vec2 coord1 = texCoord + final_offset;
vec2 coord2 = texCoord - final_offset;
float local_angle_contrib = 0.0;
float local_dist_contrib = 0.0;
sampleDepthLin_neighbor = CalculateLinearDepth(texture2D(depthTextureToSample, coord1).r, current_near_plane, current_far_plane);
float aosample1 = current_far_minus_near * (linearZ0_current_context - sampleDepthLin_neighbor) * 0.9;
local_angle_contrib += clamp(0.5 - aosample1, 0.0, 1.0);
local_dist_contrib += clamp(0.25 * aosample1 - 0.5, 0.0, 1.0);
sampleDepthLin_neighbor = CalculateLinearDepth(texture2D(depthTextureToSample, coord2).r, current_near_plane, current_far_plane);
float aosample2 = current_far_minus_near * (linearZ0_current_context - sampleDepthLin_neighbor) * 0.9;
local_angle_contrib += clamp(0.5 - aosample2, 0.0, 1.0);
local_dist_contrib += clamp(0.25 * aosample2 - 0.5, 0.0, 1.0);
ao_accumulator += clamp(local_angle_contrib + local_dist_contrib, 0.0, 1.0);
}
float normalized_ao = ao_accumulator / float(num_directions);
float smoothstepUpperEdge = 1.0f;
float shaped_ao = smoothstep(0.0, smoothstepUpperEdge, normalized_ao);
float ssaoFactorOriginal = 0.075f; // DH-specific factor
float result_exponent = clamp(SSAO_I * ssaoFactorOriginal * (1.0 - emission), 0.0, 3.0);
float powered_ao = pow(shaped_ao, result_exponent);
float base_min_occlusion = 0.5;
float distance_fade_end = 0.3;
// Calculate dynamic minimum occlusion that decreases with distance
float dynamic_min_occlusion = base_min_occlusion * (1.0 - smoothstep(0.0, distance_fade_end, linearZ0_current_context));
return mix(dynamic_min_occlusion, powered_ao, powered_ao);
}
// Improved SSAO function for Distant Horizons
float DoAmbientOcclusionDH(float z0_raw, float linearZ0_current_context, sampler2D depthTextureToSample, float dither_static_per_pixel, float emission) {
float ao_accumulator = 0.0;
int num_directions = 4;
float scm = 0.8;
float current_near_plane = dhNearPlane;
float current_far_plane = dhFarPlane;
float current_far_minus_near = current_far_plane - current_near_plane;
float sampleDepthLin_neighbor = 0.0;
float fovScale = gbufferProjection[1][1];
float viewSpaceZ0 = linearZ0_current_context * current_far_plane;
float distScale = max(viewSpaceZ0, 1.0);
vec2 overall_scale = (vec2(scm / aspectRatio, scm) * fovScale / distScale);
float goldenAngle = 2.399963229728653f;
float baseAngleOffset = dither_static_per_pixel * 6.28318530718f;
for (int i = 0; i < num_directions; i++) {
float norm_i = (float(i) + dither_static_per_pixel) / float(num_directions);
vec2 sample_kernel_offset = OffsetDistImproved(norm_i, num_directions);
vec2 offset_unrotated = sample_kernel_offset * overall_scale;
float per_sample_static_rotation = float(i) * goldenAngle * 0.1f;
float total_static_rotation = baseAngleOffset + per_sample_static_rotation;
mat2 rotationMatrix = mat2(cos(total_static_rotation), -sin(total_static_rotation),
sin(total_static_rotation), cos(total_static_rotation));
vec2 final_offset = rotationMatrix * offset_unrotated;
vec2 coord1 = texCoord + final_offset;
vec2 coord2 = texCoord - final_offset;
float local_angle_contrib = 0.0;
float local_dist_contrib = 0.0;
sampleDepthLin_neighbor = CalculateLinearDepth(texture2D(depthTextureToSample, coord1).r, current_near_plane, current_far_plane);
float aosample1 = current_far_minus_near * (linearZ0_current_context - sampleDepthLin_neighbor) * 0.9;
local_angle_contrib += clamp(0.5 - aosample1, 0.0, 1.0);
local_dist_contrib += clamp(0.25 * aosample1 - 0.5, 0.0, 1.0);
sampleDepthLin_neighbor = CalculateLinearDepth(texture2D(depthTextureToSample, coord2).r, current_near_plane, current_far_plane);
float aosample2 = current_far_minus_near * (linearZ0_current_context - sampleDepthLin_neighbor) * 0.9;
local_angle_contrib += clamp(0.5 - aosample2, 0.0, 1.0);
local_dist_contrib += clamp(0.25 * aosample2 - 0.5, 0.0, 1.0);
ao_accumulator += clamp(local_angle_contrib + local_dist_contrib, 0.0, 1.0);
}
float normalized_ao = ao_accumulator / float(num_directions);
float smoothstepUpperEdge = 1.0f;
float shaped_ao = smoothstep(0.0, smoothstepUpperEdge, normalized_ao);
float ssaoFactorOriginal = 0.075f; // DH-specific factor
float result_exponent = clamp(SSAO_I * ssaoFactorOriginal * (1.0 - emission), 0.0, 3.0);
float powered_ao = pow(shaped_ao, result_exponent);
float base_min_occlusion = 0.5;
float distance_fade_end = 0.3;
// Calculate dynamic minimum occlusion that decreases with distance
float dynamic_min_occlusion = base_min_occlusion * (1.0 - smoothstep(0.0, distance_fade_end, linearZ0_current_context));
return mix(dynamic_min_occlusion, powered_ao, powered_ao);
}
@@ -1,21 +1,21 @@
float GetDistantLightBokehMix(float lViewPos) {
//if (heldItemId == 40000 || heldItemId2 == 40000) return 0.0; // Hold spider eye to disable;
return clamp01(0.005 * (lViewPos - 60.0));
}
#ifdef GBUFFERS_TERRAIN
float GetDistantLightBokehMixMipmapped(float lViewPos) {
float dlbMix = GetDistantLightBokehMix(lViewPos);
return dlbMix * min1(miplevel * 0.4);
}
void DoDistantLightBokehMaterial(inout vec4 color, vec4 distantColor, inout float emission, float distantEmission, float lViewPos) {
float dlbMix = GetDistantLightBokehMixMipmapped(lViewPos);
color = mix(color, distantColor, dlbMix);
emission = mix(emission, distantEmission, dlbMix);
}
void DoDistantLightBokehMaterial(inout float emission, float distantEmission, float lViewPos) {
float dlbMix = GetDistantLightBokehMixMipmapped(lViewPos);
emission = mix(emission, distantEmission, dlbMix);
}
#endif
float GetDistantLightBokehMix(float lViewPos) {
//if (heldItemId == 40000 || heldItemId2 == 40000) return 0.0; // Hold spider eye to disable;
return clamp01(0.005 * (lViewPos - 60.0));
}
#ifdef GBUFFERS_TERRAIN
float GetDistantLightBokehMixMipmapped(float lViewPos) {
float dlbMix = GetDistantLightBokehMix(lViewPos);
return dlbMix * min1(miplevel * 0.4);
}
void DoDistantLightBokehMaterial(inout vec4 color, vec4 distantColor, inout float emission, float distantEmission, float lViewPos) {
float dlbMix = GetDistantLightBokehMixMipmapped(lViewPos);
color = mix(color, distantColor, dlbMix);
emission = mix(emission, distantEmission, dlbMix);
}
void DoDistantLightBokehMaterial(inout float emission, float distantEmission, float lViewPos) {
float dlbMix = GetDistantLightBokehMixMipmapped(lViewPos);
emission = mix(emission, distantEmission, dlbMix);
}
#endif
@@ -1,38 +1,38 @@
#define OVERWORLD_CURVATURE_SIZE -2048 //[-16 -32 -64 -128 -256 -512 -1024 -2048 -4096 -8192 -16384 -32768 0 32768 16384 8192 4096 2048 1024 512 256]
#define NETHER_CURVATURE_SIZE -2048 //[-16 -32 -64 -128 -256 -512 -1024 -2048 -4096 -8192 -16384 -32768 0 32768 16384 8192 4096 2048 1024 512 256]
#define END_CURVATURE_SIZE -2048 //[-16 -32 -64 -128 -256 -512 -1024 -2048 -4096 -8192 -16384 -32768 0 32768 16384 8192 4096 2048 1024 512 256]
void doMirrorDimension(inout vec4 position) {
float y = position.y;
float x = position.x;
float z = position.z;
float xz = x * x + x * z + z * z;
float noiseNumber1 = texture2DLod(noisetex, vec2(frameTimeCounter, 0.0), 0.0).r;
position.y += 15.0 * sin(xz * sin(frameTimeCounter * 1.3 + 25.0) / 1000.0) * noiseNumber1;
float noiseNumber2 = sin(xz * abs(sin(frameTimeCounter * 0.1 + 540.0) / 5000.0)) * abs(sin(frameTimeCounter * 0.05 + 180.0)) * 0.5;
position.y = x * sin(noiseNumber2) + y * cos(noiseNumber2);
position.x = x * cos(noiseNumber2) - y * sin(noiseNumber2);
}
float doWorldCurvature(vec2 position) { // code from Complementary v4
#ifdef NETHER
float curvature = dot(position, position) / NETHER_CURVATURE_SIZE;
#if NETHER_CURVATURE_SIZE == 0
curvature *= 0.0;
#endif
#elif defined END
float curvature = dot(position, position) / END_CURVATURE_SIZE;
#if END_CURVATURE_SIZE == 0
curvature *= 0.0;
#endif
#else
float curvature = dot(position, position) / OVERWORLD_CURVATURE_SIZE;
#if OVERWORLD_CURVATURE_SIZE == 0
curvature *= 0.0;
#endif
#endif
return curvature;
}
#define OVERWORLD_CURVATURE_SIZE -2048 //[-16 -32 -64 -128 -256 -512 -1024 -2048 -4096 -8192 -16384 -32768 0 32768 16384 8192 4096 2048 1024 512 256]
#define NETHER_CURVATURE_SIZE -2048 //[-16 -32 -64 -128 -256 -512 -1024 -2048 -4096 -8192 -16384 -32768 0 32768 16384 8192 4096 2048 1024 512 256]
#define END_CURVATURE_SIZE -2048 //[-16 -32 -64 -128 -256 -512 -1024 -2048 -4096 -8192 -16384 -32768 0 32768 16384 8192 4096 2048 1024 512 256]
void doMirrorDimension(inout vec4 position) {
float y = position.y;
float x = position.x;
float z = position.z;
float xz = x * x + x * z + z * z;
float noiseNumber1 = texture2DLod(noisetex, vec2(frameTimeCounter, 0.0), 0.0).r;
position.y += 15.0 * sin(xz * sin(frameTimeCounter * 1.3 + 25.0) / 1000.0) * noiseNumber1;
float noiseNumber2 = sin(xz * abs(sin(frameTimeCounter * 0.1 + 540.0) / 5000.0)) * abs(sin(frameTimeCounter * 0.05 + 180.0)) * 0.5;
position.y = x * sin(noiseNumber2) + y * cos(noiseNumber2);
position.x = x * cos(noiseNumber2) - y * sin(noiseNumber2);
}
float doWorldCurvature(vec2 position) { // code from Complementary v4
#ifdef NETHER
float curvature = dot(position, position) / NETHER_CURVATURE_SIZE;
#if NETHER_CURVATURE_SIZE == 0
curvature *= 0.0;
#endif
#elif defined END
float curvature = dot(position, position) / END_CURVATURE_SIZE;
#if END_CURVATURE_SIZE == 0
curvature *= 0.0;
#endif
#else
float curvature = dot(position, position) / OVERWORLD_CURVATURE_SIZE;
#if OVERWORLD_CURVATURE_SIZE == 0
curvature *= 0.0;
#endif
#endif
return curvature;
}
@@ -1,13 +1,13 @@
#if HAND_SWAYING == 1
const float handSwayMult = 0.5;
#elif HAND_SWAYING == 2
const float handSwayMult = 1.0;
#elif HAND_SWAYING == 3
const float handSwayMult = 2.0;
#endif
gl_Position.x += handSwayMult * (sin(frameTimeCounter * 0.86)) / 256.0;
gl_Position.y += handSwayMult * (cos(frameTimeCounter * 1.5)) / 64.0;
//dvd screensaver
//gl_Position.x -= - 0.1 + mod(frameTimeCounter * 0.3, 1.0) * sign(mod(frameTimeCounter * 0.3, 2.0) - 1.0) + float(mod(frameTimeCounter * 0.3, 2.0) < 1.0);
//gl_Position.y += mod(frameTimeCounter * 0.61803398875, 1.0) * sign(mod(frameTimeCounter * 0.61803398875, 2.0) - 1.0) + float(mod(frameTimeCounter * 0.61803398875, 2.0) < 1.0);
#if HAND_SWAYING == 1
const float handSwayMult = 0.5;
#elif HAND_SWAYING == 2
const float handSwayMult = 1.0;
#elif HAND_SWAYING == 3
const float handSwayMult = 2.0;
#endif
gl_Position.x += handSwayMult * (sin(frameTimeCounter * 0.86)) / 256.0;
gl_Position.y += handSwayMult * (cos(frameTimeCounter * 1.5)) / 64.0;
//dvd screensaver
//gl_Position.x -= - 0.1 + mod(frameTimeCounter * 0.3, 1.0) * sign(mod(frameTimeCounter * 0.3, 2.0) - 1.0) + float(mod(frameTimeCounter * 0.3, 2.0) < 1.0);
//gl_Position.y += mod(frameTimeCounter * 0.61803398875, 1.0) * sign(mod(frameTimeCounter * 0.61803398875, 2.0) - 1.0) + float(mod(frameTimeCounter * 0.61803398875, 2.0) < 1.0);
@@ -1,176 +1,176 @@
float fovmult = gbufferProjection[1][1] / 1.37373871;
vec2 getLensFlarePolygonOffset(float angle, int sides, float radius) {
float rotationRadians = LENS_FLARE_SHAPE_ROTATION * (pi / 180.0);
angle += rotationRadians;
float segmentAngle = 2.0 * pi / float(sides);
float r = cos(pi / float(sides)) / cos(mod(angle, segmentAngle) - pi / float(sides));
r *= radius;
return vec2(sin(angle), cos(angle)) * r;
}
float BaseLens(vec2 lightPos, float size, float dist, float hardness) {
vec2 lensCoord = texCoord + (lightPos * dist - 0.5);
#if LENS_FLARE_SHAPE >= 3
float radius = length(lensCoord * vec2(aspectRatio, 1.0));
float angle = atan(lensCoord.y, lensCoord.x * aspectRatio);
float polyRadius = length(getLensFlarePolygonOffset(angle, LENS_FLARE_SHAPE, 1.0));
float adjustedRadius = radius / polyRadius;
float lens = clamp(1.0 - adjustedRadius / (size * fovmult), 0.0, 1.0 / hardness) * hardness;
#else
float lens = clamp(1.0 - length(lensCoord * vec2(aspectRatio, 1.0)) / (size * fovmult), 0.0, 1.0 / hardness) * hardness;
#endif
lens *= lens; lens *= lens;
return lens;
}
float OverlapLens(vec2 lightPos, float size, float dista, float distb) {
return BaseLens(lightPos, size, dista, 2.0) * BaseLens(lightPos, size, distb, 2.0);
}
float PointLens(vec2 lightPos, float size, float dist) {
float lens = BaseLens(lightPos, size, dist, 1.5) + BaseLens(lightPos, size * 4.0, dist, 1.0) * 0.5;
return lens * (0.5 + 0.5 * sunFactor);
}
float RingLensTransform(float lensFlare) {
return pow(1.0 - pow(1.0 - pow(lensFlare, 0.25), 10.0), 5.0);
}
float RingLens(vec2 lightPos, float size, float distA, float distB) {
float lensFlare1 = RingLensTransform(BaseLens(lightPos, size, distA, 1.0));
float lensFlare2 = RingLensTransform(BaseLens(lightPos, size, distB, 1.0));
float lensFlare = clamp(lensFlare2 - lensFlare1, 0.0, 1.0);
lensFlare *= sqrt(lensFlare);
lensFlare *= 1.0 - length(texCoord - lightPos - 0.5);
return lensFlare;
}
vec2 lensFlareCheckOffsets[4] = vec2[4](
vec2( 1.0,0.0),
vec2(-1.0,1.0),
vec2( 0.0,1.0),
vec2( 1.0,1.0)
);
float AnamorphicLensFlare(vec2 lightPos, float size, float intensity) {
vec2 lensCoord = abs(texCoord - lightPos - 0.5) * vec2(aspectRatio * 0.06, 0.7); // Create horizontal stretched flare
float lens = clamp01(1.0 - length(pow(lensCoord / (size * fovmult), vec2(0.85))) * 4.0);
lens *= sqrt1(max0(1.0 - 5.0 * pow2(distance(texCoord, lightPos + 0.5)))) * pow2(lens); // Control intensity falloff with distance
return lens * intensity;
}
void DoLensFlare(inout vec3 color, vec3 viewPos, float dither) {
#if LENSFLARE_MODE == 1
if (sunVec.z > 0.0) return;
#endif
vec4 clipPosSun = gbufferProjection * vec4(sunVec + 0.001, 1.0); //+0.001 fixes black screen with camera rotation set to 0,0
vec3 lightPos3 = clipPosSun.xyz / clipPosSun.w * 0.5;
vec2 lightPos = lightPos3.xy;
vec3 screenPosSun = lightPos3 + 0.5;
float flareFactor = 1.0;
vec2 cScale = 40.0 / vec2(viewWidth, viewHeight);
for (int i = 0; i < 4; i++) {
vec2 cOffset = (lensFlareCheckOffsets[i] - dither) * cScale;
vec2 checkCoord1 = screenPosSun.xy + cOffset;
vec2 checkCoord2 = screenPosSun.xy - cOffset;
float zSample1 = texture2D(depthtex0, checkCoord1).r;
float zSample2 = texture2D(depthtex0, checkCoord2).r;
#ifdef VL_CLOUDS_ACTIVE
float cloudLinearDepth1 = texture2D(colortex5, checkCoord1).a;
float cloudLinearDepth2 = texture2D(colortex5, checkCoord2).a;
zSample1 = min(zSample1, cloudLinearDepth1);
zSample2 = min(zSample2, cloudLinearDepth2);
#endif
if (zSample1 < 1.0)
flareFactor -= 0.125;
if (zSample2 < 1.0)
flareFactor -= 0.125;
}
float str = length(lightPos * vec2(aspectRatio, 1.0));
str = pow(clamp(str * 8.0, 0.0, 1.0), 2.0) - clamp(str * 3.0 - 1.5, 0.0, 1.0);
flareFactor *= str;
float oldFlareFactor = flareFactor;
#ifdef SUN_MOON_DURING_RAIN
flareFactor *= 0.65 - 0.4 * rainFactor;
#else
flareFactor *= 1.0 - rainFactor;
#endif
#ifdef NO_RAIN_ABOVE_CLOUDS
flareFactor = mix(oldFlareFactor, flareFactor, heightRelativeToCloud);
#endif
vec3 flare = (
BaseLens(lightPos, 0.3, -0.45, 1.0) * vec3(2.2, 1.2, 0.1) * 0.07 +
BaseLens(lightPos, 0.3, 0.10, 1.0) * vec3(2.2, 0.4, 0.1) * 0.03 +
BaseLens(lightPos, 0.3, 0.30, 1.0) * vec3(2.2, 0.2, 0.1) * 0.04 +
BaseLens(lightPos, 0.3, 0.50, 1.0) * vec3(2.2, 0.4, 2.5) * 0.05 +
BaseLens(lightPos, 0.3, 0.70, 1.0) * vec3(1.8, 0.4, 2.5) * 0.06 +
BaseLens(lightPos, 0.3, 0.90, 1.0) * vec3(0.1, 0.2, 2.5) * 0.07 +
OverlapLens(lightPos, 0.08, -0.28, -0.39) * vec3(2.5, 1.2, 0.1) * 0.015 +
OverlapLens(lightPos, 0.08, -0.20, -0.31) * vec3(2.5, 0.5, 0.1) * 0.010 +
OverlapLens(lightPos, 0.12, 0.06, 0.19) * vec3(2.5, 0.2, 0.1) * 0.020 +
OverlapLens(lightPos, 0.12, 0.15, 0.28) * vec3(1.8, 0.1, 1.2) * 0.015 +
OverlapLens(lightPos, 0.12, 0.24, 0.37) * vec3(1.0, 0.1, 2.5) * 0.010 +
PointLens(lightPos, 0.03, -0.55) * vec3(2.5, 1.6, 0.0) * 0.06 +
PointLens(lightPos, 0.02, -0.40) * vec3(2.5, 1.0, 0.0) * 0.045 +
PointLens(lightPos, 0.04, 0.43) * vec3(2.5, 0.6, 0.6) * 0.06 +
PointLens(lightPos, 0.02, 0.60) * vec3(0.2, 0.6, 2.5) * 0.045 +
PointLens(lightPos, 0.03, 0.67) * vec3(0.7, 1.1, 3.0) * 0.075 +
RingLens(lightPos, 0.22, 0.44, 0.46) * vec3(0.10, 0.35, 2.50) * 1.5 +
RingLens(lightPos, 0.15, 0.98, 0.99) * vec3(0.15, 0.40, 2.55) * 2.5
);
#if ANAMORPHIC_LENS_FLARE > 0
float anamorphicIntensity = ANAMORPHIC_LENS_FLARE * 0.1;
float anamorphicFlare = AnamorphicLensFlare(lightPos, 0.53, 1.0);
vec3 anamorphicColor = vec3(0.4, 0.8, 1.0) * anamorphicFlare * anamorphicIntensity;
float secondaryFlare = AnamorphicLensFlare(lightPos, 0.22, 1.35);
anamorphicColor += vec3(0.8667, 0.2196, 0.5961) * secondaryFlare * max0(anamorphicIntensity - 0.24);
#if LENSFLARE_MODE == 2
if (sunVec.z > 0.0) {
anamorphicColor = anamorphicColor * 0.35 + GetLuminance(anamorphicColor) * vec3(0.3, 0.4, 0.6);
#if BLOOD_MOON > 0
vec3 hsvAnamorphicColor = rgb2hsv(anamorphicColor);
anamorphicColor = mix(anamorphicColor, hsv2rgb(vec3(0, max(1.0, hsvAnamorphicColor.y), hsvAnamorphicColor.z * 2.7)), getBloodMoon(0));
#endif
}
#endif
flare += anamorphicColor * flareFactor;
#endif
#if LENSFLARE_MODE == 2
if (sunVec.z > 0.0) {
flare = flare * 0.2 + GetLuminance(flare) * vec3(0.3, 0.4, 0.6);
flare *= clamp01(1.0 - (SdotU + 0.1) * 5.0);
flareFactor *= LENSFLARE_I > 1.001 ? sqrt(LENSFLARE_I) : LENSFLARE_I;
} else
#endif
{
flareFactor *= LENSFLARE_I;
flare *= clamp01((SdotU + 0.1) * 5.0);
}
flare *= flareFactor;
color = mix(color, vec3(1.0), flare);
}
float fovmult = gbufferProjection[1][1] / 1.37373871;
vec2 getLensFlarePolygonOffset(float angle, int sides, float radius) {
float rotationRadians = LENS_FLARE_SHAPE_ROTATION * (pi / 180.0);
angle += rotationRadians;
float segmentAngle = 2.0 * pi / float(sides);
float r = cos(pi / float(sides)) / cos(mod(angle, segmentAngle) - pi / float(sides));
r *= radius;
return vec2(sin(angle), cos(angle)) * r;
}
float BaseLens(vec2 lightPos, float size, float dist, float hardness) {
vec2 lensCoord = texCoord + (lightPos * dist - 0.5);
#if LENS_FLARE_SHAPE >= 3
float radius = length(lensCoord * vec2(aspectRatio, 1.0));
float angle = atan(lensCoord.y, lensCoord.x * aspectRatio);
float polyRadius = length(getLensFlarePolygonOffset(angle, LENS_FLARE_SHAPE, 1.0));
float adjustedRadius = radius / polyRadius;
float lens = clamp(1.0 - adjustedRadius / (size * fovmult), 0.0, 1.0 / hardness) * hardness;
#else
float lens = clamp(1.0 - length(lensCoord * vec2(aspectRatio, 1.0)) / (size * fovmult), 0.0, 1.0 / hardness) * hardness;
#endif
lens *= lens; lens *= lens;
return lens;
}
float OverlapLens(vec2 lightPos, float size, float dista, float distb) {
return BaseLens(lightPos, size, dista, 2.0) * BaseLens(lightPos, size, distb, 2.0);
}
float PointLens(vec2 lightPos, float size, float dist) {
float lens = BaseLens(lightPos, size, dist, 1.5) + BaseLens(lightPos, size * 4.0, dist, 1.0) * 0.5;
return lens * (0.5 + 0.5 * sunFactor);
}
float RingLensTransform(float lensFlare) {
return pow(1.0 - pow(1.0 - pow(lensFlare, 0.25), 10.0), 5.0);
}
float RingLens(vec2 lightPos, float size, float distA, float distB) {
float lensFlare1 = RingLensTransform(BaseLens(lightPos, size, distA, 1.0));
float lensFlare2 = RingLensTransform(BaseLens(lightPos, size, distB, 1.0));
float lensFlare = clamp(lensFlare2 - lensFlare1, 0.0, 1.0);
lensFlare *= sqrt(lensFlare);
lensFlare *= 1.0 - length(texCoord - lightPos - 0.5);
return lensFlare;
}
vec2 lensFlareCheckOffsets[4] = vec2[4](
vec2( 1.0,0.0),
vec2(-1.0,1.0),
vec2( 0.0,1.0),
vec2( 1.0,1.0)
);
float AnamorphicLensFlare(vec2 lightPos, float size, float intensity) {
vec2 lensCoord = abs(texCoord - lightPos - 0.5) * vec2(aspectRatio * 0.06, 0.7); // Create horizontal stretched flare
float lens = clamp01(1.0 - length(pow(lensCoord / (size * fovmult), vec2(0.85))) * 4.0);
lens *= sqrt1(max0(1.0 - 5.0 * pow2(distance(texCoord, lightPos + 0.5)))) * pow2(lens); // Control intensity falloff with distance
return lens * intensity;
}
void DoLensFlare(inout vec3 color, vec3 viewPos, float dither) {
#if LENSFLARE_MODE == 1
if (sunVec.z > 0.0) return;
#endif
vec4 clipPosSun = gbufferProjection * vec4(sunVec + 0.001, 1.0); //+0.001 fixes black screen with camera rotation set to 0,0
vec3 lightPos3 = clipPosSun.xyz / clipPosSun.w * 0.5;
vec2 lightPos = lightPos3.xy;
vec3 screenPosSun = lightPos3 + 0.5;
float flareFactor = 1.0;
vec2 cScale = 40.0 / vec2(viewWidth, viewHeight);
for (int i = 0; i < 4; i++) {
vec2 cOffset = (lensFlareCheckOffsets[i] - dither) * cScale;
vec2 checkCoord1 = screenPosSun.xy + cOffset;
vec2 checkCoord2 = screenPosSun.xy - cOffset;
float zSample1 = texture2D(depthtex0, checkCoord1).r;
float zSample2 = texture2D(depthtex0, checkCoord2).r;
#ifdef VL_CLOUDS_ACTIVE
float cloudLinearDepth1 = texture2D(colortex5, checkCoord1).a;
float cloudLinearDepth2 = texture2D(colortex5, checkCoord2).a;
zSample1 = min(zSample1, cloudLinearDepth1);
zSample2 = min(zSample2, cloudLinearDepth2);
#endif
if (zSample1 < 1.0)
flareFactor -= 0.125;
if (zSample2 < 1.0)
flareFactor -= 0.125;
}
float str = length(lightPos * vec2(aspectRatio, 1.0));
str = pow(clamp(str * 8.0, 0.0, 1.0), 2.0) - clamp(str * 3.0 - 1.5, 0.0, 1.0);
flareFactor *= str;
float oldFlareFactor = flareFactor;
#ifdef SUN_MOON_DURING_RAIN
flareFactor *= 0.65 - 0.4 * rainFactor;
#else
flareFactor *= 1.0 - rainFactor;
#endif
#ifdef NO_RAIN_ABOVE_CLOUDS
flareFactor = mix(oldFlareFactor, flareFactor, heightRelativeToCloud);
#endif
vec3 flare = (
BaseLens(lightPos, 0.3, -0.45, 1.0) * vec3(2.2, 1.2, 0.1) * 0.07 +
BaseLens(lightPos, 0.3, 0.10, 1.0) * vec3(2.2, 0.4, 0.1) * 0.03 +
BaseLens(lightPos, 0.3, 0.30, 1.0) * vec3(2.2, 0.2, 0.1) * 0.04 +
BaseLens(lightPos, 0.3, 0.50, 1.0) * vec3(2.2, 0.4, 2.5) * 0.05 +
BaseLens(lightPos, 0.3, 0.70, 1.0) * vec3(1.8, 0.4, 2.5) * 0.06 +
BaseLens(lightPos, 0.3, 0.90, 1.0) * vec3(0.1, 0.2, 2.5) * 0.07 +
OverlapLens(lightPos, 0.08, -0.28, -0.39) * vec3(2.5, 1.2, 0.1) * 0.015 +
OverlapLens(lightPos, 0.08, -0.20, -0.31) * vec3(2.5, 0.5, 0.1) * 0.010 +
OverlapLens(lightPos, 0.12, 0.06, 0.19) * vec3(2.5, 0.2, 0.1) * 0.020 +
OverlapLens(lightPos, 0.12, 0.15, 0.28) * vec3(1.8, 0.1, 1.2) * 0.015 +
OverlapLens(lightPos, 0.12, 0.24, 0.37) * vec3(1.0, 0.1, 2.5) * 0.010 +
PointLens(lightPos, 0.03, -0.55) * vec3(2.5, 1.6, 0.0) * 0.06 +
PointLens(lightPos, 0.02, -0.40) * vec3(2.5, 1.0, 0.0) * 0.045 +
PointLens(lightPos, 0.04, 0.43) * vec3(2.5, 0.6, 0.6) * 0.06 +
PointLens(lightPos, 0.02, 0.60) * vec3(0.2, 0.6, 2.5) * 0.045 +
PointLens(lightPos, 0.03, 0.67) * vec3(0.7, 1.1, 3.0) * 0.075 +
RingLens(lightPos, 0.22, 0.44, 0.46) * vec3(0.10, 0.35, 2.50) * 1.5 +
RingLens(lightPos, 0.15, 0.98, 0.99) * vec3(0.15, 0.40, 2.55) * 2.5
);
#if ANAMORPHIC_LENS_FLARE > 0
float anamorphicIntensity = ANAMORPHIC_LENS_FLARE * 0.1;
float anamorphicFlare = AnamorphicLensFlare(lightPos, 0.53, 1.0);
vec3 anamorphicColor = vec3(0.4, 0.8, 1.0) * anamorphicFlare * anamorphicIntensity;
float secondaryFlare = AnamorphicLensFlare(lightPos, 0.22, 1.35);
anamorphicColor += vec3(0.8667, 0.2196, 0.5961) * secondaryFlare * max0(anamorphicIntensity - 0.24);
#if LENSFLARE_MODE == 2
if (sunVec.z > 0.0) {
anamorphicColor = anamorphicColor * 0.35 + GetLuminance(anamorphicColor) * vec3(0.3, 0.4, 0.6);
#if BLOOD_MOON > 0
vec3 hsvAnamorphicColor = rgb2hsv(anamorphicColor);
anamorphicColor = mix(anamorphicColor, hsv2rgb(vec3(0, max(1.0, hsvAnamorphicColor.y), hsvAnamorphicColor.z * 2.7)), getBloodMoon(0));
#endif
}
#endif
flare += anamorphicColor * flareFactor;
#endif
#if LENSFLARE_MODE == 2
if (sunVec.z > 0.0) {
flare = flare * 0.2 + GetLuminance(flare) * vec3(0.3, 0.4, 0.6);
flare *= clamp01(1.0 - (SdotU + 0.1) * 5.0);
flareFactor *= LENSFLARE_I > 1.001 ? sqrt(LENSFLARE_I) : LENSFLARE_I;
} else
#endif
{
flareFactor *= LENSFLARE_I;
flare *= clamp01((SdotU + 0.1) * 5.0);
}
flare *= flareFactor;
color = mix(color, vec3(1.0), flare);
}
@@ -1,2 +1,2 @@
// Euphoria Patches 1.8.6
// Developed by SpacEagle17
// Euphoria Patches 1.8.6
// Developed by SpacEagle17
@@ -1,55 +1,55 @@
#if !defined PACKING_FILE_INCLUDED
#define PACKING_FILE_INCLUDED
// Structs
struct vec6 {
vec3 a;
vec3 b;
};
// the packing / unpacking assumes normalized floats
float pack2x16(float a, float b) {
a = clamp(a, 0.0, 0.99);
b = clamp(b, 0.0, 0.99);
uint low = uint(a * 65535.0);
uint high = uint(b * 65535.0);
return (low | (high << 16)) / 4294967295.0;
}
vec3 pack2x16(vec3 a, vec3 b) {
a = clamp(a, 0.0, 0.99);
b = clamp(b, 0.0, 0.99);
uvec3 low = uvec3(a * 65535.0);
uvec3 high = uvec3(b * 65535.0);
return (low | (high << 16)) / 4294967295.0;
}
vec2 unpack2x16(float val) {
uint temp = uint(val * 4294967295.0);
return vec2(float(temp & 65535u), (temp >> 16u)) / 65535.0;
}
vec6 unpack2x16(vec3 val) {
uvec3 temp = uvec3(val * 4294967295.0);
return vec6(vec3(temp & 65535u) / 65535.0, (temp >> 16u) / 65535.0);
}
struct vec8 {
vec4 a;
vec4 b;
};
vec4 pack2x16(vec4 a, vec4 b) {
a = clamp(a, 0.0, 0.99);
b = clamp(b, 0.0, 0.99);
uvec4 low = uvec4(a * 65535.0);
uvec4 high = uvec4(b * 65535.0);
return (low | (high << 16)) / 4294967295.0;
}
vec8 unpack2x16(vec4 val) {
uvec4 temp = uvec4(val * 4294967295.0);
return vec8(vec4(temp & 65535u) / 65535.0, (temp >> 16u) / 65535.0);
}
#endif
#if !defined PACKING_FILE_INCLUDED
#define PACKING_FILE_INCLUDED
// Structs
struct vec6 {
vec3 a;
vec3 b;
};
// the packing / unpacking assumes normalized floats
float pack2x16(float a, float b) {
a = clamp(a, 0.0, 0.99);
b = clamp(b, 0.0, 0.99);
uint low = uint(a * 65535.0);
uint high = uint(b * 65535.0);
return (low | (high << 16)) / 4294967295.0;
}
vec3 pack2x16(vec3 a, vec3 b) {
a = clamp(a, 0.0, 0.99);
b = clamp(b, 0.0, 0.99);
uvec3 low = uvec3(a * 65535.0);
uvec3 high = uvec3(b * 65535.0);
return (low | (high << 16)) / 4294967295.0;
}
vec2 unpack2x16(float val) {
uint temp = uint(val * 4294967295.0);
return vec2(float(temp & 65535u), (temp >> 16u)) / 65535.0;
}
vec6 unpack2x16(vec3 val) {
uvec3 temp = uvec3(val * 4294967295.0);
return vec6(vec3(temp & 65535u) / 65535.0, (temp >> 16u) / 65535.0);
}
struct vec8 {
vec4 a;
vec4 b;
};
vec4 pack2x16(vec4 a, vec4 b) {
a = clamp(a, 0.0, 0.99);
b = clamp(b, 0.0, 0.99);
uvec4 low = uvec4(a * 65535.0);
uvec4 high = uvec4(b * 65535.0);
return (low | (high << 16)) / 4294967295.0;
}
vec8 unpack2x16(vec4 val) {
uvec4 temp = uvec4(val * 4294967295.0);
return vec8(vec4(temp & 65535u) / 65535.0, (temp >> 16u) / 65535.0);
}
#endif
@@ -1,126 +1,126 @@
vec3 posterizeColor(vec3 color) {
return mix(color, hsv2rgb(vec3(rgb2hsv(color).x, floor(rgb2hsv(color).yz*COLOR_LEVELS)/(COLOR_LEVELS-1.0))), POSTERIZE_STRENGTH);
}
vec3 sampleCell(sampler2D tex, vec2 origin, vec2 size, int count) {
vec2 cellCoord = floor(origin / size);
vec3 sum = vec3(0.0);
float fCount = float(count);
#ifdef UNDERWATER_DISTORTION
if (isEyeInWater == 1){
origin += getUnderwaterDistortion(cellCoord, 0.0005);
}
#endif
for (int i = 0; i < count * count; i++) {
vec2 offset = vec2(mod(float(i), fCount) + 0.5, floor(float(i) / fCount) + 0.5) / fCount;
sum += texture2D(tex, origin + size * offset).rgb;
}
return sum / (fCount * fCount);
}
vec2 getCellSize() {
return vec2(float(int(ceil(256.0 / PIXELATED_SCREEN_SIZE_INTERNAL) + 1) & ~1)) / vec2(viewWidth, viewHeight);
}
vec3 createPixelation(sampler2D tex, vec2 uv, float sampleCount, vec2 cellSize) {
vec2 cellOrigin = floor(uv / cellSize) * cellSize;
sampleCount = max0(sampleCount) + 1.0;
vec3 pixelated = mix(
sampleCell(tex, cellOrigin, cellSize, int(sampleCount)),
sampleCell(tex, cellOrigin, cellSize, int(sampleCount) + 1),
fract(sampleCount)
);
return posterizeColor(pixelated);
}
// Precomputed threshold map for dithering
const mat4x4 DITHER_THRESHOLD = mat4x4(
0., 8., 2., 10.,
12., 4., 14., 6.,
3., 11., 1., 9.,
15., 7., 13., 5.
);
vec3 ditherColor(vec3 color, vec2 uv, vec2 cellSize) {
ivec2 gridCoord = ivec2(floor(uv / cellSize));
ivec2 ditherIndex = gridCoord % 4;
float ditherValue = (DITHER_THRESHOLD[ditherIndex.x][ditherIndex.y] / 16.0) - SCREEN_DITHER_I;
float luminance = GetLuminance(color);
float variance = length(color - luminance);
float ditherSpread = SCREEN_DITHER_AMOUNT * 0.1 * variance;
return color + ditherSpread * ditherValue;
}
#ifdef PALETTE_SWAP
#if USE_TEXTURE_PALETTE > 0
const int MAX_PALETTE_SIZE = 32;
#else
const int MAX_PALETTE_SIZE = 6;
vec3 FIXED_COLOR_PALETTE[MAX_PALETTE_SIZE] = vec3[](
vec3(PALETTE1R, PALETTE1G, PALETTE1B),
vec3(PALETTE2R, PALETTE2G, PALETTE2B),
vec3(PALETTE3R, PALETTE3G, PALETTE3B),
vec3(PALETTE4R, PALETTE4G, PALETTE4B),
vec3(PALETTE5R, PALETTE5G, PALETTE5B),
vec3(PALETTE6R, PALETTE6G, PALETTE6B)
);
#endif
int getPaletteTextureSize() {
return int(textureSize(depthtex2, 0).x);
}
void sortPaletteByLuminance(inout vec3 pal[MAX_PALETTE_SIZE], int size) {
for (int i = 0; i < size - 1; i++) {
for (int j = 0; j < size - i - 1; j++) {
if (GetLuminance(pal[j]) > GetLuminance(pal[j + 1])) {
vec3 temp = pal[j];
pal[j] = pal[j + 1];
pal[j + 1] = temp;
}
}
}
}
vec3 samplePaletteFromTexture(inout vec3 paletteOut[MAX_PALETTE_SIZE], int size) {
for (int x = 0; x < size; x++) {
vec3 paletteColor = texelFetch(depthtex2, ivec2(x, 0), 0).rgb;
paletteOut[x] = paletteColor;
}
return paletteOut[0];
}
vec3 convertToPaletteColor(vec3 inputColor) {
vec3 localPalette[MAX_PALETTE_SIZE];
int paletteSize = MAX_PALETTE_SIZE;
#if USE_TEXTURE_PALETTE > 0
paletteSize = getPaletteTextureSize();
if (paletteSize == viewWidth) {
return mix(mix(inputColor, vec3(GetLuminance(inputColor)), 0.93), vec3(1.0, 0.0, 0.0), 0.2); // Bright red for visibility
}
samplePaletteFromTexture(localPalette, paletteSize);
#else
for (int i = 0; i < MAX_PALETTE_SIZE; i++) {
localPalette[i] = FIXED_COLOR_PALETTE[i] / 255.0;
}
#endif
sortPaletteByLuminance(localPalette, paletteSize);
// Quantize the color based on the available palette levels.
inputColor.r = floor(inputColor.r * float(paletteSize - 1) + 0.5) / float(paletteSize - 1);
inputColor.g = floor(inputColor.g * float(paletteSize - 1) + 0.5) / float(paletteSize - 1);
inputColor.b = floor(inputColor.b * float(paletteSize - 1) + 0.5) / float(paletteSize - 1);
int paletteIndex = int(floor(GetLuminance(inputColor) * float(paletteSize)));
paletteIndex = clamp(paletteIndex, 0, paletteSize - 1);
return localPalette[paletteIndex];
}
#endif
vec3 posterizeColor(vec3 color) {
return mix(color, hsv2rgb(vec3(rgb2hsv(color).x, floor(rgb2hsv(color).yz*COLOR_LEVELS)/(COLOR_LEVELS-1.0))), POSTERIZE_STRENGTH);
}
vec3 sampleCell(sampler2D tex, vec2 origin, vec2 size, int count) {
vec2 cellCoord = floor(origin / size);
vec3 sum = vec3(0.0);
float fCount = float(count);
#ifdef UNDERWATER_DISTORTION
if (isEyeInWater == 1){
origin += getUnderwaterDistortion(cellCoord, 0.0005);
}
#endif
for (int i = 0; i < count * count; i++) {
vec2 offset = vec2(mod(float(i), fCount) + 0.5, floor(float(i) / fCount) + 0.5) / fCount;
sum += texture2D(tex, origin + size * offset).rgb;
}
return sum / (fCount * fCount);
}
vec2 getCellSize() {
return vec2(float(int(ceil(256.0 / PIXELATED_SCREEN_SIZE_INTERNAL) + 1) & ~1)) / vec2(viewWidth, viewHeight);
}
vec3 createPixelation(sampler2D tex, vec2 uv, float sampleCount, vec2 cellSize) {
vec2 cellOrigin = floor(uv / cellSize) * cellSize;
sampleCount = max0(sampleCount) + 1.0;
vec3 pixelated = mix(
sampleCell(tex, cellOrigin, cellSize, int(sampleCount)),
sampleCell(tex, cellOrigin, cellSize, int(sampleCount) + 1),
fract(sampleCount)
);
return posterizeColor(pixelated);
}
// Precomputed threshold map for dithering
const mat4x4 DITHER_THRESHOLD = mat4x4(
0., 8., 2., 10.,
12., 4., 14., 6.,
3., 11., 1., 9.,
15., 7., 13., 5.
);
vec3 ditherColor(vec3 color, vec2 uv, vec2 cellSize) {
ivec2 gridCoord = ivec2(floor(uv / cellSize));
ivec2 ditherIndex = gridCoord % 4;
float ditherValue = (DITHER_THRESHOLD[ditherIndex.x][ditherIndex.y] / 16.0) - SCREEN_DITHER_I;
float luminance = GetLuminance(color);
float variance = length(color - luminance);
float ditherSpread = SCREEN_DITHER_AMOUNT * 0.1 * variance;
return color + ditherSpread * ditherValue;
}
#ifdef PALETTE_SWAP
#if USE_TEXTURE_PALETTE > 0
const int MAX_PALETTE_SIZE = 32;
#else
const int MAX_PALETTE_SIZE = 6;
vec3 FIXED_COLOR_PALETTE[MAX_PALETTE_SIZE] = vec3[](
vec3(PALETTE1R, PALETTE1G, PALETTE1B),
vec3(PALETTE2R, PALETTE2G, PALETTE2B),
vec3(PALETTE3R, PALETTE3G, PALETTE3B),
vec3(PALETTE4R, PALETTE4G, PALETTE4B),
vec3(PALETTE5R, PALETTE5G, PALETTE5B),
vec3(PALETTE6R, PALETTE6G, PALETTE6B)
);
#endif
int getPaletteTextureSize() {
return int(textureSize(depthtex2, 0).x);
}
void sortPaletteByLuminance(inout vec3 pal[MAX_PALETTE_SIZE], int size) {
for (int i = 0; i < size - 1; i++) {
for (int j = 0; j < size - i - 1; j++) {
if (GetLuminance(pal[j]) > GetLuminance(pal[j + 1])) {
vec3 temp = pal[j];
pal[j] = pal[j + 1];
pal[j + 1] = temp;
}
}
}
}
vec3 samplePaletteFromTexture(inout vec3 paletteOut[MAX_PALETTE_SIZE], int size) {
for (int x = 0; x < size; x++) {
vec3 paletteColor = texelFetch(depthtex2, ivec2(x, 0), 0).rgb;
paletteOut[x] = paletteColor;
}
return paletteOut[0];
}
vec3 convertToPaletteColor(vec3 inputColor) {
vec3 localPalette[MAX_PALETTE_SIZE];
int paletteSize = MAX_PALETTE_SIZE;
#if USE_TEXTURE_PALETTE > 0
paletteSize = getPaletteTextureSize();
if (paletteSize == viewWidth) {
return mix(mix(inputColor, vec3(GetLuminance(inputColor)), 0.93), vec3(1.0, 0.0, 0.0), 0.2); // Bright red for visibility
}
samplePaletteFromTexture(localPalette, paletteSize);
#else
for (int i = 0; i < MAX_PALETTE_SIZE; i++) {
localPalette[i] = FIXED_COLOR_PALETTE[i] / 255.0;
}
#endif
sortPaletteByLuminance(localPalette, paletteSize);
// Quantize the color based on the available palette levels.
inputColor.r = floor(inputColor.r * float(paletteSize - 1) + 0.5) / float(paletteSize - 1);
inputColor.g = floor(inputColor.g * float(paletteSize - 1) + 0.5) / float(paletteSize - 1);
inputColor.b = floor(inputColor.b * float(paletteSize - 1) + 0.5) / float(paletteSize - 1);
int paletteIndex = int(floor(GetLuminance(inputColor) * float(paletteSize)));
paletteIndex = clamp(paletteIndex, 0, paletteSize - 1);
return localPalette[paletteIndex];
}
#endif
@@ -1,97 +1,97 @@
#if !defined PIXELATION_FILE
#define PIXELATION_FILE
#if PIXEL_SCALE == -2
#define PIXEL_TEXEL_SCALE 4.0
#elif PIXEL_SCALE == -1
#define PIXEL_TEXEL_SCALE 2.0
#elif PIXEL_SCALE == 2
#define PIXEL_TEXEL_SCALE 0.5
#elif PIXEL_SCALE == 3
#define PIXEL_TEXEL_SCALE 0.25
#elif PIXEL_SCALE == 4
#define PIXEL_TEXEL_SCALE 0.125
#elif PIXEL_SCALE == 5
#define PIXEL_TEXEL_SCALE 0.0625
#else // 1 or out of range
#define PIXEL_TEXEL_SCALE 1.0
#endif
#ifdef FRAGMENT_SHADER
// Thanks to Nestorboy
// Computes axis-aligned screen space offset to texel center.
// https://forum.unity.com/threads/the-quest-for-efficient-per-texel-lighting.529948/#post-7536023
vec2 ComputeTexelOffset(vec2 uv, vec4 texelSize) {
// 1. Calculate how much the texture UV coords need to shift to be at the center of the nearest texel.
vec2 uvCenter = (floor(uv * texelSize.zw) + 0.5) * texelSize.xy;
vec2 dUV = uvCenter - uv;
// 2. Calculate how much the texture coords vary over fragment space.
// This essentially defines a 2x2 matrix that gets texture space (UV) deltas from fragment space (ST) deltas.
vec2 dUVdS = dFdx(uv);
vec2 dUVdT = dFdy(uv);
if (abs(dUVdS) + abs(dUVdT) == vec2(0.0)) return vec2(0.0);
// 3. Invert the texture delta from fragment delta matrix. Where the magic happens.
mat2x2 dSTdUV = mat2x2(dUVdT[1], -dUVdT[0], -dUVdS[1], dUVdS[0]) * (1.0 / (dUVdS[0] * dUVdT[1] - dUVdT[0] * dUVdS[1]));
// 4. Convert the texture delta to fragment delta.
vec2 dST = dUV * dSTdUV;
return dST;
}
vec2 ComputeTexelOffset(sampler2D tex, vec2 uv) {
vec2 texSize = textureSize(tex, 0) * PIXEL_TEXEL_SCALE;
vec4 texelSize = vec4(1.0 / texSize.xy, texSize.xy);
return ComputeTexelOffset(uv, texelSize);
}
vec4 TexelSnap(vec4 value, vec2 texelOffset) {
if(all(equal(texelOffset, vec2(0.0)))) return value;
vec4 dx = dFdx(value);
vec4 dy = dFdy(value);
vec4 valueOffset = dx * texelOffset.x + dy * texelOffset.y;
valueOffset = clamp(valueOffset, -1.0, 1.0);
return value + valueOffset;
}
vec3 TexelSnap(vec3 value, vec2 texelOffset) {
if(all(equal(texelOffset, vec2(0.0)))) return value;
vec3 dx = dFdx(value);
vec3 dy = dFdy(value);
vec3 valueOffset = dx * texelOffset.x + dy * texelOffset.y;
valueOffset = clamp(valueOffset, -1.0, 1.0);
return value + valueOffset;
}
vec2 TexelSnap(vec2 value, vec2 texelOffset) {
if(all(equal(texelOffset, vec2(0.0)))) return value;
vec2 dx = dFdx(value);
vec2 dy = dFdy(value);
vec2 valueOffset = dx * texelOffset.x + dy * texelOffset.y;
valueOffset = clamp(valueOffset, -1.0, 1.0);
return value + valueOffset;
}
float TexelSnap(float value, vec2 texelOffset) {
if(all(equal(texelOffset, vec2(0.0)))) return value;
float dx = dFdx(value);
float dy = dFdy(value);
float valueOffset = dx * texelOffset.x + dy * texelOffset.y;
valueOffset = clamp(valueOffset, -1.0, 1.0);
return value + valueOffset;
}
#endif
#endif // !defined PIXELATION_FILE
#if !defined PIXELATION_FILE
#define PIXELATION_FILE
#if PIXEL_SCALE == -2
#define PIXEL_TEXEL_SCALE 4.0
#elif PIXEL_SCALE == -1
#define PIXEL_TEXEL_SCALE 2.0
#elif PIXEL_SCALE == 2
#define PIXEL_TEXEL_SCALE 0.5
#elif PIXEL_SCALE == 3
#define PIXEL_TEXEL_SCALE 0.25
#elif PIXEL_SCALE == 4
#define PIXEL_TEXEL_SCALE 0.125
#elif PIXEL_SCALE == 5
#define PIXEL_TEXEL_SCALE 0.0625
#else // 1 or out of range
#define PIXEL_TEXEL_SCALE 1.0
#endif
#ifdef FRAGMENT_SHADER
// Thanks to Nestorboy
// Computes axis-aligned screen space offset to texel center.
// https://forum.unity.com/threads/the-quest-for-efficient-per-texel-lighting.529948/#post-7536023
vec2 ComputeTexelOffset(vec2 uv, vec4 texelSize) {
// 1. Calculate how much the texture UV coords need to shift to be at the center of the nearest texel.
vec2 uvCenter = (floor(uv * texelSize.zw) + 0.5) * texelSize.xy;
vec2 dUV = uvCenter - uv;
// 2. Calculate how much the texture coords vary over fragment space.
// This essentially defines a 2x2 matrix that gets texture space (UV) deltas from fragment space (ST) deltas.
vec2 dUVdS = dFdx(uv);
vec2 dUVdT = dFdy(uv);
if (abs(dUVdS) + abs(dUVdT) == vec2(0.0)) return vec2(0.0);
// 3. Invert the texture delta from fragment delta matrix. Where the magic happens.
mat2x2 dSTdUV = mat2x2(dUVdT[1], -dUVdT[0], -dUVdS[1], dUVdS[0]) * (1.0 / (dUVdS[0] * dUVdT[1] - dUVdT[0] * dUVdS[1]));
// 4. Convert the texture delta to fragment delta.
vec2 dST = dUV * dSTdUV;
return dST;
}
vec2 ComputeTexelOffset(sampler2D tex, vec2 uv) {
vec2 texSize = textureSize(tex, 0) * PIXEL_TEXEL_SCALE;
vec4 texelSize = vec4(1.0 / texSize.xy, texSize.xy);
return ComputeTexelOffset(uv, texelSize);
}
vec4 TexelSnap(vec4 value, vec2 texelOffset) {
if(all(equal(texelOffset, vec2(0.0)))) return value;
vec4 dx = dFdx(value);
vec4 dy = dFdy(value);
vec4 valueOffset = dx * texelOffset.x + dy * texelOffset.y;
valueOffset = clamp(valueOffset, -1.0, 1.0);
return value + valueOffset;
}
vec3 TexelSnap(vec3 value, vec2 texelOffset) {
if(all(equal(texelOffset, vec2(0.0)))) return value;
vec3 dx = dFdx(value);
vec3 dy = dFdy(value);
vec3 valueOffset = dx * texelOffset.x + dy * texelOffset.y;
valueOffset = clamp(valueOffset, -1.0, 1.0);
return value + valueOffset;
}
vec2 TexelSnap(vec2 value, vec2 texelOffset) {
if(all(equal(texelOffset, vec2(0.0)))) return value;
vec2 dx = dFdx(value);
vec2 dy = dFdy(value);
vec2 valueOffset = dx * texelOffset.x + dy * texelOffset.y;
valueOffset = clamp(valueOffset, -1.0, 1.0);
return value + valueOffset;
}
float TexelSnap(float value, vec2 texelOffset) {
if(all(equal(texelOffset, vec2(0.0)))) return value;
float dx = dFdx(value);
float dy = dFdy(value);
float valueOffset = dx * texelOffset.x + dy * texelOffset.y;
valueOffset = clamp(valueOffset, -1.0, 1.0);
return value + valueOffset;
}
#endif
#endif // !defined PIXELATION_FILE
@@ -1,252 +1,252 @@
vec3 getPixelPotato(vec2 pixelCoord, vec3 color, vec2 size) { // Original Pixel art by Memokii
if (pixelCoord.x < 0.0 || pixelCoord.x >= size.x ||
pixelCoord.y < 0.0 || pixelCoord.y >= size.y) {
return color;
}
int x = int(pixelCoord.x);
int y = int(pixelCoord.y);
if ((y == 0 || y == 8) && x >= 4 && x < 10) return hex2rgb(y == 0 ? 0x7C552Au : 0x652C14u);
if (y == 1) {
if (x >= 2 && x < 4 || x >= 10 && x < 12) return hex2rgb(0x7C552Au);
if (x >= 4 && x < 7 || x == 9) return hex2rgb(0xD1A34Bu);
return x >= 7 && x < 9 ? hex2rgb(0xD8B95Bu) : color;
}
if (y == 2) {
return (x == 1) ? hex2rgb(0x7C552Au) :
(x == 2 || x == 11) ? hex2rgb(0xD1A34Bu) :
(x == 3 || x == 9) ? hex2rgb(0xE3D872u) :
(x == 4) ? hex2rgb(0x9A7D45u) :
(x >= 5 && x < 7 || x == 8) ? hex2rgb(0x353330u) :
(x == 7) ? hex2rgb(0x292623u) :
(x == 10) ? hex2rgb(0xD8B95Bu) :
(x == 12) ? hex2rgb(0x703F1Eu) : color;
}
if (y == 3) {
return (x == 0 || x == 13) ? hex2rgb(0x703F1Eu) :
(x == 1 || x == 11) ? hex2rgb(0xD1A34Bu) :
(x >= 2 && x < 4 || x == 6) ? hex2rgb(0xD8B95Bu) :
(x == 4 || x >= 7 && x < 10) ? hex2rgb(0xE3D872u) :
(x == 5) ? hex2rgb(0x353330u) :
(x == 10) ? hex2rgb(0x916E3Cu) :
(x == 12) ? hex2rgb(0xC58539u) : color;
}
if (y == 4) {
return (x == 0) ? hex2rgb(0x703F1Eu) :
(x >= 1 && x < 3 || x >= 10 && x < 13) ? hex2rgb(0xD1A34Bu) :
(x >= 3 && x < 5 || x >= 7 && x < 10) ? hex2rgb(0xD8B95Bu) :
(x >= 5 && x < 7) ? hex2rgb(0x292623u) :
(x == 13) ? hex2rgb(0x652C14u) : color;
}
if (y == 5) {
return (x == 0) ? hex2rgb(0x703F1Eu) :
(x == 1) ? hex2rgb(0xC58539u) :
(x >= 2 && x < 4 || x >= 9 && x < 12) ? hex2rgb(0xD1A34Bu) :
(x == 4 || x >= 6 && x < 8) ? hex2rgb(0xD8B95Bu) :
(x == 5) ? hex2rgb(0x1D1917u) :
(x == 8) ? hex2rgb(0x916E3Cu) :
(x == 12) ? hex2rgb(0x652C14u) : color;
}
if (y == 6) {
return (x == 1) ? hex2rgb(0x703F1Eu) :
(x == 2) ? hex2rgb(0x916E3Cu) :
(x == 3 || x >= 10 && x < 12) ? hex2rgb(0xC58539u) :
(x == 4 || x == 9) ? hex2rgb(0xD1A34Bu) :
(x >= 5 && x < 7 || x >= 7 && x < 9) ? hex2rgb(0x1D1917u) :
(x == 6) ? hex2rgb(0x292623u) :
(x == 12) ? hex2rgb(0x652C14u) : color;
}
if (y == 7) {
return (x == 2) ? hex2rgb(0x703F1Eu) :
(x == 3 || x >= 10 && x < 12) ? hex2rgb(0x652C14u) :
(x >= 4 && x < 6 || x == 8) ? hex2rgb(0xC58539u) :
(x >= 6 && x < 8) ? hex2rgb(0xD1A34Bu) :
(x == 9) ? hex2rgb(0x916E3Cu) : color;
}
return color;
}
uint randomLetter(float offset){
uint letters[36] = uint[](
_A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z,
_0, _1, _2, _3, _4, _5, _6, _7, _8, _9
);
int randomIndex = int(hash11(frameTimeCounter * 0.1 + offset) * 36);
return letters[randomIndex];
}
uint letterAnimation(float offset, float verticalOffset) {
float animation = min(shaderStartSmooth * 0.3 - offset * 0.3, 0.1) * 10.0;
if (animation < 0.95) {
return randomLetter(offset);
} else {
float noise = texture2DLod(noisetex, vec2(frameTimeCounter * 0.002), 0.0).r;
if (abs(verticalOffset) > 0.05 && noise > 0.6 || noise > 0.8) {
if (offset == 0.0) return _G;
else if (offset == 0.1) return _L;
else if (offset == 0.2) return _a;
else if (offset == 0.3) return _D;
else if (offset == 0.4) return _O;
else if (offset == 0.5) return _S;
} else {
if (offset == 0.0) return _P;
else if (offset == 0.1) return _O;
else if (offset == 0.2) return _T;
else if (offset == 0.3) return _A;
else if (offset == 0.4) return _T;
else if (offset == 0.5) return _O;
}
}
return _space;
}
vec3 printPhrase(vec3 color, int verticalTextOffset){
beginTextM(10, vec2(6, 10 + verticalTextOffset));
text.fgCol = vec4(1.0, 0.0, 0.0, 0.85);
// For each letter position, check if it should be randomized
printString((
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 0.1), 0.0).r > 0.85 ? randomLetter(0.1) : _Y,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 0.2), 0.0).r > 0.85 ? randomLetter(0.2) : _o,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 0.3), 0.0).r > 0.85 ? randomLetter(0.3) : _u,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 0.4), 0.0).r > 0.85 ? randomLetter(0.4) : _r,
_space,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 0.5), 0.0).r > 0.85 ? randomLetter(0.5) : _A,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 0.6), 0.0).r > 0.85 ? randomLetter(0.6) : _c,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 0.7), 0.0).r > 0.85 ? randomLetter(0.7) : _t,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 0.8), 0.0).r > 0.85 ? randomLetter(0.8) : _i,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 0.9), 0.0).r > 0.85 ? randomLetter(0.9) : _o,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 1.0), 0.0).r > 0.85 ? randomLetter(1.0) : _n,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 1.1), 0.0).r > 0.85 ? randomLetter(1.1) : _s,
_space,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 1.2), 0.0).r > 0.85 ? randomLetter(1.2) : _h,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 1.3), 0.0).r > 0.85 ? randomLetter(1.3) : _a,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 1.4), 0.0).r > 0.85 ? randomLetter(1.4) : _v,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 1.5), 0.0).r > 0.85 ? randomLetter(1.5) : _e
));
printLine();
// Second line with similar randomization
printString((
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 1.6), 0.0).r > 0.85 ? randomLetter(1.6) : _C,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 1.7), 0.0).r > 0.85 ? randomLetter(1.7) : _o,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 1.8), 0.0).r > 0.85 ? randomLetter(1.8) : _n,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 1.9), 0.0).r > 0.85 ? randomLetter(1.9) : _s,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 2.0), 0.0).r > 0.85 ? randomLetter(2.0) : _e,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 2.1), 0.0).r > 0.85 ? randomLetter(2.1) : _q,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 2.2), 0.0).r > 0.85 ? randomLetter(2.2) : _u,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 2.3), 0.0).r > 0.85 ? randomLetter(2.3) : _e,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 2.4), 0.0).r > 0.85 ? randomLetter(2.4) : _n,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 2.5), 0.0).r > 0.85 ? randomLetter(2.5) : _c,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 2.6), 0.0).r > 0.85 ? randomLetter(2.6) : _e,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 2.7), 0.0).r > 0.85 ? randomLetter(2.7) : _s,
_exclm
));
endText(color);
return color;
}
vec3 printNumbers(vec3 color, int verticalTextOffset) {
beginTextM(5, vec2(12, 140 + verticalTextOffset * 2));text.fgCol = vec4(0.2157, 0.0, 1.0, 0.85);
printFloat(frameTimeCounter);printLine();
printFloat(worldDay + worldTime / 24000.0);printLine();
printFloat(aspectRatio);
printString((_space));
float cameraRotateNumber = 0.0;
mat3 currentModelView = mat3(gbufferModelView);
for (int i = 0; i < 3; i++) {
vec3 rotation = currentModelView[i];
for (int j = 0; j < 3; j++) {
cameraRotateNumber += rotation[j];
}
}
printFloat(cameraRotateNumber);printLine();
endText(color);
return color;
}
vec3 potatoWatermark(vec3 color, vec2 displacedCoord, vec2 flickerNoiseVec) {
// Apply offset to watermark position
vec4 watermarkColor = waterMarkFunction(ivec2(100, 29), vec2(0.1, 0.3), displacedCoord.xy, 1.3, false);
// Rest of the effect processing remains the same
float flickerNoise = max(flickerNoiseVec.r, flickerNoiseVec.g);
float flickerFactor = step(0.4, flickerNoise);
float rareBlend = smoothstep(0.3, 0.6, texture2DLod(noisetex, vec2(frameTimeCounter * 0.09), 0.0).r);
flickerFactor = mix(flickerFactor, rareBlend, 0.3);
vec3 newWatermarkColors = saturateColors(watermarkColor.rgb, flickerFactor * 0.4 + flickerNoiseVec.r);
float noise = texture2DLod(noisetex, displacedCoord.xy * 3.0 + vec2(frameTimeCounter * 0.1, sin(frameTimeCounter * 0.05) * 0.5), 0.0).r * 10.0;
noise = smoothstep(0.3, 0.7, noise) * sin(frameTimeCounter * 3.0 + displacedCoord.x * 10.0);
float invertAlpha = watermarkColor.a * noise;
vec4 flickeringWatermarkColor = vec4(newWatermarkColors, invertAlpha);
color.rgb = mix(color.rgb, flickeringWatermarkColor.rgb, flickeringWatermarkColor.a);
return mix(color.rgb, newWatermarkColors, watermarkColor.a * flickerFactor);
}
vec3 rareShaderError(vec2 texCoordBorder) {
vec3 color = vec3(0.2);
vec2 displacedCoord = texCoordBorder;
float verticalIndicator = 0.0;
applyVerticalScreenDisplacement(displacedCoord, verticalIndicator, 1.0, 1.0, 1.0, false);
// Convert the offset to screen space for text positioning
int verticalTextOffset = int(displacedCoord.y * 8); // Adjust multiplier to match your text scale
verticalTextOffset += int(displacedCoord.x * 10.0);
beginTextM(15, vec2(8 + verticalTextOffset, 25)); text.fgCol = vec4(1.0, 0.0, 0.0, 0.85);
printString((_S, _h, _a, _d, _e, _r, _space, _E, _R, _R, _O, _R));
endText(color);
return color;
}
vec3 potatoError(){
vec3 color = vec3(0.6);
// Calculate displacement value that we'll use for all elements
vec2 texCoordBorder = curveDisplay(texCoord, 1.2, 3);
vec2 displacedCoord = texCoordBorder;
float verticalIndicator = 0.0;
vec2 noiseVec = texture2DLod(noisetex, vec2(frameTimeCounter * 0.06), 0.0).rb;
applyVerticalScreenDisplacement(displacedCoord, verticalIndicator, 1.0, 1.0, 1.0, true);
float verticalOffset = displacedCoord.y - texCoordBorder.y;
// Convert the offset to screen space for text positioning
int verticalTextOffset = int(verticalOffset * 100.0); // Adjust multiplier to match your text scale
// Apply offset to text position
color = printPhrase(color, verticalTextOffset);
beginTextM(20, vec2(3, 20 + verticalTextOffset * 0.5)); text.fgCol = vec4(1.0, 0.0, 0.0, 0.85);
printString((letterAnimation(0.0, verticalIndicator), letterAnimation(0.1, verticalIndicator), letterAnimation(0.2, verticalIndicator),
letterAnimation(0.3, verticalIndicator), letterAnimation(0.4, verticalIndicator), letterAnimation(0.5, verticalIndicator)));
endText(color);
color = printNumbers(color, verticalTextOffset);
// Apply offset to potato position
float pixelPotatoSize = 0.15;
vec2 transformedCoords = (applyHorizontalNoise(displacedCoord, 1, noiseVec.r * 1.5 + 0.5, noiseVec.g + 0.3) - vec2(0.8, 0.6)) / pixelPotatoSize;
vec2 potatoSize = vec2(14.0, 9.0);
vec2 pixelCoords = (vec2(transformedCoords.x, transformedCoords.y * -1) + 1.0) * potatoSize * 0.5;
color.rgb = getPixelPotato(floor(pixelCoords), color, potatoSize);
color.rgb = potatoWatermark(color.rgb, displacedCoord, noiseVec);
if(mod(frameTimeCounter + 10, 42.0) < 8.0) color = rareShaderError(texCoordBorder); // Why 42? Because it's the answer to everything
color *= staticColor(color, 1, 0.1, 0.6, 1.0);
color = scanline(texCoordBorder, color, 0.66, 2, 1.5, 1.2, vec3(1.0), true, false);
if (texCoordBorder.x < 0.0 || texCoordBorder.x > 1.0) color = vec3(0.0);
if (texCoordBorder.y < 0.0 || texCoordBorder.y > 1.0) color = vec3(0.0);
return color;
}
vec3 getPixelPotato(vec2 pixelCoord, vec3 color, vec2 size) { // Original Pixel art by Memokii
if (pixelCoord.x < 0.0 || pixelCoord.x >= size.x ||
pixelCoord.y < 0.0 || pixelCoord.y >= size.y) {
return color;
}
int x = int(pixelCoord.x);
int y = int(pixelCoord.y);
if ((y == 0 || y == 8) && x >= 4 && x < 10) return hex2rgb(y == 0 ? 0x7C552Au : 0x652C14u);
if (y == 1) {
if (x >= 2 && x < 4 || x >= 10 && x < 12) return hex2rgb(0x7C552Au);
if (x >= 4 && x < 7 || x == 9) return hex2rgb(0xD1A34Bu);
return x >= 7 && x < 9 ? hex2rgb(0xD8B95Bu) : color;
}
if (y == 2) {
return (x == 1) ? hex2rgb(0x7C552Au) :
(x == 2 || x == 11) ? hex2rgb(0xD1A34Bu) :
(x == 3 || x == 9) ? hex2rgb(0xE3D872u) :
(x == 4) ? hex2rgb(0x9A7D45u) :
(x >= 5 && x < 7 || x == 8) ? hex2rgb(0x353330u) :
(x == 7) ? hex2rgb(0x292623u) :
(x == 10) ? hex2rgb(0xD8B95Bu) :
(x == 12) ? hex2rgb(0x703F1Eu) : color;
}
if (y == 3) {
return (x == 0 || x == 13) ? hex2rgb(0x703F1Eu) :
(x == 1 || x == 11) ? hex2rgb(0xD1A34Bu) :
(x >= 2 && x < 4 || x == 6) ? hex2rgb(0xD8B95Bu) :
(x == 4 || x >= 7 && x < 10) ? hex2rgb(0xE3D872u) :
(x == 5) ? hex2rgb(0x353330u) :
(x == 10) ? hex2rgb(0x916E3Cu) :
(x == 12) ? hex2rgb(0xC58539u) : color;
}
if (y == 4) {
return (x == 0) ? hex2rgb(0x703F1Eu) :
(x >= 1 && x < 3 || x >= 10 && x < 13) ? hex2rgb(0xD1A34Bu) :
(x >= 3 && x < 5 || x >= 7 && x < 10) ? hex2rgb(0xD8B95Bu) :
(x >= 5 && x < 7) ? hex2rgb(0x292623u) :
(x == 13) ? hex2rgb(0x652C14u) : color;
}
if (y == 5) {
return (x == 0) ? hex2rgb(0x703F1Eu) :
(x == 1) ? hex2rgb(0xC58539u) :
(x >= 2 && x < 4 || x >= 9 && x < 12) ? hex2rgb(0xD1A34Bu) :
(x == 4 || x >= 6 && x < 8) ? hex2rgb(0xD8B95Bu) :
(x == 5) ? hex2rgb(0x1D1917u) :
(x == 8) ? hex2rgb(0x916E3Cu) :
(x == 12) ? hex2rgb(0x652C14u) : color;
}
if (y == 6) {
return (x == 1) ? hex2rgb(0x703F1Eu) :
(x == 2) ? hex2rgb(0x916E3Cu) :
(x == 3 || x >= 10 && x < 12) ? hex2rgb(0xC58539u) :
(x == 4 || x == 9) ? hex2rgb(0xD1A34Bu) :
(x >= 5 && x < 7 || x >= 7 && x < 9) ? hex2rgb(0x1D1917u) :
(x == 6) ? hex2rgb(0x292623u) :
(x == 12) ? hex2rgb(0x652C14u) : color;
}
if (y == 7) {
return (x == 2) ? hex2rgb(0x703F1Eu) :
(x == 3 || x >= 10 && x < 12) ? hex2rgb(0x652C14u) :
(x >= 4 && x < 6 || x == 8) ? hex2rgb(0xC58539u) :
(x >= 6 && x < 8) ? hex2rgb(0xD1A34Bu) :
(x == 9) ? hex2rgb(0x916E3Cu) : color;
}
return color;
}
uint randomLetter(float offset){
uint letters[36] = uint[](
_A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z,
_0, _1, _2, _3, _4, _5, _6, _7, _8, _9
);
int randomIndex = int(hash11(frameTimeCounter * 0.1 + offset) * 36);
return letters[randomIndex];
}
uint letterAnimation(float offset, float verticalOffset) {
float animation = min(shaderStartSmooth * 0.3 - offset * 0.3, 0.1) * 10.0;
if (animation < 0.95) {
return randomLetter(offset);
} else {
float noise = texture2DLod(noisetex, vec2(frameTimeCounter * 0.002), 0.0).r;
if (abs(verticalOffset) > 0.05 && noise > 0.6 || noise > 0.8) {
if (offset == 0.0) return _G;
else if (offset == 0.1) return _L;
else if (offset == 0.2) return _a;
else if (offset == 0.3) return _D;
else if (offset == 0.4) return _O;
else if (offset == 0.5) return _S;
} else {
if (offset == 0.0) return _P;
else if (offset == 0.1) return _O;
else if (offset == 0.2) return _T;
else if (offset == 0.3) return _A;
else if (offset == 0.4) return _T;
else if (offset == 0.5) return _O;
}
}
return _space;
}
vec3 printPhrase(vec3 color, int verticalTextOffset){
beginTextM(10, vec2(6, 10 + verticalTextOffset));
text.fgCol = vec4(1.0, 0.0, 0.0, 0.85);
// For each letter position, check if it should be randomized
printString((
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 0.1), 0.0).r > 0.85 ? randomLetter(0.1) : _Y,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 0.2), 0.0).r > 0.85 ? randomLetter(0.2) : _o,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 0.3), 0.0).r > 0.85 ? randomLetter(0.3) : _u,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 0.4), 0.0).r > 0.85 ? randomLetter(0.4) : _r,
_space,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 0.5), 0.0).r > 0.85 ? randomLetter(0.5) : _A,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 0.6), 0.0).r > 0.85 ? randomLetter(0.6) : _c,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 0.7), 0.0).r > 0.85 ? randomLetter(0.7) : _t,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 0.8), 0.0).r > 0.85 ? randomLetter(0.8) : _i,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 0.9), 0.0).r > 0.85 ? randomLetter(0.9) : _o,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 1.0), 0.0).r > 0.85 ? randomLetter(1.0) : _n,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 1.1), 0.0).r > 0.85 ? randomLetter(1.1) : _s,
_space,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 1.2), 0.0).r > 0.85 ? randomLetter(1.2) : _h,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 1.3), 0.0).r > 0.85 ? randomLetter(1.3) : _a,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 1.4), 0.0).r > 0.85 ? randomLetter(1.4) : _v,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 1.5), 0.0).r > 0.85 ? randomLetter(1.5) : _e
));
printLine();
// Second line with similar randomization
printString((
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 1.6), 0.0).r > 0.85 ? randomLetter(1.6) : _C,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 1.7), 0.0).r > 0.85 ? randomLetter(1.7) : _o,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 1.8), 0.0).r > 0.85 ? randomLetter(1.8) : _n,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 1.9), 0.0).r > 0.85 ? randomLetter(1.9) : _s,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 2.0), 0.0).r > 0.85 ? randomLetter(2.0) : _e,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 2.1), 0.0).r > 0.85 ? randomLetter(2.1) : _q,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 2.2), 0.0).r > 0.85 ? randomLetter(2.2) : _u,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 2.3), 0.0).r > 0.85 ? randomLetter(2.3) : _e,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 2.4), 0.0).r > 0.85 ? randomLetter(2.4) : _n,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 2.5), 0.0).r > 0.85 ? randomLetter(2.5) : _c,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 2.6), 0.0).r > 0.85 ? randomLetter(2.6) : _e,
texture2DLod(noisetex, vec2(frameTimeCounter * 0.01 + 2.7), 0.0).r > 0.85 ? randomLetter(2.7) : _s,
_exclm
));
endText(color);
return color;
}
vec3 printNumbers(vec3 color, int verticalTextOffset) {
beginTextM(5, vec2(12, 140 + verticalTextOffset * 2));text.fgCol = vec4(0.2157, 0.0, 1.0, 0.85);
printFloat(frameTimeCounter);printLine();
printFloat(worldDay + worldTime / 24000.0);printLine();
printFloat(aspectRatio);
printString((_space));
float cameraRotateNumber = 0.0;
mat3 currentModelView = mat3(gbufferModelView);
for (int i = 0; i < 3; i++) {
vec3 rotation = currentModelView[i];
for (int j = 0; j < 3; j++) {
cameraRotateNumber += rotation[j];
}
}
printFloat(cameraRotateNumber);printLine();
endText(color);
return color;
}
vec3 potatoWatermark(vec3 color, vec2 displacedCoord, vec2 flickerNoiseVec) {
// Apply offset to watermark position
vec4 watermarkColor = waterMarkFunction(ivec2(100, 29), vec2(0.1, 0.3), displacedCoord.xy, 1.3, false);
// Rest of the effect processing remains the same
float flickerNoise = max(flickerNoiseVec.r, flickerNoiseVec.g);
float flickerFactor = step(0.4, flickerNoise);
float rareBlend = smoothstep(0.3, 0.6, texture2DLod(noisetex, vec2(frameTimeCounter * 0.09), 0.0).r);
flickerFactor = mix(flickerFactor, rareBlend, 0.3);
vec3 newWatermarkColors = saturateColors(watermarkColor.rgb, flickerFactor * 0.4 + flickerNoiseVec.r);
float noise = texture2DLod(noisetex, displacedCoord.xy * 3.0 + vec2(frameTimeCounter * 0.1, sin(frameTimeCounter * 0.05) * 0.5), 0.0).r * 10.0;
noise = smoothstep(0.3, 0.7, noise) * sin(frameTimeCounter * 3.0 + displacedCoord.x * 10.0);
float invertAlpha = watermarkColor.a * noise;
vec4 flickeringWatermarkColor = vec4(newWatermarkColors, invertAlpha);
color.rgb = mix(color.rgb, flickeringWatermarkColor.rgb, flickeringWatermarkColor.a);
return mix(color.rgb, newWatermarkColors, watermarkColor.a * flickerFactor);
}
vec3 rareShaderError(vec2 texCoordBorder) {
vec3 color = vec3(0.2);
vec2 displacedCoord = texCoordBorder;
float verticalIndicator = 0.0;
applyVerticalScreenDisplacement(displacedCoord, verticalIndicator, 1.0, 1.0, 1.0, false);
// Convert the offset to screen space for text positioning
int verticalTextOffset = int(displacedCoord.y * 8); // Adjust multiplier to match your text scale
verticalTextOffset += int(displacedCoord.x * 10.0);
beginTextM(15, vec2(8 + verticalTextOffset, 25)); text.fgCol = vec4(1.0, 0.0, 0.0, 0.85);
printString((_S, _h, _a, _d, _e, _r, _space, _E, _R, _R, _O, _R));
endText(color);
return color;
}
vec3 potatoError(){
vec3 color = vec3(0.6);
// Calculate displacement value that we'll use for all elements
vec2 texCoordBorder = curveDisplay(texCoord, 1.2, 3);
vec2 displacedCoord = texCoordBorder;
float verticalIndicator = 0.0;
vec2 noiseVec = texture2DLod(noisetex, vec2(frameTimeCounter * 0.06), 0.0).rb;
applyVerticalScreenDisplacement(displacedCoord, verticalIndicator, 1.0, 1.0, 1.0, true);
float verticalOffset = displacedCoord.y - texCoordBorder.y;
// Convert the offset to screen space for text positioning
int verticalTextOffset = int(verticalOffset * 100.0); // Adjust multiplier to match your text scale
// Apply offset to text position
color = printPhrase(color, verticalTextOffset);
beginTextM(20, vec2(3, 20 + verticalTextOffset * 0.5)); text.fgCol = vec4(1.0, 0.0, 0.0, 0.85);
printString((letterAnimation(0.0, verticalIndicator), letterAnimation(0.1, verticalIndicator), letterAnimation(0.2, verticalIndicator),
letterAnimation(0.3, verticalIndicator), letterAnimation(0.4, verticalIndicator), letterAnimation(0.5, verticalIndicator)));
endText(color);
color = printNumbers(color, verticalTextOffset);
// Apply offset to potato position
float pixelPotatoSize = 0.15;
vec2 transformedCoords = (applyHorizontalNoise(displacedCoord, 1, noiseVec.r * 1.5 + 0.5, noiseVec.g + 0.3) - vec2(0.8, 0.6)) / pixelPotatoSize;
vec2 potatoSize = vec2(14.0, 9.0);
vec2 pixelCoords = (vec2(transformedCoords.x, transformedCoords.y * -1) + 1.0) * potatoSize * 0.5;
color.rgb = getPixelPotato(floor(pixelCoords), color, potatoSize);
color.rgb = potatoWatermark(color.rgb, displacedCoord, noiseVec);
if(mod(frameTimeCounter + 10, 42.0) < 8.0) color = rareShaderError(texCoordBorder); // Why 42? Because it's the answer to everything
color *= staticColor(color, 1, 0.1, 0.6, 1.0);
color = scanline(texCoordBorder, color, 0.66, 2, 1.5, 1.2, vec3(1.0), true, false);
if (texCoordBorder.x < 0.0 || texCoordBorder.x > 1.0) color = vec3(0.0);
if (texCoordBorder.y < 0.0 || texCoordBorder.y > 1.0) color = vec3(0.0);
return color;
}
@@ -1,35 +1,35 @@
#if !defined REPROJECTION_FILE
#define REPROJECTION_FILE
// Previous frame reprojection from Chocapic13
vec2 Reprojection(vec3 pos, vec3 cameraOffset) {
pos = pos * 2.0 - 1.0;
vec4 viewPosPrev = gbufferProjectionInverse * vec4(pos, 1.0);
viewPosPrev /= viewPosPrev.w;
viewPosPrev = gbufferModelViewInverse * viewPosPrev;
vec4 previousPosition = viewPosPrev + vec4(cameraOffset, 0.0);
previousPosition = gbufferPreviousModelView * previousPosition;
previousPosition = gbufferPreviousProjection * previousPosition;
return previousPosition.xy / previousPosition.w * 0.5 + 0.5;
}
vec3 FHalfReprojection(vec3 pos) {
pos = pos * 2.0 - 1.0;
vec4 viewPosPrev = gbufferProjectionInverse * vec4(pos, 1.0);
viewPosPrev /= viewPosPrev.w;
viewPosPrev = gbufferModelViewInverse * viewPosPrev;
return viewPosPrev.xyz;
}
vec2 SHalfReprojection(vec3 playerPos, vec3 cameraOffset) {
vec4 proPos = vec4(playerPos + cameraOffset, 1.0);
vec4 previousPosition = gbufferPreviousModelView * proPos;
previousPosition = gbufferPreviousProjection * previousPosition;
return previousPosition.xy / previousPosition.w * 0.5 + 0.5;
}
#endif
#if !defined REPROJECTION_FILE
#define REPROJECTION_FILE
// Previous frame reprojection from Chocapic13
vec2 Reprojection(vec3 pos, vec3 cameraOffset) {
pos = pos * 2.0 - 1.0;
vec4 viewPosPrev = gbufferProjectionInverse * vec4(pos, 1.0);
viewPosPrev /= viewPosPrev.w;
viewPosPrev = gbufferModelViewInverse * viewPosPrev;
vec4 previousPosition = viewPosPrev + vec4(cameraOffset, 0.0);
previousPosition = gbufferPreviousModelView * previousPosition;
previousPosition = gbufferPreviousProjection * previousPosition;
return previousPosition.xy / previousPosition.w * 0.5 + 0.5;
}
vec3 FHalfReprojection(vec3 pos) {
pos = pos * 2.0 - 1.0;
vec4 viewPosPrev = gbufferProjectionInverse * vec4(pos, 1.0);
viewPosPrev /= viewPosPrev.w;
viewPosPrev = gbufferModelViewInverse * viewPosPrev;
return viewPosPrev.xyz;
}
vec2 SHalfReprojection(vec3 playerPos, vec3 cameraOffset) {
vec4 proPos = vec4(playerPos + cameraOffset, 1.0);
vec4 previousPosition = gbufferPreviousModelView * proPos;
previousPosition = gbufferPreviousProjection * previousPosition;
return previousPosition.xy / previousPosition.w * 0.5 + 0.5;
}
#endif
@@ -1,69 +1,69 @@
#include "/lib/shaderSettings/shockwave.glsl"
// SDF from https://iquilezles.org/articles/distfunctions2d/
float sdBox(vec2 p, vec2 b) {
vec2 d = abs(p)-b;
return length(max(d,0.0)) + min(max(d.x,d.y),0.0);
}
float sdCircle(vec2 p, float r) {
return length(p) - r;
}
float getOffsetStrength(float animation, vec2 dir, float maxRadius) {
#if SHOCKWAVE == 1
float wave = sdCircle(vec2(dir / aspectRatio), animation * maxRadius);
#elif SHOCKWAVE == 2
float wave = sdBox(dir / aspectRatio, vec2(animation * maxRadius));
#endif
wave *= 1.0 - smoothstep(0.0, 0.2, abs(wave)); // Mask the ripple
wave *= smoothstep(0.0, 0.2, animation); // Smooth intro
wave *= 1.0 - smoothstep(0.5, 1.0, animation); // Smooth outro
return wave * 0.05;
}
vec4 doShockwave(vec3 playerPos, vec2 texCoord){ // Based on https://editor.p5js.org/BarneyCodes/sketches/ELbA93Ugb by BarneyCodes
vec2 centre = playerPos.xz + 0.4;
vec2 dir = centre - texCoord;
float animation = pow(isShockwave, 1.0 / 1.2);
vec4 shockwaveColor = vec4(0);
float maxRadius = 4;
// Chromatic aberration
float aberrationOffset = 0.05 * sin(animation * pi);
float rWave = getOffsetStrength(animation + aberrationOffset, dir, maxRadius);
float gWave = getOffsetStrength(animation, dir, maxRadius);
float bWave = getOffsetStrength(animation - aberrationOffset, dir, maxRadius);
dir = normalize(dir);
float value = 1.0;
#if defined GBUFFERS_TERRAIN || defined GBUFFERS_WATER
float blockRes = absMidCoordPos.x * atlasSize.x;
vec2 signMidCoordPosM = abs((floor((signMidCoordPos + 1.0) * blockRes) + 0.5) / blockRes - 1.0);
value = 1.0 - max(signMidCoordPosM.x, signMidCoordPosM.y); // Prevent from distorting into a different atlas texture
#endif
float waveFactor = abs(max(gWave, max(rWave, bWave)) * 100.0);
value *= step(0.01, animation);
#if ANISOTROPIC_FILTER != 0 && defined GBUFFERS_TERRAIN
float r = waveFactor > 0.0001 ? texture2D(tex, texCoord + dir * rWave * value).r : textureAF(tex, texCoord).r;
float g = waveFactor > 0.0001 ? texture2D(tex, texCoord + dir * gWave * value).g : textureAF(tex, texCoord).g;
float b = waveFactor > 0.0001 ? texture2D(tex, texCoord + dir * bWave * value).b : textureAF(tex, texCoord).b;
float a = waveFactor > 0.0001 ? texture2D(tex, texCoord).a : textureAF(tex, texCoord).a; // Use the non AF method during the wave
#else
float r = texture2D(tex, texCoord + dir * rWave * value).r;
float g = texture2D(tex, texCoord + dir * gWave * value).g;
float b = texture2D(tex, texCoord + dir * bWave * value).b;
float a = texture2D(tex, texCoord).a;
#endif
float shading = gWave * 15.0; // use gWave as it has no chromatic aberration
shockwaveColor = vec4(r, g, b, a);
shockwaveColor.rgb += shading * 1.5;
// shockwaveColor += waveFactor > 0.0001 ? vec4(3,0,0,1) : vec4(0,0,0,0); // Debugging
return shockwaveColor;
}
#include "/lib/shaderSettings/shockwave.glsl"
// SDF from https://iquilezles.org/articles/distfunctions2d/
float sdBox(vec2 p, vec2 b) {
vec2 d = abs(p)-b;
return length(max(d,0.0)) + min(max(d.x,d.y),0.0);
}
float sdCircle(vec2 p, float r) {
return length(p) - r;
}
float getOffsetStrength(float animation, vec2 dir, float maxRadius) {
#if SHOCKWAVE == 1
float wave = sdCircle(vec2(dir / aspectRatio), animation * maxRadius);
#elif SHOCKWAVE == 2
float wave = sdBox(dir / aspectRatio, vec2(animation * maxRadius));
#endif
wave *= 1.0 - smoothstep(0.0, 0.2, abs(wave)); // Mask the ripple
wave *= smoothstep(0.0, 0.2, animation); // Smooth intro
wave *= 1.0 - smoothstep(0.5, 1.0, animation); // Smooth outro
return wave * 0.05;
}
vec4 doShockwave(vec3 playerPos, vec2 texCoord){ // Based on https://editor.p5js.org/BarneyCodes/sketches/ELbA93Ugb by BarneyCodes
vec2 centre = playerPos.xz + 0.4;
vec2 dir = centre - texCoord;
float animation = pow(isShockwave, 1.0 / 1.2);
vec4 shockwaveColor = vec4(0);
float maxRadius = 4;
// Chromatic aberration
float aberrationOffset = 0.05 * sin(animation * pi);
float rWave = getOffsetStrength(animation + aberrationOffset, dir, maxRadius);
float gWave = getOffsetStrength(animation, dir, maxRadius);
float bWave = getOffsetStrength(animation - aberrationOffset, dir, maxRadius);
dir = normalize(dir);
float value = 1.0;
#if defined GBUFFERS_TERRAIN || defined GBUFFERS_WATER
float blockRes = absMidCoordPos.x * atlasSize.x;
vec2 signMidCoordPosM = abs((floor((signMidCoordPos + 1.0) * blockRes) + 0.5) / blockRes - 1.0);
value = 1.0 - max(signMidCoordPosM.x, signMidCoordPosM.y); // Prevent from distorting into a different atlas texture
#endif
float waveFactor = abs(max(gWave, max(rWave, bWave)) * 100.0);
value *= step(0.01, animation);
#if ANISOTROPIC_FILTER != 0 && defined GBUFFERS_TERRAIN
float r = waveFactor > 0.0001 ? texture2D(tex, texCoord + dir * rWave * value).r : textureAF(tex, texCoord).r;
float g = waveFactor > 0.0001 ? texture2D(tex, texCoord + dir * gWave * value).g : textureAF(tex, texCoord).g;
float b = waveFactor > 0.0001 ? texture2D(tex, texCoord + dir * bWave * value).b : textureAF(tex, texCoord).b;
float a = waveFactor > 0.0001 ? texture2D(tex, texCoord).a : textureAF(tex, texCoord).a; // Use the non AF method during the wave
#else
float r = texture2D(tex, texCoord + dir * rWave * value).r;
float g = texture2D(tex, texCoord + dir * gWave * value).g;
float b = texture2D(tex, texCoord + dir * bWave * value).b;
float a = texture2D(tex, texCoord).a;
#endif
float shading = gWave * 15.0; // use gWave as it has no chromatic aberration
shockwaveColor = vec4(r, g, b, a);
shockwaveColor.rgb += shading * 1.5;
// shockwaveColor += waveFactor > 0.0001 ? vec4(3,0,0,1) : vec4(0,0,0,0); // Debugging
return shockwaveColor;
}
@@ -1,42 +1,42 @@
#if SHOW_LIGHT_LEVEL == 1
if (heldItemId == 40000 || heldItemId2 == 40000)
#elif SHOW_LIGHT_LEVEL == 2
if (heldBlockLightValue > 7.4 || heldBlockLightValue2 > 7.4)
#endif
if (NdotU > 0.99) {
#ifdef OVERWORLD
#if MC_VERSION < 11800
float lxMin = 0.533334;
#else
float lxMin = 0.034; // Quite high minimum value because of an Iris/Sodium issue
#endif
float lyMin = 0.533334;
#else
float lxMin = 0.8;
float lyMin = 0.533334;
#endif
bool xDanger = lmCoord.x < lxMin;
#ifndef NETHER
bool yDanger = lmCoord.y < lyMin;
#else
bool yDanger = lmCoord.x < lyMin;
#endif
if (xDanger) {
vec2 indicatePos = playerPos.xz + cameraPosition.xz;
indicatePos = 1.0 - 2.0 * abs(fract(indicatePos) - 0.5);
float minPos = min(indicatePos.x, indicatePos.y);
if (minPos > 0.5) {
color.rgb = yDanger ? vec3(0.4, 0.05, 0.05) : vec3(0.3, 0.3, 0.05);
smoothnessG = 0.5;
highlightMult = 1.0;
smoothnessD = 0.0;
emission = 3.0;
}
}
}
#if SHOW_LIGHT_LEVEL == 1
if (heldItemId == 40000 || heldItemId2 == 40000)
#elif SHOW_LIGHT_LEVEL == 2
if (heldBlockLightValue > 7.4 || heldBlockLightValue2 > 7.4)
#endif
if (NdotU > 0.99) {
#ifdef OVERWORLD
#if MC_VERSION < 11800
float lxMin = 0.533334;
#else
float lxMin = 0.034; // Quite high minimum value because of an Iris/Sodium issue
#endif
float lyMin = 0.533334;
#else
float lxMin = 0.8;
float lyMin = 0.533334;
#endif
bool xDanger = lmCoord.x < lxMin;
#ifndef NETHER
bool yDanger = lmCoord.y < lyMin;
#else
bool yDanger = lmCoord.x < lyMin;
#endif
if (xDanger) {
vec2 indicatePos = playerPos.xz + cameraPosition.xz;
indicatePos = 1.0 - 2.0 * abs(fract(indicatePos) - 0.5);
float minPos = min(indicatePos.x, indicatePos.y);
if (minPos > 0.5) {
color.rgb = yDanger ? vec3(0.4, 0.05, 0.05) : vec3(0.3, 0.3, 0.05);
smoothnessG = 0.5;
highlightMult = 1.0;
smoothnessD = 0.0;
emission = 3.0;
}
}
}
@@ -1,76 +1,76 @@
vec2 worldOutlineOffset[4] = vec2[4] (
vec2(-1.0, 1.0),
vec2( 0, 1.0),
vec2( 1.0, 1.0),
vec2( 1.0, 0)
);
void DoWorldOutline(inout vec3 color, float linearZ0, float pixelFade, vec3 playerPos, float minecraft_far) {
float outlineFade = 1.0;
#ifdef DISTANT_HORIZONS
float horizontalDistance = length(playerPos.xz);
float verticalDistance = abs(playerPos.y);
float distanceToCamera = max(horizontalDistance, verticalDistance);
float fadeStart = minecraft_far * 0.7;
float fadeEnd = minecraft_far * 0.9;
if (fadeStart >= fadeEnd) {
fadeEnd = fadeStart + max(1.0, minecraft_far * 0.01);
}
outlineFade = (1.0 - smoothstep(fadeStart, fadeEnd, distanceToCamera)) * pixelFade;
if (outlineFade < 0.001) return;
#endif
vec2 scale = vec2(1.0 / view);
float outlines[2] = float[2] (0.0, 0.0);
float outlined = 1.0;
float z = linearZ0 * far;
float totalz = 0.0;
float maxz = 0.0;
float sampleza = 0.0;
float samplezb = 0.0;
#ifdef ENTITIES_ARE_LIGHT
#define WORLD_OUTLINE_THICKNESSM 4
#else
#define WORLD_OUTLINE_THICKNESSM WORLD_OUTLINE_THICKNESS
#endif
#if PIXELATED_SCREEN_SIZE > 0
int sampleCount = WORLD_OUTLINE_THICKNESSM * 4 + abs(9 - int(PIXELATED_SCREEN_SIZE_INTERNAL * 0.1));
#else
int sampleCount = WORLD_OUTLINE_THICKNESSM * 4;
#endif
for (int i = 0; i < sampleCount; i++) {
vec2 offset = (1.0 + floor(i / 4.0)) * scale * worldOutlineOffset[int(mod(float(i), 4))];
float depthCheckP = GetLinearDepth(texture2D(depthtex0, texCoord + offset).r) * far;
float depthCheckN = GetLinearDepth(texture2D(depthtex0, texCoord - offset).r) * far;
outlined *= clamp(1.0 - ((depthCheckP + depthCheckN) - z * 2.0) * 32.0 / z, 0.0, 1.0);
if (i <= 4) maxz = max(maxz, max(depthCheckP, depthCheckN));
totalz += depthCheckP + depthCheckN;
}
float outlinea = 1.0 - clamp((z * 8.0 - totalz) * 64.0 / z, 0.0, 1.0) * clamp(1.0 - ((z * 8.0 - totalz) * 32.0 - 1.0) / z, 0.0, 1.0);
float outlineb = clamp(1.0 + 8.0 * (z - maxz) / z, 0.0, 1.0);
float outlinec = clamp(1.0 + 64.0 * (z - maxz) / z, 0.0, 1.0);
float outline = (0.35 * (outlinea * outlineb) + 0.65) * (0.75 * (1.0 - outlined) * outlinec + 1.0);
outline -= 1.0;
outline *= WORLD_OUTLINE_I / WORLD_OUTLINE_THICKNESSM;
if (outline < 0.0) outline = -outline * 0.25;
outline *= outlineFade;
#if RETRO_LOOK == 1
color = outline * 10.0 * vec3(RETRO_LOOK_R, RETRO_LOOK_G, RETRO_LOOK_B) * RETRO_LOOK_I;
#elif RETRO_LOOK == 2
color = mix(color, outline * 10.0 * vec3(RETRO_LOOK_R, RETRO_LOOK_G, RETRO_LOOK_B) * RETRO_LOOK_I, nightVision);
#else
color += min(color * outline * 2.5, vec3(outline));
#endif
}
vec2 worldOutlineOffset[4] = vec2[4] (
vec2(-1.0, 1.0),
vec2( 0, 1.0),
vec2( 1.0, 1.0),
vec2( 1.0, 0)
);
void DoWorldOutline(inout vec3 color, float linearZ0, float pixelFade, vec3 playerPos, float minecraft_far) {
float outlineFade = 1.0;
#ifdef DISTANT_HORIZONS
float horizontalDistance = length(playerPos.xz);
float verticalDistance = abs(playerPos.y);
float distanceToCamera = max(horizontalDistance, verticalDistance);
float fadeStart = minecraft_far * 0.7;
float fadeEnd = minecraft_far * 0.9;
if (fadeStart >= fadeEnd) {
fadeEnd = fadeStart + max(1.0, minecraft_far * 0.01);
}
outlineFade = (1.0 - smoothstep(fadeStart, fadeEnd, distanceToCamera)) * pixelFade;
if (outlineFade < 0.001) return;
#endif
vec2 scale = vec2(1.0 / view);
float outlines[2] = float[2] (0.0, 0.0);
float outlined = 1.0;
float z = linearZ0 * far;
float totalz = 0.0;
float maxz = 0.0;
float sampleza = 0.0;
float samplezb = 0.0;
#ifdef ENTITIES_ARE_LIGHT
#define WORLD_OUTLINE_THICKNESSM 4
#else
#define WORLD_OUTLINE_THICKNESSM WORLD_OUTLINE_THICKNESS
#endif
#if PIXELATED_SCREEN_SIZE > 0
int sampleCount = WORLD_OUTLINE_THICKNESSM * 4 + abs(9 - int(PIXELATED_SCREEN_SIZE_INTERNAL * 0.1));
#else
int sampleCount = WORLD_OUTLINE_THICKNESSM * 4;
#endif
for (int i = 0; i < sampleCount; i++) {
vec2 offset = (1.0 + floor(i / 4.0)) * scale * worldOutlineOffset[int(mod(float(i), 4))];
float depthCheckP = GetLinearDepth(texture2D(depthtex0, texCoord + offset).r) * far;
float depthCheckN = GetLinearDepth(texture2D(depthtex0, texCoord - offset).r) * far;
outlined *= clamp(1.0 - ((depthCheckP + depthCheckN) - z * 2.0) * 32.0 / z, 0.0, 1.0);
if (i <= 4) maxz = max(maxz, max(depthCheckP, depthCheckN));
totalz += depthCheckP + depthCheckN;
}
float outlinea = 1.0 - clamp((z * 8.0 - totalz) * 64.0 / z, 0.0, 1.0) * clamp(1.0 - ((z * 8.0 - totalz) * 32.0 - 1.0) / z, 0.0, 1.0);
float outlineb = clamp(1.0 + 8.0 * (z - maxz) / z, 0.0, 1.0);
float outlinec = clamp(1.0 + 64.0 * (z - maxz) / z, 0.0, 1.0);
float outline = (0.35 * (outlinea * outlineb) + 0.65) * (0.75 * (1.0 - outlined) * outlinec + 1.0);
outline -= 1.0;
outline *= WORLD_OUTLINE_I / WORLD_OUTLINE_THICKNESSM;
if (outline < 0.0) outline = -outline * 0.25;
outline *= outlineFade;
#if RETRO_LOOK == 1
color = outline * 10.0 * vec3(RETRO_LOOK_R, RETRO_LOOK_G, RETRO_LOOK_B) * RETRO_LOOK_I;
#elif RETRO_LOOK == 2
color = mix(color, outline * 10.0 * vec3(RETRO_LOOK_R, RETRO_LOOK_G, RETRO_LOOK_B) * RETRO_LOOK_I, nightVision);
#else
color += min(color * outline * 2.5, vec3(outline));
#endif
}