Initial commit: Minecraft 光追着色器包(从零实现的 path tracing)

This commit is contained in:
WpyQwq
2026-09-19 12:06:22 +08:00
commit 59e30822f8
314 changed files with 9259 additions and 0 deletions
@@ -0,0 +1,33 @@
// MinecraftPT — Armor Glint Fragment Shader (enchanted armor shimmer)
#include "/Lib/Settings.glsl"
#include "/Lib/Utilities.glsl"
in vec2 texcoord;
in vec3 worldPos;
in vec3 worldNormal;
in vec3 vertexNormal;
in vec4 color;
in vec2 lightmap;
layout(location = 0) out vec4 colortex0Out;
layout(location = 1) out vec4 colortex1Out;
layout(location = 2) out vec4 colortex2Out;
layout(location = 3) out vec4 colortex3Out;
layout(location = 4) out vec4 colortex4Out;
layout(location = 5) out vec4 colortex5Out;
void main(){
vec4 albedo = texture(tex, texcoord) * color;
if (albedo.a < 0.004) discard;
// Glint is additive-ish; store with high specular
colortex0Out = vec4(albedo.rgb, 0.0);
colortex1Out = vec4(EncodeNormal(worldNormal), EncodeNormal(vertexNormal));
colortex2Out = vec4(0.0, 0.0, 0.0, 6.0 / 255.0);
colortex3Out = vec4(lightmap, 1.0, 1.0);
colortex4Out = vec4(0.0);
colortex5Out = vec4(0.0);
}
@@ -0,0 +1,37 @@
// MinecraftPT — Basic Fragment Shader (untextured geometry, e.g. clouds, selection)
#include "/Lib/Settings.glsl"
#include "/Lib/Utilities.glsl"
in vec2 texcoord;
in vec3 worldPos;
in vec3 worldNormal;
in vec3 vertexNormal;
in vec4 color;
in vec2 lightmap;
flat in int blockId;
layout(location = 0) out vec4 colortex0Out;
layout(location = 1) out vec4 colortex1Out;
layout(location = 2) out vec4 colortex2Out;
layout(location = 3) out vec4 colortex3Out;
layout(location = 4) out vec4 colortex4Out;
layout(location = 5) out vec4 colortex5Out;
void main(){
vec4 albedo = color;
#ifdef IS_SELECTION
float matID = 19.0 / 255.0; // MATID_SELECTION
#else
float matID = 0.0;
#endif
colortex0Out = vec4(albedo.rgb, 0.0);
colortex1Out = vec4(EncodeNormal(worldNormal), EncodeNormal(vertexNormal));
colortex2Out = vec4(0.0, 0.0, 0.0, matID);
colortex3Out = vec4(1.0, 1.0, 1.0, 1.0);
colortex4Out = vec4(0.0);
colortex5Out = vec4(0.0);
}
@@ -0,0 +1,32 @@
// MinecraftPT — Beacon Beam Fragment Shader (emissive beam)
#include "/Lib/Settings.glsl"
#include "/Lib/Utilities.glsl"
in vec2 texcoord;
in vec3 worldPos;
in vec3 worldNormal;
in vec3 vertexNormal;
in vec4 color;
in vec2 lightmap;
layout(location = 0) out vec4 colortex0Out;
layout(location = 1) out vec4 colortex1Out;
layout(location = 2) out vec4 colortex2Out;
layout(location = 3) out vec4 colortex3Out;
layout(location = 4) out vec4 colortex4Out;
layout(location = 5) out vec4 colortex5Out;
void main(){
vec4 albedo = texture(tex, texcoord) * color;
if (albedo.a < 0.004) discard;
colortex0Out = vec4(albedo.rgb, 1.0); // fully emissive
colortex1Out = vec4(EncodeNormal(worldNormal), EncodeNormal(vertexNormal));
colortex2Out = vec4(0.0, 0.0, 0.0, 0.0);
colortex3Out = vec4(1.0, 1.0, 1.0, 1.0);
colortex4Out = vec4(0.0);
colortex5Out = vec4(0.0);
}
@@ -0,0 +1,19 @@
// MinecraftPT — Composite_Copy_CS
// Copies the full-res GBuffer into the half-res working buffers used by the
// path tracing passes (simplified: keeps full-res, pass-through for layout parity).
#include "/Lib/Settings.glsl"
#include "/Lib/Utilities.glsl"
layout (local_size_x = 8, local_size_y = 8) in;
uniform sampler2D colortex0;
uniform sampler2D colortex1;
uniform sampler2D colortex3;
void main(){
ivec2 texel = ivec2(gl_GlobalInvocationID.xy);
// Pass-through (identity copy for pipeline parity)
// In a full implementation this would downsample to half-res buffers.
}
@@ -0,0 +1,6 @@
// MinecraftPT — Damaged Block Fragment Shader
// Handles block damage cracks — same as terrain but with damage texture overlay
#include "/Lib/Settings.glsl"
#include "/Lib/Utilities.glsl"
#include "/Lib/Programs/Gbuffers/Terrain_FS.glsl"
@@ -0,0 +1,60 @@
// MinecraftPT — Entities Fragment Shader
// Handles entities (players, mobs), hands are in Hand_FS
#include "/Lib/Settings.glsl"
#include "/Lib/Utilities.glsl"
in vec2 texcoord;
in vec3 worldPos;
in vec3 worldNormal;
in vec3 vertexNormal;
in vec4 color;
in vec2 lightmap;
flat in int blockId;
flat in float blockLightLevel;
layout(location = 0) out vec4 colortex0Out;
layout(location = 1) out vec4 colortex1Out;
layout(location = 2) out vec4 colortex2Out;
layout(location = 3) out vec4 colortex3Out;
layout(location = 4) out vec4 colortex4Out;
layout(location = 5) out vec4 colortex5Out;
uniform bool isPlayer;
void main(){
vec4 albedo = texture(tex, texcoord) * color;
if (albedo.a < 0.004) discard;
// Entity material ID — default entity
float matID = 6.0; // MATID_ENTITIES
// Player special handling (OptiFine provides isPlayer uniform in entities pass)
if (isPlayer){
matID = 7.0; // MATID_ENTITIES_PLAYER
}
vec4 specTex = vec4(0.0);
#ifdef TEXTURE_PBR_FORMAT
if (TEXTURE_PBR_FORMAT >= 1){
specTex = texture(atlasSpecular2D, texcoord);
}
#endif
vec2 lm = lightmap;
lm.y = SkyLightmapCurve(lightmap.y);
float emissive = 0.0;
#ifdef VANILLA_EMISSIVE
emissive = step(13.5, blockLightLevel) * blockLightLevel / 15.0;
#endif
colortex0Out = vec4(albedo.rgb, emissive);
colortex1Out = vec4(EncodeNormal(worldNormal), EncodeNormal(vertexNormal));
colortex2Out = vec4(specTex.r, specTex.g, specTex.b, matID / 255.0);
colortex3Out = vec4(lm, 1.0, 1.0);
colortex4Out = vec4(0.0);
colortex5Out = vec4(0.0);
}
@@ -0,0 +1,34 @@
// MinecraftPT — Entities Vertex Shader
#include "/Lib/Settings.glsl"
#include "/Lib/Utilities.glsl"
out vec2 texcoord;
out vec3 worldPos;
out vec3 worldNormal;
out vec3 vertexNormal;
out vec4 color;
out vec2 lightmap;
flat out int blockId;
flat out float blockLightLevel;
void main(){
vec4 viewPos = gl_ModelViewMatrix * gl_Vertex;
vec4 wPos = gbufferModelViewInverse * viewPos;
worldPos = wPos.xyz;
vertexNormal = normalize(gl_NormalMatrix * gl_Normal);
worldNormal = normalize(mat3(gbufferModelViewInverse) * vertexNormal);
lightmap = gl_MultiTexCoord1.xy / 240.0;
lightmap = saturate(lightmap);
blockId = int(mc_Entity.x + 0.5);
blockLightLevel = at_midBlock.w;
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
color = gl_Color;
gl_Position = gl_ProjectionMatrix * viewPos;
gl_Position.xy += taaJitter * gl_Position.w;
}
@@ -0,0 +1,34 @@
// MinecraftPT — Generic Vertex Shader (entities, textured, line, weather, glints)
#include "/Lib/Settings.glsl"
#include "/Lib/Utilities.glsl"
out vec2 texcoord;
out vec3 worldPos;
out vec3 worldNormal;
out vec3 vertexNormal;
out vec4 color;
out vec2 lightmap;
flat out int blockId;
flat out float blockLightLevel;
void main(){
vec4 viewPos = gl_ModelViewMatrix * gl_Vertex;
vec4 wPos = gbufferModelViewInverse * viewPos;
worldPos = wPos.xyz;
vertexNormal = normalize(gl_NormalMatrix * gl_Normal);
worldNormal = normalize(mat3(gbufferModelViewInverse) * vertexNormal);
lightmap = gl_MultiTexCoord1.xy / 240.0;
lightmap = saturate(lightmap);
blockId = int(mc_Entity.x + 0.5);
blockLightLevel = at_midBlock.w;
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
color = gl_Color;
gl_Position = gl_ProjectionMatrix * viewPos;
gl_Position.xy += taaJitter * gl_Position.w;
}
@@ -0,0 +1,29 @@
// MinecraftPT — Water Hand Vertex Shader (hand when submerged)
#include "/Lib/Settings.glsl"
#include "/Lib/Utilities.glsl"
out vec2 texcoord;
out vec3 worldPos;
out vec3 worldNormal;
out vec3 vertexNormal;
out vec4 color;
out vec2 lightmap;
void main(){
vec4 viewPos = gl_ModelViewMatrix * gl_Vertex;
vec4 wPos = gbufferModelViewInverse * viewPos;
worldPos = wPos.xyz;
vertexNormal = normalize(gl_NormalMatrix * gl_Normal);
worldNormal = normalize(mat3(gbufferModelViewInverse) * vertexNormal);
lightmap = gl_MultiTexCoord1.xy / 240.0;
lightmap = saturate(lightmap);
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
color = gl_Color;
gl_Position = gl_ProjectionMatrix * viewPos;
gl_Position.xy += taaJitter * gl_Position.w;
}
@@ -0,0 +1,29 @@
// MinecraftPT — Line Fragment Shader (debug lines, selection box)
#include "/Lib/Settings.glsl"
#include "/Lib/Utilities.glsl"
in vec2 texcoord;
in vec3 worldPos;
in vec3 worldNormal;
in vec3 vertexNormal;
in vec4 color;
in vec2 lightmap;
flat in int blockId;
layout(location = 0) out vec4 colortex0Out;
layout(location = 1) out vec4 colortex1Out;
layout(location = 2) out vec4 colortex2Out;
layout(location = 3) out vec4 colortex3Out;
layout(location = 4) out vec4 colortex4Out;
layout(location = 5) out vec4 colortex5Out;
void main(){
colortex0Out = vec4(color.rgb, 0.0);
colortex1Out = vec4(EncodeNormal(worldNormal), EncodeNormal(vertexNormal));
colortex2Out = vec4(0.0, 0.0, 0.0, 19.0 / 255.0); // MATID_SELECTION
colortex3Out = vec4(1.0, 1.0, 1.0, 1.0);
colortex4Out = vec4(0.0);
colortex5Out = vec4(0.0);
}
+19
View File
@@ -0,0 +1,19 @@
// MinecraftPT — Sky Vertex Shader
#include "/Lib/Settings.glsl"
#include "/Lib/Utilities.glsl"
out vec2 texcoord;
out vec3 worldPos;
out vec4 color;
void main(){
vec4 viewPos = gl_ModelViewMatrix * gl_Vertex;
vec4 wPos = gbufferModelViewInverse * viewPos;
worldPos = wPos.xyz;
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
color = gl_Color;
gl_Position = gl_ProjectionMatrix * viewPos;
}
@@ -0,0 +1,30 @@
// MinecraftPT — Sky Fragment Shader
// Writes sky color into GBuffer with MATID_SKY so composite can identify it.
// Custom sky is drawn in composite20 (Sky_Overworld_FS) over this.
#include "/Lib/Settings.glsl"
#include "/Lib/Utilities.glsl"
in vec2 texcoord;
in vec3 worldPos;
in vec4 color;
layout(location = 0) out vec4 colortex0Out;
layout(location = 1) out vec4 colortex1Out;
layout(location = 2) out vec4 colortex2Out;
layout(location = 3) out vec4 colortex3Out;
layout(location = 4) out vec4 colortex4Out;
layout(location = 5) out vec4 colortex5Out;
void main(){
vec4 albedo = texture(tex, texcoord) * color;
// Sky: mark with MATID_SKY
colortex0Out = vec4(albedo.rgb, 0.0);
colortex1Out = vec4(0.5);
colortex2Out = vec4(0.0, 0.0, 0.0, 10.0 / 255.0); // MATID_SKY
colortex3Out = vec4(1.0, 1.0, 1.0, 1.0);
colortex4Out = vec4(0.0);
colortex5Out = vec4(0.0);
}
@@ -0,0 +1,32 @@
// MinecraftPT — Spider Eyes Fragment Shader (emissive eyes)
#include "/Lib/Settings.glsl"
#include "/Lib/Utilities.glsl"
in vec2 texcoord;
in vec3 worldPos;
in vec3 worldNormal;
in vec3 vertexNormal;
in vec4 color;
in vec2 lightmap;
layout(location = 0) out vec4 colortex0Out;
layout(location = 1) out vec4 colortex1Out;
layout(location = 2) out vec4 colortex2Out;
layout(location = 3) out vec4 colortex3Out;
layout(location = 4) out vec4 colortex4Out;
layout(location = 5) out vec4 colortex5Out;
void main(){
vec4 albedo = texture(tex, texcoord) * color;
if (albedo.a < 0.004) discard;
colortex0Out = vec4(albedo.rgb, albedo.r > 0.5 ? 1.0 : 0.0);
colortex1Out = vec4(EncodeNormal(worldNormal), EncodeNormal(vertexNormal));
colortex2Out = vec4(0.0, 0.0, 0.0, 6.0 / 255.0);
colortex3Out = vec4(lightmap, 1.0, 1.0);
colortex4Out = vec4(0.0);
colortex5Out = vec4(0.0);
}
@@ -0,0 +1,157 @@
// MinecraftPT — Terrain Fragment Shader
// Writes the solid and translucent GBuffer
#include "/Lib/Settings.glsl"
#include "/Lib/Utilities.glsl"
in vec2 texcoord;
in vec3 worldPos;
in vec3 worldNormal;
in vec3 vertexNormal;
in vec4 color;
in vec2 lightmap;
flat in int blockId;
flat in float blockLightLevel;
layout(location = 0) out vec4 colortex0Out; // albedo + emissive
layout(location = 1) out vec4 colortex1Out; // normals
layout(location = 2) out vec4 colortex2Out; // spec + matID
layout(location = 3) out vec4 colortex3Out; // lightmap
layout(location = 4) out vec4 colortex4Out; // translucent albedo + alpha
layout(location = 5) out vec4 colortex5Out; // translucent normal + matID
// Material IDs from block.properties
#define BLOCK_LEAVES 1
#define BLOCK_TRANSLUCENT 2
#define BLOCK_WATER 3
#define BLOCK_CROSS 4
#define BLOCK_TORCH 5
#define BLOCK_LANTERN 6
#define BLOCK_FIRE 7
#define BLOCK_CAMPFIRE 8
#define BLOCK_LAVA 9
#define BLOCK_GLASS_PANE 10
#define BLOCK_IRON_BARS 11
#define BLOCK_STAIRS 12
#define BLOCK_SLAB 13
#define BLOCK_WALL 14
#define BLOCK_FENCE 15
#define BLOCK_FENCE_GATE 16
#define BLOCK_DOOR 17
#define BLOCK_RAIL 18
#define BLOCK_REDSTONE 19
#define BLOCK_ENDROD 20
#define BLOCK_CHAIN 21
#define BLOCK_AMETHYST 22
#define BLOCK_CANDLE 23
#define BLOCK_GLOWSTONE 24
#define BLOCK_LIGHT 25
#define BLOCK_PORTAL 26
#define BLOCK_LADDER 27
#define BLOCK_SUGARCANE 28
#define BLOCK_BAMBOO 29
#define BLOCK_CACTUS 30
#define BLOCK_CHORUS 31
#define BLOCK_CORAL 32
#define BLOCK_DRIPSTONE 33
#define BLOCK_CONDUIT 34
#define BLOCK_LIGHTNING_ROD 35
#define BLOCK_POT 36
#define BLOCK_SNOW_LAYERS 37
#define BLOCK_COBWEB 80
void main(){
vec4 albedo = texture(tex, texcoord) * color;
// Cutout (alpha test)
if (albedo.a < 0.004) discard;
// Material ID determination
float matID = 0.0; // MATID_DEFAULT
#ifdef IS_HAND
matID = 5.0; // MATID_HAND
#endif
bool isTranslucent = false;
if (blockId == BLOCK_LEAVES){
matID = 3.0; // MATID_LEAVES
}else if (blockId == BLOCK_TRANSLUCENT){
matID = 2.0; // MATID_STAINEDGLASS
isTranslucent = true;
}else if (blockId == BLOCK_WATER){
matID = 1.0; // MATID_WATER (should be handled by gbuffers_water)
isTranslucent = true;
}else if (blockId == BLOCK_CROSS){
matID = 4.0; // MATID_GRASS
}else if (blockId == BLOCK_TORCH){
matID = 11.0; // MATID_TORCH
}else if (blockId == BLOCK_LANTERN){
matID = 20.0; // MATID_COPPER_LANTERN
}else if (blockId == BLOCK_FIRE || blockId == BLOCK_CAMPFIRE){
matID = 12.0; // MATID_FIRE
}else if (blockId == BLOCK_LAVA){
matID = 12.0;
}else if (blockId == BLOCK_GLASS_PANE){
matID = 2.0; // MATID_STAINEDGLASS
isTranslucent = true;
}else if (blockId == BLOCK_ENDROD){
matID = 13.0; // MATID_ENDROD
}else if (blockId == BLOCK_AMETHYST){
matID = 14.0; // MATID_AMETHYST
}else if (blockId == BLOCK_PORTAL){
matID = 18.0; // MATID_END_PORTAL
}else if (blockId == BLOCK_COBWEB){
matID = 17.0; // MATID_PARTICLE-like
isTranslucent = true;
}
// Emissive detection
float emissive = 0.0;
#ifdef HARDCODED_EMISSIVENESS_MODE
if (blockId == BLOCK_LAVA || blockId == BLOCK_FIRE || blockId == BLOCK_CAMPFIRE ||
blockId == BLOCK_GLOWSTONE || blockId == BLOCK_ENDROD || blockId == BLOCK_LANTERN ||
blockId == BLOCK_AMETHYST || blockId == BLOCK_TORCH || blockId == BLOCK_CANDLE ||
blockId == BLOCK_LIGHT || blockId == BLOCK_CONDUIT){
emissive = 1.0;
}
#endif
#ifdef VANILLA_EMISSIVE
// Emissive blocks from vanilla light level (at_midBlock.w = 0-15)
emissive = max(emissive, step(13.5, blockLightLevel) * blockLightLevel / 15.0);
#endif
// LAB PBR specular
vec4 specTex = vec4(0.0);
#ifdef TEXTURE_PBR_FORMAT
if (TEXTURE_PBR_FORMAT >= 1 && blockId != BLOCK_WATER){
specTex = texture(atlasSpecular2D, texcoord);
}
#endif
// Lightmap
vec2 lm = lightmap;
lm.y = SkyLightmapCurve(lightmap.y);
// Parallax shadow (POM)
float parallaxShadow = 1.0;
// Encode normals (octahedral)
vec2 worldNormalEnc = EncodeNormal(worldNormal);
vec2 vertexNormalEnc = EncodeNormal(vertexNormal);
// Solid write
colortex0Out = vec4(albedo.rgb, emissive);
colortex1Out = vec4(worldNormalEnc, vertexNormalEnc);
colortex2Out = vec4(specTex.r, specTex.g, specTex.b, matID / 255.0);
colortex3Out = vec4(lm, parallaxShadow, 1.0);
// Translucent write (glass, panes, cobweb)
if (isTranslucent){
colortex4Out = vec4(albedo.rgb, albedo.a);
colortex5Out = vec4(worldNormalEnc, matID / 255.0, specTex.r);
}else{
colortex4Out = vec4(0.0);
colortex5Out = vec4(0.0);
}
}
@@ -0,0 +1,51 @@
// MinecraftPT — Terrain Vertex Shader
// Handles terrain, block entities, damaged blocks
#include "/Lib/Settings.glsl"
#include "/Lib/Utilities.glsl"
out vec2 texcoord;
out vec3 worldPos;
out vec3 worldNormal;
out vec3 vertexNormal;
out vec4 color;
out vec2 lightmap;
flat out int blockId;
flat out float blockLightLevel;
#ifdef WAVING_PLANTS
#include "/Lib/IndividualFunctions/WavingPlants.glsl"
#endif
void main(){
// World position
vec4 viewPos = gl_ModelViewMatrix * gl_Vertex;
vec4 wPos = gbufferModelViewInverse * viewPos;
worldPos = wPos.xyz;
// Normals
vertexNormal = normalize(gl_NormalMatrix * gl_Normal);
worldNormal = normalize(mat3(gbufferModelViewInverse) * vertexNormal);
worldNormal = normalize(worldNormal);
// Lightmap (blocklight, skylight)
lightmap = gl_MultiTexCoord1.xy / 240.0;
lightmap = saturate(lightmap);
// Block ID from mc_Entity
blockId = int(mc_Entity.x + 0.5);
blockLightLevel = at_midBlock.w;
// Waving plants
#ifdef WAVING_PLANTS
if (blockId == 4){
WavingPlants(wPos, lightmap.y);
}
#endif
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
color = gl_Color;
gl_Position = gl_ProjectionMatrix * viewPos;
gl_Position.xy += taaJitter * gl_Position.w;
}
@@ -0,0 +1,36 @@
// MinecraftPT — Textured Fragment Shader (textured non-terrain geometry)
#include "/Lib/Settings.glsl"
#include "/Lib/Utilities.glsl"
in vec2 texcoord;
in vec3 worldPos;
in vec3 worldNormal;
in vec3 vertexNormal;
in vec4 color;
in vec2 lightmap;
flat in int blockId;
layout(location = 0) out vec4 colortex0Out;
layout(location = 1) out vec4 colortex1Out;
layout(location = 2) out vec4 colortex2Out;
layout(location = 3) out vec4 colortex3Out;
layout(location = 4) out vec4 colortex4Out;
layout(location = 5) out vec4 colortex5Out;
void main(){
vec4 albedo = texture(tex, texcoord) * color;
if (albedo.a < 0.004) discard;
vec2 lm = lightmap;
lm.y = SkyLightmapCurve(lightmap.y);
colortex0Out = vec4(albedo.rgb, 0.0);
colortex1Out = vec4(EncodeNormal(worldNormal), EncodeNormal(vertexNormal));
colortex2Out = vec4(0.0, 0.0, 0.0, 6.0 / 255.0); // MATID_ENTITIES
colortex3Out = vec4(lm, 1.0, 1.0);
colortex4Out = vec4(0.0);
colortex5Out = vec4(0.0);
}
@@ -0,0 +1,50 @@
// MinecraftPT — Water Fragment Shader
// Writes the water GBuffer with waves, caustics data
#include "/Lib/Settings.glsl"
#include "/Lib/Utilities.glsl"
in vec2 texcoord;
in vec3 worldPos;
in vec3 worldNormal;
in vec3 vertexNormal;
in vec4 color;
in vec2 lightmap;
layout(location = 0) out vec4 colortex0Out; // albedo + emissive
layout(location = 1) out vec4 colortex1Out; // normals
layout(location = 2) out vec4 colortex2Out; // spec + matID
layout(location = 3) out vec4 colortex3Out; // lightmap
layout(location = 4) out vec4 colortex4Out; // translucent albedo + alpha
layout(location = 5) out vec4 colortex5Out; // translucent normal + matID
#include "/Lib/IndividualFunctions/WaterWaves.glsl"
void main(){
vec4 albedo = texture(tex, texcoord) * color;
// Water surface height / waves
vec3 wPos = worldPos;
#ifdef WAVE_PARALLAX
vec3 waveNormal = GetWaveNormal(wPos, lightmap.y);
#else
vec3 waveNormal = GetWaveNormal(wPos, lightmap.y);
#endif
// Water color — deep water tint
vec3 waterColor = mix(vec3(0.05, 0.15, 0.2), vec3(0.1, 0.3, 0.4), wetness * 0.5);
// Water lightmap
vec2 lm = lightmap;
lm.y = SkyLightmapCurve(lightmap.y);
// Water is translucent
colortex0Out = vec4(waterColor, 0.0);
colortex1Out = vec4(EncodeNormal(waveNormal), EncodeNormal(vertexNormal));
colortex2Out = vec4(0.0, 0.018, 0.0, 1.0 / 255.0); // matID = MATID_WATER
colortex3Out = vec4(lm, 1.0, 1.0);
// Translucent buffer: water albedo is mostly transparent, we store depth tint
colortex4Out = vec4(waterColor, 0.6);
colortex5Out = vec4(EncodeNormal(waveNormal), 1.0 / 255.0, 0.0);
}
@@ -0,0 +1,29 @@
// MinecraftPT — Water Vertex Shader
#include "/Lib/Settings.glsl"
#include "/Lib/Utilities.glsl"
out vec2 texcoord;
out vec3 worldPos;
out vec3 worldNormal;
out vec3 vertexNormal;
out vec4 color;
out vec2 lightmap;
void main(){
vec4 viewPos = gl_ModelViewMatrix * gl_Vertex;
vec4 wPos = gbufferModelViewInverse * viewPos;
worldPos = wPos.xyz;
vertexNormal = normalize(gl_NormalMatrix * gl_Normal);
worldNormal = normalize(mat3(gbufferModelViewInverse) * vertexNormal);
lightmap = gl_MultiTexCoord1.xy / 240.0;
lightmap = saturate(lightmap);
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
color = gl_Color;
gl_Position = gl_ProjectionMatrix * viewPos;
gl_Position.xy += taaJitter * gl_Position.w;
}
@@ -0,0 +1,34 @@
// MinecraftPT — Weather Fragment Shader (rain/snow)
#include "/Lib/Settings.glsl"
#include "/Lib/Utilities.glsl"
in vec2 texcoord;
in vec3 worldPos;
in vec3 worldNormal;
in vec3 vertexNormal;
in vec4 color;
in vec2 lightmap;
flat in int blockId;
layout(location = 0) out vec4 colortex0Out;
layout(location = 1) out vec4 colortex1Out;
layout(location = 2) out vec4 colortex2Out;
layout(location = 3) out vec4 colortex3Out;
layout(location = 4) out vec4 colortex4Out;
layout(location = 5) out vec4 colortex5Out;
void main(){
vec4 albedo = texture(tex, texcoord) * color;
if (albedo.a < 0.004) discard;
// Weather drops are thin — mark as particle-ish translucent
colortex0Out = vec4(albedo.rgb, 0.0);
colortex1Out = vec4(EncodeNormal(worldNormal), EncodeNormal(vertexNormal));
colortex2Out = vec4(0.0, 0.0, 0.0, 17.0 / 255.0); // MATID_PARTICLE
colortex3Out = vec4(1.0, 1.0, 1.0, 1.0);
colortex4Out = vec4(0.0);
colortex5Out = vec4(0.0);
}