revert to vanilla assets
This commit is contained in:
26
public/assets/minecraft/shaders/core/animate_sprite.vsh
Normal file
26
public/assets/minecraft/shaders/core/animate_sprite.vsh
Normal file
@@ -0,0 +1,26 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:animation_sprite.glsl>
|
||||
|
||||
out float fAnimationProgress;
|
||||
out vec2 texCoord0;
|
||||
|
||||
const vec2[] positions = vec2[](
|
||||
vec2(0, 0),
|
||||
vec2(1, 0),
|
||||
vec2(0, 1),
|
||||
vec2(0, 1),
|
||||
vec2(1, 0),
|
||||
vec2(1, 1)
|
||||
);
|
||||
|
||||
void main() {
|
||||
int index = gl_VertexID & 7;
|
||||
float frameProgress = (gl_VertexID >> 3) / 1000.0;
|
||||
vec2 padding = vec2(UPadding, VPadding);
|
||||
gl_Position = ProjectionMatrix * SpriteMatrix * vec4(positions[index], 0, 1);
|
||||
vec2 uv = positions[index];
|
||||
vec2 direction = uv * 2.0 - 1.0;
|
||||
texCoord0 = uv + (padding * direction);
|
||||
fAnimationProgress = frameProgress;
|
||||
}
|
||||
14
public/assets/minecraft/shaders/core/animate_sprite_blit.fsh
Normal file
14
public/assets/minecraft/shaders/core/animate_sprite_blit.fsh
Normal file
@@ -0,0 +1,14 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:animation_sprite.glsl>
|
||||
|
||||
uniform sampler2D Sprite;
|
||||
|
||||
in vec2 texCoord0;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
vec4 color = textureLod(Sprite, texCoord0, MipMapLevel);
|
||||
fragColor = color;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:animation_sprite.glsl>
|
||||
|
||||
uniform sampler2D CurrentSprite;
|
||||
uniform sampler2D NextSprite;
|
||||
|
||||
in float fAnimationProgress;
|
||||
in vec2 texCoord0;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
vec4 currentColor = textureLod(CurrentSprite, texCoord0, MipMapLevel);
|
||||
vec4 nextColor = textureLod(NextSprite, texCoord0, MipMapLevel);
|
||||
fragColor = mix(currentColor, nextColor, fAnimationProgress);
|
||||
}
|
||||
11
public/assets/minecraft/shaders/core/blit_screen.fsh
Normal file
11
public/assets/minecraft/shaders/core/blit_screen.fsh
Normal file
@@ -0,0 +1,11 @@
|
||||
#version 330
|
||||
|
||||
uniform sampler2D InSampler;
|
||||
|
||||
in vec2 texCoord;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
fragColor = texture(InSampler, texCoord);
|
||||
}
|
||||
23
public/assets/minecraft/shaders/core/block.fsh
Normal file
23
public/assets/minecraft/shaders/core/block.fsh
Normal file
@@ -0,0 +1,23 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
|
||||
uniform sampler2D Sampler0;
|
||||
|
||||
in float sphericalVertexDistance;
|
||||
in float cylindricalVertexDistance;
|
||||
in vec4 vertexColor;
|
||||
in vec2 texCoord0;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
vec4 color = texture(Sampler0, texCoord0) * vertexColor * ColorModulator;
|
||||
#ifdef ALPHA_CUTOUT
|
||||
if (color.a < ALPHA_CUTOUT) {
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
fragColor = apply_fog(color, sphericalVertexDistance, cylindricalVertexDistance, FogEnvironmentalStart, FogEnvironmentalEnd, FogRenderDistanceStart, FogRenderDistanceEnd, FogColor);
|
||||
}
|
||||
28
public/assets/minecraft/shaders/core/block.vsh
Normal file
28
public/assets/minecraft/shaders/core/block.vsh
Normal file
@@ -0,0 +1,28 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
#moj_import <minecraft:projection.glsl>
|
||||
#moj_import <minecraft:sample_lightmap.glsl>
|
||||
|
||||
in vec3 Position;
|
||||
in vec4 Color;
|
||||
in vec2 UV0;
|
||||
in ivec2 UV2;
|
||||
|
||||
uniform sampler2D Sampler2;
|
||||
|
||||
out float sphericalVertexDistance;
|
||||
out float cylindricalVertexDistance;
|
||||
out vec4 vertexColor;
|
||||
out vec2 texCoord0;
|
||||
|
||||
void main() {
|
||||
vec3 pos = Position + ModelOffset;
|
||||
gl_Position = ProjMat * ModelViewMat * vec4(pos, 1.0);
|
||||
|
||||
sphericalVertexDistance = fog_spherical_distance(pos);
|
||||
cylindricalVertexDistance = fog_cylindrical_distance(pos);
|
||||
vertexColor = Color * sample_lightmap(Sampler2, UV2);
|
||||
texCoord0 = UV0;
|
||||
}
|
||||
18
public/assets/minecraft/shaders/core/debug_point.vsh
Normal file
18
public/assets/minecraft/shaders/core/debug_point.vsh
Normal file
@@ -0,0 +1,18 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:globals.glsl>
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
#moj_import <minecraft:projection.glsl>
|
||||
|
||||
in vec3 Position;
|
||||
in vec4 Color;
|
||||
in float LineWidth;
|
||||
|
||||
out vec4 vertexColor;
|
||||
|
||||
void main() {
|
||||
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);
|
||||
|
||||
vertexColor = Color;
|
||||
gl_PointSize = LineWidth;
|
||||
}
|
||||
64
public/assets/minecraft/shaders/core/entity.fsh
Normal file
64
public/assets/minecraft/shaders/core/entity.fsh
Normal file
@@ -0,0 +1,64 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
|
||||
uniform sampler2D Sampler0;
|
||||
|
||||
#ifdef DISSOLVE
|
||||
uniform sampler2D DissolveMaskSampler;
|
||||
#endif
|
||||
|
||||
in float sphericalVertexDistance;
|
||||
in float cylindricalVertexDistance;
|
||||
#ifdef PER_FACE_LIGHTING
|
||||
in vec4 vertexPerFaceColorBack;
|
||||
in vec4 vertexPerFaceColorFront;
|
||||
#else
|
||||
in vec4 vertexColor;
|
||||
#endif
|
||||
|
||||
#ifndef EMISSIVE
|
||||
in vec4 lightMapColor;
|
||||
#endif
|
||||
|
||||
#ifndef NO_OVERLAY
|
||||
in vec4 overlayColor;
|
||||
#endif
|
||||
|
||||
in vec2 texCoord0;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
vec4 color = texture(Sampler0, texCoord0);
|
||||
#ifdef ALPHA_CUTOUT
|
||||
if (color.a < ALPHA_CUTOUT) {
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PER_FACE_LIGHTING
|
||||
vec4 faceVertexColor = gl_FrontFacing ? vertexPerFaceColorFront : vertexPerFaceColorBack;
|
||||
#else
|
||||
vec4 faceVertexColor = vertexColor;
|
||||
#endif
|
||||
|
||||
#ifdef DISSOLVE
|
||||
if (faceVertexColor.a < texture(DissolveMaskSampler, texCoord0).a) {
|
||||
discard;
|
||||
}
|
||||
// The dissolve effect entirely replaces translucency
|
||||
faceVertexColor.a = 1.0;
|
||||
#endif
|
||||
|
||||
color *= faceVertexColor * ColorModulator;
|
||||
#ifndef NO_OVERLAY
|
||||
color.rgb = mix(overlayColor.rgb, color.rgb, overlayColor.a);
|
||||
#endif
|
||||
#ifndef EMISSIVE
|
||||
color *= lightMapColor;
|
||||
#endif
|
||||
|
||||
fragColor = apply_fog(color, sphericalVertexDistance, cylindricalVertexDistance, FogEnvironmentalStart, FogEnvironmentalEnd, FogRenderDistanceStart, FogRenderDistanceEnd, FogColor);
|
||||
}
|
||||
75
public/assets/minecraft/shaders/core/entity.vsh
Normal file
75
public/assets/minecraft/shaders/core/entity.vsh
Normal file
@@ -0,0 +1,75 @@
|
||||
#version 330
|
||||
|
||||
#if defined(PER_FACE_LIGHTING) || !defined(NO_CARDINAL_LIGHTING)
|
||||
#moj_import <minecraft:light.glsl>
|
||||
#endif
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
#moj_import <minecraft:projection.glsl>
|
||||
#moj_import <minecraft:sample_lightmap.glsl>
|
||||
|
||||
in vec3 Position;
|
||||
in vec4 Color;
|
||||
in vec2 UV0;
|
||||
in ivec2 UV1;
|
||||
in ivec2 UV2;
|
||||
in vec3 Normal;
|
||||
|
||||
#ifndef NO_OVERLAY
|
||||
uniform sampler2D Sampler1;
|
||||
#endif
|
||||
|
||||
#ifndef EMISSIVE
|
||||
uniform sampler2D Sampler2;
|
||||
#endif
|
||||
|
||||
out float sphericalVertexDistance;
|
||||
out float cylindricalVertexDistance;
|
||||
|
||||
#ifdef PER_FACE_LIGHTING
|
||||
out vec4 vertexPerFaceColorBack;
|
||||
out vec4 vertexPerFaceColorFront;
|
||||
#else
|
||||
out vec4 vertexColor;
|
||||
#endif
|
||||
|
||||
#ifndef EMISSIVE
|
||||
out vec4 lightMapColor;
|
||||
#endif
|
||||
|
||||
#ifndef NO_OVERLAY
|
||||
out vec4 overlayColor;
|
||||
#endif
|
||||
|
||||
out vec2 texCoord0;
|
||||
|
||||
void main() {
|
||||
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);
|
||||
|
||||
sphericalVertexDistance = fog_spherical_distance(Position);
|
||||
cylindricalVertexDistance = fog_cylindrical_distance(Position);
|
||||
|
||||
#ifdef PER_FACE_LIGHTING
|
||||
vec2 light = minecraft_compute_light(Light0_Direction, Light1_Direction, Normal);
|
||||
vertexPerFaceColorBack = minecraft_mix_light_separate(-light, Color);
|
||||
vertexPerFaceColorFront = minecraft_mix_light_separate(light, Color);
|
||||
#elif defined(NO_CARDINAL_LIGHTING)
|
||||
vertexColor = Color;
|
||||
#else
|
||||
vertexColor = minecraft_mix_light(Light0_Direction, Light1_Direction, Normal, Color);
|
||||
#endif
|
||||
|
||||
#ifndef EMISSIVE
|
||||
lightMapColor = sample_lightmap(Sampler2, UV2);
|
||||
#endif
|
||||
|
||||
#ifndef NO_OVERLAY
|
||||
overlayColor = texelFetch(Sampler1, UV1, 0);
|
||||
#endif
|
||||
|
||||
texCoord0 = UV0;
|
||||
|
||||
#ifdef APPLY_TEXTURE_MATRIX
|
||||
texCoord0 = (TextureMat * vec4(UV0, 0.0, 1.0)).xy;
|
||||
#endif
|
||||
}
|
||||
22
public/assets/minecraft/shaders/core/glint.fsh
Normal file
22
public/assets/minecraft/shaders/core/glint.fsh
Normal file
@@ -0,0 +1,22 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:globals.glsl>
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
|
||||
uniform sampler2D Sampler0;
|
||||
|
||||
in float sphericalVertexDistance;
|
||||
in float cylindricalVertexDistance;
|
||||
in vec2 texCoord0;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
vec4 color = texture(Sampler0, texCoord0) * ColorModulator;
|
||||
if (color.a < 0.1) {
|
||||
discard;
|
||||
}
|
||||
float fade = (1.0f - total_fog_value(sphericalVertexDistance, cylindricalVertexDistance, FogEnvironmentalStart, FogEnvironmentalEnd, FogRenderDistanceStart, FogRenderDistanceEnd)) * GlintAlpha;
|
||||
fragColor = vec4(color.rgb * fade, color.a);
|
||||
}
|
||||
20
public/assets/minecraft/shaders/core/glint.vsh
Normal file
20
public/assets/minecraft/shaders/core/glint.vsh
Normal file
@@ -0,0 +1,20 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
#moj_import <minecraft:projection.glsl>
|
||||
|
||||
in vec3 Position;
|
||||
in vec2 UV0;
|
||||
|
||||
out float sphericalVertexDistance;
|
||||
out float cylindricalVertexDistance;
|
||||
out vec2 texCoord0;
|
||||
|
||||
void main() {
|
||||
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);
|
||||
|
||||
sphericalVertexDistance = fog_spherical_distance(Position);
|
||||
cylindricalVertexDistance = fog_cylindrical_distance(Position);
|
||||
texCoord0 = (TextureMat * vec4(UV0, 0.0, 1.0)).xy;
|
||||
}
|
||||
22
public/assets/minecraft/shaders/core/gui.fsh
Normal file
22
public/assets/minecraft/shaders/core/gui.fsh
Normal file
@@ -0,0 +1,22 @@
|
||||
#version 330
|
||||
|
||||
// Can't moj_import in things used during startup, when resource packs don't exist.
|
||||
// This is a copy of dynamicimports.glsl
|
||||
layout(std140) uniform DynamicTransforms {
|
||||
mat4 ModelViewMat;
|
||||
vec4 ColorModulator;
|
||||
vec3 ModelOffset;
|
||||
mat4 TextureMat;
|
||||
};
|
||||
|
||||
in vec4 vertexColor;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
vec4 color = vertexColor;
|
||||
if (color.a == 0.0) {
|
||||
discard;
|
||||
}
|
||||
fragColor = color * ColorModulator;
|
||||
}
|
||||
24
public/assets/minecraft/shaders/core/gui.vsh
Normal file
24
public/assets/minecraft/shaders/core/gui.vsh
Normal file
@@ -0,0 +1,24 @@
|
||||
#version 330
|
||||
|
||||
// Can't moj_import in things used during startup, when resource packs don't exist.
|
||||
// This is a copy of dynamicimports.glsl and projection.glsl
|
||||
layout(std140) uniform DynamicTransforms {
|
||||
mat4 ModelViewMat;
|
||||
vec4 ColorModulator;
|
||||
vec3 ModelOffset;
|
||||
mat4 TextureMat;
|
||||
};
|
||||
layout(std140) uniform Projection {
|
||||
mat4 ProjMat;
|
||||
};
|
||||
|
||||
in vec3 Position;
|
||||
in vec4 Color;
|
||||
|
||||
out vec4 vertexColor;
|
||||
|
||||
void main() {
|
||||
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);
|
||||
|
||||
vertexColor = Color;
|
||||
}
|
||||
30
public/assets/minecraft/shaders/core/item.fsh
Normal file
30
public/assets/minecraft/shaders/core/item.fsh
Normal file
@@ -0,0 +1,30 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
|
||||
uniform sampler2D Sampler0;
|
||||
|
||||
in float sphericalVertexDistance;
|
||||
in float cylindricalVertexDistance;
|
||||
in vec4 vertexColor;
|
||||
in vec4 lightMapColor;
|
||||
in vec4 overlayColor;
|
||||
in vec2 texCoord0;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
vec4 color = texture(Sampler0, texCoord0);
|
||||
#ifdef ALPHA_CUTOUT
|
||||
if (color.a < ALPHA_CUTOUT) {
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
|
||||
color *= vertexColor * ColorModulator;
|
||||
color.rgb = mix(overlayColor.rgb, color.rgb, overlayColor.a);
|
||||
color *= lightMapColor;
|
||||
|
||||
fragColor = apply_fog(color, sphericalVertexDistance, cylindricalVertexDistance, FogEnvironmentalStart, FogEnvironmentalEnd, FogRenderDistanceStart, FogRenderDistanceEnd, FogColor);
|
||||
}
|
||||
38
public/assets/minecraft/shaders/core/item.vsh
Normal file
38
public/assets/minecraft/shaders/core/item.vsh
Normal file
@@ -0,0 +1,38 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:light.glsl>
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
#moj_import <minecraft:projection.glsl>
|
||||
#moj_import <minecraft:sample_lightmap.glsl>
|
||||
|
||||
in vec3 Position;
|
||||
in vec4 Color;
|
||||
in vec2 UV0;
|
||||
in ivec2 UV1;
|
||||
in ivec2 UV2;
|
||||
in vec3 Normal;
|
||||
|
||||
uniform sampler2D Sampler1;
|
||||
uniform sampler2D Sampler2;
|
||||
|
||||
out float sphericalVertexDistance;
|
||||
out float cylindricalVertexDistance;
|
||||
out vec4 vertexColor;
|
||||
out vec4 lightMapColor;
|
||||
out vec4 overlayColor;
|
||||
|
||||
out vec2 texCoord0;
|
||||
|
||||
void main() {
|
||||
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);
|
||||
|
||||
sphericalVertexDistance = fog_spherical_distance(Position);
|
||||
cylindricalVertexDistance = fog_cylindrical_distance(Position);
|
||||
|
||||
vertexColor = minecraft_mix_light(Light0_Direction, Light1_Direction, Normal, Color);
|
||||
lightMapColor = sample_lightmap(Sampler2, UV2);
|
||||
overlayColor = texelFetch(Sampler1, UV1, 0);
|
||||
|
||||
texCoord0 = UV0;
|
||||
}
|
||||
66
public/assets/minecraft/shaders/core/lightmap.fsh
Normal file
66
public/assets/minecraft/shaders/core/lightmap.fsh
Normal file
@@ -0,0 +1,66 @@
|
||||
#version 330
|
||||
|
||||
layout(std140) uniform LightmapInfo {
|
||||
float SkyFactor;
|
||||
float BlockFactor;
|
||||
float NightVisionFactor;
|
||||
float DarknessScale;
|
||||
float BossOverlayWorldDarkeningFactor;
|
||||
float BrightnessFactor;
|
||||
vec3 BlockLightTint;
|
||||
vec3 SkyLightColor;
|
||||
vec3 AmbientColor;
|
||||
vec3 NightVisionColor;
|
||||
} lightmapInfo;
|
||||
|
||||
in vec2 texCoord;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
float get_brightness(float level) {
|
||||
return level / (4.0 - 3.0 * level);
|
||||
}
|
||||
|
||||
vec3 notGamma(vec3 color) {
|
||||
float maxComponent = max(max(color.x, color.y), color.z);
|
||||
float maxInverted = 1.0f - maxComponent;
|
||||
float maxScaled = 1.0f - maxInverted * maxInverted * maxInverted * maxInverted;
|
||||
return color * (maxScaled / maxComponent);
|
||||
}
|
||||
|
||||
float parabolicMixFactor(float level) {
|
||||
return (2.0 * level - 1.0) * (2.0 * level - 1.0);
|
||||
}
|
||||
|
||||
void main() {
|
||||
// Calculate block and sky brightness levels based on texture coordinates
|
||||
float block_level = floor(texCoord.x * 16) / 15;
|
||||
float sky_level = floor(texCoord.y * 16) / 15;
|
||||
|
||||
float block_brightness = get_brightness(block_level) * lightmapInfo.BlockFactor;
|
||||
float sky_brightness = get_brightness(sky_level) * lightmapInfo.SkyFactor;
|
||||
|
||||
// Calculate ambient color with or without night vision
|
||||
vec3 nightVisionColor = lightmapInfo.NightVisionColor * lightmapInfo.NightVisionFactor;
|
||||
vec3 color = max(lightmapInfo.AmbientColor, nightVisionColor);
|
||||
|
||||
// Add sky light
|
||||
color += lightmapInfo.SkyLightColor * sky_brightness;
|
||||
|
||||
// Add block light
|
||||
vec3 BlockLightColor = mix(lightmapInfo.BlockLightTint, vec3(1.0), 0.9 * parabolicMixFactor(block_level));
|
||||
color += BlockLightColor * block_brightness;
|
||||
|
||||
// Apply boss overlay darkening effect
|
||||
color = mix(color, color * vec3(0.7, 0.6, 0.6), lightmapInfo.BossOverlayWorldDarkeningFactor);
|
||||
|
||||
// Apply darkness effect scale
|
||||
color = color - vec3(lightmapInfo.DarknessScale);
|
||||
|
||||
// Apply brightness
|
||||
color = clamp(color, 0.0, 1.0);
|
||||
vec3 notGamma = notGamma(color);
|
||||
color = mix(color, notGamma, lightmapInfo.BrightnessFactor);
|
||||
|
||||
fragColor = vec4(color, 1.0);
|
||||
}
|
||||
11
public/assets/minecraft/shaders/core/panorama.fsh
Normal file
11
public/assets/minecraft/shaders/core/panorama.fsh
Normal file
@@ -0,0 +1,11 @@
|
||||
#version 330
|
||||
|
||||
uniform samplerCube Sampler0;
|
||||
|
||||
in vec3 texCoord0;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
fragColor = texture(Sampler0, texCoord0);
|
||||
}
|
||||
13
public/assets/minecraft/shaders/core/panorama.vsh
Normal file
13
public/assets/minecraft/shaders/core/panorama.vsh
Normal file
@@ -0,0 +1,13 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
#moj_import <minecraft:projection.glsl>
|
||||
|
||||
in vec3 Position;
|
||||
out vec3 texCoord0;
|
||||
|
||||
void main() {
|
||||
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);
|
||||
|
||||
texCoord0 = Position;
|
||||
}
|
||||
21
public/assets/minecraft/shaders/core/particle.fsh
Normal file
21
public/assets/minecraft/shaders/core/particle.fsh
Normal file
@@ -0,0 +1,21 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
|
||||
uniform sampler2D Sampler0;
|
||||
|
||||
in float sphericalVertexDistance;
|
||||
in float cylindricalVertexDistance;
|
||||
in vec2 texCoord0;
|
||||
in vec4 vertexColor;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
vec4 color = texture(Sampler0, texCoord0) * vertexColor * ColorModulator;
|
||||
if (color.a < 0.1) {
|
||||
discard;
|
||||
}
|
||||
fragColor = apply_fog(color, sphericalVertexDistance, cylindricalVertexDistance, FogEnvironmentalStart, FogEnvironmentalEnd, FogRenderDistanceStart, FogRenderDistanceEnd, FogColor);
|
||||
}
|
||||
27
public/assets/minecraft/shaders/core/particle.vsh
Normal file
27
public/assets/minecraft/shaders/core/particle.vsh
Normal file
@@ -0,0 +1,27 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
#moj_import <minecraft:projection.glsl>
|
||||
#moj_import <minecraft:sample_lightmap.glsl>
|
||||
|
||||
in vec3 Position;
|
||||
in vec2 UV0;
|
||||
in vec4 Color;
|
||||
in ivec2 UV2;
|
||||
|
||||
uniform sampler2D Sampler2;
|
||||
|
||||
out float sphericalVertexDistance;
|
||||
out float cylindricalVertexDistance;
|
||||
out vec2 texCoord0;
|
||||
out vec4 vertexColor;
|
||||
|
||||
void main() {
|
||||
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);
|
||||
|
||||
sphericalVertexDistance = fog_spherical_distance(Position);
|
||||
cylindricalVertexDistance = fog_cylindrical_distance(Position);
|
||||
texCoord0 = UV0;
|
||||
vertexColor = Color * sample_lightmap(Sampler2, UV2);
|
||||
}
|
||||
13
public/assets/minecraft/shaders/core/position.fsh
Normal file
13
public/assets/minecraft/shaders/core/position.fsh
Normal file
@@ -0,0 +1,13 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
|
||||
in float sphericalVertexDistance;
|
||||
in float cylindricalVertexDistance;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
fragColor = apply_fog(ColorModulator, sphericalVertexDistance, cylindricalVertexDistance, FogEnvironmentalStart, FogEnvironmentalEnd, FogRenderDistanceStart, FogRenderDistanceEnd, FogColor);
|
||||
}
|
||||
17
public/assets/minecraft/shaders/core/position.vsh
Normal file
17
public/assets/minecraft/shaders/core/position.vsh
Normal file
@@ -0,0 +1,17 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
#moj_import <minecraft:projection.glsl>
|
||||
|
||||
in vec3 Position;
|
||||
|
||||
out float sphericalVertexDistance;
|
||||
out float cylindricalVertexDistance;
|
||||
|
||||
void main() {
|
||||
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);
|
||||
|
||||
sphericalVertexDistance = fog_spherical_distance(Position);
|
||||
cylindricalVertexDistance = fog_cylindrical_distance(Position);
|
||||
}
|
||||
15
public/assets/minecraft/shaders/core/position_color.fsh
Normal file
15
public/assets/minecraft/shaders/core/position_color.fsh
Normal file
@@ -0,0 +1,15 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
|
||||
in vec4 vertexColor;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
vec4 color = vertexColor;
|
||||
if (color.a == 0.0) {
|
||||
discard;
|
||||
}
|
||||
fragColor = color * ColorModulator;
|
||||
}
|
||||
15
public/assets/minecraft/shaders/core/position_color.vsh
Normal file
15
public/assets/minecraft/shaders/core/position_color.vsh
Normal file
@@ -0,0 +1,15 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
#moj_import <minecraft:projection.glsl>
|
||||
|
||||
in vec3 Position;
|
||||
in vec4 Color;
|
||||
|
||||
out vec4 vertexColor;
|
||||
|
||||
void main() {
|
||||
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);
|
||||
|
||||
vertexColor = Color;
|
||||
}
|
||||
17
public/assets/minecraft/shaders/core/position_tex.fsh
Normal file
17
public/assets/minecraft/shaders/core/position_tex.fsh
Normal file
@@ -0,0 +1,17 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
|
||||
uniform sampler2D Sampler0;
|
||||
|
||||
in vec2 texCoord0;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
vec4 color = texture(Sampler0, texCoord0);
|
||||
if (color.a == 0.0) {
|
||||
discard;
|
||||
}
|
||||
fragColor = color * ColorModulator;
|
||||
}
|
||||
15
public/assets/minecraft/shaders/core/position_tex.vsh
Normal file
15
public/assets/minecraft/shaders/core/position_tex.vsh
Normal file
@@ -0,0 +1,15 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
#moj_import <minecraft:projection.glsl>
|
||||
|
||||
in vec3 Position;
|
||||
in vec2 UV0;
|
||||
|
||||
out vec2 texCoord0;
|
||||
|
||||
void main() {
|
||||
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);
|
||||
|
||||
texCoord0 = UV0;
|
||||
}
|
||||
25
public/assets/minecraft/shaders/core/position_tex_color.fsh
Normal file
25
public/assets/minecraft/shaders/core/position_tex_color.fsh
Normal file
@@ -0,0 +1,25 @@
|
||||
#version 330
|
||||
|
||||
// Can't moj_import in things used during startup, when resource packs don't exist.
|
||||
// This is a copy of dynamicimports.glsl
|
||||
layout(std140) uniform DynamicTransforms {
|
||||
mat4 ModelViewMat;
|
||||
vec4 ColorModulator;
|
||||
vec3 ModelOffset;
|
||||
mat4 TextureMat;
|
||||
};
|
||||
|
||||
uniform sampler2D Sampler0;
|
||||
|
||||
in vec2 texCoord0;
|
||||
in vec4 vertexColor;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
vec4 color = texture(Sampler0, texCoord0) * vertexColor;
|
||||
if (color.a == 0.0) {
|
||||
discard;
|
||||
}
|
||||
fragColor = color * ColorModulator;
|
||||
}
|
||||
27
public/assets/minecraft/shaders/core/position_tex_color.vsh
Normal file
27
public/assets/minecraft/shaders/core/position_tex_color.vsh
Normal file
@@ -0,0 +1,27 @@
|
||||
#version 330
|
||||
|
||||
// Can't moj_import in things used during startup, when resource packs don't exist.
|
||||
// This is a copy of dynamicimports.glsl and projection.glsl
|
||||
layout(std140) uniform DynamicTransforms {
|
||||
mat4 ModelViewMat;
|
||||
vec4 ColorModulator;
|
||||
vec3 ModelOffset;
|
||||
mat4 TextureMat;
|
||||
};
|
||||
layout(std140) uniform Projection {
|
||||
mat4 ProjMat;
|
||||
};
|
||||
|
||||
in vec3 Position;
|
||||
in vec2 UV0;
|
||||
in vec4 Color;
|
||||
|
||||
out vec2 texCoord0;
|
||||
out vec4 vertexColor;
|
||||
|
||||
void main() {
|
||||
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);
|
||||
|
||||
texCoord0 = UV0;
|
||||
vertexColor = Color;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
#moj_import <minecraft:projection.glsl>
|
||||
|
||||
uniform sampler2D Sampler0;
|
||||
|
||||
in vec4 vertexColor;
|
||||
in vec2 texCoord0;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
vec4 color = texture(Sampler0, texCoord0);
|
||||
color *= vertexColor * ColorModulator;
|
||||
float fragmentDistance = 1.0 / gl_FragCoord.w;
|
||||
fragColor = apply_fog(color, fragmentDistance, fragmentDistance, FogEnvironmentalStart, FogEnvironmentalEnd, FogRenderDistanceStart, FogRenderDistanceEnd, FogColor);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
#moj_import <minecraft:projection.glsl>
|
||||
|
||||
in vec3 Position;
|
||||
in vec4 Color;
|
||||
in vec2 UV0;
|
||||
|
||||
out vec4 vertexColor;
|
||||
out vec2 texCoord0;
|
||||
|
||||
void main() {
|
||||
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);
|
||||
|
||||
vertexColor = Color;
|
||||
texCoord0 = UV0;
|
||||
}
|
||||
15
public/assets/minecraft/shaders/core/rendertype_clouds.fsh
Normal file
15
public/assets/minecraft/shaders/core/rendertype_clouds.fsh
Normal file
@@ -0,0 +1,15 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
|
||||
|
||||
in float vertexDistance;
|
||||
in vec4 vertexColor;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
vec4 color = vertexColor;
|
||||
color.a *= 1.0f - linear_fog_value(vertexDistance, 0, FogCloudsEnd);
|
||||
fragColor = color;
|
||||
}
|
||||
90
public/assets/minecraft/shaders/core/rendertype_clouds.vsh
Normal file
90
public/assets/minecraft/shaders/core/rendertype_clouds.vsh
Normal file
@@ -0,0 +1,90 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
#moj_import <minecraft:projection.glsl>
|
||||
|
||||
const int FLAG_MASK_DIR = 7;
|
||||
const int FLAG_INSIDE_FACE = 1 << 4;
|
||||
const int FLAG_USE_TOP_COLOR = 1 << 5;
|
||||
const int FLAG_EXTRA_Z = 1 << 6;
|
||||
const int FLAG_EXTRA_X = 1 << 7;
|
||||
|
||||
layout(std140) uniform CloudInfo {
|
||||
vec4 CloudColor;
|
||||
vec3 CloudOffset;
|
||||
vec3 CellSize;
|
||||
};
|
||||
|
||||
uniform isamplerBuffer CloudFaces;
|
||||
|
||||
out float vertexDistance;
|
||||
out vec4 vertexColor;
|
||||
|
||||
const vec3[] vertices = vec3[](
|
||||
// Bottom face
|
||||
vec3(1, 0, 0),
|
||||
vec3(1, 0, 1),
|
||||
vec3(0, 0, 1),
|
||||
vec3(0, 0, 0),
|
||||
// Top face
|
||||
vec3(0, 1, 0),
|
||||
vec3(0, 1, 1),
|
||||
vec3(1, 1, 1),
|
||||
vec3(1, 1, 0),
|
||||
// North face
|
||||
vec3(0, 0, 0),
|
||||
vec3(0, 1, 0),
|
||||
vec3(1, 1, 0),
|
||||
vec3(1, 0, 0),
|
||||
// South face
|
||||
vec3(1, 0, 1),
|
||||
vec3(1, 1, 1),
|
||||
vec3(0, 1, 1),
|
||||
vec3(0, 0, 1),
|
||||
// West face
|
||||
vec3(0, 0, 1),
|
||||
vec3(0, 1, 1),
|
||||
vec3(0, 1, 0),
|
||||
vec3(0, 0, 0),
|
||||
// East face
|
||||
vec3(1, 0, 0),
|
||||
vec3(1, 1, 0),
|
||||
vec3(1, 1, 1),
|
||||
vec3(1, 0, 1)
|
||||
);
|
||||
|
||||
const vec4[] faceColors = vec4[](
|
||||
// Bottom face
|
||||
vec4(0.7, 0.7, 0.7, 1.0),
|
||||
// Top face
|
||||
vec4(1.0, 1.0, 1.0, 1.0),
|
||||
// North face
|
||||
vec4(0.8, 0.8, 0.8, 1.0),
|
||||
// South face
|
||||
vec4(0.8, 0.8, 0.8, 1.0),
|
||||
// West face
|
||||
vec4(0.9, 0.9, 0.9, 1.0),
|
||||
// East face
|
||||
vec4(0.9, 0.9, 0.9, 1.0)
|
||||
);
|
||||
|
||||
void main() {
|
||||
int quadVertex = gl_VertexID % 4;
|
||||
int index = (gl_VertexID / 4) * 3;
|
||||
|
||||
int cellX = texelFetch(CloudFaces, index).r;
|
||||
int cellZ = texelFetch(CloudFaces, index + 1).r;
|
||||
int dirAndFlags = texelFetch(CloudFaces, index + 2).r;
|
||||
int direction = dirAndFlags & FLAG_MASK_DIR;
|
||||
bool isInsideFace = (dirAndFlags & FLAG_INSIDE_FACE) == FLAG_INSIDE_FACE;
|
||||
bool useTopColor = (dirAndFlags & FLAG_USE_TOP_COLOR) == FLAG_USE_TOP_COLOR;
|
||||
cellX = (cellX << 1) | ((dirAndFlags & FLAG_EXTRA_X) >> 7);
|
||||
cellZ = (cellZ << 1) | ((dirAndFlags & FLAG_EXTRA_Z) >> 6);
|
||||
vec3 faceVertex = vertices[(direction * 4) + (isInsideFace ? 3 - quadVertex : quadVertex)];
|
||||
vec3 pos = (faceVertex * CellSize) + (vec3(cellX, 0, cellZ) * CellSize) + CloudOffset;
|
||||
gl_Position = ProjMat * ModelViewMat * vec4(pos, 1.0);
|
||||
|
||||
vertexDistance = fog_spherical_distance(pos);
|
||||
vertexColor = (useTopColor ? faceColors[1] : faceColors[direction]) * CloudColor;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
|
||||
uniform sampler2D Sampler0;
|
||||
|
||||
in float sphericalVertexDistance;
|
||||
in float cylindricalVertexDistance;
|
||||
in vec4 vertexColor;
|
||||
in vec2 texCoord0;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
vec4 color = texture(Sampler0, texCoord0) * vertexColor;
|
||||
if (color.a < 0.1) {
|
||||
discard;
|
||||
}
|
||||
color = color * ColorModulator;
|
||||
fragColor = apply_fog(color, sphericalVertexDistance, cylindricalVertexDistance, FogEnvironmentalStart, FogEnvironmentalEnd, FogRenderDistanceStart, FogRenderDistanceEnd, FogColor);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
#moj_import <minecraft:projection.glsl>
|
||||
|
||||
in vec3 Position;
|
||||
in vec4 Color;
|
||||
in vec2 UV0;
|
||||
in ivec2 UV2;
|
||||
|
||||
out float sphericalVertexDistance;
|
||||
out float cylindricalVertexDistance;
|
||||
out vec4 vertexColor;
|
||||
out vec2 texCoord0;
|
||||
|
||||
void main() {
|
||||
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);
|
||||
|
||||
sphericalVertexDistance = fog_spherical_distance(Position);
|
||||
cylindricalVertexDistance = fog_cylindrical_distance(Position);
|
||||
vertexColor = Color;
|
||||
texCoord0 = UV0;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:matrix.glsl>
|
||||
#moj_import <minecraft:globals.glsl>
|
||||
|
||||
uniform sampler2D Sampler0;
|
||||
uniform sampler2D Sampler1;
|
||||
|
||||
in vec4 texProj0;
|
||||
in float sphericalVertexDistance;
|
||||
in float cylindricalVertexDistance;
|
||||
|
||||
const vec3[] COLORS = vec3[](
|
||||
vec3(0.022087, 0.098399, 0.110818),
|
||||
vec3(0.011892, 0.095924, 0.089485),
|
||||
vec3(0.027636, 0.101689, 0.100326),
|
||||
vec3(0.046564, 0.109883, 0.114838),
|
||||
vec3(0.064901, 0.117696, 0.097189),
|
||||
vec3(0.063761, 0.086895, 0.123646),
|
||||
vec3(0.084817, 0.111994, 0.166380),
|
||||
vec3(0.097489, 0.154120, 0.091064),
|
||||
vec3(0.106152, 0.131144, 0.195191),
|
||||
vec3(0.097721, 0.110188, 0.187229),
|
||||
vec3(0.133516, 0.138278, 0.148582),
|
||||
vec3(0.070006, 0.243332, 0.235792),
|
||||
vec3(0.196766, 0.142899, 0.214696),
|
||||
vec3(0.047281, 0.315338, 0.321970),
|
||||
vec3(0.204675, 0.390010, 0.302066),
|
||||
vec3(0.080955, 0.314821, 0.661491)
|
||||
);
|
||||
|
||||
const mat4 SCALE_TRANSLATE = mat4(
|
||||
0.5, 0.0, 0.0, 0.25,
|
||||
0.0, 0.5, 0.0, 0.25,
|
||||
0.0, 0.0, 1.0, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0
|
||||
);
|
||||
|
||||
mat4 end_portal_layer(float layer) {
|
||||
mat4 translate = mat4(
|
||||
1.0, 0.0, 0.0, 17.0 / layer,
|
||||
0.0, 1.0, 0.0, (2.0 + layer / 1.5) * (GameTime * 1.5),
|
||||
0.0, 0.0, 1.0, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0
|
||||
);
|
||||
|
||||
mat2 rotate = mat2_rotate_z(radians((layer * layer * 4321.0 + layer * 9.0) * 2.0));
|
||||
|
||||
mat2 scale = mat2((4.5 - layer / 4.0) * 2.0);
|
||||
|
||||
return mat4(scale * rotate) * translate * SCALE_TRANSLATE;
|
||||
}
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
vec3 color = textureProj(Sampler0, texProj0).rgb * COLORS[0];
|
||||
for (int i = 0; i < PORTAL_LAYERS; i++) {
|
||||
color += textureProj(Sampler1, texProj0 * end_portal_layer(float(i + 1))).rgb * COLORS[i];
|
||||
}
|
||||
fragColor = apply_fog(vec4(color, 1.0), sphericalVertexDistance, cylindricalVertexDistance, FogEnvironmentalStart, FogEnvironmentalEnd, FogRenderDistanceStart, FogRenderDistanceEnd, FogColor);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:projection.glsl>
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
#moj_import <minecraft:projection.glsl>
|
||||
|
||||
in vec3 Position;
|
||||
|
||||
out vec4 texProj0;
|
||||
out float sphericalVertexDistance;
|
||||
out float cylindricalVertexDistance;
|
||||
|
||||
void main() {
|
||||
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);
|
||||
|
||||
texProj0 = projection_from_position(gl_Position);
|
||||
sphericalVertexDistance = fog_spherical_distance(Position);
|
||||
cylindricalVertexDistance = fog_cylindrical_distance(Position);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
|
||||
uniform sampler2D Sampler0;
|
||||
|
||||
in float sphericalVertexDistance;
|
||||
in float cylindricalVertexDistance;
|
||||
in vec4 vertexColor;
|
||||
in vec2 texCoord0;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
vec4 color = texture(Sampler0, clamp(texCoord0, 0.0, 1.0));
|
||||
color *= vertexColor * ColorModulator;
|
||||
fragColor = apply_fog(color, sphericalVertexDistance, cylindricalVertexDistance, FogEnvironmentalStart, FogEnvironmentalEnd, FogRenderDistanceStart, FogRenderDistanceEnd, FogColor);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
#moj_import <minecraft:projection.glsl>
|
||||
|
||||
in vec3 Position;
|
||||
in vec4 Color;
|
||||
in vec2 UV0;
|
||||
|
||||
out float sphericalVertexDistance;
|
||||
out float cylindricalVertexDistance;
|
||||
out vec4 vertexColor;
|
||||
out vec2 texCoord0;
|
||||
|
||||
void main() {
|
||||
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);
|
||||
|
||||
sphericalVertexDistance = fog_spherical_distance(Position);
|
||||
cylindricalVertexDistance = fog_cylindrical_distance(Position);
|
||||
vertexColor = Color;
|
||||
texCoord0 = UV0;
|
||||
}
|
||||
14
public/assets/minecraft/shaders/core/rendertype_leash.fsh
Normal file
14
public/assets/minecraft/shaders/core/rendertype_leash.fsh
Normal file
@@ -0,0 +1,14 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
|
||||
|
||||
in float sphericalVertexDistance;
|
||||
in float cylindricalVertexDistance;
|
||||
flat in vec4 vertexColor;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
fragColor = apply_fog(vertexColor, sphericalVertexDistance, cylindricalVertexDistance, FogEnvironmentalStart, FogEnvironmentalEnd, FogRenderDistanceStart, FogRenderDistanceEnd, FogColor);
|
||||
}
|
||||
24
public/assets/minecraft/shaders/core/rendertype_leash.vsh
Normal file
24
public/assets/minecraft/shaders/core/rendertype_leash.vsh
Normal file
@@ -0,0 +1,24 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
#moj_import <minecraft:projection.glsl>
|
||||
#moj_import <minecraft:sample_lightmap.glsl>
|
||||
|
||||
in vec3 Position;
|
||||
in vec4 Color;
|
||||
in ivec2 UV2;
|
||||
|
||||
uniform sampler2D Sampler2;
|
||||
|
||||
out float sphericalVertexDistance;
|
||||
out float cylindricalVertexDistance;
|
||||
flat out vec4 vertexColor;
|
||||
|
||||
void main() {
|
||||
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);
|
||||
|
||||
sphericalVertexDistance = fog_spherical_distance(Position);
|
||||
cylindricalVertexDistance = fog_cylindrical_distance(Position);
|
||||
vertexColor = Color * ColorModulator * sample_lightmap(Sampler2, UV2);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
|
||||
in float sphericalVertexDistance;
|
||||
in float cylindricalVertexDistance;
|
||||
in vec4 vertexColor;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
fragColor = vertexColor * ColorModulator * (1.0f - total_fog_value(sphericalVertexDistance, cylindricalVertexDistance, FogEnvironmentalStart, FogEnvironmentalEnd, FogRenderDistanceStart, FogRenderDistanceEnd));
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
#moj_import <minecraft:projection.glsl>
|
||||
|
||||
in vec3 Position;
|
||||
in vec4 Color;
|
||||
|
||||
out float sphericalVertexDistance;
|
||||
out float cylindricalVertexDistance;
|
||||
out vec4 vertexColor;
|
||||
|
||||
void main() {
|
||||
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);
|
||||
|
||||
sphericalVertexDistance = fog_spherical_distance(Position);
|
||||
cylindricalVertexDistance = fog_cylindrical_distance(Position);
|
||||
vertexColor = Color;
|
||||
}
|
||||
15
public/assets/minecraft/shaders/core/rendertype_lines.fsh
Normal file
15
public/assets/minecraft/shaders/core/rendertype_lines.fsh
Normal file
@@ -0,0 +1,15 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
|
||||
in float sphericalVertexDistance;
|
||||
in float cylindricalVertexDistance;
|
||||
in vec4 vertexColor;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
vec4 color = vertexColor * ColorModulator;
|
||||
fragColor = apply_fog(color, sphericalVertexDistance, cylindricalVertexDistance, FogEnvironmentalStart, FogEnvironmentalEnd, FogRenderDistanceStart, FogRenderDistanceEnd, FogColor);
|
||||
}
|
||||
48
public/assets/minecraft/shaders/core/rendertype_lines.vsh
Normal file
48
public/assets/minecraft/shaders/core/rendertype_lines.vsh
Normal file
@@ -0,0 +1,48 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:globals.glsl>
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
#moj_import <minecraft:projection.glsl>
|
||||
|
||||
in vec3 Position;
|
||||
in vec4 Color;
|
||||
in vec3 Normal;
|
||||
in float LineWidth;
|
||||
|
||||
out float sphericalVertexDistance;
|
||||
out float cylindricalVertexDistance;
|
||||
out vec4 vertexColor;
|
||||
|
||||
const float VIEW_SHRINK = 1.0 - (1.0 / 256.0);
|
||||
const mat4 VIEW_SCALE = mat4(
|
||||
VIEW_SHRINK, 0.0, 0.0, 0.0,
|
||||
0.0, VIEW_SHRINK, 0.0, 0.0,
|
||||
0.0, 0.0, VIEW_SHRINK, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0
|
||||
);
|
||||
|
||||
void main() {
|
||||
vec4 linePosStart = ProjMat * VIEW_SCALE * ModelViewMat * vec4(Position, 1.0);
|
||||
vec4 linePosEnd = ProjMat * VIEW_SCALE * ModelViewMat * vec4(Position + Normal, 1.0);
|
||||
|
||||
vec3 ndc1 = linePosStart.xyz / linePosStart.w;
|
||||
vec3 ndc2 = linePosEnd.xyz / linePosEnd.w;
|
||||
|
||||
vec2 lineScreenDirection = normalize((ndc2.xy - ndc1.xy) * ScreenSize);
|
||||
vec2 lineOffset = vec2(-lineScreenDirection.y, lineScreenDirection.x) * LineWidth / ScreenSize;
|
||||
|
||||
if (lineOffset.x < 0.0) {
|
||||
lineOffset *= -1.0;
|
||||
}
|
||||
|
||||
if (gl_VertexID % 2 == 0) {
|
||||
gl_Position = vec4((ndc1 + vec3(lineOffset, 0.0)) * linePosStart.w, linePosStart.w);
|
||||
} else {
|
||||
gl_Position = vec4((ndc1 - vec3(lineOffset, 0.0)) * linePosStart.w, linePosStart.w);
|
||||
}
|
||||
|
||||
sphericalVertexDistance = fog_spherical_distance(Position);
|
||||
cylindricalVertexDistance = fog_cylindrical_distance(Position);
|
||||
vertexColor = Color;
|
||||
}
|
||||
18
public/assets/minecraft/shaders/core/rendertype_outline.fsh
Normal file
18
public/assets/minecraft/shaders/core/rendertype_outline.fsh
Normal file
@@ -0,0 +1,18 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
|
||||
uniform sampler2D Sampler0;
|
||||
|
||||
in vec4 vertexColor;
|
||||
in vec2 texCoord0;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
vec4 color = texture(Sampler0, texCoord0);
|
||||
if (color.a == 0.0) {
|
||||
discard;
|
||||
}
|
||||
fragColor = vec4(ColorModulator.rgb * vertexColor.rgb, ColorModulator.a);
|
||||
}
|
||||
18
public/assets/minecraft/shaders/core/rendertype_outline.vsh
Normal file
18
public/assets/minecraft/shaders/core/rendertype_outline.vsh
Normal file
@@ -0,0 +1,18 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
#moj_import <minecraft:projection.glsl>
|
||||
|
||||
in vec3 Position;
|
||||
in vec4 Color;
|
||||
in vec2 UV0;
|
||||
|
||||
out vec4 vertexColor;
|
||||
out vec2 texCoord0;
|
||||
|
||||
void main() {
|
||||
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);
|
||||
|
||||
vertexColor = Color;
|
||||
texCoord0 = UV0;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
fragColor = ColorModulator;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
#moj_import <minecraft:projection.glsl>
|
||||
|
||||
in vec3 Position;
|
||||
|
||||
void main() {
|
||||
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
|
||||
uniform sampler2D Sampler0;
|
||||
|
||||
in vec2 texCoord0;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
vec4 color = texture(Sampler0, texCoord0);
|
||||
if (color.a == 0.0) {
|
||||
discard;
|
||||
}
|
||||
fragColor = color * ColorModulator;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
#moj_import <minecraft:projection.glsl>
|
||||
|
||||
in vec3 Position;
|
||||
in vec2 UV0;
|
||||
|
||||
out vec2 texCoord0;
|
||||
|
||||
void main() {
|
||||
vec3 pos = Position + ModelOffset;
|
||||
gl_Position = ProjMat * ModelViewMat * vec4(pos, 1.0);
|
||||
|
||||
texCoord0 = (TextureMat * vec4(UV0, 0.0, 1.0)).xy;
|
||||
}
|
||||
11
public/assets/minecraft/shaders/core/screenquad.vsh
Normal file
11
public/assets/minecraft/shaders/core/screenquad.vsh
Normal file
@@ -0,0 +1,11 @@
|
||||
#version 330
|
||||
|
||||
out vec2 texCoord;
|
||||
|
||||
void main() {
|
||||
vec2 uv = vec2((gl_VertexID << 1) & 2, gl_VertexID & 2);
|
||||
vec4 pos = vec4(uv * vec2(2, 2) + vec2(-1, -1), 0, 1);
|
||||
|
||||
gl_Position = pos;
|
||||
texCoord = uv;
|
||||
}
|
||||
13
public/assets/minecraft/shaders/core/sky.fsh
Normal file
13
public/assets/minecraft/shaders/core/sky.fsh
Normal file
@@ -0,0 +1,13 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
|
||||
in float sphericalVertexDistance;
|
||||
in float cylindricalVertexDistance;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
fragColor = apply_fog(ColorModulator, sphericalVertexDistance, cylindricalVertexDistance, 0.0, FogSkyEnd, FogSkyEnd, FogSkyEnd, FogColor);
|
||||
}
|
||||
17
public/assets/minecraft/shaders/core/sky.vsh
Normal file
17
public/assets/minecraft/shaders/core/sky.vsh
Normal file
@@ -0,0 +1,17 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
#moj_import <minecraft:projection.glsl>
|
||||
|
||||
in vec3 Position;
|
||||
|
||||
out float sphericalVertexDistance;
|
||||
out float cylindricalVertexDistance;
|
||||
|
||||
void main() {
|
||||
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);
|
||||
|
||||
sphericalVertexDistance = fog_spherical_distance(Position);
|
||||
cylindricalVertexDistance = fog_cylindrical_distance(Position);
|
||||
}
|
||||
9
public/assets/minecraft/shaders/core/stars.fsh
Normal file
9
public/assets/minecraft/shaders/core/stars.fsh
Normal file
@@ -0,0 +1,9 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
fragColor = ColorModulator;
|
||||
}
|
||||
10
public/assets/minecraft/shaders/core/stars.vsh
Normal file
10
public/assets/minecraft/shaders/core/stars.vsh
Normal file
@@ -0,0 +1,10 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
#moj_import <minecraft:projection.glsl>
|
||||
|
||||
in vec3 Position;
|
||||
|
||||
void main() {
|
||||
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);
|
||||
}
|
||||
97
public/assets/minecraft/shaders/core/terrain.fsh
Normal file
97
public/assets/minecraft/shaders/core/terrain.fsh
Normal file
@@ -0,0 +1,97 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:globals.glsl>
|
||||
#moj_import <minecraft:chunksection.glsl>
|
||||
|
||||
uniform sampler2D Sampler0;
|
||||
|
||||
in float sphericalVertexDistance;
|
||||
in float cylindricalVertexDistance;
|
||||
in vec4 vertexColor;
|
||||
in vec2 texCoord0;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
vec4 sampleNearest(sampler2D source, vec2 uv, vec2 pixelSize, vec2 du, vec2 dv, vec2 texelScreenSize) {
|
||||
// Convert our UV back up to texel coordinates and find out how far over we are from the center of each pixel
|
||||
vec2 uvTexelCoords = uv / pixelSize;
|
||||
vec2 texelCenter = round(uvTexelCoords) - 0.5f;
|
||||
vec2 texelOffset = uvTexelCoords - texelCenter;
|
||||
|
||||
// Move our offset closer to the texel center based on texel size on screen
|
||||
texelOffset = (texelOffset - 0.5f) * pixelSize / texelScreenSize + 0.5f;
|
||||
texelOffset = clamp(texelOffset, 0.0f, 1.0f);
|
||||
|
||||
uv = (texelCenter + texelOffset) * pixelSize;
|
||||
return textureGrad(source, uv, du, dv);
|
||||
}
|
||||
|
||||
vec4 sampleNearest(sampler2D source, vec2 uv, vec2 pixelSize) {
|
||||
vec2 du = dFdx(uv);
|
||||
vec2 dv = dFdy(uv);
|
||||
vec2 texelScreenSize = sqrt(du * du + dv * dv);
|
||||
return sampleNearest(source, uv, pixelSize, du, dv, texelScreenSize);
|
||||
}
|
||||
|
||||
// Rotated Grid Super-Sampling
|
||||
vec4 sampleRGSS(sampler2D source, vec2 uv, vec2 pixelSize) {
|
||||
vec2 du = dFdx(uv);
|
||||
vec2 dv = dFdy(uv);
|
||||
|
||||
vec2 texelScreenSize = sqrt(du * du + dv * dv);
|
||||
float maxTexelSize = max(texelScreenSize.x, texelScreenSize.y);
|
||||
|
||||
float minPixelSize = min(pixelSize.x, pixelSize.y);
|
||||
|
||||
float transitionStart = minPixelSize * 1.0;
|
||||
float transitionEnd = minPixelSize * 2.0;
|
||||
float blendFactor = smoothstep(transitionStart, transitionEnd, maxTexelSize);
|
||||
|
||||
float duLength = length(du);
|
||||
float dvLength = length(dv);
|
||||
float minDerivative = min(duLength, dvLength);
|
||||
float maxDerivative = max(duLength, dvLength);
|
||||
|
||||
float effectiveDerivative = sqrt(minDerivative * maxDerivative);
|
||||
|
||||
float mipLevelExact = max(0.0, log2(effectiveDerivative / minPixelSize));
|
||||
|
||||
float mipLevelLow = floor(mipLevelExact);
|
||||
float mipLevelHigh = mipLevelLow + 1.0;
|
||||
float mipBlend = fract(mipLevelExact);
|
||||
|
||||
const vec2 offsets[4] = vec2[](
|
||||
vec2(0.125, 0.375),
|
||||
vec2(-0.125, -0.375),
|
||||
vec2(0.375, -0.125),
|
||||
vec2(-0.375, 0.125)
|
||||
);
|
||||
|
||||
vec4 rgssColorLow = vec4(0.0);
|
||||
vec4 rgssColorHigh = vec4(0.0);
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
vec2 sampleUV = uv + offsets[i] * pixelSize;
|
||||
rgssColorLow += textureLod(source, sampleUV, mipLevelLow);
|
||||
rgssColorHigh += textureLod(source, sampleUV, mipLevelHigh);
|
||||
}
|
||||
rgssColorLow *= 0.25;
|
||||
rgssColorHigh *= 0.25;
|
||||
|
||||
vec4 rgssColor = mix(rgssColorLow, rgssColorHigh, mipBlend);
|
||||
|
||||
vec4 nearestColor = sampleNearest(source, uv, pixelSize, du, dv, texelScreenSize);
|
||||
|
||||
return mix(nearestColor, rgssColor, blendFactor);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 color = (UseRgss == 1 ? sampleRGSS(Sampler0, texCoord0, 1.0f / TextureSize) : sampleNearest(Sampler0, texCoord0, 1.0f / TextureSize)) * vertexColor;
|
||||
color = mix(FogColor * vec4(1, 1, 1, color.a), color, ChunkVisibility);
|
||||
#ifdef ALPHA_CUTOUT
|
||||
if (color.a < ALPHA_CUTOUT) {
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
fragColor = apply_fog(color, sphericalVertexDistance, cylindricalVertexDistance, FogEnvironmentalStart, FogEnvironmentalEnd, FogRenderDistanceStart, FogRenderDistanceEnd, FogColor);
|
||||
}
|
||||
29
public/assets/minecraft/shaders/core/terrain.vsh
Normal file
29
public/assets/minecraft/shaders/core/terrain.vsh
Normal file
@@ -0,0 +1,29 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:globals.glsl>
|
||||
#moj_import <minecraft:chunksection.glsl>
|
||||
#moj_import <minecraft:projection.glsl>
|
||||
#moj_import <minecraft:sample_lightmap.glsl>
|
||||
|
||||
in vec3 Position;
|
||||
in vec4 Color;
|
||||
in vec2 UV0;
|
||||
in ivec2 UV2;
|
||||
|
||||
uniform sampler2D Sampler2;
|
||||
|
||||
out float sphericalVertexDistance;
|
||||
out float cylindricalVertexDistance;
|
||||
out vec4 vertexColor;
|
||||
out vec2 texCoord0;
|
||||
|
||||
void main() {
|
||||
vec3 pos = Position + (ChunkPosition - CameraBlockPos) + CameraOffset;
|
||||
gl_Position = ProjMat * ModelViewMat * vec4(pos, 1.0);
|
||||
|
||||
sphericalVertexDistance = fog_spherical_distance(pos);
|
||||
cylindricalVertexDistance = fog_cylindrical_distance(pos);
|
||||
vertexColor = Color * sample_lightmap(Sampler2, UV2);
|
||||
texCoord0 = UV0;
|
||||
}
|
||||
44
public/assets/minecraft/shaders/core/text.fsh
Normal file
44
public/assets/minecraft/shaders/core/text.fsh
Normal file
@@ -0,0 +1,44 @@
|
||||
#version 330
|
||||
|
||||
#if !defined(IS_GUI) && !defined(IS_SEE_THROUGH)
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#endif
|
||||
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
|
||||
uniform sampler2D Sampler0;
|
||||
|
||||
#if !defined(IS_GUI) && !defined(IS_SEE_THROUGH)
|
||||
in float sphericalVertexDistance;
|
||||
in float cylindricalVertexDistance;
|
||||
#endif
|
||||
|
||||
in vec4 vertexColor;
|
||||
in vec2 texCoord0;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
#ifdef IS_GRAYSCALE
|
||||
vec4 texColor = texture(Sampler0, texCoord0).rrrr;
|
||||
#else
|
||||
vec4 texColor = texture(Sampler0, texCoord0);
|
||||
#endif
|
||||
|
||||
#ifdef IS_SEE_THROUGH
|
||||
vec4 color = texColor * vertexColor;
|
||||
#else
|
||||
vec4 color = texColor * vertexColor * ColorModulator;
|
||||
#endif
|
||||
if (color.a < 0.1) {
|
||||
discard;
|
||||
}
|
||||
|
||||
#ifdef IS_SEE_THROUGH
|
||||
fragColor = color * ColorModulator;
|
||||
#elif defined(IS_GUI)
|
||||
fragColor = color;
|
||||
#else
|
||||
fragColor = apply_fog(color, sphericalVertexDistance, cylindricalVertexDistance, FogEnvironmentalStart, FogEnvironmentalEnd, FogRenderDistanceStart, FogRenderDistanceEnd, FogColor);
|
||||
#endif
|
||||
}
|
||||
38
public/assets/minecraft/shaders/core/text.vsh
Normal file
38
public/assets/minecraft/shaders/core/text.vsh
Normal file
@@ -0,0 +1,38 @@
|
||||
#version 330
|
||||
|
||||
#if !defined(IS_GUI) && !defined(IS_SEE_THROUGH)
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:sample_lightmap.glsl>
|
||||
#endif
|
||||
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
#moj_import <minecraft:projection.glsl>
|
||||
|
||||
in vec3 Position;
|
||||
in vec4 Color;
|
||||
in vec2 UV0;
|
||||
#if !defined(IS_GUI) && !defined(IS_SEE_THROUGH)
|
||||
in ivec2 UV2;
|
||||
#endif
|
||||
|
||||
#if !defined(IS_GUI) && !defined(IS_SEE_THROUGH)
|
||||
uniform sampler2D Sampler2;
|
||||
out float sphericalVertexDistance;
|
||||
out float cylindricalVertexDistance;
|
||||
#endif
|
||||
|
||||
out vec4 vertexColor;
|
||||
out vec2 texCoord0;
|
||||
|
||||
void main() {
|
||||
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);
|
||||
|
||||
#if !defined(IS_GUI) && !defined(IS_SEE_THROUGH)
|
||||
sphericalVertexDistance = fog_spherical_distance(Position);
|
||||
cylindricalVertexDistance = fog_cylindrical_distance(Position);
|
||||
vertexColor = Color * sample_lightmap(Sampler2, UV2);
|
||||
#else
|
||||
vertexColor = Color;
|
||||
#endif
|
||||
texCoord0 = UV0;
|
||||
}
|
||||
33
public/assets/minecraft/shaders/core/text_background.fsh
Normal file
33
public/assets/minecraft/shaders/core/text_background.fsh
Normal file
@@ -0,0 +1,33 @@
|
||||
#version 330
|
||||
|
||||
#ifndef IS_SEE_THROUGH
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#endif
|
||||
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
|
||||
#ifndef IS_SEE_THROUGH
|
||||
in float sphericalVertexDistance;
|
||||
in float cylindricalVertexDistance;
|
||||
#endif
|
||||
|
||||
in vec4 vertexColor;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
#ifdef IS_SEE_THROUGH
|
||||
vec4 color = vertexColor;
|
||||
#else
|
||||
vec4 color = vertexColor * ColorModulator;
|
||||
#endif
|
||||
if (color.a < 0.1) {
|
||||
discard;
|
||||
}
|
||||
|
||||
#ifdef IS_SEE_THROUGH
|
||||
fragColor = color * ColorModulator;
|
||||
#else
|
||||
fragColor = apply_fog(color, sphericalVertexDistance, cylindricalVertexDistance, FogEnvironmentalStart, FogEnvironmentalEnd, FogRenderDistanceStart, FogRenderDistanceEnd, FogColor);
|
||||
#endif
|
||||
}
|
||||
32
public/assets/minecraft/shaders/core/text_background.vsh
Normal file
32
public/assets/minecraft/shaders/core/text_background.vsh
Normal file
@@ -0,0 +1,32 @@
|
||||
#version 330
|
||||
|
||||
#ifndef IS_SEE_THROUGH
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:sample_lightmap.glsl>
|
||||
#endif
|
||||
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
#moj_import <minecraft:projection.glsl>
|
||||
|
||||
in vec3 Position;
|
||||
in vec4 Color;
|
||||
#ifndef IS_SEE_THROUGH
|
||||
in ivec2 UV2;
|
||||
uniform sampler2D Sampler2;
|
||||
out float sphericalVertexDistance;
|
||||
out float cylindricalVertexDistance;
|
||||
#endif
|
||||
|
||||
out vec4 vertexColor;
|
||||
|
||||
void main() {
|
||||
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);
|
||||
|
||||
#ifndef IS_SEE_THROUGH
|
||||
sphericalVertexDistance = fog_spherical_distance(Position);
|
||||
cylindricalVertexDistance = fog_cylindrical_distance(Position);
|
||||
vertexColor = Color * sample_lightmap(Sampler2, UV2);
|
||||
#else
|
||||
vertexColor = Color;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#version 330
|
||||
|
||||
layout(std140) uniform SpriteAnimationInfo {
|
||||
mat4 ProjectionMatrix;
|
||||
mat4 SpriteMatrix;
|
||||
float UPadding;
|
||||
float VPadding;
|
||||
int MipMapLevel;
|
||||
};
|
||||
@@ -0,0 +1,8 @@
|
||||
#version 330
|
||||
|
||||
layout(std140) uniform ChunkSection {
|
||||
mat4 ModelViewMat;
|
||||
float ChunkVisibility;
|
||||
ivec2 TextureSize;
|
||||
ivec3 ChunkPosition;
|
||||
};
|
||||
@@ -0,0 +1,8 @@
|
||||
#version 330
|
||||
|
||||
layout(std140) uniform DynamicTransforms {
|
||||
mat4 ModelViewMat;
|
||||
vec4 ColorModulator;
|
||||
vec3 ModelOffset;
|
||||
mat4 TextureMat;
|
||||
};
|
||||
40
public/assets/minecraft/shaders/include/fog.glsl
Normal file
40
public/assets/minecraft/shaders/include/fog.glsl
Normal file
@@ -0,0 +1,40 @@
|
||||
#version 330
|
||||
|
||||
layout(std140) uniform Fog {
|
||||
vec4 FogColor;
|
||||
float FogEnvironmentalStart;
|
||||
float FogEnvironmentalEnd;
|
||||
float FogRenderDistanceStart;
|
||||
float FogRenderDistanceEnd;
|
||||
float FogSkyEnd;
|
||||
float FogCloudsEnd;
|
||||
};
|
||||
|
||||
float linear_fog_value(float vertexDistance, float fogStart, float fogEnd) {
|
||||
if (vertexDistance <= fogStart) {
|
||||
return 0.0;
|
||||
} else if (vertexDistance >= fogEnd) {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
return (vertexDistance - fogStart) / (fogEnd - fogStart);
|
||||
}
|
||||
|
||||
float total_fog_value(float sphericalVertexDistance, float cylindricalVertexDistance, float environmentalStart, float environmantalEnd, float renderDistanceStart, float renderDistanceEnd) {
|
||||
return max(linear_fog_value(sphericalVertexDistance, environmentalStart, environmantalEnd), linear_fog_value(cylindricalVertexDistance, renderDistanceStart, renderDistanceEnd));
|
||||
}
|
||||
|
||||
vec4 apply_fog(vec4 inColor, float sphericalVertexDistance, float cylindricalVertexDistance, float environmentalStart, float environmantalEnd, float renderDistanceStart, float renderDistanceEnd, vec4 fogColor) {
|
||||
float fogValue = total_fog_value(sphericalVertexDistance, cylindricalVertexDistance, environmentalStart, environmantalEnd, renderDistanceStart, renderDistanceEnd);
|
||||
return vec4(mix(inColor.rgb, fogColor.rgb, fogValue * fogColor.a), inColor.a);
|
||||
}
|
||||
|
||||
float fog_spherical_distance(vec3 pos) {
|
||||
return length(pos);
|
||||
}
|
||||
|
||||
float fog_cylindrical_distance(vec3 pos) {
|
||||
float distXZ = length(pos.xz);
|
||||
float distY = abs(pos.y);
|
||||
return max(distXZ, distY);
|
||||
}
|
||||
11
public/assets/minecraft/shaders/include/globals.glsl
Normal file
11
public/assets/minecraft/shaders/include/globals.glsl
Normal file
@@ -0,0 +1,11 @@
|
||||
#version 330
|
||||
|
||||
layout(std140) uniform Globals {
|
||||
ivec3 CameraBlockPos;
|
||||
vec3 CameraOffset;
|
||||
vec2 ScreenSize;
|
||||
float GlintAlpha;
|
||||
float GameTime;
|
||||
int MenuBlurRadius;
|
||||
int UseRgss;
|
||||
};
|
||||
25
public/assets/minecraft/shaders/include/light.glsl
Normal file
25
public/assets/minecraft/shaders/include/light.glsl
Normal file
@@ -0,0 +1,25 @@
|
||||
#version 330
|
||||
|
||||
#define MINECRAFT_LIGHT_POWER (0.6)
|
||||
#define MINECRAFT_AMBIENT_LIGHT (0.4)
|
||||
|
||||
layout(std140) uniform Lighting {
|
||||
vec3 Light0_Direction;
|
||||
vec3 Light1_Direction;
|
||||
};
|
||||
|
||||
vec2 minecraft_compute_light(vec3 lightDir0, vec3 lightDir1, vec3 normal) {
|
||||
return vec2(dot(lightDir0, normal), dot(lightDir1, normal));
|
||||
}
|
||||
|
||||
vec4 minecraft_mix_light_separate(vec2 light, vec4 color) {
|
||||
vec2 lightValue = max(vec2(0.0), light);
|
||||
float lightAccum = min(1.0, (lightValue.x + lightValue.y) * MINECRAFT_LIGHT_POWER + MINECRAFT_AMBIENT_LIGHT);
|
||||
return vec4(color.rgb * lightAccum, color.a);
|
||||
}
|
||||
|
||||
vec4 minecraft_mix_light(vec3 lightDir0, vec3 lightDir1, vec3 normal, vec4 color) {
|
||||
vec2 light = minecraft_compute_light(lightDir0, lightDir1, normal);
|
||||
return minecraft_mix_light_separate(light, color);
|
||||
}
|
||||
|
||||
8
public/assets/minecraft/shaders/include/matrix.glsl
Normal file
8
public/assets/minecraft/shaders/include/matrix.glsl
Normal file
@@ -0,0 +1,8 @@
|
||||
#version 330
|
||||
|
||||
mat2 mat2_rotate_z(float radians) {
|
||||
return mat2(
|
||||
cos(radians), -sin(radians),
|
||||
sin(radians), cos(radians)
|
||||
);
|
||||
}
|
||||
12
public/assets/minecraft/shaders/include/projection.glsl
Normal file
12
public/assets/minecraft/shaders/include/projection.glsl
Normal file
@@ -0,0 +1,12 @@
|
||||
#version 330
|
||||
|
||||
layout(std140) uniform Projection {
|
||||
mat4 ProjMat;
|
||||
};
|
||||
|
||||
vec4 projection_from_position(vec4 position) {
|
||||
vec4 projection = position * 0.5;
|
||||
projection.xy = vec2(projection.x + projection.w, projection.y + projection.w);
|
||||
projection.zw = position.zw;
|
||||
return projection;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
#version 330
|
||||
|
||||
vec4 sample_lightmap(sampler2D lightMap, ivec2 uv) {
|
||||
return texture(lightMap, clamp((uv / 256.0) + 0.5 / 16.0, vec2(0.5 / 16.0), vec2(15.5 / 16.0)));
|
||||
}
|
||||
35
public/assets/minecraft/shaders/post/bits.fsh
Normal file
35
public/assets/minecraft/shaders/post/bits.fsh
Normal file
@@ -0,0 +1,35 @@
|
||||
#version 330
|
||||
|
||||
uniform sampler2D InSampler;
|
||||
|
||||
in vec2 texCoord;
|
||||
|
||||
layout(std140) uniform SamplerInfo {
|
||||
vec2 OutSize;
|
||||
vec2 InSize;
|
||||
};
|
||||
|
||||
layout(std140) uniform BitsConfig {
|
||||
float Resolution;
|
||||
float MosaicSize;
|
||||
};
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
const float Saturation = 1.5;
|
||||
|
||||
void main() {
|
||||
vec2 oneTexel = 1.0 / InSize;
|
||||
vec2 mosaicInSize = InSize / MosaicSize;
|
||||
vec2 fractPix = fract(texCoord * mosaicInSize) / mosaicInSize;
|
||||
|
||||
vec4 baseTexel = texture(InSampler, texCoord - fractPix);
|
||||
|
||||
vec3 fractTexel = baseTexel.rgb - fract(baseTexel.rgb * Resolution) / Resolution;
|
||||
float luma = dot(fractTexel, vec3(0.3, 0.59, 0.11));
|
||||
vec3 chroma = (fractTexel - luma) * Saturation;
|
||||
baseTexel.rgb = luma + chroma;
|
||||
baseTexel.a = 1.0;
|
||||
|
||||
fragColor = baseTexel;
|
||||
}
|
||||
15
public/assets/minecraft/shaders/post/blit.fsh
Normal file
15
public/assets/minecraft/shaders/post/blit.fsh
Normal file
@@ -0,0 +1,15 @@
|
||||
#version 330
|
||||
|
||||
uniform sampler2D InSampler;
|
||||
|
||||
layout(std140) uniform BlitConfig {
|
||||
vec4 ColorModulate;
|
||||
};
|
||||
|
||||
in vec2 texCoord;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main(){
|
||||
fragColor = texture(InSampler, texCoord) * ColorModulate;
|
||||
}
|
||||
35
public/assets/minecraft/shaders/post/box_blur.fsh
Normal file
35
public/assets/minecraft/shaders/post/box_blur.fsh
Normal file
@@ -0,0 +1,35 @@
|
||||
#version 330
|
||||
|
||||
#moj_import <minecraft:globals.glsl>
|
||||
|
||||
uniform sampler2D InSampler;
|
||||
|
||||
layout(std140) uniform SamplerInfo {
|
||||
vec2 OutSize;
|
||||
vec2 InSize;
|
||||
};
|
||||
|
||||
layout(std140) uniform BlurConfig {
|
||||
vec2 BlurDir;
|
||||
float Radius;
|
||||
};
|
||||
|
||||
in vec2 texCoord;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
// This shader relies on GL_LINEAR sampling to reduce the amount of texture samples in half.
|
||||
// Instead of sampling each pixel position with a step of 1 we sample between pixels with a step of 2.
|
||||
// In the end we sample the last pixel with a half weight, since the amount of pixels to sample is always odd (actualRadius * 2 + 1).
|
||||
void main() {
|
||||
vec2 oneTexel = 1.0 / InSize;
|
||||
vec2 sampleStep = oneTexel * BlurDir;
|
||||
|
||||
vec4 blurred = vec4(0.0);
|
||||
float actualRadius = Radius >= 0.5 ? round(Radius) : float(MenuBlurRadius);
|
||||
for (float a = -actualRadius + 0.5; a <= actualRadius; a += 2.0) {
|
||||
blurred += texture(InSampler, texCoord + sampleStep * a);
|
||||
}
|
||||
blurred += texture(InSampler, texCoord + sampleStep * actualRadius) / 2.0;
|
||||
fragColor = blurred / (actualRadius + 0.5);
|
||||
}
|
||||
39
public/assets/minecraft/shaders/post/color_convolve.fsh
Normal file
39
public/assets/minecraft/shaders/post/color_convolve.fsh
Normal file
@@ -0,0 +1,39 @@
|
||||
#version 330
|
||||
|
||||
uniform sampler2D InSampler;
|
||||
|
||||
in vec2 texCoord;
|
||||
|
||||
layout(std140) uniform SamplerInfo {
|
||||
vec2 OutSize;
|
||||
vec2 InSize;
|
||||
};
|
||||
|
||||
layout(std140) uniform ColorConfig {
|
||||
vec3 RedMatrix;
|
||||
vec3 GreenMatrix;
|
||||
vec3 BlueMatrix;
|
||||
};
|
||||
|
||||
const vec3 Gray = vec3(0.3, 0.59, 0.11);
|
||||
const float Saturation = 1.8;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
vec2 oneTexel = 1.0 / InSize;
|
||||
vec4 InTexel = texture(InSampler, texCoord);
|
||||
|
||||
// Color Matrix
|
||||
float RedValue = dot(InTexel.rgb, RedMatrix);
|
||||
float GreenValue = dot(InTexel.rgb, GreenMatrix);
|
||||
float BlueValue = dot(InTexel.rgb, BlueMatrix);
|
||||
vec3 OutColor = vec3(RedValue, GreenValue, BlueValue);
|
||||
|
||||
// Saturation
|
||||
float Luma = dot(OutColor, Gray);
|
||||
vec3 Chroma = OutColor - Luma;
|
||||
OutColor = (Chroma * Saturation) + Luma;
|
||||
|
||||
fragColor = vec4(OutColor, 1.0);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#version 330
|
||||
|
||||
layout(std140) uniform SamplerInfo {
|
||||
vec2 OutSize;
|
||||
vec2 InSize;
|
||||
};
|
||||
|
||||
layout(std140) uniform BlurConfig {
|
||||
vec2 BlurDir;
|
||||
float Radius;
|
||||
};
|
||||
|
||||
uniform sampler2D InSampler;
|
||||
|
||||
in vec2 texCoord;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
vec2 oneTexel = 1.0 / InSize;
|
||||
vec2 sampleStep = oneTexel * BlurDir;
|
||||
|
||||
vec4 blurred = vec4(0.0);
|
||||
float radius = 2.0;
|
||||
for (float a = -radius + 0.5; a <= radius; a += 2.0) {
|
||||
blurred += texture(InSampler, texCoord + sampleStep * a);
|
||||
}
|
||||
blurred += texture(InSampler, texCoord + sampleStep * radius) / 2.0;
|
||||
fragColor = vec4((blurred / (radius + 0.5)).rgb, blurred.a);
|
||||
}
|
||||
29
public/assets/minecraft/shaders/post/entity_sobel.fsh
Normal file
29
public/assets/minecraft/shaders/post/entity_sobel.fsh
Normal file
@@ -0,0 +1,29 @@
|
||||
#version 330
|
||||
|
||||
uniform sampler2D InSampler;
|
||||
|
||||
layout(std140) uniform SamplerInfo {
|
||||
vec2 OutSize;
|
||||
vec2 InSize;
|
||||
};
|
||||
|
||||
in vec2 texCoord;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main(){
|
||||
vec2 oneTexel = 1.0 / InSize;
|
||||
|
||||
vec4 center = texture(InSampler, texCoord);
|
||||
vec4 left = texture(InSampler, texCoord - vec2(oneTexel.x, 0.0));
|
||||
vec4 right = texture(InSampler, texCoord + vec2(oneTexel.x, 0.0));
|
||||
vec4 up = texture(InSampler, texCoord - vec2(0.0, oneTexel.y));
|
||||
vec4 down = texture(InSampler, texCoord + vec2(0.0, oneTexel.y));
|
||||
float leftDiff = abs(center.a - left.a);
|
||||
float rightDiff = abs(center.a - right.a);
|
||||
float upDiff = abs(center.a - up.a);
|
||||
float downDiff = abs(center.a - down.a);
|
||||
float total = clamp(leftDiff + rightDiff + upDiff + downDiff, 0.0, 1.0);
|
||||
vec3 outColor = center.rgb * center.a + left.rgb * left.a + right.rgb * right.a + up.rgb * up.a + down.rgb * down.a;
|
||||
fragColor = vec4(outColor * 0.2, total);
|
||||
}
|
||||
25
public/assets/minecraft/shaders/post/invert.fsh
Normal file
25
public/assets/minecraft/shaders/post/invert.fsh
Normal file
@@ -0,0 +1,25 @@
|
||||
#version 330
|
||||
|
||||
uniform sampler2D InSampler;
|
||||
|
||||
in vec2 texCoord;
|
||||
|
||||
layout(std140) uniform SamplerInfo {
|
||||
vec2 OutSize;
|
||||
vec2 InSize;
|
||||
};
|
||||
|
||||
layout(std140) uniform InvertConfig {
|
||||
float InverseAmount;
|
||||
};
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main(){
|
||||
vec2 sizeRatio = OutSize / InSize;
|
||||
|
||||
vec4 diffuseColor = texture(InSampler, texCoord);
|
||||
vec4 invertColor = 1.0 - diffuseColor;
|
||||
vec4 outColor = mix(diffuseColor, invertColor, InverseAmount);
|
||||
fragColor = vec4(outColor.rgb, 1.0);
|
||||
}
|
||||
31
public/assets/minecraft/shaders/post/rotscale.vsh
Normal file
31
public/assets/minecraft/shaders/post/rotscale.vsh
Normal file
@@ -0,0 +1,31 @@
|
||||
#version 330
|
||||
|
||||
layout(std140) uniform SamplerInfo {
|
||||
vec2 OutSize;
|
||||
vec2 InSize;
|
||||
};
|
||||
|
||||
layout(std140) uniform RotScaleConfig {
|
||||
vec2 InScale;
|
||||
vec2 InOffset;
|
||||
float InRotation;
|
||||
};
|
||||
|
||||
out vec2 texCoord;
|
||||
out vec2 scaledCoord;
|
||||
|
||||
void main(){
|
||||
vec2 uv = vec2((gl_VertexID << 1) & 2, gl_VertexID & 2);
|
||||
vec4 pos = vec4(uv * vec2(2, 2) + vec2(-1, -1), 0, 1);
|
||||
|
||||
gl_Position = pos;
|
||||
texCoord = uv;
|
||||
|
||||
float Deg2Rad = 0.0174532925;
|
||||
float InRadians = InRotation * Deg2Rad;
|
||||
float Cosine = cos(InRadians);
|
||||
float Sine = sin(InRadians);
|
||||
float RotU = texCoord.x * Cosine - texCoord.y * Sine;
|
||||
float RotV = texCoord.y * Cosine + texCoord.x * Sine;
|
||||
scaledCoord = vec2(RotU, RotV) * InScale + InOffset;
|
||||
}
|
||||
39
public/assets/minecraft/shaders/post/spiderclip.fsh
Normal file
39
public/assets/minecraft/shaders/post/spiderclip.fsh
Normal file
@@ -0,0 +1,39 @@
|
||||
#version 330
|
||||
|
||||
uniform sampler2D InSampler;
|
||||
uniform sampler2D BlurSampler;
|
||||
|
||||
in vec2 texCoord;
|
||||
in vec2 scaledCoord;
|
||||
|
||||
layout(std140) uniform SamplerInfo {
|
||||
vec2 OutSize;
|
||||
vec2 InSize;
|
||||
};
|
||||
|
||||
layout(std140) uniform SpiderConfig {
|
||||
vec4 Scissor;
|
||||
vec4 Vignette;
|
||||
};
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
vec4 ScaledTexel = texture(InSampler, scaledCoord);
|
||||
vec4 BlurTexel = texture(BlurSampler, texCoord);
|
||||
vec4 OutTexel = ScaledTexel;
|
||||
|
||||
// -- Alpha Clipping --
|
||||
if (scaledCoord.x < Scissor.x) OutTexel = BlurTexel;
|
||||
if (scaledCoord.y < Scissor.y) OutTexel = BlurTexel;
|
||||
if (scaledCoord.x > Scissor.z) OutTexel = BlurTexel;
|
||||
if (scaledCoord.y > Scissor.w) OutTexel = BlurTexel;
|
||||
|
||||
clamp(scaledCoord, 0.0, 1.0);
|
||||
|
||||
if (scaledCoord.x < Vignette.x) OutTexel = mix(BlurTexel, OutTexel, (Scissor.x - scaledCoord.x) / (Scissor.x - Vignette.x));
|
||||
if (scaledCoord.y < Vignette.y) OutTexel = mix(BlurTexel, OutTexel, (Scissor.y - scaledCoord.y) / (Scissor.y - Vignette.y));
|
||||
if (scaledCoord.x > Vignette.z) OutTexel = mix(BlurTexel, OutTexel, (Scissor.z - scaledCoord.x) / (Scissor.z - Vignette.z));
|
||||
if (scaledCoord.y > Vignette.w) OutTexel = mix(BlurTexel, OutTexel, (Scissor.w - scaledCoord.y) / (Scissor.w - Vignette.w));
|
||||
fragColor = vec4(OutTexel.rgb, 1.0);
|
||||
}
|
||||
68
public/assets/minecraft/shaders/post/transparency.fsh
Normal file
68
public/assets/minecraft/shaders/post/transparency.fsh
Normal file
@@ -0,0 +1,68 @@
|
||||
#version 330
|
||||
|
||||
uniform sampler2D MainSampler;
|
||||
uniform sampler2D MainDepthSampler;
|
||||
uniform sampler2D TranslucentSampler;
|
||||
uniform sampler2D TranslucentDepthSampler;
|
||||
uniform sampler2D ItemEntitySampler;
|
||||
uniform sampler2D ItemEntityDepthSampler;
|
||||
uniform sampler2D ParticlesSampler;
|
||||
uniform sampler2D ParticlesDepthSampler;
|
||||
uniform sampler2D WeatherSampler;
|
||||
uniform sampler2D WeatherDepthSampler;
|
||||
uniform sampler2D CloudsSampler;
|
||||
uniform sampler2D CloudsDepthSampler;
|
||||
|
||||
in vec2 texCoord;
|
||||
|
||||
vec4 color_layers[6] = vec4[](vec4(0.0), vec4(0.0), vec4(0.0), vec4(0.0), vec4(0.0), vec4(0.0));
|
||||
float depth_layers[6] = float[](0, 0, 0, 0, 0, 0);
|
||||
int active_layers = 0;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void try_insert(vec4 color, float depth) {
|
||||
if (color.a == 0.0) {
|
||||
return;
|
||||
}
|
||||
|
||||
color_layers[active_layers] = color;
|
||||
depth_layers[active_layers] = depth;
|
||||
|
||||
int jj = active_layers++;
|
||||
int ii = jj - 1;
|
||||
while (jj > 0 && depth_layers[jj] < depth_layers[ii]) {
|
||||
float depthTemp = depth_layers[ii];
|
||||
depth_layers[ii] = depth_layers[jj];
|
||||
depth_layers[jj] = depthTemp;
|
||||
|
||||
vec4 colorTemp = color_layers[ii];
|
||||
color_layers[ii] = color_layers[jj];
|
||||
color_layers[jj] = colorTemp;
|
||||
|
||||
jj = ii--;
|
||||
}
|
||||
}
|
||||
|
||||
vec3 blend(vec3 dst, vec4 src) {
|
||||
return (dst * (1.0 - src.a)) + src.rgb;
|
||||
}
|
||||
|
||||
void main() {
|
||||
color_layers[0] = vec4(texture(MainSampler, texCoord).rgb, 1.0);
|
||||
depth_layers[0] = texture(MainDepthSampler, texCoord).r;
|
||||
active_layers = 1;
|
||||
|
||||
try_insert(texture(TranslucentSampler, texCoord), texture(TranslucentDepthSampler, texCoord).r);
|
||||
try_insert(texture(ItemEntitySampler, texCoord), texture(ItemEntityDepthSampler, texCoord).r);
|
||||
try_insert(texture(ParticlesSampler, texCoord), texture(ParticlesDepthSampler, texCoord).r);
|
||||
try_insert(texture(WeatherSampler, texCoord), texture(WeatherDepthSampler, texCoord).r);
|
||||
try_insert(texture(CloudsSampler, texCoord), texture(CloudsDepthSampler, texCoord).r);
|
||||
|
||||
vec3 texelAccum = color_layers[0].rgb;
|
||||
for (int ii = 1; ii < active_layers; ++ii) {
|
||||
texelAccum = blend(texelAccum, color_layers[ii]);
|
||||
}
|
||||
|
||||
fragColor = vec4(texelAccum.rgb, 1.0);
|
||||
}
|
||||
Reference in New Issue
Block a user