Skip to content

Commit

Permalink
shaders?!?!?!?!?!??
Browse files Browse the repository at this point in the history
  • Loading branch information
Arctic-foxxy committed Nov 13, 2024
1 parent 67b6ec0 commit 2c55cd8
Show file tree
Hide file tree
Showing 32 changed files with 663 additions and 250 deletions.
Binary file removed main/assets/minecraft/shaders/core/desktop.ini
Binary file not shown.
2 changes: 2 additions & 0 deletions main/assets/minecraft/shaders/core/position_tex.fsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#version 150
uniform sampler2D Sampler0;uniform vec4 ColorModulator;in vec2 texCoord0;out vec4 fragColor;void main(){vec4 color=texture(Sampler0,texCoord0);if(color.a==0.)discard;if(color.r==37./255.&&color.g==40./255.&&color.b==30./255.)color=vec4(0,0,0,0);if(color.r==38./255.&&color.g==26./255.&&color.b==28./255.)color=vec4(1,1,1,0.125);fragColor=color*ColorModulator;}
2 changes: 2 additions & 0 deletions main/assets/minecraft/shaders/core/position_tex.vsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#version 150
in vec3 Position;in vec2 UV0;uniform sampler2D Sampler0;uniform mat4 ModelViewMat;uniform mat4 ProjMat;out vec2 texCoord0;const vec2 corners[4]=vec2[4](vec2(1.,0.),vec2(0.,0.),vec2(0.,1.),vec2(1.,1.));vec4 getVertexColor(sampler2D Sampler,int vertexID,vec2 coords){vec2 size=1./textureSize(Sampler,0);return textureLod(Sampler,coords-(corners[vertexID%4]-0.5)*size,-9999);}void main(){gl_Position=ProjMat*ModelViewMat*vec4(Position,1.);texCoord0=UV0;vec4 color=getVertexColor(Sampler0,gl_VertexID,texCoord0);if(color.r==38./255.&&color.g==26./255.&&color.b==28./255.)gl_Position=ProjMat*ModelViewMat*vec4(Position+vec3(-5.,0.,0.),1.);else if(color.r==37./255.&&color.g==40./255.&&color.b==30./255.)gl_Position=ProjMat*ModelViewMat*vec4(Position+vec3(-5.,0.,0.),1.);}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#version 150

#moj_import <fog.glsl>
#moj_import <emissives_config_impl.glsl>

uniform sampler2D Sampler0;

uniform vec4 ColorModulator;
uniform float FogStart;
uniform float FogEnd;
uniform vec4 FogColor;

in float vertexDistance;
in vec4 vertexColor;
in vec2 texCoord0;
in vec2 texCoord1;

in vec4 lightMapValue;
in vec4 normalLightValue;

out vec4 fragColor;

void main() {
vec4 color = texture(Sampler0, texCoord0);
color = applyLighting(getAlpha(color.a), color * vertexColor, normalLightValue, lightMapValue);
if (color.a < 0.1) {
discard;
}
fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor) * ColorModulator;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#version 150

#moj_import <light.glsl>
#moj_import <fog.glsl>

in vec3 Position;
in vec4 Color;
in vec2 UV0;
in vec2 UV1;
in ivec2 UV2;
in vec3 Normal;

uniform sampler2D Sampler2;

uniform mat4 ModelViewMat;
uniform mat4 ProjMat;
uniform int FogShape;

uniform vec3 Light0_Direction;
uniform vec3 Light1_Direction;

out float vertexDistance;
out vec4 vertexColor;
out vec2 texCoord0;
out vec2 texCoord1;

out vec4 lightMapValue;
out vec4 normalLightValue;

void main() {
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);

vertexDistance = fog_distance(Position, FogShape);
vertexColor = Color;
texCoord0 = UV0;
texCoord1 = UV1;

lightMapValue = texelFetch(Sampler2, UV2 / 16, 0);
normalLightValue = minecraft_mix_light(Light0_Direction, Light1_Direction, Normal, vec4(1.0));
}
31 changes: 31 additions & 0 deletions main/assets/minecraft/shaders/core/rendertype_entity_cutout.fsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#version 150

