add v1.541 (Extreme)

This commit is contained in:
2025-11-18 08:49:24 +01:00
commit f2788f598f
105 changed files with 10844 additions and 0 deletions

98
shaders/block.properties Normal file
View File

@@ -0,0 +1,98 @@
#Forge mods may add custom block mapping as "assets/<modid>/shaders/block.properties" in the mod JAR file.
#Format "block.<id>=<block1> <block2> ..."
#Only one line per block ID is allowed.
# Short format
#block.31=red_flower yellow_flower reeds
# Long format
#block.32=minecraft:red_flower ic2:nether_flower botania:reeds
# Properties
#block.33=minecraft:red_flower:type=white_tulip minecraft:red_flower:type=pink_tulip botania:reeds:type=green
# Block ID, Metadata (backwards compatibility)
#block.34=38:6 38:7 83
#==================================================================================================================
#if MC_VERSION >= 12006
# WAVING ENTITIES
# small grass, fern
block.10031 = short_grass fern
# Small entities
block.10059 = wheat dead_bush brown_mushroom red_mushroom oak_sapling spruce_sapling birch_sapling jungle_sapling acacia_sapling dark_oak_sapling dandelion poppy blue_orchid allium azure_bluet red_tulip orange_tulip white_tulip pink_tulip oxeye_daisy carrots beetroots potatoes lily_of_the_valley wither_rose cornflower sweet_berry_bush crimson_fungus warped_fungus crimson_roots warped_roots nether_sprouts mangrove_propagule cherry_sapling pink_petals torchflower_crop torchflower pale_oak_sapling closed_eyeblossom open_eyeblossom bush firefly_bush cactus_flower wildflowers short_dry_grass tall_dry_grass
# Tall grass/Tall flowers
block.10175 = sunflower:half=lower lilac:half=lower tall_grass:half=lower large_fern:half=lower rose_bush:half=lower peony:half=lower small_dripleaf:half=lower pitcher_plant:half=lower
block.10176 = sunflower:half=upper lilac:half=upper tall_grass:half=upper large_fern:half=upper rose_bush:half=upper peony:half=upper small_dripleaf:half=upper big_dripleaf big_dripleaf_stem azalea flowering_azalea pitcher_plant:half=upper
# Inverted lower half, so they hang from the ceiling
block.10177 = hanging_roots
# Leaves
block.10018 = oak_leaves spruce_leaves birch_leaves jungle_leaves acacia_leaves dark_oak_leaves azalea_leaves flowering_azalea_leaves mangrove_leaves cherry_leaves pale_oak_leaves
# vines
block.10106 = vine weeping_vines_plant weeping_vines twisting_vines_plant twisting_vines cave_vines_plant cave_vines pale_hanging_moss
# lilypad
block.10111 = lily_pad
# fire
block.10051 = fire
# Lava
block.10010 = lava
# REFLECTIONS
# Water reflections (8, 9), also used for waving water
block.10008 = water
# Transparent reflections, ice(79), stained glass(95, 160), slimeblock(165)
block.10079 = ice honey_block slime_block white_stained_glass orange_stained_glass magenta_stained_glass light_blue_stained_glass yellow_stained_glass lime_stained_glass pink_stained_glass gray_stained_glass light_gray_stained_glass cyan_stained_glass purple_stained_glass blue_stained_glass brown_stained_glass green_stained_glass red_stained_glass black_stained_glass white_stained_glass_pane orange_stained_glass_pane magenta_stained_glass_pane light_blue_stained_glass_pane yellow_stained_glass_pane lime_stained_glass_pane pink_stained_glass_pane gray_stained_glass_pane light_gray_stained_glass_pane cyan_stained_glass_pane purple_stained_glass_pane blue_stained_glass_pane brown_stained_glass_pane green_stained_glass_pane red_stained_glass_pane black_stained_glass_pane
# Metallic block reflections
block.10080 = copper_trapdoor exposed_copper_trapdoor waxed_copper_trapdoor waxed_exposed_copper_trapdoor waxed_weathered_copper_trapdoor waxed_oxidized_copper_trapdoor copper_door exposed_copper_door waxed_copper_door waxed_exposed_copper_door waxed_weathered_copper_door waxed_oxidized_copper_door chiseled_copper exposed_chiseled_copper waxed_chiseled_copper waxed_exposed_chiseled_copper waxed_weathered_chiseled_copper waxed_oxidized_chiseled_copper copper_grate exposed_copper_grate waxed_copper_grate waxed_exposed_copper_grate waxed_weathered_copper_grate waxed_oxidized_copper_grate copper_bulb exposed_copper_bulb waxed_copper_bulb waxed_exposed_copper_bulb waxed_weathered_copper_bulb waxed_oxidized_copper_bulb anvil iron_block iron_door iron_trapdoor iron_bars heavy_weighted_pressure_plate gold_block light_weighted_pressure_plate diamond_block emerald_block amethyst_block budding_amethyst copper_block exposed_copper cut_copper exposed_cut_copper waxed_copper_block waxed_exposed_copper waxed_weathered_copper waxed_oxidized_copper waxed_cut_copper waxed_exposed_cut_copper waxed_weathered_cut_copper waxed_oxidized_cut_copper cut_copper_slab exposed_cut_copper_slab waxed_cut_copper_slab waxed_exposed_cut_copper_slab waxed_weathered_cut_copper_slab waxed_oxidized_cut_copper_slab cut_copper_stairs exposed_cut_copper_stairs waxed_cut_copper_stairs waxed_exposed_cut_copper_stairs waxed_weathered_cut_copper_stairs waxed_oxidized_cut_copper_stairs
# Polished block reflections
block.10081 = tuff_bricks tuff_brick_stairs tuff_brick_slab tuff_brick_wall chiseled_tuff_bricks polished_tuff polished_tuff_stairs polished_tuff_slab polished_tuff_wall smooth_stone smooth_stone_slab prismarine_bricks prismarine_brick_slab prismarine_brick_stairs lapis_block polished_granite polished_granite_slab polished_granite_stairs polished_diorite polished_diorite_slab polished_diorite_stairs polished_andesite polished_andesite_slab polished_andesite_stairs polished_basalt netherite_block bricks brick_slab brick_stairs sandstone chiseled_sandstone cut_sandstone smooth_sandstone sandstone_slab cut_sandstone_slab smooth_sandstone_slab sandstone_stairs smooth_sandstone_stairs red_sandstone chiseled_red_sandstone cut_red_sandstone smooth_red_sandstone red_sandstone_slab cut_red_sandstone_slab smooth_red_sandstone_slab red_sandstone_stairs smooth_red_sandstone_stairs purpur_block purpur_pillar purpur_slab purpur_stairs smooth_basalt calcite polished_deepslate chiseled_deepslate deepslate_bricks deepslate_tiles polished_deepslate_stairs deepslate_brick_stairs deepslate_tile_stairs polished_deepslate_slab deepslate_brick_slab deepslate_tile_slab polished_deepslate_wall deepslate_brick_wall deepslate_tile_wall
# blocks that shouldn't be diffused
block.20000 = cobweb nether_wart spore_blossom pitcher_crop
block.10300 = lectern
# Emissive entities (glowstone 89)
block.10089 = vault glowstone torch wall_torch redstone_torch:lit=true redstone_wall_torch:lit=true redstone_lamp:lit=true furnace:lit=true blast_furnace:lit=true smoker:lit=true jack_o_lantern beacon campfire lantern:hanging=false shroomlight candle:lit=true white_candle:lit=true orange_candle:lit=true magenta_candle:lit=true light_blue_candle:lit=true yellow_candle:lit=true lime_candle:lit=true pink_candle:lit=true gray_candle:lit=true black_candle:lit=true light_gray_candle:lit=true red_candle:lit=true cyan_candle:lit=true purple_candle:lit=true blue_candle:lit=true brown_candle:lit=true green_candle:lit=true glow_item_frame glow_lichen light cave_vines_plant:berries=true cave_vines:berries=true
block.10090 = lantern:hanging=true soul_lantern:hanging=true
block.10091 = soul_fire soul_lantern soul_torch soul_campfire:lit=true
# Fallback for 1.20.2 and below:
#elif MC_VERSION >= 11300
block.10031 = grass fern
block.10059 = wheat dead_bush brown_mushroom red_mushroom oak_sapling spruce_sapling birch_sapling jungle_sapling acacia_sapling dark_oak_sapling dandelion poppy blue_orchid allium azure_bluet red_tulip orange_tulip white_tulip pink_tulip oxeye_daisy carrots beetroots potatoes lily_of_the_valley wither_rose cornflower sweet_berry_bush crimson_fungus warped_fungus crimson_roots warped_roots nether_sprouts mangrove_propagule cherry_sapling pink_petals torchflower_crop torchflower
block.10175 = sunflower:half=lower lilac:half=lower tall_grass:half=lower large_fern:half=lower rose_bush:half=lower peony:half=lower small_dripleaf:half=lower pitcher_plant:half=lower
block.10176 = sunflower:half=upper lilac:half=upper tall_grass:half=upper large_fern:half=upper rose_bush:half=upper peony:half=upper small_dripleaf:half=upper big_dripleaf big_dripleaf_stem azalea flowering_azalea pitcher_plant:half=upper
block.10177 = hanging_roots
block.10018 = oak_leaves spruce_leaves birch_leaves jungle_leaves acacia_leaves dark_oak_leaves azalea_leaves flowering_azalea_leaves mangrove_leaves cherry_leaves
block.10106 = vine weeping_vines_plant weeping_vines twisting_vines_plant twisting_vines cave_vines_plant cave_vines
block.10111 = lily_pad
block.10051 = fire
block.10010 = lava
block.10008 = water
block.10079 = ice honey_block slime_block white_stained_glass orange_stained_glass magenta_stained_glass light_blue_stained_glass yellow_stained_glass lime_stained_glass pink_stained_glass gray_stained_glass light_gray_stained_glass cyan_stained_glass purple_stained_glass blue_stained_glass brown_stained_glass green_stained_glass red_stained_glass black_stained_glass white_stained_glass_pane orange_stained_glass_pane magenta_stained_glass_pane light_blue_stained_glass_pane yellow_stained_glass_pane lime_stained_glass_pane pink_stained_glass_pane gray_stained_glass_pane light_gray_stained_glass_pane cyan_stained_glass_pane purple_stained_glass_pane blue_stained_glass_pane brown_stained_glass_pane green_stained_glass_pane red_stained_glass_pane black_stained_glass_pane
block.10080 = anvil iron_block iron_door iron_trapdoor iron_bars heavy_weighted_pressure_plate gold_block light_weighted_pressure_plate diamond_block emerald_block amethyst_block budding_amethyst copper_block exposed_copper cut_copper exposed_cut_copper waxed_copper_block waxed_exposed_copper waxed_weathered_copper waxed_oxidized_copper waxed_cut_copper waxed_exposed_cut_copper waxed_weathered_cut_copper waxed_oxidized_cut_copper cut_copper_slab exposed_cut_copper_slab waxed_cut_copper_slab waxed_exposed_cut_copper_slab waxed_weathered_cut_copper_slab waxed_oxidized_cut_copper_slab cut_copper_stairs exposed_cut_copper_stairs waxed_cut_copper_stairs waxed_exposed_cut_copper_stairs waxed_weathered_cut_copper_stairs waxed_oxidized_cut_copper_stairs
block.10081 = smooth_stone smooth_stone_slab prismarine_bricks prismarine_brick_slab prismarine_brick_stairs lapis_block polished_granite polished_granite_slab polished_granite_stairs polished_diorite polished_diorite_slab polished_diorite_stairs polished_andesite polished_andesite_slab polished_andesite_stairs polished_basalt netherite_block bricks brick_slab brick_stairs sandstone chiseled_sandstone cut_sandstone smooth_sandstone sandstone_slab cut_sandstone_slab smooth_sandstone_slab sandstone_stairs smooth_sandstone_stairs red_sandstone chiseled_red_sandstone cut_red_sandstone smooth_red_sandstone red_sandstone_slab cut_red_sandstone_slab smooth_red_sandstone_slab red_sandstone_stairs smooth_red_sandstone_stairs purpur_block purpur_pillar purpur_slab purpur_stairs smooth_basalt calcite polished_deepslate chiseled_deepslate deepslate_bricks deepslate_tiles polished_deepslate_stairs deepslate_brick_stairs deepslate_tile_stairs polished_deepslate_slab deepslate_brick_slab deepslate_tile_slab polished_deepslate_wall deepslate_brick_wall deepslate_tile_wall
block.20000 = cobweb nether_wart spore_blossom pitcher_crop
block.10300 = lectern
block.10089 = glowstone torch wall_torch redstone_torch:lit=true redstone_wall_torch:lit=true redstone_lamp:lit=true furnace:lit=true blast_furnace:lit=true smoker:lit=true jack_o_lantern beacon campfire lantern:hanging=false shroomlight candle:lit=true white_candle:lit=true orange_candle:lit=true magenta_candle:lit=true light_blue_candle:lit=true yellow_candle:lit=true lime_candle:lit=true pink_candle:lit=true gray_candle:lit=true black_candle:lit=true light_gray_candle:lit=true red_candle:lit=true cyan_candle:lit=true purple_candle:lit=true blue_candle:lit=true brown_candle:lit=true green_candle:lit=true glow_item_frame glow_lichen light cave_vines_plant:berries=true cave_vines:berries=true
block.10090 = lantern:hanging=true soul_lantern:hanging=true
block.10091 = soul_fire soul_lantern soul_torch soul_campfire:lit=true
# Fallback for 1.12.2 and below:
#else
block.10031 = tallgrass
block.10059 = wheat deadbush brown_mushroom red_mushroom sapling yellow_flower red_flower carrots beetroots potatoes
block.10175 = double_plant:half=lower
block.10176 = double_plant:half=upper
block.10018 = leaves leaves2
block.10106 = vine
block.10111 = waterlily
block.10051 = fire
block.10010 = flowing_lava lava
block.10008 = flowing_water water
block.10079 = ice slime stained_glass stained_glass_pane
block.10080 = anvil iron_block iron_door iron_trapdoor heavy_weighted_pressure_plate gold_block light_weighted_pressure_plate diamond_block emerald_block
block.10081 = stone_slab:variant=stone double_stone_slab:variant=stone prismarine lapis_block stone:variant=smooth_granite stone:variant=smooth_diorite stone:variant=smooth_andesite brick_block stone_slab:variant=brick double_stone_slab:variant=brick brick_stairs sandstone sandstone_stairs stone_slab:variant=sandstone double_stone_slab:variant=sandstone red_sandstone red_sandstone_stairs stone_slab2 double_stone_slab2 purpur_block purpur_pillar purpur_slab purpur_double_slab purpur_stairs
block.20000 = web nether_wart
block.10089 = glowstone torch redstone_torch lit_pumpkin lit_redstone_lamp beacon
#endif

1272
shaders/composite.fsh Normal file

File diff suppressed because it is too large Load Diff

103
shaders/composite.vsh Normal file
View File

@@ -0,0 +1,103 @@
#version 120
#define Lens_Flares_Strength 4.0 //Adjust the lens flare strength [1.0 4.0 16.0 32.0 64.0]
#define lightingColors
#include "shaders.settings"
varying vec2 texcoord;
varying vec3 lightColor;
varying vec3 sunVec;
varying vec3 upVec;
varying vec3 sky1;
varying vec3 sky2;
varying float tr;
varying vec2 lightPos;
varying vec3 sunlight;
varying vec3 nsunlight;
varying vec3 rawAvg;
varying float SdotU;
varying float sunVisibility;
varying float moonVisibility;
uniform vec3 sunPosition;
uniform vec3 upPosition;
uniform int worldTime;
uniform float rainStrength;
uniform mat4 gbufferProjection;
const vec3 ToD[7] = vec3[7]( vec3(0.58597,0.16,0.005),
vec3(0.58597,0.31,0.08),
vec3(0.58597,0.45,0.16),
vec3(0.58597,0.5,0.35),
vec3(0.58597,0.5,0.36),
vec3(0.58597,0.5,0.37),
vec3(0.58597,0.5,0.38));
void main() {
//lightpos
vec4 tpos = vec4(sunPosition,1.0)*gbufferProjection;
tpos = vec4(tpos.xyz/tpos.w,1.0);
vec2 pos1 = tpos.xy/tpos.z;
lightPos = pos1*0.5+0.5;
/*----------------------------*/
//Position
gl_Position = ftransform();
texcoord = (gl_MultiTexCoord0).xy;
/*--------------------------------*/
//Sun/moon pos
sunVec = normalize(sunPosition);
upVec = normalize(upPosition);
SdotU = dot(sunVec,upVec);
sunVisibility = pow(clamp(SdotU+0.15,0.0,0.15)/0.15,4.0);
moonVisibility = pow(clamp(-SdotU+0.15,0.0,0.15)/0.15,4.0);
/*--------------------------------*/
//reduced the sun color to a 7 array
float hour = max(mod(worldTime/1000.0+2.0,24.0)-2.0,0.0); //-0.1
float cmpH = max(-abs(floor(hour)-6.0)+6.0,0.0); //12
float cmpH1 = max(-abs(floor(hour)-5.0)+6.0,0.0); //1
vec3 temp = ToD[int(cmpH)];
vec3 temp2 = ToD[int(cmpH1)];
sunlight = mix(temp,temp2,fract(hour));
sunlight.rgb += vec3(r_multiplier,g_multiplier,b_multiplier); //allows lighting colors to be tweaked.
sunlight.rgb *= light_brightness; //brightness needs to be adjusted if we tweak lighting colors.
vec2 trCalc = min(abs(worldTime-vec2(23000.0,12700.0)),750.0);
tr = max(min(trCalc.x,trCalc.y)/375.0-1.0,0.0);
/*--------------------------------*/
float tr2 = clamp(min(min(distance(float(worldTime),23000.0),750.0),min(distance(float(worldTime),12700.0),800.0))/800.0-0.5,0.0,1.0)*2.0;
vec4 bounced = vec4(0.5,0.66,1.3,0.27);
vec3 sun_ambient = bounced.w * (vec3(0.25,0.62,1.32)-rainStrength*vec3(0.1,0.47,1.17))*(1.0+rainStrength*7.0) + sunlight*(bounced.x + bounced.z)*(1.0-rainStrength*0.95);
const vec3 moonlight = vec3(0.0016, 0.00288, 0.00448);
rawAvg = (sun_ambient*sunVisibility + 8.0*moonlight*moonVisibility)*(0.05+tr2*0.15)*4.7+0.0002;
float truepos = sign(sunPosition.z)*1.0; //1 -> sun / -1 -> moon
lightColor = mix(vec3(Lens_Flares_Strength)*sunVisibility+0.00001,12.*moonlight*moonVisibility+0.00001,(truepos+1.0)/2.);
if (length(lightColor)>0.001)lightColor = mix(lightColor,normalize(vec3(0.3,0.3,0.3))*pow(normalize(lightColor),vec3(0.4))*length(lightColor)*0.03,rainStrength)*(0.25+0.25*tr2);
float mcosS = max(SdotU,0.0);
vec3 sunlight04 = pow(sunlight,vec3(0.454));
float skyMult = max(SdotU*0.1+0.1,0.0)/0.2*(1.0-rainStrength*0.6)*0.7;
nsunlight = normalize(pow(mix(sunlight04,5.*sunlight04*sunVisibility*(1.0-rainStrength*0.95)+vec3(0.3,0.3,0.35),rainStrength),vec3(2.2)))*0.6*skyMult;
vec3 sky_color = vec3(0.05, 0.32, 1.);
sky_color = normalize(mix(sky_color,2.*sunlight04*sunVisibility*(1.0-rainStrength*0.95)+vec3(0.3,0.3,0.3)*length(sunlight04),rainStrength)); //normalize colors in order to don't change luminance
sky1 = sky_color*0.6*skyMult;
sky2 = mix(sky_color,mix(nsunlight,sky_color,rainStrength*0.9),1.0-max(mcosS-0.2,0.0)*0.5)*0.6*skyMult;
}

945
shaders/composite1.fsh Normal file
View File

@@ -0,0 +1,945 @@
#version 120
#extension GL_ARB_shader_texture_lod : enable
const bool gaux1MipmapEnabled = true;
/* DRAWBUFFERS:3 */
/*
Sildur's Vibrant Shaders:
https://www.patreon.com/Sildur
https://sildurs-shaders.github.io/
https://twitter.com/SildurFX
Permissions:
You are not allowed to edit, copy code or share my shaderpack under a different name or claim it as yours.
*/
#define composite2
#define composite1
#define lightingColors
#include "shaders.settings"
//custom uniforms defined in shaders.properties
uniform float inSwamp;
uniform float BiomeTemp;
varying vec2 texcoord;
varying vec2 lightPos;
varying vec3 sunVec;
varying vec3 upVec;
varying vec3 lightColor;
varying vec3 sky1;
varying vec3 sky2;
varying vec3 nsunlight;
varying vec3 sunlight;
const vec3 moonlight = vec3(0.0025, 0.0045, 0.007);
varying vec3 rawAvg;
varying vec3 avgAmbient2;
varying vec3 cloudColor;
varying vec3 cloudColor2;
varying float fading;
varying float tr;
varying float eyeAdapt;
varying float SdotU;
varying float sunVisibility;
varying float moonVisibility;
uniform sampler2D composite;
uniform sampler2D gaux1;
uniform sampler2D depthtex0;
uniform sampler2D depthtex1;
uniform sampler2D depthtex2;
uniform sampler2D colortex0;
uniform sampler2D colortex1;
uniform sampler2D colortex2;
uniform sampler2D noisetex;
uniform sampler2D gaux3;
uniform sampler2D gaux2;
uniform sampler2D gaux4;
uniform vec3 cameraPosition;
uniform vec3 sunPosition;
uniform mat4 gbufferProjection;
uniform mat4 gbufferProjectionInverse;
uniform mat4 gbufferModelViewInverse;
uniform ivec2 eyeBrightness;
uniform ivec2 eyeBrightnessSmooth;
uniform int isEyeInWater;
uniform int worldTime;
uniform float near;
uniform float far;
uniform float viewWidth;
uniform float viewHeight;
uniform float rainStrength;
uniform float frameTimeCounter;
uniform float blindness;
#if MC_VERSION >= 11900
uniform float darknessFactor;
uniform float darknessLightFactor;
#endif
float comp = 1.0-near/far/far;
float tmult = mix(min(abs(worldTime-6000.0)/6000.0,1.0),1.0,rainStrength);
float night = clamp((worldTime-13000.0)/300.0,0.0,1.0)-clamp((worldTime-22800.0)/200.0,0.0,1.0);
//Draw sun and moon
vec3 drawSun(vec3 fposition, vec3 color, float vis) {
vec3 sVector = normalize(fposition);
float angle = (1.0-max(dot(sVector,sunVec),0.0))* 650.0;
float sun = exp(-angle*angle*angle);
sun *= (1.0-rainStrength*1.0)*sunVisibility;
vec3 sunlightB = mix(pow(sunlight,vec3(1.0))*44.0,vec3(0.25,0.3,0.4),rainStrength*0.8);
if(isEyeInWater == 1.0)sunlightB = mix(pow(moonlight*40.0,vec3(1.0))*44.0,vec3(0.25,0.3,0.4),rainStrength*0.8); //lets just render the moon underwater, it has the perfect color
return mix(color,sunlightB,sun*vis);
}
vec3 drawMoon(vec3 fposition, vec3 color, float vis) {
vec3 sVector = normalize(fposition);
float angle = (1.0-max(dot(sVector,-sunVec),0.0))* 2000.0;
float moon = exp(-angle*angle*angle);
moon *= (1.0-rainStrength*1.0)*moonVisibility;
vec3 moonlightC = mix(pow(moonlight*40.0,vec3(1.0))*44.0,vec3(0.25,0.3,0.4),rainStrength*0.8);
return mix(color,moonlightC,moon*vis);
}
#ifdef Fog
float getAirDensity (float h) {
return max(h/10.,6.0);
}
float calcFog(vec3 fposition) {
float density = wFogDensity*(1.0-rainStrength*0.115);
#ifdef morningFog
float morning = clamp((worldTime-0.1)/300.0,0.0,1.0)-clamp((worldTime-23150.0)/200.0,0.0,1.0);
density *= (0.1+0.9*morning);
#endif
vec3 worldpos = (gbufferModelViewInverse*vec4(fposition,1.0)).rgb+cameraPosition;
float height = mix(getAirDensity (worldpos.y),6.,rainStrength);
float d = length(fposition);
return pow(clamp((2.625+rainStrength*3.4)/exp(-60/10./density)*exp(-getAirDensity (cameraPosition.y)/density) * (1.0-exp( -pow(d,2.712)*height/density/(6000.-tmult*tmult*2000.)/13))/height,0.0,1.),1.0-rainStrength*0.63)*clamp((eyeBrightnessSmooth.y/255.-2/16.)*4.,0.0,1.0);
}
#else
float calcFog(vec3 fposition) {
return 0.0;
}
#endif
//Skycolor
vec3 getSkyc(vec3 fposition) {
vec3 sVector = normalize(fposition);
float invRain07 = 1.0-rainStrength*0.6;
float cosT = dot(sVector,upVec);
float mCosT = max(cosT,0.0);
float absCosT = 1.0-max(cosT*0.82+0.26,0.2);
float cosY = dot(sunVec,sVector);
float Y = acos(cosY);
const float a = -1.;
const float b = -0.22;
const float c = 8.0;
const float d = -3.5;
const float e = 0.3;
//luminance
float L = (1.0+a*exp(b/(mCosT)));
float A = 1.0+e*cosY*cosY;
//gradient
vec3 grad1 = mix(sky1,sky2,absCosT*absCosT);
float sunscat = max(cosY,0.0);
vec3 grad3 = mix(grad1,nsunlight,sunscat*sunscat*(1.0-mCosT)*(0.9-rainStrength*0.5*0.9)*(clamp(-(SdotU)*4.0+3.0,0.0,1.0)*0.65+0.35)+0.1);
float Y2 = 3.14159265359-Y;
float L2 = L * (8.0*exp(d*Y2)+A);
const vec3 moonlight2 = pow(normalize(moonlight),vec3(3.0))*length(moonlight);
const vec3 moonlightRain = normalize(vec3(0.25,0.3,0.4))*length(moonlight);
vec3 gradN = mix(moonlight,moonlight2,1.-L2/2.0);
gradN = mix(gradN,moonlightRain,rainStrength);
return pow(L*(c*exp(d*Y)+A),invRain07)*sunVisibility *length(rawAvg) * (0.85+rainStrength*0.425)*grad3+ 0.2*pow(L2*1.2+1.2,invRain07)*moonVisibility*gradN;
}/*---------------------------------*/
#ifdef DISTANT_HORIZONS
uniform sampler2D dhDepthTex0;
uniform sampler2D dhDepthTex1;
uniform int dhRenderDistance;
uniform float dhFarPlane;
uniform float dhNearPlane;
uniform mat4 dhProjection;
uniform mat4 dhProjectionInverse;
#endif
#if defined waterRefl || defined iceRefl ||defined metallicRefl || defined polishedRefl || defined RainReflections
const int maxf = 3; //number of refinements
const float ref = 0.11; //refinement multiplier
const float inc = 3.0; //increasement factor at each step
vec3 nvec3(vec4 pos) {
return pos.xyz/pos.w;
}
vec4 nvec4(vec3 pos) {
return vec4(pos.xyz, 1.0);
}
float cdist(vec2 coord) {
return max(abs(coord.s-0.5),abs(coord.t-0.5))*2.0;
}
vec4 raytrace(vec3 fragpos, vec3 skycolor, vec3 rvector, sampler2D depth, mat4 projection, mat4 projectionInverse) {
vec4 color = vec4(0.0);
vec3 start = fragpos;
rvector *= 1.2;
fragpos += rvector;
vec3 tvector = rvector;
int sr = 0;
for(int i=0;i<25;i++){
vec3 pos = nvec3(projection * nvec4(fragpos)) * 0.5 + 0.5;
if(pos.x < 0 || pos.x > 1 || pos.y < 0 || pos.y > 1 || pos.z < 0 || pos.z > 1.0) break;
vec3 fragpos0 = vec3(pos.st, texture2D(depth, pos.st).r);
fragpos0 = nvec3(projectionInverse * nvec4(fragpos0 * 2.0 - 1.0));
float err = distance(fragpos,fragpos0);
if(err < pow(length(rvector),1.175)){
sr++;
if(sr >= maxf){
bool land = texture2D(depth, pos.st).r < comp;
color = pow(texture2DLod(gaux1, pos.st, 1),vec4(2.2))*257.0;
if (isEyeInWater == 0) color.rgb = land ? mix(color.rgb,skycolor*(0.7+0.3*tmult)*(1.33-rainStrength*0.8),calcFog(fragpos0.xyz)) : drawSun(rvector,skycolor,1.0);
color.a = clamp(1.0 - pow(cdist(pos.st), 20.0), 0.0, 1.0);
break;
}
tvector -= rvector;
rvector *= ref;
}
#ifndef DISTANT_HORIZONS
rvector *= inc - 0.0000275 / (2.0 * near / (far + near - rvector.z * far - near)); //offset to reduce reflection errors
#else
rvector *= texture2D(dhDepthTex1, texcoord).x > texture2D(dhDepthTex0, texcoord).x ? inc : inc - 0.0000275 / (2.0 * near / (far + near - rvector.z * far - near)); //offset to reduce reflection errors
#endif
tvector += rvector;
fragpos = start + tvector;
}
return color;
}
vec4 raytraceLand(vec3 fragpos, vec3 skycolor, vec3 rvector) {
const int maxf = 3; //number of refinements
const float ref = 0.11; //refinement multiplier
const float inc = 2.4; //increasement factor at each step
const float errorstep = 1.5;
vec4 color = vec4(0.0);
vec3 start = fragpos;
rvector *= 1.2;
fragpos += rvector;
vec3 tvector = rvector;
int sr = 0;
for(int i=0;i<25;i++){
vec3 pos = nvec3(gbufferProjection * nvec4(fragpos)) * 0.5 + 0.5;
if(pos.x < 0 || pos.x > 1 || pos.y < 0 || pos.y > 1 || pos.z < 0 || pos.z > 1.0) break;
vec3 fragpos0 = vec3(pos.st, texture2D(depthtex1, pos.st).r);
fragpos0 = nvec3(gbufferProjectionInverse * nvec4(fragpos0 * 2.0 - 1.0));
float err = distance(fragpos,fragpos0);
if(err < pow(length(rvector),errorstep)){
sr++;
if(sr >= maxf){
bool land = texture2D(depthtex1, pos.st).r < comp;
color = pow(texture2DLod(gaux1, pos.st, 1),vec4(2.2))*257.0;
color.a = clamp(1.0 - pow(cdist(pos.st), 20.0), 0.0, 1.0);
break;
}
tvector -= rvector;
rvector *= ref;
}
rvector *= inc;
tvector += rvector;
fragpos = start + tvector;
}
return color;
}
#endif
#if Clouds == 2 || Clouds == 4
float subSurfaceScattering(vec3 vec,vec3 pos, float N) {
return pow(max(dot(vec,normalize(pos)),0.0),N)*(N+1)/6.28;
}
float noisetexture(vec2 coord){
return texture2D(noisetex, coord).x;
}
vec3 drawCloud(vec3 fposition, vec3 color) {
const float r = 3.2;
const vec4 noiseC = vec4(1.0,r,r*r,r*r*r);
const vec4 noiseWeights = 1.0/noiseC/dot(1.0/noiseC,vec4(1.0));
vec3 tpos = vec3(gbufferModelViewInverse * vec4(fposition, 0.0));
tpos = normalize(tpos);
float cosT = max(dot(fposition, upVec),0.0);
float wind = abs(frameTimeCounter*0.0005-0.5)+0.5;
float distortion = wind * 0.045;
float iMult = -log(cosT)*2.0+2.0;
float heightA = (400.0+300.0*sqrt(cosT))/(tpos.y);
for (int i = 1;i<22;i++) {
vec3 intersection = tpos*(heightA-4.0*i*iMult); //curved cloud plane
vec2 coord1 = intersection.xz/200000.0+wind*0.05;
vec2 coord = fract(coord1/0.25);
vec4 noiseSample = vec4(noisetexture(coord+distortion),
noisetexture(coord*noiseC.y+distortion),
noisetexture(coord*noiseC.z+distortion),
noisetexture(coord*noiseC.w+distortion));
float j = i / 22.0;
coord = vec2(j+0.5,-j+0.5)/noiseTextureResolution + coord.xy + sin(coord.xy*3.14*j)/10.0 + wind*0.02*(j+0.5);
vec2 secondcoord = 1.0 - coord.yx;
vec4 noiseSample2 = vec4(noisetexture(secondcoord),
noisetexture(secondcoord*noiseC.y),
noisetexture(secondcoord*noiseC.z),
noisetexture(secondcoord*noiseC.w));
float finalnoise = dot(noiseSample*noiseSample2,noiseWeights);
float cl = max((sqrt(finalnoise*max(1.0-abs(i-11.0)/11*(0.15-1.7*rainStrength),0.0))-0.55)/(0.65+2.0*rainStrength)*clamp(cosT*cosT*2.0,0.0,1.0),0.0);
float cMult = max(pow(30.0-i,3.5)/pow(30.,3.5),0.0)*6.0;
float sunscattering = subSurfaceScattering(sunVec, fposition, 75.0)*pow(cl, 3.75);
float moonscattering = subSurfaceScattering(-sunVec, fposition, 75.0)*pow(cl, 5.0);
color = color*(1.0-cl)+cl*cMult*mix(cloudColor2*4.75,cloudColor,min(cMult,0.875)) * 0.05 + sunscattering+moonscattering;
}
return color;
}/*---------------------------*/
#endif
#if Clouds == 3 || Clouds == 4
float maxHeight = (cloud_height+200.0);
float densityAtPos(in vec3 pos){
pos /= 18.0;
pos.xz *= 0.5;
vec3 p = floor(pos);
vec3 f = fract(pos);
f = (f*f) * (3.0-2.0*f);
f = sqrt(f);
vec2 uv = p.xz + f.xz + p.y * 17.0;
vec2 coord = uv / 64.0;
vec2 coord2 = uv / 64.0 + 17.0 / 64.0;
float xy1 = texture2D(noisetex, coord).x;
float xy2 = texture2D(noisetex, coord2).x;
return mix(xy1, xy2, f.y);
}
float cloudPlane(in vec3 pos){
float center = cloud_height*0.5+maxHeight*0.5;
float difcenter = maxHeight-center;
float mult = (pos.y-center)/difcenter;
vec3 samplePos = pos*vec3(0.5,0.5,0.5)*0.35+frameTimeCounter*vec3(0.5,0.,0.5);
float noise = 0.0;
float tot = 0.0;
for(int i=0 ; i < 4; i++){
noise += densityAtPos(samplePos*exp(i*1.05)*0.6+frameTimeCounter*i*vec3(0.5,0.,0.5)*0.6)*exp(-i*0.8);
tot += exp(-i*0.8);
}
return 1.0-pow(0.4,max(noise/tot-0.56-mult*mult*0.3+rainStrength*0.16,0.0)*2.2);
}
vec3 renderClouds(in vec3 pos, in vec3 color, const int cloudIT) {
float dither = fract(0.75487765 * gl_FragCoord.x + 0.56984026 * gl_FragCoord.y);
#ifdef TAA
dither = fract(frameTimeCounter * 256.0 + dither);
#endif
//setup
vec3 dV_view = pos.xyz;
vec3 progress_view = vec3(0.0);
pos = pos*2200.0 + cameraPosition; //makes max cloud distance not dependant of render distance
//3 ray setup cases : below cloud plane, in cloud plane and above cloud plane
if (cameraPosition.y <= cloud_height){
float maxHeight2 = min(maxHeight, pos.y); //stop ray when intersecting before cloud plane end
//setup ray to start at the start of the cloud plane and end at the end of the cloud plane
dV_view *= -(maxHeight2-cloud_height)/dV_view.y/cloudIT;
progress_view = dV_view*dither + cameraPosition + dV_view*(maxHeight2-cameraPosition.y)/(dV_view.y);
if (pos.y < cloud_height) return color; //don't trace if no intersection is possible
}
if (cameraPosition.y > cloud_height && cameraPosition.y < maxHeight){
if (dV_view.y <= 0.0) {
float maxHeight2 = max(cloud_height, pos.y); //stop ray when intersecting before cloud plane end
//setup ray to start at eye position and end at the end of the cloud plane
dV_view *= abs(maxHeight2-cameraPosition.y)/abs(dV_view.y)/cloudIT;
progress_view = dV_view*dither + cameraPosition + dV_view*cloudIT;
dV_view *= -1.0;
}
else if (dV_view.y > 0.0) {
float maxHeight2 = min(maxHeight, pos.y); //stop ray when intersecting before cloud plane end
//setup ray to start at eye position and end at the end of the cloud plane
dV_view *= -abs(maxHeight2-cameraPosition.y)/abs(dV_view.y)/cloudIT;
progress_view = dV_view*dither + cameraPosition - dV_view*cloudIT;
}
}
if (cameraPosition.y >= maxHeight){
float maxHeight2 = max(cloud_height, pos.y); //stop ray when intersecting before cloud plane end
//setup ray to start at eye position and end at the end of the cloud plane
dV_view *= -abs(maxHeight2-maxHeight)/abs(dV_view.y)/cloudIT;
progress_view = dV_view*dither + cameraPosition + dV_view*(maxHeight2-cameraPosition.y)/dV_view.y;
if (pos.y > maxHeight) return color; //don't trace if no intersection is possible
}
float mult = length(dV_view)/256.0;
for (int i=0;i<cloudIT;i++) {
float cloud = cloudPlane(progress_view)*40.0;
float lightsourceVis = pow(clamp(progress_view.y-cloud_height,0.,200.)/200.,2.3);
color = mix(color,mix(cloudColor2*0.05, cloudColor*0.15, lightsourceVis),1.0-exp(-cloud*mult));
progress_view += dV_view;
}
return color;
}
#endif
#ifdef customStars
float calcStars(vec3 pos){
vec3 p = pos * 256.0;
vec3 flr = floor(p);
float fr = length((p - flr) - 0.5);
flr = fract(flr * 443.8975);
flr += dot(flr, flr.xyz + 19.19);
float intensity = step(fract((flr.x + flr.y) * flr.z), 0.0025) * (1.0 - rainStrength);
float stars = clamp((fr - 0.5) / (0.0 - 0.5), 0.0, 1.0); //recreate smoothstep for opengl 120
stars = stars * stars * (3.0 - 2.0 * stars); //^
return stars * intensity;
}
#endif
#ifdef Refraction
mat2 rmatrix(float rad){
return mat2(vec2(cos(rad), -sin(rad)), vec2(sin(rad), cos(rad)));
}
float calcWaves(vec2 coord){
vec2 movement = abs(vec2(0.0, -frameTimeCounter * 0.5));
coord *= 0.4;
vec2 coord0 = coord * rmatrix(1.0) - movement * 4.5;
coord0.y *= 3.0;
vec2 coord1 = coord * rmatrix(0.5) - movement * 1.5;
coord1.y *= 3.0;
vec2 coord2 = coord * frameTimeCounter * 0.02;
coord0 *= (waveSize+0.5); //create an offset for bigger waves
coord1 *= waveSize;
float wave = texture2D(noisetex,coord0 * 0.005).x * 10.0; //big waves
wave -= texture2D(noisetex,coord1 * 0.010416).x * 7.0; //small waves
wave *= 0.0157;
return wave;
}
vec2 calcBump(vec2 coord){
const vec2 deltaPos = vec2(0.25, 0.0);
float h0 = calcWaves(coord);
float h1 = calcWaves(coord + deltaPos.xy);
float h2 = calcWaves(coord - deltaPos.xy);
float h3 = calcWaves(coord + deltaPos.yx);
float h4 = calcWaves(coord - deltaPos.yx);
float xDelta = ((h1-h0)+(h0-h2));
float yDelta = ((h3-h0)+(h0-h4));
return vec2(xDelta,yDelta)*0.05;
}
#endif
uniform float wetness;
#ifdef RainReflections
const float wetnessHalflife = 200.0f;
const float drynessHalflife = 75.0f;
float noisetexture(vec2 coord, float offset, float speed){
speed *= (0.001+rainStrength); //generate static noise after raining stopped for an improved wetness effect
offset *= rainNoise;
return texture2D(noisetex, fract(coord*offset + frameTimeCounter*speed)).x/offset;
}
float calcRainripples(vec2 pos){
float wave = noisetexture(pos, 1.75, 0.1125);
wave -= noisetexture(pos, 1.8, -0.1125);
return wave;
}
#endif
vec3 decode (vec2 enc){
vec2 fenc = enc*4-2;
float f = dot(fenc,fenc);
float g = sqrt(1-f/4.0);
vec3 n;
n.xy = fenc*g;
n.z = 1-f/2;
return n;
}
/*
vec2 texelSize = vec2(1.0/viewWidth,1.0/viewHeight);
uniform int framemod8;
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-1.,3.)/8.,
vec2(5.0,1.)/8.,
vec2(-3,-5.)/8.,
vec2(-5.,5.)/8.,
vec2(-7.,-1.)/8.,
vec2(3,7.)/8.,
vec2(7.,-7.)/8.);
vec3 ScreenSpace() {
vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw);
vec3 p3 = vec3(gl_FragCoord.xy*texelSize-offsets[framemod8]*texelSize*0.5, texture2D(depthtex0, gl_FragCoord.xy*texelSize).x) * 2.0 - 1.0;
vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3];
return normalize(fragposition.xyz / fragposition.w);
}
#if defined waterRefl || defined iceRefl
vec3 toClipSpace(vec3 viewSpacePosition) {
return (vec3(gbufferProjection[0].x, gbufferProjection[1].y, gbufferProjection[2].z) * viewSpacePosition + gbufferProjection[3].xyz) / -viewSpacePosition.z * 0.5 + 0.5;
}
vec3 newTrace(vec3 dir, vec3 position, float dither, float fresnel){
#define SSR_STEPS 40 //[10 15 20 25 30 35 40 50 100 200 400]
float quality = mix(15.0,SSR_STEPS,fresnel);
vec3 clipPosition = toClipSpace(position);
float rayLength = ((position.z + dir.z * far*1.732) > -near) ? (-near -position.z) / dir.z : far*1.732;
vec3 direction = normalize(toClipSpace(position+dir*rayLength) - clipPosition);
vec3 maxLengths = (step(0.0, direction) - clipPosition) / direction;
vec3 stepv = direction * min(min(maxLengths.x, maxLengths.y), maxLengths.z) / quality;
vec3 spos = clipPosition + stepv*dither;
float minZ = clipPosition.z;
float maxZ = spos.z+stepv.z*0.5;
spos.xy+=offsets[framemod8]*texelSize*0.5;
for (int i = 0; i < int(quality+1); i++) {
float sp = texture2D(depthtex1, spos.xy).x;
if(sp <= max(maxZ,minZ) && sp >= min(maxZ,minZ)) return vec3(spos.xy,sp);
spos += stepv;
minZ = maxZ - 0.00004 / (2.0 * near / (far + near - spos.z * (far - near))); //small offset
maxZ += stepv.z;
}
return vec3(1.1);
}
#endif
*/
void main() {
vec3 c = pow(texture2D(gaux1,texcoord).xyz,vec3(2.2))*257.;
vec3 hr = texture2D(composite,(floor(texcoord*vec2(viewWidth,viewHeight)/2.0)*2.0+1.0)/vec2(viewWidth,viewHeight)/2.0).rgb*30.0;
vec2 lightmap = texture2D(colortex1, texcoord.xy).zw;
//Depth and fragpos
float depth0 = texture2D(depthtex0, texcoord).x;
vec4 fragpos0 = gbufferProjectionInverse * (vec4(texcoord, depth0, 1.0) * 2.0 - 1.0);
fragpos0 /= fragpos0.w;
vec3 normalfragpos0 = normalize(fragpos0.xyz);
float depth1 = texture2D(depthtex1, texcoord).x;
vec4 fragpos1 = gbufferProjectionInverse * (vec4(texcoord, depth1, 1.0) * 2.0 - 1.0);
fragpos1 /= fragpos1.w;
vec3 normalfragpos1 = normalize(fragpos1.xyz);
#ifndef DISTANT_HORIZONS
bool island = !(dot(texture2D(colortex0,texcoord).rgb,vec3(1.0))<0.00000000001 || (depth1 > comp)); //must be depth1 > comp for transparency
#else
float DHdepth0 = texture2D(dhDepthTex0, texcoord).x;
vec4 DHfragpos0 = dhProjectionInverse * (vec4(texcoord, DHdepth0, 1.0) * 2.0 - 1.0);
DHfragpos0 /= DHfragpos0.w;
vec3 DHnormalfragpos0 = normalize(DHfragpos0.xyz);
float DHdepth1 = texture2D(dhDepthTex1, texcoord).x;
vec4 DHfragpos1 = dhProjectionInverse * (vec4(texcoord, DHdepth1, 1.0) * 2.0 - 1.0);
DHfragpos1 /= DHfragpos1.w;
vec3 DHnormalfragpos1 = normalize(DHfragpos1.xyz);
bool DH_reflective = DHdepth1 > DHdepth0;
bool island = !(dot(texture2D(colortex0,texcoord).rgb,vec3(1.0))<0.00000000001 || (depth1 > comp)) || (DHdepth1 < depth1); //Fix DH terrain rendering against sky
#ifdef Fog
float dither = fract(0.75487765 * gl_FragCoord.x + 0.56984026 * gl_FragCoord.y);
dither = fract(frameTimeCounter * 16.0 + dither);
if(length(fragpos1.xyz) > dither * 32.0 - 16.0 + far) c = mix(c.rgb, hr.rgb*(1.0-rainStrength*0.25), clamp((length(DHfragpos1.xyz) - dhRenderDistance * 0.05) / dhRenderDistance, 0.0, 1.0));
#endif
#endif
float mats = texture2D(colortex0,texcoord).b;
vec4 trp = texture2D(gaux3,texcoord.xy);
bool transparency = dot(trp.xyz,trp.xyz) > 0.000001;
bool isMetallic = mats > 0.39 && mats < 0.41;
bool isPolished = mats > 0.49 && mats < 0.51;
#ifndef polishedRefl
isPolished = false;
#endif
#ifndef metallicRefl
isMetallic = false;
#endif
#ifdef Refraction
if (texture2D(colortex2, texcoord).z < 0.2499 && dot(texture2D(colortex2,texcoord).xyz,texture2D(colortex2,texcoord).xyz) > 0.0 || isEyeInWater == 1.0) { //reflective water
vec2 wpos = (gbufferModelViewInverse*fragpos0).xz+cameraPosition.xz;
float caustics = 0.0;
#ifdef Caustics
float skylight = pow(max(lightmap.y-1.0/16.0,0.0)*1.14285714286, 0.5);
caustics = calcWaves(wpos*3.0);
caustics = mix(caustics*4.25, 1.0, 1.0-skylight);
caustics = clamp(caustics*causticsStrength, -0.8, 0.2); //adjust color and filter out dark parts
caustics *= (1.0-rainStrength);
#endif
#ifdef DISTANT_HORIZONS
if(DH_reflective) wpos = (gbufferModelViewInverse*DHfragpos0).xz+cameraPosition.xz; //should be before caustics but we disable them on DH water anyways
if(length(fragpos1.xyz) > 16.0 + far) caustics *= 0.0; //blend caustics with DH water
#endif
vec2 refraction = texcoord.xy + calcBump(wpos);
c = pow(texture2D(gaux1, refraction).xyz, vec3(2.2) + caustics)*257.0;
#ifdef uwatertint
if(isEyeInWater == 1.0){
vec3 underwaterC = vec3(0.0,0.0025,0.0075) * (1.0-0.95*night) * (1.0-0.95*rainStrength); //tint underwater
c = mix(c, underwaterC, 0.75);
}
#endif
}
#endif
if (!island){ //breaks transparency rendering against the sky
vec3 cpos = normalize(gbufferModelViewInverse*fragpos1).xyz;
#ifdef defskybox
c = mix(c.rgb, hr.rgb, skyboxblendfactor); //blend skytexture with shader skycolor
#else
c = hr.rgb;
#endif
#ifdef customStars
c += calcStars(cpos)*moonVisibility;
#endif
#if Clouds == 2 || Clouds == 4
c = drawCloud(normalfragpos1.xyz, c);
#endif
#ifndef defskybox
c = drawSun(fragpos1.xyz, c, 1.0);
c = drawMoon(fragpos1.xyz, c, 1.0);
#endif
#if Clouds == 3 || Clouds == 4
float cheight = (cloud_height-32.0);
if (dot(fragpos1.xyz, upVec) > 0.0 || cameraPosition.y > cheight)c = renderClouds(cpos, c, cloudsIT);
#endif
}/*--------------------------------------*/
//Draw fog
vec3 fogC = hr.rgb*(0.7+0.3*tmult)*(1.33-rainStrength*0.67);
float fogF = calcFog(fragpos0.xyz);
vec3 foglandC = fogC;
foglandC.b *= (1.5-0.5*rainStrength);
/*----------------------------------------------------------------*/
//Render before transparency
#if defined metallicRefl || defined polishedRefl
if (isMetallic || isPolished) {
vec3 relfNormal = decode(texture2D(colortex1,texcoord).xy);
vec3 reflectedVector = reflect(normalfragpos0, relfNormal);
float normalDotEye = dot(relfNormal, normalfragpos0);
float fresnel = pow(clamp(1.0 + normalDotEye,0.0,1.0), 4.0);
fresnel = mix(0.09,1.0,fresnel); //F0
vec3 sky_c = getSkyc(reflectedVector)*metallicSky;
vec4 reflection = raytrace(fragpos0.xyz, sky_c, reflectedVector, depthtex1, gbufferProjection, gbufferProjectionInverse);
reflection.rgb = mix(sky_c, reflection.rgb, reflection.a)*0.5;
c = mix(c,reflection.rgb,fresnel*metalStrength);
}
#endif
//if (transparency) { //this broke in iris 1.21.5+
vec3 normal = texture2D(colortex2,texcoord).xyz;
float sky = normal.z;
bool reflectiveWater = sky < 0.2499 && dot(normal,normal) > 0.0;
bool reflectiveIce = sky > 0.2499 && sky < 0.4999 && dot(normal,normal) > 0.0;
bool iswater = sky < 0.2499;
bool isice = sky > 0.2499 && sky < 0.4999;
if (iswater) sky *= 4.0;
if (isice) sky = (sky - 0.25)*4.0;
if (!iswater && !isice) sky = (sky - 0.5)*4.0;
sky = clamp(sky*1.2-2./16.0*1.2,0.,1.0);
sky *= sky;
normal = max(normalize(decode(normal.xy)),vec3(-1.0)); //Using max to fix issues on widescreens.
#ifndef DISTANT_HORIZONS
//draw fog for transparency
float iswater2 = float(iswater);
float skylight = pow(max(lightmap.y-2.0/16.0,0.0)*1.14285714286, 1.0);
c = mix(c, fogC, fogF-fogF) / (1.0 + 5.0*night*iswater2*skylight);
if(depth1 < comp)c = mix(hr.rgb*(1.0-rainStrength*0.25), c, exp(-exp2(length(fragpos1.xyz) / far * 16.0 - 14.0))); //chunk border fog through transparency, land only
#endif
//Draw transparency and entities
vec3 finalAc = texture2D(gaux2, texcoord.xy).rgb;
float alphaT = clamp(length(trp.rgb)*1.02,0.0,1.0);
c = mix(c,c*(trp.rgb*0.9999+0.0001)*1.732,alphaT)*(1.0-alphaT) + finalAc;
/*-----------------------------------------------------------------------------------------*/
/*
#if defined waterRefl || defined iceRefl
if (reflectiveWater || reflectiveIce) {
vec3 wFragpos1 = ScreenSpace();
vec3 reflectedVector = reflect(wFragpos1, normal);
float normalDotEye = dot(normal, wFragpos1);
float fresnel = pow(clamp(1.0 + normalDotEye,0.0,1.0), 4.0);
fresnel = mix(0.09,1.0,fresnel); //F0
fresnel *= 0.75;
vec3 sky_c = getSkyc(reflectedVector);
sky_c = (isEyeInWater == 0)? ((drawSun(reflectedVector, sky_c, 1.0)+drawMoon(reflectedVector, sky_c, 1.0)) * 0.5)*sky : pow(vec3(0.25,0.5,0.72),vec3(2.2))*rawAvg*0.1;
#if defined Cloud_reflection && (Clouds == 2 || Clouds == 3 || Clouds == 4)
vec3 cloudVector = normalize(gbufferModelViewInverse*vec4(reflect(fragpos1.xyz, normal), 1.0)).xyz;
#if Clouds == 2 || Clouds == 4
sky_c += drawCloud(reflectedVector, vec3(0.0))*1.5;
#endif
#if Clouds == 3 || Clouds == 4
sky_c += renderClouds(cloudVector, c, cloudreflIT);
#endif
#endif
vec4 reflColor = vec4(sky_c, 0.0);
vec3 reflection = newTrace(reflectedVector, fragpos0.xyz, fract(dot(gl_FragCoord.xy, vec2(0.5, 0.25))), fresnel);
if (reflection.z < 1.0){
reflColor.rgb = pow(texture2D(gaux1, reflection.xy).rgb, vec3(2.2))*257.0;
reflColor.a = 1.0;
bool land = texture2D(depthtex1, reflection.xy).x < comp;
if (isEyeInWater == 0) reflColor.rgb = land ? mix(reflColor.rgb, sky_c.rgb*(0.7+0.3*tmult)*(1.33-rainStrength*0.8), calcFog(fragpos0.xyz)) : drawSun(reflectedVector.rgb, sky_c, 1.0);
}
#ifndef waterRefl
if(reflectiveWater)reflColor.a = 0.0;
#endif
#ifndef iceRefl
if(reflectiveIce)reflColor.a = 0.0;
#endif
reflColor.rgb = mix(sky_c.rgb, reflColor.rgb, reflColor.a);
c.rgb = mix(c.rgb, reflColor.rgb, fresnel);
}
#endif
*/
if (reflectiveWater || reflectiveIce) {
#ifdef DISTANT_HORIZONS
if(DH_reflective){
normalfragpos0 = DHnormalfragpos0;
fragpos0.xyz = DHfragpos0.xyz;
}
#endif
vec3 reflectedVector = reflect(normalfragpos0, normal);
float normalDotEye = dot(normal, normalfragpos0);
float fresnel = pow(clamp(1.0 + normalDotEye,0.0,1.0), 4.0);
fresnel = mix(0.09,1.0,fresnel); //F0
vec3 sky_c = getSkyc(reflectedVector);
#if defined Cloud_reflection && (Clouds == 2 || Clouds == 3 || Clouds == 4)
vec3 cloudVector = normalize(gbufferModelViewInverse*vec4(reflect(fragpos0.xyz, normal), 1.0)).xyz;
#if Clouds == 2 || Clouds == 4
sky_c += drawCloud(reflectedVector, vec3(0.0))*1.5;
#endif
#if Clouds == 3 || Clouds == 4
sky_c += renderClouds(cloudVector, c, cloudreflIT);
#endif
#endif
#if defined waterRefl || defined iceRefl
vec4 reflection = raytrace(fragpos0.xyz, sky_c, reflectedVector, depthtex1, gbufferProjection, gbufferProjectionInverse);
#ifdef DISTANT_HORIZONS
if(DH_reflective) reflection = raytrace(DHfragpos0.xyz, sky_c, reflectedVector, dhDepthTex1, dhProjection, dhProjectionInverse);
#endif
#else
vec4 reflection = vec4(0.0);
#endif
#ifndef waterRefl
if(reflectiveWater){ reflection = vec4(0.0); fresnel *= 0.5; }
#endif
#ifndef iceRefl
if(reflectiveIce){ reflection = vec4(0.0); fresnel *= 0.5; }
#endif
sky_c = (isEyeInWater == 0)? ((drawSun(reflectedVector, sky_c, 1.0)+drawMoon(reflectedVector, sky_c, 1.0)) * 0.5)*sky : pow(vec3(0.25,0.5,0.72),vec3(2.2))*rawAvg*0.1;
reflection.rgb = mix(sky_c, reflection.rgb, reflection.a)*0.85;
c = mix(c,reflection.rgb,fresnel);
#ifdef DISTANT_HORIZONS
#ifdef Fog
if(length(fragpos0.xyz) > dither * 32.0 - 16.0 + far) c = mix(c.rgb, hr.rgb*(1.0-rainStrength*0.25), clamp((length(DHfragpos0.xyz) - dhRenderDistance * 0.05) / dhRenderDistance, 0.0, 1.0));
#endif
#endif
}
bool land = depth0 < comp;
#ifdef RainReflections
vec3 wnormal = decode(texture2D(colortex1,texcoord).xy);
float sky_lightmap = max(lightmap.y-2.0/16.0,0.0)*1.14285714286;
float iswet = wetness*pow(sky_lightmap, 20.0)*sqrt(max(dot(wnormal,upVec),0.0));
#ifdef BiomeCheck
bool isRaining = (BiomeTemp >= 0.15) && (BiomeTemp <= 1.0) && iswet > 0.01 && land && !transparency && isEyeInWater == 0.0;
#else
bool isRaining = iswet > 0.01 && land && !transparency && isEyeInWater == 0.0;
#endif
if (isRaining) {
vec2 wpos = (gbufferModelViewInverse*fragpos0).xz+cameraPosition.xz;
wnormal *= 1.0+calcRainripples(wpos); //modify normals with noise / rain ripples before reflecting
vec3 reflectedVector = reflect(fragpos0.xyz, wnormal); //TODO Improve reflections distortion
float normalDotEye = dot(normalize(reflectedVector - fragpos0.xyz), normalfragpos0.xyz);
float fresnel = pow(clamp(1.0 + normalDotEye,0.0,1.0), 4.0);
fresnel = fresnel+0.09*(1.0-fresnel);
vec3 sky_c = getSkyc(reflectedVector);
vec4 reflection = raytraceLand(fragpos0.xyz, sky_c, normalize(reflectedVector));
reflection.rgb = mix(sky_c, reflection.rgb, reflection.a)*0.5;
c = mix(c.rgb, reflection.rgb, fresnel*iswet); //smooth out wetness start and end
}
#endif
#if Clouds == 3
if(!island && rainStrength > 0.01)c = mix(c,fogC,fogF*0.75); //tint vl clouds with fog while raining, changed from land to island check for DH, might cause issues
#endif
#ifndef Volumetric_Lighting
#ifdef Godrays
float sunpos = abs(dot(normalfragpos0,normalize(sunPosition.xyz)));
#ifdef DISTANT_HORIZONS
if(DHdepth1 < depth1) sunpos = abs(dot(DHnormalfragpos0,normalize(sunPosition.xyz)));
#endif
float illuminationDecay = pow(sunpos,30.0)+pow(sunpos,16.0)*0.8+pow(sunpos,2.0)*0.125;
vec2 deltaTextCoord = (lightPos-texcoord)*0.01;
vec2 textCoord = texcoord*0.5+0.5;
float gr = texture2DLod(gaux1, textCoord + deltaTextCoord,1).a;
gr += texture2DLod(gaux1, textCoord + 2.0 * deltaTextCoord,1).a;
gr += texture2DLod(gaux1, textCoord + 3.0 * deltaTextCoord,1).a;
gr += texture2DLod(gaux1, textCoord + 4.0 * deltaTextCoord,1).a;
gr += texture2DLod(gaux1, textCoord + 5.0 * deltaTextCoord,1).a;
gr += texture2DLod(gaux1, textCoord + 6.0 * deltaTextCoord,1).a;
gr += texture2DLod(gaux1, textCoord + 7.0 * deltaTextCoord,1).a;
vec3 ufogCG = sky1.rgb*0.1;
ufogCG.r *= 0.0;
ufogCG *= (1.0-0.85*night);
vec3 finalGC = lightColor;
if(isEyeInWater == 1.0) finalGC.rgb = ufogCG*2.0; //Underwater godrays should use underwater fog color
vec3 grC = finalGC*Godrays_Density;
#if MC_VERSION >= 11900
if(blindness < 1.0 && darknessFactor < 1.0)c += grC*gr/7.0*illuminationDecay; //disable godrays when in darkness or blindess, to prevent bugs.
#else
if(blindness < 1.0)c += grC*gr/7.0*illuminationDecay;
#endif
#endif
#endif
#ifdef Volumetric_Lighting
const float exposure = 1.05;
//sun-moon switch
vec3 lightVec = -sunVec;
vec3 lightcol = moonlight*5.0;
if (sunVisibility > 0.2){
lightVec = sunVec;
lightcol = sunlight;
}
float phase = 2.5+exp(dot(normalfragpos0,lightVec)*3.0)/3.0;
float vgr = texture2DLod(gaux1, texcoord, 1).a;
vec3 vgrC = lightcol*exposure*phase*0.08*(0.25+0.75*tmult*tmult)*tr*(1.0+pow(1.0-eyeBrightnessSmooth.y/255.0,2.0))*(1.0-rainStrength*0.9);
vgrC = mix(vgrC, c.rgb, 1.0-exp(-length(fragpos0.xyz)/(0.2*far-near))); //set an offset and scale with render distance, preventing unlimited VL, fixing fog and various issues.
if (depth0 > comp) { vgrC *= 0.0; vgr *= 0.0; } //don't apply to sky
c += vgrC*vgr*(1.0-isEyeInWater)*VL_amount;
#endif
#ifdef Lens_Flares
c += texture2D(composite,texcoord.xy*0.5+0.5+1.0/vec2(viewWidth,viewHeight)).rgb*fading*30*30/100*pow(dot(texture2D(gaux1, vec2(1.0)/vec2(viewWidth,viewHeight)).w, 1.0), 2.0);
#endif
#ifndef DISTANT_HORIZONS
#ifdef Fog
//Render fog at the end.
//land fog
if(land)c = mix(c,foglandC*(1.0-isEyeInWater),fogF);
//Chunk border fog
if(land)c = mix(hr.rgb*(1.0-rainStrength*0.25), c, exp(-exp2(length(fragpos0.xyz) / far * 16.0 - 14.0)));
#endif
#endif
vec3 ufogC = sky1.rgb*0.1;
// ufogC.g *= 1.0+2.0*inSwamp; //make fog greenish in swamp biomes
ufogC.r *= 0.0;
ufogC *= (1.0-0.85*night);
#ifdef Underwater_Fog
if (isEyeInWater == 1.0) c = mix(c, ufogC, 1.0-exp(-length(fragpos0.xyz)/uFogDensity));
#endif
if (isEyeInWater == 2.0) c = mix(c, vec3(1.0, 0.0125, 0.0), 1.0-exp(-length(fragpos0.xyz))); //lava fog
if(blindness > 0.9) c = mix(c, vec3(0.0), 1.0-exp(-length(fragpos1.xyz)*1.125)); //blindness fog
#if MC_VERSION >= 11900
if(darknessFactor > 0.9) c = mix(c, vec3(0.0), 1.0-exp(-length(fragpos1.xyz)*0.40)) * (1.0-darknessLightFactor*2.0); //Darkness fog
#endif
c = (c/50.0*pow(eyeAdapt,0.88));
gl_FragData[0] = vec4(c,1.0);
}

145
shaders/composite1.vsh Normal file
View File

@@ -0,0 +1,145 @@
#version 120
#define lightingColors
#include "shaders.settings"
varying vec2 texcoord;
varying vec2 lightPos;
varying vec3 sunVec;
varying vec3 upVec;
varying vec3 lightColor;
varying vec3 sky1;
varying vec3 sky2;
varying vec3 nsunlight;
varying vec3 sunlight;
varying vec3 rawAvg;
varying vec3 avgAmbient2;
varying vec3 cloudColor;
varying vec3 cloudColor2;
varying float fading;
varying float tr;
varying float eyeAdapt;
varying float SdotU;
varying float sunVisibility;
varying float moonVisibility;
uniform vec3 sunPosition;
uniform vec3 upPosition;
uniform int worldTime;
uniform float rainStrength;
uniform ivec2 eyeBrightnessSmooth;
uniform mat4 gbufferProjection;
const float redtint = 1.5;
const vec3 ToD[7] = vec3[7]( vec3(redtint,0.15,0.02),
vec3(redtint,0.35,0.09),
vec3(redtint,0.5,0.26),
vec3(redtint,0.5,0.35),
vec3(redtint,0.5,0.36),
vec3(redtint,0.5,0.37),
vec3(redtint,0.5,0.38));
float luma(vec3 color) {
return dot(color,vec3(0.299, 0.587, 0.114));
}
void main() {
//Light pos for Godrays
vec4 tpos = vec4(sunPosition,1.0)*gbufferProjection;
tpos = vec4(tpos.xyz/tpos.w,1.0);
vec2 pos1 = tpos.xy/tpos.z;
lightPos = pos1*0.5+0.5;
/*-------------------------------*/
//Positioning
gl_Position = ftransform();
texcoord = (gl_MultiTexCoord0).xy;
/*--------------------------------*/
//Sun/Moon position
sunVec = normalize(sunPosition);
upVec = normalize(upPosition);
SdotU = dot(sunVec,upVec);
sunVisibility = pow(clamp(SdotU+0.15,0.0,0.15)/0.15,4.0);
moonVisibility = pow(clamp(-SdotU+0.15,0.0,0.15)/0.15,4.0);
/*--------------------------------*/
//reduced the sun color to a 7 array
float hour = max(mod(worldTime/1000.0+2.0,24.0)-2.0,0.0); //-0.1
float cmpH = max(-abs(floor(hour)-6.0)+6.0,0.0); //12
float cmpH1 = max(-abs(floor(hour)-5.0)+6.0,0.0); //1
vec3 temp = ToD[int(cmpH)];
vec3 temp2 = ToD[int(cmpH1)];
sunlight = mix(temp,temp2,fract(hour));
sunlight.rgb += vec3(r_multiplier,g_multiplier,b_multiplier);
sunlight.rgb *= light_brightness;
vec3 sunlight04 = pow(sunlight,vec3(0.454));
/*-----------------------------------------------------------------*/
//Lighting
float eyebright = max(eyeBrightnessSmooth.y/255.0-0.5/16.0,0.0)*1.03225806452;
float SkyL2 = mix(1.0,eyebright*eyebright,eyebright);
vec2 trCalc = min(abs(worldTime-vec2(23050.0,12700.0)),750.0);
tr = max(min(trCalc.x,trCalc.y)/375.0-1.0,0.0);
float tr = clamp(min(min(distance(float(worldTime),23050.0),750.0),min(distance(float(worldTime),12700.0),800.0))/800.0-0.5,0.0,1.0)*2.0;
vec4 bounced = vec4(0.5,0.66,1.3,0.27);
vec3 sun_ambient = bounced.w * (vec3(0.25,0.62,1.32)-rainStrength*vec3(0.1,0.47,1.17))*(1.0+rainStrength*7.0) + sunlight*(bounced.x + bounced.z)*(1.0-rainStrength*0.95);
const vec3 moonlight = vec3(0.0016, 0.00288, 0.00448);
vec3 moon_ambient = (moonlight + moonlight*eyebright*eyebright*eyebright);
float tr2 = max(min(trCalc.x,trCalc.y)/375.0-1.0,0.0);
vec4 bounced2 = vec4(0.5*SkyL2,0.66*SkyL2,0.7,0.3);
vec3 sun_ambient2 = bounced2.w * (vec3(0.25,0.62,1.32)-rainStrength*vec3(0.11,0.32,1.07)) + sunlight*(bounced2.x + bounced2.z);
vec3 moon_ambient2 = (moonlight*3.5);
rawAvg = (sun_ambient*sunVisibility + 8.0*moonlight*moonVisibility)*(0.05+tr*0.15)*4.7+0.0002;
vec3 avgAmbient =(sun_ambient2*sunVisibility + moon_ambient2*moonVisibility)*eyebright*eyebright*(0.05+tr2*0.15)*4.7+0.0006;
avgAmbient2 = (sun_ambient*sunVisibility + 6.0*moon_ambient*moonVisibility)*eyebright *(0.27+tr*0.65)+0.0002;
eyeAdapt = log(clamp(luma(avgAmbient),0.007,80.0))/log(2.6)*0.35;
eyeAdapt = 1.0/pow(eyeLight,eyeAdapt)*1.75;
avgAmbient /= sqrt(3.0);
avgAmbient2 /= sqrt(3.0);
/*--------------------------------*/
//Light pos for godrays
float truepos = sign(sunPosition.z)*1.0; //1 -> sun / -1 -> moon
lightColor = mix(sunlight*sunVisibility+0.00001,12.*moonlight*moonVisibility+0.00001,(truepos+1.0)/2.);
if (length(lightColor)>0.001)lightColor = mix(lightColor,normalize(vec3(0.3,0.3,0.3))*pow(normalize(lightColor),vec3(0.4))*length(lightColor)*0.03,rainStrength)*(0.25+0.25*tr);
/*------------------------------------------------*/
//Sky lighting
float mcosS = max(SdotU,0.0);
float skyMult = max(SdotU*0.1+0.1,0.0)/0.2*(1.0-rainStrength*0.6)*0.7;
nsunlight = normalize(pow(mix(sunlight04 ,5.*sunlight04 *sunVisibility*(1.0-rainStrength*0.95)+vec3(0.3,0.3,0.35),rainStrength),vec3(2.2)))*0.6*skyMult;
vec3 sky_color = vec3(0.15, 0.4, 1.);
sky_color = normalize(mix(sky_color,2.*sunlight04 *sunVisibility*(1.0-rainStrength*0.95)+vec3(0.3,0.3,0.3)*length(sunlight04 ),rainStrength)); //normalize colors in order to don't change luminance
sky1 = sky_color*0.6*skyMult;
sky2 = mix(sky_color,mix(nsunlight,sky_color,rainStrength*0.9),1.0-max(mcosS-0.2,0.0)*0.5)*0.6*skyMult;
cloudColor = sunlight04 *sunVisibility*(1.0-rainStrength*0.17)*length(rawAvg) + rawAvg*0.7*(1.0-rainStrength*0.1) + 2.0*moonlight*moonVisibility*(1.0-rainStrength*0.17);
cloudColor2 = 0.1*sunlight*sunVisibility*(1.0-rainStrength*0.15)*length(rawAvg) + 1.5*length(rawAvg)*mix(vec3(0.15, 0.4, 1.),vec3(0.65, 0.65, 0.65),rainStrength)*(1.0-rainStrength*0.1) + 2.0*moonlight*moonVisibility*(1.0-rainStrength*0.15);
vec2 centerLight = abs(lightPos*2.0-1.0);
float distof = max(centerLight.x,centerLight.y);
fading = clamp(1.0-distof*distof*distof*0.,0.0,1.0);
/*-----------------------------------------------------*/
}

197
shaders/composite2.fsh Normal file
View File

@@ -0,0 +1,197 @@
#version 120
/* DRAWBUFFERS:67 */
/* Temporal anti-aliasing (TAA) and adaptive sharpening implementation based on Chocapic13, all credits belong to him:
https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/minecraft-mods/1293898-1-14-chocapic13s-shaders */
#define composite2
#include "shaders.settings"
varying vec2 texcoord;
uniform float viewWidth;
uniform float viewHeight;
vec2 texelSize = vec2(1.0/viewWidth,1.0/viewHeight);
uniform sampler2D colortex6;
uniform sampler2D colortex3; //Input everything from composite1
uniform sampler2D colortex7; //Output bloom and TAA
const bool colortex7Clear = false;
#ifdef TAA
uniform sampler2D depthtex0;
uniform sampler2D colortex0;
uniform sampler2D colortex2;
uniform mat4 gbufferProjectionInverse;
uniform mat4 gbufferModelViewInverse;
uniform mat4 gbufferPreviousProjection;
uniform mat4 gbufferPreviousModelView;
uniform vec3 cameraPosition;
uniform vec3 previousCameraPosition;
uniform float near;
uniform float far;
//setup mats
float getmat = texture2D(colortex0,texcoord).b;
vec3 normal = texture2D(colortex2,texcoord).xyz;
bool emissive = getmat > 0.59 && getmat < 0.61;
bool iswater = normal.z < 0.2499 && dot(normal,normal) > 0.0;
float depth0 = texture2D(depthtex0, texcoord).x;
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz)
vec3 toClipSpace3Prev(vec3 viewSpacePosition) {
return projMAD(gbufferPreviousProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5;
}
vec3 toScreenSpace(vec3 p) {
vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw);
vec3 p3 = p * 2.0 - 1.0;
vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3];
return fragposition.xyz / fragposition.w;
}
#define BLEND_FACTOR 0.1 //[0.01 0.02 0.03 0.04 0.05 0.06 0.08 0.1 0.12 0.14 0.16] higher values = more flickering but sharper image, lower values = less flickering but the image will be blurrier
#define MOTION_REJECTION 1.0 //[0.0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.5] //Higher values=sharper image in motion at the cost of flickering
#define ANTI_GHOSTING 0.0 //[0.0 0.25 0.5 0.75 1.0] High values reduce ghosting but may create flickering
#define FLICKER_REDUCTION 1.0 //[0.0 0.25 0.5 0.75 1.0] High values reduce flickering but may reduce sharpness
//returns the projected coordinates of the closest point to the camera in the 3x3 neighborhood
vec3 closestToCamera5taps(vec2 texcoord){
vec2 du = vec2(texelSize.x*2., 0.0);
vec2 dv = vec2(0.0, texelSize.y*2.);
vec3 dtl = vec3(texcoord,0.) + vec3(-texelSize, texture2D(depthtex0, texcoord - dv - du).x);
vec3 dtr = vec3(texcoord,0.) + vec3( texelSize.x, -texelSize.y, texture2D(depthtex0, texcoord - dv + du).x);
vec3 dmc = vec3(texcoord,0.) + vec3( 0.0, 0.0, texture2D(depthtex0, texcoord).x);
vec3 dbl = vec3(texcoord,0.) + vec3(-texelSize.x, texelSize.y, texture2D(depthtex0, texcoord + dv - du).x);
vec3 dbr = vec3(texcoord,0.) + vec3( texelSize.x, texelSize.y, texture2D(depthtex0, texcoord + dv + du).x);
vec3 dmin = dmc;
dmin = dmin.z > dtr.z? dtr : dmin;
dmin = dmin.z > dtl.z? dtl : dmin;
dmin = dmin.z > dbl.z? dbl : dmin;
dmin = dmin.z > dbr.z? dbr : dmin;
return dmin;
}
//approximation from SMAA presentation from siggraph 2016
vec3 FastCatmulRom(sampler2D colorTex, vec2 texcoord, vec4 rtMetrics, float sharpenAmount){
vec2 position = rtMetrics.zw * texcoord;
vec2 centerPosition = floor(position - 0.5) + 0.5;
vec2 f = position - centerPosition;
vec2 f2 = f * f;
vec2 f3 = f * f2;
float c = sharpenAmount;
vec2 w0 = -c * f3 + 2.0 * c * f2 - c * f;
vec2 w1 = (2.0 - c) * f3 - (3.0 - c) * f2 + 1.0;
vec2 w2 = -(2.0 - c) * f3 + (3.0 - 2.0 * c) * f2 + c * f;
vec2 w3 = c * f3 - c * f2;
vec2 w12 = w1 + w2;
vec2 tc12 = rtMetrics.xy * (centerPosition + w2 / w12);
vec3 centerColor = texture2D(colorTex, vec2(tc12.x, tc12.y)).rgb;
vec2 tc0 = rtMetrics.xy * (centerPosition - 1.0);
vec2 tc3 = rtMetrics.xy * (centerPosition + 2.0);
vec4 color = vec4(texture2D(colorTex, vec2(tc12.x, tc0.y )).rgb, 1.0) * (w12.x * w0.y ) +
vec4(texture2D(colorTex, vec2(tc0.x, tc12.y)).rgb, 1.0) * (w0.x * w12.y) +
vec4(centerColor, 1.0) * (w12.x * w12.y) +
vec4(texture2D(colorTex, vec2(tc3.x, tc12.y)).rgb, 1.0) * (w3.x * w12.y) +
vec4(texture2D(colorTex, vec2(tc12.x, tc3.y )).rgb, 1.0) * (w12.x * w3.y );
return color.rgb/color.a;
}
vec3 calcTAA(){
//reproject previous frame
vec3 closestToCamera = closestToCamera5taps(texcoord);
vec3 fragposition = toScreenSpace(closestToCamera);
fragposition = mat3(gbufferModelViewInverse) * fragposition + gbufferModelViewInverse[3].xyz + (cameraPosition - previousCameraPosition);
vec3 previousPosition = mat3(gbufferPreviousModelView) * fragposition + gbufferPreviousModelView[3].xyz;
previousPosition = toClipSpace3Prev(previousPosition);
previousPosition.xy = texcoord + (previousPosition.xy - closestToCamera.xy);
//to reduce error propagation caused by interpolation during history resampling, we will introduce back some aliasing in motion
vec2 d = 0.5-abs(fract(previousPosition.xy*vec2(viewWidth,viewHeight)-texcoord*vec2(viewWidth,viewHeight))-0.5);
float rej = dot(d,d)*MOTION_REJECTION;
//reject history if off-screen and early exit
if (previousPosition.x < 0.0 || previousPosition.y < 0.0 || previousPosition.x > 1.0 || previousPosition.y > 1.0) return texture2D(colortex3, texcoord).rgb;
vec3 albedoCurrent0 = texture2D(colortex3, texcoord).rgb;
vec3 albedoCurrent1 = texture2D(colortex3, texcoord + vec2(texelSize.x,texelSize.y)).rgb;
vec3 albedoCurrent2 = texture2D(colortex3, texcoord + vec2(texelSize.x,-texelSize.y)).rgb;
vec3 albedoCurrent3 = texture2D(colortex3, texcoord + vec2(-texelSize.x,-texelSize.y)).rgb;
vec3 albedoCurrent4 = texture2D(colortex3, texcoord + vec2(-texelSize.x,texelSize.y)).rgb;
vec3 albedoCurrent5 = texture2D(colortex3, texcoord + vec2(0.0,texelSize.y)).rgb;
vec3 albedoCurrent6 = texture2D(colortex3, texcoord + vec2(0.0,-texelSize.y)).rgb;
vec3 albedoCurrent7 = texture2D(colortex3, texcoord + vec2(-texelSize.x,0.0)).rgb;
vec3 albedoCurrent8 = texture2D(colortex3, texcoord + vec2(texelSize.x,0.0)).rgb;
//turn sharpening off if set to 0.0, don't sharpen emissive blocks, water, sky and clouds
if(TAA_sharpness > 0.0 && !iswater && !emissive && depth0 < 1.0-near/far/far){
vec3 m1 = (albedoCurrent0 + albedoCurrent1 + albedoCurrent2 + albedoCurrent3 + albedoCurrent4 + albedoCurrent5 + albedoCurrent6 + albedoCurrent7 + albedoCurrent8)/9.0;
vec3 std = abs(albedoCurrent0 - m1) + abs(albedoCurrent1 - m1) + abs(albedoCurrent2 - m1) + abs(albedoCurrent3 - m1) + abs(albedoCurrent3 - m1) +
abs(albedoCurrent4 - m1) + abs(albedoCurrent5 - m1) + abs(albedoCurrent6 - m1) + abs(albedoCurrent7 - m1) + abs(albedoCurrent8 - m1);
float contrast = 1.0 - dot(std,vec3(0.299, 0.587, 0.114))/9.0;
albedoCurrent0 = albedoCurrent0*(1.0+TAA_sharpness*contrast)-(albedoCurrent5+albedoCurrent6+albedoCurrent7+albedoCurrent8+(albedoCurrent1 + albedoCurrent2 + albedoCurrent3 + albedoCurrent4)/2.0)/6.0*TAA_sharpness*contrast;
}
//Assuming the history color is a blend of the 3x3 neighborhood, we clamp the history to the min and max of each channel in the 3x3 neighborhood
vec3 cMax = max(max(max(albedoCurrent0,albedoCurrent1),albedoCurrent2),max(albedoCurrent3,max(albedoCurrent4,max(albedoCurrent5,max(albedoCurrent6,max(albedoCurrent7,albedoCurrent8))))));
vec3 cMin = min(min(min(albedoCurrent0,albedoCurrent1),albedoCurrent2),min(albedoCurrent3,min(albedoCurrent4,min(albedoCurrent5,min(albedoCurrent6,min(albedoCurrent7,albedoCurrent8))))));
vec3 albedoPrev = FastCatmulRom(colortex7, previousPosition.xy,vec4(texelSize, 1.0/texelSize), 0.82).xyz;
vec3 finalcAcc = clamp(albedoPrev,cMin,cMax);
//increases blending factor if history is far away from aabb, reduces ghosting at the cost of some flickering
float luma = dot(albedoPrev,vec3(0.21, 0.72, 0.07));
float isclamped = distance(albedoPrev,finalcAcc)/luma;
//reduces blending factor if current texel is far from history, reduces flickering
float lumDiff2 = distance(albedoPrev,albedoCurrent0)/luma;
lumDiff2 = 1.0-clamp(lumDiff2*lumDiff2,0.0,1.0)*FLICKER_REDUCTION;
//Blend current pixel with clamped history
return mix(finalcAcc,albedoCurrent0,clamp(BLEND_FACTOR*lumDiff2+rej+isclamped*ANTI_GHOSTING+0.01,0.0,1.0));
}
#endif
#ifdef Bloom
vec3 calcBloom(){
const int nSteps = 25;
const int center = 12; //=nSteps-1 / 2
vec3 blur = vec3(0.0);
float tw = 0.0;
for (int i = 0; i < nSteps; i++) {
float dist = abs(i-float(center))/center;
float weight = (exp(-(dist*dist)/ 0.28));
vec3 bsample = texture2D(colortex7,(texcoord*4.0 + 2.0*texelSize*vec2(i-center,0.0))).rgb;
blur += bsample*weight;
tw += weight;
}
blur /= tw;
return clamp(blur,0.0,1.0); //fix flashing black square
}
#endif
void main() {
#ifdef Bloom
gl_FragData[0] = vec4(calcBloom(), 1.0);
#else
gl_FragData[0] = vec4(0.0);
#endif
#ifdef TAA
gl_FragData[1] = vec4(calcTAA(), 1.0);
#else
gl_FragData[1] = texture2D(colortex3, texcoord); //if TAA is disabled just passthrough data from previous buffer.
#endif
}

8
shaders/composite2.vsh Normal file
View File

@@ -0,0 +1,8 @@
#version 120
varying vec2 texcoord;
void main() {
gl_Position = ftransform();
texcoord = gl_MultiTexCoord0.xy;
}

31
shaders/dh_terrain.fsh Normal file
View File

@@ -0,0 +1,31 @@
#version 120
/* DRAWBUFFERS:01 */
#define gbuffers_terrain
#include "shaders.settings"
varying vec4 color;
varying vec4 normal;
varying float lmcoord;
//encode normal in two channel (xy), emissive lightmap (z) and sky lightmap (w), blend mode must be disabled in shaders.properties for this to work without issues.
vec4 encode (vec3 n){
return vec4(n.xy*inversesqrt(n.z*8.0+8.0) + 0.5, lmcoord, 1.0); // set sky lightmap to 1 for distant horizons
}
vec3 RGB2YCoCg(vec3 c){
return vec3( 0.25*c.r+0.5*c.g+0.25*c.b, 0.5*c.r-0.5*c.b +0.5, -0.25*c.r+0.5*c.g-0.25*c.b +0.5);
}
void main() {
vec4 cAlbedo = vec4(RGB2YCoCg(color.rgb),color.a);
bool pattern = (mod(gl_FragCoord.x,2.0)==mod(gl_FragCoord.y,2.0));
cAlbedo.g = (pattern)?cAlbedo.b: cAlbedo.g;
cAlbedo.b = normal.a;
gl_FragData[0] = cAlbedo;
gl_FragData[1] = encode(normal.xyz);
}

43
shaders/dh_terrain.vsh Normal file
View File

@@ -0,0 +1,43 @@
#version 120
#define composite2
#define gbuffers_terrain
#include "shaders.settings"
varying vec4 color;
varying vec4 normal;
varying float lmcoord;
uniform mat4 gbufferModelView;
uniform mat4 gbufferModelViewInverse;
#ifdef TAA
uniform float viewWidth;
uniform float viewHeight;
vec2 texelSize = vec2(1.0/viewWidth,1.0/viewHeight);
uniform int framemod8;
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-1.,3.)/8.,
vec2(5.0,1.)/8.,
vec2(-3,-5.)/8.,
vec2(-5.,5.)/8.,
vec2(-7.,-1.)/8.,
vec2(3,7.)/8.,
vec2(7.,-7.)/8.);
#endif
void main() {
lmcoord = gl_MultiTexCoord1.x/255.0;
normal.a = 0.02;
normal.xyz = normalize(gl_NormalMatrix * gl_Normal);
color = gl_Color;
gl_Position = gl_ProjectionMatrix * gbufferModelView * gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
#ifdef TAA
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
#endif
}

125
shaders/dh_water.fsh Normal file
View File

@@ -0,0 +1,125 @@
#version 120
#define gbuffers_shadows
#define gbuffers_water
#include "shaders.settings"
varying vec4 color;
varying vec4 ambientNdotL;
varying vec2 lmcoord;
varying float dist;
varying vec3 viewVector;
varying vec3 worldpos;
varying mat3 tbnMatrix;
uniform sampler2D noisetex;
uniform sampler2D depthtex0;
uniform float far;
uniform float viewHeight;
uniform float viewWidth;
uniform float frameTimeCounter;
vec4 encode (vec3 n,float dif){
float p = sqrt(n.z*8+8);
float vis = lmcoord.t;
if (ambientNdotL.a > 0.9) vis = vis * 0.25;
if (ambientNdotL.a > 0.4 && ambientNdotL.a < 0.6) vis = vis*0.25+0.25;
if (ambientNdotL.a < 0.1) vis = vis*0.25+0.5;
return vec4(n.xy/p + 0.5,vis,1.0);
}
mat2 rmatrix(float rad){
return mat2(vec2(cos(rad), -sin(rad)), vec2(sin(rad), cos(rad)));
}
float calcWaves(vec2 coord, float iswater){
if(iswater > 0.9){
vec2 movement = abs(vec2(0.0, -frameTimeCounter * 0.31365));
coord *= 0.262144;
vec2 coord0 = coord * rmatrix(1.0) - movement * 4.0;
coord0.y *= 3.0;
vec2 coord1 = coord * rmatrix(0.5) - movement * 1.5;
coord1.y *= 3.0;
vec2 coord2 = coord + movement * 0.5;
coord2.y *= 3.0;
coord0 *= waveSize;
coord1 *= waveSize;
float wave = 1.0 - texture2D(noisetex,coord0 * 0.005).x * 10.0; //big waves
wave += texture2D(noisetex,coord1 * 0.010416).x * 7.0; //small waves
wave += sqrt(texture2D(noisetex,coord2 * 0.045).x * 6.5) * 1.33; //noise texture
wave *= 0.0157;
return wave;
} else return sqrt(texture2D(noisetex,coord * 0.5).x) * 0.035; //translucent noise, non water
}
vec3 calcBump(vec2 coord, float iswater){
const vec2 deltaPos = vec2(0.25, 0.0);
float h0 = calcWaves(coord, iswater);
float h1 = calcWaves(coord + deltaPos.xy, iswater);
float h2 = calcWaves(coord - deltaPos.xy, iswater);
float h3 = calcWaves(coord + deltaPos.yx, iswater);
float h4 = calcWaves(coord - deltaPos.yx, iswater);
float xDelta = ((h1-h0)+(h0-h2));
float yDelta = ((h3-h0)+(h0-h4));
return vec3(vec2(xDelta,yDelta)*0.5, 0.5); //z = 1.0-0.5
}
vec3 calcParallax(vec3 pos, float iswater){
float getwave = calcWaves(pos.xz - pos.y, iswater);
pos.xz += (getwave * viewVector.xy) * waterheight;
return pos;
}
void main() {
//Fix DH rendering through terrain, offset for reflections
if(texture2D(depthtex0, gl_FragCoord.xy / vec2(viewWidth, viewHeight)).x < 0.9990) discard;
float iswater = clamp(ambientNdotL.a*2.0-1.0,0.0,1.0);
vec4 albedo = color;
albedo.rgb = pow(albedo.rgb,vec3(2.2));
float texvis = wtexblend;
#ifndef watertex
texvis = 0.11;
if(iswater > 0.9)albedo.rgb = vec3(waterCR,waterCG,waterCB);
#endif
//Bump and parallax mapping
vec3 waterpos = worldpos;
#ifdef WaterParallax
waterpos = calcParallax(waterpos, iswater);
#endif
vec3 bump = calcBump(waterpos.xz - waterpos.y, iswater);
vec3 newnormal = normalize(bump * tbnMatrix);
vec3 fColor = albedo.rgb*(ambientNdotL.rgb);
float alpha = mix(albedo.a,texvis,iswater);
//if(iswater > 0.9)alpha *= waterA;
float dither = fract(0.75487765 * gl_FragCoord.x + 0.56984026 * gl_FragCoord.y);
dither = fract(frameTimeCounter * 16.0 + dither);
if(dist > dither * 32.0 - 16.0 + far && iswater > 0.9) alpha *= waterA; //blend water transparency
if(dist < dither * 32.0 - 16.0 + far && ambientNdotL.a > 0.4 && ambientNdotL.a < 0.6) alpha *= 0.0; //blend ice transparency
/* DRAWBUFFERS:526 */
gl_FragData[0] = vec4(fColor,alpha);
gl_FragData[1] = encode(newnormal.xyz, 0.0);
gl_FragData[2] = vec4(normalize(albedo.rgb+0.00001),alpha);
}

167
shaders/dh_water.vsh Normal file
View File

@@ -0,0 +1,167 @@
#version 120
#define composite2
#define gbuffers_shadows
#define gbuffers_water
#define lightingColors
#include "shaders.settings"
varying vec4 color;
varying vec4 ambientNdotL;
varying vec2 lmcoord;
varying float dist;
varying vec3 viewVector;
varying vec3 worldpos;
varying mat3 tbnMatrix;
uniform vec3 cameraPosition;
uniform vec3 sunPosition;
uniform vec3 upPosition;
uniform mat4 gbufferModelView;
uniform mat4 gbufferModelViewInverse;
uniform int worldTime;
uniform float rainStrength;
uniform float nightVision;
#ifdef Waving_Water
uniform float frameTimeCounter;
const float PI = 3.1415927;
#endif
const vec3 ToD[7] = vec3[7]( vec3(0.58597,0.16,0.005),
vec3(0.58597,0.31,0.05),
vec3(0.58597,0.45,0.16),
vec3(0.58597,0.5,0.35),
vec3(0.58597,0.5,0.36),
vec3(0.58597,0.5,0.37),
vec3(0.58597,0.5,0.38));
float SunIntensity(float zenithAngleCos, float sunIntensity, float cutoffAngle, float steepness){
return sunIntensity * max(0.0, 1.0 - exp(-((cutoffAngle - acos(zenithAngleCos))/steepness)));
}
float luma(vec3 color) {
return dot(color,vec3(0.299, 0.587, 0.114));
}
#ifdef TAA
uniform float viewWidth;
uniform float viewHeight;
vec2 texelSize = vec2(1.0/viewWidth,1.0/viewHeight);
uniform int framemod8;
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-1.,3.)/8.,
vec2(5.0,1.)/8.,
vec2(-3,-5.)/8.,
vec2(-5.,5.)/8.,
vec2(-7.,-1.)/8.,
vec2(3,7.)/8.,
vec2(7.,-7.)/8.);
#endif
void main() {
//pos
vec3 normal = normalize(gl_NormalMatrix * gl_Normal).xyz;
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
worldpos = position.xyz + cameraPosition;
color = gl_Color;
lmcoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
//Transparency stuff
ambientNdotL.a = 0.0;
float iswater = 1.0; //disable lightmap on water, make light go through instead
if(dhMaterialId == DH_BLOCK_WATER) {
ambientNdotL.a = 1.0;
iswater = 0.0;
#ifdef Waving_Water
float fy = fract(worldpos.y + 0.001);
float wave = 0.05 * sin(2 * PI * (frameTimeCounter*0.8 + worldpos.x / 2.5 + worldpos.z / 5.0))
+ 0.05 * sin(2 * PI * (frameTimeCounter*0.6 + worldpos.x / 6.0 + worldpos.z / 12.0));
position.y += clamp(wave, -fy, 1.0-fy)*waves_amplitude;
#endif
} else ambientNdotL.a = 0.5;
//---
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
#ifdef TAA
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
#endif
//ToD
float hour = max(mod(worldTime/1000.0+2.0,24.0)-2.0,0.0); //-0.1
float cmpH = max(-abs(floor(hour)-6.0)+6.0,0.0); //12
float cmpH1 = max(-abs(floor(hour)-5.0)+6.0,0.0); //1
#ifdef MC_GL_VENDOR_ATI
vec3 sunlight = vec3(1.0); //Time of day calculation breaks water on amd drivers 18.8.1, last working driver was 18.6.1, causes heavy flickering. TESTED ON RX460
#else
vec3 sunlight = mix(ToD[int(cmpH)], ToD[int(cmpH1)], fract(hour));
#endif
sunlight.rgb += vec3(r_multiplier,g_multiplier,b_multiplier); //allows lighting colors to be tweaked.
sunlight.rgb *= light_brightness; //brightness needs to be adjusted if we tweak lighting colors.
//---
//lightmap
float torch_lightmap = 16.0-min(15.0,(lmcoord.s-0.5/16.0)*16.0*16.0/15.0);
float fallof1 = clamp(1.0 - pow(torch_lightmap/16.0,4.0),0.0,1.0);
torch_lightmap = fallof1*fallof1/(torch_lightmap*torch_lightmap+1.0);
torch_lightmap *= iswater;
vec3 emissiveLightC = vec3(emissive_R,emissive_G,emissive_B)*torch_lightmap*0.2;
//---
//light bounce
vec3 sunVec = normalize(sunPosition);
vec3 upVec = normalize(upPosition);
vec2 visibility = vec2(dot(sunVec,upVec),dot(-sunVec,upVec));
float cutoffAngle = 1.608;
float steepness = 1.5;
float cosSunUpAngle = dot(sunVec, upVec) * 0.95 + 0.05; //Has a lower offset making it scatter when sun is below the horizon.
float sunE = SunIntensity(cosSunUpAngle, 1000.0, cutoffAngle, steepness); // Get sun intensity based on how high in the sky it is
float NdotL = dot(normal,sunVec);
float NdotU = dot(normal,upVec);
vec2 trCalc = min(abs(worldTime-vec2(23000.0,12700.0)),750.0); //adjust to make day-night switch smoother
float tr = max(min(trCalc.x,trCalc.y)/375.0-1.0,0.0);
visibility = pow(clamp(visibility+0.15,0.0,0.3)/0.3,vec2(4.4));
sunlight = sunlight/luma(sunlight)*sunE*0.0075*0.075*3.*visibility.x;
float skyL = max(lmcoord.t-2./16.0,0.0)*1.14285714286;
float SkyL2 = skyL*skyL;
float skyc2 = mix(1.0,SkyL2,skyL);
vec4 bounced = vec4(NdotL,NdotL,NdotL,NdotU) * vec4(-0.14*skyL*skyL,0.33,0.7,0.1) + vec4(0.6,0.66,0.7,0.25);
bounced *= vec4(skyc2,skyc2,visibility.x-tr*visibility.x,0.8);
vec3 ambientC = mix(vec3(0.3, 0.5, 1.1),vec3(0.08,0.1,0.1),rainStrength)*length(sunlight)*bounced.w;
ambientC += 0.25*sunlight*(bounced.x + bounced.z)*(0.03+tr*0.17)/0.4*(1.0-rainStrength*0.98) + length(sunlight)*0.2*(1.0-rainStrength*0.9);
ambientC += sunlight*(NdotL*0.5+0.45)*visibility.x*(1.0-tr)*(1.0-tr)*4.*(1.0-rainStrength*0.98);
//lighting during night time
const vec3 moonlight = vec3(0.0024, 0.00432, 0.0078);
vec3 moon_ambient = (moonlight*2.0 + moonlight*bounced.y)*(4.0-rainStrength*0.95)*0.2;
vec3 moonC = (moon_ambient*visibility.y)*SkyL2*(0.03*0.65+tr*0.17*0.65);
float wminlight = (nightVision > 0.01)? 0.075: 0.00008;
ambientNdotL.rgb = ambientC*SkyL2*0.3 + moonC + emissiveLightC + wminlight;
//sunlight = mix(sunlight,moonlight*(1.0-rainStrength*0.9),visibility.y)*tr;
sunlight = mix(sunlight,moonlight*(1.0-rainStrength*0.9),visibility.y); //remove time check to improve day-night transition
//---
vec3 binormal = normalize(gbufferModelView[2].xyz);
vec3 tangent = normalize(gbufferModelView[0].xyz);
tbnMatrix = mat3(tangent.x, binormal.x, normal.x,
tangent.y, binormal.y, normal.y,
tangent.z, binormal.z, normal.z);
dist = length(gl_ModelViewMatrix * gl_Vertex);
viewVector = tbnMatrix * (gl_ModelViewMatrix * gl_Vertex).xyz;
viewVector.xy = viewVector.xy / dist * 8.25;
}

View File

@@ -0,0 +1 @@
entity.11000=minecraft:lightning_bolt

363
shaders/final.fsh Normal file
View File

@@ -0,0 +1,363 @@
#version 120
/*
Sildur's Vibrant Shaders:
https://www.patreon.com/Sildur
https://sildurs-shaders.github.io/
https://twitter.com/SildurFX
Permissions:
You are not allowed to edit, copy code or share my shaderpack under a different name or claim it as yours.
*/
#define final
#include "shaders.settings"
varying vec2 texcoord;
uniform sampler2D gaux4; //final image
#if Showbuffer > 0
uniform sampler2D colortex0;
uniform sampler2D colortex1;
uniform sampler2D colortex2;
uniform sampler2D colortex3;
uniform sampler2D gaux1;
uniform sampler2D gaux2;
uniform sampler2D gaux3;
#endif
uniform int isEyeInWater;
uniform float aspectRatio;
uniform float viewWidth;
uniform float viewHeight;
uniform float rainStrength;
uniform float frameTimeCounter;
#ifdef Rain_Drops
varying vec2 rainPos1;
varying vec2 rainPos2;
varying vec2 rainPos3;
varying vec2 rainPos4;
varying vec4 weights;
#endif
#if defined Depth_of_Field || defined Motionblur || defined Cloudsblur
uniform sampler2D depthtex0;
uniform sampler2D depthtex1;
uniform sampler2D depthtex2;
#endif
#ifdef Motionblur
uniform vec3 cameraPosition;
uniform vec3 previousCameraPosition;
uniform mat4 gbufferProjection;
uniform mat4 gbufferProjectionInverse;
uniform mat4 gbufferPreviousProjection;
uniform mat4 gbufferPreviousModelView;
#endif
uniform mat4 gbufferModelViewInverse;
#if defined Depth_of_Field || defined Cloudsblur
uniform float near;
uniform float far;
float ld(float depth) {
return (2.0 * near) / (far + near - depth * (far - near));
}
#endif
#ifdef Depth_of_Field
//Dof constant values
const float focal = 0.024;
float aperture = 0.008;
const float sizemult = DoF_Strength;
uniform float centerDepthSmooth;
const float centerDepthHalflife = 2.0f;
//hexagon pattern
const vec2 hex_offsets[60] = vec2[60] ( vec2( 0.2165, 0.1250 ),
vec2( 0.0000, 0.2500 ),
vec2( -0.2165, 0.1250 ),
vec2( -0.2165, -0.1250 ),
vec2( -0.0000, -0.2500 ),
vec2( 0.2165, -0.1250 ),
vec2( 0.4330, 0.2500 ),
vec2( 0.0000, 0.5000 ),
vec2( -0.4330, 0.2500 ),
vec2( -0.4330, -0.2500 ),
vec2( -0.0000, -0.5000 ),
vec2( 0.4330, -0.2500 ),
vec2( 0.6495, 0.3750 ),
vec2( 0.0000, 0.7500 ),
vec2( -0.6495, 0.3750 ),
vec2( -0.6495, -0.3750 ),
vec2( -0.0000, -0.7500 ),
vec2( 0.6495, -0.3750 ),
vec2( 0.8660, 0.5000 ),
vec2( 0.0000, 1.0000 ),
vec2( -0.8660, 0.5000 ),
vec2( -0.8660, -0.5000 ),
vec2( -0.0000, -1.0000 ),
vec2( 0.8660, -0.5000 ),
vec2( 0.2163, 0.3754 ),
vec2( -0.2170, 0.3750 ),
vec2( -0.4333, -0.0004 ),
vec2( -0.2163, -0.3754 ),
vec2( 0.2170, -0.3750 ),
vec2( 0.4333, 0.0004 ),
vec2( 0.4328, 0.5004 ),
vec2( -0.2170, 0.6250 ),
vec2( -0.6498, 0.1246 ),
vec2( -0.4328, -0.5004 ),
vec2( 0.2170, -0.6250 ),
vec2( 0.6498, -0.1246 ),
vec2( 0.6493, 0.6254 ),
vec2( -0.2170, 0.8750 ),
vec2( -0.8663, 0.2496 ),
vec2( -0.6493, -0.6254 ),
vec2( 0.2170, -0.8750 ),
vec2( 0.8663, -0.2496 ),
vec2( 0.2160, 0.6259 ),
vec2( -0.4340, 0.5000 ),
vec2( -0.6500, -0.1259 ),
vec2( -0.2160, -0.6259 ),
vec2( 0.4340, -0.5000 ),
vec2( 0.6500, 0.1259 ),
vec2( 0.4325, 0.7509 ),
vec2( -0.4340, 0.7500 ),
vec2( -0.8665, -0.0009 ),
vec2( -0.4325, -0.7509 ),
vec2( 0.4340, -0.7500 ),
vec2( 0.8665, 0.0009 ),
vec2( 0.2158, 0.8763 ),
vec2( -0.6510, 0.6250 ),
vec2( -0.8668, -0.2513 ),
vec2( -0.2158, -0.8763 ),
vec2( 0.6510, -0.6250 ),
vec2( 0.8668, 0.2513 ));
#endif
#ifdef Cloudsblur
vec3 cblur(vec2 tc){
float pw = 1.0 / viewWidth;
float getdist = 1.0-(exp(-pow(ld(texture2D(depthtex1, tc).r)/256.0*far,4.0)*4.0));
float pcoc = min(getdist*pw*20.0,pw*20.0);
vec2 fast_blur[4] = vec2[4](vec2(0.0, -0.1),
vec2(-0.1, 0.0),
vec2(0.1, 0.0),
vec2(0.0, 0.1));
vec3 blurC = vec3(0.0);
for (int i = 0; i < 4; i++) {
blurC += texture2D(gaux4, tc + fast_blur[i]*pcoc*vec2(1.0,aspectRatio)).rgb;
}
blurC = blurC/4.0*50.0;
return blurC;
}
#endif
#ifdef Rain_Drops
float distratio(vec2 pos, vec2 pos2) {
return distance(pos*vec2(aspectRatio,1.0),pos2*vec2(aspectRatio,1.0));
}
float gen_circular_lens(vec2 center, float size) {
float dist=distratio(center,texcoord.xy)/size;
return exp(-dist*dist);
}
#endif
vec3 Uncharted2Tonemap(vec3 x) {
x*= Brightness;
float A = 0.28;
float B = 0.29;
float C = 0.10;
float D = 0.2;
float E = 0.025;
float F = 0.35;
return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;
}
#if Showbuffer == 1 || Showbuffer == 2 || Showbuffer == 3
vec3 decode (vec2 enc){
vec2 fenc = enc*4-2;
float f = dot(fenc,fenc);
float g = sqrt(1-f/4.0);
vec3 n;
n.xy = fenc*g;
n.z = 1-f/2;
return n;
}
vec3 YCoCg2RGB(vec3 c){
c.y-=0.5;
c.z-=0.5;
return vec3(c.r+c.g-c.b, c.r + c.b, c.r - c.g - c.b);
}
#endif
#ifdef Bloom
varying float eyeAdaptBloom;
uniform sampler2D colortex6;
vec3 calcBloom(){
const int nSteps = 17;
const int center = 8; //=nSteps-1 / 2
//huge gaussian blur for glare
vec3 blur = vec3(0.0);
float tw = 0.0;
for (int i = 0; i < nSteps; i++) {
float dist = abs(i-float(center))/center;
float weight = (exp(-(dist*dist)/ 0.28));
vec3 bsample = texture2D(colortex6,(texcoord.xy*0.25 + vec2(1.0/viewWidth,1.0/viewHeight)*vec2(0.0,i-center))).rgb*3.0;
blur += bsample*weight;
tw += weight;
}
blur /= tw;
vec3 glow = blur * bloom_strength;
vec3 overglow = glow*pow(length(glow)*2.0,2.8)*2.0;
return (overglow+glow*1.15)*(1+isEyeInWater*10.0+(pow(rainStrength,3.0)*7.0/pow(eyeAdaptBloom,1.0)))*1.2;
}
#endif
void main() {
#if defined Depth_of_Field || defined Motionblur || defined Cloudsblur
//Setup depths, do it here because amd drivers suck and texture reads outside of void main or functions are broken, thanks amd
float depth1 = texture2D(depthtex1, texcoord).x;
bool hand = !(depth1 < texture2D(depthtex2, texcoord).x); //is not hand cuz !
#endif
//Rainlens
float rainlens = 0.0;
#ifdef Rain_Drops
if (rainStrength > 0.02) {
rainlens += gen_circular_lens(rainPos1,0.1)*weights.x;
rainlens += gen_circular_lens(rainPos2,0.07)*weights.y;
rainlens += gen_circular_lens(rainPos3,0.086)*weights.z;
rainlens += gen_circular_lens(rainPos4,0.092)*weights.w;
}/*----------------------------------------------------------*/
#endif
vec2 fake_refract = vec2(0.0);
#ifdef Refraction
fake_refract = vec2(sin(frameTimeCounter + texcoord.x*100.0 + texcoord.y*50.0),cos(frameTimeCounter + texcoord.y*100.0 + texcoord.x*50.0));
#endif
vec2 newTC = clamp(texcoord + fake_refract * 0.01 * (rainlens+isEyeInWater*0.2),1.0/vec2(viewWidth,viewHeight),1.0-1.0/vec2(viewWidth,viewHeight));
vec3 color = texture2D(gaux4, newTC.xy).rgb*50.0;
#ifndef DISTANT_HORIZONS
#ifdef Cloudsblur
if(depth1 >= 1.0)color.rgb = cblur(newTC.xy);
#endif
#endif
#ifdef Depth_of_Field
if(hand){
float pw = 1.0/ viewWidth;
float z = ld(texture2D(depthtex0, newTC.st).r)*far;
#ifdef smoothDof
float focus = ld(centerDepthSmooth)*far;
#else
float focus = ld(texture2D(depthtex0, vec2(0.5)).r)*far;
#endif
float pcoc = min(abs(aperture * (focal * (z - focus)) / (z * (focus - focal)))*sizemult,pw*15.0);
#ifdef Distance_Blur
float getdist = 1-(exp(-pow(ld(texture2D(depthtex1, newTC.st).r)/Dof_Distance_View*far,4.0-(2.7*rainStrength))*4.0));
pcoc = min(getdist*pw*20.0,pw*20.0);
#endif
vec3 bcolor = vec3(0.0);
for ( int i = 0; i < 60; i++) {
bcolor += texture2D(gaux4, newTC.xy + hex_offsets[i]*pcoc*vec2(1.0,aspectRatio)).rgb;
}
color.rgb = bcolor/61.0*50.0;
}
#endif
#ifdef Motionblur
if(hand){
vec4 currentPosition = vec4(texcoord, depth1, 1.0)*2.0-1.0;
vec4 fragposition = gbufferProjectionInverse * currentPosition;
fragposition = gbufferModelViewInverse * fragposition;
fragposition /= fragposition.w;
fragposition.xyz += cameraPosition;
vec4 previousPosition = fragposition;
previousPosition.xyz -= previousCameraPosition;
previousPosition = gbufferPreviousModelView * previousPosition;
previousPosition = gbufferPreviousProjection * previousPosition;
previousPosition /= previousPosition.w;
vec2 velocity = (currentPosition - previousPosition).st * MB_strength;
vec2 coord = texcoord.st + velocity;
int mb = 1;
for (int i = 0; i < 15; ++i, coord += velocity) {
if (coord.s > 1.0 || coord.t > 1.0 || coord.s < 0.0 || coord.t < 0.0) break;
color += texture2D(gaux4, coord).xyz*50.0;
++mb;
}
color /= mb;
}
#endif
#ifdef Bloom
color.rgb += calcBloom(); //upscale bloom buffer.
#endif
color.rgb += rainlens*0.01; //draw rainlens
vec3 curr = Uncharted2Tonemap(color*4.7);
color = pow(curr/Uncharted2Tonemap(vec3(15.2)),vec3(1.0/Contrast));
#if Showbuffer == 1
color = vec3(texture2D(colortex0,texcoord).rg,0.0);
vec2 a0 = texture2D(colortex0,texcoord + vec2(1.0/viewWidth,0.0)).rg;
vec2 a1 = texture2D(colortex0,texcoord - vec2(1.0/viewWidth,0.0)).rg;
vec2 a2 = texture2D(colortex0,texcoord + vec2(0.0,1.0/viewHeight)).rg;
vec2 a3 = texture2D(colortex0,texcoord - vec2(0.0,1.0/viewHeight)).rg;
vec4 lumas = vec4(a0.x,a1.x,a2.x,a3.x);
vec4 chromas = vec4(a0.y,a1.y,a2.y,a3.y);
vec4 w = 1.0-step(0.1176, abs(lumas - color.x));
float W = dot(w,vec4(1.0));
w.x = (W==0.0)? 1.0:w.x; W = (W==0.0)? 1.0:W;
bool pattern = (mod(gl_FragCoord.x,2.0)==mod(gl_FragCoord.y,2.0));
color.b= dot(w,chromas)/W;
color.rgb = (pattern)?color.rbg:color.rgb;
color.rgb = YCoCg2RGB(color.rgb);
color = pow(color,vec3(2.2));
#endif
#if Showbuffer == 2
color = decode(texture2D(colortex1, texcoord).xy);
#endif
#if Showbuffer == 25
color = vec3(0.0, texture2D(colortex1, texcoord.xy).zw); //lightmap
#endif
#if Showbuffer == 3
color = decode(texture2D(colortex2, texcoord).xy);
#endif
#if Showbuffer == 35
color = vec3(0.0, texture2D(colortex2, texcoord.xy).zw); //lightmap
#endif
#if Showbuffer == 4
color = texture2D(colortex3, texcoord.xy).rgb * 200.0;
#endif
#if Showbuffer == 5
color = texture2D(gaux1, texcoord.xy).rgb * 25.0;
#endif
#if Showbuffer == 6
color = texture2D(gaux2, texcoord.xy).rgb * 25.0;
#endif
#if Showbuffer == 7
color = texture2D(gaux3, texcoord.xy*0.25).rgb * 25.0;
#endif
#if Showbuffer == 8
color = texture2D(gaux4, texcoord.xy).rgb * 50.0;
#endif
gl_FragColor = vec4(color,1.0);
}

106
shaders/final.vsh Normal file
View File

@@ -0,0 +1,106 @@
#version 120
#define final
#include "shaders.settings"
varying vec2 texcoord;
#if defined Rain_Drops || defined Bloom
uniform ivec2 eyeBrightnessSmooth;
uniform float rainStrength;
#endif
#ifdef Rain_Drops
varying vec2 rainPos1;
varying vec2 rainPos2;
varying vec2 rainPos3;
varying vec2 rainPos4;
varying vec4 weights;
uniform float frameTimeCounter;
vec2 noisepattern(vec2 pos) {
return vec2(abs(fract(sin(dot(pos, vec2(83147.6995379f, 125370.887575f))))));
}
#endif
#ifdef Bloom
varying float eyeAdaptBloom;
uniform vec3 sunPosition;
uniform vec3 upPosition;
uniform int worldTime;
const vec3 ToD[7] = vec3[7]( vec3(0.58597,0.16,0.025),
vec3(0.58597,0.4,0.2),
vec3(0.58597,0.52344,0.24680),
vec3(0.58597,0.55422,0.34),
vec3(0.58597,0.57954,0.38),
vec3(0.58597,0.58,0.40),
vec3(0.58597,0.58,0.40));
float luma(vec3 color) {
return dot(color,vec3(0.299, 0.587, 0.114));
}
#endif
void main() {
gl_Position = ftransform();
texcoord = (gl_MultiTexCoord0).xy;
#ifdef Bloom
texcoord = (gl_MultiTexCoord0).xy;
//Sun/Moon position
vec3 sunVec = normalize(sunPosition);
vec3 upVec = normalize(upPosition);
float SdotU = dot(sunVec,upVec);
float sunVisibility = pow(clamp(SdotU+0.15,0.0,0.15)/0.15,4.0);
float moonVisibility = pow(clamp(-SdotU+0.15,0.0,0.15)/0.15,4.0);
/*--------------------------------*/
//reduced the sun color to a 7 array
float hour = max(mod(worldTime/1000.0+2.0,24.0)-2.0,0.0); //-0.1
float cmpH = max(-abs(floor(hour)-6.0)+6.0,0.0); //12
float cmpH1 = max(-abs(floor(hour)-5.0)+6.0,0.0); //1
vec3 temp = ToD[int(cmpH)];
vec3 temp2 = ToD[int(cmpH1)];
vec3 sunlight = mix(temp,temp2,fract(hour));
/*--------------------------------*/
//Lighting
float eyebright = max(eyeBrightnessSmooth.y/255.0-0.5/16.0,0.0)*1.03225806452;
float SkyL2 = mix(1.0,eyebright*eyebright,eyebright);
vec2 trCalc = min(abs(worldTime-vec2(23250.0,12700.0)),750.0);
float tr = max(min(trCalc.x,trCalc.y)/375.0-1.0,0.0);
vec4 bounced = vec4(0.5*SkyL2,0.66*SkyL2,0.7,0.3);
vec3 sun_ambient = bounced.w * (vec3(0.25,0.62,1.32)-rainStrength*vec3(0.11,0.32,1.07)) + sunlight*(bounced.x + bounced.z);
const vec3 moonlight = vec3(0.0035, 0.0063, 0.0098);
vec3 avgAmbient =(sun_ambient*sunVisibility + moonlight*moonVisibility)*eyebright*eyebright*(0.05+tr*0.15)*4.7+0.0006;
eyeAdaptBloom = log(clamp(luma(avgAmbient),0.007,80.0))/log(2.6)*0.35;
eyeAdaptBloom = 1.0/pow(2.6,eyeAdaptBloom)*1.75;
#endif
#ifdef Rain_Drops
const float lifetime = 4.0; //water drop lifetime in seconds
float ftime = frameTimeCounter*2.0/lifetime;
vec2 drop = vec2(0.0,fract(frameTimeCounter/20.0));
rainPos1 = fract((noisepattern(vec2(-0.94386347*floor(ftime*0.5+0.25),floor(ftime*0.5+0.25))))*0.8+0.1 - drop);
rainPos2 = fract((noisepattern(vec2(0.9347*floor(ftime*0.5+0.5),-0.2533282*floor(ftime*0.5+0.5))))*0.8+0.1- drop);
rainPos3 = fract((noisepattern(vec2(0.785282*floor(ftime*0.5+0.75),-0.285282*floor(ftime*0.5+0.75))))*0.8+0.1- drop);
rainPos4 = fract((noisepattern(vec2(-0.347*floor(ftime*0.5),0.6847*floor(ftime*0.5))))*0.8+0.1- drop);
weights.x = 1.0-fract((ftime+0.5)*0.5);
weights.y = 1.0-fract((ftime+1.0)*0.5);
weights.z = 1.0-fract((ftime+1.5)*0.5);
weights.w = 1.0-fract(ftime*0.5);
weights *= rainStrength*clamp((eyeBrightnessSmooth.y-220)/15.0,0.0,1.0);
#endif
}

View File

@@ -0,0 +1,28 @@
#version 120
/* DRAWBUFFERS:5 */
uniform sampler2D texture;
varying vec4 color;
varying vec2 texcoord;
uniform int worldTime;
uniform ivec2 eyeBrightnessSmooth;
uniform float rainStrength;
float night = clamp((worldTime-13000.0)/300.0,0.0,1.0)-clamp((worldTime-22800.0)/200.0,0.0,1.0);
float cavelight = pow(eyeBrightnessSmooth.y / 255.0, 6.0f) * 1.0 + (0.7 + 0.5*night);
void main() {
vec4 albedo = texture2D(texture, texcoord.st)*color;
//Fix minecrafts way of handling enchanted effects and turn it into a somewhat consistent effect across day/night/cave/raining
vec3 lighting = vec3(1.0+ (0.4*rainStrength - 0.4*rainStrength*night));
lighting /= 0.8 - 0.5*night;
lighting /= cavelight;
albedo.rgb = pow(albedo.rgb*0.33, lighting);
gl_FragData[0] = albedo;
}

View File

@@ -0,0 +1,37 @@
#version 120
varying vec4 color;
varying vec2 texcoord;
uniform mat4 gbufferModelView;
uniform mat4 gbufferModelViewInverse;
#define composite2
#include "shaders.settings"
#ifdef TAA
uniform float viewWidth;
uniform float viewHeight;
vec2 texelSize = vec2(1.0/viewWidth,1.0/viewHeight);
uniform int framemod8;
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-1.,3.)/8.,
vec2(5.0,1.)/8.,
vec2(-3,-5.)/8.,
vec2(-5.,5.)/8.,
vec2(-7.,-1.)/8.,
vec2(3,7.)/8.,
vec2(7.,-7.)/8.);
#endif
void main() {
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
#ifdef TAA
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
#endif
color = gl_Color;
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).st;
}

View File

@@ -0,0 +1,30 @@
#version 120
/* DRAWBUFFERS:0 */ //01 breaks selection box color but fixes leads
varying vec4 color;
varying vec4 texcoord;
varying vec3 normal;
uniform sampler2D texture;
//encode normal in two channel (xy),torch and material(z) and sky lightmap (w)
vec4 encode (vec3 n){
float p = sqrt(n.z*8+8);
return vec4(n.xy/p + 0.5,texcoord.z,texcoord.w);
}
vec3 RGB2YCoCg(vec3 c){
return vec3( 0.25*c.r+0.5*c.g+0.25*c.b, 0.5*c.r-0.5*c.b +0.5, -0.25*c.r+0.5*c.g-0.25*c.b +0.5);
}
void main() {
vec4 cAlbedo = vec4(RGB2YCoCg(color.rgb),color.a);
bool pattern = (mod(gl_FragCoord.x,2.0)==mod(gl_FragCoord.y,2.0));
cAlbedo.g = (pattern)?cAlbedo.b: cAlbedo.g;
cAlbedo.b = 1.0;
gl_FragData[0] = cAlbedo;
gl_FragData[1] = encode(normal.xyz);
}

View File

@@ -0,0 +1,17 @@
#version 120
varying vec4 color;
varying vec4 texcoord;
varying vec3 normal;
void main() {
gl_Position = ftransform();
color = gl_Color;
texcoord = vec4((gl_MultiTexCoord0).xy,(gl_TextureMatrix[1] * gl_MultiTexCoord1).xy);
normal = normalize(gl_NormalMatrix * gl_Normal);
gl_FogFragCoord = gl_Position.z;
}

View File

@@ -0,0 +1,84 @@
#version 120
/* DRAWBUFFERS:56 */
//Render entities etc in here, boost and fix enchanted armor effect in gbuffers_armor_glint
#define gbuffers_shadows
#define gbuffers_texturedblock
#include "shaders.settings"
varying vec4 color;
varying vec2 texcoord;
varying vec3 normal;
varying vec3 ambientNdotL;
varying vec3 finalSunlight;
varying float skyL;
#ifdef Shadows
uniform mat4 gbufferProjectionInverse;
uniform mat4 gbufferModelViewInverse;
uniform mat4 shadowProjection;
uniform mat4 shadowModelView;
uniform sampler2DShadow shadowtex0;
vec3 toScreenSpace(vec3 pos) {
vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw);
if(gl_ProjectionMatrix[2][2] > -0.5) pos.z += 0.38; //hand
vec3 p3 = pos * 2.0 - 1.0;
vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3];
return fragposition.xyz / fragposition.w;
}
float shadowfilter(vec3 shadowpos, float dif){
vec2 offset = vec2(0.65, -0.65) / shadowMapResolution;
return clamp(dot(vec4(shadow2D(shadowtex0,vec3(shadowpos.xy + offset.xx, shadowpos.z)).x,
shadow2D(shadowtex0,vec3(shadowpos.xy + offset.yx, shadowpos.z)).x,
shadow2D(shadowtex0,vec3(shadowpos.xy + offset.xy, shadowpos.z)).x,
shadow2D(shadowtex0,vec3(shadowpos.xy + offset.yy, shadowpos.z)).x),vec4(0.25))*dif,0.0,1.0);
}
#endif
uniform sampler2D texture;
uniform float viewWidth;
uniform float viewHeight;
uniform float rainStrength;
uniform vec3 shadowLightPosition;
uniform int worldTime;
uniform ivec2 eyeBrightnessSmooth;
void main() {
float diffuse = clamp(dot(normalize(shadowLightPosition),normal),0.0,1.0);
vec4 albedo = texture2D(texture, texcoord.xy)*color;
#ifdef Shadows
#define diagonal3(mat) vec3((mat)[0].x, (mat)[1].y, (mat)[2].z)
//don't do shading if transparent/translucent (not opaque)
if (diffuse > 0.0 && rainStrength < 0.9 && albedo.a > 0.01){
vec3 fragposition = toScreenSpace(vec3(gl_FragCoord.xy/vec2(viewWidth,viewHeight),gl_FragCoord.z));
vec3 worldposition = mat3(gbufferModelViewInverse) * fragposition.xyz + gbufferModelViewInverse[3].xyz;
worldposition = mat3(shadowModelView) * worldposition.xyz + shadowModelView[3].xyz;
worldposition = diagonal3(shadowProjection) * worldposition.xyz + shadowProjection[3].xyz;
float distortion = calcDistortion(worldposition.xy);
float threshMul = max(2048.0/shadowMapResolution*shadowDistance/128.0,1.5); //increased offset to fix self shadowing on armor
float distortThresh = (sqrt(1.0-diffuse*diffuse)/diffuse+0.7)/distortion;
float bias = distortThresh/6000.0*threshMul;
worldposition.xy *= distortion;
worldposition.xyz = worldposition.xyz * vec3(0.5,0.5,0.5/6.0) + vec3(0.5,0.5,0.5);
worldposition.z -= bias;
//Fast and simple shadow drawing for proper rendering of entities etc
diffuse *= shadowfilter(worldposition, diffuse);
diffuse *= (1.0 - rainStrength);
diffuse *= mix(skyL,1.0,clamp((eyeBrightnessSmooth.y/255.0-2.0/16.)*4.0,0.0,1.0)); //avoid light leaking underground
}
#else
diffuse *= mix(skyL,1.0,clamp((eyeBrightnessSmooth.y/255.0-4.0/16.)*4.0,0.0,1.0)); //Fix lighting in caves with if shadows are disabled
#endif
vec3 finalColor = pow(albedo.rgb,vec3(2.2)) * (finalSunlight*diffuse+ambientNdotL.rgb);
gl_FragData[0] = vec4(finalColor, albedo.a);
gl_FragData[1] = vec4(normalize(albedo.rgb+0.00001), albedo.a);
}

117
shaders/gbuffers_block.vsh Normal file
View File

@@ -0,0 +1,117 @@
#version 120
#define composite2
#define gbuffers_texturedblock
#define lightingColors
#include "shaders.settings"
varying vec4 color;
varying vec2 texcoord;
varying vec3 normal;
varying vec3 ambientNdotL;
varying vec3 finalSunlight;
varying float skyL;
uniform vec3 sunPosition;
uniform vec3 upPosition;
uniform int worldTime;
uniform float rainStrength;
uniform float nightVision;
uniform mat4 gbufferModelView;
uniform mat4 gbufferModelViewInverse;
const vec3 ToD[7] = vec3[7]( vec3(0.58597,0.15,0.02),
vec3(0.58597,0.35,0.09),
vec3(0.58597,0.5,0.26),
vec3(0.58597,0.5,0.35),
vec3(0.58597,0.5,0.36),
vec3(0.58597,0.5,0.37),
vec3(0.58597,0.5,0.38));
#ifdef TAA
uniform float viewWidth;
uniform float viewHeight;
vec2 texelSize = vec2(1.0/viewWidth,1.0/viewHeight);
uniform int framemod8;
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-1.,3.)/8.,
vec2(5.0,1.)/8.,
vec2(-3,-5.)/8.,
vec2(-5.,5.)/8.,
vec2(-7.,-1.)/8.,
vec2(3,7.)/8.,
vec2(7.,-7.)/8.);
#endif
void main() {
color = gl_Color;
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
#ifdef TAA
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
#endif
normal = normalize(gl_NormalMatrix * gl_Normal);
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
vec2 lmcoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
/*--------------------------------*/
//Emissive blocks lighting in order to fix lighting on particles
float torch_lightmap = 16.0-min(15.,(lmcoord.s-0.5/16.)*16.*16./15);
float fallof1 = clamp(1.0 - pow(torch_lightmap/16.0,4.0),0.0,1.0);
torch_lightmap = fallof1*fallof1/(torch_lightmap*torch_lightmap+1.0);
vec3 emissiveLightC = vec3(emissive_R,emissive_G,emissive_B)*torch_lightmap;
float finalminlight = (nightVision > 0.01)? 0.075 : minlight; //add nightvision support but make sure minlight is still adjustable.
/*---------------------------------------------------------------------*/
//reduced the sun color to a 7 array
float hour = max(mod(worldTime/1000.0+2.0,24.0)-2.0,0.0); //-0.1
float cmpH = max(-abs(floor(hour)-6.0)+6.0,0.0); //12
float cmpH1 = max(-abs(floor(hour)-5.0)+6.0,0.0); //1
vec3 temp = ToD[int(cmpH)];
vec3 temp2 = ToD[int(cmpH1)];
vec3 sunlight = mix(temp,temp2,fract(hour));
sunlight.rgb += vec3(r_multiplier,g_multiplier,b_multiplier); //allows lighting colors to be tweaked.
sunlight.rgb *= light_brightness; //brightness needs to be adjusted if we tweak lighting colors.
const vec3 rainC = vec3(0.01,0.01,0.01);
sunlight = mix(sunlight,rainC*sunlight,rainStrength);
/*-------------------------------------------------------------------*/
const vec3 moonlight = vec3(0.0024, 0.00432, 0.0078);
vec3 sunVec = normalize(sunPosition);
vec3 upVec = normalize(upPosition);
vec2 visibility = vec2(dot(sunVec,upVec),dot(-sunVec,upVec));
float NdotL = dot(normal,sunVec);
float NdotU = dot(normal,upVec);
vec2 trCalc = min(abs(worldTime-vec2(23000.0,12700.0)),750.0); //adjust to make day-night switch smoother
float tr = max(min(trCalc.x,trCalc.y)/375.0-1.0,0.0);
visibility = pow(clamp(visibility+0.15,0.0,0.15)/0.15,vec2(4.0));
skyL = max(lmcoord.t-2./16.0,0.0)*1.14285714286;
float SkyL2 = skyL*skyL;
float skyc2 = mix(1.0,SkyL2,skyL);
vec4 bounced = vec4(NdotL,NdotL,NdotL,NdotU) * vec4(-0.14*skyL*skyL,0.34,0.7,0.1) + vec4(0.6,0.66,0.7,0.25);
bounced *= vec4(skyc2,skyc2,visibility.x-tr*visibility.x,0.8);
vec3 sun_ambient = bounced.w * (vec3(0.1, 0.5, 1.1)+rainStrength*vec3(0.05,-0.27,-0.8))*2.3+ 1.7*sunlight*(sqrt(bounced.w)*bounced.x*2.4 + bounced.z)*(1.0-rainStrength*0.98);
vec3 moon_ambient = (moonlight*0.7 + moonlight*bounced.y)*(1.0-rainStrength*0.95)*2.0;
vec3 amb1 = (sun_ambient*visibility.x + moon_ambient*visibility.y)*SkyL2*(0.03+tr*0.17)*0.65;
ambientNdotL.rgb = amb1 + emissiveLightC + finalminlight*0.5*min(skyL+6/16.,9/16.)*normalize(amb1+0.0001)*3.0;
//sunlight = mix(sunlight,moonlight*(1.0-rainStrength*0.9),visibility.y)*tr;
sunlight = mix(sunlight,moonlight*(1.0-rainStrength*0.9),visibility.y); //remove time check to improve day-night transition
finalSunlight = sunlight*0.9;
}

View File

@@ -0,0 +1,36 @@
#version 120
/* DRAWBUFFERS:01 */
#define Clouds 3 //[0 1 2 3 4] Toggle clouds. 0=Off, 1=Default MC, 2=2D, 3=VL, 4=2D+VL
uniform sampler2D texture;
varying vec4 color;
varying vec4 texcoord;
varying vec3 normal;
#if Clouds == 1
vec3 RGB2YCoCg(vec3 c){
return vec3( 0.25*c.r+0.5*c.g+0.25*c.b, 0.5*c.r-0.5*c.b +0.5, -0.25*c.r+0.5*c.g-0.25*c.b +0.5);
}
vec4 encode (vec3 n){
return vec4(n.xy*inversesqrt(n.z*8.0+8.0) + 0.5, texcoord.zw);
}
#endif
void main() {
#if Clouds == 1
vec4 albedo = texture2D(texture, texcoord.xy)*color;
vec4 cAlbedo = vec4(RGB2YCoCg(albedo.rgb),albedo.a);
bool pattern = (mod(gl_FragCoord.x,2.0)==mod(gl_FragCoord.y,2.0));
cAlbedo.g = (pattern)?cAlbedo.b: cAlbedo.g;
cAlbedo.b = 0.02;
gl_FragData[0] = cAlbedo;
gl_FragData[1] = encode(normal.xyz);
#else
discard;
#endif
}

View File

@@ -0,0 +1,38 @@
#version 120
#define composite2
#include "shaders.settings"
varying vec4 color;
varying vec4 texcoord;
varying vec3 normal;
#ifdef TAA
uniform float viewWidth;
uniform float viewHeight;
vec2 texelSize = vec2(1.0/viewWidth,1.0/viewHeight);
uniform int framemod8;
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-1.,3.)/8.,
vec2(5.0,1.)/8.,
vec2(-3,-5.)/8.,
vec2(-5.,5.)/8.,
vec2(-7.,-1.)/8.,
vec2(3,7.)/8.,
vec2(7.,-7.)/8.);
#endif
void main() {
gl_Position = ftransform();
#ifdef TAA
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
#endif
texcoord.xy = (gl_MultiTexCoord0).xy;
texcoord.zw = gl_MultiTexCoord1.xy/255.0;
color = gl_Color;
normal = normalize(gl_NormalMatrix * gl_Normal);
}

View File

@@ -0,0 +1,5 @@
#version 120
void main() {
gl_FragData[0] = vec4(0.0, 0.0, 0.0, 1.0); //fill with zeros to avoid issues, alpha has to be set to 1.0 to fix an optifine issue in 1.17+ causing the sky to be black at certain angles.
}

View File

@@ -0,0 +1,5 @@
#version 120
void main() {
gl_Position = ftransform();
}

View File

@@ -0,0 +1,17 @@
#version 120
/* DRAWBUFFERS:3 */
#define gbuffers_skytextured
#include "shaders.settings"
varying vec4 color;
varying vec2 texcoord;
uniform sampler2D texture;
void main() {
#ifdef defskybox
gl_FragData[0] = texture2D(texture,texcoord.xy)*color;
#else
gl_FragData[0] = vec4(0.0);
#endif
}

View File

@@ -0,0 +1,14 @@
#version 120
varying vec4 color;
varying vec2 texcoord;
void main() {
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
color = gl_Color;
gl_Position = ftransform();
}

View File

@@ -0,0 +1,20 @@
#version 120
/* DRAWBUFFERS:56 */
#define gbuffers_texturedblock
#include "shaders.settings"
varying vec4 color;
varying vec2 texcoord;
varying vec3 ambientNdotL;
uniform sampler2D texture;
void main() {
vec4 albedo = texture2D(texture, texcoord.xy)*color;
vec3 finalColor = pow(albedo.rgb,vec3(2.2)) * ambientNdotL.rgb;
gl_FragData[0] = vec4(finalColor, albedo.a);
gl_FragData[1] = vec4(normalize(albedo.rgb+0.00001), albedo.a);
}

View File

@@ -0,0 +1,68 @@
#version 120
#define composite2
#define gbuffers_texturedblock
#define lightingColors
#include "shaders.settings"
varying vec4 color;
varying vec2 texcoord;
varying vec3 ambientNdotL;
uniform vec3 sunPosition;
uniform vec3 upPosition;
uniform int worldTime;
uniform float rainStrength;
uniform float nightVision;
uniform mat4 gbufferModelView;
uniform mat4 gbufferModelViewInverse;
const vec3 ToD[7] = vec3[7]( vec3(0.58597,0.15,0.02),
vec3(0.58597,0.35,0.09),
vec3(0.58597,0.5,0.26),
vec3(0.58597,0.5,0.35),
vec3(0.58597,0.5,0.36),
vec3(0.58597,0.5,0.37),
vec3(0.58597,0.5,0.38));
#ifdef TAA
uniform float viewWidth;
uniform float viewHeight;
vec2 texelSize = vec2(1.0/viewWidth,1.0/viewHeight);
uniform int framemod8;
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-1.,3.)/8.,
vec2(5.0,1.)/8.,
vec2(-3,-5.)/8.,
vec2(-5.,5.)/8.,
vec2(-7.,-1.)/8.,
vec2(3,7.)/8.,
vec2(7.,-7.)/8.);
#endif
void main() {
color = gl_Color;
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
#ifdef TAA
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
#endif
vec3 normal = normalize(gl_NormalMatrix * gl_Normal);
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
vec2 lmcoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
/*--------------------------------*/
//Emissive blocks lighting
float torch_lightmap = 16.0-min(15.,(lmcoord.s-0.5/16.)*16.*16./15);
float fallof1 = clamp(1.0 - pow(torch_lightmap/16.0,4.0),0.0,1.0);
torch_lightmap = fallof1*fallof1/(torch_lightmap*torch_lightmap+1.0);
//vec3 emissiveLightC = vec3(emissive_R,emissive_G,emissive_B)*torch_lightmap;
vec3 emissiveLightC = vec3(0.5, 0.0, 1.0); //purple eyes
float finalminlight = (nightVision > 0.01)? 0.025 : (minlight+0.006)*10.0; //multiply by 10 to improve eye rendering
ambientNdotL.rgb = emissiveLightC + finalminlight;
}

View File

@@ -0,0 +1,139 @@
#version 120
/* DRAWBUFFERS:01 */
#define gbuffers_terrain
#include "shaders.settings"
/* Don't remove me
const int colortex0Format = RGBA16;
const int colortex1Format = RGBA16;
const int colortex2Format = RGBA16; //Entities etc
const int colortex3Format = R11F_G11F_B10F;
const int gaux1Format = RGBA16;
const int gaux2Format = R11F_G11F_B10F;
const int gaux3Format = R11F_G11F_B10F;
const int gaux4Format = R11F_G11F_B10F;
-----------------------------------------*/
varying vec4 color;
varying vec4 texcoord;
varying vec4 normal;
varying vec3 worldpos;
varying vec3 viewVector;
varying mat3 tbnMatrix;
uniform sampler2D texture;
//uniform sampler2D specular;
uniform sampler2D noisetex;
//encode normal in two channel (xy), emissive lightmap (z) and sky lightmap (w), blend mode must be disabled in shaders.properties for this to work without issues.
vec4 encode (vec3 n){
return vec4(n.xy*inversesqrt(n.z*8.0+8.0) + 0.5, texcoord.zw);
}
vec3 RGB2YCoCg(vec3 c){
return vec3( 0.25*c.r+0.5*c.g+0.25*c.b, 0.5*c.r-0.5*c.b +0.5, -0.25*c.r+0.5*c.g-0.25*c.b +0.5);
}
vec3 newnormal = normal.xyz;
#if nMap >= 1
#extension GL_ARB_shader_texture_lod : enable
uniform sampler2D normals;
varying float block;
bool isblock = block > 0.0 || block < 0.0; //workaround for 1.16 bugs on block entities
varying float dist;
varying vec4 vtexcoordam; // .st for add, .pq for mul
varying vec2 vtexcoord;
uniform ivec2 atlasSize;
vec2 atlasAspect = vec2(atlasSize.y/float(atlasSize.x), atlasSize.x/float(atlasSize.y));
mat2 mipmap = mat2(dFdx(vtexcoord.xy*vtexcoordam.pq), dFdy(vtexcoord.xy*vtexcoordam.pq));
vec4 readNormal(in vec2 coord){
return texture2DGradARB(normals,fract(coord)*vtexcoordam.pq+vtexcoordam.st,mipmap[0],mipmap[1]);
}
vec4 calcPOM(vec4 albedo){
vec2 newCoord = vtexcoord.xy*vtexcoordam.pq+vtexcoordam.st;
#if nMap == 2
if (dist < POM_DIST && viewVector.z < 0.0 && readNormal(vtexcoord.xy).a < 1.0){
vec2 viewCorrection = max(vec2(vtexcoordam.q/vtexcoordam.p*atlasAspect.x,1.0), vec2(1.0,vtexcoordam.p/vtexcoordam.q*atlasAspect.y));
const float res_stepths = 0.33 * POM_RES;
vec2 pstepth = viewCorrection * viewVector.xy * POM_DEPTH / (-viewVector.z * POM_RES);
vec2 coord = vtexcoord.xy;
for (int i= 0; i < res_stepths && (readNormal(coord.xy).a < 1.0-float(i)/POM_RES); ++i) coord += pstepth;
newCoord = fract(coord.xy)*vtexcoordam.pq+vtexcoordam.st;
}
#endif
//vec4 specularity = texture2DGradARB(specular, newCoord, dcdx, dcdy);
vec3 bumpMapping = texture2DGradARB(normals, newCoord, mipmap[0],mipmap[1]).rgb*2.0-1.0;
newnormal = normalize(bumpMapping * tbnMatrix);
return albedo = texture2DGradARB(texture, newCoord, mipmap[0],mipmap[1])*color;
}
#endif
#if defined metallicRefl || defined polishedRefl
float calcNoise(vec2 coord){
return sqrt(texture2D(noisetex, vec2(coord.x*1.25, coord.y*1.95)).x) * 0.45;
}
vec3 calcBump(vec2 coord){
const vec2 deltaPos = vec2(0.25, 0.0);
float h0 = calcNoise(coord);
float h1 = calcNoise(coord + deltaPos.xy);
float h2 = calcNoise(coord - deltaPos.xy);
float h3 = calcNoise(coord + deltaPos.yx);
float h4 = calcNoise(coord - deltaPos.yx);
float xDelta = ((h1-h0)+(h0-h2));
float yDelta = ((h3-h0)+(h0-h4));
return vec3(vec2(xDelta,yDelta)*0.2, 0.8); //z = 1.0-0.5
}
vec3 calcParallax(vec3 pos){
float getnoise = calcNoise(pos.xz);
float height = 1.0;
pos.xz += (getnoise * viewVector.xy) * height;
return pos;
}
#endif
void main() {
vec4 albedo = texture2D(texture, texcoord.xy)*color;
#if nMap >= 1
if(isblock)albedo = calcPOM(albedo);
#endif
#if defined metallicRefl || defined polishedRefl
bool isMetallic = normal.a > 0.39 && normal.a < 0.41;
bool isPolished = normal.a > 0.49 && normal.a < 0.51;
#ifndef polishedRefl
isPolished = false;
#endif
#ifndef metallicRefl
isMetallic = false;
#endif
if(isMetallic || isPolished){
vec3 bumpPos = worldpos;
bumpPos = calcParallax(bumpPos);
vec3 bump = calcBump(bumpPos.xy);
newnormal = normalize(bump * tbnMatrix);
}
#endif
vec4 cAlbedo = vec4(RGB2YCoCg(albedo.rgb),albedo.a);
bool pattern = (mod(gl_FragCoord.x,2.0)==mod(gl_FragCoord.y,2.0));
cAlbedo.g = (pattern)?cAlbedo.b: cAlbedo.g;
cAlbedo.b = normal.a;
gl_FragData[0] = cAlbedo;
gl_FragData[1] = encode(newnormal.xyz);
}

View File

@@ -0,0 +1,281 @@
#version 120
#define composite2
#define gbuffers_terrain
#include "shaders.settings"
//Moving entities IDs
//See block.properties for mapped ids
#define ENTITY_SMALLGRASS 10031.0
#define ENTITY_LOWERGRASS 10175.0 //lower half only in 1.13+
#define ENTITY_UPPERGRASS 10176.0 //upper half only used in 1.13+
#define ENTITY_SMALLENTS 10059.0
#define ENTITY_LEAVES 10018.0
#define ENTITY_VINES 10106.0
#define ENTITY_LILYPAD 10111.0
#define ENTITY_FIRE 10051.0
#define ENTITY_LAVA 10010.0
#define ENTITY_EMISSIVE 10089.0 //emissive blocks defined in block.properties
#define ENITIY_SOULFIRE 10091.0
#define METALLIC_BLOCK 10080.0 //defined in block.properties
#define POLISHED_BLOCK 10081.0
#define ENTITY_INVERTED_LOWER 10177.0 //hanging_roots
#define ENTITY_NON_DIFFUSED 20000.0
varying vec4 color;
varying vec4 texcoord;
varying vec4 normal;
varying vec3 worldpos;
attribute vec4 mc_Entity;
attribute vec4 mc_midTexCoord;
uniform vec3 cameraPosition;
uniform mat4 gbufferModelView;
uniform mat4 gbufferModelViewInverse;
uniform float frameTimeCounter;
const float PI = 3.1415927;
const float PI48 = 150.796447372;
float pi2wt = (PI48*frameTimeCounter) * animationSpeed;
#if nMap >= 1 || defined metallicRefl || defined polishedRefl
attribute vec4 at_tangent; //xyz = tangent vector, w = handedness, added in 1.7.10
varying float block;
varying float dist;
varying vec3 viewVector;
varying mat3 tbnMatrix;
varying vec4 vtexcoordam; // .st for add, .pq for mul
varying vec2 vtexcoord;
#endif
vec3 calcWave(in vec3 pos, in float fm, in float mm, in float ma, in float f0, in float f1, in float f2, in float f3, in float f4, in float f5) {
vec3 ret;
float magnitude,d0,d1,d2,d3;
magnitude = sin(pi2wt*fm + pos.x*0.5 + pos.z*0.5 + pos.y*0.5) * mm + ma;
d0 = sin(pi2wt*f0);
d1 = sin(pi2wt*f1);
d2 = sin(pi2wt*f2);
ret.x = sin(pi2wt*f3 + d0 + d1 - pos.x + pos.z + pos.y) * magnitude;
ret.z = sin(pi2wt*f4 + d1 + d2 + pos.x - pos.z + pos.y) * magnitude;
ret.y = sin(pi2wt*f5 + d2 + d0 + pos.z + pos.y - pos.y) * magnitude;
return ret;
}
vec3 calcMove(in vec3 pos, in float f0, in float f1, in float f2, in float f3, in float f4, in float f5, in vec3 amp1, in vec3 amp2) {
vec3 move1 = calcWave(pos , 0.0027, 0.0400, 0.0400, 0.0127, 0.0089, 0.0114, 0.0063, 0.0224, 0.0015) * amp1;
vec3 move2 = calcWave(pos+move1, 0.0348, 0.0400, 0.0400, f0, f1, f2, f3, f4, f5) * amp2;
return move1+move2;
}
#ifdef TAA
uniform float viewWidth;
uniform float viewHeight;
vec2 texelSize = vec2(1.0/viewWidth,1.0/viewHeight);
uniform int framemod8;
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-1.,3.)/8.,
vec2(5.0,1.)/8.,
vec2(-3,-5.)/8.,
vec2(-5.,5.)/8.,
vec2(-7.,-1.)/8.,
vec2(3,7.)/8.,
vec2(7.,-7.)/8.);
#endif
void main() {
texcoord.xy = (gl_MultiTexCoord0).xy;
texcoord.zw = gl_MultiTexCoord1.xy/255.0;
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
worldpos = position.xyz + cameraPosition;
bool istopv = gl_MultiTexCoord0.t < mc_midTexCoord.t;
/*
bool entities = (mc_Entity.x == ENTITY_VINES || mc_Entity.x == ENTITY_SMALLENTS || mc_Entity.x == 10030.0 || mc_Entity.x == 10031.0 || mc_Entity.x == 10115.0 || mc_Entity.x == ENTITY_LILYPAD
|| mc_Entity.x == ENTITY_LAVA || mc_Entity.x == ENTITY_LEAVES || mc_Entity.x == ENTITY_SMALLGRASS || mc_Entity.x == ENTITY_UPPERGRASS || mc_Entity.x == ENTITY_LOWERGRASS);
*/
normal.a = 0.02;
normal.xyz = normalize(gl_NormalMatrix * gl_Normal);
#ifdef Waving_Tallgrass
if (mc_Entity.x == ENTITY_LOWERGRASS && istopv || mc_Entity.x == ENTITY_UPPERGRASS)
position.xyz += calcMove(worldpos.xyz,
0.0041,
0.0070,
0.0044,
0.0038,
0.0240,
0.0000,
vec3(0.8,0.0,0.8),
vec3(0.4,0.0,0.4));
#endif
if (istopv) {
#ifdef Waving_Grass
if (mc_Entity.x == ENTITY_SMALLGRASS)
position.xyz += calcMove(worldpos.xyz,
0.0041,
0.0070,
0.0044,
0.0038,
0.0063,
0.0000,
vec3(3.0,1.6,3.0),
vec3(0.0,0.0,0.0));
#endif
#ifdef Waving_Entities
if (mc_Entity.x == ENTITY_SMALLENTS)
position.xyz += calcMove(worldpos.xyz,
0.0041,
0.0070,
0.0044,
0.0038,
0.0240,
0.0000,
vec3(0.8,0.0,0.8),
vec3(0.4,0.0,0.4));
#endif
#ifdef Waving_Fire
if (mc_Entity.x == ENTITY_FIRE)
position.xyz += calcMove(worldpos.xyz,
0.0105,
0.0096,
0.0087,
0.0063,
0.0097,
0.0156,
vec3(1.2,0.4,1.2),
vec3(0.8,0.8,0.8));
#endif
}
#ifdef Waving_Leaves
if (mc_Entity.x == ENTITY_LEAVES)
position.xyz += calcMove(worldpos.xyz,
0.0040,
0.0064,
0.0043,
0.0035,
0.0037,
0.0041,
vec3(1.0,0.2,1.0),
vec3(0.5,0.1,0.5));
#endif
#ifdef Waving_Vines
if ( mc_Entity.x == ENTITY_VINES)
position.xyz += calcMove(worldpos.xyz,
0.0040,
0.0064,
0.0043,
0.0035,
0.0037,
0.0041,
vec3(0.5,1.0,0.5),
vec3(0.25,0.5,0.25));
if (mc_Entity.x == ENTITY_INVERTED_LOWER && gl_MultiTexCoord0.t > mc_midTexCoord.t)
position.xyz += calcMove(worldpos.xyz,
0.0041,
0.0070,
0.0044,
0.0038,
0.0240,
0.0000,
vec3(0.8,0.0,0.8),
vec3(0.4,0.0,0.4));
#endif
#ifdef Waving_Lava
if(mc_Entity.x == ENTITY_LAVA){
float fy = fract(worldpos.y + 0.001);
float wave = 0.05 * sin(2 * PI * (frameTimeCounter*0.2 + worldpos.x / 7.0 + worldpos.z / 13.0))
+ 0.05 * sin(2 * PI * (frameTimeCounter*0.15 + worldpos.x / 11.0 + worldpos.z / 5.0));
position.y += clamp(wave, -fy, 1.0-fy)*0.5;
}
#endif
#ifdef Waving_Lilypads
if(mc_Entity.x == ENTITY_LILYPAD){
float fy = fract(worldpos.y + 0.001);
float wave = 0.05 * sin(2 * PI * (frameTimeCounter*0.8 + worldpos.x / 2.5 + worldpos.z / 5.0))
+ 0.05 * sin(2 * PI * (frameTimeCounter*0.6 + worldpos.x / 6.0 + worldpos.z / 12.0));
position.y += clamp(wave, -fy, 1.0-fy)*1.05;
}
#endif
#ifdef Waving_Lanterns
if(mc_Entity.x == 10090.0){
vec3 fxyz = fract(worldpos.xyz + 0.001);
float wave = 0.025 * sin(2 * PI * (frameTimeCounter*0.4 + worldpos.x * 0.5 + worldpos.z * 0.5));
//+ 0.025 * sin(2 * PI * (frameTimeCounter*0.4 + worldpos.y *0.25 + worldpos.z *0.25));
float waveY = 0.05 * cos(frameTimeCounter*2.0 + worldpos.y);
position.x -= clamp(wave, -fxyz.x, 1.0-fxyz.x);
position.y += clamp(waveY*0.25, -fxyz.y, 1.0-fxyz.y)+0.015;
position.z += clamp(wave*0.45, -fxyz.z, 1.0-fxyz.z);
}
#endif
color = gl_Color;
if(mc_Entity.x == METALLIC_BLOCK) normal.a = 0.4;
if(mc_Entity.x == POLISHED_BLOCK) normal.a = 0.5;
//Fix colors on emissive blocks, removed lava as it might cause issues with custom optifine color maps.
if (mc_Entity.x == ENTITY_FIRE
|| mc_Entity.x == ENTITY_EMISSIVE
|| mc_Entity.x == ENITIY_SOULFIRE
|| mc_Entity.x == 10090.0){
normal.a = 0.6;
color = vec4(1.0);
}
if(mc_Entity.x == ENITIY_SOULFIRE || mc_Entity.x == 10090.0) texcoord.z = 0.85;
if(mc_Entity.x == ENTITY_LAVA) normal.a = 0.6;
//Translucent blocks
if (mc_Entity.x == ENTITY_VINES
|| mc_Entity.x == ENTITY_SMALLENTS
|| mc_Entity.x == ENTITY_NON_DIFFUSED
|| mc_Entity.x == ENTITY_LILYPAD
|| mc_Entity.x == ENTITY_LAVA
|| mc_Entity.x == ENTITY_LEAVES
|| mc_Entity.x == ENTITY_SMALLGRASS
|| mc_Entity.x == ENTITY_UPPERGRASS
|| mc_Entity.x == ENTITY_LOWERGRASS){
normal.a = 0.7;
}
if(mc_Entity.x == 10300.0) color = vec4(1.0); //fix lecterns
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
#ifdef TAA
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
#endif
#if nMap >= 1 || defined metallicRefl || defined polishedRefl
block = mc_Entity.x;
if(mc_Entity.x == ENTITY_EMISSIVE) block = -1.0; //enable bump and parallax mapping for defined ids.
vec2 midcoord = (gl_TextureMatrix[0] * mc_midTexCoord).st;
vec2 texcoordminusmid = texcoord.xy-midcoord;
vtexcoordam.pq = abs(texcoordminusmid)*2;
vtexcoordam.st = min(texcoord.xy ,midcoord-texcoordminusmid);
vtexcoord.xy = sign(texcoordminusmid)*0.5+0.5;
vec3 tangent = normalize(gl_NormalMatrix * at_tangent.xyz);
vec3 binormal = normalize(gl_NormalMatrix * cross(at_tangent.xyz, gl_Normal.xyz) * at_tangent.w);
tbnMatrix = mat3(tangent.x, binormal.x, normal.x,
tangent.y, binormal.y, normal.y,
tangent.z, binormal.z, normal.z);
dist = length(gl_ModelViewMatrix * gl_Vertex);
//viewVector = tbnMatrix * (mat3(gl_ModelViewMatrix) * gl_Vertex.xyz + gl_ModelViewMatrix[3].xyz);
viewVector = tbnMatrix * (gl_ModelViewMatrix * gl_Vertex).xyz;
//viewVector.xy = viewVector.xy / dist * 8.25;
#endif
}

View File

@@ -0,0 +1,96 @@
#version 120
/* DRAWBUFFERS:56 */
//Render entities etc in here, boost and fix enchanted armor effect in gbuffers_armor_glint
#define gbuffers_shadows
#define gbuffers_texturedblock
#include "shaders.settings"
varying vec4 color;
varying vec2 texcoord;
varying vec3 normal;
varying vec3 ambientNdotL;
varying vec3 finalSunlight;
varying float skyL;
#ifdef Shadows
uniform mat4 gbufferProjectionInverse;
uniform mat4 gbufferModelViewInverse;
uniform mat4 shadowProjection;
uniform mat4 shadowModelView;
uniform sampler2DShadow shadowtex0;
vec3 toScreenSpace(vec3 pos) {
vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw);
if(gl_ProjectionMatrix[2][2] > -0.5) pos.z += 0.38; //hand
vec3 p3 = pos * 2.0 - 1.0;
vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3];
return fragposition.xyz / fragposition.w;
}
float shadowfilter(vec3 shadowpos, float dif){
vec2 offset = vec2(0.65, -0.65) / shadowMapResolution;
return clamp(dot(vec4(shadow2D(shadowtex0,vec3(shadowpos.xy + offset.xx, shadowpos.z)).x,
shadow2D(shadowtex0,vec3(shadowpos.xy + offset.yx, shadowpos.z)).x,
shadow2D(shadowtex0,vec3(shadowpos.xy + offset.xy, shadowpos.z)).x,
shadow2D(shadowtex0,vec3(shadowpos.xy + offset.yy, shadowpos.z)).x),vec4(0.25))*dif,0.0,1.0);
}
#endif
uniform sampler2D texture;
uniform float viewWidth;
uniform float viewHeight;
uniform float rainStrength;
uniform vec3 shadowLightPosition;
uniform int worldTime;
uniform ivec2 eyeBrightnessSmooth;
uniform vec4 entityColor;
uniform int entityId;
void main() {
float diffuse = clamp(dot(normalize(shadowLightPosition),normal),0.0,1.0);
vec4 albedo = texture2D(texture, texcoord.xy)*color;
#ifdef MobsFlashRed
albedo.rgb = mix(albedo.rgb,entityColor.rgb,entityColor.a);
#endif
#ifdef Shadows
#define diagonal3(mat) vec3((mat)[0].x, (mat)[1].y, (mat)[2].z)
//don't do shading if transparent/translucent (not opaque)
if (diffuse > 0.0 && rainStrength < 0.9 && albedo.a > 0.01){
vec3 fragposition = toScreenSpace(vec3(gl_FragCoord.xy/vec2(viewWidth,viewHeight),gl_FragCoord.z));
vec3 worldposition = mat3(gbufferModelViewInverse) * fragposition.xyz + gbufferModelViewInverse[3].xyz;
worldposition = mat3(shadowModelView) * worldposition.xyz + shadowModelView[3].xyz;
worldposition = diagonal3(shadowProjection) * worldposition.xyz + shadowProjection[3].xyz;
float distortion = calcDistortion(worldposition.xy);
float threshMul = max(2048.0/shadowMapResolution*shadowDistance/128.0,1.5); //increased offset to fix self shadowing on armor
float distortThresh = (sqrt(1.0-diffuse*diffuse)/diffuse+0.7)/distortion;
float bias = distortThresh/6000.0*threshMul;
worldposition.xy *= distortion;
worldposition.xyz = worldposition.xyz * vec3(0.5,0.5,0.5/6.0) + vec3(0.5,0.5,0.5);
worldposition.z -= bias;
//Fast and simple shadow drawing for proper rendering of entities etc
diffuse *= shadowfilter(worldposition, diffuse);
diffuse *= (1.0 - rainStrength);
diffuse *= mix(skyL,1.0,clamp((eyeBrightnessSmooth.y/255.0-2.0/16.)*4.0,0.0,1.0)); //avoid light leaking underground
}
#else
diffuse *= mix(skyL,1.0,clamp((eyeBrightnessSmooth.y/255.0-4.0/16.)*4.0,0.0,1.0)); //Fix lighting in caves with if shadows are disabled
#endif
vec3 finalColor = pow(albedo.rgb,vec3(2.2)) * (finalSunlight*diffuse+ambientNdotL.rgb);
//Lightning rendering
if(entityId == 11000.0){
float night = clamp((worldTime-13000.0)/300.0,0.0,1.0)-clamp((worldTime-22800.0)/200.0,0.0,1.0);
finalColor = vec3(0.025, 0.03, 0.05) * (1.0-0.75*night);
albedo.a = 1.0;
}
gl_FragData[0] = vec4(finalColor, albedo.a);
gl_FragData[1] = vec4(normalize(albedo.rgb+0.00001), albedo.a);
}

View File

@@ -0,0 +1,127 @@
#version 120
#define composite2
#define gbuffers_texturedblock
#define lightingColors
#include "shaders.settings"
varying vec4 color;
varying vec2 texcoord;
varying vec3 normal;
varying vec3 ambientNdotL;
varying vec3 finalSunlight;
varying float skyL;
uniform vec3 sunPosition;
uniform vec3 upPosition;
uniform int worldTime;
uniform float rainStrength;
uniform float nightVision;
uniform mat4 gbufferModelView;
uniform mat4 gbufferModelViewInverse;
const vec3 ToD[7] = vec3[7]( vec3(0.58597,0.15,0.02),
vec3(0.58597,0.35,0.09),
vec3(0.58597,0.5,0.26),
vec3(0.58597,0.5,0.35),
vec3(0.58597,0.5,0.36),
vec3(0.58597,0.5,0.37),
vec3(0.58597,0.5,0.38));
#ifdef TAA
uniform float viewWidth;
uniform float viewHeight;
vec2 texelSize = vec2(1.0/viewWidth,1.0/viewHeight);
uniform int framemod8;
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-1.,3.)/8.,
vec2(5.0,1.)/8.,
vec2(-3,-5.)/8.,
vec2(-5.,5.)/8.,
vec2(-7.,-1.)/8.,
vec2(3,7.)/8.,
vec2(7.,-7.)/8.);
#endif
#ifdef HandLight
uniform int isEyeInWater;
uniform int heldBlockLightValue;
uniform int heldBlockLightValue2;
#endif
void main() {
color = gl_Color;
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
#ifdef TAA
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
#endif
normal = normalize(gl_NormalMatrix * gl_Normal);
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
vec2 lmcoord = clamp((gl_TextureMatrix[1] * gl_MultiTexCoord1).xy, 0.0, 1.0);
/*--------------------------------*/
//Emissive blocks lighting in order to fix lighting on particles
#ifdef HandLight
bool underwaterlava = (isEyeInWater == 1.0 || isEyeInWater == 2.0);
if(!underwaterlava) lmcoord.x = max(lmcoord.x, max(max(float(heldBlockLightValue), float(heldBlockLightValue2)) - 1.0 - length(gl_ModelViewMatrix * gl_Vertex), 0.0) / 15.0);
#endif
float torch_lightmap = 16.0-min(15.,(lmcoord.s-0.5/16.)*16.*16./15);
float fallof1 = clamp(1.0 - pow(torch_lightmap/16.0,4.0),0.0,1.0);
torch_lightmap = fallof1*fallof1/(torch_lightmap*torch_lightmap+1.0);
vec3 emissiveLightC = vec3(emissive_R,emissive_G,emissive_B)*torch_lightmap;
float finalminlight = (nightVision > 0.01)? 0.075 : minlight; //add nightvision support but make sure minlight is still adjustable.
/*---------------------------------------------------------------------*/
//reduced the sun color to a 7 array
float hour = max(mod(worldTime/1000.0+2.0,24.0)-2.0,0.0); //-0.1
float cmpH = max(-abs(floor(hour)-6.0)+6.0,0.0); //12
float cmpH1 = max(-abs(floor(hour)-5.0)+6.0,0.0); //1
vec3 temp = ToD[int(cmpH)];
vec3 temp2 = ToD[int(cmpH1)];
vec3 sunlight = mix(temp,temp2,fract(hour));
sunlight.rgb += vec3(r_multiplier,g_multiplier,b_multiplier); //allows lighting colors to be tweaked.
sunlight.rgb *= light_brightness; //brightness needs to be adjusted if we tweak lighting colors.
const vec3 rainC = vec3(0.01,0.01,0.01);
sunlight = mix(sunlight,rainC*sunlight,rainStrength);
/*-------------------------------------------------------------------*/
const vec3 moonlight = vec3(0.0024, 0.00432, 0.0078);
vec3 sunVec = normalize(sunPosition);
vec3 upVec = normalize(upPosition);
vec2 visibility = vec2(dot(sunVec,upVec),dot(-sunVec,upVec));
float NdotL = dot(normal,sunVec);
float NdotU = dot(normal,upVec);
vec2 trCalc = min(abs(worldTime-vec2(23000.0,12700.0)),750.0); //adjust to make day-night switch smoother
float tr = max(min(trCalc.x,trCalc.y)/375.0-1.0,0.0);
visibility = pow(clamp(visibility+0.15,0.0,0.15)/0.15,vec2(4.0));
skyL = max(lmcoord.t-2./16.0,0.0)*1.14285714286;
float SkyL2 = skyL*skyL;
float skyc2 = mix(1.0,SkyL2,skyL);
vec4 bounced = vec4(NdotL,NdotL,NdotL,NdotU) * vec4(-0.14*skyL*skyL,0.34,0.7,0.1) + vec4(0.6,0.66,0.7,0.25);
bounced *= vec4(skyc2,skyc2,visibility.x-tr*visibility.x,0.8);
vec3 sun_ambient = bounced.w * (vec3(0.1, 0.5, 1.1)+rainStrength*vec3(0.05,-0.27,-0.8))*2.3+ 1.7*sunlight*(sqrt(bounced.w)*bounced.x*2.4 + bounced.z)*(1.0-rainStrength*0.98);
vec3 moon_ambient = (moonlight*0.7 + moonlight*bounced.y)*(1.0-rainStrength*0.95)*2.0;
vec3 amb1 = (sun_ambient*visibility.x + moon_ambient*visibility.y)*SkyL2*(0.03+tr*0.17)*0.65;
ambientNdotL.rgb = amb1 + emissiveLightC + finalminlight*0.5*min(skyL+6/16.,9/16.)*normalize(amb1+0.0001)*3.0;
//sunlight = mix(sunlight,moonlight*(1.0-rainStrength*0.9),visibility.y)*tr;
sunlight = mix(sunlight,moonlight*(1.0-rainStrength*0.9),visibility.y); //remove time check to improve day-night transition
finalSunlight = sunlight*0.9;
}

142
shaders/gbuffers_water.fsh Normal file
View File

@@ -0,0 +1,142 @@
#version 120
#define gbuffers_shadows
#define gbuffers_water
#include "shaders.settings"
varying vec4 color;
varying vec4 ambientNdotL;
varying vec2 texcoord;
varying vec2 lmcoord;
varying vec3 getSunlight;
varying vec3 viewVector;
varying vec3 worldpos;
varying vec3 getShadowPos;
varying float diffuse;
varying mat3 tbnMatrix;
uniform sampler2D noisetex;
uniform sampler2D texture;
uniform vec3 shadowLightPosition;
uniform float rainStrength;
uniform float frameTimeCounter;
#ifdef Shadows
uniform sampler2DShadow shadowtex0;
float shadowfilter(){
vec2 offset = vec2(0.65, -0.65) / shadowMapResolution;
return dot(vec4(shadow2D(shadowtex0,vec3(getShadowPos.xy + offset.xx, getShadowPos.z)).x,
shadow2D(shadowtex0,vec3(getShadowPos.xy + offset.yx, getShadowPos.z)).x,
shadow2D(shadowtex0,vec3(getShadowPos.xy + offset.xy, getShadowPos.z)).x,
shadow2D(shadowtex0,vec3(getShadowPos.xy + offset.yy, getShadowPos.z)).x),vec4(0.25));
}
#endif
vec4 encode (vec3 n,float dif){
float p = sqrt(n.z*8+8);
float vis = lmcoord.t;
if (ambientNdotL.a > 0.9) vis = vis * 0.25;
if (ambientNdotL.a > 0.4 && ambientNdotL.a < 0.6) vis = vis*0.25+0.25;
if (ambientNdotL.a < 0.1) vis = vis*0.25+0.5;
return vec4(n.xy/p + 0.5,vis,1.0);
}
mat2 rmatrix(float rad){
return mat2(vec2(cos(rad), -sin(rad)), vec2(sin(rad), cos(rad)));
}
float calcWaves(vec2 coord, float iswater){
if(iswater > 0.9){
vec2 movement = abs(vec2(0.0, -frameTimeCounter * 0.31365));
coord *= 0.262144;
vec2 coord0 = coord * rmatrix(1.0) - movement * 4.0;
coord0.y *= 3.0;
vec2 coord1 = coord * rmatrix(0.5) - movement * 1.5;
coord1.y *= 3.0;
vec2 coord2 = coord + movement * 0.5;
coord2.y *= 3.0;
coord0 *= waveSize;
coord1 *= waveSize;
float wave = 1.0 - texture2D(noisetex,coord0 * 0.005).x * 10.0; //big waves
wave += texture2D(noisetex,coord1 * 0.010416).x * 7.0; //small waves
wave += sqrt(texture2D(noisetex,coord2 * 0.045).x * 6.5) * 1.33; //noise texture
wave *= 0.0157;
return wave;
} else return sqrt(texture2D(noisetex,coord * 0.5).x) * 0.035; //translucent noise, non water
}
vec3 calcBump(vec2 coord, float iswater){
const vec2 deltaPos = vec2(0.25, 0.0);
float h0 = calcWaves(coord, iswater);
float h1 = calcWaves(coord + deltaPos.xy, iswater);
float h2 = calcWaves(coord - deltaPos.xy, iswater);
float h3 = calcWaves(coord + deltaPos.yx, iswater);
float h4 = calcWaves(coord - deltaPos.yx, iswater);
float xDelta = ((h1-h0)+(h0-h2));
float yDelta = ((h3-h0)+(h0-h4));
return vec3(vec2(xDelta,yDelta)*0.5, 0.5); //z = 1.0-0.5
}
vec3 calcParallax(vec3 pos, float iswater){
float getwave = calcWaves(pos.xz - pos.y, iswater);
pos.xz += (getwave * viewVector.xy) * waterheight;
return pos;
}
void main() {
float iswater = clamp(ambientNdotL.a*2.0-1.0,0.0,1.0);
vec4 albedo = texture2D(texture, texcoord.xy)*color;
albedo.rgb = pow(albedo.rgb,vec3(2.2));
float texvis = wtexblend;
#ifndef watertex
texvis = 0.11;
if(iswater > 0.9)albedo.rgb = vec3(waterCR,waterCG,waterCB);
#endif
//Bump and parallax mapping
vec3 waterpos = worldpos;
#ifdef WaterParallax
waterpos = calcParallax(waterpos, iswater);
#endif
vec3 bump = calcBump(waterpos.xz - waterpos.y, iswater);
vec3 newnormal = normalize(bump * tbnMatrix);
//---
//fast shading for translucent blocks
float NdotL = diffuse;
#ifdef Shadows
if(NdotL > 0.001 && (abs(getShadowPos.x) < 1.0-1.5/shadowMapResolution && abs(getShadowPos.y) < 1.0-1.5/shadowMapResolution && abs(getShadowPos.z) < 6.0) && rainStrength < 0.9)NdotL *= shadowfilter();
NdotL *= (1.0 - iswater);
NdotL *= (1.0 - rainStrength);
#endif
vec3 sunlight = getSunlight.rgb*NdotL*(1.0-rainStrength*0.99)*0.85;
//---
//vec3 fColor = albedo.rgb*(0.002+sunlight+ambientNdotL.rgb); //add a min value for water color in caves, makes water a tiny bit brighter, WIP
vec3 fColor = albedo.rgb*(sunlight+ambientNdotL.rgb);
float alpha = mix(albedo.a,texvis,iswater);
if(iswater > 0.9)alpha *= waterA;
/* DRAWBUFFERS:526 */
gl_FragData[0] = vec4(fColor,alpha);
gl_FragData[1] = encode(newnormal.xyz, NdotL);
gl_FragData[2] = vec4(normalize(albedo.rgb+0.00001),alpha);
}

209
shaders/gbuffers_water.vsh Normal file
View File

@@ -0,0 +1,209 @@
#version 120
#define composite2
#define gbuffers_shadows
#define gbuffers_water
#define lightingColors
#include "shaders.settings"
varying vec4 color;
varying vec4 ambientNdotL;
varying vec2 texcoord;
varying vec2 lmcoord;
varying vec3 getSunlight;
varying vec3 viewVector;
varying vec3 worldpos;
varying vec3 getShadowPos;
varying float diffuse;
varying mat3 tbnMatrix;
attribute vec4 mc_Entity;
attribute vec4 at_tangent; //xyz = tangent vector, w = handedness, added in 1.7.10
uniform vec3 cameraPosition;
uniform vec3 sunPosition;
uniform vec3 upPosition;
uniform mat4 gbufferModelView;
uniform mat4 gbufferModelViewInverse;
uniform int worldTime;
uniform float rainStrength;
uniform float nightVision;
#ifdef Shadows
uniform mat4 shadowProjection;
uniform mat4 shadowModelView;
uniform vec3 shadowLightPosition;
#endif
#ifdef Waving_Water
uniform float frameTimeCounter;
const float PI = 3.1415927;
#endif
const vec3 ToD[7] = vec3[7]( vec3(0.58597,0.16,0.005),
vec3(0.58597,0.31,0.05),
vec3(0.58597,0.45,0.16),
vec3(0.58597,0.5,0.35),
vec3(0.58597,0.5,0.36),
vec3(0.58597,0.5,0.37),
vec3(0.58597,0.5,0.38));
float SunIntensity(float zenithAngleCos, float sunIntensity, float cutoffAngle, float steepness){
return sunIntensity * max(0.0, 1.0 - exp(-((cutoffAngle - acos(zenithAngleCos))/steepness)));
}
float luma(vec3 color) {
return dot(color,vec3(0.299, 0.587, 0.114));
}
#ifdef TAA
uniform float viewWidth;
uniform float viewHeight;
vec2 texelSize = vec2(1.0/viewWidth,1.0/viewHeight);
uniform int framemod8;
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-1.,3.)/8.,
vec2(5.0,1.)/8.,
vec2(-3,-5.)/8.,
vec2(-5.,5.)/8.,
vec2(-7.,-1.)/8.,
vec2(3,7.)/8.,
vec2(7.,-7.)/8.);
#endif
void main() {
//pos
vec3 normal = normalize(gl_NormalMatrix * gl_Normal).xyz;
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
worldpos = position.xyz + cameraPosition;
color = gl_Color;
texcoord = (gl_MultiTexCoord0).xy;
lmcoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
diffuse = 0.0; //required to fix compiling issues on macOS
#ifdef Shadows
#define diagonal3(mat) vec3((mat)[0].x, (mat)[1].y, (mat)[2].z)
diffuse = clamp(dot(normal, normalize(shadowLightPosition)),0.0,1.0);
if(diffuse > 0.001){
vec3 shadowpos = position.xyz;
shadowpos = mat3(shadowModelView) * shadowpos.xyz + shadowModelView[3].xyz;
shadowpos = diagonal3(shadowProjection) * shadowpos.xyz + shadowProjection[3].xyz;
float distortion = calcDistortion(shadowpos.xy);
shadowpos.xy *= distortion;
//only if on shadowmap
if (abs(shadowpos.x) < 1.0-1.5/shadowMapResolution && abs(shadowpos.y) < 1.0-1.5/shadowMapResolution && abs(shadowpos.z) < 6.0){
float threshMul = max(2048.0/shadowMapResolution*shadowDistance/128.0,0.95);
float distortThresh = (sqrt(1.0-diffuse*diffuse)/diffuse+0.7)/distortion;
float bias = distortThresh/6000.0*threshMul;
shadowpos = shadowpos * vec3(0.5,0.5,0.5/6.0) + vec3(0.5,0.5,0.5);
shadowpos.z -= bias;
getShadowPos = shadowpos.xyz;
}
}
#endif
//Transparency stuff
ambientNdotL.a = 0.0;
float iswater = 1.0; //disable lightmap on water, make light go through instead
if(mc_Entity.x == 10008.0) {
ambientNdotL.a = 1.0;
iswater = 0.0;
#ifdef Waving_Water
float fy = fract(worldpos.y + 0.001);
float wave = 0.05 * sin(2 * PI * (frameTimeCounter*0.8 + worldpos.x / 2.5 + worldpos.z / 5.0))
+ 0.05 * sin(2 * PI * (frameTimeCounter*0.6 + worldpos.x / 6.0 + worldpos.z / 12.0));
position.y += clamp(wave, -fy, 1.0-fy)*waves_amplitude;
#endif
}
if(mc_Entity.x == 10079.0) ambientNdotL.a = 0.5;
//---
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
#ifdef TAA
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
#endif
//ToD
float hour = max(mod(worldTime/1000.0+2.0,24.0)-2.0,0.0); //-0.1
float cmpH = max(-abs(floor(hour)-6.0)+6.0,0.0); //12
float cmpH1 = max(-abs(floor(hour)-5.0)+6.0,0.0); //1
#ifdef MC_GL_VENDOR_ATI
vec3 sunlight = vec3(1.0); //Time of day calculation breaks water on amd drivers 18.8.1, last working driver was 18.6.1, causes heavy flickering. TESTED ON RX460
#else
vec3 sunlight = mix(ToD[int(cmpH)], ToD[int(cmpH1)], fract(hour));
#endif
sunlight.rgb += vec3(r_multiplier,g_multiplier,b_multiplier); //allows lighting colors to be tweaked.
sunlight.rgb *= light_brightness; //brightness needs to be adjusted if we tweak lighting colors.
//---
//lightmap
float torch_lightmap = 16.0-min(15.0,(lmcoord.s-0.5/16.0)*16.0*16.0/15.0);
float fallof1 = clamp(1.0 - pow(torch_lightmap/16.0,4.0),0.0,1.0);
torch_lightmap = fallof1*fallof1/(torch_lightmap*torch_lightmap+1.0);
torch_lightmap *= iswater;
vec3 emissiveLightC = vec3(emissive_R,emissive_G,emissive_B)*torch_lightmap*0.2;
//---
//light bounce
vec3 sunVec = normalize(sunPosition);
vec3 upVec = normalize(upPosition);
vec2 visibility = vec2(dot(sunVec,upVec),dot(-sunVec,upVec));
float cutoffAngle = 1.608;
float steepness = 1.5;
float cosSunUpAngle = dot(sunVec, upVec) * 0.95 + 0.05; //Has a lower offset making it scatter when sun is below the horizon.
float sunE = SunIntensity(cosSunUpAngle, 1000.0, cutoffAngle, steepness); // Get sun intensity based on how high in the sky it is
float NdotL = dot(normal,sunVec);
float NdotU = dot(normal,upVec);
vec2 trCalc = min(abs(worldTime-vec2(23000.0,12700.0)),750.0); //adjust to make day-night switch smoother
float tr = max(min(trCalc.x,trCalc.y)/375.0-1.0,0.0);
visibility = pow(clamp(visibility+0.15,0.0,0.3)/0.3,vec2(4.4));
sunlight = sunlight/luma(sunlight)*sunE*0.0075*0.075*3.*visibility.x;
float skyL = max(lmcoord.t-2./16.0,0.0)*1.14285714286;
float SkyL2 = skyL*skyL;
float skyc2 = mix(1.0,SkyL2,skyL);
vec4 bounced = vec4(NdotL,NdotL,NdotL,NdotU) * vec4(-0.14*skyL*skyL,0.33,0.7,0.1) + vec4(0.6,0.66,0.7,0.25);
bounced *= vec4(skyc2,skyc2,visibility.x-tr*visibility.x,0.8);
vec3 ambientC = mix(vec3(0.3, 0.5, 1.1),vec3(0.08,0.1,0.1),rainStrength)*length(sunlight)*bounced.w;
ambientC += 0.25*sunlight*(bounced.x + bounced.z)*(0.03+tr*0.17)/0.4*(1.0-rainStrength*0.98) + length(sunlight)*0.2*(1.0-rainStrength*0.9);
ambientC += sunlight*(NdotL*0.5+0.45)*visibility.x*(1.0-tr)*(1.0-tr)*4.*(1.0-rainStrength*0.98);
//lighting during night time
const vec3 moonlight = vec3(0.0024, 0.00432, 0.0078);
vec3 moon_ambient = (moonlight*2.0 + moonlight*bounced.y)*(4.0-rainStrength*0.95)*0.2;
vec3 moonC = (moon_ambient*visibility.y)*SkyL2*(0.03*0.65+tr*0.17*0.65);
float wminlight = (nightVision > 0.01)? 0.075: 0.00008;
ambientNdotL.rgb = ambientC*SkyL2*0.3 + moonC + emissiveLightC + wminlight;
//sunlight = mix(sunlight,moonlight*(1.0-rainStrength*0.9),visibility.y)*tr;
sunlight = mix(sunlight,moonlight*(1.0-rainStrength*0.9),visibility.y); //remove time check to improve day-night transition
getSunlight = sunlight;
//---
vec3 tangent = normalize(gl_NormalMatrix * at_tangent.xyz);
vec3 binormal = normalize(gl_NormalMatrix * cross(at_tangent.xyz, gl_Normal.xyz) * at_tangent.w);
tbnMatrix = mat3(tangent.x, binormal.x, normal.x,
tangent.y, binormal.y, normal.y,
tangent.z, binormal.z, normal.z);
float dist = length(gl_ModelViewMatrix * gl_Vertex);
viewVector = tbnMatrix * (gl_ModelViewMatrix * gl_Vertex).xyz;
viewVector.xy = viewVector.xy / dist * 8.25;
}

View File

@@ -0,0 +1,17 @@
#version 120
/* DRAWBUFFERS:26 */
varying vec4 color;
varying vec2 texcoord;
varying float lmcoord;
uniform sampler2D texture;
void main() {
vec4 tex = texture2D(texture, texcoord.xy)*color;
gl_FragData[0] = vec4(vec3(1.0,lmcoord,1.0),tex.a*length(tex.rgb)/1.732); //render weather infront of transparency
gl_FragData[1] = vec4(vec3(1.0,lmcoord,1.0),tex.a*length(tex.rgb)/1.732); //render weather for everything else
}

View File

@@ -0,0 +1,28 @@
#version 120
#define gbuffers_weather
#include "shaders.settings"
varying vec4 color;
varying vec2 texcoord;
varying float lmcoord;
uniform vec3 cameraPosition;
uniform mat4 gbufferModelViewInverse;
uniform mat4 gbufferModelView;
void main() {
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
#ifdef WeatherAngle
float worldpos = position.y + cameraPosition.y;
bool istopv = worldpos > cameraPosition.y+5.0;
if (!istopv) position.xz += vec2(3.0,1.0);
#endif
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
lmcoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).s;
color = gl_Color;
}

355
shaders/lang/en_US.lang Normal file
View File

@@ -0,0 +1,355 @@
# Change effect names using a language file
# How to change names and comments:
# option.EffectName=New effect name
# option.EffectName.comment=Your comment.
#
# Change screen names through language instead of properties
# How to change screen names and give them comments:
# screen.ScreenName=New screen name
# screen.ScreenName.comment=Your comment
#
# Tooltip lines ending with "!" are automatically shown red.
# example: option.SHADOW_FILTER.comment=Smooth out shadows. Very small performance hit!.
#composite.fsh
option.TAA_sharpness=sharpening
value.TAA_sharpness.0.0=Off
option.HandLight=Handheld Lighting
option.HandLight.comment=Toggle handheld lighting.
option.light_brightness=Light brightness
option.light_brightness.comment=This should be tweaked once you've adjusted the lighting colors.
option.r_multiplier=red amount
option.g_multiplier=green amount
option.b_multiplier=blue amount
option.eyeLight=Eye light adaption
option.eyeLight.comment=Adjust the eye light adapation amount, doing so will increase or decrease lighting strength in general. Adjust bloom accordingly.
option.sunPathRotation=Sun/Moon angle
option.sunPathRotation.comment=Adjust sun and moon angle.
value.sunPathRotation.0.0f=Default
value.sunPathRotation.-40.0f=Alternative
option.EmissiveLightStrength=Lighting strength
option.EmissiveLightStrength.comment=Adjust the lighting strength of emissive blocks, like torches.
option.Sunlightamount=Sunlightamount
option.Sunlightamount.comment=10,50,200
option.ColoredShadows=Colored Shadows
option.ColoredShadows.comment=Toggle colored shadows. Tints shadows color if passing through stained glass. Can cause some visual glitches.
option.grass_shadows=Grass Shadows
option.grass_shadows.comment=Toggle grass shadows, also disables shadows for tallgrass and flowers.
option.Penumbra=Variable Penumbra Shadows
option.Penumbra.comment=Shadow filtering. The farther shadows are away from their source the more soft they become. Doesn't work on AMD or Intel gpus.
option.shadow_samples=Shadowfilter Quality
option.shadow_samples.comment=Adjust the quality of the shadowfilter. Increase this if you run into issues with penumbra shadows on.
option.Farshadowplane=Far Shadowplane Quality
option.Farshadowplane.comment=This is the far plane of the shadowmap. Higher values reduce closeup quality, improve performance and shadow rendering distance by stretching the shadowmap. If black dots appear increase near shadowplane quality.
option.Nearshadowplane=Near Shadowplane Quality
option.Nearshadowplane.comment=This is the near plane of the shadowmap. Lower values improve shadow quality, reduce performance and shadow rendering distance by squeezing the shadowmap together. You want to increase this if you increase far plane shadow quality, otherwise leave it alone.
option.raytracedShadows=Raytraced Shadows
option.raytracedShadows.comment=Improves closeup and faraway shadows. Also allows shadows to be cast outside of the shadowmap, outside of your shadows render distance. Requires shadows to be enabled. Has some issues since it's raytraced in screenspace.
option.shadowMapResolution=Shadows Resolution
option.shadowMapResolution.comment=Change the shadows resolution. Reduce the shadow render distance at low resolutions to improve quality and reduce flickering.
value.shadowMapResolution.256=Lowest
value.shadowMapResolution.512=Very Low
value.shadowMapResolution.1024=Low
value.shadowMapResolution.2048=Medium
value.shadowMapResolution.3072=High
value.shadowMapResolution.4096=Very High
value.shadowMapResolution.6144=Extreme
value.shadowMapResolution.8192=Insane
value.shadowMapResolution.16384=Madman
option.shadowDistance=Shadows Render Distance
option.shadowDistance.comment=Change the render distance of shadows. This stretches the shadowmap, so make sure to increase the shadows resolution on high values.
option.Clouds=Clouds
option.Clouds.comment=Toggle clouds. Volumetric clouds run a bit faster than 2D clouds.
value.Clouds.0=Off
value.Clouds.1=Default MC
value.Clouds.2=2D
value.Clouds.3=Volumetric
value.Clouds.4=2D + Volumetric
option.cloudsIT=Cloud Quality
option.cloudsIT.comment=Adjust quality of volumetric clouds.
option.cloudreflIT=Cloud Reflections Quality
option.cloudreflIT.comment=Adjust reflections quality of volumetric clouds.
option.Cloud_reflection=Cloud reflections
option.Cloud_reflection.comment=Toggle cloud reflections. §4Medium performance impact.
option.cloud_height=Cloud height
option.cloud_height.comment=Adjust the clouds height.
option.Cloudsblur=Sky blur
option.Cloudsblur.comment=Apply a blur filter to the sky to make volumetric clouds smoother. On AMD cards this filter is also applied to distant land due to driver issues. Doesn't work with DoF or Motionbur.
option.waterRefl=Water reflections
option.waterRefl.comment=Toggle water reflections.
option.iceRefl=Ice and Glass reflections
option.iceRefl.comment=Toggle ice and stained glass reflections.
option.metallicRefl=Metallic Reflections
option.metallicRefl.comment=Toggle reflections for metallic blocks like iron. Metallic blocks are defined in block.properties.
option.polishedRefl=Polished Reflections
option.polishedRefl.comment=Toggle reflections for polished blocks like polished granite. Polished blocks are defined in block.properties.
option.metalStrength=Reflections strength
option.metalStrength.comment=Adjust reflection strength for metallic and polished reflections. If the reflections become to dark, increase sky reflection.
option.metallicSky=Sky reflection
option.metallicSky.comment=Adjust the amount of sky reflections on metallic and polished blocks. Higher values make it look more wet.
option.RainReflections=Rain reflections
option.RainReflections.comment=Toggle rain reflections / wetness while raining.
option.BiomeCheck=Biomes check
option.BiomeCheck.comment=Checks if the biome that you're in actually supports rainy weather for reflections. Disable to have rain reflections / wetness in every biome. Updating optifine might resolve issues with missing reflections with this on.
option.rainNoise=Rain noise
option.rainNoise.comment=Adjust the amount of noise for rain reflections, higher values mean less noise.
option.defskybox=Default Skybox
option.defskybox.comment=Toggle support for the default skybox, including custom skies from resourcepacks. If no resourcepack is present this will only enable the default sun and moon texture. This option also auto disables the custom shader sun and moon.
option.skyboxblendfactor=Skybox blend factor
option.skyboxblendfactor.comment=Tweak the color amount of the custom shader sky mixing with the default skybox texture.
option.customStars=Shader Stars
option.customStars.comment=Toggle stars.
option.Dynamic_Handlight=Dynamic Handlight
option.Dynamic_Handlight.comment=Items like torches emit light while holding them in your hand. §4No performance impact.
option.Godrays=Godrays
option.Godrays.comment=Makes the sun casts rays. §4Low performance impact.
Volumetric_Lighting
option.Volumetric_Lighting=Volumetric Lighting
option.Volumetric_Lighting.comment=Enable volumetric lightning, disables godrays since it's comes with it's own ones.
option.VL_amount=Volumetric lighting amount
option.Celshading=Celshading
option.Celshading.comment=Applies black lines on everything making it look cartoony, similar to borderlands. §4Very low perfomance impact.
option.Celborder=Celshading outline thickness
option.Celborder.comment=Adjust the outline thickness of celshading
option.Celradius=Celshading search radius
option.Celradius.comment=Adjust the search radius for celshading. Lower values mean less search radius, which might misses some inline borders, creating more of an outline shader. Which can look cool aswell.
option.SSDO=Ambient Occlusion
option.SSDO.comment=Makes lighting more realistic (SSDO). §4Medium performance impact.
option.ao_strength=AO amount
option.ao_strength.comment=Adjust the amount/strength of ambient occlusion.
option.Fog=Fog
option.Fog.comment=Toggle fog.
option.wFogDensity=Overworld fog density.
option.wFogDensity.comment=Adjust overworld fog density
option.morningFog=Morning Fog
option.morningFog.comment=Increases fog density during sunrise.
option.Underwater_Fog=Underwater Fog
option.Underwater_Fog.comment=Toggle fog underwater.
option.uFogDensity=Underwater fog density
option.uFogDensity.comment=Adjust underwater fog density.
option.uwatertint=Underwater color tint
option.uwatertint.comment=Toggle the blue color tint for ground underwater.
option.Whiteworld=Whiteworld
option.Whiteworld.comment=Makes the ground white, mostly used for debugging. This option was added because it was requested alot. I suppose it looks kinda neat for screenshots.
#composite.vsh
option.Moonlight=Moonlight
option.Moonlight.comment=Adjust brightness during night time.
value.Moonlight.0.0=Very Dark
value.Moonlight.0.0015=Dark
value.Moonlight.0.003=Default
value.Moonlight.0.006=Bright
value.Moonlight.0.009=Very bright
#----------------------------------------------------
#gbuffers_entitites.fsh
option.MobsFlashRed=Damage flash
option.MobsFlashRed.comment=Makes mobs and the player flash red when hurt.
#----------------------------------------------------
#final.fsh
option.Rain_Drops=Rain Drops
option.Rain_Drops.comment=Enables rain drops on screen during raining. §4Low performance impact.
#Godrays from composite.fsh
#Defined variables from final.fsh
option.Godrays_Density=Godrays density
option.Godrays_Density.comment=Changes the amount of sunrays.
value.Godrays_Density.0.575=Low
value.Godrays_Density.1.15=Default
value.Godrays_Density.2.3=Medium
value.Godrays_Density.4.6=High
value.Godrays_Density.9.2=Very High
option.Lens_Flares=Lens Flares
option.Lens_Flares.comment=Simulates camera lens effects. §4Bloom must be enabled for lens flares. §4Low performance impact.
option.Lens_Flares_Strength=Lens Flares strength
option.Lens_Flares_Strength.comment=Adjust the strength of lens flares.
value.Lens_Flares_Strength.1.0=Weak
value.Lens_Flares_Strength.4.0=Default
value.Lens_Flares_Strength.16.0=Strong
value.Lens_Flares_Strength.32.0=Very Strong
value.Lens_Flares_Strength.64.0=Even stronger
option.Bloom=Bloom
option.Bloom.comment=Adds a glowing effect to emissive blocks. Is also used for sun/moon glow. §4Medium performance impact.
option.bloom_strength=Bloom strength
option.bloom_strength.comment=Adjust the strength of bloom. Higher values make the image more soft and more blurry.
value.bloom_strength.0.5=Low
value.bloom_strength.0.75=Default
value.bloom_strength.1.0=Medium
value.bloom_strength.2.0=High
option.Depth_of_Field=Depth of Field
option.Depth_of_Field.comment=Simulates eye focusing on objects. §4Low performance impact
option.DoF_Strength=Blur amount
option.DoF_Strength.comment=Adjust the amount of blur used for depth of field.
option.smoothDof=Smooth Transition
option.smoothDof.comment=Toggle a smooth transition between clear and blurry while focusing on something.
option.Distance_Blur=Distance Blur
option.Distance_Blur.comment=§4Requires Depth of Field to be enabled. Replaces eye focusing effect with distance being blurred instead.
option.Dof_Distance_View=Blur view distance
option.Dof_Distance_View.comment=Adjust the view distance of blur.
option.Motionblur=Motionblur
option.Motionblur.comment=Blurres your view/camera during movemenent. Doesn't work with Depth of Field.
option.MB_strength=Blur strength
option.MB_strength.comment=Adjust the blur strength of Motionblur.
value.MB_strength.0.008=Low
value.MB_strength.0.014=Default
value.MB_strength.0.020=High
#----------------------------------------------------
#gbuffers_terrain.fsh/vsh
option.WaterParallax=Water parallax mapping
option.WaterParallax.comment=Enable or disable parallax mapping for water. §4Low performance impact
option.waterheight=Water height
option.waterheight.comment=Adjust the water height / parallax strength.
option.causticsStrength=Caustics strength
option.waveSize=Wave size
option.watertex=Water texture
option.watertex.comment=Toggle the default water texture / texture from your resourcepack.
option.wtexblend=Watertexture blend factor
option.wtexblend.comment=Adjust the texture strength.
option.waterCR=water color red
option.waterCG=water color green
option.waterCB=water color blue
option.waterA=water alpha
option.nMap=RP Support
option.nMap.comment=Enable bump or parallax mapping support for resourcepacks, the resourcepack must support it.
value.nMap.0=Off
value.nMap.1=Bumpmapping
value.nMap.2=Parallax
option.POM_RES=RP Resolution
option.POM_RES.comment=Increasing the resolution past the rp resolution makes it smoother.
option.POM_DEPTH=POM Depth
option.POM_DEPTH.comment=Adjust the depth of parallax mapping, to high values might look weird.
option.POM_DIST=POM Render Distance
option.POM_DIST.comment=Adjust the distance at which parallax mapping renders.
option.Waving_Leaves=Waving Leaves
option.Waving_Leaves.comment=
option.Waving_Vines=Waving Vines
option.Waving_Vines.comment=
option.Waving_Grass=Waving Grass
option.Waving_Grass.comment=Does not include tallgrass due some issues with it.
option.Waving_Fire=Waving Fire
option.Waving_Fire.comment=
option.Waving_Lanterns=Waving Lanterns
option.Waving_Lava=Waving Lava
option.Waving_Lava.comment=
option.Waving_Water=Waving Water
option.Waving_Water.comment=
option.waves_amplitude=Waves amplitude
option.waves_amplitude.comment=Adjust the water waves amplitude (height)
option.animationSpeed=Animation speed
option.animationSpeed.comment=Adjust the speed of all animations except water.
option.Waving_Lilypads=Waving Lilypad
option.Waving_Lilypads.comment=
option.Waving_Entities=Waving Entities
option.Waving_Entities.comment=Includes: Saplings, small flowers, wheat, carrots, potatoes and beetroot.
#----------------------------------------------------
#gbuffers_weather.vsh
option.WeatherAngle=Alternative Weather angle
option.WeatherAngle.comment=Toggle alternative weather angle.
#Screens
screen.AA_SCREEN=Antialiasing
screen.AA_SCREEN.comment=Toggle antialiasing (TAA) and adaptive sharpening.
screen.BLOOM_SCREEN=Bloom
screen.BLOOM_SCREEN.comment=Change things related to Bloom.
screen.COLORS_SCREEN=Colors
screen.COLORS_SCREEN.comment=Change various color options, like gamma or watercolors.
screen.WATERC_SCREEN=Water Colors
screen.LIGHTINGC_SCREEN=Lighting colors
screen.DOF_SCREEN=Depth of field
screen.DOF_SCREEN.comment=Change things related to Depth of Field.
screen.MB_SCREEN=Motionblur
screen.MB_SCREEN.comment=Change things related to Motionblur.
screen.SKY_SCREEN=Sky & Lighting
screen.SKY_SCREEN.comment=Contains sky related options, like godrays, lens flares and clouds.
screen.SHADOWS_SCREEN=Shadows
screen.SHADOWS_SCREEN.comment=Change shadow related settings like resolution and view distance.
screen.FOG_SCREEN=Fog options
screen.FOG_SCREEN.comment=Contains all fog related options.
screen.NORMALMAP_SCREEN=Normal map
screen.NORMALMAP_SCREEN.comment=Enable bump or parallax support if the resourcepack supports it.
screen.WAVING_SCREEN=Waving Objects
screen.WAVING_SCREEN.comment=Contains grass, wheat, leaves etc.
screen.EMISSIVE_SCREEN=Emissive Light
screen.EMISSIVE_SCREEN.comment=Change the lighting color of blocks that emit light, like torches.
option.emissive_R=red
option.emissive_G=green
option.emissive_B=blue
option.minlight=Minimum Light
screen.REFLECTIONS_SCREEN=Reflections
screen.REFLECTIONS_SCREEN.comment=Toggle various reflections and adjust their quality.
screen.SHADING_SCREEN=Shading
screen.SHADING_SCREEN.comment=Adjust various shading effects like ambient occlusion or celshading

117
shaders/shaders.properties Normal file
View File

@@ -0,0 +1,117 @@
#Global Settings
# The DH shadow pass is automatically enabled. It can be turned on or off with the shader property dhShadow.enabled.
# Distant Horizons has no set shadow distance; all chunks will be rendered.
dhShadow.enabled=false
# Enable or disable old hand light
# Backwards compatibility for shader packs not supporting main and off hand.
# When enabled uses the handheld item with higher light value for the main hand.
# The old hand light is also controlled by "Video Settings -> Shaders -> Old Hand Light" with higher priority
#oldHandLight=true|false
# Enable or disable old block lighting with fixed multiplier
# The old block lighting is also controlled by "Video Settings -> Shaders -> Old Lighting" with higher priority
# oldLighting=true|false
oldLighting=false
# Enable or disable rendering of translucent blocks (water, stained glass) in the shadow pass
# shadowTranslucent=true|false
shadowTranslucent=true
# Frustum culling
# Enable or disable frustum culling
frustum.culling=true
# Enable or disable the dynamic hand light from "Dynamic Lights"
# This option can be used to disable the dynamic hand light from "Dynamic Lights" if the shader implements its own hand light.
# dynamicHandLight=true|false
# Enable or disable underwater screen overlay
underwaterOverlay=false
# Enable or disable sun rendering
# sun=true|false
# Enable or disable moon rendering
# moon=true|false
# Disable the shadow progam if shadows or VL are disabled
program.shadow.enabled=Shadows || Volumetric_Lighting
#Final screen
screen=[AA_SCREEN] [BLOOM_SCREEN] [COLORS_SCREEN] [DOF_SCREEN] [FOG_SCREEN] [MB_SCREEN] [NORMALMAP_SCREEN] [REFLECTIONS_SCREEN] [SKY_SCREEN] [SHADOWS_SCREEN] [SHADING_SCREEN] [WAVING_SCREEN] [EMISSIVE_SCREEN] [Debug] MobsFlashRed Whiteworld
#Sub-screens:
screen.AA_SCREEN=TAA TAA_sharpness
screen.BLOOM_SCREEN=Bloom bloom_strength
screen.COLORS_SCREEN=Brightness Contrast [WATERC_SCREEN] [LIGHTINGC_SCREEN]
screen.WATERC_SCREEN=watertex wtexblend waterCR <empty> waterCG <empty> waterCB <empty> waterA
screen.LIGHTINGC_SCREEN=HandLight <empty> eyeLight <empty> light_brightness <empty> r_multiplier <empty> g_multiplier <empty> b_multiplier
screen.MB_SCREEN=Motionblur MB_strength
screen.DOF_SCREEN=Depth_of_Field DoF_Strength smoothDof <empty> Distance_Blur Dof_Distance_View
screen.SKY_SCREEN=Lens_Flares Lens_Flares_Strength Rain_Drops <empty> Godrays Godrays_Density Volumetric_Lighting VL_amount Clouds cloudsIT Cloudsblur cloud_height defskybox skyboxblendfactor customStars sunPathRotation Moonlight WeatherAngle
screen.SHADOWS_SCREEN=Shadows ColoredShadows Penumbra grass_shadows shadowMapResolution raytracedShadows shadowDistance shadow_samples Nearshadowplane Farshadowplane
screen.WAVING_SCREEN=animationSpeed <empty> Waving_Grass Waving_Tallgrass Waving_Entities Waving_Leaves Waving_Vines Waving_Fire Waving_Lanterns Waving_Lava Waving_Lilypads Waving_Water waves_amplitude
screen.NORMALMAP_SCREEN=nMap POM_RES <empty> POM_DEPTH <empty> POM_DIST WaterParallax waterheight
screen.FOG_SCREEN=Fog wFogDensity morningFog Underwater_Fog uFogDensity uwatertint
screen.EMISSIVE_SCREEN=minlight <empty> emissive_R <empty> emissive_G <empty> emissive_B
screen.REFLECTIONS_SCREEN=waterRefl Refraction Caustics causticsStrength iceRefl waveSize metallicRefl metalStrength polishedRefl metallicSky RainReflections rainNoise <empty> BiomeCheck Cloud_reflection cloudreflIT
screen.SHADING_SCREEN=SSDO ao_strength Celshading Celborder <empty> Celradius
screen.Debug=Showbuffer
#screen.Experimental=*
sliders=TAA_sharpness VL_amount ao_strength Celborder Celradius eyeLight emissive_R emissive_G emissive_B waterCR waterCG waterCB waterA light_brightness r_multiplier g_multiplier b_multiplier shadow_samples Nearshadowplane Farshadowplane shadowDistance Brightness Contrast DoF_Strength Dof_Distance_View wFogDensity uFogDensity POM_DIST POM_DEPTH minlight cloudsIT cloudreflIT cloud_height skyboxblendfactor sunPathRotation rainNoise waveSize causticsStrength AS_sharpening waves_amplitude wtexblend metalStrength metallicSky
# Setup for different colors per biome
uniform.float.inSwamp=smooth(1, if(in(biome, BIOME_SWAMP, BIOME_SWAMP_HILLS), 1, 0), 5)
# Rainy biomes
#uniform.bool.rainBiomes=in(biome, BIOME_PLAINS, BIOME_SUNFLOWER_PLAINS, BIOME_FOREST, BIOME_WOODED_HILLS, BIOME_FLOWER_FOREST, BIOME_BIRCH_FOREST, BIOME_BIRCH_FOREST_HILLS, BIOME_TALL_BIRCH_FOREST, BIOME_TALL_BIRCH_HILLS, BIOME_DARK_FOREST, BIOME_DARK_FOREST_HILLS, BIOME_SWAMP, BIOME_SWAMP_HILLS, BIOME_JUNGLE, BIOME_JUNGLE_HILLS, BIOME_MODIFIED_JUNGLE, BIOME_JUNGLE_EDGE, BIOME_MODIFIED_JUNGLE_EDGE, BIOME_RIVER, BIOME_BEACH, BIOME_MUSHROOM_FIELDS, BIOME_MUSHROOM_FIELD_SHORE, BIOME_OCEAN, BIOME_DEEP_OCEAN, BIOME_COLD_OCEAN, BIOME_DEEP_COLD_OCEAN, BIOME_WARM_OCEAN, BIOME_LUKEWARM_OCEAN, BIOME_DEEP_LUKEWARM_OCEAN)
# Rainy biomes below y = 90+ otherwise snowy, using cameraPosition.y to workaround this
#uniform.bool.coldBiomes=in(biome, BIOME_MOUNTAINS, BIOME_GRAVELLY_MOUNTAINS, BIOME_WOODED_MOUNTAINS, BIOME_MODIFIED_GRAVELLY_MOUNTAINS, BIOME_MOUNTAIN_EDGE, BIOME_TAIGA, BIOME_TAIGA_HILLS, BIOME_TAIGA_MOUNTAINS, BIOME_GIANT_TREE_TAIGA, BIOME_GIANT_TREE_TAIGA_HILLS, BIOME_GIANT_SPRUCE_TAIGA, BIOME_GIANT_SPRUCE_TAIGA_HILLS, BIOME_STONE_SHORE)
# Nether update 1.16+
#variable.bool.isBlueNether=in(biome, BIOME_SOUL_SAND_VALLEY)
#uniform.float.blueNether=smooth(1, if(isBlueNether, 1, 0), 5)
#uniform.bool.isBasaltNether=in(biome, BIOME_BASALT_DELTAS)
#uniform.float.basaltNether=smooth(1, if(isBasaltNether, 1, 0), 5)
#uniform.bool.isPurpleNether=in(biome, BIOME_WARPED_FOREST)
#uniform.float.purpleNether=smooth(1, if(isPurpleNether, 1, 0), 5)
# Biome temperature
uniform.float.BiomeTemp=temperature
# Used for TAA
#uniform.vec2.texelSize=vec2(1.0/viewWidth,1.0/viewHeight) Doesn't work on 1.7.10
uniform.int.framemod8=fmod(frameCounter, 8)
# Scale down the bloom buffer, it's faster than using texcoord for scaling, might break if you're in a dimension without shaders and return to one that supports shaders.
#scale.composite3=0.25
# Must be turned off so that we can store data in alpha channel without issues
blend.gbuffers_basic=off
blend.gbuffers_damagedblock=off
blend.gbuffers_clouds=off
alphaTest.gbuffers_basic=GREATER 0.1
alphaTest.gbuffers_damagedblock=GREATER 0.1
alphaTest.gbuffers_clouds=GREATER 0.1
# Fixes various issues with rain if we don't render it to its own buffer.
#rain.depth=true
# Shadowlight pos from Chocapic
#variable.float.normSunVec = sqrt(sunPosition.x*sunPosition.x+sunPosition.y*sunPosition.y+sunPosition.z*sunPosition.z)
#variable.float.normUpVec = sqrt(upPosition.x*upPosition.x+upPosition.y*upPosition.y+upPosition.z*upPosition.z)
#variable.float.sunPosX = sunPosition.x/normSunVec
#variable.float.sunPosY = sunPosition.y/normSunVec
#variable.float.sunPosZ = sunPosition.z/normSunVec
#variable.float.upPosX = upPosition.x/normUpVec
#variable.float.upPosY = upPosition.y/normUpVec
#variable.float.upPosZ = upPosition.z/normUpVec
#uniform.float.sunElevation = sunPosX*upPosX+sunPosY*upPosY+sunPosZ*upPosZ

222
shaders/shaders.settings Normal file
View File

@@ -0,0 +1,222 @@
/*
Sildur's Vibrant Shaders:
https://www.patreon.com/Sildur
https://sildurs-shaders.github.io/
https://twitter.com/SildurFX
Permissions:
You are not allowed to edit, copy code or share my shaderpack under a different name or claim it as yours.
*/
#ifdef composite0
#define ColoredShadows //Toggle colored shadows
#define Penumbra //Toggle penumbra soft shadows
//#define raytracedShadows //Improves closeup and faraway shadows. Also allows shadows to be cast outside of the shadowmap, outside of your shadows render distance. Requires shadows to be enabled. Has some issues since it's raytraced in screenspace.
const int VPS_samples = 8; //Used for penumbra shadows [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30]
#define shadow_samples 15 //Used for shadows in general [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30]
const bool shadowHardwareFiltering0 = true;
const bool shadowHardwareFiltering1 = true;
const float sunPathRotation = -40.0; //[-10.0 -20.0 -30.0 -40.0 -50.0 -60.0 -70.0 -80.0 0.0 10.0 20.0 30.0 40.0 50.0 60.0 70.0 80.0]
#define SSDO //Ambient Occlusion, makes lighting more realistic. High performance impact.
#define ao_strength 1.0 //[0.25 0.5 0.75 1.0 1.25 1.5 1.75 2.0 2.25 2.5 2.75 3.0 3.25 3.5 3.75 4.0]
#define Godrays
const int grays_sample = 23; //17=lite, 17=med, 20=high, 23=extreme
#ifndef DISTANT_HORIZONS
//#define Volumetric_Lighting //Disable godrays before enabling volumetric lighting.
#endif
//#define Lens_Flares
//#define Celshading //Cel shades everything, making it look somewhat like Borderlands. Zero performance impact.
#define Celborder 1.0 //[1.0 1.2 1.4 1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0]
#define Celradius 1.0 //[1.0 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0.075 0.05]
//#define Whiteworld //Makes the ground white, screenshot -> https://i.imgur.com/xziUB8O.png
#define Moonlight 0.003 //[0.0 0.0015 0.003 0.006 0.009]
//#define defskybox
#ifdef Penumbra
//required for optifine to parse it since it doesn't parse #if defined penumbra, nvidia, windows.
#endif
//Use the same color as water for water shading, diffuse
#define waterCR 0.0 //[0.0 0.1 0.125 0.15 0.175 0.2 0.225 0.25 0.275 0.3 0.325 0.35 0.375 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0]
#define waterCG 0.175 //[0.0 0.1 0.125 0.15 0.175 0.2 0.225 0.25 0.275 0.3 0.325 0.35 0.375 0.4 0.6 0.65 0.8 1.0 1.2 1.4 1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0]
#define waterCB 0.2 //[0.0 0.1 0.125 0.15 0.175 0.2 0.225 0.25 0.275 0.3 0.325 0.35 0.375 0.4 0.6 0.8 1.0 1.2 1.25 1.4 1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0]
#endif
#ifdef gbuffers_shadows
#define Shadows //Toggle all shadows
#define SHADOW_MAP_BIAS 0.80
#define grass_shadows //Also disables tallgrass and flowers shadows
#if defined Shadows || defined Volumetric_Lighting
const float shadowDistance = 110.0; //Render distance of shadows. 60=lite, 80=med, 80=high, 120=extreme [60.0 70.0 80.0 90.0 100.0 110.0 120.0 130.0 140.0 150.0 160.0 170.0 180.0 190.0 200.0 210.0 220.0 230.0 240.0 250.0 260.0 270.0 280.0 290.0 300.0 310.0 320.0 330.0 340.0 350.0 360.0 370.0 380.0 390.0 400.0]
const int shadowMapResolution = 3072; //Shadows resolution. [256 512 1024 2048 3072 4096 6144 8192 16384] 512=lite, 1024=med, 2048=high, 3072=extreme
const float k = 1.8;
#define Nearshadowplane 0.05 //[0.04 0.045 0.05 0.055 0.06 0.065 0.07 0.075 0.08 0.085 0.09 0.095 0.1] close quality, lower=higher quality, 0.09 is required for 2.0 farshadowmap to prevent glitches
#define Farshadowplane 0.8 //[0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0] far quality, streches the shadowmap, lower values closer, higher further away: 0.8=extreme, 1.0=high, 1.2=medium, 1.4=lite
float a = exp(Nearshadowplane);
float b = (exp(Farshadowplane)-a)*shadowDistance/128.0;
float calcDistortion(vec2 worldpos){
return 1.0/(log(length(worldpos)*b+a)*k);
}
#endif
#endif
#ifdef composite1
const int noiseTextureResolution = 128; //must be in composite1 for 2d clouds
#define Godrays
#define Godrays_Density 1.15 //[0.575 1.15 2.3 4.6 9.2]
//#define Lens_Flares
#ifndef DISTANT_HORIZONS
//#define Volumetric_Lighting //Disable godrays before enabling volumetric lighting.
#endif
#define VL_amount 1.0 //[0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0] Adjust volumetric lighting amount.
#define Fog //Toggle fog
#define wFogDensity 100.0 //adjust fog density [5.0 10.0 15.0 20.0 25.0 30.0 35.0 40.0 45.0 50.0 55.0 60.0 65.0 70.0 75.0 80.0 90.0 100.0 110.0 120.0 130.0 140.0 150.0 160.0 170.0 180.0 190.0 200.0 210.0 220.0 230.0 240.0 250.0 260.0 270.0 280.0 290.0 300.0]
//#define morningFog //Toggle dynamic fog during sunrise.
#define Underwater_Fog //Toggle underwater fog.
#define uFogDensity 25.0 //adjust underwater fog density [5.0 10.0 15.0 20.0 25.0 30.0 35.0 40.0 45.0 50.0 55.0 60.0 65.0 70.0 75.0 80.0 90.0 100.0 110.0 120.0 130.0 140.0 150.0 160.0 170.0 180.0 190.0 200.0]
#define uwatertint //Tints the underwater ground with blue color.
#define Clouds 3 //[0 1 2 3 4] Toggle clouds. 0=Off, 1=Default MC, 2=2D, 3=VL, 4=2D+VL, also adjust in gbuffers_cloud
#define cloudsIT 8 //[6 8 10 12 14 16 18 20 24 32 48] Volumetric clouds quality.
#define cloudreflIT 6 //[2 4 6 8 10 12 14 16] Reflected volumetric clouds quality.
#define Cloud_reflection //Toggle clouds reflection in water
#define cloud_height 256.0 //[64.0 80.0 96.0 112.0 128.0 144.0 160.0 176.0 192.0 208.0 224.0 240.0 256.0 272.0 288.0 304.0 320.0 336.0 352.0 368.0 384.0 400.0]
#define waterRefl //Toggle water reflections
#define iceRefl //Toggle stained glass and ice reflections
#define Refraction //Toggle water refractions.
#define Caustics //Toggle water caustics.
#define causticsStrength 0.8 //[0.1 0.15 0.2 0.25 0.30 0.35 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 0.95 1.0 1.05 1.10 1.15 1.20 1.25 1.3 1.35 1.4 1.45 1.5 1.55 1.6 1.65 1.75 1.8 1.85 1.9 1.95 2.0]
#define waveSize 1.0 //[0.25 0.5 0.75 1.0 1.25 1.5 1.75 2.0 2.25 2.5 2.75 3.0] Adjust water wave size, includes refraction and caustic size.
#define metallicRefl //Toggle reflections for metallic blocks defined in block.properties
//#define polishedRefl //Toggle reflections for polished blocks defined in block.properties
#define metalStrength 1.0 //[0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0] Metallic and polished reflection strength
#define metallicSky 0.1 //[0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0] Sky reflection strength
#define RainReflections //Toggle rain reflections, wetness
#define BiomeCheck //Toggle biome check for rain reflections. Only enable if no reflections are present. Updating optifine might resolve missing reflections with this on.
#define rainNoise 1.0 //[1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0] Higher values means less noise
#define customStars //Toggle custom stars.
//#define defskybox //Toggle support for the default skybox, including custom skies from resourcepacks. If no resourcepack is present this will only enable the default sun and moon texture. This option also auto disables the custom shader sun and moon.
#define skyboxblendfactor 0.75 //[0.0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 0.95 1.0] Adjust the blend factor of custom sky and default skybox
#ifdef Cloud_reflection
//required for optifine to parse it since it doesn't parse #if defined
#endif
#ifdef waterRefl
//required for optifine to parse it since it doesn't parse #if defined
#endif
#endif
#ifdef composite2
#define Bloom
#if MC_VERSION >= 11710
#define TAA //Toggle temporal anti-aliasing (TAA)
#endif
#define TAA_sharpness 0.65 //[0.0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 0.95 1.0 1.05 1.1 1.15 1.2 1.25 1.3 1.35 1.4 1.45 1.5] Adjust sharpening strength. 0.0 turns sharpening completly off.
#endif
#ifdef final
#define Bloom
#define bloom_strength 0.75 //Adjust bloom strength [0.5 0.75 1.0 2.0]
#define Rain_Drops //Enables rain drops on screen during raining. Requires sun effects to be enabled. Low performance impact.
#define Refraction
//#define Depth_of_Field //Simulates eye focusing on objects. Low performance impact
//#define Distance_Blur //Requires Depth of Field to be enabled. Replaces eye focusing effect with distance being blurred instead.
#define smoothDof //Toggle smooth transition between clear and blurry.
//#define Motionblur //Blurres your view/camera during movemenent. Low performance impact. Doesn't work with Depth of Field.
#define Cloudsblur //Blurres the sky abit, making volumetric clouds less noisy. Doesn't work with MB and DoF
//Defined values for Optifine
#define DoF_Strength 90 //[10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300]
#define Dof_Distance_View 256 //[128 256 384 512]
#define MB_strength 0.014 //[0.008 0.014 0.020]
#define Contrast 2.2 //Lower values increase contrast while higher values reduce conrast. If you adjust contrast make sure adjust brightness aswell. [1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0]
#define Brightness 1.0 //Adjust brightness. [0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0]
#define Showbuffer 0 //[0 1 2 25 3 35 4 5 6 7 8]
#endif
#ifdef gbuffers_skytextured
//#define defskybox
#endif
#ifdef gbuffers_terrain
#define nMap 0 //[0 1 2]0=Off 1=Bumpmapping, 2=Parallax
#define POM_RES 32 //Texture / Resourcepack resolution. [32 64 128 256 512 1024 2048]
#define POM_DIST 16.0 //[8.0 16.0 24.0 32.0 40.0 48.0 56.0 64.0 72.0 80.0 88.0 96.0 104.0 112.0 120.0 128.0]
#define POM_DEPTH 0.30 //[0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.0]
#define metallicRefl //Toggle reflections for blocks defined in block.properties
//#define polishedRefl //Toggle reflections for polished blocks defined in block.properties
#define Waving_Leaves
#define Waving_Vines
#define Waving_Grass //Does not include tallgrass due some issues with it.
#define Waving_Tallgrass
#define Waving_Fire
#define Waving_Lava
#define Waving_Lilypads
#define Waving_Lanterns
#define Waving_Entities //Includes: Saplings, small flowers, wheat, carrots, potatoes and beetroot.
#define animationSpeed 1.0 //[0.25 0.5 0.75 1.0 1.25 1.5 1.75 2.0]
#endif
#ifdef gbuffers_texturedblock //textured and block are mostly the same so lets use the same defines
#define MobsFlashRed
#endif
#ifdef gbuffers_water
#define Waving_Water
#define waves_amplitude 0.65 //[0.55 0.65 0.75 0.85 0.95 1.05 1.15 1.25 1.35 1.45 1.55 1.65 1.75 1.85 1.95 2.05]
#define waveSize 1.0 //[0.25 0.5 0.75 1.0 1.25 1.5 1.75 2.0 2.25 2.5 2.75 3.0] Adjust water wave size, includes refraction and caustic size.
//#define watertex
#define wtexblend 0.12 //[0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.20 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.30 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.40 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.50]
#define WaterParallax
#define waterheight 1.0 //[1.0 1.5 2.0] height for parallax mapping
#define waterCR 0.0 //[0.0 0.1 0.125 0.15 0.175 0.2 0.225 0.25 0.275 0.3 0.325 0.35 0.375 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0]
#define waterCG 0.175 //[0.0 0.1 0.125 0.15 0.175 0.2 0.225 0.25 0.275 0.3 0.325 0.35 0.375 0.4 0.6 0.65 0.8 1.0 1.2 1.4 1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0]
#define waterCB 0.2 //[0.0 0.1 0.125 0.15 0.175 0.2 0.225 0.25 0.275 0.3 0.325 0.35 0.375 0.4 0.6 0.8 1.0 1.2 1.25 1.4 1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0]
#define waterA 6.0 //[1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 7.0 8.0 9.0 10.0]
#define emissive_R 1.5 //[0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
#define emissive_G 0.42 //[0.0 0.1 0.2 0.3 0.42 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
#define emissive_B 0.045 //[0.0 0.045 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
#endif
#ifdef gbuffers_weather
//#define WeatherAngle //Toggle alternative weather angle
#endif
#ifdef lightingColors
#define HandLight //Toggle handheld lighting.
#define eyeLight 2.6 //Adjust the eye light adapation amount, doing so will increase or decrease lighting strength in general. Adjust bloom accordingly. [1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 6.0]
#define light_brightness 1.0 //[0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0]
#define emissive_R 1.5 //[0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
#define emissive_G 0.42 //[0.0 0.1 0.2 0.3 0.42 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
#define emissive_B 0.045 //[0.0 0.045 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0]
#define minlight 0.002 //Tweak the amount of minimal light inside caves etc. [0.001 0.002 0.003 0.004 0.005 0.006 0.007 0.008 0.009 0.010 0.011 0.012 0.013 0.014 0.015 0.016 0.017 0.018 0.019 0.020 0.021 0.022 0.023 0.024 0.025 0.026 0.027 0.028 0.029 0.030]
#define r_multiplier 0.0 //[0.0 0.25 0.5 0.75 1.0 1.25 1.5 1.75 2.0 2.25 2.5 2.75 3.0 3.25 3.5 3.75 4.0 4.25 4.5 4.75 5.0 5.25 5.5 5.75 6.0 6.25 6.5 6.75 7.0 7.25 7.5 7.75 8.0 8.25 8.5 8.75 9.0 9.25 9.5 9.75 10.0]
#define g_multiplier 0.0 //[0.0 0.25 0.5 0.75 1.0 1.25 1.5 1.75 2.0 2.25 2.5 2.75 3.0 3.25 3.5 3.75 4.0 4.25 4.5 4.75 5.0 5.25 5.5 5.75 6.0 6.25 6.5 6.75 7.0 7.25 7.5 7.75 8.0 8.25 8.5 8.75 9.0 9.25 9.5 9.75 10.0]
#define b_multiplier 0.0 //[0.0 0.25 0.5 0.75 1.0 1.25 1.5 1.75 2.0 2.25 2.5 2.75 3.0 3.25 3.5 3.75 4.0 4.25 4.5 4.75 5.0 5.25 5.5 5.75 6.0 6.25 6.5 6.75 7.0 7.25 7.5 7.75 8.0 8.25 8.5 8.75 9.0 9.25 9.5 9.75 10.0]
#endif

28
shaders/shadow.fsh Normal file
View File

@@ -0,0 +1,28 @@
#version 120
#define gbuffers_shadows
#define composite0
#include "shaders.settings"
#if defined Shadows || defined Volumetric_Lighting
varying vec4 texcoord;
uniform sampler2D texture;
uniform int blockEntityId;
uniform int entityId;
#endif
void main() {
#if defined Shadows || defined Volumetric_Lighting
vec4 color = texture2D(texture, texcoord.xy);
if(texcoord.z > 0.9)color.rgb = vec3(1.0, 1.0, 1.0); //water shadows color
if(texcoord.w > 0.9)color = vec4(0.0); //disable shadows on entities defined in vertex shadows
if(entityId == 11000.0)color *= 0.0; //remove lightning strike shadow.
#if MC_VERSION < 11601 //blockEntityId broken in 1.16.1, causes shadow issue, used to remove beam shadows, 10089 is the id of all emissive blocks but only beam is a block entity
if(blockEntityId == 10089.0) color *= 0.0;
#endif
gl_FragData[0] = color;
#else
gl_FragData[0] = vec4(0.0);
#endif
}

34
shaders/shadow.vsh Normal file
View File

@@ -0,0 +1,34 @@
#version 120
#define gbuffers_shadows
#define composite0
#include "shaders.settings"
#if defined Shadows || defined Volumetric_Lighting
varying vec4 texcoord;
attribute vec4 mc_Entity;
vec2 calcShadowDistortion(in vec2 shadowpos) {
float distortion = log(length(shadowpos.xy)*b+a)*k;
return shadowpos.xy / distortion;
}
#endif
void main() {
vec4 position = gl_ModelViewProjectionMatrix * gl_Vertex;
#if defined Shadows || defined Volumetric_Lighting
position.xy = calcShadowDistortion(position.xy);
position.z /= 6.0;
texcoord.xy = (gl_MultiTexCoord0).xy;
texcoord.z = 0.0;
texcoord.w = 0.0;
if(mc_Entity.x == 10008.0) texcoord.z = 1.0;
#ifndef grass_shadows
if(mc_Entity.x == 10031.0 || mc_Entity.x == 10059.0 || mc_Entity.x == 10175.0 || mc_Entity.x == 10176.0) texcoord.w = 1.0;
#endif
#endif
gl_Position = position;
}

View File

@@ -0,0 +1,286 @@
#version 120
/* DRAWBUFFERS:34 */
#define gbuffers_shadows
#define composite0
#define composite2
#define lightingColors
#include "/shaders.settings"
#ifdef HandLight
uniform int heldBlockLightValue;
uniform int heldBlockLightValue2;
#endif
varying vec2 texcoord;
varying vec3 sunVec;
varying vec3 upVec;
varying vec3 sunlight;
varying float tr;
varying float sunVisibility;
varying float moonVisibility;
uniform sampler2D depthtex0;
uniform sampler2D depthtex1;
uniform sampler2D colortex0;
uniform sampler2D colortex1;
uniform sampler2D colortex2;
uniform sampler2D composite;
uniform mat4 gbufferProjectionInverse;
uniform int isEyeInWater;
uniform float aspectRatio;
uniform float near;
uniform float far;
uniform float viewWidth;
uniform float viewHeight;
uniform float rainStrength;
uniform float nightVision;
uniform float screenBrightness;
float comp = 1.0-near/far/far; //distance above that are considered as sky
const vec2 check_offsets[25] = vec2[25](vec2(-0.4894566f,-0.3586783f),
vec2(-0.1717194f,0.6272162f),
vec2(-0.4709477f,-0.01774091f),
vec2(-0.9910634f,0.03831699f),
vec2(-0.2101292f,0.2034733f),
vec2(-0.7889516f,-0.5671548f),
vec2(-0.1037751f,-0.1583221f),
vec2(-0.5728408f,0.3416965f),
vec2(-0.1863332f,0.5697952f),
vec2(0.3561834f,0.007138769f),
vec2(0.2868255f,-0.5463203f),
vec2(-0.4640967f,-0.8804076f),
vec2(0.1969438f,0.6236954f),
vec2(0.6999109f,0.6357007f),
vec2(-0.3462536f,0.8966291f),
vec2(0.172607f,0.2832828f),
vec2(0.4149241f,0.8816f),
vec2(0.136898f,-0.9716249f),
vec2(-0.6272043f,0.6721309f),
vec2(-0.8974028f,0.4271871f),
vec2(0.5551881f,0.324069f),
vec2(0.9487136f,0.2605085f),
vec2(0.7140148f,-0.312601f),
vec2(0.0440252f,0.9363738f),
vec2(0.620311f,-0.6673451f)
);
vec3 decode (vec2 enc){
vec2 fenc = enc*4-2;
float f = dot(fenc,fenc);
float g = sqrt(1-f/4.0);
vec3 n;
n.xy = fenc*g;
n.z = 1-f/2;
return n;
}
vec3 YCoCg2RGB(vec3 c){
c.y-=0.5;
c.z-=0.5;
return vec3(c.r+c.g-c.b, c.r + c.b, c.r - c.g - c.b);
}
#ifdef Celshading
float edepth(vec2 coord) {
return texture2D(depthtex1,coord).x;
}
vec3 celshade(vec3 clrr) {
//edge detect
float dtresh = 1.0/(far-near) / (5000.0*Celradius);
vec4 dc = vec4(edepth(texcoord.xy));
vec3 border = vec3(1.0/viewWidth, 1.0/viewHeight, 0.0)*Celborder;
vec4 sa = vec4(edepth(texcoord.xy + vec2(-border.x,-border.y)),
edepth(texcoord.xy + vec2(border.x,-border.y)),
edepth(texcoord.xy + vec2(-border.x,border.z)),
edepth(texcoord.xy + vec2(border.z,border.y)));
//opposite side samples
vec4 sb = vec4(edepth(texcoord.xy + vec2(border.x,border.y)),
edepth(texcoord.xy + vec2(-border.x,border.y)),
edepth(texcoord.xy + vec2(border.x,border.z)),
edepth(texcoord.xy + vec2(border.z,-border.y)));
vec4 dd = abs(2.0* dc - sa - sb) - dtresh;
dd = step(dd.xyzw, vec4(0.0));
float e = clamp(dot(dd,vec4(0.25f)),0.0,1.0);
return clrr*e;
}
#endif
#ifdef TAA
vec2 texelSize = vec2(1.0/viewWidth,1.0/viewHeight);
uniform int framemod8;
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-1.,3.)/8.,
vec2(5.0,1.)/8.,
vec2(-3,-5.)/8.,
vec2(-5.,5.)/8.,
vec2(-7.,-1.)/8.,
vec2(3,7.)/8.,
vec2(7.,-7.)/8.);
#endif
vec3 toScreenSpace(vec3 p) {
vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw);
vec3 p3 = p * 2.0 - 1.0;
vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3];
return fragposition.xyz / fragposition.w;
}
#ifdef SSDO
uniform float frameTimeCounter;
//modified version of Yuriy O'Donnell's SSDO (License MIT -> https://github.com/kayru/dssdo)
float calcSSDO(vec3 fragpos, vec3 normal){
float finalAO = 0.0;
float radius = 0.05 / (fragpos.z);
const float attenuation_angle_threshold = 0.1;
const int num_samples = 16;
const float ao_weight = 1.0;
#ifdef TAA
float noise = fract(0.75487765 * gl_FragCoord.x + 0.56984026 * gl_FragCoord.y);
noise = fract(frameTimeCounter * 2.0 + noise);
#else
float noise = 1.0;
#endif
for( int i=0; i<num_samples; ++i ){
vec2 texOffset = pow(length(check_offsets[i].xy),0.5)*radius*vec2(1.0,aspectRatio)*normalize(check_offsets[i].xy);
vec2 newTC = texcoord+texOffset*noise;
#ifdef TAA
vec3 t0 = toScreenSpace(vec3(newTC-offsets[framemod8]*texelSize*0.5, texture2D(depthtex1, newTC).x));
#else
vec3 t0 = toScreenSpace(vec3(newTC, texture2D(depthtex1, newTC).x));
#endif
vec3 center_to_sample = t0.xyz - fragpos.xyz;
float dist = length(center_to_sample);
vec3 center_to_sample_normalized = center_to_sample / dist;
float attenuation = 1.0-clamp(dist/6.0,0.0,1.0);
float dp = dot(normal, center_to_sample_normalized);
attenuation = sqrt(max(dp,0.0))*attenuation*attenuation * step(attenuation_angle_threshold, dp);
finalAO += attenuation * (ao_weight / num_samples);
}
return finalAO;
}
#endif
uniform mat4 gbufferModelViewInverse;
void main() {
//Setup depth
float depth0 = texture2D(depthtex0, texcoord).x; //everything
float depth1 = texture2D(depthtex1, texcoord).x; //transparency
bool sky = (depth0 >= 1.0);
vec4 albedo = texture2D(colortex0,texcoord);
vec3 normal = decode(texture2D(colortex1, texcoord).xy);
vec2 lightmap = texture2D(colortex1, texcoord.xy).zw;
bool translucent = albedo.b > 0.69 && albedo.b < 0.71;
bool emissive = albedo.b > 0.59 && albedo.b < 0.61;
vec3 color = vec3(albedo.rg,0.0);
vec2 a0 = texture2D(colortex0,texcoord + vec2(1.0/viewWidth,0.0)).rg;
vec2 a1 = texture2D(colortex0,texcoord - vec2(1.0/viewWidth,0.0)).rg;
vec2 a2 = texture2D(colortex0,texcoord + vec2(0.0,1.0/viewHeight)).rg;
vec2 a3 = texture2D(colortex0,texcoord - vec2(0.0,1.0/viewHeight)).rg;
vec4 lumas = vec4(a0.x,a1.x,a2.x,a3.x);
vec4 chromas = vec4(a0.y,a1.y,a2.y,a3.y);
vec4 w = 1.0-step(0.1176, abs(lumas - color.x));
float W = dot(w,vec4(1.0));
w.x = (W==0.0)? 1.0:w.x; W = (W==0.0)? 1.0:W;
bool pattern = (mod(gl_FragCoord.x,2.0)==mod(gl_FragCoord.y,2.0));
color.b= dot(w,chromas)/W;
color.rgb = (pattern)?color.rbg:color.rgb;
color.rgb = YCoCg2RGB(color.rgb);
color = pow(color,vec3(2.2));
if (!sky){
//Water and Ice
vec3 wnormal = texture2D(colortex2,texcoord).xyz;
bool iswater = wnormal.z < 0.2499 && dot(wnormal,wnormal) > 0.0;
bool isice = wnormal.z > 0.2499 && wnormal.z < 0.4999 && dot(wnormal,wnormal) > 0.0;
bool isnsun = (iswater||isice) || ((!iswater||!isice) && isEyeInWater == 1);
/*--------------------------------------------------------------------------------------*/
#ifdef TAA
vec2 newTC = gl_FragCoord.xy*texelSize;
vec3 TAAfragpos = toScreenSpace(vec3(newTC-offsets[framemod8]*texelSize*0.5, texture2D(depthtex1, newTC).x));
#else
vec3 TAAfragpos = toScreenSpace(vec3(texcoord,depth1)); //was depth0 before, might cause issues
#endif
#ifdef Whiteworld
color += vec3(1.5);
#endif
#ifdef Celshading
color = celshade(color);
#endif
float ao = 1.0;
#ifdef SSDO
float occlusion = calcSSDO(TAAfragpos, normal);
if(!iswater)ao = pow(1.0-occlusion, ao_strength);
#endif
//Emissive blocks lighting and colors
#ifdef HandLight
bool underwaterlava = (isEyeInWater == 1.0 || isEyeInWater == 2.0);
if(!underwaterlava) lightmap.x = max(lightmap.x, max(max(float(heldBlockLightValue), float(heldBlockLightValue2)) - 1.0 - length(TAAfragpos), 0.0) / 15.0);
#endif
float torch_lightmap = 16.0-min(15.0,(lightmap.x-0.5/16.0)*16.0*16.0/15.0);
float fallof1 = clamp(1.0 - pow(torch_lightmap/16.0,4.0),0.0,1.0);
torch_lightmap = fallof1*fallof1/(torch_lightmap*torch_lightmap+1.0);
float c_emitted = dot((color.rgb),vec3(1.0,0.6,0.4))/2.0;
float emitted = emissive? clamp(c_emitted*c_emitted,0.0,1.0)*torch_lightmap : 0.0;
vec3 emissiveLightC = vec3(emissive_R,emissive_G,emissive_B);
/*------------------------------------------------------------------------------------------*/
//Lighting and colors
float NdotL = dot(normal,sunVec);
float NdotU = dot(normal,upVec);
const vec3 moonlight = vec3(0.5, 0.9, 1.8) * Moonlight;
vec2 visibility = vec2(sunVisibility,moonVisibility);
float skyL = max(lightmap.y-2./16.0,0.0)*1.14285714286;
float SkyL2 = skyL*skyL;
float skyc2 = mix(1.0,SkyL2,skyL);
vec4 bounced = vec4(NdotL,NdotL,NdotL,NdotU) * vec4(-0.14*skyL*skyL,0.33,0.7,0.1) + vec4(0.6,0.66,0.7,0.25);
bounced *= vec4(skyc2,skyc2,visibility.x-tr*visibility.x,0.8);
vec3 sun_ambient = bounced.w * (vec3(0.1, 0.5, 1.1)*2.4+rainStrength*2.3*vec3(0.05,-0.33,-0.9))+ 1.6*sunlight*(sqrt(bounced.w)*bounced.x*2.4 + bounced.z)*(1.0-rainStrength*0.99);
vec3 moon_ambient = (moonlight*0.7 + moonlight*bounced.y)*4.0;
vec3 amb1 = (sun_ambient*visibility.x + moon_ambient*visibility.y)*SkyL2*(0.03*0.65+tr*0.17*0.65);
float finalminlight = (nightVision > 0.01)? 0.15 : (minlight+0.025)+(screenBrightness*0.05); //add nightvision support but make sure minlight is still adjustable. Also scale with brightness slider
vec3 ambientC = ao*amb1 + emissiveLightC*(emitted*15.*color + torch_lightmap*ao)*0.66 + ao*finalminlight*min(skyL+6/16.,9/16.)*normalize(amb1+0.0001);
/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
color *= (ambientC*(isnsun?1.0/(SkyL2*skyL*0.5+0.5):1.0)*1.4)*0.63;
}
//Draw skytexture from gbuffers_skytextured
if (sky)color = pow(texture2D(composite, texcoord.xy).rgb,vec3(2.2));
gl_FragData[0] = vec4(0.0); //used by custom skycolor, godrays and VL not needed in end dimension
gl_FragData[1] = vec4(pow(color/257.0,vec3(0.454)), 1.0);
}

View File

@@ -0,0 +1,55 @@
#version 120
#define lightingColors
#include "/shaders.settings"
varying vec2 texcoord;
varying vec3 sunVec;
varying vec3 upVec;
varying vec3 sunlight;
varying float tr;
varying float sunVisibility;
varying float moonVisibility;
uniform vec3 sunPosition;
uniform vec3 upPosition;
uniform int worldTime;
const vec3 ToD[7] = vec3[7]( vec3(0.58597,0.16,0.005),
vec3(0.58597,0.31,0.08),
vec3(0.58597,0.45,0.16),
vec3(0.58597,0.5,0.35),
vec3(0.58597,0.5,0.36),
vec3(0.58597,0.5,0.37),
vec3(0.58597,0.5,0.38));
void main() {
//Position
gl_Position = ftransform();
texcoord = (gl_MultiTexCoord0).xy;
/*--------------------------------*/
//Sun/moon pos
sunVec = normalize(sunPosition);
upVec = vec3(0.0, 1.0, 0.0); //fix for loading shaderpacks in nether and end, optifine bug.
float SdotU = dot(sunVec,upVec);
sunVisibility = pow(clamp(SdotU+0.15,0.0,0.15)/0.15,4.0);
moonVisibility = pow(clamp(-SdotU+0.15,0.0,0.15)/0.15,4.0);
/*--------------------------------*/
//reduced the sun color to a 7 array
float hour = max(mod(worldTime/1000.0+2.0,24.0)-2.0,0.0); //-0.1
float cmpH = max(-abs(floor(hour)-6.0)+6.0,0.0); //12
float cmpH1 = max(-abs(floor(hour)-5.0)+6.0,0.0); //1
vec3 temp = ToD[int(cmpH)];
vec3 temp2 = ToD[int(cmpH1)];
sunlight = mix(temp,temp2,fract(hour));
sunlight.rgb += vec3(r_multiplier,g_multiplier,b_multiplier); //allows lighting colors to be tweaked.
sunlight.rgb *= light_brightness; //brightness needs to be adjusted if we tweak lighting colors.
vec2 trCalc = min(abs(worldTime-vec2(23000.0,12700.0)),750.0);
tr = max(min(trCalc.x,trCalc.y)/375.0-1.0,0.0);
}

View File

@@ -0,0 +1,296 @@
#version 120
#extension GL_ARB_shader_texture_lod : enable
const bool gaux1MipmapEnabled = true;
/* DRAWBUFFERS:3 */
#define composite2
#define composite1
#define lightingColors
#include "/shaders.settings"
varying vec2 texcoord;
uniform sampler2D gaux1;
uniform sampler2D depthtex0;
uniform sampler2D depthtex1;
uniform sampler2D colortex0;
uniform sampler2D colortex1;
uniform sampler2D colortex2;
uniform sampler2D gdepth;
uniform sampler2D noisetex;
uniform sampler2D gaux3;
uniform sampler2D gaux2;
uniform vec3 cameraPosition;
uniform mat4 gbufferProjection;
uniform mat4 gbufferProjectionInverse;
uniform mat4 gbufferModelViewInverse;
uniform float screenBrightness;
uniform int isEyeInWater;
uniform float near;
uniform float far;
uniform float frameTimeCounter;
uniform float blindness;
uniform vec3 fogColor;
#if MC_VERSION >= 11900
uniform float darknessFactor;
uniform float darknessLightFactor;
#endif
/*------------------------------------------*/
float comp = 1.0-near/far/far;
#if defined waterRefl || defined iceRefl
const int maxf = 3; //number of refinements
const float ref = 0.11; //refinement multiplier
const float inc = 3.0; //increasement factor at each step
vec3 nvec3(vec4 pos) {
return pos.xyz/pos.w;
}
vec4 nvec4(vec3 pos) {
return vec4(pos.xyz, 1.0);
}
float cdist(vec2 coord) {
return max(abs(coord.s-0.5),abs(coord.t-0.5))*2.0;
}
vec4 raytrace(vec3 fragpos, vec3 skycolor, vec3 rvector) {
vec4 color = vec4(0.0);
vec3 start = fragpos;
rvector *= 1.2;
fragpos += rvector;
vec3 tvector = rvector;
int sr = 0;
for(int i=0;i<25;i++){
vec3 pos = nvec3(gbufferProjection * nvec4(fragpos)) * 0.5 + 0.5;
if(pos.x < 0 || pos.x > 1 || pos.y < 0 || pos.y > 1 || pos.z < 0 || pos.z > 1.0) break;
vec3 fragpos0 = vec3(pos.st, texture2D(depthtex1, pos.st).r);
fragpos0 = nvec3(gbufferProjectionInverse * nvec4(fragpos0 * 2.0 - 1.0));
float err = distance(fragpos,fragpos0);
if(err < pow(length(rvector),1.175)){ //if(err < pow(length(rvector)*1.85,1.15)){ <- old, adjusted error check to reduce banding issues/glitches
sr++;
if(sr >= maxf){
bool land = texture2D(depthtex1, pos.st).r < comp;
color = pow(texture2DLod(gaux1, pos.st, 1),vec4(2.2))*257.0;
if (isEyeInWater == 0) color.rgb = land ? mix(color.rgb,skycolor,0.5) : skycolor; //reflections color, blend it with fake sky color.
color.a = clamp(1.0 - pow(cdist(pos.st), 20.0), 0.0, 1.0);
break;
}
tvector -= rvector;
rvector *= ref;
}
rvector *= inc;
tvector += rvector;
fragpos = start + tvector;
}
return color;
}
#endif
#ifdef Refraction
mat2 rmatrix(float rad){
return mat2(vec2(cos(rad), -sin(rad)), vec2(sin(rad), cos(rad)));
}
float calcWaves(vec2 coord){
vec2 movement = abs(vec2(0.0, -frameTimeCounter * 0.5));
coord *= 0.4;
vec2 coord0 = coord * rmatrix(1.0) - movement * 4.5;
coord0.y *= 3.0;
vec2 coord1 = coord * rmatrix(0.5) - movement * 1.5;
coord1.y *= 3.0;
vec2 coord2 = coord * frameTimeCounter * 0.02;
coord0 *= waveSize;
coord1 *= (waveSize-0.5); //create an offset for smaller waves
float wave = texture2D(noisetex,coord0 * 0.005).x * 10.0; //big waves
wave -= texture2D(noisetex,coord1 * 0.010416).x * 7.0; //small waves
wave += 1.0-sqrt(texture2D(noisetex,coord2 * 0.0416).x * 6.5) * 1.33; //noise texture
wave *= 0.0157;
return wave;
}
vec2 calcBump(vec2 coord){
const vec2 deltaPos = vec2(0.25, 0.0);
float h0 = calcWaves(coord);
float h1 = calcWaves(coord + deltaPos.xy);
float h2 = calcWaves(coord - deltaPos.xy);
float h3 = calcWaves(coord + deltaPos.yx);
float h4 = calcWaves(coord - deltaPos.yx);
float xDelta = ((h1-h0)+(h0-h2));
float yDelta = ((h3-h0)+(h0-h4));
return vec2(xDelta,yDelta)*0.05;
}
#endif
vec3 decode (vec2 enc){
vec2 fenc = enc*4-2;
float f = dot(fenc,fenc);
float g = sqrt(1-f/4.0);
vec3 n;
n.xy = fenc*g;
n.z = 1-f/2;
return n;
}
void main() {
vec3 c = pow(texture2D(gaux1,texcoord).xyz,vec3(2.2))*257.;
//Depth and fragpos
float depth0 = texture2D(depthtex0, texcoord).x;
vec4 fragpos0 = gbufferProjectionInverse * (vec4(texcoord, depth0, 1.0) * 2.0 - 1.0);
fragpos0 /= fragpos0.w;
vec3 normalfragpos0 = normalize(fragpos0.xyz);
float depth1 = texture2D(depthtex1, texcoord).x;
vec4 fragpos1 = gbufferProjectionInverse * (vec4(texcoord, depth1, 1.0) * 2.0 - 1.0);
fragpos1 /= fragpos1.w;
vec3 normalfragpos1 = normalize(fragpos1.xyz);
/*--------------------------------------------------------------------------------------------*/
vec4 trp = texture2D(gaux3,texcoord.xy);
bool transparency = dot(trp.xyz,trp.xyz) > 0.000001;
#if MC_VERSION >= 11600
if (depth1 > comp){
c.rgb = fogColor*0.02; //use default MC fogcolor for sky aswell
}
vec3 fogC = fogColor*0.5;
#else
if (depth1 > comp){
c.r = 0.002+(screenBrightness*0.001); //draw nether sky, keep it similar to fog color, scale with brightness
}
vec3 fogC = vec3(0.05, 0.0, 0.0);
#endif
#ifdef Refraction
if (texture2D(colortex2, texcoord).z < 0.2499 && dot(texture2D(colortex2,texcoord).xyz,texture2D(colortex2,texcoord).xyz) > 0.0 || isEyeInWater == 1.0) { //reflective water
vec2 wpos = (gbufferModelViewInverse*fragpos0).xz+cameraPosition.xz;
vec2 refraction = texcoord.xy + calcBump(wpos);
c = pow(texture2D(gaux1, refraction).xyz, vec3(2.2))*257.0;
}
#endif
//Render before transparency
float mats = texture2D(colortex0,texcoord).b;
bool isMetallic = mats > 0.39 && mats < 0.41;
bool isPolished = mats > 0.49 && mats < 0.51;
#ifndef polishedRefl
isPolished = false;
#endif
#ifndef metallicRefl
isMetallic = false;
#endif
#if defined metallicRefl || defined polishedRefl
if (isMetallic || isPolished) {
vec3 relfNormal = decode(texture2D(colortex1,texcoord).xy);
vec3 reflectedVector = reflect(normalfragpos0, relfNormal);
float normalDotEye = dot(relfNormal, normalfragpos0);
float fresnel = pow(clamp(1.0 + normalDotEye,0.0,1.0), 4.0);
fresnel = mix(0.09,1.0,fresnel); //F0
vec3 sky_c = fogC*metallicSky;
vec4 reflection = raytrace(fragpos0.xyz, sky_c, reflectedVector);
reflection.rgb = mix(sky_c, reflection.rgb, reflection.a)*0.5;
c = mix(c,reflection.rgb,fresnel*metalStrength);
}
#endif
if (transparency) {
vec3 normal = texture2D(colortex2,texcoord).xyz;
float sky = normal.z;
bool reflectiveWater = sky < 0.2499 && dot(normal,normal) > 0.0;
bool reflectiveIce = sky > 0.2499 && sky < 0.4999 && dot(normal,normal) > 0.0;
bool iswater = sky < 0.2499;
bool isice = sky > 0.2499 && sky < 0.4999;
if (iswater) sky *= 4.0;
if (isice) sky = (sky - 0.25)*4.0;
if (!iswater && !isice) sky = (sky - 0.5)*4.0;
sky = clamp(sky*1.2-2./16.0*1.2,0.,1.0);
sky *= sky;
normal = decode(normal.xy);
normal = normalize(normal);
//draw fog for transparency
c = mix(c, fogC*0.04, 1.0-exp(-length(fragpos1.xyz)*0.0005));
if(depth1 < comp)c = mix(fogC*0.04, c, exp(-exp2(length(fragpos1.xyz) / far * 16.0 - 14.0)));
//Draw transparency
vec3 finalAc = texture2D(gaux2, texcoord.xy).rgb;
float alphaT = clamp(length(trp.rgb)*1.02,0.0,1.0);
c = mix(c,c*(trp.rgb*0.9999+0.0001)*1.732,alphaT)*(1.0-alphaT) + finalAc;
//Reflections
float iswater2 = float(iswater);
if (reflectiveWater || reflectiveIce) {
vec3 reflectedVector = reflect(normalfragpos1, normal);
vec3 hV= normalize(reflectedVector - normalfragpos1);
float normalDotEye = dot(hV, normalfragpos1);
float F0 = 0.09;
float fresnel = pow(clamp(1.0 + normalDotEye,0.0,1.0), 4.0) ;
fresnel = fresnel+F0*(1.0-fresnel);
vec3 sky_c = fogC*0.2; //Use fogC as our custom sky reflections
#if defined waterRefl || defined iceRefl
vec4 reflection = raytrace(fragpos0.xyz, sky_c, reflectedVector);
#else
vec4 reflection = vec4(0.0);
fresnel *= 0.5;
#endif
reflection.rgb = mix(sky_c, reflection.rgb, reflection.a)*0.5;
#ifdef iceRefl
fresnel *= 0.5*float(isice) + 0.5*iswater2;
#else
fresnel *= 1.0*iswater2;
#endif
c = mix(c,reflection.rgb,fresnel*1.5);
}
}
#ifdef Fog
if(depth0 < comp)c = mix(c, fogC*(1.0-isEyeInWater), 1.0-exp(-length(fragpos0.xyz)*0.0005));
//Chunk border fog
if(depth0 < comp)c = mix(fogC*0.04, c, exp(-exp2(length(fragpos0.xyz) / far * 16.0 - 14.0)));
#endif
#ifdef Underwater_Fog
vec3 ufogC = vec3(0.0, 0.005, 0.0125);
if (isEyeInWater == 1.0) c = mix(c, ufogC, 1.0-exp(-length(fragpos0.xyz)/uFogDensity));
#endif
if (isEyeInWater == 2.0) c = mix(c, vec3(1.0, 0.0125, 0.0), 1.0-exp(-length(fragpos0.xyz))); //lava fog
if(blindness > 0.9) c = mix(c, vec3(0.0), 1.0-exp(-length(fragpos1.xyz)*1.125)); //blindness fog
#if MC_VERSION >= 11900
if(darknessFactor > 0.9) c = mix(c, vec3(0.0), 1.0-exp(-length(fragpos1.xyz)*0.2)) * (1.0-darknessLightFactor*2.0); //Darkness fog, adjust for nether.
#endif
c *= 0.142;
gl_FragData[0] = vec4(c,1.0);
}

View File

@@ -0,0 +1,8 @@
#version 120
varying vec2 texcoord;
void main() {
gl_Position = ftransform();
texcoord = (gl_MultiTexCoord0).xy;
}

View File

@@ -0,0 +1,146 @@
#version 120
/* DRAWBUFFERS:7 */
/* Temporal anti-aliasing (TAA) and adaptive sharpening implementation based on Chocapic13, all credits belong to him:
https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/minecraft-mods/1293898-1-14-chocapic13s-shaders */
#define composite2
#include "/shaders.settings"
varying vec2 texcoord;
uniform sampler2D composite; //everything from composite1
#ifdef TAA
const bool gaux4Clear = false;
uniform sampler2D gaux4; //composite, TAA mixed with everything
uniform sampler2D depthtex0;
/*
uniform sampler2D gcolor;
uniform sampler2D gnormal;
uniform float near;
uniform float far;
*/
uniform float viewWidth;
uniform float viewHeight;
vec2 texelSize = vec2(1.0/viewWidth,1.0/viewHeight);
uniform mat4 gbufferProjectionInverse;
uniform mat4 gbufferModelViewInverse;
uniform mat4 gbufferPreviousProjection;
uniform mat4 gbufferPreviousModelView;
uniform vec3 cameraPosition;
uniform vec3 previousCameraPosition;
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz)
vec3 toClipSpace3Prev(vec3 viewSpacePosition) {
return projMAD(gbufferPreviousProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5;
}
vec3 toScreenSpace(vec3 p) {
vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw);
vec3 p3 = p * 2.0 - 1.0;
vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3];
return fragposition.xyz / fragposition.w;
}
//approximation from SMAA presentation from siggraph 2016
vec3 FastCatmulRom(sampler2D colorTex, vec2 texcoord, vec4 rtMetrics, float sharpenAmount){
vec2 position = rtMetrics.zw * texcoord;
vec2 centerPosition = floor(position - 0.5) + 0.5;
vec2 f = position - centerPosition;
vec2 f2 = f * f;
vec2 f3 = f * f2;
float c = sharpenAmount;
vec2 w0 = -c * f3 + 2.0 * c * f2 - c * f;
vec2 w1 = (2.0 - c) * f3 - (3.0 - c) * f2 + 1.0;
vec2 w2 = -(2.0 - c) * f3 + (3.0 - 2.0 * c) * f2 + c * f;
vec2 w3 = c * f3 - c * f2;
vec2 w12 = w1 + w2;
vec2 tc12 = rtMetrics.xy * (centerPosition + w2 / w12);
vec3 centerColor = texture2D(colorTex, vec2(tc12.x, tc12.y)).rgb;
vec2 tc0 = rtMetrics.xy * (centerPosition - 1.0);
vec2 tc3 = rtMetrics.xy * (centerPosition + 2.0);
vec4 color = vec4(texture2D(colorTex, vec2(tc12.x, tc0.y )).rgb, 1.0) * (w12.x * w0.y ) +
vec4(texture2D(colorTex, vec2(tc0.x, tc12.y)).rgb, 1.0) * (w0.x * w12.y) +
vec4(centerColor, 1.0) * (w12.x * w12.y) +
vec4(texture2D(colorTex, vec2(tc3.x, tc12.y)).rgb, 1.0) * (w3.x * w12.y) +
vec4(texture2D(colorTex, vec2(tc12.x, tc3.y )).rgb, 1.0) * (w12.x * w3.y );
return color.rgb/color.a;
}
vec3 calcTAA(){
//reproject previous frame
float depth0 = texture2D(depthtex0,texcoord).x;
vec3 closestToCamera = vec3(texcoord,depth0);
vec3 fragposition = toScreenSpace(closestToCamera);
fragposition = mat3(gbufferModelViewInverse) * fragposition + gbufferModelViewInverse[3].xyz + (cameraPosition - previousCameraPosition);
vec3 previousPosition = mat3(gbufferPreviousModelView) * fragposition + gbufferPreviousModelView[3].xyz;
previousPosition = toClipSpace3Prev(previousPosition);
previousPosition.xy = texcoord + (previousPosition.xy - closestToCamera.xy);
//to reduce error propagation caused by interpolation during history resampling, we will introduce back some aliasing in motion
vec2 d = 0.5-abs(fract(previousPosition.xy*vec2(viewWidth,viewHeight)-texcoord*vec2(viewWidth,viewHeight))-0.5);
float rej = dot(d,d)*0.5;
//reject history if off-screen and early exit
if (previousPosition.x < 0.0 || previousPosition.y < 0.0 || previousPosition.x > 1.0 || previousPosition.y > 1.0) return texture2D(composite, texcoord).rgb;
//Samples current frame 3x3 neighboorhood
vec3 albedoCurrent0 = texture2D(composite, texcoord).rgb;
vec3 albedoCurrent1 = texture2D(composite, texcoord + vec2(texelSize.x,texelSize.y)).rgb;
vec3 albedoCurrent2 = texture2D(composite, texcoord + vec2(texelSize.x,-texelSize.y)).rgb;
vec3 albedoCurrent3 = texture2D(composite, texcoord + vec2(-texelSize.x,-texelSize.y)).rgb;
vec3 albedoCurrent4 = texture2D(composite, texcoord + vec2(-texelSize.x,texelSize.y)).rgb;
vec3 albedoCurrent5 = texture2D(composite, texcoord + vec2(0.0,texelSize.y)).rgb;
vec3 albedoCurrent6 = texture2D(composite, texcoord + vec2(0.0,-texelSize.y)).rgb;
vec3 albedoCurrent7 = texture2D(composite, texcoord + vec2(-texelSize.x,0.0)).rgb;
vec3 albedoCurrent8 = texture2D(composite, texcoord + vec2(texelSize.x,0.0)).rgb;
/* - TODO
float getmat = texture2D(gcolor,texcoord).b;
bool emissive = getmat > 0.59 && getmat < 0.61;
vec3 normal = texture2D(gnormal,texcoord).xyz;
bool iswater = normal.z < 0.2499 && dot(normal,normal) > 0.0;
if(!iswater && !emissive && depth0 < 1.0-near/far/far){ //don't sharpen emissive blocks, water and sky, clouds
vec3 m1 = (albedoCurrent0 + albedoCurrent1 + albedoCurrent2 + albedoCurrent3 + albedoCurrent4 + albedoCurrent5 + albedoCurrent6 + albedoCurrent7 + albedoCurrent8)/9.0;
vec3 std = abs(albedoCurrent0 - m1) + abs(albedoCurrent1 - m1) + abs(albedoCurrent2 - m1) + abs(albedoCurrent3 - m1) + abs(albedoCurrent3 - m1) +
abs(albedoCurrent4 - m1) + abs(albedoCurrent5 - m1) + abs(albedoCurrent6 - m1) + abs(albedoCurrent7 - m1) + abs(albedoCurrent8 - m1);
float contrast = 1.0 - dot(std,vec3(0.299, 0.587, 0.114))/9.0;
albedoCurrent0 = albedoCurrent0*(1.0+AS_sharpening*contrast)-(albedoCurrent5+albedoCurrent6+albedoCurrent7+albedoCurrent8+(albedoCurrent1 + albedoCurrent2 + albedoCurrent3 + albedoCurrent4)/2.0)/6.0*AS_sharpening*contrast;
}
*/
//Assuming the history color is a blend of the 3x3 neighborhood, we clamp the history to the min and max of each channel in the 3x3 neighborhood
vec3 cMax = max(max(max(albedoCurrent0,albedoCurrent1),albedoCurrent2),max(albedoCurrent3,max(albedoCurrent4,max(albedoCurrent5,max(albedoCurrent6,max(albedoCurrent7,albedoCurrent8))))));
vec3 cMin = min(min(min(albedoCurrent0,albedoCurrent1),albedoCurrent2),min(albedoCurrent3,min(albedoCurrent4,min(albedoCurrent5,min(albedoCurrent6,min(albedoCurrent7,albedoCurrent8))))));
vec3 albedoPrev = FastCatmulRom(gaux4, previousPosition.xy,vec4(texelSize, 1.0/texelSize), 0.82).xyz;
vec3 finalcAcc = clamp(albedoPrev,cMin,cMax);
//increases blending factor if history is far away from aabb, reduces ghosting at the cost of some flickering
float luma = dot(albedoPrev,vec3(0.21, 0.72, 0.07));
float isclamped = distance(albedoPrev,finalcAcc)/luma;
//reduces blending factor if current texel is far from history, reduces flickering
float lumDiff2 = distance(albedoPrev,albedoCurrent0)/luma;
lumDiff2 = 1.0-clamp(lumDiff2*lumDiff2,0.0,1.0)*0.75;
//Blend current pixel with clamped history
return mix(finalcAcc,albedoCurrent0,clamp(0.1*lumDiff2+rej+isclamped+0.01,0.0,1.0));
}
#endif
void main() {
#ifdef TAA
gl_FragData[0] = vec4(calcTAA(), 1.0);
#else
gl_FragData[0] = texture2D(composite, texcoord); //if TAA is disabled just passthrough data from composite0, previous buffer.
#endif
}

View File

@@ -0,0 +1,8 @@
#version 120
varying vec2 texcoord;
void main() {
gl_Position = ftransform();
texcoord = gl_MultiTexCoord0.xy;
}

View File

@@ -0,0 +1,42 @@
#version 120
/* DRAWBUFFERS:6 */
//overwrite buffer 6, final image is buffer 7
//This buffer is scaled down, defined in shaders.properties, it's faster than texcoord scaling
#define Bloom
#define composite3
#include "/shaders.settings"
#ifdef Bloom
varying vec2 texcoord;
uniform sampler2D colortex7; //read buffer 7, TAA+everything
uniform float viewWidth;
uniform float viewHeight;
const bool colortex7MipmapEnabled = true;
#endif
void main() {
#ifdef Bloom
const int nSteps = 25;
const int center = 12; //=nSteps-1 / 2
vec3 blur = vec3(0.0);
float tw = 0.0;
for (int i = 0; i < nSteps; i++) {
float dist = abs(i-float(center))/center;
float weight = (exp(-(dist*dist)/ 0.28));
vec3 bsample = texture2D(colortex7,(texcoord*4.0 + 2.0*vec2(1.0/viewWidth,1.0/viewHeight)*vec2(i-center,0.0))).rgb;
blur += bsample*weight;
tw += weight;
}
blur /= tw;
blur = clamp(blur,0.0,1.0); //fix flashing black square
gl_FragData[0] = vec4(blur, 1.0);
#else
gl_FragData[0] = vec4(0.0);
#endif
}

View File

@@ -0,0 +1,8 @@
#version 120
varying vec2 texcoord;
void main() {
gl_Position = ftransform();
texcoord = gl_MultiTexCoord0.xy;
}

View File

@@ -0,0 +1,50 @@
#version 120
/* DRAWBUFFERS:6 */
//overwrite buffer 6, final image is buffer 7
#define Bloom
#define bloom_strength 0.75
#define composite4
#include "/shaders.settings"
#ifdef Bloom
varying vec2 texcoord;
varying float eyeAdapt;
uniform sampler2D colortex6;
uniform int isEyeInWater;
uniform float rainStrength;
uniform float viewWidth;
uniform float viewHeight;
#endif
void main() {
#ifdef Bloom
const int nSteps = 17;
const int center = 8; //=nSteps-1 / 2
//huge gaussian blur for glare
vec3 blur = vec3(0.0);
float tw = 0.0;
for (int i = 0; i < nSteps; i++) {
float dist = abs(i-float(center))/center;
float weight = (exp(-(dist*dist)/ 0.28));
vec3 bsample = texture2D(colortex6,(texcoord.xy + vec2(1.0/viewWidth,1.0/viewHeight)*vec2(0.0,i-center))).rgb*3.0;
blur += bsample*weight;
tw += weight;
}
blur /= tw;
vec3 glow = blur * bloom_strength;
vec3 overglow = glow*pow(length(glow)*2.0,2.8)*2.0;
vec3 finalColor = (overglow+glow*1.15)*(1+isEyeInWater*10.0+(pow(rainStrength,3.0)*7.0/pow(eyeAdapt,1.0)))*1.2;
gl_FragData[0] = vec4(finalColor, 1.0);
#else
gl_FragData[0] = vec4(0.0);
#endif
}

View File

@@ -0,0 +1,77 @@
#version 120
#define Bloom
#define composite3 //it's composite4 but we don't need the extra define so use 3 instead
#include "/shaders.settings"
#ifdef Bloom
varying vec2 texcoord;
varying float eyeAdapt;
uniform vec3 sunPosition;
uniform vec3 upPosition;
uniform ivec2 eyeBrightnessSmooth;
uniform int worldTime;
uniform float rainStrength;
uniform float frameTimeCounter;
const vec3 ToD[7] = vec3[7]( vec3(0.58597,0.16,0.025),
vec3(0.58597,0.4,0.2),
vec3(0.58597,0.52344,0.24680),
vec3(0.58597,0.55422,0.34),
vec3(0.58597,0.57954,0.38),
vec3(0.58597,0.58,0.40),
vec3(0.58597,0.58,0.40));
float luma(vec3 color) {
return dot(color,vec3(0.299, 0.587, 0.114));
}
#endif
void main() {
gl_Position = ftransform();
#ifdef Bloom
texcoord = (gl_MultiTexCoord0).xy;
//Sun/Moon position
vec3 sunVec = normalize(sunPosition);
vec3 upVec = vec3(0.0, 1.0, 0.0); //fix for loading shaderpacks in nether and end, optifine bug.
float SdotU = dot(sunVec,upVec);
float sunVisibility = pow(clamp(SdotU+0.15,0.0,0.15)/0.15,4.0);
float moonVisibility = pow(clamp(-SdotU+0.15,0.0,0.15)/0.15,4.0);
/*--------------------------------*/
//reduced the sun color to a 7 array
float hour = max(mod(worldTime/1000.0+2.0,24.0)-2.0,0.0); //-0.1
float cmpH = max(-abs(floor(hour)-6.0)+6.0,0.0); //12
float cmpH1 = max(-abs(floor(hour)-5.0)+6.0,0.0); //1
vec3 temp = ToD[int(cmpH)];
vec3 temp2 = ToD[int(cmpH1)];
vec3 sunlight = mix(temp,temp2,fract(hour));
/*--------------------------------*/
//Lighting
float eyebright = max(eyeBrightnessSmooth.y/255.0-0.5/16.0,0.0)*1.03225806452;
float SkyL2 = mix(1.0,eyebright*eyebright,eyebright);
vec2 trCalc = min(abs(worldTime-vec2(23250.0,12700.0)),750.0);
float tr = max(min(trCalc.x,trCalc.y)/375.0-1.0,0.0);
vec4 bounced = vec4(0.5*SkyL2,0.66*SkyL2,0.7,0.3);
vec3 sun_ambient = bounced.w * (vec3(0.25,0.62,1.32)-rainStrength*vec3(0.11,0.32,1.07)) + sunlight*(bounced.x + bounced.z);
const vec3 moonlight = vec3(0.0035, 0.0063, 0.0098);
vec3 avgAmbient =(sun_ambient*sunVisibility + moonlight*moonVisibility)*eyebright*eyebright*(0.05+tr*0.15)*4.7+0.0006;
eyeAdapt = log(clamp(luma(avgAmbient),0.007,80.0))/log(2.6)*0.35;
eyeAdapt = 1.0/pow(2.6,eyeAdapt)*1.75;
#endif
}

279
shaders/world-1/final.fsh Normal file
View File

@@ -0,0 +1,279 @@
#version 120
#define final
#include "/shaders.settings"
varying vec2 texcoord;
uniform sampler2D gaux4; //final image
#ifdef Bloom
uniform sampler2D colortex6; //overwritten by bloom
#endif
#if Showbuffer > 0
uniform sampler2D colortex0;
uniform sampler2D colortex1;
uniform sampler2D colortex2;
uniform sampler2D colortex3;
uniform sampler2D gaux1;
uniform sampler2D gaux2;
uniform sampler2D gaux3;
#endif
uniform int isEyeInWater;
uniform float aspectRatio;
uniform float viewWidth;
uniform float viewHeight;
uniform float rainStrength;
uniform float frameTimeCounter;
#if defined Depth_of_Field || defined Motionblur
uniform sampler2D depthtex0;
uniform sampler2D depthtex1;
uniform sampler2D depthtex2;
#endif
#ifdef Motionblur
uniform vec3 cameraPosition;
uniform vec3 previousCameraPosition;
uniform mat4 gbufferProjection;
uniform mat4 gbufferProjectionInverse;
uniform mat4 gbufferPreviousProjection;
uniform mat4 gbufferModelViewInverse;
uniform mat4 gbufferPreviousModelView;
#endif
#if defined Depth_of_Field
uniform float near;
uniform float far;
float ld(float depth) {
return (2.0 * near) / (far + near - depth * (far - near));
}
#endif
#ifdef Depth_of_Field
//Dof constant values
const float focal = 0.024;
float aperture = 0.008;
const float sizemult = DoF_Strength;
uniform float centerDepthSmooth;
const float centerDepthHalflife = 2.0f;
//hexagon pattern
const vec2 hex_offsets[60] = vec2[60] ( vec2( 0.2165, 0.1250 ),
vec2( 0.0000, 0.2500 ),
vec2( -0.2165, 0.1250 ),
vec2( -0.2165, -0.1250 ),
vec2( -0.0000, -0.2500 ),
vec2( 0.2165, -0.1250 ),
vec2( 0.4330, 0.2500 ),
vec2( 0.0000, 0.5000 ),
vec2( -0.4330, 0.2500 ),
vec2( -0.4330, -0.2500 ),
vec2( -0.0000, -0.5000 ),
vec2( 0.4330, -0.2500 ),
vec2( 0.6495, 0.3750 ),
vec2( 0.0000, 0.7500 ),
vec2( -0.6495, 0.3750 ),
vec2( -0.6495, -0.3750 ),
vec2( -0.0000, -0.7500 ),
vec2( 0.6495, -0.3750 ),
vec2( 0.8660, 0.5000 ),
vec2( 0.0000, 1.0000 ),
vec2( -0.8660, 0.5000 ),
vec2( -0.8660, -0.5000 ),
vec2( -0.0000, -1.0000 ),
vec2( 0.8660, -0.5000 ),
vec2( 0.2163, 0.3754 ),
vec2( -0.2170, 0.3750 ),
vec2( -0.4333, -0.0004 ),
vec2( -0.2163, -0.3754 ),
vec2( 0.2170, -0.3750 ),
vec2( 0.4333, 0.0004 ),
vec2( 0.4328, 0.5004 ),
vec2( -0.2170, 0.6250 ),
vec2( -0.6498, 0.1246 ),
vec2( -0.4328, -0.5004 ),
vec2( 0.2170, -0.6250 ),
vec2( 0.6498, -0.1246 ),
vec2( 0.6493, 0.6254 ),
vec2( -0.2170, 0.8750 ),
vec2( -0.8663, 0.2496 ),
vec2( -0.6493, -0.6254 ),
vec2( 0.2170, -0.8750 ),
vec2( 0.8663, -0.2496 ),
vec2( 0.2160, 0.6259 ),
vec2( -0.4340, 0.5000 ),
vec2( -0.6500, -0.1259 ),
vec2( -0.2160, -0.6259 ),
vec2( 0.4340, -0.5000 ),
vec2( 0.6500, 0.1259 ),
vec2( 0.4325, 0.7509 ),
vec2( -0.4340, 0.7500 ),
vec2( -0.8665, -0.0009 ),
vec2( -0.4325, -0.7509 ),
vec2( 0.4340, -0.7500 ),
vec2( 0.8665, 0.0009 ),
vec2( 0.2158, 0.8763 ),
vec2( -0.6510, 0.6250 ),
vec2( -0.8668, -0.2513 ),
vec2( -0.2158, -0.8763 ),
vec2( 0.6510, -0.6250 ),
vec2( 0.8668, 0.2513 ));
#endif
vec3 Uncharted2Tonemap(vec3 x) {
x*= Brightness;
float A = 0.28;
float B = 0.29;
float C = 0.10;
float D = 0.2;
float E = 0.025;
float F = 0.35;
return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;
}
#if Showbuffer == 1 || Showbuffer == 2 || Showbuffer == 3
vec3 decode (vec2 enc){
vec2 fenc = enc*4-2;
float f = dot(fenc,fenc);
float g = sqrt(1-f/4.0);
vec3 n;
n.xy = fenc*g;
n.z = 1-f/2;
return n;
}
vec3 YCoCg2RGB(vec3 c){
c.y-=0.5;
c.z-=0.5;
return vec3(c.r+c.g-c.b, c.r + c.b, c.r - c.g - c.b);
}
#endif
void main() {
#if defined Depth_of_Field || defined Motionblur
//Setup depths, do it here because amd drivers suck and texture reads outside of void main or functions are broken, thanks amd
float depth0 = texture2D(depthtex0, texcoord).x;
float depth1 = texture2D(depthtex1, texcoord).x;
float depth2 = texture2D(depthtex2, texcoord).x;
bool hand = (depth0 < depth1) || !(depth0 < depth2);
#endif
float rainlens = 0.0;
vec2 fake_refract = vec2(0.0);
#ifdef Refraction
fake_refract = vec2(sin(frameTimeCounter + texcoord.x*100.0 + texcoord.y*50.0),cos(frameTimeCounter + texcoord.y*100.0 + texcoord.x*50.0));
#endif
vec2 newTC = clamp(texcoord + fake_refract * 0.01 * (rainlens+isEyeInWater*0.2),1.0/vec2(viewWidth,viewHeight),1.0-1.0/vec2(viewWidth,viewHeight));
vec3 color = texture2D(gaux4, newTC.xy).rgb*50.0;
#ifdef Depth_of_Field
if(hand){
float pw = 1.0/ viewWidth;
float z = ld(texture2D(depthtex0, newTC.st).r)*far;
#ifdef smoothDof
float focus = ld(centerDepthSmooth)*far;
#else
float focus = ld(texture2D(depthtex0, vec2(0.5)).r)*far;
#endif
float pcoc = min(abs(aperture * (focal * (z - focus)) / (z * (focus - focal)))*sizemult,pw*15.0);
#ifdef Distance_Blur
float getdist = 1-(exp(-pow(ld(texture2D(depthtex1, newTC.st).r)/Dof_Distance_View*far,4.0-(2.7*rainStrength))*4.0));
pcoc = min(getdist*pw*20.0,pw*20.0);
#endif
vec3 bcolor = vec3(0.0);
for ( int i = 0; i < 60; i++) {
bcolor += texture2D(gaux4, newTC.xy + hex_offsets[i]*pcoc*vec2(1.0,aspectRatio)).rgb;
}
color.rgb = bcolor/61.0*50.0;
}
#endif
#ifdef Motionblur
if(hand){
vec4 currentPosition = vec4(texcoord, depth1, 1.0)*2.0-1.0;
vec4 fragposition = gbufferProjectionInverse * currentPosition;
fragposition = gbufferModelViewInverse * fragposition;
fragposition /= fragposition.w;
fragposition.xyz += cameraPosition;
vec4 previousPosition = fragposition;
previousPosition.xyz -= previousCameraPosition;
previousPosition = gbufferPreviousModelView * previousPosition;
previousPosition = gbufferPreviousProjection * previousPosition;
previousPosition /= previousPosition.w;
vec2 velocity = (currentPosition - previousPosition).st * MB_strength;
vec2 coord = texcoord.st + velocity;
int mb = 1;
for (int i = 0; i < 15; ++i, coord += velocity) {
if (coord.s > 1.0 || coord.t > 1.0 || coord.s < 0.0 || coord.t < 0.0) break;
color += texture2D(gaux4, coord).xyz*50.0;
++mb;
}
color /= mb;
}
#endif
#ifdef Bloom
color.rgb += texture2D(colortex6, texcoord.xy*0.25).rgb; //upscale bloom buffer.
#endif
color.rgb += rainlens*0.01; //draw rainlens
vec3 curr = Uncharted2Tonemap(color*4.7);
color = pow(curr/Uncharted2Tonemap(vec3(15.2)),vec3(1.0/Contrast));
#if Showbuffer == 1
color = vec3(texture2D(colortex0,texcoord).rg,0.0);
vec2 a0 = texture2D(colortex0,texcoord + vec2(1.0/viewWidth,0.0)).rg;
vec2 a1 = texture2D(colortex0,texcoord - vec2(1.0/viewWidth,0.0)).rg;
vec2 a2 = texture2D(colortex0,texcoord + vec2(0.0,1.0/viewHeight)).rg;
vec2 a3 = texture2D(colortex0,texcoord - vec2(0.0,1.0/viewHeight)).rg;
vec4 lumas = vec4(a0.x,a1.x,a2.x,a3.x);
vec4 chromas = vec4(a0.y,a1.y,a2.y,a3.y);
vec4 w = 1.0-step(0.1176, abs(lumas - color.x));
float W = dot(w,vec4(1.0));
w.x = (W==0.0)? 1.0:w.x; W = (W==0.0)? 1.0:W;
bool pattern = (mod(gl_FragCoord.x,2.0)==mod(gl_FragCoord.y,2.0));
color.b= dot(w,chromas)/W;
color.rgb = (pattern)?color.rbg:color.rgb;
color.rgb = YCoCg2RGB(color.rgb);
color = pow(color,vec3(2.2));
#endif
#if Showbuffer == 2
color = decode(texture2D(colortex1, texcoord).xy);
#endif
#if Showbuffer == 25
color = vec3(0.0, texture2D(colortex1, texcoord.xy).zw); //lightmap
#endif
#if Showbuffer == 3
color = decode(texture2D(colortex2, texcoord).xy);
#endif
#if Showbuffer == 35
color = vec3(0.0, texture2D(colortex2, texcoord.xy).zw); //lightmap
#endif
#if Showbuffer == 4
color = texture2D(colortex3, texcoord.xy).rgb * 200.0;
#endif
#if Showbuffer == 5
color = texture2D(gaux1, texcoord.xy).rgb * 25.0;
#endif
#if Showbuffer == 6
color = texture2D(gaux2, texcoord.xy).rgb * 25.0;
#endif
#if Showbuffer == 7
color = texture2D(gaux3, texcoord.xy*0.25).rgb * 25.0;
#endif
#if Showbuffer == 8
color = texture2D(gaux4, texcoord.xy).rgb * 50.0;
#endif
gl_FragColor = vec4(color,1.0);
}

View File

@@ -0,0 +1,8 @@
#version 120
varying vec2 texcoord;
void main() {
gl_Position = ftransform();
texcoord = (gl_MultiTexCoord0).xy;
}

View File

@@ -0,0 +1,28 @@
#version 120
/* DRAWBUFFERS:5 */
uniform sampler2D texture;
varying vec4 color;
varying vec2 texcoord;
uniform int worldTime;
uniform ivec2 eyeBrightnessSmooth;
uniform float rainStrength;
float night = clamp((worldTime-13000.0)/300.0,0.0,1.0)-clamp((worldTime-22800.0)/200.0,0.0,1.0);
float cavelight = pow(eyeBrightnessSmooth.y / 255.0, 6.0f) * 1.0 + (0.7 + 0.5*night);
void main() {
vec4 albedo = texture2D(texture, texcoord.st)*color;
//Fix minecrafts way of handling enchanted effects and turn it into a somewhat consistent effect across day/night/cave/raining
vec3 lighting = vec3(1.0+ (0.4*rainStrength - 0.4*rainStrength*night));
lighting /= 0.8 - 0.5*night;
lighting /= cavelight;
albedo.rgb = pow(albedo.rgb*0.33, lighting);
gl_FragData[0] = albedo;
}

View File

@@ -0,0 +1,37 @@
#version 120
varying vec4 color;
varying vec2 texcoord;
uniform mat4 gbufferModelView;
uniform mat4 gbufferModelViewInverse;
#define composite2
#include "/shaders.settings"
#ifdef TAA
uniform float viewWidth;
uniform float viewHeight;
vec2 texelSize = vec2(1.0/viewWidth,1.0/viewHeight);
uniform int framemod8;
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-1.,3.)/8.,
vec2(5.0,1.)/8.,
vec2(-3,-5.)/8.,
vec2(-5.,5.)/8.,
vec2(-7.,-1.)/8.,
vec2(3,7.)/8.,
vec2(7.,-7.)/8.);
#endif
void main() {
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
#ifdef TAA
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
#endif
color = gl_Color;
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).st;
}

View File

@@ -0,0 +1,30 @@
#version 120
/* DRAWBUFFERS:0 */ //01 breaks selection box color but fixes leads
varying vec4 color;
varying vec4 texcoord;
varying vec3 normal;
uniform sampler2D texture;
//encode normal in two channel (xy),torch and material(z) and sky lightmap (w)
vec4 encode (vec3 n){
float p = sqrt(n.z*8+8);
return vec4(n.xy/p + 0.5,texcoord.z,texcoord.w);
}
vec3 RGB2YCoCg(vec3 c){
return vec3( 0.25*c.r+0.5*c.g+0.25*c.b, 0.5*c.r-0.5*c.b +0.5, -0.25*c.r+0.5*c.g-0.25*c.b +0.5);
}
void main() {
vec4 cAlbedo = vec4(RGB2YCoCg(color.rgb),color.a);
bool pattern = (mod(gl_FragCoord.x,2.0)==mod(gl_FragCoord.y,2.0));
cAlbedo.g = (pattern)?cAlbedo.b: cAlbedo.g;
cAlbedo.b = 1.0;
gl_FragData[0] = cAlbedo;
gl_FragData[1] = encode(normal.xyz);
}

View File

@@ -0,0 +1,17 @@
#version 120
varying vec4 color;
varying vec4 texcoord;
varying vec3 normal;
void main() {
gl_Position = ftransform();
color = gl_Color;
texcoord = vec4((gl_MultiTexCoord0).xy,(gl_TextureMatrix[1] * gl_MultiTexCoord1).xy);
normal = normalize(gl_NormalMatrix * gl_Normal);
gl_FogFragCoord = gl_Position.z;
}

View File

@@ -0,0 +1,26 @@
#version 120
/* DRAWBUFFERS:56 */
//Render hand, entities and particles in here, boost and fix enchanted armor effect in gbuffers_armor_glint
#define gbuffers_texturedblock
#include "/shaders.settings"
varying vec4 color;
varying vec2 texcoord;
varying vec3 ambientNdotL;
uniform sampler2D texture;
uniform vec4 entityColor;
void main() {
vec4 albedo = texture2D(texture, texcoord.xy)*color;
#ifdef MobsFlashRed
albedo.rgb = mix(albedo.rgb,entityColor.rgb,entityColor.a);
#endif
vec3 finalColor = pow(albedo.rgb,vec3(2.2)) * ambientNdotL.rgb;
gl_FragData[0] = vec4(finalColor, albedo.a);
gl_FragData[1] = vec4(normalize(albedo.rgb+0.00001), albedo.a);
}

View File

@@ -0,0 +1,105 @@
#version 120
#define composite2
#define gbuffers_texturedblock
#define lightingColors
#include "/shaders.settings"
varying vec4 color;
varying vec2 texcoord;
varying vec3 ambientNdotL;
uniform vec3 sunPosition;
uniform vec3 upPosition;
uniform int worldTime;
uniform float rainStrength;
uniform float nightVision;
uniform float screenBrightness;
const vec3 ToD[7] = vec3[7]( vec3(0.58597,0.15,0.02),
vec3(0.58597,0.35,0.09),
vec3(0.58597,0.5,0.26),
vec3(0.58597,0.5,0.35),
vec3(0.58597,0.5,0.36),
vec3(0.58597,0.5,0.37),
vec3(0.58597,0.5,0.38));
#ifdef TAA
uniform float viewWidth;
uniform float viewHeight;
vec2 texelSize = vec2(1.0/viewWidth,1.0/viewHeight);
uniform int framemod8;
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-1.,3.)/8.,
vec2(5.0,1.)/8.,
vec2(-3,-5.)/8.,
vec2(-5.,5.)/8.,
vec2(-7.,-1.)/8.,
vec2(3,7.)/8.,
vec2(7.,-7.)/8.);
#endif
void main() {
//setup basics
color = gl_Color;
gl_Position = ftransform();
#ifdef TAA
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
#endif
vec3 normal = normalize(gl_NormalMatrix * gl_Normal);
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
vec2 lmcoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
/*--------------------------------*/
//Emissive blocks lighting in order to fix lighting on particles
float torch_lightmap = 16.0-min(15.,(lmcoord.s-0.5/16.)*16.*16./15);
float fallof1 = clamp(1.0 - pow(torch_lightmap/16.0,4.0),0.0,1.0);
torch_lightmap = fallof1*fallof1/(torch_lightmap*torch_lightmap+1.0);
vec3 emissiveLightC = vec3(emissive_R,emissive_G,emissive_B)*torch_lightmap;
float finalminlight = (nightVision > 0.01)? 0.025 : ((minlight+0.015)+(screenBrightness*0.025))*0.15;
/*---------------------------------------------------------------------*/
//reduced the sun color to a 7 array
float hour = max(mod(worldTime/1000.0+2.0,24.0)-2.0,0.0); //-0.1
float cmpH = max(-abs(floor(hour)-6.0)+6.0,0.0); //12
float cmpH1 = max(-abs(floor(hour)-5.0)+6.0,0.0); //1
vec3 temp = ToD[int(cmpH)];
vec3 temp2 = ToD[int(cmpH1)];
vec3 sunlight = mix(temp,temp2,fract(hour));
const vec3 rainC = vec3(0.01,0.01,0.01);
sunlight = mix(sunlight,rainC*sunlight,rainStrength);
/*-------------------------------------------------------------------*/
const vec3 moonlight = vec3(0.0024, 0.00432, 0.0078);
vec3 sunVec = normalize(sunPosition);
vec3 upVec = vec3(0.0, 1.0, 0.0); //fix for loading shaderpacks in nether and end, optifine bug.
vec2 visibility = vec2(dot(sunVec,upVec),dot(-sunVec,upVec));
float NdotL = dot(normal,sunVec);
float NdotU = dot(normal,upVec);
vec2 trCalc = min(abs(worldTime-vec2(23250.0,12700.0)),750.0);
float tr = max(min(trCalc.x,trCalc.y)/375.0-1.0,0.0);
visibility = pow(clamp(visibility+0.15,0.0,0.15)/0.15,vec2(4.0));
float skyL = max(lmcoord.t-2./16.0,0.0)*1.14285714286;
float SkyL2 = skyL*skyL;
float skyc2 = mix(1.0,SkyL2,skyL);
vec4 bounced = vec4(NdotL,NdotL,NdotL,NdotU) * vec4(-0.14*skyL*skyL,0.34,0.7,0.1) + vec4(0.6,0.66,0.7,0.25);
bounced *= vec4(skyc2,skyc2,visibility.x-tr*visibility.x,0.8);
vec3 sun_ambient = bounced.w * (vec3(0.1, 0.5, 1.1)+rainStrength*vec3(0.05,-0.27,-0.8))*2.3+ 1.7*sunlight*(sqrt(bounced.w)*bounced.x*2.4 + bounced.z)*(1.0-rainStrength*0.98);
vec3 moon_ambient = (moonlight*0.7 + moonlight*bounced.y)*(1.0-rainStrength*0.95)*2.0;
vec3 amb1 = (sun_ambient*visibility.x + moon_ambient*visibility.y)*SkyL2*(0.03+tr*0.17)*0.65;
ambientNdotL.rgb = amb1 + emissiveLightC + finalminlight;
sunlight = mix(sunlight,moonlight*(1.0-rainStrength*0.9),visibility.y)*tr;
}

View File

@@ -0,0 +1,5 @@
#version 120
void main() {
discard;
}

View File

@@ -0,0 +1,5 @@
#version 120
void main() {
gl_Position = ftransform();
}

View File

@@ -0,0 +1,5 @@
#version 120
void main() {
gl_FragData[0] = vec4(0.0, 0.0, 0.0, 1.0); //fill with zeros to avoid issues, alpha has to be set to 1.0 to fix an optifine issue in 1.17+ causing the sky to be black at certain angles.
}

View File

@@ -0,0 +1,5 @@
#version 120
void main() {
gl_Position = ftransform();
}

View File

@@ -0,0 +1,6 @@
#version 120
/* DRAWBUFFERS:0 */
void main() {
gl_FragData[0] = vec4(0.0);
}

View File

@@ -0,0 +1,7 @@
#version 120
void main() {
gl_Position = ftransform();
}

View File

@@ -0,0 +1,20 @@
#version 120
/* DRAWBUFFERS:56 */
#define gbuffers_texturedblock
#include "/shaders.settings"
varying vec4 color;
varying vec2 texcoord;
varying vec3 ambientNdotL;
uniform sampler2D texture;
void main() {
vec4 albedo = texture2D(texture, texcoord.xy)*color;
vec3 finalColor = pow(albedo.rgb,vec3(2.2)) * ambientNdotL.rgb;
gl_FragData[0] = vec4(finalColor, albedo.a);
gl_FragData[1] = vec4(normalize(albedo.rgb+0.00001), albedo.a);
}

View File

@@ -0,0 +1,64 @@
#version 120
#define composite2
#define gbuffers_texturedblock
#define lightingColors
#include "/shaders.settings"
varying vec4 color;
varying vec2 texcoord;
varying vec3 ambientNdotL;
uniform vec3 sunPosition;
uniform vec3 upPosition;
uniform int worldTime;
uniform float rainStrength;
uniform float nightVision;
const vec3 ToD[7] = vec3[7]( vec3(0.58597,0.15,0.02),
vec3(0.58597,0.35,0.09),
vec3(0.58597,0.5,0.26),
vec3(0.58597,0.5,0.35),
vec3(0.58597,0.5,0.36),
vec3(0.58597,0.5,0.37),
vec3(0.58597,0.5,0.38));
#ifdef TAA
uniform float viewWidth;
uniform float viewHeight;
vec2 texelSize = vec2(1.0/viewWidth,1.0/viewHeight);
uniform int framemod8;
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-1.,3.)/8.,
vec2(5.0,1.)/8.,
vec2(-3,-5.)/8.,
vec2(-5.,5.)/8.,
vec2(-7.,-1.)/8.,
vec2(3,7.)/8.,
vec2(7.,-7.)/8.);
#endif
void main() {
//setup basics
color = gl_Color;
gl_Position = ftransform();
#ifdef TAA
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
#endif
vec3 normal = normalize(gl_NormalMatrix * gl_Normal);
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
vec2 lmcoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
/*--------------------------------*/
//Emissive blocks lighting
float torch_lightmap = 16.0-min(15.,(lmcoord.s-0.5/16.)*16.*16./15);
float fallof1 = clamp(1.0 - pow(torch_lightmap/16.0,4.0),0.0,1.0);
torch_lightmap = fallof1*fallof1/(torch_lightmap*torch_lightmap+1.0);
//vec3 emissiveLightC = vec3(emissive_R,emissive_G,emissive_B)*torch_lightmap;
vec3 emissiveLightC = vec3(0.5, 0.0, 1.0); //purple eyes
float finalminlight = (nightVision > 0.01)? 0.025 : (minlight+0.025)*4.0; //multiply to improve eye rendering
ambientNdotL.rgb = emissiveLightC + finalminlight;
}

View File

@@ -0,0 +1,134 @@
#version 120
#extension GL_ARB_shader_texture_lod : enable //This extension must always be enabled to prevent issues with amd linux drivers
/* DRAWBUFFERS:01 */
#define gbuffers_terrain
#include "/shaders.settings"
/* Don't remove me
const int colortex0Format = RGBA16;
const int colortex1Format = RGBA16;
const int colortex2Format = RGBA16; //Entities etc
const int colortex3Format = R11F_G11F_B10F;
const int gaux1Format = RGBA16;
const int gaux2Format = R11F_G11F_B10F;
const int gaux3Format = R11F_G11F_B10F;
const int gaux4Format = R11F_G11F_B10F;
-----------------------------------------*/
varying vec4 color;
varying vec4 texcoord;
varying vec4 normal;
varying vec3 worldpos;
varying vec3 viewVector;
varying mat3 tbnMatrix;
uniform sampler2D texture;
uniform sampler2D noisetex;
//encode normal in two channel (xy),torch and material(z) and sky lightmap (w)
vec4 encode (vec3 n){
return vec4(n.xy*inversesqrt(n.z*8.0+8.0) + 0.5, texcoord.zw);
}
vec3 RGB2YCoCg(vec3 c){
return vec3( 0.25*c.r+0.5*c.g+0.25*c.b, 0.5*c.r-0.5*c.b +0.5, -0.25*c.r+0.5*c.g-0.25*c.b +0.5);
}
vec3 newnormal = normal.xyz;
#if nMap >= 1
varying float block;
bool isblock = block > 0.0 || block < 0.0; //workaround for 1.16 bugs on block entities
uniform sampler2D normals;
varying float dist;
varying vec4 vtexcoordam; // .st for add, .pq for mul
varying vec2 vtexcoord;
mat2 mipmap = mat2(dFdx(vtexcoord.xy*vtexcoordam.pq), dFdy(vtexcoord.xy*vtexcoordam.pq));
vec4 readNormal(in vec2 coord){
return texture2DGradARB(normals,fract(coord)*vtexcoordam.pq+vtexcoordam.st,mipmap[0],mipmap[1]);
}
vec4 calcPOM(vec4 albedo){
vec2 newCoord = vtexcoord.xy*vtexcoordam.pq+vtexcoordam.st;
#if nMap == 2
if (dist < POM_DIST && viewVector.z < 0.0 && readNormal(vtexcoord.xy).a < 1.0){
const float res_stepths = 0.33 * POM_RES;
vec2 pstepth = viewVector.xy * POM_DEPTH / (-viewVector.z * POM_RES);
vec2 coord = vtexcoord.xy;
for (int i= 0; i < res_stepths && (readNormal(coord.xy).a < 1.0-float(i)/POM_RES); ++i) coord += pstepth;
newCoord = fract(coord.xy)*vtexcoordam.pq+vtexcoordam.st;
}
#endif
//vec4 specularity = texture2DGradARB(specular, newCoord, dcdx, dcdy);
vec3 bumpMapping = texture2DGradARB(normals, newCoord, mipmap[0],mipmap[1]).rgb*2.0-1.0;
newnormal = normalize(bumpMapping * tbnMatrix);
return albedo = texture2DGradARB(texture, newCoord, mipmap[0],mipmap[1])*color;
}
#endif
#if defined metallicRefl || defined polishedRefl
float calcNoise(vec2 coord){
return sqrt(texture2D(noisetex, vec2(coord.x*1.25, coord.y*1.95)).x) * 0.45;
}
vec3 calcBump(vec2 coord){
const vec2 deltaPos = vec2(0.25, 0.0);
float h0 = calcNoise(coord);
float h1 = calcNoise(coord + deltaPos.xy);
float h2 = calcNoise(coord - deltaPos.xy);
float h3 = calcNoise(coord + deltaPos.yx);
float h4 = calcNoise(coord - deltaPos.yx);
float xDelta = ((h1-h0)+(h0-h2));
float yDelta = ((h3-h0)+(h0-h4));
return vec3(vec2(xDelta,yDelta)*0.2, 0.8); //z = 1.0-0.5
}
vec3 calcParallax(vec3 pos){
float getnoise = calcNoise(pos.xz);
float height = 1.0;
pos.xz += (getnoise * viewVector.xy) * height;
return pos;
}
#endif
void main() {
vec4 albedo = texture2D(texture, texcoord.xy)*color;
#if nMap >= 1
if(isblock)albedo = calcPOM(albedo);
#endif
#if defined metallicRefl || defined polishedRefl
bool isMetallic = normal.a > 0.39 && normal.a < 0.41;
bool isPolished = normal.a > 0.49 && normal.a < 0.51;
#ifndef polishedRefl
isPolished = false;
#endif
#ifndef metallicRefl
isMetallic = false;
#endif
if(isMetallic || isPolished){
vec3 bumpPos = worldpos;
bumpPos = calcParallax(bumpPos);
vec3 bump = calcBump(bumpPos.xy);
newnormal = normalize(bump * tbnMatrix);
}
#endif
vec4 cAlbedo = vec4(RGB2YCoCg(albedo.rgb),albedo.a);
bool pattern = (mod(gl_FragCoord.x,2.0)==mod(gl_FragCoord.y,2.0));
cAlbedo.g = (pattern)?cAlbedo.b: cAlbedo.g;
cAlbedo.b = normal.a;
gl_FragData[0] = cAlbedo;
gl_FragData[1] = encode(newnormal.xyz);
}

View File

@@ -0,0 +1,266 @@
#version 120
#define composite2
#define gbuffers_terrain
#include "/shaders.settings"
//Moving entities IDs
//See block.properties for mapped ids
#define ENTITY_SMALLGRASS 10031.0
#define ENTITY_LOWERGRASS 10175.0 //lower half only in 1.13+
#define ENTITY_UPPERGRASS 10176.0 //upper half only used in 1.13+
#define ENTITY_SMALLENTS 10059.0
#define ENTITY_LEAVES 10018.0
#define ENTITY_VINES 10106.0
#define ENTITY_LILYPAD 10111.0
#define ENTITY_FIRE 10051.0
#define ENTITY_LAVA 10010.0
#define ENTITY_EMISSIVE 10089.0 //emissive blocks defined in block.properties
#define ENITIY_SOULFIRE 10091.0
#define METALLIC_BLOCK 10080.0 //defined in block.properties
#define POLISHED_BLOCK 10081.0
#define ENTITY_INVERTED_LOWER 10177.0 //hanging_roots
varying vec4 color;
varying vec4 texcoord;
varying vec4 normal;
varying vec3 worldpos;
attribute vec4 mc_Entity;
attribute vec4 mc_midTexCoord;
uniform vec3 cameraPosition;
uniform mat4 gbufferModelView;
uniform mat4 gbufferModelViewInverse;
uniform float frameTimeCounter;
const float PI = 3.1415927;
const float PI48 = 150.796447372;
float pi2wt = (PI48*frameTimeCounter) * animationSpeed;
#if nMap >= 1 || defined metallicRefl || defined polishedRefl
attribute vec4 at_tangent; //xyz = tangent vector, w = handedness, added in 1.7.10
varying float block;
varying float dist;
varying vec3 viewVector;
varying mat3 tbnMatrix;
varying vec4 vtexcoordam; // .st for add, .pq for mul
varying vec2 vtexcoord;
#endif
vec3 calcWave(in vec3 pos, in float fm, in float mm, in float ma, in float f0, in float f1, in float f2, in float f3, in float f4, in float f5) {
vec3 ret;
float magnitude,d0,d1,d2,d3;
magnitude = sin(pi2wt*fm + pos.x*0.5 + pos.z*0.5 + pos.y*0.5) * mm + ma;
d0 = sin(pi2wt*f0);
d1 = sin(pi2wt*f1);
d2 = sin(pi2wt*f2);
ret.x = sin(pi2wt*f3 + d0 + d1 - pos.x + pos.z + pos.y) * magnitude;
ret.z = sin(pi2wt*f4 + d1 + d2 + pos.x - pos.z + pos.y) * magnitude;
ret.y = sin(pi2wt*f5 + d2 + d0 + pos.z + pos.y - pos.y) * magnitude;
return ret;
}
vec3 calcMove(in vec3 pos, in float f0, in float f1, in float f2, in float f3, in float f4, in float f5, in vec3 amp1, in vec3 amp2) {
vec3 move1 = calcWave(pos , 0.0027, 0.0400, 0.0400, 0.0127, 0.0089, 0.0114, 0.0063, 0.0224, 0.0015) * amp1;
vec3 move2 = calcWave(pos+move1, 0.0348, 0.0400, 0.0400, f0, f1, f2, f3, f4, f5) * amp2;
return move1+move2;
}
#ifdef TAA
uniform float viewWidth;
uniform float viewHeight;
vec2 texelSize = vec2(1.0/viewWidth,1.0/viewHeight);
uniform int framemod8;
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-1.,3.)/8.,
vec2(5.0,1.)/8.,
vec2(-3,-5.)/8.,
vec2(-5.,5.)/8.,
vec2(-7.,-1.)/8.,
vec2(3,7.)/8.,
vec2(7.,-7.)/8.);
#endif
void main() {
//Positioning
/*
bool entities = (mc_Entity.x == ENTITY_VINES || mc_Entity.x == ENTITY_SMALLENTS || mc_Entity.x == 10030.0 || mc_Entity.x == 10031.0 || mc_Entity.x == 10115.0 || mc_Entity.x == ENTITY_LILYPAD
|| mc_Entity.x == ENTITY_LAVA || mc_Entity.x == ENTITY_LEAVES || mc_Entity.x == ENTITY_SMALLGRASS || mc_Entity.x == ENTITY_UPPERGRASS || mc_Entity.x == ENTITY_LOWERGRASS);
*/
normal.a = 0.02;
normal.xyz = normalize(gl_NormalMatrix * gl_Normal);
texcoord = vec4((gl_MultiTexCoord0).xy,(gl_TextureMatrix[1] * gl_MultiTexCoord1).xy);
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
worldpos = position.xyz + cameraPosition;
bool istopv = gl_MultiTexCoord0.t < mc_midTexCoord.t;
#ifdef Waving_Tallgrass
if (mc_Entity.x == ENTITY_LOWERGRASS && istopv || mc_Entity.x == ENTITY_UPPERGRASS)
position.xyz += calcMove(worldpos.xyz,
0.0041,
0.0070,
0.0044,
0.0038,
0.0240,
0.0000,
vec3(0.8,0.0,0.8),
vec3(0.4,0.0,0.4));
#endif
if (istopv) {
#ifdef Waving_Grass
if ( mc_Entity.x == ENTITY_SMALLGRASS)
position.xyz += calcMove(worldpos.xyz,
0.0041,
0.0070,
0.0044,
0.0038,
0.0063,
0.0000,
vec3(3.0,1.6,3.0),
vec3(0.0,0.0,0.0));
#endif
#ifdef Waving_Entities
if ( mc_Entity.x == ENTITY_SMALLENTS)
position.xyz += calcMove(worldpos.xyz,
0.0041,
0.0070,
0.0044,
0.0038,
0.0240,
0.0000,
vec3(0.8,0.0,0.8),
vec3(0.4,0.0,0.4));
#endif
#ifdef Waving_Fire
if ( mc_Entity.x == ENTITY_FIRE)
position.xyz += calcMove(worldpos.xyz,
0.0105,
0.0096,
0.0087,
0.0063,
0.0097,
0.0156,
vec3(1.2,0.4,1.2),
vec3(0.8,0.8,0.8));
#endif
}
#ifdef Waving_Leaves
if ( mc_Entity.x == ENTITY_LEAVES)
position.xyz += calcMove(worldpos.xyz,
0.0040,
0.0064,
0.0043,
0.0035,
0.0037,
0.0041,
vec3(1.0,0.2,1.0),
vec3(0.5,0.1,0.5));
#endif
#ifdef Waving_Vines
if ( mc_Entity.x == ENTITY_VINES)
position.xyz += calcMove(worldpos.xyz,
0.0040,
0.0064,
0.0043,
0.0035,
0.0037,
0.0041,
vec3(0.5,1.0,0.5),
vec3(0.25,0.5,0.25));
if (mc_Entity.x == ENTITY_INVERTED_LOWER && gl_MultiTexCoord0.t > mc_midTexCoord.t)
position.xyz += calcMove(worldpos.xyz,
0.0041,
0.0070,
0.0044,
0.0038,
0.0240,
0.0000,
vec3(0.8,0.0,0.8),
vec3(0.4,0.0,0.4));
#endif
#ifdef Waving_Lava
if(mc_Entity.x == ENTITY_LAVA){
float fy = fract(worldpos.y + 0.001);
float wave = 0.05 * sin(2 * PI * (frameTimeCounter*0.2 + worldpos.x / 7.0 + worldpos.z / 13.0))
+ 0.05 * sin(2 * PI * (frameTimeCounter*0.15 + worldpos.x / 11.0 + worldpos.z / 5.0));
position.y += clamp(wave, -fy, 1.0-fy)*0.5;
}
#endif
#ifdef Waving_Lilypads
if(mc_Entity.x == ENTITY_LILYPAD){
float fy = fract(worldpos.y + 0.001);
float wave = 0.05 * sin(2 * PI * (frameTimeCounter*0.8 + worldpos.x / 2.5 + worldpos.z / 5.0))
+ 0.05 * sin(2 * PI * (frameTimeCounter*0.6 + worldpos.x / 6.0 + worldpos.z / 12.0));
position.y += clamp(wave, -fy, 1.0-fy)*1.05;
}
#endif
#ifdef Waving_Lanterns
if(mc_Entity.x == 10090.0){
vec3 fxyz = fract(worldpos.xyz + 0.001);
float wave = 0.025 * sin(2 * PI * (frameTimeCounter*0.4 + worldpos.x * 0.5 + worldpos.z * 0.5));
float waveY = 0.05 * cos(frameTimeCounter*2.0 + worldpos.y);
position.x -= clamp(wave, -fxyz.x, 1.0-fxyz.x);
position.y += clamp(waveY*0.25, -fxyz.y, 1.0-fxyz.y)+0.015;
position.z += clamp(wave*0.45, -fxyz.z, 1.0-fxyz.z);
}
#endif
color = gl_Color;
if(mc_Entity.x == METALLIC_BLOCK) normal.a = 0.4;
if(mc_Entity.x == POLISHED_BLOCK) normal.a = 0.5;
//Fix colors on emissive blocks, removed lava as it might cause issues with custom optifine color maps.
if (mc_Entity.x == ENTITY_FIRE
|| mc_Entity.x == ENTITY_EMISSIVE
|| mc_Entity.x == ENITIY_SOULFIRE
|| mc_Entity.x == 10090.0){
normal.a = 0.6;
color = vec4(1.0);
}
if(mc_Entity.x == ENITIY_SOULFIRE || mc_Entity.x == 10090.0) texcoord.z = 0.85;
if(mc_Entity.x == ENTITY_LAVA) normal.a = 0.6;
if(mc_Entity.x == 10300.0) color = vec4(1.0); //fix lecterns
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
#ifdef TAA
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
#endif
#if nMap >= 1 || defined metallicRefl || defined polishedRefl
block = mc_Entity.x;
if(mc_Entity.x == ENTITY_EMISSIVE) block = -1.0; //enable bump and parallax mapping for defined ids.
#ifdef entityBump
block = 1.0;
#endif
vec2 midcoord = (gl_TextureMatrix[0] * mc_midTexCoord).st;
vec2 texcoordminusmid = texcoord.xy-midcoord;
vtexcoordam.pq = abs(texcoordminusmid)*2;
vtexcoordam.st = min(texcoord.xy ,midcoord-texcoordminusmid);
vtexcoord.xy = sign(texcoordminusmid)*0.5+0.5;
vec3 tangent = normalize(gl_NormalMatrix * at_tangent.xyz);
vec3 binormal = normalize(gl_NormalMatrix * cross(at_tangent.xyz, gl_Normal.xyz) * at_tangent.w);
tbnMatrix = mat3(tangent.x, binormal.x, normal.x,
tangent.y, binormal.y, normal.y,
tangent.z, binormal.z, normal.z);
//viewVector = tbnMatrix * (mat3(gl_ModelViewMatrix) * gl_Vertex.xyz + gl_ModelViewMatrix[3].xyz);
viewVector = tbnMatrix * (gl_ModelViewMatrix * gl_Vertex).xyz;
dist = length(gl_ModelViewMatrix * gl_Vertex);
#endif
}

View File

@@ -0,0 +1,35 @@
#version 120
/* DRAWBUFFERS:56 */
//Render hand, entities and particles in here, boost and fix enchanted armor effect in gbuffers_armor_glint
#define gbuffers_texturedblock
#include "/shaders.settings"
varying vec4 color;
varying vec2 texcoord;
varying vec3 ambientNdotL;
uniform sampler2D texture;
uniform vec4 entityColor;
uniform int worldTime;
uniform int entityId;
void main() {
vec4 albedo = texture2D(texture, texcoord.xy)*color;
#ifdef MobsFlashRed
albedo.rgb = mix(albedo.rgb,entityColor.rgb,entityColor.a);
#endif
vec3 finalColor = pow(albedo.rgb,vec3(2.2)) * ambientNdotL.rgb;
//Lightning rendering
if(entityId == 11000.0){
float night = clamp((worldTime-13000.0)/300.0,0.0,1.0)-clamp((worldTime-22800.0)/200.0,0.0,1.0);
finalColor = vec3(0.025, 0.03, 0.05) * (1.0-0.75*night);
albedo.a = 1.0;
}
gl_FragData[0] = vec4(finalColor, albedo.a);
gl_FragData[1] = vec4(normalize(albedo.rgb+0.00001), albedo.a);
}

View File

@@ -0,0 +1,120 @@
#version 120
#define composite2
#define gbuffers_texturedblock
#define lightingColors
#include "/shaders.settings"
varying vec4 color;
varying vec2 texcoord;
varying vec3 ambientNdotL;
uniform vec3 sunPosition;
uniform vec3 upPosition;
uniform int worldTime;
uniform float rainStrength;
uniform float nightVision;
uniform float screenBrightness;
uniform mat4 gbufferModelView;
uniform mat4 gbufferModelViewInverse;
const vec3 ToD[7] = vec3[7]( vec3(0.58597,0.15,0.02),
vec3(0.58597,0.35,0.09),
vec3(0.58597,0.5,0.26),
vec3(0.58597,0.5,0.35),
vec3(0.58597,0.5,0.36),
vec3(0.58597,0.5,0.37),
vec3(0.58597,0.5,0.38));
#ifdef TAA
uniform float viewWidth;
uniform float viewHeight;
vec2 texelSize = vec2(1.0/viewWidth,1.0/viewHeight);
uniform int framemod8;
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-1.,3.)/8.,
vec2(5.0,1.)/8.,
vec2(-3,-5.)/8.,
vec2(-5.,5.)/8.,
vec2(-7.,-1.)/8.,
vec2(3,7.)/8.,
vec2(7.,-7.)/8.);
#endif
#ifdef HandLight
uniform int isEyeInWater;
uniform int heldBlockLightValue;
uniform int heldBlockLightValue2;
#endif
void main() {
//setup basics
color = gl_Color;
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
#ifdef TAA
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
#endif
vec3 normal = normalize(gl_NormalMatrix * gl_Normal);
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
vec2 lmcoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
/*--------------------------------*/
//Emissive blocks lighting in order to fix lighting on particles
#ifdef HandLight
bool underwaterlava = (isEyeInWater == 1.0 || isEyeInWater == 2.0);
if(!underwaterlava) lmcoord.x = max(lmcoord.x, max(max(float(heldBlockLightValue), float(heldBlockLightValue2)) - 1.0 - length(gl_ModelViewMatrix * gl_Vertex), 0.0) / 15.0);
#endif
float torch_lightmap = 16.0-min(15.,(lmcoord.s-0.5/16.)*16.*16./15);
float fallof1 = clamp(1.0 - pow(torch_lightmap/16.0,4.0),0.0,1.0);
torch_lightmap = fallof1*fallof1/(torch_lightmap*torch_lightmap+1.0);
vec3 emissiveLightC = vec3(emissive_R,emissive_G,emissive_B)*torch_lightmap;
float finalminlight = (nightVision > 0.01)? 0.025 : ((minlight+0.015)+(screenBrightness*0.025))*0.15;
/*---------------------------------------------------------------------*/
//reduced the sun color to a 7 array
float hour = max(mod(worldTime/1000.0+2.0,24.0)-2.0,0.0); //-0.1
float cmpH = max(-abs(floor(hour)-6.0)+6.0,0.0); //12
float cmpH1 = max(-abs(floor(hour)-5.0)+6.0,0.0); //1
vec3 temp = ToD[int(cmpH)];
vec3 temp2 = ToD[int(cmpH1)];
vec3 sunlight = mix(temp,temp2,fract(hour));
const vec3 rainC = vec3(0.01,0.01,0.01);
sunlight = mix(sunlight,rainC*sunlight,rainStrength);
/*-------------------------------------------------------------------*/
const vec3 moonlight = vec3(0.0024, 0.00432, 0.0078);
vec3 sunVec = normalize(sunPosition);
vec3 upVec = vec3(0.0, 1.0, 0.0); //fix for loading shaderpacks in nether and end, optifine bug.
vec2 visibility = vec2(dot(sunVec,upVec),dot(-sunVec,upVec));
float NdotL = dot(normal,sunVec);
float NdotU = dot(normal,upVec);
vec2 trCalc = min(abs(worldTime-vec2(23250.0,12700.0)),750.0);
float tr = max(min(trCalc.x,trCalc.y)/375.0-1.0,0.0);
visibility = pow(clamp(visibility+0.15,0.0,0.15)/0.15,vec2(4.0));
float skyL = max(lmcoord.t-2./16.0,0.0)*1.14285714286;
float SkyL2 = skyL*skyL;
float skyc2 = mix(1.0,SkyL2,skyL);
vec4 bounced = vec4(NdotL,NdotL,NdotL,NdotU) * vec4(-0.14*skyL*skyL,0.34,0.7,0.1) + vec4(0.6,0.66,0.7,0.25);
bounced *= vec4(skyc2,skyc2,visibility.x-tr*visibility.x,0.8);
vec3 sun_ambient = bounced.w * (vec3(0.1, 0.5, 1.1)+rainStrength*vec3(0.05,-0.27,-0.8))*2.3+ 1.7*sunlight*(sqrt(bounced.w)*bounced.x*2.4 + bounced.z)*(1.0-rainStrength*0.98);
vec3 moon_ambient = (moonlight*0.7 + moonlight*bounced.y)*(1.0-rainStrength*0.95)*2.0;
vec3 amb1 = (sun_ambient*visibility.x + moon_ambient*visibility.y)*SkyL2*(0.03+tr*0.17)*0.65;
ambientNdotL.rgb = amb1 + emissiveLightC + finalminlight;
sunlight = mix(sunlight,moonlight*(1.0-rainStrength*0.9),visibility.y)*tr;
}

View File

@@ -0,0 +1,109 @@
#version 120
#define gbuffers_water
#include "/shaders.settings"
varying vec4 color;
varying vec4 ambientNdotL;
varying vec2 texcoord;
varying vec2 lmcoord;
varying vec3 viewVector;
varying vec3 worldpos;
varying mat3 tbnMatrix;
uniform sampler2D noisetex;
uniform sampler2D texture;
uniform float frameTimeCounter;
vec4 encode (vec3 n,float dif){
float p = sqrt(n.z*8+8);
float vis = lmcoord.t;
if (ambientNdotL.a > 0.9) vis = vis * 0.25;
if (ambientNdotL.a > 0.4 && ambientNdotL.a < 0.6) vis = vis*0.25+0.25;
if (ambientNdotL.a < 0.1) vis = vis*0.25+0.5;
return vec4(n.xy/p + 0.5,vis,1.0);
}
mat2 rmatrix(float rad){
return mat2(vec2(cos(rad), -sin(rad)), vec2(sin(rad), cos(rad)));
}
float calcWaves(vec2 coord, float iswater){
vec2 movement = abs(vec2(0.0, -frameTimeCounter * 0.31365*iswater));
coord *= 0.262144;
vec2 coord0 = coord * rmatrix(1.0) - movement * 4.0;
coord0.y *= 3.0;
vec2 coord1 = coord * rmatrix(0.5) - movement * 1.5;
coord1.y *= 3.0;
vec2 coord2 = coord + movement * 0.5;
coord2.y *= 3.0;
float wave = 1.0 - texture2D(noisetex,coord0 * 0.005).x * 10.0; //big waves
wave += texture2D(noisetex,coord1 * 0.010416).x * 7.0; //small waves
wave += sqrt(texture2D(noisetex,coord2 * 0.045).x * 6.5) * 1.33;//noise texture
wave *= 0.0157;
return wave;
}
vec3 calcBump(vec2 coord, float iswater){
const vec2 deltaPos = vec2(0.25, 0.0);
float h0 = calcWaves(coord, iswater);
float h1 = calcWaves(coord + deltaPos.xy, iswater);
float h2 = calcWaves(coord - deltaPos.xy, iswater);
float h3 = calcWaves(coord + deltaPos.yx, iswater);
float h4 = calcWaves(coord - deltaPos.yx, iswater);
float xDelta = ((h1-h0)+(h0-h2));
float yDelta = ((h3-h0)+(h0-h4));
return vec3(vec2(xDelta,yDelta)*0.5, 0.5); //z = 1.0-0.5
}
vec3 calcParallax(vec3 pos, float iswater){
float getwave = calcWaves(pos.xz - pos.y, iswater);
pos.xz += (getwave * viewVector.xy) * waterheight;
return pos;
}
void main() {
float iswater = clamp(ambientNdotL.a*2.0-1.0,0.0,1.0);
vec4 albedo = texture2D(texture, texcoord.xy)*color;
albedo.rgb = pow(albedo.rgb,vec3(2.2));
float texvis = 0.5;
#ifndef watertex
texvis = 0.11;
if(iswater > 0.9)albedo.rgb = vec3(waterCR,waterCG,waterCB);
#endif
//Bump and parallax mapping
vec3 waterpos = worldpos;
#ifdef WaterParallax
waterpos = calcParallax(waterpos, iswater);
#endif
vec3 bump = calcBump(waterpos.xz - waterpos.y, iswater);
vec3 newnormal = normalize(bump * tbnMatrix);
//---
vec3 fColor = albedo.rgb*ambientNdotL.rgb;
float alpha = mix(albedo.a,texvis,iswater);
if(iswater > 0.9)alpha *= waterA;
/* DRAWBUFFERS:526 */
gl_FragData[0] = vec4(fColor,alpha);
gl_FragData[1] = encode(newnormal.xyz, 1.0);
gl_FragData[2] = vec4(normalize(albedo.rgb+0.00001),alpha);
}

View File

@@ -0,0 +1,172 @@
#version 120
#define composite2
#define gbuffers_water
#define lightingColors
#include "/shaders.settings"
varying vec4 color;
varying vec4 ambientNdotL;
varying vec2 texcoord;
varying vec2 lmcoord;
varying vec3 viewVector;
varying vec3 worldpos;
varying mat3 tbnMatrix;
attribute vec4 mc_Entity;
attribute vec4 at_tangent; //xyz = tangent vector, w = handedness, added in 1.7.10
uniform vec3 cameraPosition;
uniform vec3 sunPosition;
uniform vec3 upPosition;
uniform mat4 gbufferModelView;
uniform mat4 gbufferModelViewInverse;
uniform int worldTime;
uniform float rainStrength;
uniform float nightVision;
uniform float screenBrightness;
#ifdef Waving_Water
uniform float frameTimeCounter;
const float PI = 3.1415927;
#endif
const vec3 ToD[7] = vec3[7]( vec3(0.58597,0.16,0.005),
vec3(0.58597,0.31,0.05),
vec3(0.58597,0.45,0.16),
vec3(0.58597,0.5,0.35),
vec3(0.58597,0.5,0.36),
vec3(0.58597,0.5,0.37),
vec3(0.58597,0.5,0.38));
float SunIntensity(float zenithAngleCos, float sunIntensity, float cutoffAngle, float steepness){
return sunIntensity * max(0.0, 1.0 - exp(-((cutoffAngle - acos(zenithAngleCos))/steepness)));
}
float luma(vec3 color) {
return dot(color,vec3(0.299, 0.587, 0.114));
}
#ifdef TAA
uniform float viewWidth;
uniform float viewHeight;
vec2 texelSize = vec2(1.0/viewWidth,1.0/viewHeight);
uniform int framemod8;
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-1.,3.)/8.,
vec2(5.0,1.)/8.,
vec2(-3,-5.)/8.,
vec2(-5.,5.)/8.,
vec2(-7.,-1.)/8.,
vec2(3,7.)/8.,
vec2(7.,-7.)/8.);
#endif
void main() {
//pos
vec3 normal = normalize(gl_NormalMatrix * gl_Normal).xyz;
vec3 position = mat3(gbufferModelViewInverse) * (gl_ModelViewMatrix * gl_Vertex).xyz + gbufferModelViewInverse[3].xyz;
worldpos = position.xyz + cameraPosition;
color = gl_Color;
texcoord = (gl_MultiTexCoord0).xy;
lmcoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
//Transparency stuff
ambientNdotL.a = 0.0;
float iswater = 1.0; //disable lightmap on water, make light go through instead
if(mc_Entity.x == 10008.0) {
ambientNdotL.a = 1.0;
iswater = 0.0;
#ifdef Waving_Water
float fy = fract(worldpos.y + 0.001);
float wave = 0.05 * sin(2 * PI * (frameTimeCounter*0.8 + worldpos.x / 2.5 + worldpos.z / 5.0))
+ 0.05 * sin(2 * PI * (frameTimeCounter*0.6 + worldpos.x / 6.0 + worldpos.z / 12.0));
position.y += clamp(wave, -fy, 1.0-fy)*waves_amplitude;
#endif
}
if(mc_Entity.x == 10079.0) ambientNdotL.a = 0.5;
//---
gl_Position = gl_ProjectionMatrix * gbufferModelView * vec4(position, 1.0);
#ifdef TAA
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
#endif
//ToD
float hour = max(mod(worldTime/1000.0+2.0,24.0)-2.0,0.0); //-0.1
float cmpH = max(-abs(floor(hour)-6.0)+6.0,0.0); //12
float cmpH1 = max(-abs(floor(hour)-5.0)+6.0,0.0); //1
#ifdef MC_GL_VENDOR_ATI
vec3 sunlight = vec3(1.0); //Time of day calculation breaks water on amd drivers 18.8.1, last working driver was 18.6.1, causes heavy flickering. TESTED ON RX460
#else
vec3 sunlight = mix(ToD[int(cmpH)], ToD[int(cmpH1)], fract(hour));
#endif
sunlight.rgb += vec3(r_multiplier,g_multiplier,b_multiplier); //allows lighting colors to be tweaked.
sunlight.rgb *= light_brightness; //brightness needs to be adjusted if we tweak lighting colors.
//---
//lightmap
float torch_lightmap = 16.0-min(15.0,(lmcoord.s-0.5/16.0)*16.0*16.0/15.0);
float fallof1 = clamp(1.0 - pow(torch_lightmap/16.0,4.0),0.0,1.0);
torch_lightmap = fallof1*fallof1/(torch_lightmap*torch_lightmap+1.0);
torch_lightmap *= iswater;
vec3 emissiveLightC = vec3(emissive_R,emissive_G,emissive_B)*torch_lightmap*0.2;
//---
//light bounce
vec3 sunVec = normalize(sunPosition);
vec3 upVec = vec3(0.0, 1.0, 0.0); //fix for loading shaderpacks in nether and end, optifine bug.
vec2 visibility = vec2(dot(sunVec,upVec),dot(-sunVec,upVec));
float cutoffAngle = 1.608;
float steepness = 1.5;
float cosSunUpAngle = dot(sunVec, upVec) * 0.95 + 0.05; //Has a lower offset making it scatter when sun is below the horizon.
float sunE = SunIntensity(cosSunUpAngle, 1000.0, cutoffAngle, steepness); // Get sun intensity based on how high in the sky it is
float NdotL = dot(normal,sunVec);
float NdotU = dot(normal,upVec);
vec2 trCalc = min(abs(worldTime-vec2(23000.0,12700.0)),750.0); //adjust to make day-night switch smoother
float tr = max(min(trCalc.x,trCalc.y)/375.0-1.0,0.0);
visibility = pow(clamp(visibility+0.15,0.0,0.3)/0.3,vec2(4.4));
sunlight = sunlight/luma(sunlight)*sunE*0.0075*0.075*3.*visibility.x;
float skyL = max(lmcoord.t-2./16.0,0.0)*1.14285714286;
float SkyL2 = skyL*skyL;
float skyc2 = mix(1.0,SkyL2,skyL);
vec4 bounced = vec4(NdotL,NdotL,NdotL,NdotU) * vec4(-0.14*skyL*skyL,0.33,0.7,0.1) + vec4(0.6,0.66,0.7,0.25);
bounced *= vec4(skyc2,skyc2,visibility.x-tr*visibility.x,0.8);
vec3 ambientC = mix(vec3(0.3, 0.5, 1.1),vec3(0.08,0.1,0.1),rainStrength)*length(sunlight)*bounced.w;
ambientC += 0.25*sunlight*(bounced.x + bounced.z)*(0.03+tr*0.17)/0.4*(1.0-rainStrength*0.98) + length(sunlight)*0.2*(1.0-rainStrength*0.9);
ambientC += sunlight*(NdotL*0.5+0.45)*visibility.x*(1.0-tr)*(1.0-tr)*4.*(1.0-rainStrength*0.98);
//lighting during night time
const vec3 moonlight = vec3(0.0024, 0.00432, 0.0078);
vec3 moon_ambient = (moonlight*2.0 + moonlight*bounced.y)*(4.0-rainStrength*0.95)*0.2;
vec3 moonC = (moon_ambient*visibility.y)*SkyL2*(0.03*0.65+tr*0.17*0.65);
float finalminlight = (nightVision > 0.01)? 0.075: ((minlight+0.015)+(screenBrightness*0.025))*0.1;
ambientNdotL.rgb = ambientC*SkyL2*0.3 + moonC + emissiveLightC + finalminlight;
//sunlight = mix(sunlight,moonlight*(1.0-rainStrength*0.9),visibility.y)*tr;
sunlight = mix(sunlight,moonlight*(1.0-rainStrength*0.9),visibility.y); //remove time check to improve day-night transition
//---
vec3 tangent = normalize(gl_NormalMatrix * at_tangent.xyz);
vec3 binormal = normalize(gl_NormalMatrix * cross(at_tangent.xyz, gl_Normal.xyz) * at_tangent.w);
tbnMatrix = mat3(tangent.x, binormal.x, normal.x,
tangent.y, binormal.y, normal.y,
tangent.z, binormal.z, normal.z);
float dist = length(gl_ModelViewMatrix * gl_Vertex);
viewVector = tbnMatrix * (gl_ModelViewMatrix * gl_Vertex).xyz;
viewVector.xy = viewVector.xy / dist * 8.25;
}

View File

@@ -0,0 +1,291 @@
#version 120
/* DRAWBUFFERS:34 */
#define gbuffers_shadows
#define composite0
#define composite2
#define lightingColors
#include "/shaders.settings"
#ifdef HandLight
uniform int heldBlockLightValue;
uniform int heldBlockLightValue2;
#endif
varying vec2 texcoord;
varying vec3 sunVec;
varying vec3 upVec;
varying vec3 sunlight;
varying float tr;
varying float sunVisibility;
varying float moonVisibility;
uniform sampler2D depthtex0;
uniform sampler2D depthtex1;
uniform sampler2D colortex0;
uniform sampler2D colortex1;
uniform sampler2D colortex2;
uniform sampler2D composite;
uniform mat4 gbufferProjectionInverse;
uniform int isEyeInWater;
uniform float aspectRatio;
uniform float near;
uniform float far;
uniform float viewWidth;
uniform float viewHeight;
uniform float rainStrength;
uniform float nightVision;
uniform float screenBrightness;
float comp = 1.0-near/far/far; //distance above that are considered as sky
const vec2 check_offsets[25] = vec2[25](vec2(-0.4894566f,-0.3586783f),
vec2(-0.1717194f,0.6272162f),
vec2(-0.4709477f,-0.01774091f),
vec2(-0.9910634f,0.03831699f),
vec2(-0.2101292f,0.2034733f),
vec2(-0.7889516f,-0.5671548f),
vec2(-0.1037751f,-0.1583221f),
vec2(-0.5728408f,0.3416965f),
vec2(-0.1863332f,0.5697952f),
vec2(0.3561834f,0.007138769f),
vec2(0.2868255f,-0.5463203f),
vec2(-0.4640967f,-0.8804076f),
vec2(0.1969438f,0.6236954f),
vec2(0.6999109f,0.6357007f),
vec2(-0.3462536f,0.8966291f),
vec2(0.172607f,0.2832828f),
vec2(0.4149241f,0.8816f),
vec2(0.136898f,-0.9716249f),
vec2(-0.6272043f,0.6721309f),
vec2(-0.8974028f,0.4271871f),
vec2(0.5551881f,0.324069f),
vec2(0.9487136f,0.2605085f),
vec2(0.7140148f,-0.312601f),
vec2(0.0440252f,0.9363738f),
vec2(0.620311f,-0.6673451f)
);
vec3 decode (vec2 enc){
vec2 fenc = enc*4-2;
float f = dot(fenc,fenc);
float g = sqrt(1-f/4.0);
vec3 n;
n.xy = fenc*g;
n.z = 1-f/2;
return n;
}
vec3 YCoCg2RGB(vec3 c){
c.y-=0.5;
c.z-=0.5;
return vec3(c.r+c.g-c.b, c.r + c.b, c.r - c.g - c.b);
}
#ifdef Celshading
float edepth(vec2 coord) {
return texture2D(depthtex1,coord).x;
}
vec3 celshade(vec3 clrr) {
//edge detect
float dtresh = 1.0/(far-near) / (5000.0*Celradius);
vec4 dc = vec4(edepth(texcoord.xy));
vec3 border = vec3(1.0/viewWidth, 1.0/viewHeight, 0.0)*Celborder;
vec4 sa = vec4(edepth(texcoord.xy + vec2(-border.x,-border.y)),
edepth(texcoord.xy + vec2(border.x,-border.y)),
edepth(texcoord.xy + vec2(-border.x,border.z)),
edepth(texcoord.xy + vec2(border.z,border.y)));
//opposite side samples
vec4 sb = vec4(edepth(texcoord.xy + vec2(border.x,border.y)),
edepth(texcoord.xy + vec2(-border.x,border.y)),
edepth(texcoord.xy + vec2(border.x,border.z)),
edepth(texcoord.xy + vec2(border.z,-border.y)));
vec4 dd = abs(2.0* dc - sa - sb) - dtresh;
dd = step(dd.xyzw, vec4(0.0));
float e = clamp(dot(dd,vec4(0.25f)),0.0,1.0);
return clrr*e;
}
#endif
#ifdef TAA
vec2 texelSize = vec2(1.0/viewWidth,1.0/viewHeight);
uniform int framemod8;
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-1.,3.)/8.,
vec2(5.0,1.)/8.,
vec2(-3,-5.)/8.,
vec2(-5.,5.)/8.,
vec2(-7.,-1.)/8.,
vec2(3,7.)/8.,
vec2(7.,-7.)/8.);
#endif
vec3 toScreenSpace(vec3 p) {
vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw);
vec3 p3 = p * 2.0 - 1.0;
vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3];
return fragposition.xyz / fragposition.w;
}
#ifdef SSDO
uniform float frameTimeCounter;
//modified version of Yuriy O'Donnell's SSDO (License MIT -> https://github.com/kayru/dssdo)
float calcSSDO(vec3 fragpos, vec3 normal){
float finalAO = 0.0;
float radius = 0.05 / (fragpos.z);
const float attenuation_angle_threshold = 0.1;
const int num_samples = 16;
const float ao_weight = 1.0;
#ifdef TAA
float noise = fract(0.75487765 * gl_FragCoord.x + 0.56984026 * gl_FragCoord.y);
noise = fract(frameTimeCounter * 2.0 + noise);
#else
float noise = 1.0;
#endif
for( int i=0; i<num_samples; ++i ){
vec2 texOffset = pow(length(check_offsets[i].xy),0.5)*radius*vec2(1.0,aspectRatio)*normalize(check_offsets[i].xy);
vec2 newTC = texcoord+texOffset*noise;
#ifdef TAA
vec3 t0 = toScreenSpace(vec3(newTC-offsets[framemod8]*texelSize*0.5, texture2D(depthtex1, newTC).x));
#else
vec3 t0 = toScreenSpace(vec3(newTC, texture2D(depthtex1, newTC).x));
#endif
vec3 center_to_sample = t0.xyz - fragpos.xyz;
float dist = length(center_to_sample);
vec3 center_to_sample_normalized = center_to_sample / dist;
float attenuation = 1.0-clamp(dist/6.0,0.0,1.0);
float dp = dot(normal, center_to_sample_normalized);
attenuation = sqrt(max(dp,0.0))*attenuation*attenuation * step(attenuation_angle_threshold, dp);
finalAO += attenuation * (ao_weight / num_samples);
}
return finalAO;
}
#endif
vec2 decodeVec2(float a){
const vec2 constant1 = 65535. / vec2( 256., 65536.);
const float constant2 = 256. / 255.;
return fract( a * constant1 ) * constant2 ;
}
uniform mat4 gbufferModelViewInverse;
void main() {
//Setup depth
float depth0 = texture2D(depthtex0, texcoord).x; //everything
float depth1 = texture2D(depthtex1, texcoord).x; //transparency
bool sky = (depth1 >= 1.0);
vec4 albedo = texture2D(colortex0,texcoord);
vec3 normal = decode(texture2D(colortex1, texcoord).xy);
vec2 lightmap = texture2D(colortex1, texcoord.xy).zw;
bool translucent = albedo.b > 0.69 && albedo.b < 0.71;
bool emissive = albedo.b > 0.59 && albedo.b < 0.61;
vec3 color = vec3(albedo.rg,0.0);
vec2 a0 = texture2D(colortex0,texcoord + vec2(1.0/viewWidth,0.0)).rg;
vec2 a1 = texture2D(colortex0,texcoord - vec2(1.0/viewWidth,0.0)).rg;
vec2 a2 = texture2D(colortex0,texcoord + vec2(0.0,1.0/viewHeight)).rg;
vec2 a3 = texture2D(colortex0,texcoord - vec2(0.0,1.0/viewHeight)).rg;
vec4 lumas = vec4(a0.x,a1.x,a2.x,a3.x);
vec4 chromas = vec4(a0.y,a1.y,a2.y,a3.y);
vec4 w = 1.0-step(0.1176, abs(lumas - color.x));
float W = dot(w,vec4(1.0));
w.x = (W==0.0)? 1.0:w.x; W = (W==0.0)? 1.0:W;
bool pattern = (mod(gl_FragCoord.x,2.0)==mod(gl_FragCoord.y,2.0));
color.b= dot(w,chromas)/W;
color.rgb = (pattern)?color.rbg:color.rgb;
color.rgb = YCoCg2RGB(color.rgb);
color = pow(color,vec3(2.2));
if (!sky){
//Water and Ice
vec3 Wnormal = texture2D(colortex2,texcoord).xyz;
bool iswater = Wnormal.z < 0.2499 && dot(Wnormal,Wnormal) > 0.0;
bool isice = Wnormal.z > 0.2499 && Wnormal.z < 0.4999 && dot(Wnormal,Wnormal) > 0.0;
bool isnsun = (iswater||isice) || ((!iswater||!isice) && isEyeInWater == 1);
/*--------------------------------------------------------------------------------------*/
#ifdef TAA
vec2 newTC = gl_FragCoord.xy*texelSize;
vec3 TAAfragpos = toScreenSpace(vec3(newTC-offsets[framemod8]*texelSize*0.5, texture2D(depthtex1, newTC).x));
#else
vec3 TAAfragpos = toScreenSpace(vec3(texcoord,depth1)); //was depth0 before, might cause issues
#endif
#ifdef Whiteworld
color += vec3(1.5);
#endif
#ifdef Celshading
color = celshade(color);
#endif
float ao = 1.0;
#ifdef SSDO
float occlusion = calcSSDO(TAAfragpos, normal);
if(!iswater)ao = pow(1.0-occlusion, ao_strength);
#endif
//Emissive blocks lighting and colors
#ifdef HandLight
bool underwaterlava = (isEyeInWater == 1.0 || isEyeInWater == 2.0);
if(!underwaterlava) lightmap.x = max(lightmap.x, max(max(float(heldBlockLightValue), float(heldBlockLightValue2)) - 1.0 - length(TAAfragpos), 0.0) / 15.0);
#endif
float torch_lightmap = 16.0-min(15.0,(lightmap.x-0.5/16.0)*16.0*16.0/15.0);
float fallof1 = clamp(1.0 - pow(torch_lightmap/16.0,4.0),0.0,1.0);
torch_lightmap = fallof1*fallof1/(torch_lightmap*torch_lightmap+1.0);
float c_emitted = dot((color.rgb),vec3(1.0,0.6,0.4))/2.0;
float emitted = emissive? clamp(c_emitted*c_emitted,0.0,1.0)*torch_lightmap : 0.0;
vec3 emissiveLightC = vec3(emissive_R,emissive_G,emissive_B);
/*------------------------------------------------------------------------------------------*/
//Lighting and colors
float NdotL = dot(normal,sunVec);
float NdotU = dot(normal,upVec);
const vec3 moonlight = vec3(0.5, 0.9, 1.8) * Moonlight;
vec2 visibility = vec2(sunVisibility,moonVisibility);
float skyL = max(lightmap.y-2./16.0,0.0)*1.14285714286;
float SkyL2 = skyL*skyL;
float skyc2 = mix(1.0,SkyL2,skyL);
vec4 bounced = vec4(NdotL,NdotL,NdotL,NdotU) * vec4(-0.14*skyL*skyL,0.33,0.7,0.1) + vec4(0.6,0.66,0.7,0.25);
bounced *= vec4(skyc2,skyc2,visibility.x-tr*visibility.x,0.8);
vec3 sun_ambient = bounced.w * (vec3(0.1, 0.5, 1.1)*2.4+rainStrength*2.3*vec3(0.05,-0.33,-0.9))+ 1.6*sunlight*(sqrt(bounced.w)*bounced.x*2.4 + bounced.z)*(1.0-rainStrength*0.99);
vec3 moon_ambient = (moonlight*0.7 + moonlight*bounced.y)*4.0;
vec3 amb1 = (sun_ambient*visibility.x + moon_ambient*visibility.y)*SkyL2*(0.03*0.65+tr*0.17*0.65);
float finalminlight = (nightVision > 0.01)? 0.15 : (minlight+0.006)+(screenBrightness*0.0125); //add nightvision support but make sure minlight is still adjustable.
vec3 ambientC = ao*amb1 + emissiveLightC*(emitted*15.*color + torch_lightmap*ao)*0.66 + ao*finalminlight*min(skyL+6/16.,9/16.)*normalize(amb1+0.0001);
/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
color *= (ambientC*(isnsun?1.0/(SkyL2*skyL*0.5+0.5):1.0)*1.4)*0.63;
}
//Draw skytexture from gbuffers_skytextured
if (sky)color = pow(texture2D(composite, texcoord.xy).rgb,vec3(2.2));
gl_FragData[0] = vec4(0.0); //used by custom skycolor, godrays and VL not needed in end dimension
gl_FragData[1] = vec4(pow(color/257.0,vec3(0.454)), 1.0);
}

View File

@@ -0,0 +1,55 @@
#version 120
#define lightingColors
#include "/shaders.settings"
varying vec2 texcoord;
varying vec3 sunVec;
varying vec3 upVec;
varying vec3 sunlight;
varying float tr;
varying float sunVisibility;
varying float moonVisibility;
uniform vec3 sunPosition;
uniform vec3 upPosition;
uniform int worldTime;
const vec3 ToD[7] = vec3[7]( vec3(0.58597,0.16,0.005),
vec3(0.58597,0.31,0.08),
vec3(0.58597,0.45,0.16),
vec3(0.58597,0.5,0.35),
vec3(0.58597,0.5,0.36),
vec3(0.58597,0.5,0.37),
vec3(0.58597,0.5,0.38));
void main() {
//Position
gl_Position = ftransform();
texcoord = (gl_MultiTexCoord0).xy;
/*--------------------------------*/
//Sun/moon pos
sunVec = normalize(sunPosition);
upVec = vec3(0.0, 1.0, 0.0); //fix for loading shaderpacks in nether and end, optifine bug.
float SdotU = dot(sunVec,upVec);
sunVisibility = pow(clamp(SdotU+0.15,0.0,0.15)/0.15,4.0);
moonVisibility = pow(clamp(-SdotU+0.15,0.0,0.15)/0.15,4.0);
/*--------------------------------*/
//reduced the sun color to a 7 array
float hour = max(mod(worldTime/1000.0+2.0,24.0)-2.0,0.0); //-0.1
float cmpH = max(-abs(floor(hour)-6.0)+6.0,0.0); //12
float cmpH1 = max(-abs(floor(hour)-5.0)+6.0,0.0); //1
vec3 temp = ToD[int(cmpH)];
vec3 temp2 = ToD[int(cmpH1)];
sunlight = mix(temp,temp2,fract(hour));
sunlight.rgb += vec3(r_multiplier,g_multiplier,b_multiplier); //allows lighting colors to be tweaked.
sunlight.rgb *= light_brightness; //brightness needs to be adjusted if we tweak lighting colors.
vec2 trCalc = min(abs(worldTime-vec2(23000.0,12700.0)),750.0);
tr = max(min(trCalc.x,trCalc.y)/375.0-1.0,0.0);
}

View File

@@ -0,0 +1,287 @@
#version 120
#extension GL_ARB_shader_texture_lod : enable
const bool gaux1MipmapEnabled = true;
/* DRAWBUFFERS:3 */
#define composite2
#define composite1
#define lightingColors
#include "/shaders.settings"
varying vec2 texcoord;
uniform sampler2D composite;
uniform sampler2D gaux1;
uniform sampler2D depthtex0;
uniform sampler2D depthtex1;
uniform sampler2D colortex0;
uniform sampler2D colortex1;
uniform sampler2D colortex2;
uniform sampler2D gdepth;
uniform sampler2D noisetex;
uniform sampler2D gaux3;
uniform sampler2D gaux2;
uniform vec3 cameraPosition;
uniform mat4 gbufferProjection;
uniform mat4 gbufferProjectionInverse;
uniform mat4 gbufferModelViewInverse;
uniform int isEyeInWater;
uniform float near;
uniform float far;
uniform float screenBrightness;
uniform float frameTimeCounter;
uniform float blindness;
#if MC_VERSION >= 11900
uniform float darknessFactor;
uniform float darknessLightFactor;
#endif
/*------------------------------------------*/
float comp = 1.0-near/far/far;
#if defined waterRefl || defined iceRefl
const int maxf = 3; //number of refinements
const float ref = 0.11; //refinement multiplier
const float inc = 3.0; //increasement factor at each step
vec3 nvec3(vec4 pos) {
return pos.xyz/pos.w;
}
vec4 nvec4(vec3 pos) {
return vec4(pos.xyz, 1.0);
}
float cdist(vec2 coord) {
return max(abs(coord.s-0.5),abs(coord.t-0.5))*2.0;
}
vec4 raytrace(vec3 fragpos, vec3 skycolor, vec3 rvector) {
vec4 color = vec4(0.0);
vec3 start = fragpos;
rvector *= 1.2;
fragpos += rvector;
vec3 tvector = rvector;
int sr = 0;
for(int i=0;i<25;i++){
vec3 pos = nvec3(gbufferProjection * nvec4(fragpos)) * 0.5 + 0.5;
if(pos.x < 0 || pos.x > 1 || pos.y < 0 || pos.y > 1 || pos.z < 0 || pos.z > 1.0) break;
vec3 fragpos0 = vec3(pos.st, texture2D(depthtex1, pos.st).r);
fragpos0 = nvec3(gbufferProjectionInverse * nvec4(fragpos0 * 2.0 - 1.0));
float err = distance(fragpos,fragpos0);
if(err < pow(length(rvector),1.175)){ //if(err < pow(length(rvector)*1.85,1.15)){ <- old, adjusted error check to reduce banding issues/glitches
sr++;
if(sr >= maxf){
bool land = texture2D(depthtex1, pos.st).r < comp;
color = pow(texture2DLod(gaux1, pos.st, 1),vec4(2.2))*257.0;
if (isEyeInWater == 0) color.rgb = land ? mix(color.rgb,skycolor,0.5) : skycolor; //reflections color, blend it with fake sky color.
color.a = clamp(1.0 - pow(cdist(pos.st), 20.0), 0.0, 1.0);
break;
}
tvector -= rvector;
rvector *= ref;
}
rvector *= inc;
tvector += rvector;
fragpos = start + tvector;
}
return color;
}
#endif
#ifdef Refraction
mat2 rmatrix(float rad){
return mat2(vec2(cos(rad), -sin(rad)), vec2(sin(rad), cos(rad)));
}
float calcWaves(vec2 coord){
vec2 movement = abs(vec2(0.0, -frameTimeCounter * 0.5));
coord *= 0.4;
vec2 coord0 = coord * rmatrix(1.0) - movement * 4.5;
coord0.y *= 3.0;
vec2 coord1 = coord * rmatrix(0.5) - movement * 1.5;
coord1.y *= 3.0;
vec2 coord2 = coord * frameTimeCounter * 0.02;
coord0 *= waveSize;
coord1 *= (waveSize-0.5); //create an offset for smaller waves
float wave = texture2D(noisetex,coord0 * 0.005).x * 10.0; //big waves
wave -= texture2D(noisetex,coord1 * 0.010416).x * 7.0; //small waves
wave += 1.0-sqrt(texture2D(noisetex,coord2 * 0.0416).x * 6.5) * 1.33; //noise texture
wave *= 0.0157;
return wave;
}
vec2 calcBump(vec2 coord){
const vec2 deltaPos = vec2(0.25, 0.0);
float h0 = calcWaves(coord);
float h1 = calcWaves(coord + deltaPos.xy);
float h2 = calcWaves(coord - deltaPos.xy);
float h3 = calcWaves(coord + deltaPos.yx);
float h4 = calcWaves(coord - deltaPos.yx);
float xDelta = ((h1-h0)+(h0-h2));
float yDelta = ((h3-h0)+(h0-h4));
return vec2(xDelta,yDelta)*0.05;
}
#endif
vec3 decode (vec2 enc){
vec2 fenc = enc*4-2;
float f = dot(fenc,fenc);
float g = sqrt(1-f/4.0);
vec3 n;
n.xy = fenc*g;
n.z = 1-f/2;
return n;
}
void main() {
vec3 c = pow(texture2D(gaux1,texcoord).xyz,vec3(2.2))*257.;
//Depth and fragpos
float depth0 = texture2D(depthtex0, texcoord).x;
vec4 fragpos0 = gbufferProjectionInverse * (vec4(texcoord, depth0, 1.0) * 2.0 - 1.0);
fragpos0 /= fragpos0.w;
vec3 normalfragpos0 = normalize(fragpos0.xyz);
float depth1 = texture2D(depthtex1, texcoord).x;
vec4 fragpos1 = gbufferProjectionInverse * (vec4(texcoord, depth1, 1.0) * 2.0 - 1.0);
fragpos1 /= fragpos1.w;
vec3 normalfragpos1 = normalize(fragpos1.xyz);
/*--------------------------------------------------------------------------------------------*/
vec4 trp = texture2D(gaux3,texcoord.xy);
bool transparency = dot(trp.xyz,trp.xyz) > 0.000001;
#ifdef Refraction
if (texture2D(colortex2, texcoord).z < 0.2499 && dot(texture2D(colortex2,texcoord).xyz,texture2D(colortex2,texcoord).xyz) > 0.0 || isEyeInWater == 1.0) { //reflective water
vec2 wpos = (gbufferModelViewInverse*fragpos0).xz+cameraPosition.xz;
vec2 refraction = texcoord.xy + calcBump(wpos);
c = pow(texture2D(gaux1, refraction).xyz, vec3(2.2))*257.0;
//remove underwater tint, not needed in end
}
#endif
//Draw fog
vec3 fogC = vec3(0.001, 0.0, 0.002);
//float fogF = calcFog(fragpos0.xyz);
//Render before transparency
float mats = texture2D(colortex0,texcoord).b;
bool isMetallic = mats > 0.39 && mats < 0.41;
bool isPolished = mats > 0.49 && mats < 0.51;
#ifndef polishedRefl
isPolished = false;
#endif
#ifndef metallicRefl
isMetallic = false;
#endif
#if defined metallicRefl || defined polishedRefl
if (isMetallic || isPolished) {
vec3 relfNormal = decode(texture2D(colortex1,texcoord).xy);
vec3 reflectedVector = reflect(normalfragpos0, relfNormal);
float normalDotEye = dot(relfNormal, normalfragpos0);
float fresnel = pow(clamp(1.0 + normalDotEye,0.0,1.0), 4.0);
fresnel = mix(0.09,1.0,fresnel); //F0
vec3 sky_c = fogC*metallicSky;
vec4 reflection = raytrace(fragpos0.xyz, sky_c, reflectedVector);
reflection.rgb = mix(sky_c, reflection.rgb, reflection.a)*0.5;
c = mix(c,reflection.rgb,fresnel*metalStrength);
}
#endif
if (transparency) {
vec3 normal = texture2D(colortex2,texcoord).xyz;
float sky = normal.z;
bool reflectiveWater = sky < 0.2499 && dot(normal,normal) > 0.0;
bool reflectiveIce = sky > 0.2499 && sky < 0.4999 && dot(normal,normal) > 0.0;
bool iswater = sky < 0.2499;
bool isice = sky > 0.2499 && sky < 0.4999;
if (iswater) sky *= 4.0;
if (isice) sky = (sky - 0.25)*4.0;
if (!iswater && !isice) sky = (sky - 0.5)*4.0;
sky = clamp(sky*1.2-2./16.0*1.2,0.,1.0);
sky *= sky;
normal = decode(normal.xy);
normal = normalize(normal);
//draw fog for transparency
float iswater2 = float(iswater);
//c = mix(c, fogC, 1.0-exp(-length(fragpos1.xyz)*(0.0075+(screenBrightness*0.001))));
if(depth1 < comp)c = mix(fogC, c, exp(-exp2(length(fragpos1.xyz) / far * 16.0 - 14.0)));
//Draw transparency
vec3 finalAc = texture2D(gaux2, texcoord.xy).rgb;
float alphaT = clamp(length(trp.rgb)*1.02,0.0,1.0);
c = mix(c,c*(trp.rgb*0.9999+0.0001)*1.732,alphaT)*(1.0-alphaT) + finalAc;
/*-----------------------------------------------------------------------------------------*/
//Reflections
if (reflectiveWater || reflectiveIce) {
vec3 reflectedVector = reflect(normalfragpos1, normal);
vec3 hV= normalize(reflectedVector - normalfragpos1);
float normalDotEye = dot(hV, normalfragpos1);
float F0 = 0.09;
float fresnel = pow(clamp(1.0 + normalDotEye,0.0,1.0), 4.0) ;
fresnel = fresnel+F0*(1.0-fresnel);
vec3 sky_c = fogC*0.5; //Use fogC as our custom sky reflections
#if defined waterRefl || defined iceRefl
vec4 reflection = raytrace(fragpos0.xyz, sky_c, reflectedVector);
#else
vec4 reflection = vec4(0.0);
fresnel *= 0.5;
#endif
reflection.rgb = mix(sky_c, reflection.rgb, reflection.a)*0.5;
#ifdef IceGlassReflections
fresnel *= 0.5*float(isice) + 0.5*iswater2;
#else
fresnel *= 1.0*iswater2;
#endif
c = mix(c,reflection.rgb,fresnel*1.5);
}
}
#ifdef Fog
if(depth0 < comp)c = mix(c, fogC*(1.0-isEyeInWater), 1.0-exp(-length(fragpos0.xyz)*(0.0075+(screenBrightness*0.001)))); //scale with screenbrightness
if(depth0 < comp)c = mix(fogC, c, exp(-exp2(length(fragpos0.xyz) / far * 16.0 - 14.0)));
#endif
#ifdef Underwater_Fog
vec3 ufogC = vec3(0.0, 0.005, 0.0125);
if (isEyeInWater == 1.0) c = mix(c, ufogC, 1.0-exp(-length(fragpos0.xyz)/uFogDensity));
#endif
if (isEyeInWater == 2.0) c = mix(c, vec3(1.0, 0.0125, 0.0), 1.0-exp(-length(fragpos0.xyz))); //lava fog
if(blindness > 0.9) c = mix(c, vec3(0.0), 1.0-exp(-length(fragpos1.xyz)*1.125)); //blindness fog
#if MC_VERSION >= 11900
if(darknessFactor > 0.9) c = mix(c, vec3(0.0), 1.0-exp(-length(fragpos1.xyz)*0.125)) * (1.0-darknessLightFactor*2.0); //Darkness fog, adjust for end.
#endif
c *= 0.142;
gl_FragData[0] = vec4(c,1.0);
}

View File

@@ -0,0 +1,8 @@
#version 120
varying vec2 texcoord;
void main() {
gl_Position = ftransform();
texcoord = (gl_MultiTexCoord0).xy;
}

View File

@@ -0,0 +1,145 @@
#version 120
/* DRAWBUFFERS:7 */
/* Temporal anti-aliasing (TAA) and adaptive sharpening implementation based on Chocapic13, all credits belong to him:
https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/minecraft-mods/1293898-1-14-chocapic13s-shaders */
#define composite2
#include "/shaders.settings"
varying vec2 texcoord;
uniform sampler2D composite; //everything from composite1
#ifdef TAA
const bool gaux4Clear = false;
uniform sampler2D gaux4; //composite, TAA mixed with everything
uniform sampler2D depthtex0;
/*
uniform sampler2D gcolor;
uniform sampler2D gnormal;
uniform float near;
uniform float far;
*/
uniform float viewWidth;
uniform float viewHeight;
vec2 texelSize = vec2(1.0/viewWidth,1.0/viewHeight);
uniform mat4 gbufferProjectionInverse;
uniform mat4 gbufferModelViewInverse;
uniform mat4 gbufferPreviousProjection;
uniform mat4 gbufferPreviousModelView;
uniform vec3 cameraPosition;
uniform vec3 previousCameraPosition;
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz)
vec3 toClipSpace3Prev(vec3 viewSpacePosition) {
return projMAD(gbufferPreviousProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5;
}
vec3 toScreenSpace(vec3 p) {
vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw);
vec3 p3 = p * 2.0 - 1.0;
vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3];
return fragposition.xyz / fragposition.w;
}
//approximation from SMAA presentation from siggraph 2016
vec3 FastCatmulRom(sampler2D colorTex, vec2 texcoord, vec4 rtMetrics, float sharpenAmount){
vec2 position = rtMetrics.zw * texcoord;
vec2 centerPosition = floor(position - 0.5) + 0.5;
vec2 f = position - centerPosition;
vec2 f2 = f * f;
vec2 f3 = f * f2;
float c = sharpenAmount;
vec2 w0 = -c * f3 + 2.0 * c * f2 - c * f;
vec2 w1 = (2.0 - c) * f3 - (3.0 - c) * f2 + 1.0;
vec2 w2 = -(2.0 - c) * f3 + (3.0 - 2.0 * c) * f2 + c * f;
vec2 w3 = c * f3 - c * f2;
vec2 w12 = w1 + w2;
vec2 tc12 = rtMetrics.xy * (centerPosition + w2 / w12);
vec3 centerColor = texture2D(colorTex, vec2(tc12.x, tc12.y)).rgb;
vec2 tc0 = rtMetrics.xy * (centerPosition - 1.0);
vec2 tc3 = rtMetrics.xy * (centerPosition + 2.0);
vec4 color = vec4(texture2D(colorTex, vec2(tc12.x, tc0.y )).rgb, 1.0) * (w12.x * w0.y ) +
vec4(texture2D(colorTex, vec2(tc0.x, tc12.y)).rgb, 1.0) * (w0.x * w12.y) +
vec4(centerColor, 1.0) * (w12.x * w12.y) +
vec4(texture2D(colorTex, vec2(tc3.x, tc12.y)).rgb, 1.0) * (w3.x * w12.y) +
vec4(texture2D(colorTex, vec2(tc12.x, tc3.y )).rgb, 1.0) * (w12.x * w3.y );
return color.rgb/color.a;
}
vec3 calcTAA(){
//reproject previous frame
float depth0 = texture2D(depthtex0,texcoord).x;
vec3 closestToCamera = vec3(texcoord,depth0);
vec3 fragposition = toScreenSpace(closestToCamera);
fragposition = mat3(gbufferModelViewInverse) * fragposition + gbufferModelViewInverse[3].xyz + (cameraPosition - previousCameraPosition);
vec3 previousPosition = mat3(gbufferPreviousModelView) * fragposition + gbufferPreviousModelView[3].xyz;
previousPosition = toClipSpace3Prev(previousPosition);
previousPosition.xy = texcoord + (previousPosition.xy - closestToCamera.xy);
//to reduce error propagation caused by interpolation during history resampling, we will introduce back some aliasing in motion
vec2 d = 0.5-abs(fract(previousPosition.xy*vec2(viewWidth,viewHeight)-texcoord*vec2(viewWidth,viewHeight))-0.5);
float rej = dot(d,d)*0.5;
//reject history if off-screen and early exit
if (previousPosition.x < 0.0 || previousPosition.y < 0.0 || previousPosition.x > 1.0 || previousPosition.y > 1.0) return texture2D(composite, texcoord).rgb;
//Samples current frame 3x3 neighboorhood
vec3 albedoCurrent0 = texture2D(composite, texcoord).rgb;
vec3 albedoCurrent1 = texture2D(composite, texcoord + vec2(texelSize.x,texelSize.y)).rgb;
vec3 albedoCurrent2 = texture2D(composite, texcoord + vec2(texelSize.x,-texelSize.y)).rgb;
vec3 albedoCurrent3 = texture2D(composite, texcoord + vec2(-texelSize.x,-texelSize.y)).rgb;
vec3 albedoCurrent4 = texture2D(composite, texcoord + vec2(-texelSize.x,texelSize.y)).rgb;
vec3 albedoCurrent5 = texture2D(composite, texcoord + vec2(0.0,texelSize.y)).rgb;
vec3 albedoCurrent6 = texture2D(composite, texcoord + vec2(0.0,-texelSize.y)).rgb;
vec3 albedoCurrent7 = texture2D(composite, texcoord + vec2(-texelSize.x,0.0)).rgb;
vec3 albedoCurrent8 = texture2D(composite, texcoord + vec2(texelSize.x,0.0)).rgb;
/*
float getmat = texture2D(gcolor,texcoord).b;
bool emissive = getmat > 0.59 && getmat < 0.61;
vec3 normal = texture2D(gnormal,texcoord).xyz;
bool iswater = normal.z < 0.2499 && dot(normal,normal) > 0.0;
if(!iswater && !emissive && depth0 < 1.0-near/far/far){ //don't sharpen emissive blocks, water and sky, clouds
vec3 m1 = (albedoCurrent0 + albedoCurrent1 + albedoCurrent2 + albedoCurrent3 + albedoCurrent4 + albedoCurrent5 + albedoCurrent6 + albedoCurrent7 + albedoCurrent8)/9.0;
vec3 std = abs(albedoCurrent0 - m1) + abs(albedoCurrent1 - m1) + abs(albedoCurrent2 - m1) + abs(albedoCurrent3 - m1) + abs(albedoCurrent3 - m1) +
abs(albedoCurrent4 - m1) + abs(albedoCurrent5 - m1) + abs(albedoCurrent6 - m1) + abs(albedoCurrent7 - m1) + abs(albedoCurrent8 - m1);
float contrast = 1.0 - dot(std,vec3(0.299, 0.587, 0.114))/9.0;
albedoCurrent0 = albedoCurrent0*(1.0+AS_sharpening*contrast)-(albedoCurrent5+albedoCurrent6+albedoCurrent7+albedoCurrent8+(albedoCurrent1 + albedoCurrent2 + albedoCurrent3 + albedoCurrent4)/2.0)/6.0*AS_sharpening*contrast;
}
*/
//Assuming the history color is a blend of the 3x3 neighborhood, we clamp the history to the min and max of each channel in the 3x3 neighborhood
vec3 cMax = max(max(max(albedoCurrent0,albedoCurrent1),albedoCurrent2),max(albedoCurrent3,max(albedoCurrent4,max(albedoCurrent5,max(albedoCurrent6,max(albedoCurrent7,albedoCurrent8))))));
vec3 cMin = min(min(min(albedoCurrent0,albedoCurrent1),albedoCurrent2),min(albedoCurrent3,min(albedoCurrent4,min(albedoCurrent5,min(albedoCurrent6,min(albedoCurrent7,albedoCurrent8))))));
vec3 albedoPrev = FastCatmulRom(gaux4, previousPosition.xy,vec4(texelSize, 1.0/texelSize), 0.82).xyz;
vec3 finalcAcc = clamp(albedoPrev,cMin,cMax);
//increases blending factor if history is far away from aabb, reduces ghosting at the cost of some flickering
float luma = dot(albedoPrev,vec3(0.21, 0.72, 0.07));
float isclamped = distance(albedoPrev,finalcAcc)/luma;
//reduces blending factor if current texel is far from history, reduces flickering
float lumDiff2 = distance(albedoPrev,albedoCurrent0)/luma;
lumDiff2 = 1.0-clamp(lumDiff2*lumDiff2,0.0,1.0)*0.75;
//Blend current pixel with clamped history
return mix(finalcAcc,albedoCurrent0,clamp(0.1*lumDiff2+rej+isclamped+0.01,0.0,1.0));
}
#endif
void main() {
#ifdef TAA
gl_FragData[0] = vec4(calcTAA(), 1.0);
#else
gl_FragData[0] = texture2D(composite, texcoord); //if TAA is disabled just passthrough data from composite0, previous buffer.
#endif
}

View File

@@ -0,0 +1,8 @@
#version 120
varying vec2 texcoord;
void main() {
gl_Position = ftransform();
texcoord = gl_MultiTexCoord0.xy;
}

View File

@@ -0,0 +1,42 @@
#version 120
/* DRAWBUFFERS:6 */
//overwrite buffer 6, final image is buffer 7
//This buffer is scaled down, defined in shaders.properties, it's faster than texcoord scaling
#define Bloom
#define composite3
#include "/shaders.settings"
#ifdef Bloom
varying vec2 texcoord;
uniform sampler2D colortex7; //read buffer 7, TAA+everything
uniform float viewWidth;
uniform float viewHeight;
const bool colortex7MipmapEnabled = true;
#endif
void main() {
#ifdef Bloom
const int nSteps = 25;
const int center = 12; //=nSteps-1 / 2
vec3 blur = vec3(0.0);
float tw = 0.0;
for (int i = 0; i < nSteps; i++) {
float dist = abs(i-float(center))/center;
float weight = (exp(-(dist*dist)/ 0.28));
vec3 bsample = texture2D(colortex7,(texcoord*4.0 + 2.0*vec2(1.0/viewWidth,1.0/viewHeight)*vec2(i-center,0.0))).rgb;
blur += bsample*weight;
tw += weight;
}
blur /= tw;
blur = clamp(blur,0.0,1.0); //fix flashing black square
gl_FragData[0] = vec4(blur, 1.0);
#else
gl_FragData[0] = vec4(0.0);
#endif
}

View File

@@ -0,0 +1,8 @@
#version 120
varying vec2 texcoord;
void main() {
gl_Position = ftransform();
texcoord = gl_MultiTexCoord0.xy;
}

View File

@@ -0,0 +1,50 @@
#version 120
/* DRAWBUFFERS:6 */
//overwrite buffer 6, final image is buffer 7
#define Bloom
#define bloom_strength 0.75
#define composite4
#include "/shaders.settings"
#ifdef Bloom
varying vec2 texcoord;
varying float eyeAdapt;
uniform sampler2D colortex6;
uniform int isEyeInWater;
uniform float rainStrength;
uniform float viewWidth;
uniform float viewHeight;
#endif
void main() {
#ifdef Bloom
const int nSteps = 17;
const int center = 8; //=nSteps-1 / 2
//huge gaussian blur for glare
vec3 blur = vec3(0.0);
float tw = 0.0;
for (int i = 0; i < nSteps; i++) {
float dist = abs(i-float(center))/center;
float weight = (exp(-(dist*dist)/ 0.28));
vec3 bsample = texture2D(colortex6,(texcoord.xy + vec2(1.0/viewWidth,1.0/viewHeight)*vec2(0.0,i-center))).rgb*3.0;
blur += bsample*weight;
tw += weight;
}
blur /= tw;
vec3 glow = blur * bloom_strength;
vec3 overglow = glow*pow(length(glow)*2.0,2.8)*2.0;
vec3 finalColor = (overglow+glow*1.15)*(1+isEyeInWater*10.0+(pow(rainStrength,3.0)*7.0/pow(eyeAdapt,1.0)))*1.2;
gl_FragData[0] = vec4(finalColor, 1.0);
#else
gl_FragData[0] = vec4(0.0);
#endif
}

View File

@@ -0,0 +1,77 @@
#version 120
#define Bloom
#define composite3 //it's composite4 but we don't need the extra define so use 3 instead
#include "/shaders.settings"
#ifdef Bloom
varying vec2 texcoord;
varying float eyeAdapt;
uniform vec3 sunPosition;
uniform vec3 upPosition;
uniform ivec2 eyeBrightnessSmooth;
uniform int worldTime;
uniform float rainStrength;
uniform float frameTimeCounter;
const vec3 ToD[7] = vec3[7]( vec3(0.58597,0.16,0.025),
vec3(0.58597,0.4,0.2),
vec3(0.58597,0.52344,0.24680),
vec3(0.58597,0.55422,0.34),
vec3(0.58597,0.57954,0.38),
vec3(0.58597,0.58,0.40),
vec3(0.58597,0.58,0.40));
float luma(vec3 color) {
return dot(color,vec3(0.299, 0.587, 0.114));
}
#endif
void main() {
gl_Position = ftransform();
#ifdef Bloom
texcoord = (gl_MultiTexCoord0).xy;
//Sun/Moon position
vec3 sunVec = normalize(sunPosition);
vec3 upVec = vec3(0.0, 1.0, 0.0); //fix for loading shaderpacks in nether and end, optifine bug.
float SdotU = dot(sunVec,upVec);
float sunVisibility = pow(clamp(SdotU+0.15,0.0,0.15)/0.15,4.0);
float moonVisibility = pow(clamp(-SdotU+0.15,0.0,0.15)/0.15,4.0);
/*--------------------------------*/
//reduced the sun color to a 7 array
float hour = max(mod(worldTime/1000.0+2.0,24.0)-2.0,0.0); //-0.1
float cmpH = max(-abs(floor(hour)-6.0)+6.0,0.0); //12
float cmpH1 = max(-abs(floor(hour)-5.0)+6.0,0.0); //1
vec3 temp = ToD[int(cmpH)];
vec3 temp2 = ToD[int(cmpH1)];
vec3 sunlight = mix(temp,temp2,fract(hour));
/*--------------------------------*/
//Lighting
float eyebright = max(eyeBrightnessSmooth.y/255.0-0.5/16.0,0.0)*1.03225806452;
float SkyL2 = mix(1.0,eyebright*eyebright,eyebright);
vec2 trCalc = min(abs(worldTime-vec2(23250.0,12700.0)),750.0);
float tr = max(min(trCalc.x,trCalc.y)/375.0-1.0,0.0);
vec4 bounced = vec4(0.5*SkyL2,0.66*SkyL2,0.7,0.3);
vec3 sun_ambient = bounced.w * (vec3(0.25,0.62,1.32)-rainStrength*vec3(0.11,0.32,1.07)) + sunlight*(bounced.x + bounced.z);
const vec3 moonlight = vec3(0.0035, 0.0063, 0.0098);
vec3 avgAmbient =(sun_ambient*sunVisibility + moonlight*moonVisibility)*eyebright*eyebright*(0.05+tr*0.15)*4.7+0.0006;
eyeAdapt = log(clamp(luma(avgAmbient),0.007,80.0))/log(2.6)*0.35;
eyeAdapt = 1.0/pow(2.6,eyeAdapt)*1.75;
#endif
}

278
shaders/world1/final.fsh Normal file
View File

@@ -0,0 +1,278 @@
#version 120
#define final
#include "/shaders.settings"
varying vec2 texcoord;
uniform sampler2D gaux4; //final image
#ifdef Bloom
uniform sampler2D colortex6; //overwritten by bloom
#endif
#if Showbuffer > 0
uniform sampler2D colortex0;
uniform sampler2D colortex1;
uniform sampler2D colortex2;
uniform sampler2D colortex3;
uniform sampler2D gaux1;
uniform sampler2D gaux2;
uniform sampler2D gaux3;
#endif
uniform int isEyeInWater;
uniform float aspectRatio;
uniform float viewWidth;
uniform float viewHeight;
uniform float rainStrength;
uniform float frameTimeCounter;
#if defined Depth_of_Field || defined Motionblur
uniform sampler2D depthtex0;
uniform sampler2D depthtex1;
uniform sampler2D depthtex2;
#endif
#ifdef Motionblur
uniform vec3 cameraPosition;
uniform vec3 previousCameraPosition;
uniform mat4 gbufferProjection;
uniform mat4 gbufferProjectionInverse;
uniform mat4 gbufferPreviousProjection;
uniform mat4 gbufferModelViewInverse;
uniform mat4 gbufferPreviousModelView;
#endif
#if defined Depth_of_Field
uniform float near;
uniform float far;
float ld(float depth) {
return (2.0 * near) / (far + near - depth * (far - near));
}
#endif
#ifdef Depth_of_Field
//Dof constant values
const float focal = 0.024;
float aperture = 0.008;
const float sizemult = DoF_Strength;
uniform float centerDepthSmooth;
const float centerDepthHalflife = 2.0f;
//hexagon pattern
const vec2 hex_offsets[60] = vec2[60] ( vec2( 0.2165, 0.1250 ),
vec2( 0.0000, 0.2500 ),
vec2( -0.2165, 0.1250 ),
vec2( -0.2165, -0.1250 ),
vec2( -0.0000, -0.2500 ),
vec2( 0.2165, -0.1250 ),
vec2( 0.4330, 0.2500 ),
vec2( 0.0000, 0.5000 ),
vec2( -0.4330, 0.2500 ),
vec2( -0.4330, -0.2500 ),
vec2( -0.0000, -0.5000 ),
vec2( 0.4330, -0.2500 ),
vec2( 0.6495, 0.3750 ),
vec2( 0.0000, 0.7500 ),
vec2( -0.6495, 0.3750 ),
vec2( -0.6495, -0.3750 ),
vec2( -0.0000, -0.7500 ),
vec2( 0.6495, -0.3750 ),
vec2( 0.8660, 0.5000 ),
vec2( 0.0000, 1.0000 ),
vec2( -0.8660, 0.5000 ),
vec2( -0.8660, -0.5000 ),
vec2( -0.0000, -1.0000 ),
vec2( 0.8660, -0.5000 ),
vec2( 0.2163, 0.3754 ),
vec2( -0.2170, 0.3750 ),
vec2( -0.4333, -0.0004 ),
vec2( -0.2163, -0.3754 ),
vec2( 0.2170, -0.3750 ),
vec2( 0.4333, 0.0004 ),
vec2( 0.4328, 0.5004 ),
vec2( -0.2170, 0.6250 ),
vec2( -0.6498, 0.1246 ),
vec2( -0.4328, -0.5004 ),
vec2( 0.2170, -0.6250 ),
vec2( 0.6498, -0.1246 ),
vec2( 0.6493, 0.6254 ),
vec2( -0.2170, 0.8750 ),
vec2( -0.8663, 0.2496 ),
vec2( -0.6493, -0.6254 ),
vec2( 0.2170, -0.8750 ),
vec2( 0.8663, -0.2496 ),
vec2( 0.2160, 0.6259 ),
vec2( -0.4340, 0.5000 ),
vec2( -0.6500, -0.1259 ),
vec2( -0.2160, -0.6259 ),
vec2( 0.4340, -0.5000 ),
vec2( 0.6500, 0.1259 ),
vec2( 0.4325, 0.7509 ),
vec2( -0.4340, 0.7500 ),
vec2( -0.8665, -0.0009 ),
vec2( -0.4325, -0.7509 ),
vec2( 0.4340, -0.7500 ),
vec2( 0.8665, 0.0009 ),
vec2( 0.2158, 0.8763 ),
vec2( -0.6510, 0.6250 ),
vec2( -0.8668, -0.2513 ),
vec2( -0.2158, -0.8763 ),
vec2( 0.6510, -0.6250 ),
vec2( 0.8668, 0.2513 ));
#endif
vec3 Uncharted2Tonemap(vec3 x) {
x*= Brightness;
float A = 0.28;
float B = 0.29;
float C = 0.10;
float D = 0.2;
float E = 0.025;
float F = 0.35;
return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;
}
#if Showbuffer == 1 || Showbuffer == 2 || Showbuffer == 3
vec3 decode (vec2 enc){
vec2 fenc = enc*4-2;
float f = dot(fenc,fenc);
float g = sqrt(1-f/4.0);
vec3 n;
n.xy = fenc*g;
n.z = 1-f/2;
return n;
}
vec3 YCoCg2RGB(vec3 c){
c.y-=0.5;
c.z-=0.5;
return vec3(c.r+c.g-c.b, c.r + c.b, c.r - c.g - c.b);
}
#endif
void main() {
#if defined Depth_of_Field || defined Motionblur
//Setup depths, do it here because amd drivers suck and texture reads outside of void main or functions are broken, thanks amd
float depth0 = texture2D(depthtex0, texcoord).x;
float depth1 = texture2D(depthtex1, texcoord).x;
float depth2 = texture2D(depthtex2, texcoord).x;
bool hand = (depth0 < depth1) || !(depth0 < depth2);
#endif
float rainlens = 0.0;
vec2 fake_refract = vec2(0.0);
#ifdef Refraction
fake_refract = vec2(sin(frameTimeCounter + texcoord.x*100.0 + texcoord.y*50.0),cos(frameTimeCounter + texcoord.y*100.0 + texcoord.x*50.0));
#endif
vec2 newTC = clamp(texcoord + fake_refract * 0.01 * (rainlens+isEyeInWater*0.2),1.0/vec2(viewWidth,viewHeight),1.0-1.0/vec2(viewWidth,viewHeight));
vec3 color = texture2D(gaux4, newTC.xy).rgb*50.0;
#ifdef Depth_of_Field
if(hand){
float pw = 1.0/ viewWidth;
float z = ld(texture2D(depthtex0, newTC.st).r)*far;
#ifdef smoothDof
float focus = ld(centerDepthSmooth)*far;
#else
float focus = ld(texture2D(depthtex0, vec2(0.5)).r)*far;
#endif
float pcoc = min(abs(aperture * (focal * (z - focus)) / (z * (focus - focal)))*sizemult,pw*15.0);
#ifdef Distance_Blur
float getdist = 1-(exp(-pow(ld(texture2D(depthtex1, newTC.st).r)/Dof_Distance_View*far,4.0-(2.7*rainStrength))*4.0));
pcoc = min(getdist*pw*20.0,pw*20.0);
#endif
vec3 bcolor = vec3(0.0);
for ( int i = 0; i < 60; i++) {
bcolor += texture2D(gaux4, newTC.xy + hex_offsets[i]*pcoc*vec2(1.0,aspectRatio)).rgb;
}
color.rgb = bcolor/61.0*50.0;
}
#endif
#ifdef Motionblur
if(hand){
vec4 currentPosition = vec4(texcoord, depth1, 1.0)*2.0-1.0;
vec4 fragposition = gbufferProjectionInverse * currentPosition;
fragposition = gbufferModelViewInverse * fragposition;
fragposition /= fragposition.w;
fragposition.xyz += cameraPosition;
vec4 previousPosition = fragposition;
previousPosition.xyz -= previousCameraPosition;
previousPosition = gbufferPreviousModelView * previousPosition;
previousPosition = gbufferPreviousProjection * previousPosition;
previousPosition /= previousPosition.w;
vec2 velocity = (currentPosition - previousPosition).st * MB_strength;
vec2 coord = texcoord.st + velocity;
int mb = 1;
for (int i = 0; i < 15; ++i, coord += velocity) {
if (coord.s > 1.0 || coord.t > 1.0 || coord.s < 0.0 || coord.t < 0.0) break;
color += texture2D(gaux4, coord).xyz*50.0;
++mb;
}
color /= mb;
}
#endif
#ifdef Bloom
color.rgb += texture2D(colortex6, texcoord.xy*0.25).rgb; //upscale bloom buffer.
#endif
color.rgb += rainlens*0.01; //draw rainlens
vec3 curr = Uncharted2Tonemap(color*4.7);
color = pow(curr/Uncharted2Tonemap(vec3(15.2)),vec3(1.0/Contrast));
#if Showbuffer == 1
color = vec3(texture2D(colortex0,texcoord).rg,0.0);
vec2 a0 = texture2D(colortex0,texcoord + vec2(1.0/viewWidth,0.0)).rg;
vec2 a1 = texture2D(colortex0,texcoord - vec2(1.0/viewWidth,0.0)).rg;
vec2 a2 = texture2D(colortex0,texcoord + vec2(0.0,1.0/viewHeight)).rg;
vec2 a3 = texture2D(colortex0,texcoord - vec2(0.0,1.0/viewHeight)).rg;
vec4 lumas = vec4(a0.x,a1.x,a2.x,a3.x);
vec4 chromas = vec4(a0.y,a1.y,a2.y,a3.y);
vec4 w = 1.0-step(0.1176, abs(lumas - color.x));
float W = dot(w,vec4(1.0));
w.x = (W==0.0)? 1.0:w.x; W = (W==0.0)? 1.0:W;
bool pattern = (mod(gl_FragCoord.x,2.0)==mod(gl_FragCoord.y,2.0));
color.b= dot(w,chromas)/W;
color.rgb = (pattern)?color.rbg:color.rgb;
color.rgb = YCoCg2RGB(color.rgb);
color = pow(color,vec3(2.2));
#endif
#if Showbuffer == 2
color = decode(texture2D(colortex1, texcoord).xy);
#endif
#if Showbuffer == 25
color = vec3(0.0, texture2D(colortex1, texcoord.xy).zw); //lightmap
#endif
#if Showbuffer == 3
color = decode(texture2D(colortex2, texcoord).xy);
#endif
#if Showbuffer == 35
color = vec3(0.0, texture2D(colortex2, texcoord.xy).zw); //lightmap
#endif
#if Showbuffer == 4
color = texture2D(colortex3, texcoord.xy).rgb * 200.0;
#endif
#if Showbuffer == 5
color = texture2D(gaux1, texcoord.xy).rgb * 25.0;
#endif
#if Showbuffer == 6
color = texture2D(gaux2, texcoord.xy).rgb * 25.0;
#endif
#if Showbuffer == 7
color = texture2D(gaux3, texcoord.xy*0.25).rgb * 25.0;
#endif
#if Showbuffer == 8
color = texture2D(gaux4, texcoord.xy).rgb * 50.0;
#endif
gl_FragColor = vec4(color,1.0);
}

8
shaders/world1/final.vsh Normal file
View File

@@ -0,0 +1,8 @@
#version 120
varying vec2 texcoord;
void main() {
gl_Position = ftransform();
texcoord = (gl_MultiTexCoord0).xy;
}

View File

@@ -0,0 +1,28 @@
#version 120
/* DRAWBUFFERS:5 */
uniform sampler2D texture;
varying vec4 color;
varying vec2 texcoord;
uniform int worldTime;
uniform ivec2 eyeBrightnessSmooth;
uniform float rainStrength;
float night = clamp((worldTime-13000.0)/300.0,0.0,1.0)-clamp((worldTime-22800.0)/200.0,0.0,1.0);
float cavelight = pow(eyeBrightnessSmooth.y / 255.0, 6.0f) * 1.0 + (0.7 + 0.5*night);
void main() {
vec4 albedo = texture2D(texture, texcoord.st)*color;
//Fix minecrafts way of handling enchanted effects and turn it into a somewhat consistent effect across day/night/cave/raining
vec3 lighting = vec3(1.0+ (0.4*rainStrength - 0.4*rainStrength*night));
lighting /= 0.8 - 0.5*night;
lighting /= cavelight;
albedo.rgb = pow(albedo.rgb*0.33, lighting);
gl_FragData[0] = albedo;
}

View File

@@ -0,0 +1,37 @@
#version 120
varying vec4 color;
varying vec2 texcoord;
uniform mat4 gbufferModelView;
uniform mat4 gbufferModelViewInverse;
#define composite2
#include "/shaders.settings"
#ifdef TAA
uniform float viewWidth;
uniform float viewHeight;
vec2 texelSize = vec2(1.0/viewWidth,1.0/viewHeight);
uniform int framemod8;
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-1.,3.)/8.,
vec2(5.0,1.)/8.,
vec2(-3,-5.)/8.,
vec2(-5.,5.)/8.,
vec2(-7.,-1.)/8.,
vec2(3,7.)/8.,
vec2(7.,-7.)/8.);
#endif
void main() {
vec4 position = gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex;
gl_Position = gl_ProjectionMatrix * gbufferModelView * position;
#ifdef TAA
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
#endif
color = gl_Color;
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).st;
}

View File

@@ -0,0 +1,30 @@
#version 120
/* DRAWBUFFERS:0 */ //01 breaks selection box color but fixes leads
varying vec4 color;
varying vec4 texcoord;
varying vec3 normal;
uniform sampler2D texture;
//encode normal in two channel (xy),torch and material(z) and sky lightmap (w)
vec4 encode (vec3 n){
float p = sqrt(n.z*8+8);
return vec4(n.xy/p + 0.5,texcoord.z,texcoord.w);
}
vec3 RGB2YCoCg(vec3 c){
return vec3( 0.25*c.r+0.5*c.g+0.25*c.b, 0.5*c.r-0.5*c.b +0.5, -0.25*c.r+0.5*c.g-0.25*c.b +0.5);
}
void main() {
vec4 cAlbedo = vec4(RGB2YCoCg(color.rgb),color.a);
bool pattern = (mod(gl_FragCoord.x,2.0)==mod(gl_FragCoord.y,2.0));
cAlbedo.g = (pattern)?cAlbedo.b: cAlbedo.g;
cAlbedo.b = 1.0;
gl_FragData[0] = cAlbedo;
gl_FragData[1] = encode(normal.xyz);
}

View File

@@ -0,0 +1,17 @@
#version 120
varying vec4 color;
varying vec4 texcoord;
varying vec3 normal;
void main() {
gl_Position = ftransform();
color = gl_Color;
texcoord = vec4((gl_MultiTexCoord0).xy,(gl_TextureMatrix[1] * gl_MultiTexCoord1).xy);
normal = normalize(gl_NormalMatrix * gl_Normal);
gl_FogFragCoord = gl_Position.z;
}

View File

@@ -0,0 +1,26 @@
#version 120
/* DRAWBUFFERS:56 */
//Render hand, entities and particles in here, boost and fix enchanted armor effect in gbuffers_armor_glint
#define gbuffers_texturedblock
#include "/shaders.settings"
varying vec4 color;
varying vec2 texcoord;
varying vec3 ambientNdotL;
uniform sampler2D texture;
uniform vec4 entityColor;
void main() {
vec4 albedo = texture2D(texture, texcoord.xy)*color;
#ifdef MobsFlashRed
albedo.rgb = mix(albedo.rgb,entityColor.rgb,entityColor.a);
#endif
vec3 finalColor = pow(albedo.rgb,vec3(2.2)) * ambientNdotL.rgb;
gl_FragData[0] = vec4(finalColor, albedo.a);
gl_FragData[1] = vec4(normalize(albedo.rgb+0.00001), albedo.a);
}

View File

@@ -0,0 +1,105 @@
#version 120
#define composite2
#define gbuffers_texturedblock
#define lightingColors
#include "/shaders.settings"
varying vec4 color;
varying vec2 texcoord;
varying vec3 ambientNdotL;
uniform vec3 sunPosition;
uniform vec3 upPosition;
uniform int worldTime;
uniform float rainStrength;
uniform float nightVision;
uniform float screenBrightness;
const vec3 ToD[7] = vec3[7]( vec3(0.58597,0.15,0.02),
vec3(0.58597,0.35,0.09),
vec3(0.58597,0.5,0.26),
vec3(0.58597,0.5,0.35),
vec3(0.58597,0.5,0.36),
vec3(0.58597,0.5,0.37),
vec3(0.58597,0.5,0.38));
#ifdef TAA
uniform float viewWidth;
uniform float viewHeight;
vec2 texelSize = vec2(1.0/viewWidth,1.0/viewHeight);
uniform int framemod8;
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-1.,3.)/8.,
vec2(5.0,1.)/8.,
vec2(-3,-5.)/8.,
vec2(-5.,5.)/8.,
vec2(-7.,-1.)/8.,
vec2(3,7.)/8.,
vec2(7.,-7.)/8.);
#endif
void main() {
//setup basics
color = gl_Color;
gl_Position = ftransform();
#ifdef TAA
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
#endif
vec3 normal = normalize(gl_NormalMatrix * gl_Normal);
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
vec2 lmcoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
/*--------------------------------*/
//Emissive blocks lighting in order to fix lighting on particles
float torch_lightmap = 16.0-min(15.,(lmcoord.s-0.5/16.)*16.*16./15);
float fallof1 = clamp(1.0 - pow(torch_lightmap/16.0,4.0),0.0,1.0);
torch_lightmap = fallof1*fallof1/(torch_lightmap*torch_lightmap+1.0);
vec3 emissiveLightC = vec3(emissive_R,emissive_G,emissive_B)*torch_lightmap;
float finalminlight = (nightVision > 0.01)? 0.025 : ((minlight+0.006)+(screenBrightness*0.0125))*0.5;
/*---------------------------------------------------------------------*/
//reduced the sun color to a 7 array
float hour = max(mod(worldTime/1000.0+2.0,24.0)-2.0,0.0); //-0.1
float cmpH = max(-abs(floor(hour)-6.0)+6.0,0.0); //12
float cmpH1 = max(-abs(floor(hour)-5.0)+6.0,0.0); //1
vec3 temp = ToD[int(cmpH)];
vec3 temp2 = ToD[int(cmpH1)];
vec3 sunlight = mix(temp,temp2,fract(hour));
const vec3 rainC = vec3(0.01,0.01,0.01);
sunlight = mix(sunlight,rainC*sunlight,rainStrength);
/*-------------------------------------------------------------------*/
const vec3 moonlight = vec3(0.0024, 0.00432, 0.0078);
vec3 sunVec = normalize(sunPosition);
vec3 upVec = vec3(0.0, 1.0, 0.0); //fix for loading shaderpacks in nether and end, optifine bug.
vec2 visibility = vec2(dot(sunVec,upVec),dot(-sunVec,upVec));
float NdotL = dot(normal,sunVec);
float NdotU = dot(normal,upVec);
vec2 trCalc = min(abs(worldTime-vec2(23250.0,12700.0)),750.0);
float tr = max(min(trCalc.x,trCalc.y)/375.0-1.0,0.0);
visibility = pow(clamp(visibility+0.15,0.0,0.15)/0.15,vec2(4.0));
float skyL = max(lmcoord.t-2./16.0,0.0)*1.14285714286;
float SkyL2 = skyL*skyL;
float skyc2 = mix(1.0,SkyL2,skyL);
vec4 bounced = vec4(NdotL,NdotL,NdotL,NdotU) * vec4(-0.14*skyL*skyL,0.34,0.7,0.1) + vec4(0.6,0.66,0.7,0.25);
bounced *= vec4(skyc2,skyc2,visibility.x-tr*visibility.x,0.8);
vec3 sun_ambient = bounced.w * (vec3(0.1, 0.5, 1.1)+rainStrength*vec3(0.05,-0.27,-0.8))*2.3+ 1.7*sunlight*(sqrt(bounced.w)*bounced.x*2.4 + bounced.z)*(1.0-rainStrength*0.98);
vec3 moon_ambient = (moonlight*0.7 + moonlight*bounced.y)*(1.0-rainStrength*0.95)*2.0;
vec3 amb1 = (sun_ambient*visibility.x + moon_ambient*visibility.y)*SkyL2*(0.03+tr*0.17)*0.65;
ambientNdotL.rgb = amb1 + emissiveLightC + finalminlight;
sunlight = mix(sunlight,moonlight*(1.0-rainStrength*0.9),visibility.y)*tr;
}

View File

@@ -0,0 +1,5 @@
#version 120
void main() {
discard;
}

View File

@@ -0,0 +1,5 @@
#version 120
void main() {
gl_Position = ftransform();
}

View File

@@ -0,0 +1,5 @@
#version 120
void main() {
gl_FragData[0] = vec4(0.0, 0.0, 0.0, 1.0); //fill with zeros to avoid issues, alpha has to be set to 1.0 to fix an optifine issue in 1.17+ causing the sky to be black at certain angles.
}

View File

@@ -0,0 +1,5 @@
#version 120
void main() {
gl_Position = ftransform();
}

View File

@@ -0,0 +1,10 @@
#version 120
/* DRAWBUFFERS:3 */
varying vec4 color;
varying vec2 texcoord;
uniform sampler2D texture;
void main() {
gl_FragData[0] = texture2D(texture,texcoord.xy)*color*0.85;
}

View File

@@ -0,0 +1,14 @@
#version 120
varying vec4 color;
varying vec2 texcoord;
void main() {
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
color = gl_Color;
gl_Position = ftransform();
}

View File

@@ -0,0 +1,20 @@
#version 120
/* DRAWBUFFERS:56 */
#define gbuffers_texturedblock
#include "/shaders.settings"
varying vec4 color;
varying vec2 texcoord;
varying vec3 ambientNdotL;
uniform sampler2D texture;
void main() {
vec4 albedo = texture2D(texture, texcoord.xy)*color;
vec3 finalColor = pow(albedo.rgb,vec3(2.2)) * ambientNdotL.rgb;
gl_FragData[0] = vec4(finalColor, albedo.a);
gl_FragData[1] = vec4(normalize(albedo.rgb+0.00001), albedo.a);
}

View File

@@ -0,0 +1,64 @@
#version 120
#define composite2
#define gbuffers_texturedblock
#define lightingColors
#include "/shaders.settings"
varying vec4 color;
varying vec2 texcoord;
varying vec3 ambientNdotL;
uniform vec3 sunPosition;
uniform vec3 upPosition;
uniform int worldTime;
uniform float rainStrength;
uniform float nightVision;
const vec3 ToD[7] = vec3[7]( vec3(0.58597,0.15,0.02),
vec3(0.58597,0.35,0.09),
vec3(0.58597,0.5,0.26),
vec3(0.58597,0.5,0.35),
vec3(0.58597,0.5,0.36),
vec3(0.58597,0.5,0.37),
vec3(0.58597,0.5,0.38));
#ifdef TAA
uniform float viewWidth;
uniform float viewHeight;
vec2 texelSize = vec2(1.0/viewWidth,1.0/viewHeight);
uniform int framemod8;
const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.),
vec2(-1.,3.)/8.,
vec2(5.0,1.)/8.,
vec2(-3,-5.)/8.,
vec2(-5.,5.)/8.,
vec2(-7.,-1.)/8.,
vec2(3,7.)/8.,
vec2(7.,-7.)/8.);
#endif
void main() {
//setup basics
color = gl_Color;
gl_Position = ftransform();
#ifdef TAA
gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize;
#endif
vec3 normal = normalize(gl_NormalMatrix * gl_Normal);
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
vec2 lmcoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
/*--------------------------------*/
//Emissive blocks lighting
float torch_lightmap = 16.0-min(15.,(lmcoord.s-0.5/16.)*16.*16./15);
float fallof1 = clamp(1.0 - pow(torch_lightmap/16.0,4.0),0.0,1.0);
torch_lightmap = fallof1*fallof1/(torch_lightmap*torch_lightmap+1.0);
//vec3 emissiveLightC = vec3(emissive_R,emissive_G,emissive_B)*torch_lightmap;
vec3 emissiveLightC = vec3(0.5, 0.0, 1.0); //purple eyes
float finalminlight = (nightVision > 0.01)? 0.025 : (minlight+0.006)*10.0; //multiply by 10 to improve eye rendering
ambientNdotL.rgb = emissiveLightC + finalminlight;
}

View File

@@ -0,0 +1,135 @@
#version 120
#extension GL_ARB_shader_texture_lod : enable //This extension must always be enabled to prevent issues with amd linux drivers
/* DRAWBUFFERS:01 */
#define gbuffers_terrain
#include "/shaders.settings"
/* Don't remove me
const int colortex0Format = RGBA16;
const int colortex1Format = RGBA16;
const int colortex2Format = RGBA16; //Entities etc
const int colortex3Format = R11F_G11F_B10F;
const int gaux1Format = RGBA16;
const int gaux2Format = R11F_G11F_B10F;
const int gaux3Format = R11F_G11F_B10F;
const int gaux4Format = R11F_G11F_B10F;
-----------------------------------------*/
varying vec4 color;
varying vec4 texcoord;
varying vec4 normal;
varying vec3 worldpos;
varying vec3 viewVector;
varying mat3 tbnMatrix;
uniform sampler2D texture;
uniform sampler2D noisetex;
//encode normal in two channel (xy),torch and material(z) and sky lightmap (w)
vec4 encode (vec3 n){
return vec4(n.xy*inversesqrt(n.z*8.0+8.0) + 0.5, texcoord.zw);
}
vec3 RGB2YCoCg(vec3 c){
return vec3( 0.25*c.r+0.5*c.g+0.25*c.b, 0.5*c.r-0.5*c.b +0.5, -0.25*c.r+0.5*c.g-0.25*c.b +0.5);
}
vec3 newnormal = normal.xyz;
#if nMap >= 1
varying float block;
bool isblock = block > 0.0 || block < 0.0; //workaround for 1.16 bugs on block entities
uniform sampler2D normals;
varying float dist;
varying vec4 vtexcoordam; // .st for add, .pq for mul
varying vec2 vtexcoord;
mat2 mipmap = mat2(dFdx(vtexcoord.xy*vtexcoordam.pq), dFdy(vtexcoord.xy*vtexcoordam.pq));
vec4 readNormal(in vec2 coord){
return texture2DGradARB(normals,fract(coord)*vtexcoordam.pq+vtexcoordam.st,mipmap[0],mipmap[1]);
}
vec4 calcPOM(vec4 albedo){
vec2 newCoord = vtexcoord.xy*vtexcoordam.pq+vtexcoordam.st;
#if nMap == 2
if (dist < POM_DIST && viewVector.z < 0.0 && readNormal(vtexcoord.xy).a < 1.0){
const float res_stepths = 0.33 * POM_RES;
vec2 pstepth = viewVector.xy * POM_DEPTH / (-viewVector.z * POM_RES);
vec2 coord = vtexcoord.xy;
for (int i= 0; i < res_stepths && (readNormal(coord.xy).a < 1.0-float(i)/POM_RES); ++i) coord += pstepth;
newCoord = fract(coord.xy)*vtexcoordam.pq+vtexcoordam.st;
}
#endif
//vec4 specularity = texture2DGradARB(specular, newCoord, dcdx, dcdy);
vec3 bumpMapping = texture2DGradARB(normals, newCoord, mipmap[0],mipmap[1]).rgb*2.0-1.0;
newnormal = normalize(bumpMapping * tbnMatrix);
return albedo = texture2DGradARB(texture, newCoord, mipmap[0],mipmap[1])*color;
}
#endif
#if defined metallicRefl || defined polishedRefl
float calcNoise(vec2 coord){
return sqrt(texture2D(noisetex, vec2(coord.x*1.25, coord.y*1.95)).x) * 0.45;
}
vec3 calcBump(vec2 coord){
const vec2 deltaPos = vec2(0.25, 0.0);
float h0 = calcNoise(coord);
float h1 = calcNoise(coord + deltaPos.xy);
float h2 = calcNoise(coord - deltaPos.xy);
float h3 = calcNoise(coord + deltaPos.yx);
float h4 = calcNoise(coord - deltaPos.yx);
float xDelta = ((h1-h0)+(h0-h2));
float yDelta = ((h3-h0)+(h0-h4));
return vec3(vec2(xDelta,yDelta)*0.2, 0.8); //z = 1.0-0.5
}
vec3 calcParallax(vec3 pos){
float getnoise = calcNoise(pos.xz);
float height = 1.0;
pos.xz += (getnoise * viewVector.xy) * height;
return pos;
}
#endif
void main() {
vec4 albedo = texture2D(texture, texcoord.xy)*color;
#if nMap >= 1
if(isblock)albedo = calcPOM(albedo);
#endif
#if defined metallicRefl || defined polishedRefl
bool isMetallic = normal.a > 0.39 && normal.a < 0.41;
bool isPolished = normal.a > 0.49 && normal.a < 0.51;
#ifndef polishedRefl
isPolished = false;
#endif
#ifndef metallicRefl
isMetallic = false;
#endif
if(isMetallic || isPolished){
vec3 bumpPos = worldpos;
bumpPos = calcParallax(bumpPos);
vec3 bump = calcBump(bumpPos.xy);
newnormal = normalize(bump * tbnMatrix);
}
#endif
vec4 cAlbedo = vec4(RGB2YCoCg(albedo.rgb),albedo.a);
bool pattern = (mod(gl_FragCoord.x,2.0)==mod(gl_FragCoord.y,2.0));
cAlbedo.g = (pattern)?cAlbedo.b: cAlbedo.g;
cAlbedo.b = normal.a;
gl_FragData[0] = cAlbedo;
gl_FragData[1] = encode(newnormal.xyz);
}

Some files were not shown because too many files have changed in this diff Show More