#moj_import <fog.glsl>

#moj_import <emissives_config_impl.glsl>

uniform sampler2D Sampler0;

uniform vec4 ColorModulator;
uniform float FogStart;
uniform float FogEnd;
uniform vec4 FogColor;

in float vertexDistance;
in vec4 vertexColor;
in vec4 lightMapColor;
in vec4 overlayColor;
in vec2 texCoord0;

in vec4 normalLightValue;

out vec4 fragColor;

void main() {
vec4 color = texture(Sampler0, texCoord0);
if (color.a < 0.1) {
discard;
}
color = applyLighting(getAlpha(color.a), mix(overlayColor, color * vertexColor, overlayColor.a), normalLightValue, lightMapColor);
fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor) * ColorModulator;
}
41 changes: 41 additions & 0 deletions main/assets/minecraft/shaders/core/rendertype_entity_cutout.vsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#version 150

#moj_import <light.glsl>
#moj_import <fog.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;

uniform mat4 ModelViewMat;
uniform mat4 ProjMat;
uniform int FogShape;

uniform vec3 Light0_Direction;
uniform vec3 Light1_Direction;

out float vertexDistance;
out vec4 vertexColor;
out vec4 lightMapColor;
out vec4 overlayColor;
out vec2 texCoord0;

out vec4 normalLightValue;

void main() {
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);

vertexDistance = fog_distance(Position, FogShape);
vertexColor = Color;
lightMapColor = texelFetch(Sampler2, UV2 / 16, 0);
overlayColor = texelFetch(Sampler1, UV1, 0);
texCoord0 = UV0;

normalLightValue = minecraft_mix_light(Light0_Direction, Light1_Direction, Normal, vec4(1.0));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#version 150

#moj_import <fog.glsl>
#moj_import <emissives_config_impl.glsl>

uniform sampler2D Sampler0;

uniform vec4 ColorModulator;
uniform float FogStart;
uniform float FogEnd;
uniform vec4 FogColor;

in float vertexDistance;
in vec4 vertexColor;
in vec4 lightMapColor;
in vec4 overlayColor;
in vec2 texCoord0;

in vec4 normalLightValue;

out vec4 fragColor;

void main() {
vec4 color = texture(Sampler0, texCoord0);
if (color.a < 0.1) {
discard;
}
color = applyLighting(getAlpha(color.a), mix(overlayColor, color * vertexColor, overlayColor.a), normalLightValue, lightMapColor);
fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor) * ColorModulator;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#version 150

#moj_import <light.glsl>
#moj_import <fog.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;

uniform mat4 ModelViewMat;
uniform mat4 ProjMat;
uniform int FogShape;

uniform vec3 Light0_Direction;
uniform vec3 Light1_Direction;

out float vertexDistance;
out vec4 vertexColor;
out vec4 lightMapColor;
out vec4 overlayColor;
out vec2 texCoord0;

out vec4 normalLightValue;

void main() {
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);

vertexDistance = fog_distance(Position, FogShape);
vertexColor = Color;
lightMapColor = texelFetch(Sampler2, UV2 / 16, 0);
overlayColor = texelFetch(Sampler1, UV1, 0);
texCoord0 = UV0;

normalLightValue = minecraft_mix_light(Light0_Direction, Light1_Direction, Normal, vec4(1.0));
}
30 changes: 30 additions & 0 deletions main/assets/minecraft/shaders/core/rendertype_entity_solid.fsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#version 150

#moj_import <fog.glsl>
#moj_import <emissives_config_impl.glsl>

uniform sampler2D Sampler0;

uniform vec4 ColorModulator;
uniform float FogStart;
uniform float FogEnd;
uniform vec4 FogColor;

in float vertexDistance;
in vec4 vertexColor;
in vec4 lightMapColor;
in vec4 overlayColor;
in vec2 texCoord0;

in vec4 normalLightValue;

out vec4 fragColor;

void main() {
vec4 color = texture(Sampler0, texCoord0);
color = applyLighting(getAlpha(color.a), mix(overlayColor, color * vertexColor, overlayColor.a), normalLightValue, lightMapColor);
if (color.a < 0.1) {
discard;
}
fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor) * ColorModulator;
}
41 changes: 41 additions & 0 deletions main/assets/minecraft/shaders/core/rendertype_entity_solid.vsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#version 150

#moj_import <light.glsl>
#moj_import <fog.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;

uniform mat4 ModelViewMat;
uniform mat4 ProjMat;
uniform int FogShape;

uniform vec3 Light0_Direction;
uniform vec3 Light1_Direction;

out float vertexDistance;
out vec4 vertexColor;
out vec4 lightMapColor;
out vec4 overlayColor;
out vec2 texCoord0;

out vec4 normalLightValue;

void main() {
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);

vertexDistance = fog_distance(Position, FogShape);
vertexColor = Color;
lightMapColor = texelFetch(Sampler2, UV2 / 16, 0);
overlayColor = texelFetch(Sampler1, UV1, 0);
texCoord0 = UV0;

normalLightValue = minecraft_mix_light(Light0_Direction, Light1_Direction, Normal, vec4(1.0));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#version 150

#moj_import <fog.glsl>
#moj_import <emissives_config_impl.glsl>

uniform sampler2D Sampler0;

uniform vec4 ColorModulator;
uniform float FogStart;
uniform float FogEnd;
uniform vec4 FogColor;

in float vertexDistance;
in vec4 vertexColor;
in vec2 texCoord0;
in vec2 texCoord1;

in vec4 lightMapValue;
in vec4 normalLightValue;

flat in int hideVertex;

out vec4 fragColor;

void main() {
vec4 color = texture(Sampler0, texCoord0);

// If hideVertex equal to 1 (true).
// If vertextDistance is more than 800 it's a UI item.
if(hideVertex == 1 && vertexDistance <= 800) {
float alpha = textureLod(Sampler0, texCoord0, 0.0).a;

// Discard if the alpha of the pixel is of value of 254, 251, 250, 201, 181, 180, 141, 140, 101, 100.
// 254, 201, 101 are normal.
// 251 is for emissive.
if(alpha == 254.0 / 255.0 || alpha == 251.0 / 255.0 || alpha == 250.0 / 255.0 || alpha == 201.0 / 255.0 || alpha == 181.0 / 255.0 || alpha == 180.0 / 255.0 || alpha == 141.0 / 255.0 || alpha == 140.0 / 255.0 || alpha == 101.0 / 255.0 || alpha == 100.0 / 255.0) {
discard;
}
}

color = applyLighting(getAlpha(color.a), color * vertexColor, normalLightValue, lightMapValue);
if (color.a < 0.1) {
discard;
}
fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor) * ColorModulator;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#version 150

#moj_import <light.glsl>
#moj_import <fog.glsl>

in vec3 Position;
in vec4 Color;
in vec2 UV0;
in vec2 UV1;
in ivec2 UV2;
in vec3 Normal;

uniform sampler2D Sampler2;

uniform mat4 ModelViewMat;
uniform mat4 ProjMat;
uniform int FogShape;

uniform vec3 Light0_Direction;
uniform vec3 Light1_Direction;

out float vertexDistance;
out vec4 vertexColor;
out vec2 texCoord0;
out vec2 texCoord1;

out vec4 lightMapValue;
out vec4 normalLightValue;

flat out int hideVertex;

void main() {
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);

// Fast distance check from camera using view space.
float distToCamera = gl_Position.w;
if(distToCamera <= 1.4) {
hideVertex = 1;
} else {
hideVertex = 0;
}

vertexDistance = fog_distance(Position, FogShape);
vertexColor = Color;
texCoord0 = UV0;
texCoord1 = UV1;

lightMapValue = texelFetch(Sampler2, UV2 / 16, 0);
normalLightValue = minecraft_mix_light(Light0_Direction, Light1_Direction, Normal, vec4(1.0));
}
Loading

0 comments on commit 2c55cd8

Please sign in to comment.