diff --git a/shaders/block.properties b/shaders/block.properties index 3e36652..a3d829f 100644 --- a/shaders/block.properties +++ b/shaders/block.properties @@ -1,76 +1,51 @@ - -#if MC_VERSION >= 11300 - - block.2200 = minecraft:oak_sign minecraft:spruce_sign minecraft:birch_sign minecraft:jungle_sign minecraft:acacia_sign minecraft:dark_oak_sign minecraft:mangrove_sign minecraft:crimson_sign minecraft:warped_sign minecraft:oak_wall_sign minecraft:spruce_wall_sign minecraft:birch_wall_sign minecraft:jungle_wall_sign minecraft:acacia_wall_sign minecraft:dark_oak_wall_sign minecraft:mangrove_wall_sign minecraft:crimson_wall_sign minecraft:warped_wall_sign +####### ----- waving blocks with SSS ----- ####### + ##ground waving + # add a newline to organize for modded blocks + block.10001 = minecraft:sunflower:half=upper minecraft:beetroots minecraft:potatoes minecraft:carrots minecraft:wheat minecraft:nether_wart minecraft:kelp minecraft:large_fern:half=upper minecraft:peony:half=upper minecraft:rose_bush:half=upper minecraft:lilac:half=upper minecraft:crimson_roots minecraft:nether_sprouts minecraft:warped_roots minecraft:seagrass minecraft:tall_seagrass:half=upper minecraft:tall_grass:half=upper minecraft:wither_rose minecraft:lily_of_the_valley minecraft:cornflower minecraft:sweet_berry_bush minecraft:oxeye_daisy minecraft:pink_tulip minecraft:white_tulip minecraft:orange_tulip minecraft:red_tulip minecraft:azure_bluet minecraft:allium minecraft:blue_orchid minecraft:poppy minecraft:dandelion minecraft:dead_bush minecraft:oak_sapling minecraft:spruce_sapling minecraft:birch_sapling minecraft:jungle_sapling minecraft:acacia_sapling minecraft:dark_oak_sapling + + block.10009 = minecraft:grass minecraft:fern + ##air waving + # add a newline to organize for modded blocks + block.10003 = minecraft:azalea_leaves minecraft:flowering_azalea_leaves minecraft:cherry_leaves minecraft:mangrove_leaves minecraft:vine minecraft:oak_leaves minecraft:spruce_leaves minecraft:birch_leaves minecraft:jungle_leaves minecraft:acacia_leaves minecraft:dark_oak_leaves \ + westerosblocks:vine_jasmine westerosblocks:apple_fruit_leaves westerosblocks:apricot_fruit_leaves westerosblocks:cherry_fruit_leaves westerosblocks:purple_grape_fruit_leaves westerosblocks:lemon_fruit_leaves westerosblocks:lime_fruit_leaves westerosblocks:orange_fruit_leaves westerosblocks:peach_fruit_leaves westerosblocks:plum_fruit_leaves westerosblocks:pomegranate_fruit_leaves westerosblocks:weirwood_leaves westerosblocks:hop_fruit_leaves westerosblocks:olive_fruit_leaves westerosblocks:palm_leaves westerosblocks:white_grape_fruit_leaves +####### ----- blocks with SSS ----- ####### + ## strong sss + block.10004 =minecraft:tall_seagrass minecraft:seagrass minecraft:kelp minecraft:large_fern:half=lower minecraft:tall_grass minecraft:tall_seagrass minecraft:kelp_plant minecraft:peony minecraft:rose_bush minecraft:lilac minecraft:sunflower:half=lower minecraft:packed_ice minecraft:blue_ice minecraft:melon_stem minecraft:pumpkin_stem minecraft:attached_melon_stem minecraft:attached_pumpkin_stem minecraft:lily_pad \ + westerosblocks:blackberry_bush westerosblocks:blueberry_bush westerosblocks:raspberry_bush westerosblocks:juniper_bush westerosblocks:red_rose_bush westerosblocks:pink_rose_bush westerosblocks:white_rose_bush westerosblocks:yellow_rose_bush westerosblocks:yellow_wildflowers westerosblocks:green_spiny_herb westerosblocks:green_leafy_herb westerosblocks:orange_marigolds westerosblocks:orange_trollius westerosblocks:blue_forgetmenots westerosblocks:pink_wildflowers westerosblocks:yellow_tansy westerosblocks:blue_flax westerosblocks:white_daisies westerosblocks:yellow_daisies westerosblocks:green_scrub_grass westerosblocks:dead_scrub_grass westerosblocks:yellow_bedstraw westerosblocks:orange_bells westerosblocks:blue_bells westerosblocks:blue_swamp_bells westerosblocks:yellow_buttercups westerosblocks:orange_bog_asphodel westerosblocks:yellow_lupine westerosblocks:blue_hyacinth westerosblocks:pink_thistle westerosblocks:yellow_dandelions westerosblocks:yellow_daffodils westerosblocks:yellow_roses westerosblocks:strawberry_bush westerosblocks:white_lilyofthevalley westerosblocks:yellow_bells westerosblocks:yellow_sunflower westerosblocks:white_roses westerosblocks:red_dark_roses westerosblocks:yellow_hellebore westerosblocks:meadow_fescue westerosblocks:red_poppies westerosblocks:red_roses westerosblocks:purple_pansies westerosblocks:purple_roses westerosblocks:orange_sun_star westerosblocks:pink_primrose westerosblocks:red_aster westerosblocks:blue_chicory westerosblocks:red_flowering_spiny_herb westerosblocks:purple_foxglove westerosblocks:pink_allium westerosblocks:purple_violets westerosblocks:white_chamomile westerosblocks:red_tulips westerosblocks:white_peony westerosblocks:purple_alpine_sowthistle westerosblocks:red_carnations westerosblocks:magenta_roses westerosblocks:red_chrysanthemum westerosblocks:blue_orchid westerosblocks:yellow_rudbeckia westerosblocks:pink_tulips westerosblocks:cranberry_bush westerosblocks:purple_lavender westerosblocks:red_sourleaf_bush westerosblocks:pink_sweet_peas westerosblocks:red_sorrel westerosblocks:pink_roses westerosblocks:unshaded_grass westerosblocks:cow_parsely westerosblocks:bracken westerosblocks:lady_fern westerosblocks:nettle westerosblocks:dead_bracken westerosblocks:fireweed westerosblocks:heather westerosblocks:red_fern westerosblocks:dock_leaf westerosblocks:jasmine_vines westerosblocks:dappled_moss westerosblocks:cushion_moss_wall westerosblocks:hemp_short westerosblocks:hemp_tall westerosblocks:hemp_dense westerosblocks:crop_carrots westerosblocks:crop_wheat westerosblocks:crop_turnips westerosblocks:crop_peas westerosblocks:cattails westerosblocks:jungle_tall_fern westerosblocks:jungle_tall_grass westerosblocks:savanna_tall_grass + + ## weak sss + block.10006 = minecraft:grass_block:snowy=true minecraft:snow_block minecraft:snow powder_snow cobweb red_mushroom_block brown_mushroom_block weeping_vines weeping_vines_plant twisting_vines twisting_vines_plant vine tube_coral tube_coral_block tube_coral_fan tube_coral_wall_fan horn_coral horn_coral_block horn_coral_fan horn_coral_wall_fan fire_coral fire_coral_block fire_coral_fan fire_coral_wall_fan dead_brain_coral dead_brain_coral_block dead_brain_coral_fan dead_brain_coral_wall_fan dead_bubble_coral dead_bubble_coral_block dead_bubble_coral_fan dead_bubble_coral_wall_fan dead_bush dead_fire_coral dead_fire_coral_block dead_fire_coral_fan dead_fire_coral_wall_fan dead_horn_coral dead_horn_coral_block dead_horn_coral_fan dead_horn_coral_wall_fan dead_tube_coral dead_tube_coral_block dead_tube_coral_fan dead_tube_coral_wall_fan bubble_coral bubble_coral_block bubble_coral_fan bubble_coral_wall_fan brain_coral brain_coral_block brain_coral_fan brain_coral_wall_fan bamboo bamboo_sapling minecraft:spore_blossom minecraft:cave_vines minecraft:cave_vines_plant minecraft:glow_lichen minecraft:melon minecraft:pumpkin minecraft:big_dripleaf minecraft:big_dripleaf_stem minecraft:cactus minecraft:hay_block minecraft:brown_mushroom minecraft:mushroom_stem minecraft:sugar_cane minecraft:crimson_fungus minecraft:warped_fungus minecraft:sea_pickle minecraft:honeycomb_block + ## weak sss + block.200 = minecraft:white_wool minecraft:orange_wool minecraft:magenta_wool minecraft:light_blue_wool minecraft:yellow_wool minecraft:lime_wool minecraft:pink_wool minecraft:gray_wool minecraft:light_gray_wool minecraft:cyan_wool minecraft:purple_wool minecraft:blue_wool minecraft:brown_wool minecraft:green_wool minecraft:red_wool minecraft:black_wool minecraft:orange_carpet minecraft:magenta_carpet minecraft:light_blue_carpet minecraft:yellow_carpet minecraft:lime_carpet minecraft:pink_carpet minecraft:gray_carpet minecraft:light_gray_carpet minecraft:cyan_carpet minecraft:purple_carpet minecraft:blue_carpet minecraft:brown_carpet minecraft:green_carpet minecraft:red_carpet minecraft:black_carpet \ + westerosblocks:clothesline westerosblocks:smoke westerosblocks:brown_mushroom_1 westerosblocks:brown_mushroom_2 westerosblocks:brown_mushroom_3 westerosblocks:brown_mushroom_4 westerosblocks:brown_mushroom_5 westerosblocks:brown_mushroom_6 westerosblocks:brown_mushroom_7 westerosblocks:brown_mushroom_8 westerosblocks:brown_mushroom_9 westerosblocks:brown_mushroom_10 westerosblocks:brown_mushroom_11 westerosblocks:brown_mushroom_12 westerosblocks:brown_mushroom_13 westerosblocks:red_mushroom_1 westerosblocks:red_mushroom_2 westerosblocks:red_mushroom_3 westerosblocks:red_mushroom_4 westerosblocks:red_mushroom_5 westerosblocks:red_mushroom_6 westerosblocks:red_mushroom_7 westerosblocks:red_mushroom_8 westerosblocks:red_mushroom_9 westerosblocks:white_wool_slab westerosblocks:orange_wool_slab westerosblocks:light_brown_wool_slab westerosblocks:light_blue_wool_slab westerosblocks:yellow_wool_slab westerosblocks:dirty_white_wool_slab westerosblocks:pink_wool_slab westerosblocks:grey_wool_slab westerosblocks:light_grey_wool_slab westerosblocks:cyan_wool_slab westerosblocks:purple_wool_slab westerosblocks:blue_wool_slab westerosblocks:brown_wool_slab westerosblocks:green_wool_slab westerosblocks:red_wool_slab westerosblocks:black_wool_slab westerosblocks:white_wool_carpet westerosblocks:orange_wool_carpet westerosblocks:light_brown_wool_carpet westerosblocks:light_blue_wool_carpet westerosblocks:yellow_wool_carpet westerosblocks:dirty_white_wool_carpet westerosblocks:pink_wool_carpet westerosblocks:grey_wool_carpet westerosblocks:light_grey_wool_carpet westerosblocks:cyan_wool_carpet westerosblocks:purple_wool_carpet westerosblocks:blue_wool_carpet westerosblocks:brown_wool_carpet westerosblocks:green_wool_carpet westerosblocks:red_wool_carpet westerosblocks:black_wool_carpet westerosblocks:thatch_light_fur_carpet westerosblocks:thatch_dark_fur_carpet + + ## weak sss + block.10010 = minecraft:white_wall_banner minecraft:orange_wall_banner minecraft:magenta_wall_banner minecraft:light_blue_wall_banner minecraft:yellow_wall_banner minecraft:lime_wall_banner minecraft:pink_wall_banner minecraft:gray_wall_banner minecraft:light_gray_wall_banner minecraft:cyan_wall_banner minecraft:purple_wall_banner minecraft:blue_wall_banner minecraft:brown_wall_banner minecraft:green_wall_banner minecraft:red_wall_banner minecraft:black_wall_banner minecraft:white_banner minecraft:orange_banner minecraft:magenta_banner minecraft:light_blue_banner minecraft:yellow_banner minecraft:lime_banner minecraft:pink_banner minecraft:gray_banner minecraft:light_gray_banner minecraft:cyan_banner minecraft:purple_banner minecraft:blue_banner minecraft:brown_banner minecraft:green_banner minecraft:red_banner minecraft:black_banner \ + westerosblocks:renly_banner westerosblocks:redwyne_banner westerosblocks:grafton_banner westerosblocks:grey_banner westerosblocks:red_banner westerosblocks:black_banner westerosblocks:the_faith_of_the_seven_banner westerosblocks:cream_banner westerosblocks:blue_banner westerosblocks:brown_banner westerosblocks:cyan_banner westerosblocks:green_banner westerosblocks:orange_banner westerosblocks:pink_banner westerosblocks:purple_banner westerosblocks:lord_of_light_rhllor_banner westerosblocks:yellow_banner westerosblocks:arryn_banner westerosblocks:baratheon_banner westerosblocks:bolton_banner westerosblocks:dayne_banner westerosblocks:frey_banner westerosblocks:greyjoy_banner westerosblocks:hightower_banner westerosblocks:lannister_banner westerosblocks:manderly_banner westerosblocks:martell_banner westerosblocks:stannis_banner westerosblocks:stark_banner westerosblocks:targaryen_banner westerosblocks:tarly_banner westerosblocks:tully_banner westerosblocks:tyrell_banner + + ## weird blocks + block.10007 = minecraft:sand minecraft:red_sand + + ## grass uwu + block.10008 = minecraft:grass_block:snowy=false + +####### ----- lightsources ----- ####### + block.10005 = minecraft:sculk_sensor:sculk_sensor_phase=active minecraft:soul_fire minecraft:soul_campfire:lit=true minecraft:cave_vines_plant:berries=true minecraft:soul_lantern minecraft:soul_torch minecraft:soul_wall_torch minecraft:conduit minecraft:beacon minecraft:sea_pickle minecraft:respawn_anchor:charges=4 minecraft:smoker:lit=true minecraft:blast_furnace:lit=true minecraft:furnace:lit=true minecraft:lava_cauldron minecraft:sea_lantern minecraft:cave_vines:berries=true minecraft:glowstone minecraft:torch minecraft:wall_torch minecraft:lava minecraft:fire minecraft:redstone_torch minecraft:redstone_wall_torch minecraft:jack_o_lantern minecraft:magma_block minecraft:redstone_lamp:lit=true minecraft:lantern minecraft:campfire:lit=true minecraft:shroomlight minecraft:end_rod minecraft:end_gateway minecraft:lava minecraft:fire \ + westerosblocks:safe_fire + +####### ----- reflective translucents / glass ----- ####### + block.10002 = minecraft:slime_block minecraft:nether_portal minecraft:honey_block ice minecraft:frosted_ice minecraft:black_stained_glass minecraft:black_stained_glass_pane minecraft:blue_stained_glass minecraft:blue_stained_glass_pane minecraft:brown_stained_glass minecraft:brown_stained_glass_pane minecraft:cyan_stained_glass minecraft:cyan_stained_glass_pane minecraft:gray_stained_glass minecraft:gray_stained_glass_pane minecraft:green_stained_glass minecraft:green_stained_glass_pane minecraft:light_blue_stained_glass minecraft:light_blue_stained_glass_pane minecraft:light_gray_stained_glass minecraft:light_gray_stained_glass_pane minecraft:lime_stained_glass minecraft:lime_stained_glass_pane minecraft:magenta_stained_glass minecraft:magenta_stained_glass_pane minecraft:orange_stained_glass minecraft:orange_stained_glass_pane minecraft:pink_stained_glass minecraft:pink_stained_glass_pane minecraft:purple_stained_glass minecraft:purple_stained_glass_pane minecraft:red_stained_glass minecraft:red_stained_glass_pane minecraft:white_stained_glass minecraft:white_stained_glass_pane minecraft:yellow_stained_glass minecraft:yellow_stained_glass_pane minecraft:glass_pane minecraft:glass + +####### ----- misc ----- ####### + ## all blocks here get exluded from POM. + block.2200 = minecraft:oak_sign minecraft:spruce_sign minecraft:birch_sign minecraft:jungle_sign minecraft:acacia_sign minecraft:dark_oak_sign minecraft:mangrove_sign minecraft:crimson_sign minecraft:warped_sign minecraft:oak_wall_sign minecraft:spruce_wall_sign minecraft:birch_wall_sign minecraft:jungle_wall_sign minecraft:acacia_wall_sign minecraft:dark_oak_wall_sign minecraft:mangrove_wall_sign minecraft:crimson_wall_sign minecraft:warped_wall_sign + + ## stuff block.2100 = minecraft:end_portal - - ####### ----- SSS and waving ----- ####### + + block.8 = minecraft:water minecraft:flowing_water - ##ground waving - block.10001 = minecraft:sunflower:half=upper minecraft:beetroots minecraft:potatoes minecraft:carrots minecraft:wheat minecraft:nether_wart minecraft:kelp minecraft:large_fern:half=upper minecraft:peony:half=upper minecraft:rose_bush:half=upper minecraft:lilac:half=upper minecraft:crimson_roots minecraft:nether_sprouts minecraft:warped_roots minecraft:seagrass minecraft:tall_seagrass:half=upper minecraft:tall_grass:half=upper minecraft:wither_rose minecraft:lily_of_the_valley minecraft:cornflower minecraft:sweet_berry_bush minecraft:oxeye_daisy minecraft:pink_tulip minecraft:white_tulip minecraft:orange_tulip minecraft:red_tulip minecraft:azure_bluet minecraft:allium minecraft:blue_orchid minecraft:poppy minecraft:dandelion minecraft:dead_bush minecraft:oak_sapling minecraft:spruce_sapling minecraft:birch_sapling minecraft:jungle_sapling minecraft:acacia_sapling minecraft:dark_oak_sapling minecraft:fern - - block.10009 = minecraft:grass - - ##air waving - block.10003 = minecraft:azalea_leaves minecraft:flowering_azalea_leaves minecraft:cherry_leaves minecraft:mangrove_leaves minecraft:vine minecraft:oak_leaves minecraft:spruce_leaves minecraft:birch_leaves minecraft:jungle_leaves minecraft:acacia_leaves minecraft:dark_oak_leaves - - ####### ----- SSS ----- ####### - - ## strong - block.10004 = minecraft:fern minecraft:packed_ice minecraft:blue_ice minecraft:melon_stem minecraft:pumpkin_stem minecraft:attached_melon_stem minecraft:attached_pumpkin_stem minecraft:lily_pad - - ## weak - block.10006 = minecraft:grass_block:snowy=true minecraft:snow_block minecraft:snow powder_snow cobweb red_mushroom_block brown_mushroom_block weeping_vines weeping_vines_plant twisting_vines twisting_vines_plant vine tube_coral tube_coral_block tube_coral_fan tube_coral_wall_fan horn_coral horn_coral_block horn_coral_fan horn_coral_wall_fan fire_coral fire_coral_block fire_coral_fan fire_coral_wall_fan dead_brain_coral dead_brain_coral_block dead_brain_coral_fan dead_brain_coral_wall_fan dead_bubble_coral dead_bubble_coral_block dead_bubble_coral_fan dead_bubble_coral_wall_fan dead_bush dead_fire_coral dead_fire_coral_block dead_fire_coral_fan dead_fire_coral_wall_fan dead_horn_coral dead_horn_coral_block dead_horn_coral_fan dead_horn_coral_wall_fan dead_tube_coral dead_tube_coral_block dead_tube_coral_fan dead_tube_coral_wall_fan bubble_coral bubble_coral_block bubble_coral_fan bubble_coral_wall_fan brain_coral brain_coral_block brain_coral_fan brain_coral_wall_fan bamboo bamboo_sapling minecraft:tall_seagrass minecraft:seagrass minecraft:kelp minecraft:large_fern minecraft:tall_grass minecraft:tall_seagrass minecraft:kelp_plant minecraft:peony minecraft:rose_bush minecraft:lilac minecraft:sunflower:half=lower minecraft:spore_blossom minecraft:cave_vines minecraft:cave_vines_plant minecraft:glow_lichen minecraft:melon minecraft:pumpkin minecraft:big_dripleaf minecraft:big_dripleaf_stem minecraft:cactus minecraft:hay_block minecraft:brown_mushroom minecraft:mushroom_stem minecraft:sugar_cane minecraft:crimson_fungus minecraft:warped_fungus minecraft:sea_pickle minecraft:honeycomb_block - - - block.200 = minecraft:white_wool minecraft:orange_wool minecraft:magenta_wool minecraft:light_blue_wool minecraft:yellow_wool minecraft:lime_wool minecraft:pink_wool minecraft:gray_wool minecraft:light_gray_wool minecraft:cyan_wool minecraft:purple_wool minecraft:blue_wool minecraft:brown_wool minecraft:green_wool minecraft:red_wool minecraft:black_wool minecraft:orange_carpet minecraft:magenta_carpet minecraft:light_blue_carpet minecraft:yellow_carpet minecraft:lime_carpet minecraft:pink_carpet minecraft:gray_carpet minecraft:light_gray_carpet minecraft:cyan_carpet minecraft:purple_carpet minecraft:blue_carpet minecraft:brown_carpet minecraft:green_carpet minecraft:red_carpet minecraft:black_carpet - - - block.10010 = minecraft:white_wall_banner minecraft:orange_wall_banner minecraft:magenta_wall_banner minecraft:light_blue_wall_banner minecraft:yellow_wall_banner minecraft:lime_wall_banner minecraft:pink_wall_banner minecraft:gray_wall_banner minecraft:light_gray_wall_banner minecraft:cyan_wall_banner minecraft:purple_wall_banner minecraft:blue_wall_banner minecraft:brown_wall_banner minecraft:green_wall_banner minecraft:red_wall_banner minecraft:black_wall_banner minecraft:white_banner minecraft:orange_banner minecraft:magenta_banner minecraft:light_blue_banner minecraft:yellow_banner minecraft:lime_banner minecraft:pink_banner minecraft:gray_banner minecraft:light_gray_banner minecraft:cyan_banner minecraft:purple_banner minecraft:blue_banner minecraft:brown_banner minecraft:green_banner minecraft:red_banner minecraft:black_banner - - - ## weird blocks - block.10007 = minecraft:sand minecraft:red_sand - - ## grass uwu - block.10008 = minecraft:grass_block:snowy=false - - - - ####### ----- lightsources ----- ####### - - block.10005 = minecraft:sculk_sensor:sculk_sensor_phase=active minecraft:soul_fire minecraft:soul_campfire:lit=true minecraft:cave_vines_plant:berries=true minecraft:soul_lantern minecraft:soul_torch minecraft:soul_wall_torch minecraft:conduit minecraft:beacon minecraft:sea_pickle minecraft:respawn_anchor:charges=4 minecraft:smoker:lit=true minecraft:blast_furnace:lit=true minecraft:furnace:lit=true minecraft:lava_cauldron minecraft:sea_lantern minecraft:cave_vines:berries=true minecraft:glowstone minecraft:torch minecraft:wall_torch minecraft:lava minecraft:fire minecraft:redstone_torch minecraft:redstone_wall_torch minecraft:jack_o_lantern minecraft:magma_block minecraft:redstone_lamp:lit=true minecraft:lantern minecraft:campfire:lit=true minecraft:shroomlight minecraft:end_rod minecraft:end_gateway minecraft:lava minecraft:fire - - ####### ----- reflective translucents / glass ----- ####### - - block.10002 = minecraft:slime_block minecraft:nether_portal minecraft:honey_block ice minecraft:frosted_ice minecraft:black_stained_glass minecraft:black_stained_glass_pane minecraft:blue_stained_glass minecraft:blue_stained_glass_pane minecraft:brown_stained_glass minecraft:brown_stained_glass_pane minecraft:cyan_stained_glass minecraft:cyan_stained_glass_pane minecraft:gray_stained_glass minecraft:gray_stained_glass_pane minecraft:green_stained_glass minecraft:green_stained_glass_pane minecraft:light_blue_stained_glass minecraft:light_blue_stained_glass_pane minecraft:light_gray_stained_glass minecraft:light_gray_stained_glass_pane minecraft:lime_stained_glass minecraft:lime_stained_glass_pane minecraft:magenta_stained_glass minecraft:magenta_stained_glass_pane minecraft:orange_stained_glass minecraft:orange_stained_glass_pane minecraft:pink_stained_glass minecraft:pink_stained_glass_pane minecraft:purple_stained_glass minecraft:purple_stained_glass_pane minecraft:red_stained_glass minecraft:red_stained_glass_pane minecraft:white_stained_glass minecraft:white_stained_glass_pane minecraft:yellow_stained_glass minecraft:yellow_stained_glass_pane minecraft:glass_pane minecraft:glass - - ####### ----- misc ----- ####### - - - block.8 = minecraft:water minecraft:flowing_water - - #else - - #wavy plants, translucent, bottom vertices not moving - - block.10001= 6 31 32 37 38 39 40 59 115 141 142 207 - - #wavy plants (blocks) - - block.10003 = 18 106 161 - - #translucent - - block.10004 = 30 83 104 105 111 175 176 177 - - #reflective surfaces (not including water and ice) - - block.10002=95 160 - -#endif - -layer.translucent=minecraft:glass_pane minecraft:glass -# layer.solid = minecraft:tripwire minecraft:slime_block minecraft:nether_portal minecraft:honey_block minecraft:ice minecraft:black_stained_glass minecraft:black_stained_glass_pane minecraft:blue_stained_glass minecraft:blue_stained_glass_pane minecraft:brown_stained_glass minecraft:brown_stained_glass_pane minecraft:cyan_stained_glass minecraft:cyan_stained_glass_pane minecraft:gray_stained_glass minecraft:gray_stained_glass_pane minecraft:green_stained_glass minecraft:green_stained_glass_pane minecraft:light_blue_stained_glass minecraft:light_blue_stained_glass_pane minecraft:light_gray_stained_glass minecraft:light_gray_stained_glass_pane minecraft:lime_stained_glass minecraft:lime_stained_glass_pane minecraft:magenta_stained_glass minecraft:magenta_stained_glass_pane minecraft:orange_stained_glass minecraft:orange_stained_glass_pane minecraft:pink_stained_glass minecraft:pink_stained_glass_pane minecraft:purple_stained_glass minecraft:purple_stained_glass_pane minecraft:red_stained_glass minecraft:red_stained_glass_pane minecraft:white_stained_glass minecraft:white_stained_glass_pane minecraft:yellow_stained_glass minecraft:yellow_stained_glass_pane minecraft:glass_pane minecraft:glass \ No newline at end of file + layer.translucent = minecraft:glass_pane minecraft:glass + # layer.cutout = minecraft:tripwire minecraft:slime_block minecraft:nether_portal minecraft:honey_block minecraft:ice minecraft:black_stained_glass minecraft:black_stained_glass_pane minecraft:blue_stained_glass minecraft:blue_stained_glass_pane minecraft:brown_stained_glass minecraft:brown_stained_glass_pane minecraft:cyan_stained_glass minecraft:cyan_stained_glass_pane minecraft:gray_stained_glass minecraft:gray_stained_glass_pane minecraft:green_stained_glass minecraft:green_stained_glass_pane minecraft:light_blue_stained_glass minecraft:light_blue_stained_glass_pane minecraft:light_gray_stained_glass minecraft:light_gray_stained_glass_pane minecraft:lime_stained_glass minecraft:lime_stained_glass_pane minecraft:magenta_stained_glass minecraft:magenta_stained_glass_pane minecraft:orange_stained_glass minecraft:orange_stained_glass_pane minecraft:pink_stained_glass minecraft:pink_stained_glass_pane minecraft:purple_stained_glass minecraft:purple_stained_glass_pane minecraft:red_stained_glass minecraft:red_stained_glass_pane minecraft:white_stained_glass minecraft:white_stained_glass_pane minecraft:yellow_stained_glass minecraft:yellow_stained_glass_pane minecraft:glass_pane minecraft:glass \ No newline at end of file diff --git a/shaders/composite.fsh b/shaders/composite.fsh deleted file mode 100644 index e327b58..0000000 --- a/shaders/composite.fsh +++ /dev/null @@ -1,272 +0,0 @@ -#version 120 -//#extension GL_EXT_gpu_shader4 : disable - -#include "/lib/settings.glsl" - - -flat varying vec3 WsunVec; -flat varying vec2 TAA_Offset; -#include "/lib/res_params.glsl" -#include "/lib/Shadow_Params.glsl" - -uniform sampler2D depthtex1; -uniform sampler2D colortex1; -uniform sampler2D colortex6; // Noise -uniform sampler2D colortex8; // Noise -uniform sampler2D colortex15; // Noise -uniform sampler2D shadow; -uniform sampler2D noisetex; -uniform vec3 sunVec; -uniform vec2 texelSize; -uniform float frameTimeCounter; -uniform float rainStrength; -uniform int frameCounter; -uniform mat4 gbufferProjection; -uniform mat4 gbufferProjectionInverse; -uniform mat4 gbufferModelViewInverse; -uniform mat4 gbufferModelView; - -uniform mat4 shadowModelView; -uniform mat4 shadowProjection; -uniform vec3 cameraPosition; -uniform float viewWidth; -uniform float aspectRatio; -uniform float viewHeight; -uniform float far; -uniform float near; - -#define ffstep(x,y) clamp((y - x) * 1e35,0.0,1.0) -#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z) -#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz) -vec3 toScreenSpace(vec3 p) { - vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw); - vec3 p3 = p * 2. - 1.; - vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3]; - return fragposition.xyz / fragposition.w; -} -vec3 worldToView(vec3 worldPos) { - vec4 pos = vec4(worldPos, 0.0); - pos = gbufferModelView * pos; - return pos.xyz; -} - -vec2 tapLocation(int sampleNumber,int nb, float nbRot,float jitter,float distort) -{ - float alpha = (sampleNumber+jitter)/nb; - float angle = jitter*6.28+alpha * nbRot * 6.28; - float sin_v, cos_v; - - sin_v = sin(angle); - cos_v = cos(angle); - - return vec2(cos_v, sin_v)*alpha; -} -// float interleaved_gradientNoise(){ -// vec2 coord = gl_FragCoord.xy; -// float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y)+ 1.0/1.6180339887 * frameCounter) ; -// return noise; -// } -// float interleaved_gradientNoise2(){ -// vec2 alpha = vec2(0.75487765, 0.56984026); -// vec2 coord = vec2(alpha.x * gl_FragCoord.x,alpha.y * gl_FragCoord.y)+ 1.0/1.6180339887 * frameCounter; -// float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y)); -// return noise; -// } -float interleaved_gradientNoise(){ - vec2 coord = gl_FragCoord.xy + (frameCounter%40000); - // vec2 coord = gl_FragCoord.xy + frameTimeCounter; - // vec2 coord = gl_FragCoord.xy; - float noise = fract( 52.9829189 * fract( (coord.x * 0.06711056) + (coord.y * 0.00583715)) ); - return noise ; -} -vec3 decode (vec2 encn){ - vec3 n = vec3(0.0); - encn = encn * 2.0 - 1.0; - n.xy = abs(encn); - n.z = 1.0 - n.x - n.y; - n.xy = n.z <= 0.0 ? (1.0 - n.yx) * sign(encn) : encn; - return clamp(normalize(n.xyz),-1.0,1.0); -} -vec2 decodeVec2(float a){ - const vec2 constant1 = 65535. / vec2( 256., 65536.); - const float constant2 = 256. / 255.; - return fract( a * constant1 ) * constant2 ; -} -float R2_dither(){ - vec2 alpha = vec2(0.75487765, 0.56984026); - return fract(alpha.x * gl_FragCoord.x + alpha.y * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter); -} -float blueNoise(){ - return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter); -} -vec4 blueNoise(vec2 coord){ - return texelFetch2D(colortex6, ivec2(coord )%512 , 0); -} - -vec2 R2_samples(int n){ - vec2 alpha = vec2(0.75487765, 0.56984026); - return fract(alpha * n); -} -vec2 tapLocation_alternate( - int sampleNumber, - float spinAngle, - int nb, - float nbRot, - float r0 -){ - float alpha = (float(sampleNumber*1.0f + r0) * (1.0 / (nb))); - float angle = alpha * (nbRot * 3.14) ; - - float ssR = alpha + spinAngle*3.14; - float sin_v, cos_v; - - sin_v = sin(angle); - cos_v = cos(angle); - return vec2(cos_v, sin_v)*ssR; -} -vec3 viewToWorld(vec3 viewPosition) { - vec4 pos; - pos.xyz = viewPosition; - pos.w = 0.0; - pos = gbufferModelViewInverse * pos; - return pos.xyz; -} - - -// Emin's and Gri's combined ideas to stop peter panning and light leaking, also has little shadowacne so thats nice -// https://www.complementary.dev/reimagined -// https://github.com/gri573 -void GriAndEminShadowFix( - inout vec3 WorldPos, - vec3 FlatNormal, - float VanillaAO, - float SkyLightmap, - bool Entities -){ - float DistanceOffset = clamp(0.1 + length(WorldPos) / (shadowMapResolution*0.20), 0.0,1.0) ; - vec3 Bias = FlatNormal * DistanceOffset; // adjust the bias thingy's strength as it gets farther away. - - // stop lightleaking - if(SkyLightmap < 0.1 && !Entities) { - WorldPos += mix(Bias, 0.5 * (0.5 - fract(WorldPos + cameraPosition + FlatNormal*0.01 ) ), VanillaAO) ; - }else{ - WorldPos += Bias; - } -} - -void main() { -/* DRAWBUFFERS:3 */ - vec2 texcoord = gl_FragCoord.xy*texelSize; - - float z = texture2D(depthtex1,texcoord).x; - - vec2 tempOffset=TAA_Offset; - - vec4 data = texture2D(colortex1,texcoord); - vec4 dataUnpacked0 = vec4(decodeVec2(data.x),decodeVec2(data.y)); - vec4 dataUnpacked1 = vec4(decodeVec2(data.z),decodeVec2(data.w)); - vec3 normal = mat3(gbufferModelViewInverse) * clamp(worldToView( decode(dataUnpacked0.yw) ),-1.,1.); - vec2 lightmap = dataUnpacked1.yz; - - - // bool lightningBolt = abs(dataUnpacked1.w-0.5) <0.01; - // bool isLeaf = abs(dataUnpacked1.w-0.55) <0.01; - // bool translucent2 = abs(dataUnpacked1.w-0.6) <0.01; // Weak translucency - // bool translucent4 = abs(dataUnpacked1.w-0.65) <0.01; // Weak translucency - bool entities = abs(dataUnpacked1.w-0.45) < 0.01; - bool hand = abs(dataUnpacked1.w-0.75) < 0.01; - // bool blocklights = abs(dataUnpacked1.w-0.8) <0.01; - - - float minshadowfilt = Min_Shadow_Filter_Radius; - float maxshadowfilt = Max_Shadow_Filter_Radius; - - float NdotL = clamp(dot(normal,WsunVec),0.0,1.0); - - // vec4 normalAndAO = texture2D(colortex15,texcoord); - // vec3 FlatNormals = normalAndAO.rgb * 2.0 - 1.0; - // float vanillAO = clamp(normalAndAO.a,0.0,1.0) ; - - float vanillAO = clamp(texture2D(colortex15,texcoord).a,0.0,1.0) ; - - if(lightmap.y < 0.1 && !entities){ - // minshadowfilt *= vanillAO; - maxshadowfilt = mix(minshadowfilt, maxshadowfilt, vanillAO); - } - - - float SpecularTex = texture2D(colortex8,texcoord).z; - float LabSSS = clamp((-64.0 + SpecularTex * 255.0) / 191.0 ,0.0,1.0); - - #ifndef Variable_Penumbra_Shadows - if (LabSSS > 0.0 && !hand && NdotL < 0.001) minshadowfilt += 50; - #endif - - gl_FragData[0] = vec4(minshadowfilt, 0.1, 0.0, 0.0); - - if (z < 1.0 && !hand){ - - vec3 fragpos = toScreenSpace(vec3(texcoord/RENDER_SCALE-vec2(tempOffset)*texelSize*0.5,z)); - - #ifdef Variable_Penumbra_Shadows - - if (NdotL > 0.001 || LabSSS > 0.0) { - - vec3 p3 = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz; - - // GriAndEminShadowFix(p3, viewToWorld(FlatNormals), vanillAO, lightmap.y, entities); - - vec3 projectedShadowPosition = mat3(shadowModelView) * p3 + shadowModelView[3].xyz; - projectedShadowPosition = diagonal3(shadowProjection) * projectedShadowPosition + shadowProjection[3].xyz; - - //apply distortion - float distortFactor = calcDistort(projectedShadowPosition.xy); - projectedShadowPosition.xy *= distortFactor; - //do shadows only if on shadow map - if (abs(projectedShadowPosition.x) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.y) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.z) < 6.0){ - const float threshMul = max(2048.0/shadowMapResolution*shadowDistance/128.0,0.95); - float distortThresh = (sqrt(1.0-NdotL*NdotL)/NdotL+0.7)/distortFactor; - float diffthresh = distortThresh/6000.0*threshMul; - projectedShadowPosition = projectedShadowPosition * vec3(0.5,0.5,0.5/6.0) + vec3(0.5,0.5,0.5); - - float mult = maxshadowfilt; - float avgBlockerDepth = 0.0; - vec2 scales = vec2(0.0, 120.0 - Max_Filter_Depth); - float blockerCount = 0.0; - float rdMul = distortFactor*(1.0+mult)*d0*k/shadowMapResolution; - float diffthreshM = diffthresh*mult*d0*k/20.; - float avgDepth = 0.0; - - int seed = (frameCounter%40000) + (1+frameCounter); - float randomDir = fract(R2_samples(seed).y + blueNoise(gl_FragCoord.xy).g) * 1.61803398874 ; - - for(int i = 0; i < VPS_Search_Samples; i++){ - - // vec2 offsetS = tapLocation(i,VPS_Search_Samples,1.61803398874 , blueNoise(),0.0); - - vec2 offsetS = tapLocation_alternate(i, 0.0, 7, 20, randomDir); - - float weight = 3.0 + (i+blueNoise() ) *rdMul/SHADOW_FILTER_SAMPLE_COUNT*shadowMapResolution*distortFactor/2.7; - // float d = texelFetch2D( shadow, ivec2((projectedShadowPosition.xy+offsetS*rdMul)*shadowMapResolution),0).x; - float d = texelFetch2D( shadow, ivec2((projectedShadowPosition.xy+offsetS*rdMul)*shadowMapResolution),0).x; - - - float b = smoothstep(weight*diffthresh/2.0, weight*diffthresh, projectedShadowPosition.z - d); - - blockerCount += b; - avgDepth += max(projectedShadowPosition.z - d, 0.0)*1000.; - avgBlockerDepth += d * b; - } - - gl_FragData[0].g = avgDepth / VPS_Search_Samples; - gl_FragData[0].b = blockerCount / VPS_Search_Samples; - if (blockerCount >= 0.9){ - avgBlockerDepth /= blockerCount; - float ssample = max(projectedShadowPosition.z - avgBlockerDepth,0.0)*1500.0; - gl_FragData[0].r = clamp(ssample, scales.x, scales.y)/(scales.y)*(mult-minshadowfilt)+minshadowfilt; - } - } - } - #endif - } -} \ No newline at end of file diff --git a/shaders/composite.vsh b/shaders/composite.vsh deleted file mode 100644 index 667fd18..0000000 --- a/shaders/composite.vsh +++ /dev/null @@ -1,37 +0,0 @@ -#version 120 -//#extension GL_EXT_gpu_shader4 : disable - -#include "/lib/settings.glsl" - -flat varying vec2 TAA_Offset; -flat varying vec3 WsunVec; - -uniform sampler2D colortex4; - -uniform int frameCounter; -uniform float sunElevation; -uniform vec3 sunPosition; -uniform mat4 gbufferModelViewInverse; -#include "/lib/util.glsl" -#include "/lib/res_params.glsl" - -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.); -void main() { - TAA_Offset = offsets[frameCounter%8]; - #ifndef TAA - TAA_Offset = vec2(0.0); - #endif - gl_Position = ftransform(); - #ifdef TAA_UPSCALING - gl_Position.xy = (gl_Position.xy*0.5+0.5)*RENDER_SCALE*2.0-1.0; - #endif - - WsunVec = (float(sunElevation > 1e-5)*2-1.)*normalize(mat3(gbufferModelViewInverse) * sunPosition); -} diff --git a/shaders/composite1.fsh b/shaders/composite1.fsh deleted file mode 100644 index bf9082e..0000000 --- a/shaders/composite1.fsh +++ /dev/null @@ -1,1297 +0,0 @@ -#version 120 -//Render sky, volumetric clouds, direct lighting -//#extension GL_EXT_gpu_shader4 : disable - -#include "/lib/settings.glsl" - -const bool colortex5MipmapEnabled = true; -const bool colortex12MipmapEnabled = true; - -// #ifndef Rough_reflections - // const bool colortex4MipmapEnabled = true; -// #endif - -const bool shadowHardwareFiltering = true; - -flat varying vec3 averageSkyCol_Clouds; -flat varying vec4 lightCol; - -flat varying vec3 WsunVec; -flat varying vec2 TAA_Offset; - - -uniform float eyeAltitude; - -flat varying vec3 zMults; -uniform sampler2D colortex0;//clouds -uniform sampler2D colortex1;//albedo(rgb),material(alpha) RGBA16 -// uniform sampler2D colortex4;//Skybox -uniform sampler2D colortex3; -uniform sampler2D colortex5; -uniform sampler2D colortex7; // normal -uniform sampler2D colortex6; // Noise -uniform sampler2D colortex8; // specular -// uniform sampler2D colortex9; // specular -uniform sampler2D colortex11; // specular -uniform sampler2D colortex10; // specular -uniform sampler2D colortex12; // specular -uniform sampler2D colortex13; // specular -uniform sampler2D colortex14; -uniform sampler2D colortex15; // specular -uniform sampler2D colortex16; // specular -uniform sampler2D depthtex1;//depth -uniform sampler2D depthtex0;//depth -uniform sampler2D noisetex;//depth -uniform sampler2DShadow shadow; -varying vec4 normalMat; -uniform int heldBlockLightValue; -uniform int frameCounter; -uniform int isEyeInWater; -uniform float far; -uniform float near; -uniform float frameTimeCounter; -uniform float rainStrength; -uniform mat4 gbufferProjection; -uniform mat4 gbufferProjectionInverse; -uniform mat4 gbufferModelViewInverse; -uniform mat4 gbufferPreviousModelView; -uniform mat4 gbufferPreviousProjection; -uniform vec3 previousCameraPosition; -uniform mat4 shadowModelView; -uniform mat4 shadowProjection; -uniform mat4 gbufferModelView; -// uniform float viewWidth; -// uniform float viewHeight; -uniform int hideGUI; -uniform float aspectRatio; -uniform vec2 texelSize; -uniform vec3 cameraPosition; -uniform vec3 sunVec; -uniform ivec2 eyeBrightnessSmooth; -uniform ivec2 eyeBrightness; - -uniform float screenBrightness; -flat varying vec2 rodExposureDepth; - -flat varying float WinterTimeForSnow; - -// uniform int worldTime; - -#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z) - -#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz) - - -vec3 toScreenSpace(vec3 p) { - vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw); - vec3 p3 = p * 2. - 1.; - vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3]; - return fragposition.xyz / fragposition.w; -} - -vec3 toScreenSpacePrev(vec3 p) { - vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw); - vec3 p3 = p * 2. - 1.; - vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3]; - return fragposition.xyz / fragposition.w; -} -vec3 worldToView(vec3 p3) { - vec4 pos = vec4(p3, 0.0); - pos = gbufferModelView * pos; - return pos.xyz; -} - - -float ld(float dist) { - return (2.0 * near) / (far + near - dist * (far - near)); -} -vec3 ld(vec3 dist) { - return (2.0 * near) / (far + near - dist * (far - near)); -} -vec3 srgbToLinear2(vec3 srgb){ - return mix( - srgb / 12.92, - pow(.947867 * srgb + .0521327, vec3(2.4) ), - step( .04045, srgb ) - ); -} -vec3 blackbody2(float Temp) -{ - float t = pow(Temp, -1.5); - float lt = log(Temp); - - vec3 col = vec3(0.0); - col.x = 220000.0 * t + 0.58039215686; - col.y = 0.39231372549 * lt - 2.44549019608; - col.y = Temp > 6500. ? 138039.215686 * t + 0.72156862745 : col.y; - col.z = 0.76078431372 * lt - 5.68078431373; - col = clamp(col,0.0,1.0); - col = Temp < 1000. ? col * Temp * 0.001 : col; - - return srgbToLinear2(col); -} - -vec3 normVec (vec3 vec){ - return vec*inversesqrt(dot(vec,vec)); -} -vec3 viewToWorld(vec3 viewPosition) { - vec4 pos; - pos.xyz = viewPosition; - pos.w = 0.0; - pos = gbufferModelViewInverse * pos; - return pos.xyz; -} - - -#include "/lib/res_params.glsl" -#include "/lib/Shadow_Params.glsl" -#include "/lib/color_transforms.glsl" -#include "/lib/sky_gradient.glsl" -#include "/lib/stars.glsl" -#include "/lib/volumetricClouds.glsl" -#include "/lib/waterBump.glsl" - -#define OVERWORLD_SHADER -#include "/lib/specular.glsl" -#include "/lib/diffuse_lighting.glsl" - -float lengthVec (vec3 vec){ - return sqrt(dot(vec,vec)); -} -#define fsign(a) (clamp((a)*1e35,0.,1.)*2.-1.) -float triangularize(float dither) -{ - float center = dither*2.0-1.0; - dither = center*inversesqrt(abs(center)); - return clamp(dither-fsign(center),0.0,1.0); -} - - -float interleaved_gradientNoise(){ - // vec2 coord = gl_FragCoord.xy + (frameCounter%40000); - vec2 coord = gl_FragCoord.xy + (frameCounter%40000); - // vec2 coord = gl_FragCoord.xy; - float noise = fract( 52.9829189 * fract( (coord.x * 0.06711056) + (coord.y * 0.00583715)) ); - return noise ; -} - -vec2 R2_dither(){ - vec2 alpha = vec2(0.75487765, 0.56984026); - return vec2(fract(alpha.x * gl_FragCoord.x + alpha.y * gl_FragCoord.y + 1.0/1.6180339887 * (frameCounter%40000)), fract((1.0-alpha.x) * gl_FragCoord.x + (1.0-alpha.y) * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter)); -} -float blueNoise(){ - return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * (frameCounter%40000) ); -} -vec4 blueNoise(vec2 coord){ - return texelFetch2D(colortex6, ivec2(coord)%512, 0) ; -} -vec3 fp10Dither(vec3 color,float dither){ - const vec3 mantissaBits = vec3(6.,6.,5.); - vec3 exponent = floor(log2(color)); - return color + dither*exp2(-mantissaBits)*exp2(exponent); -} - -vec3 decode (vec2 encn){ - vec3 n = vec3(0.0); - encn = encn * 2.0 - 1.0; - n.xy = abs(encn); - n.z = 1.0 - n.x - n.y; - n.xy = n.z <= 0.0 ? (1.0 - n.yx) * sign(encn) : encn; - return clamp(normalize(n.xyz),-1.0,1.0); -} - - -vec2 decodeVec2(float a){ - const vec2 constant1 = 65535. / vec2( 256., 65536.); - const float constant2 = 256. / 255.; - return fract( a * constant1 ) * constant2 ; -} - - -vec2 tapLocation(int sampleNumber,int nb, float nbRot,float jitter,float distort){ - float alpha0 = sampleNumber/nb; - float alpha = (sampleNumber+jitter)/nb; - float angle = jitter*6.28 + alpha * 84.0 * 6.28; - - float sin_v, cos_v; - - sin_v = sin(angle); - cos_v = cos(angle); - - return vec2(cos_v, sin_v)*sqrt(alpha); -} -vec3 toShadowSpaceProjected(vec3 p3){ - p3 = mat3(gbufferModelViewInverse) * p3 + gbufferModelViewInverse[3].xyz; - p3 = mat3(shadowModelView) * p3 + shadowModelView[3].xyz; - p3 = diagonal3(shadowProjection) * p3 + shadowProjection[3].xyz; - return p3; -} - -vec2 R2_samples(int n){ - vec2 alpha = vec2(0.75487765, 0.56984026); - return fract(alpha * n); -} - -vec2 tapLocation(int sampleNumber, float spinAngle,int nb, float nbRot,float r0){ - float alpha = (float(sampleNumber*1.0f + r0) * (1.0 / (nb))); - float angle = alpha * (nbRot * 3.14) + spinAngle*3.14; - - float ssR = alpha; - float sin_v, cos_v; - - sin_v = sin(angle); - cos_v = cos(angle); - - return vec2(cos_v, sin_v)*ssR; -} - - -void waterVolumetrics(inout vec3 inColor, vec3 rayStart, vec3 rayEnd, float estEndDepth, float estSunDepth, float rayLength, float dither, vec3 waterCoefs, vec3 scatterCoef, vec3 ambient, vec3 lightSource, float VdotL){ - inColor *= exp(-rayLength * waterCoefs); //No need to take the integrated value - int spCount = rayMarchSampleCount; - vec3 start = toShadowSpaceProjected(rayStart); - vec3 end = toShadowSpaceProjected(rayEnd); - vec3 dV = (end-start); - //limit ray length at 32 blocks for performance and reducing integration error - //you can't see above this anyway - float maxZ = min(rayLength,12.0)/(1e-8+rayLength); - dV *= maxZ; - - - rayLength *= maxZ; - - float dY = normalize(mat3(gbufferModelViewInverse) * rayEnd).y * rayLength; - estEndDepth *= maxZ; - estSunDepth *= maxZ; - - vec3 wpos = mat3(gbufferModelViewInverse) * rayStart + gbufferModelViewInverse[3].xyz; - vec3 dVWorld = (wpos-gbufferModelViewInverse[3].xyz); - - // float phase = (phaseg(VdotL,0.5) + phaseg(VdotL,0.8)) ; - float phase = (phaseg(VdotL,0.6) + phaseg(VdotL,0.8)) * 0.5; - // float phase = phaseg(VdotL, 0.7); - - vec3 absorbance = vec3(1.0); - vec3 vL = vec3(0.0); - - float expFactor = 11.0; - for (int i=0;i -near) ? - (-near -position.z) / dir.z : far*sqrt(3.) ; - vec3 direction = toClipSpace3(position+dir*rayLength)-clipPosition; //convert to clip space - direction.xyz = direction.xyz/max(abs(direction.x)/texelSize.x,abs(direction.y)/texelSize.y); //fixed step size - vec3 stepv = direction * 3.0 * clamp(MC_RENDER_QUALITY,1.,2.0)*vec3(RENDER_SCALE,1.0); - - vec3 spos = clipPosition*vec3(RENDER_SCALE,1.0); - - // this is to remove the "peterpanning" on things outside the shadowmap with SSS - if(outsideShadowMap){ - spos += stepv*dither - stepv*0.9; - }else{ - spos += stepv*dither ; - } - - - for (int i = 0; i < int(quality); i++) { - spos += stepv; - - float sp = texture2D(depthtex1,spos.xy).x; - - if( sp < spos.z) { - float dist = abs(linZ(sp)-linZ(spos.z))/linZ(spos.z); - if (dist < 0.015 ) return i / quality; - } - } - return 1.0; -} - -vec2 tapLocation_alternate( - int sampleNumber, - float spinAngle, - int nb, - float nbRot, - float r0 -){ - float alpha = (float(sampleNumber*1.0f + r0) * (1.0 / (nb))); - float angle = alpha * (nbRot * 3.14) ; - - float ssR = alpha + spinAngle*3.14; - float sin_v, cos_v; - - sin_v = sin(angle); - cos_v = cos(angle); - - return vec2(cos_v, sin_v)*ssR; -} - - -void ssAO(inout vec3 lighting, inout float sss, vec3 fragpos,float mulfov, vec2 noise, vec3 normal, vec2 texcoord, vec3 ambientCoefs, vec2 lightmap, bool isleaves){ - - ivec2 pos = ivec2(gl_FragCoord.xy); - const float tan70 = tan(70.*3.14/180.); - - float dist = 1.0 + clamp(fragpos.z*fragpos.z/50.0,0,2); // shrink sample size as distance increases - float mulfov2 = gbufferProjection[1][1]/(tan70 * dist); - float maxR2 = fragpos.z*fragpos.z*mulfov2*2.*5/50.0; - - #ifdef Ambient_SSS - // float dist3 = clamp(1.0 - exp( fragpos.z*fragpos.z / -50),0,1); - // float maxR2_2 = mix(10.0, fragpos.z*fragpos.z*mulfov2*2./50.0, dist3); - - float maxR2_2 = fragpos.z*fragpos.z*mulfov2*2./50.0; - float dist3 = clamp(1-exp( fragpos.z*fragpos.z / -50),0,1); - if(isleaves) maxR2_2 = mix(10, maxR2_2, dist3); - #endif - - float rd = mulfov2 * 0.1 ; - - vec2 acc = -(TAA_Offset*(texelSize/2))*RENDER_SCALE ; - - int seed = (frameCounter%40000)*2 + (1+frameCounter); - float randomDir = fract(R2_samples(seed).y + noise.x ) * 1.61803398874 ; - - float n = 0.0; - float occlusion = 0.0; - for (int j = 0; j < 7; j++) { - - vec2 sp = tapLocation_alternate(j, 0.0, 7, 20, randomDir); - - vec2 sampleOffset = sp*rd; - ivec2 offset = ivec2(gl_FragCoord.xy + sampleOffset*vec2(viewWidth,viewHeight*aspectRatio)*RENDER_SCALE); - - if (offset.x >= 0 && offset.y >= 0 && offset.x < viewWidth*RENDER_SCALE.x && offset.y < viewHeight*RENDER_SCALE.y ) { - vec3 t0 = toScreenSpace(vec3(offset*texelSize+acc+0.5*texelSize,texelFetch2D(depthtex1,offset,0).x) * vec3(1.0/RENDER_SCALE, 1.0) ); - vec3 vec = (t0.xyz - fragpos); - float dsquared = dot(vec,vec) ; - - - if (dsquared > 1e-5){ - if (dsquared < maxR2){ - float NdotV = clamp(dot(vec*inversesqrt(dsquared), normalize(normal)),0.,1.); - occlusion += NdotV * clamp(1.0-dsquared/maxR2,0.0,1.0); - } - - #ifdef Ambient_SSS - if(dsquared > maxR2_2){ - float NdotV = 1.0 - clamp(dot(vec*dsquared, normalize(normal)),0.,1.); - sss += max((NdotV - (1.0-NdotV)) * clamp(1.0-maxR2_2/dsquared,0.0,1.0) ,0.0); - } - #endif - - n += 1; - } - } - } - - #ifdef Ambient_SSS - sss = max(1.0 - sss/n, 0.0) ; - #endif - occlusion *= AO_Strength; - occlusion *= 2.0; - occlusion = max(1.0 - occlusion/n, 0.0); - - - lighting = lighting*max(occlusion,pow(lightmap.x,4)); -} - -vec3 rayTrace_GI(vec3 dir,vec3 position,float dither, float quality){ - - vec3 clipPosition = toClipSpace3(position); - float rayLength = ((position.z + dir.z * far*sqrt(3.)) > -near) ? - (-near -position.z) / dir.z : far*sqrt(3.); - vec3 direction = normalize(toClipSpace3(position+dir*rayLength)-clipPosition); //convert to clip space - direction.xy = normalize(direction.xy); - - //get at which length the ray intersects with the edge of the screen - vec3 maxLengths = (step(0.,direction)-clipPosition) / direction; - float mult = maxLengths.y; - - vec3 stepv = direction * mult / quality*vec3(RENDER_SCALE,1.0) * dither; - vec3 spos = clipPosition*vec3(RENDER_SCALE,1.0) ; - - spos.xy += TAA_Offset*texelSize*0.5/RENDER_SCALE; - - float biasdist = clamp(position.z*position.z/50.0,1,2); // shrink sample size as distance increases - - for(int i = 0; i < int(quality); i++){ - spos += stepv; - float sp = sqrt(texelFetch2D(colortex4,ivec2(spos.xy/texelSize/4),0).w/65000.0); - float currZ = linZ(spos.z); - - if( sp < currZ) { - float dist = abs(sp-currZ)/currZ; - if (abs(dist) < biasdist*0.05) return vec3(spos.xy, invLinZ(sp))/vec3(RENDER_SCALE,1.0); - } - spos += stepv; - } - return vec3(1.1); -} -vec3 RT(vec3 dir, vec3 position, float noise, float stepsizes){ - float dist = 1.0 + clamp(position.z*position.z/50.0,0,2); // shrink sample size as distance increases - - float stepSize = stepsizes / dist; - int maxSteps = STEPS; - vec3 clipPosition = toClipSpace3(position); - float rayLength = ((position.z + dir.z * sqrt(3.0)*far) > -sqrt(3.0)*near) ? - (-sqrt(3.0)*near -position.z) / dir.z : sqrt(3.0)*far; - vec3 end = toClipSpace3(position+dir*rayLength) ; - vec3 direction = end-clipPosition ; //convert to clip space - - float len = max(abs(direction.x)/texelSize.x,abs(direction.y)/texelSize.y)/stepSize; - //get at which length the ray intersects with the edge of the screen - vec3 maxLengths = (step(0.,direction)-clipPosition) / direction; - - float mult = min(min(maxLengths.x,maxLengths.y),maxLengths.z)*2000.0; - - vec3 stepv = direction/len; - - int iterations = min(int(min(len, mult*len)-2), maxSteps); - - //Do one iteration for closest texel (good contact shadows) - vec3 spos = clipPosition*vec3(RENDER_SCALE,1.0) ; - spos.xy += TAA_Offset*texelSize*0.5*RENDER_SCALE; - spos += stepv/(stepSize/2); - - float distancered = 1.0 + clamp(position.z*position.z/50.0,0,2); // shrink sample size as distance increases - - for(int i = 0; i < iterations; i++){ - if (spos.x < 0.0 || spos.y < 0.0 || spos.z < 0.0 || spos.x > 1.0 || spos.y > 1.0 || spos.z > 1.0) return vec3(1.1); - spos += stepv*noise; - - float sp = sqrt(texelFetch2D(colortex4,ivec2(spos.xy/ texelSize/4),0).w/65000.0); - float currZ = linZ(spos.z); - - if( sp < currZ) { - float dist = abs(sp-currZ)/currZ; - if (dist <= 0.1) return vec3(spos.xy, invLinZ(sp))/vec3(RENDER_SCALE,1.0); - } - } - return vec3(1.1); -} - -vec3 cosineHemisphereSample(vec2 Xi, float roughness){ - float r = sqrt(Xi.x); - float theta = 2.0 * 3.14159265359 * Xi.y; - - float x = r * cos(theta); - float y = r * sin(theta); - - return vec3(x, y, sqrt(clamp(1.0 - Xi.x,0.,1.))); -} - -vec3 TangentToWorld(vec3 N, vec3 H, float roughness){ - vec3 UpVector = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); - vec3 T = normalize(cross(UpVector, N)); - vec3 B = cross(N, T); - - return vec3((T * H.x) + (B * H.y) + (N * H.z)); -} - -void ApplySSRT(inout vec3 lighting, vec3 normal,vec2 noise,vec3 fragpos, vec2 lightmaps, vec3 skylightcolor, vec3 torchcolor, bool isGrass){ - int nrays = RAY_COUNT; - - vec3 radiance = vec3(0.0); - - vec3 occlusion = vec3(0.0); - vec3 skycontribution = vec3(0.0); - - vec3 occlusion2 = vec3(0.0); - vec3 skycontribution2 = vec3(0.0); - - float skyLM = 0.0; - vec3 torchlight = vec3(0.0); - DoRTAmbientLighting(torchcolor, lightmaps, skyLM, torchlight, skylightcolor); - - for (int i = 0; i < nrays; i++){ - int seed = (frameCounter%40000)*nrays+i; - vec2 ij = fract(R2_samples(seed) + noise ); - - vec3 rayDir = TangentToWorld(normal, normalize(cosineHemisphereSample(ij,1.0)) ,1.0); - - #ifdef HQ_SSGI - vec3 rayHit = rayTrace_GI( mat3(gbufferModelView) * rayDir, fragpos, blueNoise(), 50.); // ssr rt - #else - vec3 rayHit = RT(mat3(gbufferModelView)*rayDir, fragpos, blueNoise(), 30.); // choc sspt - #endif - - #ifdef SKY_CONTRIBUTION_IN_SSRT - if(isGrass) rayDir.y = clamp(rayDir.y + 0.5,-1,1); - skycontribution = (skyCloudsFromTex(rayDir, colortex4).rgb / 15.0) * skyLM + torchlight; - #else - if(isGrass) rayDir.y = clamp(rayDir.y + 0.25,-1,1); - - skycontribution = skylightcolor * 2 * (max(rayDir.y,0.0)*0.9+0.1) + torchlight; - - #if indirect_effect == 4 - skycontribution2 = skylightcolor + torchlight; - #endif - - #endif - - if (rayHit.z < 1.){ - - #if indirect_effect == 4 - vec3 previousPosition = mat3(gbufferModelViewInverse) * toScreenSpace(rayHit) + gbufferModelViewInverse[3].xyz + cameraPosition-previousCameraPosition; - previousPosition = mat3(gbufferPreviousModelView) * previousPosition + gbufferPreviousModelView[3].xyz; - previousPosition.xy = projMAD(gbufferPreviousProjection, previousPosition).xy / -previousPosition.z * 0.5 + 0.5; - - if (previousPosition.x > 0.0 && previousPosition.y > 0.0 && previousPosition.x < 1.0 && previousPosition.x < 1.0){ - radiance += (texture2D(colortex5,previousPosition.xy).rgb + skycontribution) * GI_Strength; - } else{ - radiance += skycontribution; - } - - #else - radiance += skycontribution; - #endif - - occlusion += skycontribution * GI_Strength; - - #if indirect_effect == 4 - occlusion2 += skycontribution2 * GI_Strength; - #endif - - } else { - radiance += skycontribution; - } - } - - occlusion *= AO_Strength; - - #if indirect_effect == 4 - lighting = max(radiance/nrays - max(occlusion, occlusion2*0.5)/nrays, 0.0); - #else - lighting = max(radiance/nrays - occlusion/nrays, 0.0); - #endif - -} - - -vec3 SubsurfaceScattering_sun(vec3 albedo, float Scattering, float Density, float lightPos){ - - float labcurve = pow(Density,LabSSS_Curve); - float density = sqrt(30 - labcurve*15); - - vec3 absorbed = max(1.0 - albedo,0.0); - vec3 scatter = exp(absorbed * -sqrt(Scattering * 5)) * exp(Scattering * -density); - - scatter *= labcurve; - scatter *= 0.5 + CustomPhase(lightPos, 1.0,30.0)*20; - - return scatter; - -} - -vec3 SubsurfaceScattering_sky(vec3 albedo, float Scattering, float Density){ - - vec3 absorbed = max(luma(albedo) - albedo,0.0); - vec3 scatter = sqrt(exp(-(absorbed * Scattering * 15))) * (1.0 - Scattering); - - // scatter *= pow(Density,LabSSS_Curve); - scatter *= clamp(1 - exp(Density * -10),0,1); - - return scatter; -} - -void ScreenSpace_SSS(inout float sss, vec3 fragpos, vec2 noise, vec3 normal, bool isleaves){ - ivec2 pos = ivec2(gl_FragCoord.xy); - const float tan70 = tan(70.*3.14/180.); - - float dist = 1.0 + (clamp(fragpos.z*fragpos.z/50.0,0,2)); // shrink sample size as distance increases - float mulfov2 = gbufferProjection[1][1]/(tan70 * dist); - - float maxR2_2 = fragpos.z*fragpos.z*mulfov2*2./50.0; - - float dist3 = clamp(1-exp( fragpos.z*fragpos.z / -50),0,1); - if(isleaves) maxR2_2 = mix(10, maxR2_2, dist3); - - float rd = mulfov2 * 0.1; - - - vec2 acc = -(TAA_Offset*(texelSize/2))*RENDER_SCALE ; - - int seed = (frameCounter%40000)*2 + (1+frameCounter); - float randomDir = fract(R2_samples(seed).y + noise.x ) * 1.61803398874 ; - - float n = 0.0; - for (int j = 0; j < 7 ;j++) { - - vec2 sp = tapLocation_alternate(j, 0.0, 7, 20, randomDir); - vec2 sampleOffset = sp*rd; - ivec2 offset = ivec2(gl_FragCoord.xy + sampleOffset*vec2(viewWidth,viewHeight*aspectRatio)*RENDER_SCALE); - - if (offset.x >= 0 && offset.y >= 0 && offset.x < viewWidth*RENDER_SCALE.x && offset.y < viewHeight*RENDER_SCALE.y ) { - vec3 t0 = toScreenSpace(vec3(offset*texelSize+acc+0.5*texelSize,texelFetch2D(depthtex1,offset,0).x) * vec3(1.0/RENDER_SCALE, 1.0) ); - vec3 vec = t0.xyz - fragpos; - float dsquared = dot(vec,vec); - - if (dsquared > 1e-5){ - if(dsquared > maxR2_2){ - float NdotV = 1.0 - clamp(dot(vec*dsquared, normalize(normal)),0.,1.); - sss += max((NdotV - (1.0-NdotV)) * clamp(1.0-maxR2_2/dsquared,0.0,1.0) ,0.0); - } - n += 1; - } - } - } - sss = max(1.0 - sss/n, 0.0); -} - - -float densityAtPosSNOW(in vec3 pos){ - pos /= 18.; - pos.xz *= 0.5; - vec3 p = floor(pos); - vec3 f = fract(pos); - f = (f*f) * (3.-2.*f); - vec2 uv = p.xz + f.xz + p.y * vec2(0.0,193.0); - vec2 coord = uv / 512.0; - vec2 xy = texture2D(noisetex, coord).yx; - return mix(xy.r,xy.g, f.y); -} - -// Emin's and Gri's combined ideas to stop peter panning and light leaking, also has little shadowacne so thats nice -// https://www.complementary.dev/reimagined -// https://github.com/gri573 -void GriAndEminShadowFix( - inout vec3 WorldPos, - vec3 FlatNormal, - float VanillaAO, - float SkyLightmap, - bool Entities -){ - - float DistanceOffset = clamp(0.1 + length(WorldPos) / (shadowMapResolution*0.20), 0.0,1.0) ; - vec3 Bias = FlatNormal * DistanceOffset; // adjust the bias thingy's strength as it gets farther away. - - vec3 finalBias = Bias; - - // stop lightleaking - vec2 scale = vec2(0.5); scale.y *= 0.5; - vec3 zoomShadow = scale.y - scale.x * fract(WorldPos + cameraPosition + Bias*scale.y); - if(SkyLightmap < 0.1 && !Entities) finalBias = mix(Bias, zoomShadow, clamp(VanillaAO*5,0,1)); - - WorldPos += finalBias; -} - -void Emission( - inout vec3 Lighting, - vec3 Albedo, - float Emission -){ - // if( Emission < 255.0/255.0 ) Lighting = mix(Lighting, Albedo * Emissive_Brightness, pow(Emission, Emissive_Curve)); // old method.... idk why - if( Emission < 255.0/255.0 ) Lighting += (Albedo * Emissive_Brightness) * pow(Emission, Emissive_Curve); -} - -vec3 Moon(vec3 PlayerPos, vec3 WorldSunVec, vec3 Color, inout vec3 occludeStars){ - - float Shape = clamp((exp(1 + -1000 * dot(WorldSunVec+PlayerPos,PlayerPos)) - 1.5),0.0,25.0); - occludeStars *= max(1.0-Shape*5,0.0); - - float shape2 = pow(exp(Shape * -10),0.15) * 255.0; - - vec3 sunNormal = vec3(dot(WorldSunVec+PlayerPos, vec3(shape2,0,0)), dot(PlayerPos+WorldSunVec, vec3(0,shape2,0)), -dot(WorldSunVec, PlayerPos) * 15.0); - - - // even has a little tilt approximation haha.... yeah.... - vec3[8] phase = vec3[8](vec3( -1.0, -0.5, 1.0 ), - vec3( -1.0, -0.5, 0.35 ), - vec3( -1.0, -0.5, 0.2 ), - vec3( -1.0, -0.5, 0.1 ), - vec3( 1.0, 0.25, -1.0 ), - vec3( 1.0, 0.25, 0.1 ), - vec3( 1.0, 0.25, 0.2 ), - vec3( 1.0, 0.25, 0.35 ) - ); - - vec3 LightDir = phase[moonPhase]; - - return Shape * pow(clamp(dot(sunNormal,LightDir)/5,0.0,1.5),5) * Color + clamp(Shape * 4.0 * pow(shape2/200,2.0),0.0,1.0)*0.004; -} - -vec3 applyContrast(vec3 color, float contrast){ - return (color - 0.5) * contrast + 0.5; -} - - -#include "/lib/PhotonGTAO.glsl" - -uniform float detectThunderStorm; -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -void main() { - - vec2 texcoord = gl_FragCoord.xy*texelSize; - - float z0 = texture2D(depthtex0,texcoord).x; - float z = texture2D(depthtex1,texcoord).x; - float TranslucentDepth = clamp( ld(z0)-ld(z0),0.0,1.0); - - vec2 tempOffset=TAA_Offset; - vec3 fragpos = toScreenSpace(vec3(texcoord/RENDER_SCALE-TAA_Offset*texelSize*0.5,z)); - vec3 fragpos_rtshadow = toScreenSpace(vec3(texcoord/RENDER_SCALE,z)); - vec3 fragpos_handfix = fragpos; - - if ( z < 0.56) fragpos_handfix.z /= MC_HAND_DEPTH; // fix lighting on hand - - vec3 p3 = mat3(gbufferModelViewInverse) * fragpos; - vec3 np3 = normVec(p3); - - p3 += gbufferModelViewInverse[3].xyz; - - - float dirtAmount = Dirt_Amount; - vec3 waterEpsilon = vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B); - - vec3 dirtEpsilon = vec3(Dirt_Absorb_R, Dirt_Absorb_G, Dirt_Absorb_B); - vec3 totEpsilon = dirtEpsilon*dirtAmount + waterEpsilon; - vec3 scatterCoef = dirtAmount * vec3(Dirt_Scatter_R, Dirt_Scatter_G, Dirt_Scatter_B) / pi; - - #ifdef AEROCHROME_MODE - totEpsilon *= 10.0; - scatterCoef *= 0.1; - #endif - - float noise = blueNoise(); - - float iswaterstuff = texture2D(colortex7,texcoord).a ; - bool iswater = iswaterstuff > 0.99; - - ////// --------------- UNPACK OPAQUE GBUFFERS --------------- ////// - vec4 data = texture2D(colortex1,texcoord); - vec4 dataUnpacked0 = vec4(decodeVec2(data.x),decodeVec2(data.y)); // albedo, masks - vec4 dataUnpacked1 = vec4(decodeVec2(data.z),decodeVec2(data.w)); // normals, lightmaps - // vec4 dataUnpacked2 = vec4(decodeVec2(data.z),decodeVec2(data.w)); - - vec3 albedo = toLinear(vec3(dataUnpacked0.xz,dataUnpacked1.x)); - vec2 lightmap = dataUnpacked1.yz; - vec3 normal = decode(dataUnpacked0.yw); - - - ////// --------------- UNPACK TRANSLUCENT GBUFFERS --------------- ////// - // vec4 dataTranslucent = texture2D(colortex11,texcoord); - // vec4 dataT_Unpacked0 = vec4(decodeVec2(dataTranslucent.x),decodeVec2(dataTranslucent.y)); - // vec4 dataT_Unpacked1 = vec4(decodeVec2(dataTranslucent.z),decodeVec2(dataTranslucent.w)); - // vec4 dataT_Unpacked2 = vec4(decodeVec2(dataTranslucent.z),decodeVec2(dataTranslucent.w)); - - ////// --------------- UNPACK MISC --------------- ////// - vec4 SpecularTex = texture2D(colortex8,texcoord); - float LabSSS = clamp((-64.0 + SpecularTex.z * 255.0) / 191.0 ,0.0,1.0); - - vec4 normalAndAO = texture2D(colortex15,texcoord); - vec3 FlatNormals = normalAndAO.rgb * 2.0 - 1.0; - vec3 slopednormal = normal; - - #ifdef POM - #ifdef Horrible_slope_normals - - vec3 ApproximatedFlatNormal = normalize(cross(dFdx(p3), dFdy(p3))); // it uses depth that has POM written to it. - - slopednormal = normalize(clamp(normal, ApproximatedFlatNormal*2.0 - 1.0, ApproximatedFlatNormal*2.0 + 1.0) ); - #endif - #endif - - // masks - bool isLeaf = abs(dataUnpacked1.w-0.55) <0.01; - bool lightningBolt = abs(dataUnpacked1.w-0.50) <0.01; - bool entities = abs(dataUnpacked1.w-0.45) < 0.01; - bool hand = abs(dataUnpacked1.w-0.75) < 0.01; - // bool blocklights = abs(dataUnpacked1.w-0.8) <0.01; - bool isGrass = abs(dataUnpacked1.w-0.60) < 0.01; - - float vanilla_AO = normalAndAO.a; - - vec3 filtered = vec3(1.412,1.0,0.0); - if (!hand) filtered = texture2D(colortex3,texcoord).rgb; - - vec3 ambientCoefs = slopednormal/dot(abs(slopednormal),vec3(1.)); - - vec3 DirectLightColor = lightCol.rgb/80.0; - vec3 Direct_SSS = vec3(0.0); - - #ifdef ambientLight_only - DirectLightColor = vec3(0.0); - #endif - - #ifdef OLD_LIGHTLEAK_FIX - DirectLightColor *= pow(clamp(eyeBrightnessSmooth.y/240. + lightmap.y,0.0,1.0),2.0); - #else - if(hand) DirectLightColor *= pow(clamp(eyeBrightnessSmooth.y/240. + lightmap.y,0.0,1.0),2.0); - #endif - - int shadowmapindicator = 0; - float cloudShadow = 1.0; - - vec3 AmbientLightColor = averageSkyCol_Clouds; - vec3 Indirect_SSS = vec3(0.0); - - vec3 debug = vec3(0.0); - - if ( z >= 1.) {//sky - - //////////////////////////////////////////////////////////////////////////////// - //////////////////////////////// SKY STUFF //////////////////////////////// - //////////////////////////////////////////////////////////////////////////////// - - #ifdef Compositing_Sky - - gl_FragData[0].rgb = vec3(CompSky_R, CompSky_G, CompSky_B); - - #else - - vec3 background = vec3(0.0); - vec3 orbitstar = vec3(np3.x,abs(np3.y),np3.z); - orbitstar.x -= WsunVec.x*0.2; - background += stars(orbitstar) * 10.0 ; - - #ifndef ambientLight_only - background += Moon(np3, -WsunVec, DirectLightColor*20, background); // moon - background += drawSun(dot(lightCol.a * WsunVec, np3),0, DirectLightColor,vec3(0.0)) ; // sun - // vec3 moon = drawSun(dot(lightCol.a * -WsunVec, np3),0, DirectLightColor/5,vec3(0.0)) ; // moon - #endif - - background *= clamp( (np3.y+ 0.02)*5.0 + (eyeAltitude - 319)/800000 ,0.0,1.0); - - vec3 skyTEX = skyFromTex(np3,colortex4)/150.0 * 5.0; - background += skyTEX; - - vec4 cloud = texture2D_bicubic(colortex0,texcoord*CLOUDS_QUALITY); - if(eyeAltitude < 25000) background = background*cloud.a + cloud.rgb; - - gl_FragData[0].rgb = clamp(fp10Dither(background ,triangularize(noise)),0.0,65000.); - - #endif - - }else{//land - - //////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////// DIRECT LIGHTING //////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////// - - vec3 Direct_lighting = vec3(1.0); - - float Shadows = clamp(1.0 - filtered.b,0.0,1.0); - float SHADOWBLOCKERDEPTBH = filtered.y; - - float NdotL = dot(slopednormal,WsunVec); - NdotL = clamp((-15 + NdotL*255.0) / 240.0 ,0.0,1.0); - - - float shadowNDOTL = NdotL; - #ifndef Variable_Penumbra_Shadows - shadowNDOTL += LabSSS; - #endif - - vec3 p3_shadow = mat3(gbufferModelViewInverse) * fragpos_handfix + gbufferModelViewInverse[3].xyz; - - if(!hand) GriAndEminShadowFix(p3_shadow, viewToWorld(FlatNormals), vanilla_AO, lightmap.y, entities); - - vec3 projectedShadowPosition = mat3(shadowModelView) * p3_shadow + shadowModelView[3].xyz; - projectedShadowPosition = diagonal3(shadowProjection) * projectedShadowPosition + shadowProjection[3].xyz; - - //apply distortion - float distortFactor = calcDistort(projectedShadowPosition.xy); - projectedShadowPosition.xy *= distortFactor; - - - bool ShadowBounds = false; - if(shadowDistanceRenderMul > 0.0) ShadowBounds = length(p3_shadow) < max(shadowDistance - 20,0.0); - - if(shadowDistanceRenderMul < 0.0) ShadowBounds = abs(projectedShadowPosition.x) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.y) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.z) < 6.0; - - //do shadows only if on shadow map - if(ShadowBounds){ - if (shadowNDOTL >= -0.001){ - Shadows = 0.0; - projectedShadowPosition = projectedShadowPosition * vec3(0.5,0.5,0.5/6.0) + vec3(0.5); - - #ifdef BASIC_SHADOW_FILTER - float rdMul = filtered.x*distortFactor*d0*k/shadowMapResolution; - - for(int i = 0; i < SHADOW_FILTER_SAMPLE_COUNT; i++){ - vec2 offsetS = tapLocation(i,SHADOW_FILTER_SAMPLE_COUNT,1.618,noise,0.0); - - float isShadow = shadow2D(shadow,projectedShadowPosition + vec3(rdMul*offsetS, 0.0) ).x; - Shadows += isShadow/SHADOW_FILTER_SAMPLE_COUNT; - } - #else - Shadows = shadow2D(shadow, projectedShadowPosition).x; - #endif - } - shadowmapindicator = 1; - } - - bool outsideShadowMap = shadowmapindicator < 1; - - if(outsideShadowMap && !iswater) Shadows = min(max(lightmap.y-0.8, 0.0) * 25,1.0); - - //////////////////////////////////////////////////////////////////////////////// - //////////////////////////////// SUN SSS //////////////////////////////// - //////////////////////////////////////////////////////////////////////////////// - - #if SSS_TYPE != 0 - #ifndef Variable_Penumbra_Shadows - if(LabSSS > 0 ) { - SHADOWBLOCKERDEPTBH = pow(1.0 - Shadows,2); - } - #endif - - if (outsideShadowMap) SHADOWBLOCKERDEPTBH = 0.0; - - float sunSSS_density = LabSSS; - - #ifndef RENDER_ENTITY_SHADOWS - if(entities) sunSSS_density = 0.0; - #endif - - - Direct_SSS = SubsurfaceScattering_sun(albedo, SHADOWBLOCKERDEPTBH, sunSSS_density, clamp(dot(np3, WsunVec),0.0,1.0)) ; - - if (isEyeInWater == 0) Direct_SSS *= clamp(pow(eyeBrightnessSmooth.y/240. + lightmap.y,2.0) ,0.0,1.0); // light leak fix - #endif - - if (!hand){ - #ifdef SCREENSPACE_CONTACT_SHADOWS - bool dodistantSSS = outsideShadowMap && LabSSS > 0.0; - float screenShadow = rayTraceShadow(lightCol.a*sunVec, fragpos_rtshadow, interleaved_gradientNoise(), dodistantSSS); - screenShadow *= screenShadow; - - Shadows = min(screenShadow, Shadows); - - if (outsideShadowMap) Direct_SSS *= Shadows; - - #else - - if (outsideShadowMap) Direct_SSS = vec3(0.0); - #endif - } - - #if SSS_TYPE != 0 - Direct_SSS *= 1.0-clamp(NdotL*Shadows,0,1); - #endif - - #ifdef VOLUMETRIC_CLOUDS - #ifdef CLOUDS_SHADOWS - cloudShadow = GetCloudShadow(p3); - Shadows *= cloudShadow; - Direct_SSS *= cloudShadow; - #endif - #endif - - //////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////// INDIRECT LIGHTING //////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////// - - vec3 Indirect_lighting = vec3(1.0); - - if(isGrass) ambientCoefs.y = 0.75; - float skylight = clamp(ambientCoefs.y + 0.5,0.25,2.0) * 1.35; - - AmbientLightColor += (lightningEffect * 10) * skylight * pow(lightmap.y,2); - - #ifndef ambientSSS_view - - #if indirect_effect == 2 - skylight = 1.0; - #endif - - #if indirect_effect != 3 || indirect_effect != 4 - Indirect_lighting = DoAmbientLighting(AmbientLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.xy, skylight); - #endif - - #else - Indirect_lighting = vec3(0.0); - #endif - - //////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////// UNDER WATER SHADING //////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////// - - if ((isEyeInWater == 0 && iswater) || (isEyeInWater == 1 && !iswater)){ - - vec3 fragpos0 = toScreenSpace(vec3(texcoord/RENDER_SCALE-TAA_Offset*texelSize*0.5,z0)); - float Vdiff = distance(fragpos,fragpos0); - float VdotU = np3.y; - float estimatedDepth = Vdiff * abs(VdotU); //assuming water plane - estimatedDepth = estimatedDepth; - // make it such that the estimated depth flips to be correct when entering water. - - if (isEyeInWater == 1) estimatedDepth = (1.0-lightmap.y)*16.0; - - float estimatedSunDepth = Vdiff; //assuming water plane - vec3 Absorbtion = exp2(-totEpsilon*estimatedDepth); - - // caustics... - float Direct_caustics = waterCaustics(p3 + cameraPosition, WsunVec) * cloudShadow; - // float Ambient_Caustics = waterCaustics(p3 + cameraPosition, vec3(0.5, 1, 0.5)); - - // apply caustics to the lighting - DirectLightColor *= 1.0 + max(pow(Direct_caustics * 3.0, 2.0),0.0); - // Indirect_lighting *= 0.5 + max(pow(Ambient_Caustics, 2.0),0.0); - - DirectLightColor *= Absorbtion; - if(isEyeInWater == 1 ) Indirect_lighting = (Indirect_lighting/exp2(-estimatedDepth*0.5)) * Absorbtion; - - if(isEyeInWater == 0) DirectLightColor *= max(eyeBrightnessSmooth.y/240., 0.0); - DirectLightColor *= cloudShadow; - } - - //////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////// EFFECTS FOR INDIRECT //////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////// - - vec3 AO = vec3(1.0); - float SkySSS = 0.0; - - // vanilla AO - #if indirect_effect == 0 - AO = vec3( exp( (vanilla_AO*vanilla_AO) * -5) ) ; - #endif - - // SSAO + vanilla AO - #if indirect_effect == 1 - AO = vec3( exp( (vanilla_AO*vanilla_AO) * -3) ) ; - if (!hand) ssAO(AO, SkySSS, fragpos, 1.0, blueNoise(gl_FragCoord.xy).rg, FlatNormals , texcoord, ambientCoefs, lightmap.xy, isLeaf); - #endif - - // GTAO - #if indirect_effect == 2 - int seed = (frameCounter%40000); - vec2 r2 = fract(R2_samples(seed) + blueNoise(gl_FragCoord.xy).rg); - if (!hand) AO = ambient_occlusion(vec3(texcoord/RENDER_SCALE-TAA_Offset*texelSize*0.5,z), fragpos, worldToView(slopednormal), r2, debug) * vec3(1.0); - #endif - - // RTAO and/or SSGI - #if indirect_effect == 3 || indirect_effect == 4 - AO = vec3(1.0); - if (!hand) ApplySSRT(Indirect_lighting, normal, blueNoise(gl_FragCoord.xy).rg, fragpos, lightmap.xy, AmbientLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), isGrass); - #endif - - #ifndef AO_in_sunlight - AO = mix(AO,vec3(1.0), min(NdotL*Shadows,1.0)); - #endif - - Indirect_lighting *= AO; - - //////////////////////////////////////////////////////////////////////////////// - //////////////////////////////// SKY SSS //////////////////////////////// - //////////////////////////////////////////////////////////////////////////////// - - #ifdef Ambient_SSS - if (!hand){ - - vec3 SSS_forSky = vec3(0.0); - - #if indirect_effect != 1 - ScreenSpace_SSS(SkySSS, fragpos, blueNoise(gl_FragCoord.xy).rg, FlatNormals, isLeaf); - #endif - - vec3 ambientColor = ((AmbientLightColor * ambient_brightness) / 30.0 ) * 1.5; - float skylightmap = pow(lightmap.y,3); - float uplimit = clamp(1.0-pow(clamp(ambientCoefs.y + 0.5,0.0,1.0),2),0,1); - - SSS_forSky = SubsurfaceScattering_sky(albedo, SkySSS, LabSSS); - SSS_forSky *= ambientColor; - SSS_forSky *= skylightmap; - SSS_forSky *= uplimit; - - // Combine with the other SSS - Indirect_SSS += SSS_forSky; - - SSS_forSky = vec3((1.0 - SkySSS) * LabSSS); - SSS_forSky *= ambientColor; - SSS_forSky *= skylightmap; - - ////light up dark parts so its more visible - Indirect_lighting = max(Indirect_lighting, SSS_forSky); - } - #endif - - //////////////////////////////// //////////////////////////////// - //////////////////////////////// FINALIZE //////////////////////////////// - //////////////////////////////// //////////////////////////////// - - #ifdef Seasons - #ifdef Snowy_Winter - - vec3 snow_p3 = p3 + cameraPosition ; - - snow_p3 /= 75.0; - - // float resolution = 1000.; - // snow_p3 = (fract(snow_p3 * resolution) / resolution) - snow_p3; - - float SnowPatches = texture2D(noisetex, snow_p3.xz).r; - // float SnowPatches = densityAtPosSNOW(snow_p3); - - SnowPatches = 1.0 - clamp( exp(pow(SnowPatches,3.5) * -100.0) ,0,1); - SnowPatches *= clamp(sqrt(normal.y),0,1) * clamp(pow(lightmap.y,25)*25,0,1); - - SnowPatches = mix(0.0, SnowPatches, WinterTimeForSnow); - - if(!hand && !iswater && !entities && isEyeInWater == 0){ - albedo = mix(albedo, vec3(0.8,0.9,1.0), SnowPatches); - SpecularTex.rg = mix(SpecularTex.rg, vec2(1,0.05), SnowPatches); - } - #endif - #endif - - Direct_lighting = DoDirectLighting(DirectLightColor, Shadows, NdotL, 0.0); - Direct_SSS *= DirectLightColor; // do this here so it gets underwater absorbtion. - - vec3 FINAL_COLOR = Indirect_lighting + Indirect_SSS + Direct_lighting + Direct_SSS ; - - #ifndef ambientSSS_view - FINAL_COLOR *= albedo; - #endif - - #ifdef Specular_Reflections - // MaterialReflections(FINAL_COLOR, SpecularTex.r, SpecularTex.ggg, albedo, WsunVec, (Shadows*NdotL)*DirectLightColor, lightmap.y, slopednormal, np3, fragpos, vec3(blueNoise(gl_FragCoord.xy).rg, interleaved_gradientNoise()), hand, entities); - - vec3 specNoise = vec3(blueNoise(gl_FragCoord.xy).rg, interleaved_gradientNoise()); - - DoSpecularReflections(FINAL_COLOR, fragpos, np3, WsunVec, specNoise, slopednormal, SpecularTex.r, SpecularTex.g, albedo, DirectLightColor*NdotL*Shadows, lightmap.y, hand); - #endif - - Emission(FINAL_COLOR, albedo, SpecularTex.a); - - if(lightningBolt) FINAL_COLOR.rgb += vec3(77.0, 153.0, 255.0); - - gl_FragData[0].rgb = FINAL_COLOR; - - } - - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////// UNDERWATER FOG //////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - - if (iswater && isEyeInWater == 0){ - vec3 fragpos0 = toScreenSpace(vec3(texcoord/RENDER_SCALE-TAA_Offset*texelSize*0.5,z0)); - float Vdiff = distance(fragpos,fragpos0); - float VdotU = np3.y; - float estimatedDepth = Vdiff * abs(VdotU) ; //assuming water plane - float estimatedSunDepth = estimatedDepth/abs(WsunVec.y); //assuming water plane - - float custom_lightmap_T = clamp(pow(texture2D(colortex14, texcoord).a,3.0),0.0,1.0); - - vec3 lightColVol = lightCol.rgb / 80.; - // if(shadowmapindicator < 1) lightColVol *= clamp((custom_lightmap_T-0.8) * 15,0,1) - - vec3 lightningColor = (lightningEffect / 3) * (max(eyeBrightnessSmooth.y,0)/240.); - vec3 ambientColVol = max((averageSkyCol_Clouds / 30.0) * custom_lightmap_T, vec3(0.2,0.4,1.0) * (MIN_LIGHT_AMOUNT*0.01 + nightVision)) + lightningColor; - - waterVolumetrics(gl_FragData[0].rgb, fragpos0, fragpos, estimatedDepth , estimatedSunDepth, Vdiff, noise, totEpsilon, scatterCoef, ambientColVol, lightColVol, dot(np3, WsunVec)); - } - - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////// MISC EFFECTS //////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - - - #if DOF_QUALITY == 5 - vec3 laserColor; - #if FOCUS_LASER_COLOR == 0 // Red - laserColor = vec3(25, 0, 0); - #elif FOCUS_LASER_COLOR == 1 // Green - laserColor = vec3(0, 25, 0); - #elif FOCUS_LASER_COLOR == 2 // Blue - laserColor = vec3(0, 0, 25); - #elif FOCUS_LASER_COLOR == 3 // Pink - laserColor = vec3(25, 10, 15); - #elif FOCUS_LASER_COLOR == 4 // Yellow - laserColor = vec3(25, 25, 0); - #elif FOCUS_LASER_COLOR == 5 // White - laserColor = vec3(25); - #endif - - #if MANUAL_FOCUS == -2 - float focusDist = rodExposureDepth.y*far; - #elif MANUAL_FOCUS == -1 - float focusDist = mix(pow(512.0, screenBrightness), 512.0 * screenBrightness, 0.25); - #else - float focusDist = MANUAL_FOCUS; - #endif - - if( hideGUI < 1.0) gl_FragData[0].rgb += laserColor * pow( clamp( 1.0-abs(focusDist-abs(fragpos.z)) ,0,1),25) ; - #endif - -/* DRAWBUFFERS:3 */ -} \ No newline at end of file diff --git a/shaders/composite1.vsh b/shaders/composite1.vsh deleted file mode 100644 index 9c984cd..0000000 --- a/shaders/composite1.vsh +++ /dev/null @@ -1,101 +0,0 @@ -#version 120 -//#extension GL_EXT_gpu_shader4 : disable -#include "/lib/settings.glsl" - -flat varying vec3 averageSkyCol_Clouds; -flat varying vec4 lightCol; - -flat varying vec2 rodExposureDepth; - -flat varying vec3 WsunVec; -flat varying float tempOffsets; -flat varying vec2 TAA_Offset; -flat varying vec3 zMults; - -attribute vec4 mc_Entity; -uniform sampler2D colortex4; -varying vec4 lmtexcoord; -// varying float vanilla_ao; - -uniform float far; -uniform float near; -uniform mat4 gbufferModelViewInverse; -uniform vec3 sunPosition; -uniform float sunElevation; -uniform int frameCounter; - -// uniform float sandStorm; - -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.); -float luma(vec3 color) { - return dot(color,vec3(0.299, 0.587, 0.114)); -} - -#include "/lib/util.glsl" -#include "/lib/res_params.glsl" - - - - - -#define SEASONS_VSH -#include "/lib/climate_settings.glsl" - -flat varying float WinterTimeForSnow; - - - - -void main() { - gl_Position = ftransform(); - - -// if (gl_FragCoord.x < 1. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) - - averageSkyCol_Clouds = texelFetch2D(colortex4,ivec2(0,37),0).rgb; - - // averageSkyCol = texelFetch2D(colortex4,ivec2(1,37),0).rgb; - // averageSkyCol_Clouds = texelFetch2D(colortex4,ivec2(1,37),0).rgb;; - // sunColor = texelFetch2D(colortex4,ivec2(6,37),0).rgb; - - // moonColor = texelFetch2D(colortex4,ivec2(13,37),0).rgb; - - - vec3 sc = texelFetch2D(colortex4,ivec2(6,37),0).rgb; - lightCol.a = float(sunElevation > 1e-5)*2-1.; - lightCol.rgb = sc; - - WsunVec = lightCol.a*normalize(mat3(gbufferModelViewInverse) *sunPosition); - zMults = vec3((far * near)*2.0,far+near,far-near); - - rodExposureDepth = texelFetch2D(colortex4,ivec2(14,37),0).rg; - rodExposureDepth.y = sqrt(rodExposureDepth.y/65000.0); - - WinterTimeForSnow = 0.0; - - #ifdef Seasons - #ifdef Snowy_Winter - vec3 color1 = vec3(0.0); - vec3 color2 = color1; - YearCycleColor(color1, color2, WinterTimeForSnow); - #endif - #endif - - - TAA_Offset = offsets[frameCounter%8]; - - #ifndef TAA - TAA_Offset = vec2(0.0); - #endif - - #ifdef TAA_UPSCALING - gl_Position.xy = (gl_Position.xy*0.5+0.5)*RENDER_SCALE*2.0-1.0; - #endif -} diff --git a/shaders/composite10.vsh b/shaders/composite10.vsh deleted file mode 100644 index 86ba64b..0000000 --- a/shaders/composite10.vsh +++ /dev/null @@ -1,18 +0,0 @@ -#version 120 -#include "/lib/settings.glsl" -#include "/lib/res_params.glsl" -uniform float viewWidth; -uniform float viewHeight; -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// - -void main() { - //Improves performances and makes sure bloom radius stays the same at high resolution (>1080p) - vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.)); - gl_Position = ftransform(); - //*0.51 to avoid errors when sampling outside since clearing is disabled - gl_Position.xy = (gl_Position.xy*0.5+0.5)*0.51*BLOOM_QUALITY/clampedRes*vec2(1920.0,1080.)*2.0-1.0; -} diff --git a/shaders/composite11.vsh b/shaders/composite11.vsh deleted file mode 100644 index e5dec68..0000000 --- a/shaders/composite11.vsh +++ /dev/null @@ -1,38 +0,0 @@ -#version 120 -//#extension GL_EXT_gpu_shader4 : disable -#include "/lib/settings.glsl" - - -varying vec2 texcoord; -flat varying vec4 exposure; -flat varying vec2 rodExposureDepth; -uniform sampler2D colortex4; - -uniform vec2 texelSize; -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.); - -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// - -void main() { - - - gl_Position = ftransform(); - - - texcoord = gl_MultiTexCoord0.xy; - exposure=vec4(texelFetch2D(colortex4,ivec2(10,37),0).r*vec3(FinalR,FinalG,FinalB),texelFetch2D(colortex4,ivec2(10,37),0).r); - rodExposureDepth = texelFetch2D(colortex4,ivec2(14,37),0).rg; - rodExposureDepth.y = sqrt(rodExposureDepth.y/65000.0); -} diff --git a/shaders/composite2.fsh b/shaders/composite2.fsh deleted file mode 100644 index b9610d1..0000000 --- a/shaders/composite2.fsh +++ /dev/null @@ -1,406 +0,0 @@ -#version 120 -//Volumetric fog rendering -//#extension GL_EXT_gpu_shader4 : disable - -#include "/lib/settings.glsl" - -flat varying vec4 lightCol; -flat varying vec3 sunColor; -flat varying vec3 moonColor; - -flat varying vec3 averageSkyCol_Clouds; -flat varying vec3 averageSkyCol; - -flat varying float tempOffsets; -uniform sampler2D noisetex; -uniform sampler2D depthtex0; -uniform sampler2D depthtex1; -uniform sampler2DShadow shadow; -flat varying vec3 refractedSunVec; -flat varying vec3 WsunVec; - -// uniform sampler2D colortex1; -// uniform sampler2D colortex3; -// // uniform sampler2D colortex0; -// uniform sampler2D colortex7; -// uniform sampler2D colortex13; -// uniform sampler2D colortex4; - -uniform vec3 sunVec; -uniform float far; -uniform float near; -uniform int frameCounter; -uniform float aspectRatio; -uniform float rainStrength; -uniform float sunElevation; -uniform ivec2 eyeBrightnessSmooth; -uniform ivec2 eyeBrightness; -uniform float frameTimeCounter; -uniform int isEyeInWater; -uniform vec2 texelSize; - - -// uniform int worldTime; - -#include "/lib/Shadow_Params.glsl" -#include "/lib/color_transforms.glsl" -#include "/lib/color_dither.glsl" -#include "/lib/projections.glsl" -#include "/lib/sky_gradient.glsl" -#include "/lib/res_params.glsl" - - -#define TIMEOFDAYFOG -#include "/lib/volumetricClouds.glsl" -#include "/lib/bokeh.glsl" - - -float blueNoise(){ - return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter); -} -float R2_dither(){ - vec2 alpha = vec2(0.75487765, 0.56984026); - return fract(alpha.x * gl_FragCoord.x + alpha.y * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter) ; -} -float R2_dither2(){ - vec2 alpha = vec2(0.75487765, 0.56984026); - return fract(alpha.x *(1- gl_FragCoord.x) + alpha.y * (1-gl_FragCoord.y) + 1.0/1.6180339887 * frameCounter) ; -} -float interleaved_gradientNoise(){ - vec2 alpha = vec2(0.75487765, 0.56984026); - vec2 coord = vec2(alpha.x * gl_FragCoord.x,alpha.y * gl_FragCoord.y)+ 1.0/1.6180339887 * frameCounter; - float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y)); - return noise; -} - - - -float waterCaustics(vec3 wPos, vec3 lightSource) { // water waves - - vec2 pos = wPos.xz + (lightSource.xz/lightSource.y*wPos.y); - if(isEyeInWater==1) pos = wPos.xz - (lightSource.xz/lightSource.y*wPos.y); // fix the fucky - vec2 movement = vec2(-0.035*frameTimeCounter); - float caustic = 0.0; - float weightSum = 0.0; - float radiance = 2.39996; - mat2 rotationMatrix = mat2(vec2(cos(radiance), -sin(radiance)), vec2(sin(radiance), cos(radiance))); - - const vec2 wave_size[4] = vec2[]( - vec2(64.), - vec2(32.,16.), - vec2(16.,32.), - vec2(48.) - ); - - for (int i = 0; i < 4; i++){ - pos = rotationMatrix * pos; - - vec2 speed = movement; - float waveStrength = 1.0; - - if( i == 0) { - speed *= 0.15; - waveStrength = 2.0; - } - - float small_wave = texture2D(noisetex, pos / wave_size[i] + speed ).b * waveStrength; - - caustic += max( 1.0-sin( 1.0-pow( 0.5+sin( small_wave*3.0 )*0.5, 25.0) ), 0); - - weightSum -= exp2(caustic*0.1); - } - return caustic / weightSum; -} - -// vec3 normVec (vec3 vec){ -// return vec*inversesqrt(dot(vec,vec)); -// } - -#include "/lib/volumetricFog.glsl" - -void waterVolumetrics(inout vec3 inColor, vec3 rayStart, vec3 rayEnd, float estEyeDepth, float estSunDepth, float rayLength, float dither, vec3 waterCoefs, vec3 scatterCoef, vec3 ambient, vec3 lightSource, float VdotL){ - int spCount = 8; - - vec3 start = toShadowSpaceProjected(rayStart); - vec3 end = toShadowSpaceProjected(rayEnd); - vec3 dV = (end-start); - - //limit ray length at 32 blocks for performance and reducing integration error - //you can't see above this anyway - float maxZ = min(rayLength,32.0)/(1e-8+rayLength); - dV *= maxZ; - vec3 dVWorld = mat3(gbufferModelViewInverse) * (rayEnd - rayStart) * maxZ; - rayLength *= maxZ; - float dY = normalize(mat3(gbufferModelViewInverse) * rayEnd).y * rayLength; - - vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition; - vec3 WsunVec = mat3(gbufferModelViewInverse) * sunVec * lightCol.a; - - float phase = (phaseg(VdotL,0.6) + phaseg(VdotL,0.8)) * 0.5; - - vec3 absorbance = vec3(1.0); - vec3 vL = vec3(0.0); - float expFactor = 11.0; - - for (int i=0;i 0.0){ - // rays = RainRays(vec3(0.0), fragpos, length(fragpos), R2_dither(), (avgAmbient*2.0) * 8./150./3., lightCol.rgb, dot(normalize(fragpos), normalize(sunVec) )); - // VL_CLOUDFOG += rays * rainStrength; - // } - - gl_FragData[0] = clamp(VL_CLOUDFOG, 0.0,65000.); - #else - - vec4 VL_Fog = getVolumetricRays(fragpos, blueNoise(), averageSkyCol); - gl_FragData[0] = clamp(VL_Fog,0.0,65000.); - - #endif - - #else - - vec4 VL_Fog = getVolumetricRays(fragpos, blueNoise(), averageSkyCol); - gl_FragData[0] = clamp(VL_Fog,0.0,65000.); - - #endif - } - - if (isEyeInWater == 1){ - - float dirtAmount = Dirt_Amount; - vec3 waterEpsilon = vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B); - vec3 dirtEpsilon = vec3(Dirt_Absorb_R, Dirt_Absorb_G, Dirt_Absorb_B); - vec3 totEpsilon = dirtEpsilon*dirtAmount + waterEpsilon; - vec3 scatterCoef = dirtAmount * vec3(Dirt_Scatter_R, Dirt_Scatter_G, Dirt_Scatter_B); - - #ifdef AEROCHROME_MODE - totEpsilon *= 2.0; - scatterCoef *= 10.0; - #endif - - vec3 fragpos = toScreenSpace(vec3(tc/RENDER_SCALE,z)); - float noise = blueNoise(); - - float estEyeDepth = 1.0-clamp(eyeBrightnessSmooth.y/240.0,0.,1.0); - estEyeDepth = pow(estEyeDepth,3.0) * 32.0; - - vec3 lightColVol = lightCol.rgb / 80.; - - vec3 lightningColor = (lightningEffect / 3) * (max(eyeBrightnessSmooth.y,0)/240.); - vec3 ambientColVol = (averageSkyCol_Clouds/30.0); - - // estEyeDepth = max(Water_Top_Layer - cameraPosition.y,0.0); - - vec3 vl = vec3(0.0); - waterVolumetrics(vl, vec3(0.0), fragpos, estEyeDepth, estEyeDepth, length(fragpos), noise, totEpsilon, scatterCoef, ambientColVol, lightColVol*(1.0-pow(1.0-sunElevation*lightCol.a,5.0)) , dot(normalize(fragpos), normalize(sunVec* lightCol.a ) )); - - gl_FragData[0] = clamp(vec4(vl,1.0),0.000001,65000.); - } -} diff --git a/shaders/composite2.vsh b/shaders/composite2.vsh deleted file mode 100644 index 6fde17c..0000000 --- a/shaders/composite2.vsh +++ /dev/null @@ -1,88 +0,0 @@ -#version 120 -//#extension GL_EXT_gpu_shader4 : disable - -#include "/lib/settings.glsl" - -flat varying vec3 averageSkyCol_Clouds; -flat varying vec3 averageSkyCol; - -flat varying vec4 lightCol; -flat varying vec3 sunColor; -flat varying vec3 moonColor; - -flat varying vec2 TAA_Offset; -flat varying float tempOffsets; - -flat varying vec3 WsunVec; -flat varying vec3 refractedSunVec; - -uniform sampler2D colortex4; -uniform vec3 sunPosition; -uniform float sunElevation; -uniform float rainStrength; -uniform int isEyeInWater; -uniform int frameCounter; -// uniform int worldTime; -uniform mat4 gbufferModelViewInverse; - - -#include "/lib/util.glsl" -#include "/lib/res_params.glsl" -// #include "/lib/biome_specifics.glsl" - - -// uniform float sandStorm; -float luma(vec3 color) { - return dot(color,vec3(0.21, 0.72, 0.07)); -} -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.); -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// - -void main() { - tempOffsets = HaltonSeq2(frameCounter%10000); - gl_Position = ftransform(); - gl_Position.xy = (gl_Position.xy*0.5+0.5)*(0.01+VL_RENDER_RESOLUTION)*2.0-1.0; - #ifdef TAA_UPSCALING - gl_Position.xy = (gl_Position.xy*0.5+0.5)*RENDER_SCALE*2.0-1.0; - #endif - vec3 sc = texelFetch2D(colortex4,ivec2(6,37),0).rgb; - - - averageSkyCol_Clouds = texelFetch2D(colortex4,ivec2(0,37),0).rgb; - averageSkyCol = texelFetch2D(colortex4,ivec2(1,37),0).rgb; - - sunColor = texelFetch2D(colortex4,ivec2(6,37),0).rgb; - moonColor = texelFetch2D(colortex4,ivec2(13,37),0).rgb; - - lightCol.a = float(sunElevation > 1e-5)*2-1.; - lightCol.rgb = sc; - - // lightCol.rgb = mix(lightCol.rgb, luma(lightCol.rgb) * vec3(1.0, 0.01, 0.1) , sandStorm); - - // #ifdef VOLUMETRIC_CLOUDS - // #ifndef VL_Clouds_Shadows - // lightCol.rgb *= (1.0-rainStrength*0.9); - // #endif - // #endif - - - - TAA_Offset = offsets[frameCounter%8]; - #ifndef TAA - TAA_Offset = vec2(0.0); - #endif - - WsunVec = lightCol.a*normalize(mat3(gbufferModelViewInverse) *sunPosition); - refractedSunVec = refract(WsunVec, -vec3(0.0,1.0,0.0), 1.0/1.33333); -} diff --git a/shaders/composite3.fsh b/shaders/composite3.fsh deleted file mode 100644 index 9ac05ec..0000000 --- a/shaders/composite3.fsh +++ /dev/null @@ -1,348 +0,0 @@ -#version 120 -//Horizontal bilateral blur for volumetric fog + Forward rendered objects + Draw volumetric fog -//#extension GL_EXT_gpu_shader4 : disable -#include "/lib/settings.glsl" - -flat varying vec3 zMults; -flat varying vec2 TAA_Offset; - - -uniform sampler2D noisetex; -uniform sampler2D depthtex0; -uniform sampler2D depthtex1; -uniform sampler2D colortex0; -uniform sampler2D colortex1; -uniform sampler2D colortex2; -uniform sampler2D colortex3; -// uniform sampler2D colortex4; -uniform sampler2D colortex5; -uniform sampler2D colortex6; -uniform sampler2D colortex7; -uniform sampler2D colortex8; -uniform sampler2D colortex9; -uniform sampler2D colortex11; -uniform sampler2D colortex13; -uniform sampler2D colortex15; -uniform vec2 texelSize; - -flat varying vec3 noooormal; -flat varying vec4 lightCol; //main light source color (rgb),used light source(1=sun,-1=moon) -flat varying vec3 WsunVec; - -uniform vec3 sunVec; -uniform float frameTimeCounter; -uniform int frameCounter; -uniform float far; -uniform float near; -uniform mat4 gbufferModelViewInverse; -uniform mat4 gbufferModelView; -uniform mat4 gbufferPreviousModelView; -uniform mat4 gbufferProjectionInverse; -uniform mat4 gbufferProjection; -uniform mat4 gbufferPreviousProjection; -uniform vec3 cameraPosition; -uniform vec3 previousCameraPosition; - -uniform int isEyeInWater; -uniform ivec2 eyeBrightnessSmooth; -uniform float rainStrength; -uniform float blindness; -uniform float darknessFactor; -uniform float darknessLightFactor; - - -#include "/lib/waterBump.glsl" -#include "/lib/res_params.glsl" - -#include "/lib/sky_gradient.glsl" -#include "/lib/volumetricClouds.glsl" -// #include "/lib/biome_specifics.glsl" - - - - -#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z) -#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz) - -float ld(float depth) { - return 1.0 / (zMults.y - depth * zMults.z); // (-depth * (far - near)) = (2.0 * near)/ld - far - near -} -float luma(vec3 color) { - return dot(color,vec3(0.21, 0.72, 0.07)); -} -vec3 toLinear(vec3 sRGB){ - return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878); -} -vec3 toScreenSpace(vec3 p) { - vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw); - vec3 p3 = p * 2. - 1.; - vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3]; - return fragposition.xyz / fragposition.w; -} - - -// #include "/lib/specular.glsl" - - - - -vec4 BilateralUpscale(sampler2D tex, sampler2D depth,vec2 coord,float frDepth, vec2 distort){ - coord = coord; - vec4 vl = vec4(0.0); - float sum = 0.0; - mat3x3 weights; - const ivec2 scaling = ivec2(1.0/VL_RENDER_RESOLUTION); - ivec2 posD = ivec2(coord*VL_RENDER_RESOLUTION + distort)*scaling; - ivec2 posVl = ivec2(coord*VL_RENDER_RESOLUTION + distort); - float dz = zMults.x; - ivec2 pos = (ivec2(gl_FragCoord.xy+frameCounter) % 2 )*2; - - ivec2 tcDepth = posD + ivec2(-2,-2) * scaling + pos * scaling; - float dsample = ld(texelFetch2D(depth,tcDepth,0).r); - float w = abs(dsample-frDepth) < dz ? 1.0 : 1e-5; - vl += texelFetch2D(tex,posVl+ivec2(-2)+pos,0)*w; - sum += w; - - tcDepth = posD + ivec2(-2,0) * scaling + pos * scaling; - dsample = ld(texelFetch2D(depth,tcDepth,0).r); - w = abs(dsample-frDepth) < dz ? 1.0 : 1e-5; - vl += texelFetch2D(tex,posVl+ivec2(-2,0)+pos,0)*w; - sum += w; - - tcDepth = posD + ivec2(0) + pos * scaling; - dsample = ld(texelFetch2D(depth,tcDepth,0).r); - w = abs(dsample-frDepth) < dz ? 1.0 : 1e-5; - vl += texelFetch2D(tex,posVl+ivec2(0)+pos,0)*w; - sum += w; - - tcDepth = posD + ivec2(0,-2) * scaling + pos * scaling; - dsample = ld(texelFetch2D(depth,tcDepth,0).r); - w = abs(dsample-frDepth) < dz ? 1.0 : 1e-5; - vl += texelFetch2D(tex,posVl+ivec2(0,-2)+pos,0)*w; - sum += w; - - return vl/sum; -} - -vec3 decode (vec2 encn){ - vec3 n = vec3(0.0); - encn = encn * 2.0 - 1.0; - n.xy = abs(encn); - n.z = 1.0 - n.x - n.y; - n.xy = n.z <= 0.0 ? (1.0 - n.yx) * sign(encn) : encn; - return clamp(normalize(n.xyz),-1.0,1.0); -} -vec2 decodeVec2(float a){ - const vec2 constant1 = 65535. / vec2( 256., 65536.); - const float constant2 = 256. / 255.; - return fract( a * constant1 ) * constant2 ; -} - -vec3 worldToView(vec3 worldPos) { - vec4 pos = vec4(worldPos, 0.0); - pos = gbufferModelView * pos; - return pos.xyz; -} -float blueNoise(){ - return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter); -} -vec4 blueNoise(vec2 coord){ - return texelFetch2D(colortex6, ivec2(coord )%512 , 0); -} -vec3 normVec (vec3 vec){ - return vec*inversesqrt(dot(vec,vec)); -} - -float interleaved_gradientNoise(){ - vec2 coord = gl_FragCoord.xy; - float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y)); - return noise; -} -vec3 viewToWorld(vec3 viewPosition) { - vec4 pos; - pos.xyz = viewPosition; - pos.w = 0.0; - pos = gbufferModelViewInverse * pos; - return pos.xyz; -} - -/// thanks stackoverflow https://stackoverflow.com/questions/944713/help-with-pixel-shader-effect-for-brightness-and-contrast#3027595 -void applyContrast(inout vec3 color, float contrast){ - color = ((color - 0.5) * max(contrast, 0.0)) + 0.5; -} -void main() { - /* DRAWBUFFERS:73 */ - - vec2 texcoord = gl_FragCoord.xy*texelSize; - - vec4 trpData = texture2D(colortex7,texcoord); - - bool iswater = trpData.a > 0.99; - float translucentAlpha = trpData.a; - - // vec4 speculartex = texture2D(colortex8,texcoord); // translucents - // float sunlight = speculartex.b; - - //3x3 bilateral upscale from half resolution - float z = texture2D(depthtex0,texcoord).x; - float z2 = texture2D(depthtex1,texcoord).x; - float frDepth = ld(z2); - - // vec4 vl = texture2D(colortex0,texcoord * 0.5); - - ////// --------------- UNPACK OPAQUE GBUFFERS --------------- ////// - vec4 data_opaque = texture2D(colortex1,texcoord); - vec4 dataUnpacked1 = vec4(decodeVec2(data_opaque.z),decodeVec2(data_opaque.w)); // normals, lightmaps - // vec4 dataUnpacked2 = vec4(decodeVec2(data.z),decodeVec2(data.w)); - - bool hand = abs(dataUnpacked1.w-0.75) < 0.01; - vec2 lightmap = dataUnpacked1.yz; - - ////// --------------- UNPACK TRANSLUCENT GBUFFERS --------------- ////// - - vec3 data = texture2D(colortex11,texcoord).rgb; - - vec4 unpack0 = vec4(decodeVec2(data.r),decodeVec2(data.g)) ; - vec4 unpack1 = vec4(decodeVec2(data.b),0,0) ; - - - - vec4 albedo = vec4(unpack0.ba,unpack1.rg); - - vec2 tangentNormals = unpack0.xy*2.0-1.0; - - if(albedo.a <= 0.0) tangentNormals = vec2(0.0); - - vec4 TranslucentShader = texture2D(colortex2,texcoord); - - float lightleakfix = clamp(pow(eyeBrightnessSmooth.y/240.,2) ,0.0,1.0); - - - vec2 tempOffset = TAA_Offset; - vec3 fragpos = toScreenSpace(vec3(texcoord/RENDER_SCALE-vec2(tempOffset)*texelSize*0.5,z)); - vec3 fragpos2 = toScreenSpace(vec3(texcoord/RENDER_SCALE-vec2(tempOffset)*texelSize*0.5,z2)); - - - vec3 p3 = mat3(gbufferModelViewInverse) * fragpos; - vec3 np3 = normVec(p3); - - - vec2 refractedCoord = texcoord; - - /// --- REFRACTION --- /// - #ifdef Refraction - refractedCoord += (tangentNormals * clamp((ld(z2) - ld(z)) * 0.5,0.0,0.15)) * RENDER_SCALE; - // refractedCoord += tangentNormals * 0.1 * RENDER_SCALE; - - float refractedalpha = decodeVec2(texture2D(colortex11,refractedCoord).b).g; - float refractedalpha2 = texture2D(colortex7,refractedCoord).a; - if( refractedalpha <= 0.001 ||z < 0.56) refractedCoord = texcoord; // remove refracted coords on solids - #endif - - /// --- MAIN COLOR BUFFER --- /// - // it is sampled with distorted texcoords - vec3 color = texture2D(colortex3,refractedCoord).rgb; - - #ifdef BorderFog - vec3 sky = skyFromTex(np3,colortex4) / 150. * 5.0; - float fog = 1.0 - clamp(exp(-pow(length(fragpos / far),10.)*4.0) ,0.0,1.0); - float heightFalloff = clamp( pow(abs(np3.y-1.01),5) ,0,1) ; - - if(z < 1.0 && isEyeInWater == 0) color.rgb = mix(color.rgb, sky, fog * heightFalloff* lightleakfix); - #endif - - vec4 vl = BilateralUpscale(colortex0, depthtex1, gl_FragCoord.xy, frDepth, vec2(0.0)); - float bloomyFogMult = 1.0; - - if (TranslucentShader.a > 0.0){ - #ifdef Glass_Tint - if(albedo.a > 0.2) color = color*albedo.rgb + color * clamp(pow(1.0-luma(albedo.rgb),20.),0.0,1.0); - #endif - - color = color*(1.0-TranslucentShader.a) + TranslucentShader.rgb; - - #ifdef BorderFog - if(z < 1.0 && isEyeInWater == 0) color.rgb = mix(color.rgb, sky, fog * heightFalloff * lightleakfix); - #endif - } - - - //cave fog - #ifdef Cave_fog - if (isEyeInWater == 0){ - - // float fogdistfade = clamp( pow(length(fragpos) / far, CaveFogFallOff) ,0.0,1.0); - // float fogfade = clamp( exp(clamp(np3.y * 0.5 + 0.5,0,1) * -3.0) ,0.0,1.0); - - float fogdistfade = clamp( pow(length(fragpos) / far, CaveFogFallOff) ,0.0,1.0); - - fogdistfade = fogdistfade*0.95 + clamp( pow(1.0 - exp((length(fragpos) / far) * -5), 2.0) ,0.0,1.0)*0.05; - float fogfade = clamp( exp(clamp(np3.y * 0.5 + 0.5,0,1) * -3.0) ,0.0,1.0); - - // vl.a *= 1-fogdistfade ; - // float fogdistfade = clamp( pow(1.0 - exp((length(fragpos) / far) * -5), 2.0) ,0.0,1.0); - // // float fogfade = clamp( exp(clamp(np3.y * 0.35 + 0.35,0,1) * -5.0) ,0.0,1.0) * 0.1; - - vec3 cavefogCol = vec3(CaveFogColor_R,CaveFogColor_G,CaveFogColor_B); - - #ifdef Biome_specific_environment - BiomeFogColor(cavefogCol); - #endif - - color.rgb = mix(color.rgb, cavefogCol*fogfade, fogdistfade * (1.0-lightleakfix) * (1.0-darknessFactor) * clamp( 1.5 - np3.y,0.,1)) ; - // color.rgb = vec3(CaveFogColor_R,CaveFogColor_G,CaveFogColor_B)*fogfade ; - } - #endif - - // underwater fog - if (isEyeInWater == 1){ - float dirtAmount = Dirt_Amount; - vec3 waterEpsilon = vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B); - vec3 dirtEpsilon = vec3(Dirt_Absorb_R, Dirt_Absorb_G, Dirt_Absorb_B); - vec3 totEpsilon = dirtEpsilon*dirtAmount + waterEpsilon; - - // float fogfade = clamp( exp(length(fragpos) / -20) ,0.0,1.0); - // vec3 fogfade = clamp( exp( (length(fragpos) / -4) * totEpsilon ) ,0.0,1.0); - vec3 fogfade = clamp( exp( (length(fragpos) / -4) * totEpsilon ) ,0.0,1.0); - fogfade *= 1.0 - clamp( length(fragpos) / far,0.0,1.0); - - color.rgb *= fogfade ; - bloomyFogMult *= 0.4; - } - - // apply VL fog to the scene - color *= vl.a; - color += vl.rgb; - -// bloomy rain effect - float rainDrops = clamp(texture2D(colortex9,texcoord).a, 0.0,1.0); - if(rainDrops > 0.0) bloomyFogMult *= clamp(1.0 - pow(rainDrops*5.0,2),0.0,1.0); - - /// lava. - if (isEyeInWater == 2){ - color.rgb = vec3(4.0,0.5,0.1); - } - - /// powdered snow - if (isEyeInWater == 3){ - color.rgb = mix(color.rgb,vec3(10,15,20),clamp(length(fragpos)*0.5,0.,1.)); - bloomyFogMult = 0.0; - } - - // blidnesss - color.rgb *= mix(1.0,clamp( exp(pow(length(fragpos)*(blindness*0.2),2) * -5),0.,1.) , blindness); - - // darkness effect - color.rgb *= mix(1.0, (1.0-darknessLightFactor*2.0) * clamp(1.0-pow(length(fragpos2)*(darknessFactor*0.07),2.0),0.0,1.0), darknessFactor); - - #ifdef display_LUT - vec2 movedTC = texcoord; - vec3 thingy = texture2D(colortex4,movedTC).rgb / 150. * 5.0; - if(luma(thingy) > 0.0 ) color.rgb = thingy; - #endif - - gl_FragData[0].r = vl.a * bloomyFogMult; // pass fog alpha so bloom can do bloomy fog - - gl_FragData[1].rgb = clamp(color.rgb,0.0,68000.0); - -} \ No newline at end of file diff --git a/shaders/composite3.vsh b/shaders/composite3.vsh deleted file mode 100644 index cc4dad6..0000000 --- a/shaders/composite3.vsh +++ /dev/null @@ -1,55 +0,0 @@ -#version 120 -//#extension GL_EXT_gpu_shader4 : disable - -#include "/lib/settings.glsl" -flat varying vec4 lightCol; -flat varying vec3 WsunVec; - -uniform mat4 gbufferModelViewInverse; -uniform int frameCounter; -uniform vec3 sunPosition; -uniform float sunElevation; - -flat varying vec2 TAA_Offset; -uniform sampler2D colortex4; -flat varying vec3 zMults; -uniform float far; -uniform float near; -#include "/lib/res_params.glsl" -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.); - - -flat varying vec3 noooormal; -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// - -void main() { - zMults = vec3(1.0/(far * near),far+near,far-near); - gl_Position = ftransform(); - #ifdef TAA_UPSCALING - gl_Position.xy = (gl_Position.xy*0.5+0.5)*RENDER_SCALE*2.0-1.0; - #endif - TAA_Offset = offsets[frameCounter%8]; - - #ifndef TAA - TAA_Offset = vec2(0.0); - #endif - - vec3 sc = texelFetch2D(colortex4,ivec2(6,37),0).rgb; - lightCol.a = float(sunElevation > 1e-5)*2-1.; - lightCol.rgb = sc; - - WsunVec = lightCol.a*normalize(mat3(gbufferModelViewInverse) *sunPosition); - - vec3 noooormal = normalize(gl_NormalMatrix * gl_Normal); -} diff --git a/shaders/composite4.fsh b/shaders/composite4.fsh deleted file mode 100644 index d33eec1..0000000 --- a/shaders/composite4.fsh +++ /dev/null @@ -1,46 +0,0 @@ -#version 120 -//#extension GL_EXT_gpu_shader4 : disable - -#include "/lib/settings.glsl" -uniform sampler2D colortex3; -// Compute 3x3 min max for TAA - -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// - -void main() { -/* DRAWBUFFERS:06 */ - ivec2 center = ivec2(gl_FragCoord.xy); - vec3 current = texelFetch2D(colortex3, center, 0).rgb; - vec3 cMin = current; - vec3 cMax = current; - current = texelFetch2D(colortex3, center + ivec2(-1, -1), 0).rgb; - cMin = min(cMin, current); - cMax = max(cMax, current); - current = texelFetch2D(colortex3, center + ivec2(-1, 0), 0).rgb; - cMin = min(cMin, current); - cMax = max(cMax, current); - current = texelFetch2D(colortex3, center + ivec2(-1, 1), 0).rgb; - cMin = min(cMin, current); - cMax = max(cMax, current); - current = texelFetch2D(colortex3, center + ivec2(0, -1), 0).rgb; - cMin = min(cMin, current); - cMax = max(cMax, current); - current = texelFetch2D(colortex3, center + ivec2(0, 1), 0).rgb; - cMin = min(cMin, current); - cMax = max(cMax, current); - current = texelFetch2D(colortex3, center + ivec2(1, -1), 0).rgb; - cMin = min(cMin, current); - cMax = max(cMax, current); - current = texelFetch2D(colortex3, center + ivec2(1, 0), 0).rgb; - cMin = min(cMin, current); - cMax = max(cMax, current); - current = texelFetch2D(colortex3, center + ivec2(1, 1), 0).rgb; - cMin = min(cMin, current); - cMax = max(cMax, current); - gl_FragData[0].rgb = cMax; - gl_FragData[1].rgb = cMin; -} diff --git a/shaders/composite4.vsh b/shaders/composite4.vsh deleted file mode 100644 index 19b0cb5..0000000 --- a/shaders/composite4.vsh +++ /dev/null @@ -1,18 +0,0 @@ -#version 120 -//#extension GL_EXT_gpu_shader4 : disable - -#include "/lib/settings.glsl" - -#include "/lib/res_params.glsl" -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// - -void main() { - gl_Position = ftransform(); - #ifdef TAA_UPSCALING - gl_Position.xy = (gl_Position.xy*0.5+0.5)*RENDER_SCALE*2.0-1.0; - #endif -} diff --git a/shaders/composite5.fsh b/shaders/composite5.fsh deleted file mode 100644 index 69b4035..0000000 --- a/shaders/composite5.fsh +++ /dev/null @@ -1,491 +0,0 @@ -#version 120 -//Temporal Anti-Aliasing + Dynamic exposure calculations (vertex shader) - -//#extension GL_EXT_gpu_shader4 : disable - -#include "/lib/settings.glsl" -#include "/lib/res_params.glsl" - - -//TAA OPTIONS - -const int noiseTextureResolution = 32; - - -/* -const int colortex0Format = RGBA16F; // low res clouds (deferred->composite2) + low res VL (composite5->composite15) -const int colortex1Format = RGBA16; //terrain gbuffer (gbuffer->composite2) -const int colortex2Format = RGBA16F; //forward + transparencies (gbuffer->composite4) -const int colortex3Format = R11F_G11F_B10F; //frame buffer + bloom (deferred6->final) -const int colortex4Format = RGBA16F; //light values and skyboxes (everything) - - - -const int colortex6Format = R11F_G11F_B10F; //additionnal buffer for bloom (composite3->final) -const int colortex7Format = RGBA8; //Final output, transparencies id (gbuffer->composite4) -const int colortex8Format = RGBA16F; //Final output, transparencies id (gbuffer->composite4) -const int colortex9Format = RGBA8; //Final output, transparencies id (gbuffer->composite4) -const int colortex10Format = RGBA16F; //FREE BUFFER - -const int colortex11Format = RGBA16; -const int colortex13Format = RGBA8; -const int colortex14Format = RGBA8; -const int colortex15Format = RGBA8; // flat normals and vanilla AO -*/ - -//no need to clear the buffers, saves a few fps - -/* -const bool colortex0Clear = false; -const bool colortex1Clear = false; -const bool colortex2Clear = true; -const bool colortex3Clear = false; -const bool colortex4Clear = false; -const bool colortex5Clear = false; -const bool colortex6Clear = false; -const bool colortex7Clear = false; -*/ - - - -#ifdef SCREENSHOT_MODE - /* - const int colortex5Format = RGBA32F; //TAA buffer (everything) - */ -#else - /* - const int colortex5Format = R11F_G11F_B10F; //TAA buffer (everything) - */ -#endif - -varying vec2 texcoord; -flat varying float exposureA; -flat varying float tempOffsets; - -uniform sampler2D colortex0; -uniform sampler2D colortex1; -uniform sampler2D colortex3; -uniform sampler2D colortex5; -uniform sampler2D colortex6; -// uniform sampler2D colortex10; -uniform sampler2D colortex13; - -uniform sampler2D depthtex0; -uniform sampler2D depthtex1; - -uniform vec2 texelSize; -uniform float frameTimeCounter; -uniform float viewHeight; -uniform float viewWidth; -uniform int frameCounter; -uniform int framemod8; -uniform vec3 previousCameraPosition; -uniform mat4 gbufferPreviousModelView; - -uniform int hideGUI; - -#define fsign(a) (clamp((a)*1e35,0.,1.)*2.-1.) - -#include "/lib/projections.glsl" - - -float luma(vec3 color) { - return dot(color,vec3(0.21, 0.72, 0.07)); -} -float interleaved_gradientNoise(){ - return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y)+tempOffsets); -} -float triangularize(float dither) -{ - float center = dither*2.0-1.0; - dither = center*inversesqrt(abs(center)); - return clamp(dither-fsign(center),0.0,1.0); -} -vec3 fp10Dither(vec3 color,float dither){ - const vec3 mantissaBits = vec3(6.,6.,5.); - vec3 exponent = floor(log2(color)); - return color + dither*exp2(-mantissaBits)*exp2(exponent); -} - - -//returns the projected coordinates of the closest point to the camera in the 3x3 neighborhood -vec3 closestToCamera5taps(vec2 texcoord, sampler2D depth) -{ - vec2 du = vec2(texelSize.x*2., 0.0); - vec2 dv = vec2(0.0, texelSize.y*2.); - - vec3 dtl = vec3(texcoord,0.) + vec3(-texelSize, texture2D(depth, texcoord - dv - du).x); - vec3 dtr = vec3(texcoord,0.) + vec3( texelSize.x, -texelSize.y, texture2D(depth, texcoord - dv + du).x); - vec3 dmc = vec3(texcoord,0.) + vec3( 0.0, 0.0, texture2D(depth, texcoord).x); - vec3 dbl = vec3(texcoord,0.) + vec3(-texelSize.x, texelSize.y, texture2D(depth, texcoord + dv - du).x); - vec3 dbr = vec3(texcoord,0.) + vec3( texelSize.x, texelSize.y, texture2D(depth, 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; - - #ifdef TAA_UPSCALING - dmin.xy = dmin.xy/RENDER_SCALE; - #endif - - return dmin; -} - -//Modified texture interpolation from inigo quilez -vec4 smoothfilter(in sampler2D tex, in vec2 uv) -{ - vec2 textureResolution = vec2(viewWidth,viewHeight); - uv = uv*textureResolution + 0.5; - vec2 iuv = floor( uv ); - vec2 fuv = fract( uv ); - uv = iuv + fuv*fuv*fuv*(fuv*(fuv*6.0-15.0)+10.0); - uv = (uv - 0.5)/textureResolution; - return texture2D( tex, uv); -} -//Due to low sample count we "tonemap" the inputs to preserve colors and smoother edges -vec3 weightedSample(sampler2D colorTex, vec2 texcoord){ - vec3 wsample = texture2D(colorTex,texcoord).rgb*exposureA; - return wsample/(1.0+luma(wsample)); - -} - - -//from : https://gist.github.com/TheRealMJP/c83b8c0f46b63f3a88a5986f4fa982b1 -vec4 SampleTextureCatmullRom(sampler2D tex, vec2 uv, vec2 texSize ) -{ - // We're going to sample a a 4x4 grid of texels surrounding the target UV coordinate. We'll do this by rounding - // down the sample location to get the exact center of our "starting" texel. The starting texel will be at - // location [1, 1] in the grid, where [0, 0] is the top left corner. - vec2 samplePos = uv * texSize; - vec2 texPos1 = floor(samplePos - 0.5) + 0.5; - - // Compute the fractional offset from our starting texel to our original sample location, which we'll - // feed into the Catmull-Rom spline function to get our filter weights. - vec2 f = samplePos - texPos1; - - // Compute the Catmull-Rom weights using the fractional offset that we calculated earlier. - // These equations are pre-expanded based on our knowledge of where the texels will be located, - // which lets us avoid having to evaluate a piece-wise function. - vec2 w0 = f * ( -0.5 + f * (1.0 - 0.5*f)); - vec2 w1 = 1.0 + f * f * (-2.5 + 1.5*f); - vec2 w2 = f * ( 0.5 + f * (2.0 - 1.5*f) ); - vec2 w3 = f * f * (-0.5 + 0.5 * f); - - // Work out weighting factors and sampling offsets that will let us use bilinear filtering to - // simultaneously evaluate the middle 2 samples from the 4x4 grid. - vec2 w12 = w1 + w2; - vec2 offset12 = w2 / (w1 + w2); - - // Compute the final UV coordinates we'll use for sampling the texture - vec2 texPos0 = texPos1 - vec2(1.0); - vec2 texPos3 = texPos1 + vec2(2.0); - vec2 texPos12 = texPos1 + offset12; - - texPos0 *= texelSize; - texPos3 *= texelSize; - texPos12 *= texelSize; - - vec4 result = vec4(0.0); - result += texture2D(tex, vec2(texPos0.x, texPos0.y)) * w0.x * w0.y; - result += texture2D(tex, vec2(texPos12.x, texPos0.y)) * w12.x * w0.y; - result += texture2D(tex, vec2(texPos3.x, texPos0.y)) * w3.x * w0.y; - - result += texture2D(tex, vec2(texPos0.x, texPos12.y)) * w0.x * w12.y; - result += texture2D(tex, vec2(texPos12.x, texPos12.y)) * w12.x * w12.y; - result += texture2D(tex, vec2(texPos3.x, texPos12.y)) * w3.x * w12.y; - - result += texture2D(tex, vec2(texPos0.x, texPos3.y)) * w0.x * w3.y; - result += texture2D(tex, vec2(texPos12.x, texPos3.y)) * w12.x * w3.y; - result += texture2D(tex, vec2(texPos3.x, texPos3.y)) * w3.x * w3.y; - - return result; -} -float R2_dither(){ - vec2 alpha = vec2(0.75487765, 0.56984026); - return fract(alpha.x * gl_FragCoord.x + alpha.y * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter); -} -//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 clip_aabb(vec3 q,vec3 aabb_min, vec3 aabb_max) - { - vec3 p_clip = 0.5 * (aabb_max + aabb_min); - vec3 e_clip = 0.5 * (aabb_max - aabb_min) + 0.00000001; - - vec3 v_clip = q - vec3(p_clip); - vec3 v_unit = v_clip.xyz / e_clip; - vec3 a_unit = abs(v_unit); - float ma_unit = max(a_unit.x, max(a_unit.y, a_unit.z)); - - if (ma_unit > 1.0) - return vec3(p_clip) + v_clip / ma_unit; - else - return q; - } -vec3 toClipSpace3Prev(vec3 viewSpacePosition) { - return projMAD(gbufferPreviousProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5; -} - -vec3 tonemap(vec3 col){ - return col/(1+luma(col)); -} -vec3 invTonemap(vec3 col){ - return col/(1-luma(col)); -} -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.); - - - -// float maxOf(vec2 v) { return max(v.x, v.y); } -// float maxOf(vec3 v) { return max(v.x, max(v.y, v.z)); } -// float maxOf(vec4 v) { return max(v.x, max(v.y, max(v.z, v.w))); } -// const float eps = 1e-6; - -// vec3 reproject(vec3 screenPos, sampler2D velocitySampler) { -// vec3 velocity = texelFetch(velocitySampler, ivec2(screenPos.xy), 0).xyz; - -// if (maxOf(abs(velocity)) < r) { -// return reproject(screenPos); -// } else { -// vec3 pos = screenToViewSpace(screenPos, false); -// pos = pos - velocity; -// pos = toScreenSpace(pos, false); - -// return pos; -// } -// } -vec3 worldToView(vec3 p3) { - vec4 pos = vec4(p3, 0.0); - pos = gbufferModelView * pos; - return pos.xyz; -} - -vec3 viewToWorld(vec3 viewPosition) { - vec4 pos; - pos.xyz = viewPosition; - pos.w = 0.0; - pos = gbufferModelViewInverse * pos; - return pos.xyz; -} -vec3 projectAndDivide(mat4 projectionMatrix, vec3 position){ - vec4 homogeneousPos = projectionMatrix * vec4(position, 1.0); - return homogeneousPos.xyz / homogeneousPos.w; -} -; -vec3 TAA_hq(bool hand, bool istranslucent, vec3 EntityVelocity, inout vec3 DEBUG){ - #ifdef TAA_UPSCALING - vec2 adjTC = clamp(texcoord*RENDER_SCALE, vec2(0.0),RENDER_SCALE-texelSize*2.); - #else - vec2 adjTC = texcoord; - #endif - - //use velocity from the nearest texel from camera in a 3x3 box in order to improve edge quality in motion - #ifdef CLOSEST_VELOCITY - vec3 closestToCamera = closestToCamera5taps(adjTC, depthtex0); - #endif - // if( EntityVelocity > vec3(0.0) ) closestToCamera = closestToCamera - EntityVelocity; - - #ifndef CLOSEST_VELOCITY - vec3 closestToCamera = vec3(texcoord,texture2D(depthtex1,adjTC).x); - #endif - - //reproject previous frame - vec3 fragposition = toScreenSpace(closestToCamera); - fragposition = mat3(gbufferModelViewInverse) * fragposition + gbufferModelViewInverse[3].xyz + (cameraPosition - previousCameraPosition); - - vec3 previousPosition = mat3(gbufferPreviousModelView) * fragposition + gbufferPreviousModelView[3].xyz; - previousPosition = toClipSpace3Prev(previousPosition) ; - - - - - vec2 velocity = previousPosition.xy - closestToCamera.xy; - previousPosition.xy = texcoord + velocity ; - // previousPosition -= abs(EntityVelocity); - - DEBUG = previousPosition; - - //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 smoothfilter(colortex3, adjTC + offsets[framemod8]*texelSize*0.5).xyz; - - #ifdef TAA_UPSCALING - vec3 albedoCurrent0 = smoothfilter(colortex3, adjTC + offsets[framemod8]*texelSize*0.5).xyz; - // Interpolating neighboorhood clampling boundaries between pixels - vec3 cMax = texture2D(colortex0, adjTC).rgb; - vec3 cMin = texture2D(colortex6, adjTC).rgb; - #else - vec3 albedoCurrent0 = texture2D(colortex3, adjTC).rgb; - vec3 albedoCurrent1 = texture2D(colortex3, adjTC + vec2(texelSize.x,texelSize.y)).rgb; - vec3 albedoCurrent2 = texture2D(colortex3, adjTC + vec2(texelSize.x,-texelSize.y)).rgb; - vec3 albedoCurrent3 = texture2D(colortex3, adjTC + vec2(-texelSize.x,-texelSize.y)).rgb; - vec3 albedoCurrent4 = texture2D(colortex3, adjTC + vec2(-texelSize.x,texelSize.y)).rgb; - vec3 albedoCurrent5 = texture2D(colortex3, adjTC + vec2(0.0,texelSize.y)).rgb; - vec3 albedoCurrent6 = texture2D(colortex3, adjTC + vec2(0.0,-texelSize.y)).rgb; - vec3 albedoCurrent7 = texture2D(colortex3, adjTC + vec2(-texelSize.x,0.0)).rgb; - vec3 albedoCurrent8 = texture2D(colortex3, adjTC + vec2(texelSize.x,0.0)).rgb; - //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)))))); - albedoCurrent0 = smoothfilter(colortex3, adjTC + offsets[framemod8]*texelSize*0.5).rgb; - #endif - - #ifndef NO_CLIP - vec3 albedoPrev = max(FastCatmulRom(colortex5, previousPosition.xy,vec4(texelSize, 1.0/texelSize), 0.75).xyz, 0.0); - vec3 finalcAcc = clamp(albedoPrev,cMin,cMax); - - //Increases blending factor when far from AABB and in motion, reduces ghosting - float isclamped = distance(albedoPrev,finalcAcc)/luma(albedoPrev) * 0.5; - float movementRejection = (0.12+isclamped)*clamp(length(velocity/texelSize),0.0,1.0); - - float test = 0.05; - if(hand) movementRejection *= 5; - if(istranslucent) test = 0.1; - - //Blend current pixel with clamped history, apply fast tonemap beforehand to reduce flickering - // vec3 supersampled = invTonemap(mix(tonemap(finalcAcc),tonemap(albedoCurrent0),clamp(BLEND_FACTOR + movementRejection, min(luma(motionVector) *255,1.0),1.))); - - vec3 supersampled = invTonemap(mix(tonemap(finalcAcc),tonemap(albedoCurrent0),clamp(BLEND_FACTOR + movementRejection, test,1.))); - #endif - - - #ifdef NO_CLIP - vec3 albedoPrev = texture2D(colortex5, previousPosition.xy).xyz; - vec3 supersampled = mix(albedoPrev,albedoCurrent0,clamp(0.05,0.,1.)); - #endif - - //De-tonemap - return supersampled; -} - - -vec3 decode (vec2 encn){ - vec3 n = vec3(0.0); - encn = encn * 2.0 - 1.0; - n.xy = abs(encn); - n.z = 1.0 - n.x - n.y; - n.xy = n.z <= 0.0 ? (1.0 - n.yx) * sign(encn) : encn; - return clamp(normalize(n.xyz),-1.0,1.0); -} -vec2 decodeVec2(float a){ - const vec2 constant1 = 65535. / vec2( 256., 65536.); - const float constant2 = 256. / 255.; - return fract( a * constant1 ) * constant2 ; -} -vec2 R2_samples(int n){ - vec2 alpha = vec2(0.75487765, 0.56984026); - return fract(alpha * n)*2.-1.0; -} - -vec4 TAA_hq_render(){ - #ifdef TAA_UPSCALING - vec2 adjTC = clamp(texcoord*RENDER_SCALE, vec2(0.0),RENDER_SCALE-texelSize*2.); - #else - vec2 adjTC = texcoord; - #endif - - //use velocity from the nearest texel from camera in a 3x3 box in order to improve edge quality in motion - #ifdef CLOSEST_VELOCITY - vec3 closestToCamera = closestToCamera5taps(adjTC,depthtex0); - #endif - - #ifndef CLOSEST_VELOCITY - vec3 closestToCamera = vec3(texcoord,texture2D(depthtex0,adjTC).x); - #endif - - //reproject previous frame - vec3 fragposition = toScreenSpace(closestToCamera); - fragposition = mat3(gbufferModelViewInverse) * fragposition + gbufferModelViewInverse[3].xyz + (cameraPosition - previousCameraPosition); - vec3 previousPosition = mat3(gbufferPreviousModelView) * fragposition + gbufferPreviousModelView[3].xyz; - previousPosition = toClipSpace3Prev(previousPosition); - vec2 velocity = previousPosition.xy - closestToCamera.xy; - previousPosition.xy = texcoord + velocity; - - // //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 vec4(smoothfilter(colortex3, adjTC + R2_samples(frameCounter)*texelSize*0.5).xyz, 1.0); - - vec3 albedoCurrent0 = smoothfilter(colortex3, adjTC + R2_samples(frameCounter)*texelSize*0.5).xyz; - - float rej = 0.0; - vec4 albedoPrev = texture2D(colortex5, previousPosition.xy); - vec3 supersampled = albedoPrev.rgb * albedoPrev.a + albedoCurrent0; - - if (length(velocity) > 1e-6) return vec4(albedoCurrent0,1.0); - return vec4(supersampled/(albedoPrev.a+1.0), albedoPrev.a+1.0); -} - -void main() { - -/* DRAWBUFFERS:5 */ - - gl_FragData[0].a = 1.0; - - #ifdef SCREENSHOT_MODE - - if(hideGUI > 0) { - vec4 color = TAA_hq_render(); - gl_FragData[0] = color; - } else { - vec3 color = clamp(fp10Dither(texture2D(colortex3,texcoord).rgb,triangularize(interleaved_gradientNoise())),0.,65000.); - gl_FragData[0].rgb = color; - } - - #else - - #ifdef TAA - vec4 data = texture2D(colortex1,texcoord* RENDER_SCALE); // terraom - vec4 dataUnpacked1 = vec4(decodeVec2(data.z),decodeVec2(data.w)); - bool hand = abs(dataUnpacked1.w-0.75) < 0.01; - bool translucentCol = texture2D(colortex13,texcoord * RENDER_SCALE).a > 0.0; // translucents - vec3 color = vec3(0.0); - - vec3 DEBUG = vec3(0.0); - color += TAA_hq(hand, translucentCol, vec3(0.0), DEBUG); - - - gl_FragData[0].rgb = clamp(fp10Dither(color ,triangularize(R2_dither())),6.11*1e-5,65000.0); - - #else - vec3 color = clamp(fp10Dither(texture2D(colortex3,texcoord).rgb,triangularize(interleaved_gradientNoise())),0.,65000.); - gl_FragData[0].rgb = color; - #endif - - #endif -} \ No newline at end of file diff --git a/shaders/composite5.vsh b/shaders/composite5.vsh deleted file mode 100644 index dc10bf5..0000000 --- a/shaders/composite5.vsh +++ /dev/null @@ -1,18 +0,0 @@ -#version 120 -//#extension GL_EXT_gpu_shader4 : disable - -#include "/lib/settings.glsl" - -varying vec2 texcoord; -flat varying float exposureA; -flat varying float tempOffsets; -uniform sampler2D colortex4; -uniform int frameCounter; -#include "/lib/util.glsl" -void main() { - - tempOffsets = HaltonSeq2(frameCounter%10000); - gl_Position = ftransform(); - texcoord = gl_MultiTexCoord0.xy; - exposureA = texelFetch2D(colortex4,ivec2(10,37),0).r; -} diff --git a/shaders/composite6.fsh b/shaders/composite6.fsh deleted file mode 100644 index c2c485c..0000000 --- a/shaders/composite6.fsh +++ /dev/null @@ -1,50 +0,0 @@ -#version 120 -//downsample 1st pass (half res) for bloom - -#include "/lib/settings.glsl" -uniform sampler2D colortex5; -// uniform sampler2D colortex8; -uniform vec2 texelSize; -uniform float viewWidth; -uniform float viewHeight; - -#include "/lib/res_params.glsl" - - -void main() { -/* DRAWBUFFERS:3 */ - - -vec2 resScale = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.))/vec2(1920.,1080.); -vec2 quarterResTC = gl_FragCoord.xy*texelSize*2.*resScale/BLOOM_QUALITY; - -// float emissives1 = texture2D(colortex8,quarterResTC).a; -// float emissives2 = emissives1 < 1.0 ? emissives1 : 0.0; - - // 0.5 - gl_FragData[0] = texture2D(colortex5,quarterResTC-1.0*vec2(texelSize.x,texelSize.y))/4.*0.5; - gl_FragData[0] += texture2D(colortex5,quarterResTC+1.0*vec2(texelSize.x,texelSize.y))/4.*0.5; - gl_FragData[0] += texture2D(colortex5,quarterResTC+vec2(-1.0*texelSize.x,1.0*texelSize.y))/4.*0.5; - gl_FragData[0] += texture2D(colortex5,quarterResTC+vec2(1.0*texelSize.x,-1.0*texelSize.y))/4.*0.5; - - //0.25 - gl_FragData[0] += texture2D(colortex5,quarterResTC-2.0*vec2(texelSize.x,0.0))/2.*0.125; - gl_FragData[0] += texture2D(colortex5,quarterResTC+2.0*vec2(0.0,texelSize.y))/2.*0.125; - gl_FragData[0] += texture2D(colortex5,quarterResTC+2.0*vec2(0,-texelSize.y))/2*0.125; - gl_FragData[0] += texture2D(colortex5,quarterResTC+2.0*vec2(-texelSize.x,0.0))/2*0.125; - - //0.125 - gl_FragData[0] += texture2D(colortex5,quarterResTC-2.0*vec2(texelSize.x,texelSize.y))/4.*0.125; - gl_FragData[0] += texture2D(colortex5,quarterResTC+2.0*vec2(texelSize.x,texelSize.y))/4.*0.125; - gl_FragData[0] += texture2D(colortex5,quarterResTC+vec2(-2.0*texelSize.x,2.0*texelSize.y))/4.*0.125; - gl_FragData[0] += texture2D(colortex5,quarterResTC+vec2(2.0*texelSize.x,-2.0*texelSize.y))/4.*0.125; - - //0.125 - gl_FragData[0] += texture2D(colortex5,quarterResTC)*0.125; - - - gl_FragData[0].rgb = clamp(gl_FragData[0].rgb,0.0,65000.); - if (quarterResTC.x > 1.0 - 3.5*texelSize.x || quarterResTC.y > 1.0 -3.5*texelSize.y || quarterResTC.x < 3.5*texelSize.x || quarterResTC.y < 3.5*texelSize.y) gl_FragData[0].rgb = vec3(0.0); - - -} diff --git a/shaders/composite6.vsh b/shaders/composite6.vsh deleted file mode 100644 index 86ba64b..0000000 --- a/shaders/composite6.vsh +++ /dev/null @@ -1,18 +0,0 @@ -#version 120 -#include "/lib/settings.glsl" -#include "/lib/res_params.glsl" -uniform float viewWidth; -uniform float viewHeight; -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// - -void main() { - //Improves performances and makes sure bloom radius stays the same at high resolution (>1080p) - vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.)); - gl_Position = ftransform(); - //*0.51 to avoid errors when sampling outside since clearing is disabled - gl_Position.xy = (gl_Position.xy*0.5+0.5)*0.51*BLOOM_QUALITY/clampedRes*vec2(1920.0,1080.)*2.0-1.0; -} diff --git a/shaders/composite7.fsh b/shaders/composite7.fsh deleted file mode 100644 index 83a15f7..0000000 --- a/shaders/composite7.fsh +++ /dev/null @@ -1,44 +0,0 @@ -#version 120 -#include "/lib/settings.glsl" -//downsample 1st pass (half res) for bloom -#include "/lib/res_params.glsl" -uniform sampler2D colortex3; -// uniform sampler2D colortex8; -uniform vec2 texelSize; -uniform float viewWidth; -uniform float viewHeight; -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// - -void main() { - -/* DRAWBUFFERS:6 */ -vec2 resScale = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.))/vec2(1920.,1080.); -vec2 quarterResTC = gl_FragCoord.xy*texelSize*2.; - - //0.5 - gl_FragData[0] = texture2D(colortex3,quarterResTC-1.0*vec2(texelSize.x,texelSize.y))/4.*0.5; - gl_FragData[0] += texture2D(colortex3,quarterResTC+1.0*vec2(texelSize.x,texelSize.y))/4.*0.5; - gl_FragData[0] += texture2D(colortex3,quarterResTC+vec2(-1.0*texelSize.x,1.0*texelSize.y))/4.*0.5; - gl_FragData[0] += texture2D(colortex3,quarterResTC+vec2(1.0*texelSize.x,-1.0*texelSize.y))/4.*0.5; - - //0.25 - gl_FragData[0] += texture2D(colortex3,quarterResTC-2.0*vec2(texelSize.x,0.0))/2.*0.125; - gl_FragData[0] += texture2D(colortex3,quarterResTC+2.0*vec2(0.0,texelSize.y))/2.*0.125; - gl_FragData[0] += texture2D(colortex3,quarterResTC+2.0*vec2(0,-texelSize.y))/2*0.125; - gl_FragData[0] += texture2D(colortex3,quarterResTC+2.0*vec2(-texelSize.x,0.0))/2*0.125; - - //0.125 - gl_FragData[0] += texture2D(colortex3,quarterResTC-2.0*vec2(texelSize.x,texelSize.y))/4.*0.125; - gl_FragData[0] += texture2D(colortex3,quarterResTC+2.0*vec2(texelSize.x,texelSize.y))/4.*0.125; - gl_FragData[0] += texture2D(colortex3,quarterResTC+vec2(-2.0*texelSize.x,2.0*texelSize.y))/4.*0.125; - gl_FragData[0] += texture2D(colortex3,quarterResTC+vec2(2.0*texelSize.x,-2.0*texelSize.y))/4.*0.125; - - //0.125 - gl_FragData[0] += texture2D(colortex3,quarterResTC)*0.125; - - gl_FragData[0].rgb = clamp(gl_FragData[0].rgb,0.0,65000.); -} diff --git a/shaders/composite8.fsh b/shaders/composite8.fsh deleted file mode 100644 index 54aea8f..0000000 --- a/shaders/composite8.fsh +++ /dev/null @@ -1,62 +0,0 @@ -#version 120 -#include "/lib/settings.glsl" -//6 Horizontal gaussian blurs and horizontal downsampling -#include "/lib/res_params.glsl" - -uniform sampler2D colortex6; -uniform vec2 texelSize; -varying vec2 texcoord; -uniform float viewWidth; -uniform float viewHeight; -vec2 resScale = vec2(1920.,1080.)/max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.))*BLOOM_QUALITY; -vec3 gauss1D(vec2 coord,vec2 dir,float alpha,int maxIT){ - vec4 tot = vec4(0.); - float maxTC = 0.25*resScale.x; - float minTC = 0.; - for (int i = -maxIT;i minTC && spCoord.x < maxTC); - } - return tot.rgb/max(1.0,tot.a); -} - -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// - -void main() { -/* DRAWBUFFERS:6 */ - -vec2 texcoord = (gl_FragCoord.xy*vec2(2.0,4.0))*texelSize; -vec2 gaussDir = vec2(1.0,0.0); -gl_FragData[0].rgb = vec3(0.0); -vec2 tc2 = texcoord*vec2(2.0,1.)/2.; -if (tc2.x < 1.0*resScale.x && tc2.y <1.0*resScale.y) -gl_FragData[0].xyz = gauss1D(tc2/2,gaussDir,0.16,0); - -vec2 tc4 = texcoord*vec2(4.0,1.)/2.-vec2(0.5*resScale.x+4.0*texelSize.x,0.)*2.0; -if (tc4.x > 0.0 && tc4.y > 0.0 && tc4.x < 1.0*resScale.x && tc4.y <1.0*resScale.y) -gl_FragData[0].xyz = gauss1D(tc4/2,gaussDir,0.16,3); - -vec2 tc8 = texcoord*vec2(8.0,1.)/2.-vec2(0.75*resScale.x+8.*texelSize.x,0.)*4.0; -if (tc8.x > 0.0 && tc8.y > 0.0 && tc8.x < 1.0*resScale.x && tc8.y <1.0*resScale.y) -gl_FragData[0].xyz = gauss1D(tc8/2,gaussDir,0.035,6); - -vec2 tc16 = texcoord*vec2(8.0,1./2.)-vec2(0.875*resScale.x+12.*texelSize.x,0.)*8.0; -if (tc16.x > 0.0 && tc16.y > 0.0 && tc16.x < 1.0*resScale.x && tc16.y <1.0*resScale.y) -gl_FragData[0].xyz = gauss1D(tc16/2,gaussDir,0.0085,12); - -vec2 tc32 = texcoord*vec2(16.0,1./2.)-vec2(0.9375*resScale.x+16.*texelSize.x,0.)*16.0; -if (tc32.x > 0.0 && tc32.y > 0.0 && tc32.x < 1.0*resScale.x && tc32.y <1.0*resScale.y) -gl_FragData[0].xyz = gauss1D(tc32/2,gaussDir,0.002,28); - -vec2 tc64 = texcoord*vec2(32.0,1./2.)-vec2(0.96875*resScale.x+20.*texelSize.x,0.)*32.0; -if (tc64.x > 0.0 && tc64.y > 0.0 && tc64.x < 1.0*resScale.x && tc64.y <1.0*resScale.y) -gl_FragData[0].xyz = gauss1D(tc64/2,gaussDir,0.0005,60); - -gl_FragData[0].rgb = clamp(gl_FragData[0].rgb,0.0,65000.); -} diff --git a/shaders/composite8.vsh b/shaders/composite8.vsh deleted file mode 100644 index fe2f03e..0000000 --- a/shaders/composite8.vsh +++ /dev/null @@ -1,21 +0,0 @@ -#version 120 -#include "/lib/settings.glsl" -#include "/lib/res_params.glsl" -uniform float viewWidth; -uniform float viewHeight; -varying vec2 texcoord; -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// - -void main() { - vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.0))/BLOOM_QUALITY; - gl_Position = ftransform(); - //0-0.25 - gl_Position.y = (gl_Position.y*0.5+0.5)*0.25/clampedRes.y*1080.0*2.0-1.0; - //0-0.5 - gl_Position.x = (gl_Position.x*0.5+0.5)*0.5/clampedRes.x*1920.0*2.0-1.0; - texcoord = gl_MultiTexCoord0.xy/clampedRes*vec2(1920.,1080.); -} diff --git a/shaders/composite9.fsh b/shaders/composite9.fsh deleted file mode 100644 index 7f635c3..0000000 --- a/shaders/composite9.fsh +++ /dev/null @@ -1,62 +0,0 @@ -#version 120 -#include "/lib/settings.glsl" -//6 Vertical gaussian blurs and vertical downsampling -#include "/lib/res_params.glsl" - - -uniform sampler2D colortex6; -uniform vec2 texelSize; -varying vec2 texcoord; -uniform float viewWidth; -uniform float viewHeight; -vec2 resScale = vec2(1920.,1080.)/max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.))*BLOOM_QUALITY; -vec3 gauss1D(vec2 coord,vec2 dir,float alpha,int maxIT){ - vec4 tot = vec4(0.); - float maxTC = 0.25*resScale.y; - float minTC = 0.; - for (int i = -maxIT;i minTC && spCoord.y < maxTC); - } - return tot.rgb/max(1.0,tot.a); -} - -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// - -void main() { -/* DRAWBUFFERS:6 */ -vec2 texcoord = (gl_FragCoord.xy*vec2(2.0,4.0))*texelSize; - -vec2 gaussDir = vec2(0.0,1.0); -gl_FragData[0].rgb = vec3(0.0); -vec2 tc2 = texcoord*vec2(2.0,1.); -if (tc2.x < 1.0*resScale.x && tc2.y <1.0*resScale.y) -gl_FragData[0].xyz = gauss1D(texcoord/vec2(2.0,4.0),gaussDir,0.16,0); - -vec2 tc4 = texcoord*vec2(4.0,2.)-vec2(0.5*resScale.x+4.0*texelSize.x,0.)*4.0; -if (tc4.x > 0.0 && tc4.y > 0.0 && tc4.x < 1.0*resScale.x && tc4.y <1.0*resScale.y) -gl_FragData[0].xyz = gauss1D(texcoord/vec2(2.0,2.0),gaussDir,0.16,3); - -vec2 tc8 = texcoord*vec2(8.0,4.)-vec2(0.75*resScale.x+8.*texelSize.x,0.)*8.0; -if (tc8.x > 0.0 && tc8.y > 0.0 && tc8.x < 1.0*resScale.x && tc8.y <1.0*resScale.y) -gl_FragData[0].xyz = gauss1D(texcoord*vec2(1.0,2.0)/vec2(2.0,2.0),gaussDir,0.035,6); - -vec2 tc16 = texcoord*vec2(16.0,8.)-vec2(0.875*resScale.x+12.*texelSize.x,0.)*16.0; -if (tc16.x > 0.0 && tc16.y > 0.0 && tc16.x < 1.0*resScale.x && tc16.y <1.0*resScale.y) -gl_FragData[0].xyz = gauss1D(texcoord*vec2(1.0,4.0)/vec2(2.0,2.0),gaussDir,0.0085,12); - -vec2 tc32 = texcoord*vec2(32.0,16.)-vec2(0.9375*resScale.x+16.*texelSize.x,0.)*32.0; -if (tc32.x > 0.0 && tc32.y > 0.0 && tc32.x < 1.0*resScale.x && tc32.y <1.0*resScale.y) -gl_FragData[0].xyz = gauss1D(texcoord*vec2(1.0,8.0)/vec2(2.0,2.0),gaussDir,0.002,30); - -vec2 tc64 = texcoord*vec2(64.0,32.)-vec2(0.96875*resScale.x+20.*texelSize.x,0.)*64.0; -if (tc64.x > 0.0 && tc64.y > 0.0 && tc64.x < 1.0*resScale.x && tc64.y <1.0*resScale.y) -gl_FragData[0].xyz = gauss1D(texcoord*vec2(1.0,16.0)/vec2(2.0,2.0),gaussDir,0.0005,60); - -gl_FragData[0].rgb = clamp(gl_FragData[0].rgb,0.0,65000.); -} diff --git a/shaders/composite9.vsh b/shaders/composite9.vsh deleted file mode 100644 index 3bbdf17..0000000 --- a/shaders/composite9.vsh +++ /dev/null @@ -1,23 +0,0 @@ -#version 120 - -#include "/lib/settings.glsl" -#include "/lib/res_params.glsl" -uniform float viewWidth; -uniform float viewHeight; -varying vec2 texcoord; -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// - -void main() { - vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.0))/BLOOM_QUALITY; - gl_Position = ftransform(); - //0-0.25 - gl_Position.y = (gl_Position.y*0.5+0.5)*0.25/clampedRes.y*1080.0*2.0-1.0; - //0-0.5 - gl_Position.x = (gl_Position.x*0.5+0.5)*0.5/clampedRes.x*1920.0*2.0-1.0; - texcoord = gl_MultiTexCoord0.xy/clampedRes*vec2(1920.,1080.); - -} diff --git a/shaders/deferred.fsh b/shaders/deferred.fsh deleted file mode 100644 index f146556..0000000 --- a/shaders/deferred.fsh +++ /dev/null @@ -1,189 +0,0 @@ -#version 120 -//#extension GL_EXT_gpu_shader4 : disable - -#include "/lib/settings.glsl" -//Prepares sky textures (2 * 256 * 256), computes light values and custom lightmaps -#define ReflectedFog - -flat varying vec3 averageSkyCol_Clouds; -flat varying vec3 averageSkyCol; - -flat varying vec3 lightSourceColor; -flat varying vec3 sunColor; -flat varying vec3 moonColor; -flat varying vec3 zenithColor; - -flat varying float avgL2; -flat varying vec2 tempOffsets; -flat varying float exposure; -flat varying float rodExposure; -flat varying float avgBrightness; -flat varying float centerDepth; - -// uniform sampler2D colortex4; -uniform sampler2D noisetex; -uniform sampler2DShadow shadow; - -uniform int frameCounter; -uniform float rainStrength; -uniform float eyeAltitude; -uniform vec3 sunVec; -flat varying vec3 WsunVec; -uniform vec2 texelSize; -uniform float frameTimeCounter; -uniform mat4 gbufferProjection; -uniform mat4 gbufferProjectionInverse; -uniform mat4 gbufferPreviousProjection; -uniform mat4 gbufferModelViewInverse; -uniform mat4 gbufferModelView; -uniform mat4 shadowModelView; -uniform mat4 shadowProjection; -uniform float sunElevation; -uniform vec3 cameraPosition; -uniform float far; -uniform ivec2 eyeBrightnessSmooth; - -uniform float lightningFlash; - -#include "/lib/Shadow_Params.glsl" -#include "/lib/util.glsl" -#include "/lib/ROBOBO_sky.glsl" -#include "/lib/sky_gradient.glsl" - -// uniform int worldTime; - -#define TIMEOFDAYFOG -#include "/lib/volumetricClouds.glsl" - -// #include "/lib/biome_specifics.glsl" - -vec3 toShadowSpaceProjected(vec3 p3){ - p3 = mat3(gbufferModelViewInverse) * p3 + gbufferModelViewInverse[3].xyz; - p3 = mat3(shadowModelView) * p3 + shadowModelView[3].xyz; - p3 = diagonal3(shadowProjection) * p3 + shadowProjection[3].xyz; - - return p3; -} -float R2_dither(){ - vec2 alpha = vec2(0.75487765, 0.56984026); - return fract(alpha.x * gl_FragCoord.x + alpha.y * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter); -} -float blueNoise(){ - return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter); -} -float interleaved_gradientNoise(){ - vec2 coord = gl_FragCoord.xy; - float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y + 1.0/1.6180339887 * frameCounter)); - return noise; -} -vec4 lightCol = vec4(lightSourceColor, float(sunElevation > 1e-5)*2-1.); - -float luma(vec3 color) { - return dot(color,vec3(0.299, 0.587, 0.114)); -} - -#include "/lib/volumetricFog.glsl" - -const float[17] Slightmap = float[17](14.0,17.,19.0,22.0,24.0,28.0,31.0,40.0,60.0,79.0,93.0,110.0,132.0,160.0,197.0,249.0,249.0); - -uniform sampler2D depthtex1;//depth -// #define ffstep(x,y) clamp((y - x) * 1e35,0.0,1.0) -// #define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z) -// #define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz) -vec3 toScreenSpace(vec3 p) { - vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw); - vec3 p3 = p * 2. - 1.; - vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3]; - return fragposition.xyz / fragposition.w; -} - -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.); - - -void main() { -/* DRAWBUFFERS:4 */ -gl_FragData[0] = vec4(0.0); - -//Save light values -if (gl_FragCoord.x < 1. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) -gl_FragData[0] = vec4(averageSkyCol_Clouds,1.0); -if (gl_FragCoord.x > 1. && gl_FragCoord.x < 2. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) -gl_FragData[0] = vec4(averageSkyCol,1.0); - -if (gl_FragCoord.x > 6. && gl_FragCoord.x < 7. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) -gl_FragData[0] = vec4(lightSourceColor,1.0); - -if (gl_FragCoord.x > 8. && gl_FragCoord.x < 9. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) -gl_FragData[0] = vec4(sunColor,1.0); -if (gl_FragCoord.x > 13. && gl_FragCoord.x < 14. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) -gl_FragData[0] = vec4(moonColor,1.0); - - - - -const float pi = 3.141592653589793238462643383279502884197169; - -//Sky gradient (no clouds) -if (gl_FragCoord.x > 18. && gl_FragCoord.y > 1. && gl_FragCoord.x < 18+257){ - vec2 p = clamp(floor(gl_FragCoord.xy-vec2(18.,1.))/256.+tempOffsets/256.,0.0,1.0); - vec3 viewVector = cartToSphere(p); - - vec2 planetSphere = vec2(0.0); - vec3 sky = vec3(0.0); - vec3 skyAbsorb = vec3(0.0); - - vec3 WsunVec = mat3(gbufferModelViewInverse)*sunVec; - - sky = calculateAtmosphere(averageSkyCol*4000./2.0, viewVector, vec3(0.0,1.0,0.0), WsunVec, -WsunVec, planetSphere, skyAbsorb, 10, blueNoise()); - - #ifdef AEROCHROME_MODE - sky *= vec3(0.0, 0.18, 0.35); - #endif - - gl_FragData[0] = vec4(sky/4000.*Sky_Brightness,1.0); -} - -//Sky gradient with clouds -if (gl_FragCoord.x > 18.+257. && gl_FragCoord.y > 1. && gl_FragCoord.x < 18+257+257.){ - vec2 p = clamp(floor(gl_FragCoord.xy-vec2(18.+257,1.))/256.+tempOffsets/256.,0.0,1.0); - vec3 viewVector = cartToSphere(p); - - vec3 WsunVec = mat3(gbufferModelViewInverse)*sunVec; - vec3 sky = texelFetch2D(colortex4,ivec2(gl_FragCoord.xy)-ivec2(257,0),0).rgb/150. ; - - if(viewVector.y < -0.025) sky = sky * clamp( exp(viewVector.y) - 1.0,0.25,1.0) ; - - vec4 clouds = renderClouds(mat3(gbufferModelView)*viewVector*1024.,vec2(fract(frameCounter/1.6180339887),1-fract(frameCounter/1.6180339887)), sunColor, moonColor, averageSkyCol*5.0); - sky = sky*clouds.a + clouds.rgb/5.0; - - vec4 VL_Fog = getVolumetricRays(mat3(gbufferModelView)*viewVector*1024., fract(frameCounter/1.6180339887), averageSkyCol); - - if(viewVector.y < -0.025) VL_Fog.rgb *= clamp( exp(viewVector.y) - 1.0,0.25,1.0) ; - - sky = sky*VL_Fog.a + VL_Fog.rgb*20; - - gl_FragData[0] = vec4(sky,1.0); -} - -//Temporally accumulate sky and light values -vec3 temp = texelFetch2D(colortex4,ivec2(gl_FragCoord.xy),0).rgb; -vec3 curr = gl_FragData[0].rgb*150.; - -float flashtiming = pow(clamp((0.01-lightningFlash)*100,0,1),25); - -gl_FragData[0].rgb = clamp(mix(temp,curr, 0.07 * flashtiming),0.0,65000.); - -//Exposure values -if (gl_FragCoord.x > 10. && gl_FragCoord.x < 11. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) -gl_FragData[0] = vec4(exposure,avgBrightness,avgL2,1.0); -if (gl_FragCoord.x > 14. && gl_FragCoord.x < 15. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) -gl_FragData[0] = vec4(rodExposure,centerDepth,0.0, 1.0); - -} diff --git a/shaders/deferred.vsh b/shaders/deferred.vsh deleted file mode 100644 index 3693103..0000000 --- a/shaders/deferred.vsh +++ /dev/null @@ -1,187 +0,0 @@ -#version 120 - -//#extension GL_EXT_gpu_shader4 : disable - -#include "/lib/settings.glsl" -#include "/lib/res_params.glsl" - -flat varying vec3 averageSkyCol_Clouds; -flat varying vec3 averageSkyCol; - -flat varying vec3 sunColor; -flat varying vec3 moonColor; -flat varying vec3 lightSourceColor; -flat varying vec3 zenithColor; - -flat varying vec2 tempOffsets; -flat varying float exposure; -flat varying float avgBrightness; -flat varying float rodExposure; -flat varying float avgL2; -flat varying float centerDepth; - -uniform sampler2D colortex4; -uniform sampler2D colortex6; -uniform sampler2D depthtex0; - -uniform mat4 gbufferModelViewInverse; -uniform vec3 sunPosition; -uniform vec2 texelSize; -uniform float sunElevation; -uniform float eyeAltitude; -uniform float near; -uniform float far; -uniform float frameTime; -uniform int frameCounter; -uniform float rainStrength; - -// uniform int worldTime; -vec3 sunVec = normalize(mat3(gbufferModelViewInverse) *sunPosition); - -#include "/lib/sky_gradient.glsl" -#include "/lib/util.glsl" -#include "/lib/ROBOBO_sky.glsl" - -float luma(vec3 color) { - return dot(color,vec3(0.21, 0.72, 0.07)); -} - -//Low discrepancy 2D sequence, integration error is as low as sobol but easier to compute : http://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/ -vec2 R2_samples(int n){ - vec2 alpha = vec2(0.75487765, 0.56984026); - return fract(alpha * n); -} -float tanh(float x){ - return (exp(x) - exp(-x))/(exp(x) + exp(-x)); -} -float ld(float depth) { - return (2.0 * near) / (far + near - depth * (far - near)); // (-depth * (far - near)) = (2.0 * near)/ld - far - near -} - -uniform float nightVision; - - -void main() { - - gl_Position = ftransform()*0.5+0.5; - gl_Position.xy = gl_Position.xy*vec2(18.+258*2,258.)*texelSize; - gl_Position.xy = gl_Position.xy*2.-1.0; - -/////////////////////////////////// -/// --- AMBIENT LIGHT STUFF --- /// -/////////////////////////////////// - - averageSkyCol_Clouds = vec3(0.0); - averageSkyCol = vec3(0.0); - - vec2 sample3x3[9] = vec2[]( - - vec2(-1.0, -0.3), - vec2( 0.0, 0.0), - vec2( 1.0, -0.3), - - vec2(-1.0, -0.5), - vec2( 0.0, -0.5), - vec2( 1.0, -0.5), - - vec2(-1.0, -1.0), - vec2( 0.0, -1.0), - vec2( 1.0, -1.0) - ); - - // sample in a 3x3 pattern to get a good area for average color - vec3 pos = normalize(vec3(0,1,0)); - int maxIT = 9; - for (int i = 0; i < maxIT; i++) { - pos = normalize(vec3(0,1,0)); - pos.xy += normalize(sample3x3[i]) * vec2(0.3183,0.90); - - averageSkyCol_Clouds += 2.0*skyCloudsFromTex(pos,colortex4).rgb/maxIT/150.; - - // pos = normalize(vec3(0,1,0)); - // pos.xy += normalize(sample3x3[i]) * vec2(0.3183,0.90); - averageSkyCol += 1.5*skyFromTex(pos,colortex4).rgb/maxIT/150.; // please dont do an infinite feedback loop.... - - } - - /// TOOO DAMN BLUE - // // only need to sample one spot for this - // averageSkyCol += 2.0*skyFromTex(normalize(vec3(0.0,1.0,0.0)),colortex4).rgb/150.; - vec3 minimimlight = vec3(0.2,0.4,1.0) * (MIN_LIGHT_AMOUNT*0.0005 + nightVision); - averageSkyCol_Clouds = max(averageSkyCol_Clouds, minimimlight); - averageSkyCol = max(averageSkyCol, minimimlight); - -//////////////////////////////////////// -/// --- SUNLIGHT/MOONLIGHT STUFF --- /// -//////////////////////////////////////// - - vec2 planetSphere = vec2(0.0); - vec3 sky = vec3(0.0); - vec3 skyAbsorb = vec3(0.0); - - float sunVis = clamp(sunElevation,0.0,0.05)/0.05*clamp(sunElevation,0.0,0.05)/0.05; - float moonVis = clamp(-sunElevation,0.0,0.05)/0.05*clamp(-sunElevation,0.0,0.05)/0.05; - - zenithColor = calculateAtmosphere(vec3(0.0), vec3(0.0,1.0,0.0), vec3(0.0,1.0,0.0), sunVec, -sunVec, planetSphere, skyAbsorb, 25,tempOffsets.x); - skyAbsorb = vec3(0.0); - vec3 absorb = vec3(0.0); - sunColor = calculateAtmosphere(vec3(0.0), sunVec, vec3(0.0,1.0,0.0), sunVec, -sunVec, planetSphere, skyAbsorb, 25,0.0); - sunColor = sunColorBase/4000. * skyAbsorb; - - skyAbsorb = vec3(1.0); - moonColor = calculateAtmosphere(vec3(0.0), -sunVec, vec3(0.0,1.0,0.0), sunVec, -sunVec, planetSphere, skyAbsorb, 25,0.5); - moonColor = moonColorBase/4000.0; - - lightSourceColor = sunVis >= 1e-5 ? sunColor * sunVis : moonColor * moonVis; - - float lightDir = float( sunVis >= 1e-5)*2.0-1.0; - - - -////////////////////////////// -/// --- EXPOSURE STUFF --- /// -////////////////////////////// - - float avgLuma = 0.0; - float m2 = 0.0; - int n=100; - vec2 clampedRes = max(1.0/texelSize,vec2(1920.0,1080.)); - float avgExp = 0.0; - float avgB = 0.0; - vec2 resScale = vec2(1920.,1080.)/clampedRes*BLOOM_QUALITY; - const int maxITexp = 50; - float w = 0.0; - for (int i = 0; i < maxITexp; i++){ - vec2 ij = R2_samples((frameCounter%2000)*maxITexp+i); - vec2 tc = 0.5 + (ij-0.5) * 0.7; - vec3 sp = texture2D(colortex6,tc/16. * resScale+vec2(0.375*resScale.x+4.5*texelSize.x,.0)).rgb; - avgExp += log(luma(sp)); - avgB += log(min(dot(sp,vec3(0.07,0.22,0.71)),8e-2)); - } - - avgExp = exp(avgExp/maxITexp); - avgB = exp(avgB/maxITexp); - - avgBrightness = clamp(mix(avgExp,texelFetch2D(colortex4,ivec2(10,37),0).g,0.95),0.00003051757,65000.0); - - float L = max(avgBrightness,1e-8); - float keyVal = 1.03-2.0/(log(L*4000/150.*8./3.0+1.0)/log(10.0)+2.0); - float expFunc = 0.5+0.5*tanh(log(L)); - float targetExposure = 0.18/log2(L*2.5+1.045)*0.62; - - avgL2 = clamp(mix(avgB,texelFetch2D(colortex4,ivec2(10,37),0).b,0.985),0.00003051757,65000.0); - float targetrodExposure = max(0.012/log2(avgL2+1.002)-0.1,0.0)*1.2; - - - exposure=max(targetExposure*EXPOSURE_MULTIPLIER, 0); - float currCenterDepth = ld(texture2D(depthtex0, vec2(0.5)*RENDER_SCALE).r); - centerDepth = mix(sqrt(texelFetch2D(colortex4,ivec2(14,37),0).g/65000.0), currCenterDepth, clamp(DoF_Adaptation_Speed*exp(-0.016/frameTime+1.0)/(6.0+currCenterDepth*far),0.0,1.0)); - centerDepth = centerDepth * centerDepth * 65000.0; - - rodExposure = targetrodExposure; - - #ifndef AUTO_EXPOSURE - exposure = Manual_exposure_value; - rodExposure = clamp(log(Manual_exposure_value*2.0+1.0)-0.1,0.0,2.0); - #endif -} \ No newline at end of file diff --git a/shaders/deferred2.fsh b/shaders/deferred2.fsh deleted file mode 100644 index fb23457..0000000 --- a/shaders/deferred2.fsh +++ /dev/null @@ -1,29 +0,0 @@ -#version 120 -//#extension GL_EXT_gpu_shader4 : disable -#include "/lib/settings.glsl" - -uniform sampler2D colortex4; -uniform sampler2D depthtex1; - -uniform float near; -uniform float far; - - -float linZ(float depth) { - return (2.0 * near) / (far + near - depth * (far - near)); -} -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// - -void main() { -/* DRAWBUFFERS:4 */ - vec3 oldTex = texelFetch2D(colortex4, ivec2(gl_FragCoord.xy), 0).xyz; - float newTex = texelFetch2D(depthtex1, ivec2(gl_FragCoord.xy*4), 0).x; - if (newTex < 1.0) - gl_FragData[0] = vec4(oldTex, linZ(newTex)*linZ(newTex)*65000.0); - else - gl_FragData[0] = vec4(oldTex, 2.0); -} diff --git a/shaders/deferred2.vsh b/shaders/deferred2.vsh deleted file mode 100644 index 1d24af4..0000000 --- a/shaders/deferred2.vsh +++ /dev/null @@ -1,11 +0,0 @@ -#version 120 -//#extension GL_EXT_gpu_shader4 : disable -#include "/lib/settings.glsl" - -uniform vec2 texelSize; -#include "/lib/res_params.glsl" -void main() { - gl_Position = ftransform(); - vec2 scaleRatio = max(vec2(0.25), vec2(18.+258*2,258.)*texelSize); - gl_Position.xy = (gl_Position.xy*0.5+0.5)*clamp(scaleRatio+0.01,0.0,1.0)*2.0-1.0; -} diff --git a/shaders/dimensions/all_particles.fsh b/shaders/dimensions/all_particles.fsh index af7eed5..402113f 100644 --- a/shaders/dimensions/all_particles.fsh +++ b/shaders/dimensions/all_particles.fsh @@ -1,11 +1,22 @@ -// #version 120 +#include "/lib/settings.glsl" +#include "/lib/res_params.glsl" +#include "/lib/Shadow_Params.glsl" + varying vec4 lmtexcoord; varying vec4 color; +#ifdef OVERWORLD_SHADER + const bool shadowHardwareFiltering = true; + uniform sampler2DShadow shadow; + + flat varying vec3 WsunVec; + + flat varying vec3 averageSkyCol_Clouds; + flat varying vec4 lightCol; +#endif + uniform sampler2D texture; - uniform sampler2D noisetex; - uniform sampler2D colortex4; @@ -23,7 +34,15 @@ uniform vec2 texelSize; uniform ivec2 eyeBrightnessSmooth; uniform float rainStrength; -#include "/lib/settings.glsl" +#ifndef OVERWORLD_SHADER + uniform float nightVision; +#endif + +#ifdef OVERWORLD_SHADER + #define CLOUDSHADOWSONLY + #include "/lib/volumetricClouds.glsl" +#endif + #include "/lib/diffuse_lighting.glsl" #include "/lib/sky_gradient.glsl" @@ -51,8 +70,10 @@ const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.), vec2(3,7.)/8., vec2(7.,-7.)/8.); -vec3 normVec (vec3 vec){ - return vec*inversesqrt(dot(vec,vec)); +//Mie phase function +float phaseg(float x, float g){ + float gg = g * g; + return (gg * -0.25 + 0.25) * pow(-2.0 * (g * x) + (gg + 1.0), -1.5) / 3.14; } //////////////////////////////VOID MAIN////////////////////////////// @@ -60,26 +81,83 @@ vec3 normVec (vec3 vec){ //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// -/* DRAWBUFFERS:2 */ + +/* DRAWBUFFERS:29 */ + void main() { - - gl_FragData[0] = texture2D(texture, lmtexcoord.xy)*color; - - vec3 Albedo = toLinear(gl_FragData[0].rgb); - vec2 tempOffset = offsets[framemod8]; - vec3 fragpos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0)); - vec3 p3 = mat3(gbufferModelViewInverse) * fragpos; - vec3 np3 = normVec(p3); + vec3 viewPos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0)); + vec3 feetPlayerPos = mat3(gbufferModelViewInverse) * viewPos; + vec3 feetPlayerPos_normalized = normalize(feetPlayerPos); - vec3 Indirect_lighting = vec3(1.0); - float lightmap = lmtexcoord.z; - vec3 nothing = vec3(0.0); + vec4 TEXTURE = texture2D(texture, lmtexcoord.xy)*color; + vec3 Albedo = toLinear(TEXTURE.rgb); + + vec2 lightmap = lmtexcoord.zw; + + #ifndef OVERWORLD_SHADER + lightmap.y = 1.0; + #endif + + #ifdef WEATHER + // lightmap.x = clamp(max(lightmap.x - 0.5, 0.0) * 2.5, 0.0, 1.0); + gl_FragData[1].a = TEXTURE.a; // for bloomy rain and stuff + #endif + + +#ifndef WEATHER + #ifndef LINES + gl_FragData[0].a = TEXTURE.a; + #else + gl_FragData[0].a = 1.0; + #endif + + gl_FragData[1].a = 0.0; // for bloomy rain and stuff + + vec3 Direct_lighting = vec3(0.0); + vec3 Indirect_lighting = vec3(0.0); + vec3 Torch_Color = vec3(TORCH_R,TORCH_G,TORCH_B); + + #ifdef LIT + Torch_Color *= LIT_PARTICLE_BRIGHTNESS; + #endif + + #ifdef OVERWORLD_SHADER + float Shadows = 1.0; + + vec3 feetPlayerPos_shadow = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz; + vec3 projectedShadowPosition = mat3(shadowModelView) * feetPlayerPos_shadow + shadowModelView[3].xyz; + projectedShadowPosition = diagonal3(shadowProjection) * projectedShadowPosition + shadowProjection[3].xyz; + + //apply distortion + float distortFactor = calcDistort(projectedShadowPosition.xy); + projectedShadowPosition.xy *= distortFactor; + + //do shadows only if on shadow map + if (abs(projectedShadowPosition.x) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.y) < 1.0-1.5/shadowMapResolution){ + + projectedShadowPosition = projectedShadowPosition * vec3(0.5,0.5,0.5/6.0) + vec3(0.5); + + Shadows = shadow2D(shadow, projectedShadowPosition).x; + } + + float cloudShadow = GetCloudShadow(feetPlayerPos); + + Direct_lighting = (lightCol.rgb/80.0) * Shadows * cloudShadow; + + #ifndef LINES + Direct_lighting *= phaseg(clamp(dot(feetPlayerPos_normalized, WsunVec),0.0,1.0), 0.65)*2 + 0.5; + #endif + + Indirect_lighting = DoAmbientLighting(averageSkyCol_Clouds, Torch_Color, clamp(lightmap.xy,0,1), 3.0); + #endif + #ifdef END_SHADER - float TorchLM = 10.0 - ( 1.0 / (pow(exp(-0.5*inversesqrt(lightmap)),5.0)+0.1)); - TorchLM = pow(TorchLM/4,10) + pow(lightmap,1.5)*0.5; - vec3 TorchLight = (vec3(TORCH_R,TORCH_G,TORCH_B) * TorchLM * 0.75) * TORCH_AMOUNT; + float TorchLM = 10.0 - ( 1.0 / (pow(exp(-0.5*inversesqrt(lightmap.x)),5.0)+0.1)); + TorchLM = pow(TorchLM/4,10) + pow(lightmap.x,1.5)*0.5; + + vec3 TorchLight = (Torch_Color * TorchLM * 0.75) * TORCH_AMOUNT; Indirect_lighting = max(vec3(0.5,0.75,1.0) * 0.1, (MIN_LIGHT_AMOUNT*0.01 + nightVision*0.5) ) + TorchLight; #endif @@ -87,8 +165,17 @@ void main() { #ifdef NETHER_SHADER vec3 AmbientLightColor = skyCloudsFromTexLOD2(vec3( 0, 1, 0), colortex4, 6).rgb / 10; - Indirect_lighting = DoAmbientLighting_Nether(AmbientLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap, nothing, nothing, nothing); + vec3 nothing = vec3(0.0); + Indirect_lighting = DoAmbientLighting_Nether(AmbientLightColor, Torch_Color, lightmap.x, nothing, nothing, nothing); #endif - - gl_FragData[0].rgb = Indirect_lighting * Albedo; + + #ifndef LINES + gl_FragData[0].rgb = (Indirect_lighting + Direct_lighting) * Albedo; + #else + gl_FragData[0].rgb = (Indirect_lighting + Direct_lighting) * toLinear(color.rgb); + #endif + + // distance fade targeting the world border... + if(TEXTURE.a < 0.7 && TEXTURE.a > 0.2) gl_FragData[0] *= clamp(1.0 - length(feetPlayerPos) / 100.0 ,0.0,1.0); +#endif } \ No newline at end of file diff --git a/shaders/dimensions/all_particles.vsh b/shaders/dimensions/all_particles.vsh index a913831..3942677 100644 --- a/shaders/dimensions/all_particles.vsh +++ b/shaders/dimensions/all_particles.vsh @@ -1,7 +1,5 @@ -// #version 120 -//#extension GL_EXT_gpu_shader4 : disable - #include "/lib/settings.glsl" +#include "/lib/res_params.glsl" /* !! DO NOT REMOVE !! @@ -12,9 +10,21 @@ Read the terms of modification and sharing before changing something below pleas varying vec4 lmtexcoord; varying vec4 color; + +#ifdef OVERWORLD_SHADER + flat varying vec3 averageSkyCol_Clouds; + flat varying vec4 lightCol; + flat varying vec3 WsunVec; + uniform sampler2D colortex4; +#endif + +uniform vec3 sunPosition; +uniform float sunElevation; + uniform vec2 texelSize; uniform int framemod8; +uniform mat4 gbufferModelViewInverse; const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.), vec2(-1.,3.)/8., vec2(5.0,1.)/8., @@ -34,11 +44,24 @@ void main() { gl_Position = ftransform(); lmtexcoord.xy = (gl_MultiTexCoord0).xy; - vec2 lmcoord = gl_MultiTexCoord1.xy/255.; + vec2 lmcoord = gl_MultiTexCoord1.xy / 255.0; // is this even correct? lol' lmtexcoord.zw = lmcoord; color = gl_Color; - + #ifdef LINES + color.a = 1.0; + #endif + #ifdef OVERWORLD_SHADER + lightCol.rgb = texelFetch2D(colortex4,ivec2(6,37),0).rgb; + lightCol.a = float(sunElevation > 1e-5)*2.0 - 1.0; + + averageSkyCol_Clouds = texelFetch2D(colortex4,ivec2(0,37),0).rgb; + + WsunVec = lightCol.a * normalize(mat3(gbufferModelViewInverse) * sunPosition); + #endif + #ifdef TAA_UPSCALING + gl_Position.xy = gl_Position.xy * RENDER_SCALE + RENDER_SCALE * gl_Position.w - gl_Position.w; + #endif #ifdef TAA gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize; #endif diff --git a/shaders/dimensions/all_solid.fsh b/shaders/dimensions/all_solid.fsh index f338065..7d36607 100644 --- a/shaders/dimensions/all_solid.fsh +++ b/shaders/dimensions/all_solid.fsh @@ -1,11 +1,14 @@ -//#extension GL_EXT_gpu_shader4 : disable -//#extension GL_ARB_shader_texture_lod : disable +#extension GL_EXT_gpu_shader4 : enable +#extension GL_ARB_shader_texture_lod : enable #include "/lib/settings.glsl" - flat varying int NameTags; +#ifdef HAND +#undef POM +#endif + #ifndef USE_LUMINANCE_AS_HEIGHTMAP #ifndef MC_NORMAL_MAP #undef POM @@ -38,23 +41,28 @@ vec2 dcdy = dFdy(vtexcoord.st*vtexcoordam.pq)*exp2(Texture_MipMap_Bias); // #endif #include "/lib/res_params.glsl" - varying vec4 lmtexcoord; + varying vec4 color; -varying vec4 NoSeasonCol; -varying vec4 seasonColor; + uniform float far; + + +uniform float wetness; varying vec4 normalMat; + #ifdef MC_NORMAL_MAP - varying vec4 tangent; uniform sampler2D normals; + varying vec4 tangent; varying vec3 FlatNormals; #endif + uniform sampler2D specular; -flat varying int lightningBolt; + + uniform sampler2D texture; uniform sampler2D colortex1;//albedo(rgb),material(alpha) RGBA16 uniform float frameTimeCounter; @@ -67,21 +75,46 @@ uniform vec3 cameraPosition; uniform float rainStrength; uniform sampler2D noisetex;//depth uniform sampler2D depthtex0; + uniform vec4 entityColor; +// in vec3 velocity; + +flat varying int PHYSICSMOD_SNOW; flat varying float blockID; flat varying float SSSAMOUNT; flat varying float EMISSIVE; flat varying int LIGHTNING; +flat varying int PORTAL; flat varying int SIGN; -flat varying float HELD_ITEM_BRIGHTNESS; +flat varying float HELD_ITEM_BRIGHTNESS; +uniform float noPuddleAreas; + + +// float interleaved_gradientNoise(){ +// return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y)+frameTimeCounter*51.9521); +// } +float interleaved_gradientNoise_temp(){ + vec2 alpha = vec2(0.75487765, 0.56984026); + vec2 coord = vec2(alpha.x * gl_FragCoord.x,alpha.y * gl_FragCoord.y)+ 1.0/1.6180339887 * frameCounter; + float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y)); + return noise; +} +float interleaved_gradientNoise(){ + vec2 coord = gl_FragCoord.xy; + float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y)); + return noise; +} float blueNoise(){ return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter); } - +float R2_dither(){ + vec2 alpha = vec2(0.75487765, 0.56984026); + return fract(alpha.x * gl_FragCoord.x + alpha.y * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter) ; +} mat3 inverse(mat3 m) { float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2]; @@ -99,15 +132,6 @@ mat3 inverse(mat3 m) { b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det; } - -#ifdef MC_NORMAL_MAP - vec3 applyBump(mat3 tbnMatrix, vec3 bump, float puddle_values){ - float bumpmult = clamp(puddle_values,0.0,1.0); - bump = bump * vec3(bumpmult, bumpmult, bumpmult) + vec3(0.0f, 0.0f, 1.0f - bumpmult); - return normalize(bump*tbnMatrix); - } -#endif - vec3 viewToWorld(vec3 viewPosition) { vec4 pos; pos.xyz = viewPosition; @@ -115,13 +139,11 @@ vec3 viewToWorld(vec3 viewPosition) { pos = gbufferModelViewInverse * pos; return pos.xyz; } - vec3 worldToView(vec3 worldPos) { vec4 pos = vec4(worldPos, 0.0); pos = gbufferModelView * pos; return pos.xyz; } - vec4 encode (vec3 n, vec2 lightmaps){ n.xy = n.xy / dot(abs(n), vec3(1.0)); n.xy = n.z <= 0.0 ? (1.0 - abs(n.yx)) * sign(n.xy) : n.xy; @@ -140,6 +162,15 @@ float encodeVec2(float x,float y){ return encodeVec2(vec2(x,y)); } +#ifdef MC_NORMAL_MAP + vec3 applyBump(mat3 tbnMatrix, vec3 bump, float puddle_values){ + float bumpmult = clamp(puddle_values,0.0,1.0); + bump = bump * vec3(bumpmult, bumpmult, bumpmult) + vec3(0.0f, 0.0f, 1.0f - bumpmult); + return normalize(bump*tbnMatrix); + } +#endif + + #define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z) #define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz) @@ -164,10 +195,17 @@ vec3 toClipSpace3(vec3 viewSpacePosition) { } #endif + float luma(vec3 color) { return dot(color,vec3(0.21, 0.72, 0.07)); } + +vec3 toLinear(vec3 sRGB){ + return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878); +} + + const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.), vec2(-1.,3.)/8., vec2(5.0,1.)/8., @@ -176,11 +214,75 @@ const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.), vec2(-7.,-1.)/8., vec2(3,7.)/8., vec2(7.,-7.)/8.); +vec3 srgbToLinear2(vec3 srgb){ + return mix( + srgb / 12.92, + pow(.947867 * srgb + .0521327, vec3(2.4) ), + step( .04045, srgb ) + ); +} +vec3 blackbody2(float Temp) +{ + float t = pow(Temp, -1.5); + float lt = log(Temp); -float bias(){ - return Texture_MipMap_Bias + (blueNoise()-0.5)*0.5; + vec3 col = vec3(0.0); + col.x = 220000.0 * t + 0.58039215686; + col.y = 0.39231372549 * lt - 2.44549019608; + col.y = Temp > 6500. ? 138039.215686 * t + 0.72156862745 : col.y; + col.z = 0.76078431372 * lt - 5.68078431373; + col = clamp(col,0.0,1.0); + col = Temp < 1000. ? col * Temp * 0.001 : col; + + return srgbToLinear2(col); } +uniform float near; + + +float ld(float dist) { + return (2.0 * near) / (far + near - dist * (far - near)); +} + + +vec4 readNoise(in vec2 coord){ + // return texture2D(noisetex,coord*vtexcoordam.pq+vtexcoord.st); + return texture2DGradARB(noisetex,coord*vtexcoordam.pq + vtexcoordam.st,dcdx,dcdy); +} +float EndPortalEffect( + inout vec4 ALBEDO, + vec3 FragPos, + vec3 WorldPos, + mat3 tbnMatrix +){ + + int maxdist = 25; + int quality = 35; + + vec3 viewVec = normalize(tbnMatrix*FragPos); + if ( viewVec.z < 0.0 && length(FragPos) < maxdist) { + float endportalGLow = 0.0; + float Depth = 0.3; + vec3 interval = (viewVec.xyz /-viewVec.z/quality*Depth) * (0.7 + (blueNoise()-0.5)*0.1); + + vec3 coord = vec3(WorldPos.xz , 1.0); + coord += interval; + + for (int loopCount = 0; (loopCount < quality) && (1.0 - Depth + Depth * ( 1.0-readNoise(coord.st).r - readNoise(-coord.st*3).b*0.2 ) ) < coord.p && coord.p >= 0.0; ++loopCount) { + coord = coord+interval ; + endportalGLow += (0.3/quality); + } + + ALBEDO.rgb = vec3(0.5,0.75,1.0) * sqrt(endportalGLow); + + return clamp(pow(endportalGLow*3.5,3),0,1); + } +} + +float bias(){ + // return (Texture_MipMap_Bias + (blueNoise()-0.5)*0.5) - (1.0-RENDER_SCALE.x) * 2.0; + return Texture_MipMap_Bias - (1.0-RENDER_SCALE.x) * 2.0; +} vec4 texture2D_POMSwitch( sampler2D sampler, vec2 lightmapCoord, @@ -193,6 +295,9 @@ vec4 texture2D_POMSwitch( return texture2D(sampler, lightmapCoord, bias()); } } + + + //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// @@ -222,9 +327,8 @@ void main() { vec2 tempOffset=offsets[framemod8]; - vec3 fragpos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0)); - vec3 worldpos = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz + cameraPosition; - + vec3 fragpos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0)); + vec3 worldpos = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz + cameraPosition; float torchlightmap = lmtexcoord.z; @@ -234,103 +338,159 @@ void main() { float lightmap = clamp( (lmtexcoord.w-0.8) * 10.0,0.,1.); - - vec2 adjustedTexCoord = lmtexcoord.xy; - - #ifdef POM - - adjustedTexCoord = fract(vtexcoord.st)*vtexcoordam.pq+vtexcoordam.st; - - vec3 viewVector = normalize(tbnMatrix*fragpos); - float dist = length(fragpos); - - gl_FragDepth = gl_FragCoord.z; - - #ifdef WORLD - if (dist < MAX_OCCLUSION_DISTANCE) { - - float depthmap = readNormal(vtexcoord.st).a; - float used_POM_DEPTH = 1.0; - - if ( viewVector.z < 0.0 && depthmap < 0.9999 && depthmap > 0.00001) { - - #ifdef Adaptive_Step_length - vec3 interval = (viewVector.xyz /-viewVector.z/MAX_OCCLUSION_POINTS * POM_DEPTH) * clamp(1.0-pow(depthmap,2),0.1,1.0) ; - used_POM_DEPTH = 1.0; - #else - vec3 interval = viewVector.xyz /-viewVector.z/MAX_OCCLUSION_POINTS*POM_DEPTH; - #endif - vec3 coord = vec3(vtexcoord.st, 1.0); - - coord += interval * used_POM_DEPTH; - - float sumVec = 0.5; - for (int loopCount = 0; (loopCount < MAX_OCCLUSION_POINTS) && (1.0 - POM_DEPTH + POM_DEPTH * readNormal(coord.st).a ) < coord.p && coord.p >= 0.0; ++loopCount) { - coord = coord+interval * used_POM_DEPTH; - sumVec += 1.0 * used_POM_DEPTH; - } - - if (coord.t < mincoord) { - if (readTexture(vec2(coord.s,mincoord)).a == 0.0) { - coord.t = mincoord; - discard; - } - } - adjustedTexCoord = mix(fract(coord.st)*vtexcoordam.pq+vtexcoordam.st, adjustedTexCoord, max(dist-MIX_OCCLUSION_DISTANCE,0.0)/(MAX_OCCLUSION_DISTANCE-MIX_OCCLUSION_DISTANCE)); - - vec3 truePos = fragpos + sumVec*inverse(tbnMatrix)*interval; - - gl_FragDepth = toClipSpace3(truePos).z; - } - } - #endif + float rainfall = rainStrength * noPuddleAreas; + float Puddle_shape = 0.; + + #if defined Puddles && defined WORLD && !defined ENTITIES && !defined HAND + Puddle_shape = (1.0 - clamp(exp(-15 * pow(texture2D(noisetex, worldpos.xz * (0.020 * Puddle_Size) ).b ,5)),0,1)) * lightmap ; + Puddle_shape *= clamp( viewToWorld(normal).y*0.5+0.5 ,0.0,1.0); + Puddle_shape *= rainfall; #endif + + vec2 adjustedTexCoord = lmtexcoord.xy; + +#if defined POM && defined WORLD && !defined ENTITIES && !defined HAND + // vec2 tempOffset=offsets[framemod8]; + adjustedTexCoord = fract(vtexcoord.st)*vtexcoordam.pq+vtexcoordam.st; + // vec3 fragpos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0)); + vec3 viewVector = normalize(tbnMatrix*fragpos); + float dist = length(fragpos); + + float maxdist = MAX_OCCLUSION_DISTANCE; + if(!ifPOM) maxdist = 0.0; + + gl_FragDepth = gl_FragCoord.z; + + if (dist < maxdist) { + + float depthmap = readNormal(vtexcoord.st).a; + float used_POM_DEPTH = 1.0; + + if ( viewVector.z < 0.0 && depthmap < 0.9999 && depthmap > 0.00001) { + // float noise = interleaved_gradientNoise_temp(); + #ifdef Adaptive_Step_length + vec3 interval = (viewVector.xyz /-viewVector.z/MAX_OCCLUSION_POINTS * POM_DEPTH) * clamp(1.0-pow(depthmap,2),0.1,1.0); + used_POM_DEPTH = 1.0; + #else + vec3 interval = viewVector.xyz /-viewVector.z/MAX_OCCLUSION_POINTS*POM_DEPTH; + #endif + vec3 coord = vec3(vtexcoord.st , 1.0); + + coord += interval * used_POM_DEPTH; + + float sumVec = 0.5; + for (int loopCount = 0; (loopCount < MAX_OCCLUSION_POINTS) && (1.0 - POM_DEPTH + POM_DEPTH * readNormal(coord.st).a ) < coord.p && coord.p >= 0.0; ++loopCount) { + coord = coord + interval * used_POM_DEPTH; + sumVec += 1.0 * used_POM_DEPTH; + } + + if (coord.t < mincoord) { + if (readTexture(vec2(coord.s,mincoord)).a == 0.0) { + coord.t = mincoord; + discard; + } + } + + adjustedTexCoord = mix(fract(coord.st)*vtexcoordam.pq+vtexcoordam.st, adjustedTexCoord, max(dist-MIX_OCCLUSION_DISTANCE,0.0)/(MAX_OCCLUSION_DISTANCE-MIX_OCCLUSION_DISTANCE)); + + vec3 truePos = fragpos + sumVec*inverse(tbnMatrix)*interval; + // #ifdef Depth_Write_POM + gl_FragDepth = toClipSpace3(truePos).z; + // #endif + } + } +#endif + if(!ifPOM) adjustedTexCoord = lmtexcoord.xy; + - //////////////////////////////// - //////////////////////////////// ALBEDO - //////////////////////////////// - + //////////////////////////////// //////////////////////////////// + //////////////////////////////// ALBEDO //////////////////////////////// + //////////////////////////////// //////////////////////////////// + vec4 Albedo = texture2D_POMSwitch(texture, adjustedTexCoord.xy, vec4(dcdx,dcdy), ifPOM) * color; + if(LIGHTNING > 0) Albedo = vec4(1); + // float ENDPORTAL_EFFECT = 0.0; + // #ifndef ENTITIES + // ENDPORTAL_EFFECT = PORTAL > 0 ? EndPortalEffect(Albedo, fragpos, worldpos, tbnMatrix) : 0; + // #endif + + #ifdef WhiteWorld + Albedo.rgb = vec3(1.0); + #endif + + + #ifdef AEROCHROME_MODE + vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631), AEROCHROME_PINKNESS); + float gray = dot(Albedo.rgb, vec3(0.2, 01.0, 0.07)); + if(blockID == 10001 || blockID == 10003 || blockID == 10004 || blockID == 10006) { + // IR Reflective (Pink-red) + Albedo.rgb = mix(vec3(gray), aerochrome_color, 0.7); + } + else if(blockID == 10008) { + // Special handling for grass block + float strength = 1.0 - color.b; + Albedo.rgb = mix(Albedo.rgb, aerochrome_color, strength); + } + #ifdef AEROCHROME_WOOL_ENABLED + else if(blockID == 200) { + // Wool + Albedo.rgb = mix(Albedo.rgb, aerochrome_color, 0.3); + } + #endif + else if(blockID == 8 || blockID == 10002) + { + // IR Absorbsive? Dark. + Albedo.rgb = mix(Albedo.rgb, vec3(0.01, 0.08, 0.15), 0.5); + } + #endif + #ifdef WORLD if (Albedo.a > 0.1) Albedo.a = normalMat.a; else Albedo.a = 0.0; #endif - #ifdef HAND + #if defined HAND if (Albedo.a > 0.1) Albedo.a = 0.75; else Albedo.a = 0.0; #endif - #ifdef WhiteWorld - Albedo.rgb = vec3(1.0); + + //////////////////////////////// //////////////////////////////// + //////////////////////////////// NORMAL //////////////////////////////// + //////////////////////////////// //////////////////////////////// + + #if defined WORLD && defined MC_NORMAL_MAP + vec3 NormalTex = texture2D_POMSwitch(normals, adjustedTexCoord.xy, vec4(dcdx,dcdy), ifPOM).xya; + float Heightmap = 1.0 - NormalTex.z; + + NormalTex.xy = NormalTex.xy*2.0-1.0; + NormalTex.z = clamp(sqrt(1.0 - dot(NormalTex.xy, NormalTex.xy)),0.0,1.0) ; + + #if defined HEIGTHMAP_DEPTH_OFFSET && !defined HAND + gl_FragDepth = gl_FragCoord.z; + vec3 truePos = fragpos; + truePos.z -= Heightmap * POM_DEPTH * (1.0 + ld(truePos.z)); + + gl_FragDepth = toClipSpace3(truePos).z; + #endif + + if(PHYSICSMOD_SNOW < 1) normal = applyBump(tbnMatrix, NormalTex.xyz, mix(1.0,1-Puddle_shape,rainfall) ); #endif - //////////////////////////////// - //////////////////////////////// NORMAL - //////////////////////////////// - - #ifdef WORLD - #ifdef MC_NORMAL_MAP - - vec4 NormalTex = texture2D_POMSwitch(normals, adjustedTexCoord.xy, vec4(dcdx,dcdy), ifPOM); - NormalTex.xy = NormalTex.xy*2.0-1.0; - NormalTex.z = clamp(sqrt(1.0 - dot(NormalTex.xy, NormalTex.xy)),0.0,1.0) ; - - normal = applyBump(tbnMatrix, NormalTex.xyz, 1.0); - #endif - #endif - - //////////////////////////////// - //////////////////////////////// SPECULAR - //////////////////////////////// - + //////////////////////////////// //////////////////////////////// + //////////////////////////////// SPECULAR //////////////////////////////// + //////////////////////////////// //////////////////////////////// + #ifdef WORLD vec4 SpecularTex = texture2D_POMSwitch(specular, adjustedTexCoord.xy, vec4(dcdx,dcdy), ifPOM); + SpecularTex.r = max(SpecularTex.r, Puddle_shape); + SpecularTex.g = max(SpecularTex.g, Puddle_shape*0.02); + gl_FragData[2].rg = SpecularTex.rg; #if EMISSIVE_TYPE == 0 @@ -366,35 +526,51 @@ void main() { #if SSS_TYPE == 3 gl_FragData[2].b = SpecularTex.b; #endif - - // hit glow effect... - #ifdef ENTITIES - Albedo.rgb = mix(Albedo.rgb, entityColor.rgb, entityColor.a); - gl_FragData[2].a = mix(gl_FragData[2].a, 0.9, entityColor.a);; - #endif - + + // #ifndef ENTITIES + // if(PORTAL > 0){ + // gl_FragData[2].rgb = vec3(0); + // gl_FragData[2].a = clamp(ENDPORTAL_EFFECT * 0.9, 0,0.9); + // } + // #endif #endif - //////////////////////////////// - //////////////////////////////// FINALIZE - //////////////////////////////// + // hit glow effect... + #ifdef ENTITIES + Albedo.rgb = mix(Albedo.rgb, entityColor.rgb, entityColor.a); + gl_FragData[2].a = mix(gl_FragData[2].a, 0.25, clamp(entityColor.a*5,0,1)); + #endif - vec4 data1 = clamp( encode(viewToWorld(normal), (blueNoise()*vec2(torchlightmap,lmtexcoord.w) / (30.0 * (1+ (1-RENDER_SCALE.x))) ) + vec2(torchlightmap,lmtexcoord.w)), 0.0, 1.0); - gl_FragData[0] = vec4(encodeVec2(Albedo.x,data1.x), encodeVec2(Albedo.y,data1.y), encodeVec2(Albedo.z,data1.z), encodeVec2(data1.w,Albedo.w)); - - gl_FragData[1].a = 0.0; - - //////////////////////////////// - //////////////////////////////// OTHER STUFF - //////////////////////////////// + //////////////////////////////// //////////////////////////////// + //////////////////////////////// FINALIZE //////////////////////////////// + //////////////////////////////// //////////////////////////////// #ifdef WORLD - gl_FragData[3] = vec4(FlatNormals * 0.5 + 0.5,VanillaAO); + + #ifdef Puddles + float porosity = 0.4; + #ifdef Porosity + porosity = SpecularTex.z >= 64.5/255.0 ? 0.0 : (SpecularTex.z*255.0/64.0)*0.65; + #endif + if(SpecularTex.g < 229.5/255.0) Albedo.rgb = mix(Albedo.rgb, vec3(0), Puddle_shape*porosity); + #endif + + // apply noise to lightmaps to reduce banding. + vec2 PackLightmaps = vec2(torchlightmap, lmtexcoord.w); + + #if !defined ENTITIES && !defined HAND + // PackLightmaps = clamp(PackLightmaps*blueNoise()*0.05 + PackLightmaps,0.0,1.0); + #endif + + + vec4 data1 = clamp( encode(viewToWorld(normal), PackLightmaps), 0.0, 1.0); + + gl_FragData[0] = vec4(encodeVec2(Albedo.x,data1.x), encodeVec2(Albedo.y,data1.y), encodeVec2(Albedo.z,data1.z), encodeVec2(data1.w,Albedo.w)); + + + gl_FragData[3] = vec4(FlatNormals * 0.5 + 0.5, VanillaAO); + #endif - - // gl_FragData[4].x = 0; - - // #ifdef ENTITIES - // gl_FragData[4].x = 1; - // #endif + + gl_FragData[1].a = 0.0; } \ No newline at end of file diff --git a/shaders/dimensions/all_solid.vsh b/shaders/dimensions/all_solid.vsh index da5e516..640a829 100644 --- a/shaders/dimensions/all_solid.vsh +++ b/shaders/dimensions/all_solid.vsh @@ -1,7 +1,7 @@ -//#extension GL_EXT_gpu_shader4 : disable +#extension GL_EXT_gpu_shader4 : enable #include "/lib/settings.glsl" - #include "/lib/res_params.glsl" +#include "/lib/bokeh.glsl" /* !! DO NOT REMOVE !! @@ -61,12 +61,24 @@ flat varying float HELD_ITEM_BRIGHTNESS; flat varying int PHYSICSMOD_SNOW; flat varying int NameTags; +uniform int frameCounter; +uniform float far; +uniform float aspectRatio; +uniform float viewHeight; +uniform float viewWidth; +uniform int hideGUI; +uniform float screenBrightness; + flat varying float SSSAMOUNT; flat varying float EMISSIVE; flat varying int LIGHTNING; flat varying int PORTAL; flat varying int SIGN; +// in vec3 at_velocity; +// out vec3 velocity; + + uniform mat4 gbufferModelView; uniform mat4 gbufferModelViewInverse; @@ -83,6 +95,7 @@ const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.), vec2(-7.,-1.)/8., vec2(3,7.)/8., vec2(7.,-7.)/8.); + #define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z) #define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz) vec4 toClipSpace3(vec3 viewSpacePosition) { @@ -212,12 +225,19 @@ void main() { FlatNormals = normalMat.xyz; blockID = mc_Entity.x; + // velocity = at_velocity; + + if(mc_Entity.x == 10009) normalMat.a = 0.60; + PORTAL = 0; SIGN = 0; + #ifdef WORLD // disallow POM to work on signs. if(blockEntityId == 2200) SIGN = 1; + + if(blockEntityId == 2100) PORTAL = 1; #endif NameTags = 0; @@ -255,7 +275,7 @@ void main() { #ifdef ENTITIES if(entityId == 12345){ LIGHTNING = 1; - normalMat.a = 0.5; + normalMat.a = 0.50; } #endif @@ -270,26 +290,32 @@ void main() { #ifdef WORLD + /////// ----- SSS ON BLOCKS ----- /////// // strong - if(mc_Entity.x == 10001 || mc_Entity.x == 10003 || mc_Entity.x == 10004) SSSAMOUNT = 1.0; + if(mc_Entity.x == 10001 || mc_Entity.x == 10003 || mc_Entity.x == 10004 || mc_Entity.x == 10009) SSSAMOUNT = 1.0; // medium if(mc_Entity.x == 10006 || mc_Entity.x == 200) SSSAMOUNT = 0.75; // low - if(mc_Entity.x == 10007 || mc_Entity.x == 10008) SSSAMOUNT = 0.5; - + + #ifdef MISC_BLOCK_SSS + if(mc_Entity.x == 10007 || mc_Entity.x == 10008) SSSAMOUNT = 0.5; // weird SSS on blocks like grass and stuff + #endif + #ifdef ENTITIES - /////// ----- SSS ON MOBS----- /////// - // strong - if(entityId == 1100) SSSAMOUNT = 0.75; - - // medium - - // low - if(entityId == 1200) SSSAMOUNT = 0.3; + #ifdef MOB_SSS + /////// ----- SSS ON MOBS----- /////// + // strong + if(entityId == 1100) SSSAMOUNT = 0.75; + + // medium + + // low + if(entityId == 1200) SSSAMOUNT = 0.3; + #endif #endif #ifdef BLOCKENTITIES @@ -304,14 +330,62 @@ void main() { #endif + #ifdef WAVY_PLANTS + bool istopv = gl_MultiTexCoord0.t < mc_midTexCoord.t; + if ((mc_Entity.x == 10001 || mc_Entity.x == 10009) && istopv && abs(position.z) < 64.0) { + vec3 worldpos = mat3(gbufferModelViewInverse) * position + gbufferModelViewInverse[3].xyz + cameraPosition; + worldpos.xyz += calcMovePlants(worldpos.xyz)*lmtexcoord.w - cameraPosition; + position = mat3(gbufferModelView) * worldpos + gbufferModelView[3].xyz; + } + + if (mc_Entity.x == 10003 && abs(position.z) < 64.0) { + vec3 worldpos = mat3(gbufferModelViewInverse) * position + gbufferModelViewInverse[3].xyz + cameraPosition; + worldpos.xyz += calcMoveLeaves(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))*lmtexcoord.w - cameraPosition; + position = mat3(gbufferModelView) * worldpos + gbufferModelView[3].xyz; + } + #endif gl_Position = toClipSpace3(position); #endif + #ifdef Seasons + #ifdef WORLD + #ifndef BLOCKENTITIES + #ifndef ENTITIES + #ifndef HAND + float blank = 0.0; + YearCycleColor(color.rgb, gl_Color.rgb, blank); + #endif + #endif + #endif + #endif + #endif + #ifdef TAA_UPSCALING + gl_Position.xy = gl_Position.xy * RENDER_SCALE + RENDER_SCALE * gl_Position.w - gl_Position.w; + #endif #ifdef TAA - gl_Position.xy += offsets[framemod8] * gl_Position.w * texelSize; + gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize; + #endif + + +#if DOF_QUALITY == 5 + vec2 jitter = clamp(jitter_offsets[frameCounter % 64], -1.0, 1.0); + jitter = rotate(radians(float(frameCounter))) * jitter; + jitter.y *= aspectRatio; + jitter.x *= DOF_ANAMORPHIC_RATIO; + + #if MANUAL_FOCUS == -2 + float focusMul = 0; + #elif MANUAL_FOCUS == -1 + float focusMul = gl_Position.z - mix(pow(512.0, screenBrightness), 512.0 * screenBrightness, 0.25); + #else + float focusMul = gl_Position.z - MANUAL_FOCUS; + #endif + + vec2 totalOffset = (jitter * JITTER_STRENGTH) * focusMul * 1e-2; + gl_Position.xy += hideGUI >= 1 ? totalOffset : vec2(0); #endif } diff --git a/shaders/dimensions/all_translucent.fsh b/shaders/dimensions/all_translucent.fsh index 2ddf384..d96f680 100644 --- a/shaders/dimensions/all_translucent.fsh +++ b/shaders/dimensions/all_translucent.fsh @@ -4,6 +4,16 @@ varying vec4 lmtexcoord; varying vec4 color; +#ifdef OVERWORLD_SHADER + const bool shadowHardwareFiltering = true; + uniform sampler2DShadow shadow; + + uniform float lightSign; + flat varying vec3 WsunVec; + + flat varying vec3 averageSkyCol_Clouds; + flat varying vec4 lightCol; +#endif const bool colortex4MipmapEnabled = true; uniform sampler2D noisetex; @@ -17,14 +27,15 @@ uniform sampler2D normals; varying vec4 tangent; varying vec4 normalMat; varying vec3 binormal; - +varying vec3 flatnormal; varying vec3 viewVector; + uniform vec3 sunVec; uniform float near; -uniform float far; +// uniform float far; uniform float sunElevation; uniform int isEyeInWater; @@ -37,7 +48,6 @@ uniform float frameTimeCounter; uniform vec2 texelSize; uniform int framemod8; -flat varying vec3 WsunVec; uniform mat4 gbufferPreviousModelView; uniform vec3 previousCameraPosition; @@ -57,10 +67,17 @@ uniform vec3 nsunColor; #include "/lib/waterBump.glsl" #include "/lib/clouds.glsl" #include "/lib/stars.glsl" -#include "/lib/volumetricClouds.glsl" -#define OVERWORLD -#include "/lib/diffuse_lighting.glsl" +#ifdef OVERWORLD_SHADER + flat varying float Flashing; + #include "/lib/lightning_stuff.glsl" + #include "/lib/volumetricClouds.glsl" +#else + uniform sampler2D colortex4; + uniform float nightVision; +#endif + +#include "/lib/diffuse_lighting.glsl" float blueNoise(){ return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter); @@ -134,9 +151,9 @@ vec2 tapLocation(int sampleNumber,int nb, float nbRot,float jitter,float distort } -vec3 viewToWorld(vec3 viewPosition) { +vec3 viewToWorld(vec3 viewPos) { vec4 pos; - pos.xyz = viewPosition; + pos.xyz = viewPos; pos.w = 0.0; pos = gbufferModelViewInverse * pos; return pos.xyz; @@ -173,7 +190,7 @@ float ld(float dist) { return (2.0 * near) / (far + near - dist * (far - near)); } -vec3 rayTrace(vec3 dir,vec3 position,float dither, float fresnel, bool inwater){ +vec3 rayTrace(vec3 dir, vec3 position,float dither, float fresnel, bool inwater){ float quality = mix(15,SSR_STEPS,fresnel); vec3 clipPosition = toClipSpace3(position); @@ -187,29 +204,30 @@ vec3 rayTrace(vec3 dir,vec3 position,float dither, float fresnel, bool inwater){ float mult = min(min(maxLengths.x,maxLengths.y),maxLengths.z); - vec3 stepv = direction * mult / quality; + vec3 stepv = direction * mult / quality * vec3(RENDER_SCALE,1.0); - vec3 spos = clipPosition+ stepv*dither; + vec3 spos = clipPosition*vec3(RENDER_SCALE,1.0) + stepv*dither; float minZ = clipPosition.z; float maxZ = spos.z+stepv.z*0.5; - spos.xy += offsets[framemod8]*texelSize*0.5; + spos.xy += offsets[framemod8]*texelSize*0.5/RENDER_SCALE; float dist = 1.0 + clamp(position.z*position.z/50.0,0,2); // shrink sample size as distance increases for (int i = 0; i <= int(quality); i++) { - #ifdef USE_QUARTER_RES_DEPTH - // decode depth buffer - float sp = sqrt(texelFetch2D(colortex4,ivec2(spos.xy/texelSize/4),0).w/65000.0); - sp = invLinZ(sp); - if(sp <= max(maxZ,minZ) && sp >= min(maxZ,minZ)) return vec3(spos.xy,sp); + // decode depth buffer + // float sp = sqrt(texelFetch2D(colortex4,ivec2(spos.xy/texelSize/4),0).w/65000.0); + #ifdef HAND + vec2 testthing = spos.xy*texelSize; // fix for ssr on hand #else - float sp = texelFetch2D(depthtex1,ivec2(spos.xy/texelSize),0).r; - if(sp <= max(maxZ,minZ) && sp >= min(maxZ,minZ)) return vec3(spos.xy,sp); - - + vec2 testthing = spos.xy/texelSize/4.0; #endif + float sp = sqrt((texelFetch2D(colortex4,ivec2(testthing),0).a+0.1)/65000.0); + sp = invLinZ(sp); + + if(sp <= max(maxZ,minZ) && sp >= min(maxZ,minZ)) return vec3(spos.xy/RENDER_SCALE,sp); + spos += stepv; //small bias @@ -255,12 +273,17 @@ vec3 GGX (vec3 n, vec3 v, vec3 l, float r, vec3 F0) { /* RENDERTARGETS:2,7,11,14 */ void main() { if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) { + vec2 tempOffset = offsets[framemod8]; - vec3 fragpos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0)); + vec3 viewPos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0)); + vec3 feetPlayerPos = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz; + + //////////////////////////////// + //////////////////////////////// ALBEDO + //////////////////////////////// gl_FragData[0] = texture2D(texture, lmtexcoord.xy, Texture_MipMap_Bias) * color; vec3 Albedo = toLinear(gl_FragData[0].rgb); - float UnchangedAlpha = gl_FragData[0].a; float iswater = normalMat.w; @@ -282,20 +305,21 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) #endif - vec4 COLORTEST = vec4(Albedo,UnchangedAlpha); + vec4 COLORTEST = vec4(Albedo, UnchangedAlpha); - vec3 p3 = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz; + + //////////////////////////////// + //////////////////////////////// NORMAL + //////////////////////////////// vec3 normal = normalMat.xyz; vec2 TangentNormal = vec2(0); // for refractions vec3 tangent2 = normalize(cross(tangent.rgb,normal)*tangent.w); mat3 tbnMatrix = mat3(tangent.x, tangent2.x, normal.x, - tangent.y, tangent2.y, normal.y, - tangent.z, tangent2.z, normal.z); - - /// ------ NORMALS ------ /// + tangent.y, tangent2.y, normal.y, + tangent.z, tangent2.z, normal.z); vec4 NormalTex = texture2D(normals, lmtexcoord.xy, Texture_MipMap_Bias).rgba; NormalTex.xy = NormalTex.xy*2.0-1.0; @@ -304,30 +328,108 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) normal = applyBump(tbnMatrix, NormalTex.xyz, 1.0); - if (iswater > 0.95){ - float bumpmult = 1.0; - vec3 bump = vec3(0); - vec3 posxz = p3+cameraPosition; + + #ifndef HAND + if (iswater > 0.95){ + float bumpmult = 1.0; + vec3 bump = vec3(0); + vec3 posxz = feetPlayerPos+cameraPosition; - posxz.xz -= posxz.y; - posxz.xyz = getParallaxDisplacement(posxz,iswater,bumpmult,normalize(tbnMatrix*fragpos)) ; + posxz.xz -= posxz.y; + posxz.xyz = getParallaxDisplacement(posxz,iswater,bumpmult,normalize(tbnMatrix*viewPos)) ; - bump = normalize(getWaveHeight(posxz.xz,iswater)); - - TangentNormal = bump.xy*0.5+0.5; // tangent space normals for refraction + bump = normalize(getWaveHeight(posxz.xz,iswater)); - bump = bump * vec3(bumpmult, bumpmult, bumpmult) + vec3(0.0f, 0.0f, 1.0f - bumpmult); - normal = normalize(bump * tbnMatrix); - } + TangentNormal = bump.xy*0.5+0.5; // tangent space normals for refraction + + bump = bump * vec3(bumpmult, bumpmult, bumpmult) + vec3(0.0f, 0.0f, 1.0f - bumpmult); + normal = normalize(bump * tbnMatrix); + } + #endif gl_FragData[2] = vec4(encodeVec2(TangentNormal), encodeVec2(COLORTEST.rg), encodeVec2(COLORTEST.ba), UnchangedAlpha); - - vec3 WS_normal = viewToWorld(normal); + //////////////////////////////// + //////////////////////////////// DIFFUSE LIGHTING + //////////////////////////////// - vec2 lightmaps2 = lmtexcoord.zw; + vec2 lightmap = lmtexcoord.zw; + #ifndef OVERWORLD_SHADER + lightmap.y = 1.0; + #endif vec3 Indirect_lighting = vec3(0.0); + vec3 Direct_lighting = vec3(0.0); + + #ifdef OVERWORLD_SHADER + float NdotL = clamp(dot(normal, normalize(WsunVec*mat3(gbufferModelViewInverse))),0.0,1.0); NdotL = clamp((-15 + NdotL*255.0) / 240.0 ,0.0,1.0); + float Shadows = 0.0; + bool inShadowmapBounds = false; + + vec3 feetPlayerPos_shadow = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz; + + vec3 projectedShadowPosition = mat3(shadowModelView) * feetPlayerPos_shadow + shadowModelView[3].xyz; + projectedShadowPosition = diagonal3(shadowProjection) * projectedShadowPosition + shadowProjection[3].xyz; + + //apply distortion + float distortFactor = calcDistort(projectedShadowPosition.xy); + projectedShadowPosition.xy *= distortFactor; + + bool ShadowBounds = false; + if(shadowDistanceRenderMul > 0.0) ShadowBounds = length(feetPlayerPos_shadow) < max(shadowDistance - 20,0.0); + + if(shadowDistanceRenderMul < 0.0) ShadowBounds = abs(projectedShadowPosition.x) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.y) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.z) < 6.0; + + // sample shadows only if on shadow map + if(ShadowBounds){ + if (NdotL > 0.0){ + Shadows = 0.0; + projectedShadowPosition = projectedShadowPosition * vec3(0.5,0.5,0.5/6.0) + vec3(0.5); + + #ifndef HAND + #ifdef BASIC_SHADOW_FILTER + const float threshMul = max(2048.0/shadowMapResolution*shadowDistance/128.0,0.95); + float distortThresh = (sqrt(1.0-NdotL*NdotL)/NdotL+0.7)/distortFactor; + float diffthresh = distortThresh/6000.0*threshMul; + + float rdMul = 4.0/shadowMapResolution; + float noise = blueNoise(); + + int SampleCount = 7; + for(int i = 0; i < SampleCount; i++){ + vec2 offsetS = tapLocation(i,SampleCount,1.618,noise,0.0); + + float weight = 1.0+(i+noise)*rdMul/9.0*shadowMapResolution; + float isShadow = shadow2D(shadow, projectedShadowPosition + vec3(rdMul*offsetS, -diffthresh*weight)).x / SampleCount; + Shadows += isShadow; + } + + #else + Shadows = shadow2D(shadow, projectedShadowPosition - vec3(0.0,0.0,0.0001)).x; + #endif + #else + Shadows = shadow2D(shadow, projectedShadowPosition - vec3(0.0,0.0,0.0005)).x; + #endif + } + inShadowmapBounds = true; + } + + // if(!inShadowmapBounds && !iswater) Shadows = min(max(lightmap.y-0.8, 0.0) * 25,1.0); + if(!inShadowmapBounds) Shadows = 1.0; + + Shadows *= GetCloudShadow(feetPlayerPos); + + Direct_lighting = (lightCol.rgb/80.0) * NdotL * Shadows; + + + vec3 ambientcoefs = WS_normal / dot(abs(WS_normal), vec3(1)); + float SkylightDir = ambientcoefs.y*1.5; + + float skylight = max(pow(viewToWorld(flatnormal).y*0.5+0.5,0.1) + SkylightDir, 0.25); + + // float skylight = max(pow(viewToWorld(flatnormal).y*0.5+0.5,0.1) + viewToWorld(normal).y, 0.25) * 1.35; + Indirect_lighting = DoAmbientLighting(averageSkyCol_Clouds, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.xy, skylight); + #endif #ifdef NETHER_SHADER WS_normal.xz = -WS_normal.xz; @@ -342,25 +444,31 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) AmbientLightColor += up + down; // do all ambient lighting stuff - Indirect_lighting = DoAmbientLighting_Nether(AmbientLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), lightmaps2.x, vec3(0.0), vec3(0.0), vec3(0.0)); + Indirect_lighting = DoAmbientLighting_Nether(AmbientLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, vec3(0.0), vec3(0.0), vec3(0.0)); #endif #ifdef END_SHADER // do all ambient lighting stuff - Indirect_lighting = DoAmbientLighting_End(gl_Fog.color.rgb, vec3(TORCH_R,TORCH_G,TORCH_B), lightmaps2.x, normal, p3 ); + Indirect_lighting = DoAmbientLighting_End(gl_Fog.color.rgb, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, normal, feetPlayerPos ); #endif - vec3 FinalColor = Indirect_lighting * Albedo; + vec3 FinalColor = (Indirect_lighting + Direct_lighting) * Albedo; #ifdef Glass_Tint - float alphashit = min(pow(gl_FragData[0].a,2.0),1.0); - FinalColor *= alphashit; + FinalColor *= min(pow(gl_FragData[0].a,2.0),1.0); #endif + //////////////////////////////// + //////////////////////////////// SPECULAR + //////////////////////////////// + #ifdef DAMAGE_BLOCK_EFFECT + #undef WATER_REFLECTIONS + #endif + #ifdef WATER_REFLECTIONS vec2 SpecularTex = texture2D(specular, lmtexcoord.xy, Texture_MipMap_Bias).rg; - SpecularTex = (iswater > 0.0 && iswater < 0.9) && SpecularTex.r > 0.0 && SpecularTex.g < 0.9 ? SpecularTex : vec2(1.0,0.1); + SpecularTex = (iswater > 0.0 && iswater < 0.9) && SpecularTex.r > 0.0 && SpecularTex.g < 0.9 ? SpecularTex : vec2(1.0,0.02); float roughness = max(pow(1.0-SpecularTex.r,2.0),0.05); float f0 = SpecularTex.g; @@ -369,28 +477,41 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) vec3 Reflections_Final = vec3(0.0); vec4 Reflections = vec4(0.0); vec3 SkyReflection = vec3(0.0); + vec3 SunReflection = vec3(0.0); + + float indoors = clamp((lightmap.y-0.6)*5.0, 0.0,1.0); - - vec3 reflectedVector = reflect(normalize(fragpos), normal); - float normalDotEye = dot(normal, normalize(fragpos)); - float fresnel = pow(clamp(1.0 + normalDotEye,0.0,1.0), 5.0); + vec3 reflectedVector = reflect(normalize(viewPos), normal); + + float normalDotEye = dot(normal, normalize(viewPos)); + float fresnel = pow(clamp(1.0 + dot(normal, normalize(viewPos)), 0.0, 1.0),5.0); + + // float fresnel = exp(clamp(0.0 - dot(normal, normalize(viewPos)), 0.0, 1.0) * -5); // snells window looking thing if(isEyeInWater == 1 ) fresnel = pow(clamp(1.66 + normalDotEye,0.0,1.0), 25.0); fresnel = mix(f0, 1.0, fresnel); - vec3 wrefl = mat3(gbufferModelViewInverse)*reflectedVector; - // SSR, Sky, and Sun reflections - #ifdef WATER_BACKGROUND_SPECULAR - SkyReflection = skyCloudsFromTexLOD2(wrefl, colortex4, 0).rgb / 30.0; - if(isEyeInWater == 1) SkyReflection = vec3(0.0); + // Sun, Sky, and screen-space reflections + #ifdef OVERWORLD_SHADER + #ifdef WATER_SUN_SPECULAR + SunReflection = Direct_lighting * GGX(normal, -normalize(viewPos), WsunVec*mat3(gbufferModelViewInverse), roughness, vec3(f0)); + #endif + #ifdef WATER_BACKGROUND_SPECULAR + SkyReflection = skyCloudsFromTex(mat3(gbufferModelViewInverse) * reflectedVector, colortex4).rgb / 30.0; + if(isEyeInWater == 1) SkyReflection = vec3(0.0); + #endif + #else + #ifdef WATER_BACKGROUND_SPECULAR + SkyReflection = skyCloudsFromTexLOD2(mat3(gbufferModelViewInverse) * reflectedVector, colortex4, 0).rgb / 30.0; + if(isEyeInWater == 1) SkyReflection = vec3(0.0); + #endif #endif - #ifdef SCREENSPACE_REFLECTIONS if(iswater > 0.0){ - vec3 rtPos = rayTrace(reflectedVector,fragpos.xyz, interleaved_gradientNoise(), fresnel, isEyeInWater == 1); + vec3 rtPos = rayTrace(reflectedVector, viewPos.xyz, interleaved_gradientNoise(), fresnel, isEyeInWater == 1); if (rtPos.z < 1.){ vec3 previousPosition = mat3(gbufferModelViewInverse) * toScreenSpace(rtPos) + gbufferModelViewInverse[3].xyz + cameraPosition-previousCameraPosition; previousPosition = mat3(gbufferPreviousModelView) * previousPosition + gbufferPreviousModelView[3].xyz; @@ -405,8 +526,10 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) float visibilityFactor = clamp(exp2((pow(roughness,3.0) / f0) * -4),0,1); - Reflections_Final = mix(SkyReflection, Reflections.rgb, Reflections.a); - Reflections_Final = mix(FinalColor, Reflections_Final, fresnel * visibilityFactor); + Reflections_Final = mix(SkyReflection*indoors, Reflections.rgb, Reflections.a); + Reflections_Final = mix(FinalColor, Reflections_Final, fresnel); + Reflections_Final += SunReflection; + gl_FragData[0].rgb = Reflections_Final; @@ -423,7 +546,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) #endif #ifndef HAND - gl_FragData[1] = vec4(Albedo,iswater); + gl_FragData[1] = vec4(Albedo, iswater); #endif gl_FragData[3].a = max(lmtexcoord.w*blueNoise()*0.05 + lmtexcoord.w,0.0); diff --git a/shaders/dimensions/all_translucent.vsh b/shaders/dimensions/all_translucent.vsh index 9fa4dc3..051c005 100644 --- a/shaders/dimensions/all_translucent.vsh +++ b/shaders/dimensions/all_translucent.vsh @@ -1,8 +1,7 @@ -// #version 120 -//#extension GL_EXT_gpu_shader4 : disable #include "/lib/settings.glsl" #include "/lib/res_params.glsl" #include "/lib/bokeh.glsl" +#include "/lib/Shadow_Params.glsl" /* !! DO NOT REMOVE !! @@ -13,9 +12,17 @@ Read the terms of modification and sharing before changing something below pleas varying vec4 lmtexcoord; varying vec4 color; + +#ifdef OVERWORLD_SHADER + flat varying vec3 averageSkyCol_Clouds; + flat varying vec4 lightCol; + flat varying vec3 WsunVec; +#endif + varying vec4 normalMat; varying vec3 binormal; varying vec4 tangent; +varying vec3 flatnormal; uniform mat4 gbufferModelViewInverse; varying vec3 viewVector; @@ -28,13 +35,12 @@ attribute vec4 mc_Entity; uniform sampler2D colortex4; uniform vec3 sunPosition; -flat varying vec3 WsunVec; uniform float sunElevation; varying vec4 tangent_other; uniform int frameCounter; -uniform float far; +// uniform float far; uniform float aspectRatio; uniform float viewHeight; uniform float viewWidth; @@ -77,7 +83,6 @@ void main() { vec3 position = mat3(gl_ModelViewMatrix) * vec3(Swtich_gl_vertex) + gl_ModelViewMatrix[3].xyz; gl_Position = toClipSpace3(position); - color = vec4(gl_Color.rgb,1.0); float mat = 0.0; @@ -106,10 +111,30 @@ void main() { mat3 tbnMatrix = mat3(tangent2.x, binormal.x, normalMat.x, tangent2.y, binormal.y, normalMat.y, tangent2.z, binormal.z, normalMat.z); + + flatnormal = normalMat.xyz; viewVector = ( gl_ModelViewMatrix * Swtich_gl_vertex).xyz; viewVector = normalize(tbnMatrix * viewVector); + + color = vec4(gl_Color.rgb, 1.0); + + #ifdef OVERWORLD_SHADER + lightCol.rgb = texelFetch2D(colortex4,ivec2(6,37),0).rgb; + lightCol.a = float(sunElevation > 1e-5)*2.0 - 1.0; + + averageSkyCol_Clouds = texelFetch2D(colortex4,ivec2(0,37),0).rgb; + + WsunVec = lightCol.a * normalize(mat3(gbufferModelViewInverse) * sunPosition); + // WsunVec = normalize(LightDir); + #endif + + + + #ifdef TAA_UPSCALING + gl_Position.xy = gl_Position.xy * RENDER_SCALE + RENDER_SCALE * gl_Position.w - gl_Position.w; + #endif #ifdef TAA gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize; #endif diff --git a/shaders/gbuffers_spidereyes.fsh b/shaders/dimensions/all_vanilla_emissives.fsh similarity index 56% rename from shaders/gbuffers_spidereyes.fsh rename to shaders/dimensions/all_vanilla_emissives.fsh index 53d6bca..1c169e0 100644 --- a/shaders/gbuffers_spidereyes.fsh +++ b/shaders/dimensions/all_vanilla_emissives.fsh @@ -1,6 +1,3 @@ -#version 120 - - varying vec4 color; varying vec2 texcoord; @@ -34,17 +31,37 @@ float encodeVec2(float x,float y){ //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// -/* DRAWBUFFERS:28 */ +#if defined SPIDER_EYES || defined BEACON_BEAM || defined GLOWING + /* DRAWBUFFERS:1 */ +#endif + +#ifdef ENCHANT_GLINT + /* DRAWBUFFERS:2 */ +#endif void main() { vec4 Albedo = texture2D(texture, texcoord); - Albedo *= color; - Albedo.rgb = toLinear(Albedo.rgb); + #if defined SPIDER_EYES || defined BEACON_BEAM || defined GLOWING + vec4 data1 = vec4(1.0); float materialMask = 1.0; - gl_FragData[0] = Albedo; - if (gl_FragData[0].r > 65000.) gl_FragData[0].rgba = vec4(0.); + #if defined SPIDER_EYES || defined GLOWING + if(Albedo.a < 0.1) discard; + Albedo.rgb *= color.a; + #endif - gl_FragData[1] = vec4(0.0,0.0,0.0,0.5); + #ifdef BEACON_BEAM + Albedo.rgb = Albedo.rgb * color.rgb; + materialMask = 0.75; + #endif + + gl_FragData[0] = vec4(encodeVec2(Albedo.x,data1.x), encodeVec2(Albedo.y,data1.y), encodeVec2(Albedo.z,data1.z), encodeVec2(data1.w, materialMask)); + #endif + + #ifdef ENCHANT_GLINT + vec3 GlintColor = toLinear(Albedo.rgb * color.rgb) * Albedo.a; + + gl_FragData[0] = vec4(GlintColor, Albedo.a * 0.1); + #endif } \ No newline at end of file diff --git a/shaders/gbuffers_spidereyes.vsh b/shaders/dimensions/all_vanilla_emissives.vsh similarity index 83% rename from shaders/gbuffers_spidereyes.vsh rename to shaders/dimensions/all_vanilla_emissives.vsh index 5bb3b51..52b9875 100644 --- a/shaders/gbuffers_spidereyes.vsh +++ b/shaders/dimensions/all_vanilla_emissives.vsh @@ -1,6 +1,3 @@ -#version 120 -//#extension GL_EXT_gpu_shader4 : disable - #include "/lib/settings.glsl" #include "/lib/res_params.glsl" @@ -24,6 +21,7 @@ const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.), vec2(-7.,-1.)/8., vec2(3,7.)/8., vec2(7.,-7.)/8.); + //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// @@ -34,10 +32,18 @@ void main() { gl_Position = ftransform(); - // gl_Position = vec4(10,10,10,1); - texcoord = (gl_MultiTexCoord0).xy; + #ifdef ENCHANT_GLINT + texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).st; + // float exposure = texelFetch2D(colortex4, ivec2(10,37),0).r; + #endif + color = gl_Color; + #ifdef BEACON_BEAM + if(gl_Color.a < 1.0) gl_Position = vec4(10,10,10,0); + #endif + + #ifdef TAA_UPSCALING gl_Position.xy = gl_Position.xy * RENDER_SCALE + RENDER_SCALE * gl_Position.w - gl_Position.w; diff --git a/shaders/dimensions/composite.fsh b/shaders/dimensions/composite.fsh index c0230d0..a3c623c 100644 --- a/shaders/dimensions/composite.fsh +++ b/shaders/dimensions/composite.fsh @@ -1,119 +1,80 @@ #include "/lib/settings.glsl" -#include "/lib/diffuse_lighting.glsl" - - -varying vec2 texcoord; - - - -const bool colortex5MipmapEnabled = true; -const bool colortex4MipmapEnabled = true; - -uniform sampler2D noisetex;//depth - -uniform sampler2D depthtex1;//depth -uniform sampler2D depthtex0;//depth - -uniform sampler2D colortex0;//clouds -uniform sampler2D colortex1;//albedo(rgb),material(alpha) RGBA16 -uniform sampler2D colortex2; -uniform sampler2D colortex3; -uniform sampler2D colortex4;//Skybox -uniform sampler2D colortex5; -uniform sampler2D colortex6;//Skybox -uniform sampler2D colortex7; -uniform sampler2D colortex8; -uniform sampler2D colortex10; -uniform sampler2D colortex15; - - -uniform mat4 shadowModelView; -uniform mat4 shadowModelViewInverse; -uniform mat4 shadowProjection; -uniform mat4 shadowProjectionInverse; -uniform mat4 gbufferProjection; -uniform mat4 gbufferProjectionInverse; -uniform mat4 gbufferModelView; -uniform mat4 gbufferModelViewInverse; -uniform mat4 gbufferPreviousProjection; -uniform mat4 gbufferPreviousModelView; - -uniform vec3 cameraPosition; -uniform vec3 previousCameraPosition; - -uniform float far; -uniform float near; - -uniform vec2 texelSize; -uniform float viewWidth; -uniform float viewHeight; -uniform float aspectRatio; +flat varying vec3 WsunVec; flat varying vec2 TAA_Offset; -uniform int frameCounter; -uniform float frameTimeCounter; - -uniform float rainStrength; -uniform int isEyeInWater; -uniform ivec2 eyeBrightnessSmooth; +#include "/lib/res_params.glsl" +uniform sampler2D depthtex1; +uniform sampler2D colortex1; +uniform sampler2D colortex6; // Noise +uniform sampler2D colortex8; // Noise +uniform sampler2D colortex15; // Noise +uniform sampler2D shadow; +uniform sampler2D noisetex; uniform vec3 sunVec; +uniform vec2 texelSize; +uniform float frameTimeCounter; +uniform float rainStrength; +uniform int frameCounter; +uniform mat4 gbufferProjection; +uniform mat4 gbufferProjectionInverse; +uniform mat4 gbufferModelViewInverse; +uniform mat4 gbufferModelView; +uniform mat4 shadowModelView; +uniform mat4 shadowProjection; +uniform vec3 cameraPosition; +uniform float viewWidth; +uniform float aspectRatio; +uniform float viewHeight; +// uniform float far; +uniform float near; + +#define ffstep(x,y) clamp((y - x) * 1e35,0.0,1.0) #define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z) #define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz) - vec3 toScreenSpace(vec3 p) { vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw); vec3 p3 = p * 2. - 1.; vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3]; return fragposition.xyz / fragposition.w; } - -#include "/lib/color_transforms.glsl" -#include "/lib/waterBump.glsl" -#include "/lib/sky_gradient.glsl" - - -float ld(float dist) { - return (2.0 * near) / (far + near - dist * (far - near)); +vec3 worldToView(vec3 worldPos) { + vec4 pos = vec4(worldPos, 0.0); + pos = gbufferModelView * pos; + return pos.xyz; } -vec2 RENDER_SCALE = vec2(1.0); - -#include "/lib/end_fog.glsl" - -#undef LIGHTSOURCE_REFLECTION -#define ENDSPECULAR -#include "/lib/specular.glsl" - - -vec3 normVec (vec3 vec){ - return vec*inversesqrt(dot(vec,vec)); -} -float lengthVec (vec3 vec){ - return sqrt(dot(vec,vec)); -} -#define fsign(a) (clamp((a)*1e35,0.,1.)*2.-1.) -float triangularize(float dither) +vec2 tapLocation(int sampleNumber,int nb, float nbRot,float jitter,float distort) { - float center = dither*2.0-1.0; - dither = center*inversesqrt(abs(center)); - return clamp(dither-fsign(center),0.0,1.0); + float alpha = (sampleNumber+jitter)/nb; + float angle = jitter*6.28+alpha * nbRot * 6.28; + float sin_v, cos_v; + + sin_v = sin(angle); + cos_v = cos(angle); + + return vec2(cos_v, sin_v)*alpha; } +vec2 tapLocation2(int sampleNumber, int nb, float jitter){ + float alpha = (sampleNumber+jitter)/nb; + float angle = jitter*6.28 + alpha * 84.0 * 6.28; -vec3 fp10Dither(vec3 color,float dither){ - const vec3 mantissaBits = vec3(6.,6.,5.); - vec3 exponent = floor(log2(color)); - return color + dither*exp2(-mantissaBits)*exp2(exponent); + float sin_v, cos_v; + + sin_v = sin(angle); + cos_v = cos(angle); + + return vec2(cos_v, sin_v)*sqrt(alpha); } - - - -float facos(float sx){ - float x = clamp(abs( sx ),0.,1.); - return sqrt( 1. - x ) * ( -0.16882 * x + 1.56734 ); +float interleaved_gradientNoise(){ + vec2 coord = gl_FragCoord.xy + (frameCounter%40000); + // vec2 coord = gl_FragCoord.xy + frameTimeCounter; + // vec2 coord = gl_FragCoord.xy; + float noise = fract( 52.9829189 * fract( (coord.x * 0.06711056) + (coord.y * 0.00583715)) ); + return noise ; } vec3 decode (vec2 encn){ vec3 n = vec3(0.0); @@ -128,542 +89,185 @@ vec2 decodeVec2(float a){ const float constant2 = 256. / 255.; return fract( a * constant1 ) * constant2 ; } -// float linZ(float depth) { -// return (2.0 * near) / (far + near - depth * (far - near)); -// // l = (2*n)/(f+n-d(f-n)) -// // f+n-d(f-n) = 2n/l -// // -d(f-n) = ((2n/l)-f-n) -// // d = -((2n/l)-f-n)/(f-n) - -// } -// float invLinZ (float lindepth){ -// return -((2.0*near/lindepth)-far-near)/(far-near); -// } - -// vec3 toClipSpace3(vec3 viewSpacePosition) { -// return projMAD(gbufferProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5; -// } - - - - -vec2 tapLocation(int sampleNumber,int nb, float nbRot,float jitter,float distort) -{ - float alpha0 = sampleNumber/nb; - float alpha = (sampleNumber+jitter)/nb; - float angle = jitter*6.28 + alpha * 4.0 * 6.28; - - float sin_v, cos_v; - - sin_v = sin(angle); - cos_v = cos(angle); - - return vec2(cos_v, sin_v)*sqrt(alpha); -} - - - -vec3 BilateralFiltering(sampler2D tex, sampler2D depth,vec2 coord,float frDepth,float maxZ){ - vec4 sampled = vec4(texelFetch2D(tex,ivec2(coord),0).rgb,1.0); - - return vec3(sampled.x,sampled.yz/sampled.w); -} -float interleaved_gradientNoise(){ - // vec2 coord = gl_FragCoord.xy + (frameCounter%40000); - vec2 coord = gl_FragCoord.xy + frameTimeCounter; - // vec2 coord = gl_FragCoord.xy; - float noise = fract( 52.9829189 * fract( (coord.x * 0.06711056) + (coord.y * 0.00583715)) ); - return noise ; -} - -vec2 R2_dither(){ +float R2_dither(){ vec2 alpha = vec2(0.75487765, 0.56984026); - return vec2(fract(alpha.x * gl_FragCoord.x + alpha.y * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter), fract((1.0-alpha.x) * gl_FragCoord.x + (1.0-alpha.y) * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter)); + return fract(alpha.x * gl_FragCoord.x + alpha.y * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter); } float blueNoise(){ - return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * (frameCounter*0.5+0.5) ); + return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter); } vec4 blueNoise(vec2 coord){ - return texelFetch2D(colortex6, ivec2(coord)%512 , 0) ; -} -vec3 toShadowSpaceProjected(vec3 p3){ - p3 = mat3(gbufferModelViewInverse) * p3 + gbufferModelViewInverse[3].xyz; - p3 = mat3(shadowModelView) * p3 + shadowModelView[3].xyz; - p3 = diagonal3(shadowProjection) * p3 + shadowProjection[3].xyz; - - return p3; -} -vec2 tapLocation(int sampleNumber, float spinAngle,int nb, float nbRot,float r0) -{ - float alpha = (float(sampleNumber*1.0f + r0) * (1.0 / (nb))); - float angle = alpha * (nbRot * 6.28) + spinAngle*6.28; - - float ssR = alpha; - float sin_v, cos_v; - - sin_v = sin(angle); - cos_v = cos(angle); - - return vec2(cos_v, sin_v)*ssR; + return texelFetch2D(colortex6, ivec2(coord )%512 , 0); } - -float ssao(vec3 fragpos, float dither,vec3 normal) -{ - float mulfov = 1.0; - ivec2 pos = ivec2(gl_FragCoord.xy); - const float tan70 = tan(70.*3.14/180.); - float mulfov2 = gbufferProjection[1][1]/tan70; - - const float PI = 3.14159265; - const float samplingRadius = 0.712; - float angle_thresh = 0.05; - - - - - float rd = mulfov2*0.05; - //pre-rotate direction - float n = 0.; - - float occlusion = 0.0; - - vec2 acc = -vec2(TAA_Offset)*texelSize*0.5; - float mult = (dot(normal,normalize(fragpos))+1.0)*0.5+0.5; - - vec2 v = fract(vec2(dither,interleaved_gradientNoise()) + (frameCounter%10000) * vec2(0.75487765, 0.56984026)); - for (int j = 0; j < 7+2 ;j++) { - vec2 sp = tapLocation(j,v.x,7+2,2.,v.y); - vec2 sampleOffset = sp*rd; - ivec2 offset = ivec2(gl_FragCoord.xy + sampleOffset*vec2(viewWidth,viewHeight)); - if (offset.x >= 0 && offset.y >= 0 && offset.x < viewWidth && offset.y < viewHeight ) { - vec3 t0 = toScreenSpace(vec3(offset*texelSize+acc+0.5*texelSize,texelFetch2D(depthtex1,offset,0).x)); - - vec3 vec = t0.xyz - fragpos; - float dsquared = dot(vec,vec); - if (dsquared > 1e-5){ - if (dsquared < fragpos.z*fragpos.z*0.05*0.05*mulfov2*2.*1.412){ - float NdotV = clamp(dot(vec*inversesqrt(dsquared), normalize(normal)),0.,1.); - occlusion += NdotV; - } - n += 1.0; - } - } - } - - - - - return clamp(1.0-occlusion/n*2.0,0.,1.0); -} -vec3 viewToWorld(vec3 viewPosition) { - vec4 pos; - pos.xyz = viewPosition; - pos.w = 0.0; - pos = gbufferModelViewInverse * pos; - return pos.xyz; -} -vec3 worldToView(vec3 worldPos) { - vec4 pos = vec4(worldPos, 0.0); - pos = gbufferModelView * pos; - return pos.xyz; -} -void waterVolumetrics(inout vec3 inColor, vec3 rayStart, vec3 rayEnd, float estEndDepth, float estSunDepth, float rayLength, float dither, vec3 waterCoefs, vec3 scatterCoef, vec3 ambient){ - inColor *= exp(-rayLength * waterCoefs); //No need to take the integrated value - int spCount = rayMarchSampleCount; - vec3 start = toShadowSpaceProjected(rayStart); - vec3 end = toShadowSpaceProjected(rayEnd); - vec3 dV = (end-start); - //limit ray length at 32 blocks for performance and reducing integration error - //you can't see above this anyway - float maxZ = min(rayLength,12.0)/(1e-8+rayLength); - dV *= maxZ; - vec3 dVWorld = -mat3(gbufferModelViewInverse) * (rayEnd - rayStart) * maxZ; - rayLength *= maxZ; - float dY = normalize(mat3(gbufferModelViewInverse) * rayEnd).y * rayLength; - estEndDepth *= maxZ; - estSunDepth *= maxZ; - vec3 absorbance = vec3(1.0); - vec3 vL = vec3(0.0); - - - float expFactor = 11.0; - vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition; - for (int i=0;i -near) ? - (-near -position.z) / dir.z : far*sqrt(3.) ; - vec3 direction = toClipSpace3(position+dir*rayLength)-clipPosition; //convert to clip space - direction.xyz = direction.xyz/max(abs(direction.x)/texelSize.x,abs(direction.y)/texelSize.y); //fixed step size - vec3 stepv = direction * 3.0 * clamp(MC_RENDER_QUALITY,1.,2.0); - - vec3 spos = clipPosition; - spos += stepv*dither ; - - for (int i = 0; i < int(quality); i++) { - spos += stepv; - - float sp = texture2D(depthtex1,spos.xy).x; - - if( sp < spos.z) { - float dist = abs(linZ(sp)-linZ(spos.z))/linZ(spos.z); - if (dist < 0.015 ) return i / quality; - } - } - return 1.0; -} - - - -vec3 rayTrace_GI(vec3 dir,vec3 position,float dither, float quality){ - - vec3 clipPosition = toClipSpace3(position); - float rayLength = ((position.z + dir.z * far*sqrt(3.)) > -near) ? - (-near -position.z) / dir.z : far*sqrt(3.); - vec3 direction = normalize(toClipSpace3(position+dir*rayLength)-clipPosition); //convert to clip space - direction.xy = normalize(direction.xy); - - //get at which length the ray intersects with the edge of the screen - vec3 maxLengths = (step(0.,direction)-clipPosition) / direction; - float mult = maxLengths.y; - - vec3 stepv = direction * mult / quality*vec3(RENDER_SCALE,1.0) * dither; - vec3 spos = clipPosition*vec3(RENDER_SCALE,1.0) ; - - spos.xy += TAA_Offset*texelSize*0.5/RENDER_SCALE; - - float biasdist = clamp(position.z*position.z/50.0,1,2); // shrink sample size as distance increases - - for(int i = 0; i < int(quality); i++){ - spos += stepv; - float sp = sqrt(texelFetch2D(colortex4,ivec2(spos.xy/texelSize/4),0).w/65000.0); - float currZ = linZ(spos.z); - - if( sp < currZ) { - float dist = abs(sp-currZ)/currZ; - if (abs(dist) < biasdist*0.05) return vec3(spos.xy, invLinZ(sp))/vec3(RENDER_SCALE,1.0); - } - spos += stepv; - } - return vec3(1.1); -} -vec3 RT(vec3 dir, vec3 position, float noise, float stepsizes){ - float dist = 1.0 + clamp(position.z*position.z/50.0,0,2); // shrink sample size as distance increases - - float stepSize = stepsizes / dist; - int maxSteps = STEPS; - vec3 clipPosition = toClipSpace3(position); - float rayLength = ((position.z + dir.z * sqrt(3.0)*far) > -sqrt(3.0)*near) ? - (-sqrt(3.0)*near -position.z) / dir.z : sqrt(3.0)*far; - vec3 end = toClipSpace3(position+dir*rayLength) ; - vec3 direction = end-clipPosition ; //convert to clip space - - float len = max(abs(direction.x)/texelSize.x,abs(direction.y)/texelSize.y)/stepSize; - //get at which length the ray intersects with the edge of the screen - vec3 maxLengths = (step(0.,direction)-clipPosition) / direction; - - float mult = min(min(maxLengths.x,maxLengths.y),maxLengths.z)*2000.0; - - vec3 stepv = direction/len; - - int iterations = min(int(min(len, mult*len)-2), maxSteps); - - //Do one iteration for closest texel (good contact shadows) - vec3 spos = clipPosition*vec3(RENDER_SCALE,1.0) ; - spos.xy += TAA_Offset*texelSize*0.5*RENDER_SCALE; - spos += stepv/(stepSize/2); - - float distancered = 1.0 + clamp(position.z*position.z/50.0,0,2); // shrink sample size as distance increases - - for(int i = 0; i < iterations; i++){ - if (spos.x < 0.0 || spos.y < 0.0 || spos.z < 0.0 || spos.x > 1.0 || spos.y > 1.0 || spos.z > 1.0) return vec3(1.1); - spos += stepv*noise; - - float sp = sqrt(texelFetch2D(colortex4,ivec2(spos.xy/ texelSize/4),0).w/65000.0); - float currZ = linZ(spos.z); - - if( sp < currZ) { - float dist = abs(sp-currZ)/currZ; - if (dist <= 0.1) return vec3(spos.xy, invLinZ(sp))/vec3(RENDER_SCALE,1.0); - } - } - return vec3(1.1); -} - -vec3 cosineHemisphereSample(vec2 Xi, float roughness){ - float r = sqrt(Xi.x); - float theta = 2.0 * 3.14159265359 * Xi.y; - - float x = r * cos(theta); - float y = r * sin(theta); - - return vec3(x, y, sqrt(clamp(1.0 - Xi.x,0.,1.))); -} - -vec3 TangentToWorld(vec3 N, vec3 H, float roughness){ - vec3 UpVector = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); - vec3 T = normalize(cross(UpVector, N)); - vec3 B = cross(N, T); - - return vec3((T * H.x) + (B * H.y) + (N * H.z)); -} vec2 R2_samples(int n){ vec2 alpha = vec2(0.75487765, 0.56984026); return fract(alpha * n); } +vec2 tapLocation_alternate( + int sampleNumber, + float spinAngle, + int nb, + float nbRot, + float r0 +){ + float alpha = (float(sampleNumber*1.0f + r0) * (1.0 / (nb))); + float angle = alpha * (nbRot * 3.14) ; -void ApplySSRT(inout vec3 lighting, vec3 normal,vec2 noise,vec3 fragpos, float lightmaps, vec3 torchcolor){ - int nrays = RAY_COUNT; + float ssR = alpha + spinAngle*3.14; + float sin_v, cos_v; - vec3 radiance = vec3(0.0); - vec3 occlusion = vec3(0.0); - vec3 skycontribution = vec3(0.0); - - // float skyLM = 0.0; - // vec3 torchlight = vec3(0.0); - // vec3 blank = vec3(0.0); - // DoRTAmbientLighting(torchcolor, vec2(lightmaps,1.0), skyLM, torchlight, blank); - - for (int i = 0; i < nrays; i++){ - int seed = (frameCounter%40000)*nrays+i; - vec2 ij = fract(R2_samples(seed) + noise ); - - vec3 rayDir = TangentToWorld(normal, normalize(cosineHemisphereSample(ij,1.0)) ,1.0); - - #ifdef HQ_SSGI - vec3 rayHit = rayTrace_GI( mat3(gbufferModelView) * rayDir, fragpos, blueNoise(), 50.); // ssr rt - #else - vec3 rayHit = RT(mat3(gbufferModelView)*rayDir, fragpos, blueNoise(), 30.); // choc sspt - #endif - - skycontribution = lighting; - - if (rayHit.z < 1.){ - - #if indirect_effect == 4 - vec3 previousPosition = mat3(gbufferModelViewInverse) * toScreenSpace(rayHit) + gbufferModelViewInverse[3].xyz + cameraPosition-previousCameraPosition; - previousPosition = mat3(gbufferPreviousModelView) * previousPosition + gbufferPreviousModelView[3].xyz; - previousPosition.xy = projMAD(gbufferPreviousProjection, previousPosition).xy / -previousPosition.z * 0.5 + 0.5; - if (previousPosition.x > 0.0 && previousPosition.y > 0.0 && previousPosition.x < 1.0 && previousPosition.x < 1.0){ - radiance += (texture2D(colortex5,previousPosition.xy).rgb + skycontribution) * GI_Strength; - }else{ - radiance += skycontribution; - } - #else - radiance += skycontribution; - #endif - - occlusion += skycontribution * GI_Strength; - - } else { - radiance += skycontribution; - } - } - - occlusion *= AO_Strength; - - lighting = max(radiance/nrays - occlusion/nrays, 0.0); + sin_v = sin(angle); + cos_v = cos(angle); + return vec2(cos_v, sin_v)*ssR; } +vec3 viewToWorld(vec3 viewPos) { + vec4 pos; + pos.xyz = viewPos; + pos.w = 0.0; + pos = gbufferModelViewInverse * pos; + return pos.xyz; +} + + +// Emin's and Gri's combined ideas to stop peter panning and light leaking, also has little shadowacne so thats nice +// https://www.complementary.dev/reimagined +// https://github.com/gri573 +void GriAndEminShadowFix( + inout vec3 WorldPos, + vec3 FlatNormal, + float VanillaAO, + float SkyLightmap, + bool Entities +){ + float DistanceOffset = clamp(0.1 + length(WorldPos) / (shadowMapResolution*0.20), 0.0,1.0) ; + vec3 Bias = FlatNormal * DistanceOffset; // adjust the bias thingy's strength as it gets farther away. + + // stop lightleaking + if(SkyLightmap < 0.1 && !Entities) { + WorldPos += mix(Bias, 0.5 * (0.5 - fract(WorldPos + cameraPosition + FlatNormal*0.01 ) ), VanillaAO) ; + }else{ + WorldPos += Bias; + } +} + +#include "/lib/Shadow_Params.glsl" void main() { - - ////// --------------- SETUP COORDINATE SPACES --------------- ////// - - float z0 = texture2D(depthtex0,texcoord).x; - float z = texture2D(depthtex1,texcoord).x; - - vec2 tempOffset=TAA_Offset; - float noise = blueNoise(); - - vec3 fragpos = toScreenSpace(vec3(texcoord-vec2(tempOffset)*texelSize*0.5,z)); - vec3 p3 = mat3(gbufferModelViewInverse) * fragpos; - vec3 np3 = normVec(p3); - - ////// --------------- UNPACK OPAQUE GBUFFERS --------------- ////// - - vec4 data = texture2D(colortex1,texcoord); - vec4 dataUnpacked0 = vec4(decodeVec2(data.x),decodeVec2(data.y)); // albedo, masks - vec4 dataUnpacked1 = vec4(decodeVec2(data.z),decodeVec2(data.w)); // normals, lightmaps - // vec4 dataUnpacked2 = vec4(decodeVec2(data.z),decodeVec2(data.w)); - - vec3 albedo = toLinear(vec3(dataUnpacked0.xz,dataUnpacked1.x)); - vec2 lightmap = dataUnpacked1.yz; - vec3 normal = decode(dataUnpacked0.yw); - - ////// --------------- UNPACK MISC --------------- ////// - - vec4 SpecularTex = texture2D(colortex8,texcoord); - float LabSSS = clamp((-65.0 + SpecularTex.z * 255.0) / 190.0 ,0.0,1.0); - - vec4 normalAndAO = texture2D(colortex15,texcoord); - vec3 FlatNormals = normalAndAO.rgb * 2.0 - 1.0; - vec3 slopednormal = normal; - - #ifdef POM - #ifdef Horrible_slope_normals - vec3 ApproximatedFlatNormal = normalize(cross(dFdx(p3), dFdy(p3))); // it uses depth that has POM written to it. - slopednormal = normalize(clamp(normal, ApproximatedFlatNormal*2.0 - 1.0, ApproximatedFlatNormal*2.0 + 1.0) ); - #endif - #endif - - float vanilla_AO = clamp(normalAndAO.a,0,1); - normalAndAO.a = clamp(pow(normalAndAO.a*5,4),0,1); - - - ////// --------------- MASKS/BOOLEANS --------------- ////// - - bool iswater = texture2D(colortex7,texcoord).a > 0.99; - bool lightningBolt = abs(dataUnpacked1.w-0.5) <0.01; - bool isLeaf = abs(dataUnpacked1.w-0.55) <0.01; - bool entities = abs(dataUnpacked1.w-0.45) < 0.01; - bool hand = abs(dataUnpacked1.w-0.75) < 0.01; - // bool blocklights = abs(dataUnpacked1.w-0.8) <0.01; - - - ////// --------------- COLORS --------------- ////// - - float dirtAmount = Dirt_Amount; - vec3 waterEpsilon = vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B); - vec3 dirtEpsilon = vec3(Dirt_Absorb_R, Dirt_Absorb_G, Dirt_Absorb_B); - vec3 totEpsilon = dirtEpsilon*dirtAmount + waterEpsilon; - vec3 scatterCoef = dirtAmount * vec3(Dirt_Scatter_R, Dirt_Scatter_G, Dirt_Scatter_B) / 3.14; - - vec3 Indirect_lighting = vec3(1.0); - vec3 Direct_lighting = vec3(0.0); - - ///////////////////////////// start drawin :D - - if (z >= 1.0) { - - gl_FragData[0].rgb = vec3(0.0); - - } else { - - p3 += gbufferModelViewInverse[3].xyz; - - //////////////////////////////////////////////////////////////////////////////////// - ///////////////////////////// MAJOR LIGHTSOURCE STUFF //////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - - #ifdef END_SHADER - vec3 LightColor = LightSourceColor(clamp(sqrt(length(p3+cameraPosition) / 150.0 - 1.0) ,0.0,1.0)); - vec3 LightPos = LightSourcePosition(p3+cameraPosition, cameraPosition); - - float LightFalloff = max(exp2(4.0 + length(LightPos) / -25),0.0); - - float NdotL = clamp( dot(normal,normalize(-LightPos)),0.0,1.0); - NdotL = clamp((-15 + NdotL*255.0) / 240.0 ,0.0,1.0); - - float fogshadow = GetCloudShadow(p3+cameraPosition, LightPos, blueNoise()); - Direct_lighting = (LightColor * max(LightColor - (1-fogshadow) ,0.0)) * LightFalloff * NdotL; - // vec3 LightSource = LightColor * fogshadow * LightFalloff * NdotL ; - - - - float LightFalloff2 = max(1.0-length(LightPos)/120,0.0); - LightFalloff2 = pow(1.0-pow(1.0-LightFalloff2,0.5),2.0); - LightFalloff2 *= 25; - - Direct_lighting += (LightColor * max(LightColor - 0.6,0.0)) * vec3(1.0,1.3,1.0) * LightFalloff2 * (NdotL*0.7+0.3); - - // float RT_Shadows = rayTraceShadow(worldToView(normalize(-LightPos)), fragpos_RTSHADOW, blueNoise()); - // if(!hand) LightSource *= RT_Shadows*RT_Shadows; - #endif - - ///////////////////////////////////////////////////////////////////////////////// - ///////////////////////////// INDIRECT LIGHTING ///////////////////////////// - ///////////////////////////////////////////////////////////////////////////////// - - #ifdef END_SHADER - Indirect_lighting = DoAmbientLighting_End(gl_Fog.color.rgb, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, normal, np3); - #endif - - #ifdef NETHER_SHADER - vec3 AmbientLightColor = skyCloudsFromTexLOD2(normal, colortex4, 6).rgb / 10; - - vec3 up = skyCloudsFromTexLOD2(vec3( 0, 1, 0), colortex4, 6).rgb / 10; - vec3 down = skyCloudsFromTexLOD2(vec3( 0,-1, 0), colortex4, 6).rgb / 10; - - up *= pow( max( slopednormal.y, 0), 2); - down *= pow( max(-slopednormal.y, 0), 2); - AmbientLightColor += up + down; - - // do all ambient lighting stuff - Indirect_lighting = DoAmbientLighting_Nether(AmbientLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, normal, np3, p3 ); - #endif - ///////////////////////////////////////////////////////////////////////////////////// - ///////////////////////////// EFFECTS FOR INDIRECT ///////////////////////////// - ///////////////////////////////////////////////////////////////////////////////////// - - #if indirect_effect == 0 - vec3 AO = vec3( exp( (vanilla_AO*vanilla_AO) * -5) ) ; - if(!hand) Indirect_lighting *= AO; - #endif - - #if indirect_effect == 1 - vec3 AO = vec3( exp( (vanilla_AO*vanilla_AO) * -5) ) ; - if(!hand) Indirect_lighting *= ssao(fragpos,noise,FlatNormals) * AO; - #endif - - // RTAO and/or SSGI - #if indirect_effect == 3 || indirect_effect == 4 - if (!hand) ApplySSRT(Indirect_lighting, normal, blueNoise(gl_FragCoord.xy).rg, fragpos, lightmap.x,vec3(TORCH_R,TORCH_G,TORCH_B)); - #endif - - ///////////////////////////////////////////////////////////////////////// - ///////////////////////////// FINALIZE ///////////////////////////// - ///////////////////////////////////////////////////////////////////////// - - gl_FragData[0].rgb = (Indirect_lighting + Direct_lighting) * albedo; - - #ifdef Specular_Reflections - vec3 specNoise = vec3(blueNoise(gl_FragCoord.xy).rg, interleaved_gradientNoise()); - DoSpecularReflections(gl_FragData[0].rgb, fragpos, np3, vec3(0.0), specNoise, normal, SpecularTex.r, SpecularTex.g, albedo, vec3(0.0), 1.0, hand); - #endif - - Emission(gl_FragData[0].rgb, albedo, SpecularTex.a); - - if(lightningBolt) gl_FragData[0].rgb = vec3(1); - - } - - if (iswater && isEyeInWater == 0){ - vec3 fragpos0 = toScreenSpace(vec3(texcoord/RENDER_SCALE-TAA_Offset*texelSize*0.5,z0)); - float Vdiff = distance(fragpos,fragpos0); - float VdotU = np3.y; - float estimatedDepth = Vdiff * abs(VdotU) ; //assuming water plane - - vec3 ambientColVol = max(vec3(1.0,0.5,1.0) * 0.3, vec3(0.2,0.4,1.0) * (MIN_LIGHT_AMOUNT*0.01 + nightVision)); - - waterVolumetrics(gl_FragData[0].rgb, fragpos0, fragpos, estimatedDepth , estimatedDepth, Vdiff, noise, totEpsilon, scatterCoef, ambientColVol); - } - /* DRAWBUFFERS:3 */ -} + vec2 texcoord = gl_FragCoord.xy*texelSize; + + float z = texture2D(depthtex1,texcoord).x; + + vec2 tempOffset=TAA_Offset; + + vec4 data = texture2D(colortex1,texcoord); + vec4 dataUnpacked0 = vec4(decodeVec2(data.x),decodeVec2(data.y)); + vec4 dataUnpacked1 = vec4(decodeVec2(data.z),decodeVec2(data.w)); + vec3 normal = mat3(gbufferModelViewInverse) * clamp(worldToView( decode(dataUnpacked0.yw) ),-1.,1.); + vec2 lightmap = dataUnpacked1.yz; + + + // bool lightningBolt = abs(dataUnpacked1.w-0.5) <0.01; + // bool isLeaf = abs(dataUnpacked1.w-0.55) <0.01; + // bool translucent2 = abs(dataUnpacked1.w-0.6) <0.01; // Weak translucency + // bool translucent4 = abs(dataUnpacked1.w-0.65) <0.01; // Weak translucency + bool entities = abs(dataUnpacked1.w-0.45) < 0.01; + bool hand = abs(dataUnpacked1.w-0.75) < 0.01; + // bool blocklights = abs(dataUnpacked1.w-0.8) <0.01; + + + float minshadowfilt = Min_Shadow_Filter_Radius; + float maxshadowfilt = Max_Shadow_Filter_Radius; + + float NdotL = clamp(dot(normal,WsunVec),0.0,1.0); + + // vec4 normalAndAO = texture2D(colortex15,texcoord); + // vec3 FlatNormals = normalAndAO.rgb * 2.0 - 1.0; + // float vanillAO = clamp(normalAndAO.a,0.0,1.0) ; + + float vanillAO = clamp(texture2D(colortex15,texcoord).a,0.0,1.0) ; + + if(lightmap.y < 0.1 && !entities){ + // minshadowfilt *= vanillAO; + maxshadowfilt = mix(minshadowfilt, maxshadowfilt, vanillAO); + } + + + float SpecularTex = texture2D(colortex8,texcoord).z; + float LabSSS = clamp((-64.0 + SpecularTex * 255.0) / 191.0 ,0.0,1.0); + + #ifndef Variable_Penumbra_Shadows + if (LabSSS > 0.0 && !hand && NdotL < 0.001) minshadowfilt += 50; + #endif + + gl_FragData[0] = vec4(minshadowfilt, 0.1, 0.0, 0.0); + + gl_FragData[0].y = 0; + if (z < 1.0 && !hand){ + + vec3 viewPos = toScreenSpace(vec3(texcoord/RENDER_SCALE-vec2(tempOffset)*texelSize*0.5,z)); + + #ifdef Variable_Penumbra_Shadows + + if (NdotL > 0.001 || LabSSS > 0.0) { + + vec3 feetPlayerPos = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz; + + // GriAndEminShadowFix(p3, viewToWorld(FlatNormals), vanillAO, lightmap.y, entities); + + vec3 projectedShadowPosition = mat3(shadowModelView) * feetPlayerPos + shadowModelView[3].xyz; + projectedShadowPosition = diagonal3(shadowProjection) * projectedShadowPosition + shadowProjection[3].xyz; + + //apply distortion + float distortFactor = calcDistort(projectedShadowPosition.xy); + projectedShadowPosition.xy *= distortFactor; + + //do shadows only if on shadow map + if (abs(projectedShadowPosition.x) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.y) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.z) < 6.0){ + const float threshMul = max(2048.0/shadowMapResolution*shadowDistance/128.0,0.95); + float distortThresh = (sqrt(1.0-NdotL*NdotL)/NdotL+0.7)/distortFactor; + float diffthresh = distortThresh/6000.0*threshMul; + projectedShadowPosition = projectedShadowPosition * vec3(0.5,0.5,0.5/6.0) + vec3(0.5,0.5,0.5); + + float mult = maxshadowfilt; + float avgBlockerDepth = 0.0; + vec2 scales = vec2(0.0, 120.0 - Max_Filter_Depth); + float blockerCount = 0.0; + float rdMul = distortFactor*(1.0+mult)*d0*k/shadowMapResolution; + float diffthreshM = diffthresh*mult*d0*k/20.; + float avgDepth = 0.0; + + int seed = (frameCounter%40000) * 2 + (1+frameCounter); + float samplePos = fract(R2_samples(seed).x + blueNoise(gl_FragCoord.xy).x) * 1.61803398874; + float noise = 0.5+blueNoise(); + + for(int i = 0; i < VPS_Search_Samples; i++){ + + vec2 offsetS = tapLocation_alternate(i+1, i/VPS_Search_Samples, 7, 20, samplePos) * noise; + + + float weight = 3.0 + (i+blueNoise() ) *rdMul/SHADOW_FILTER_SAMPLE_COUNT*shadowMapResolution*distortFactor/2.7; + // float d = texelFetch2D( shadow, ivec2((projectedShadowPosition.xy+offsetS*rdMul)*shadowMapResolution),0).x; + float d = texelFetch2D( shadow, ivec2((projectedShadowPosition.xy+offsetS*rdMul)*shadowMapResolution),0).x; + + + float b = smoothstep(weight*diffthresh/2.0, weight*diffthresh, projectedShadowPosition.z - d); + + blockerCount += b; + avgDepth += max(projectedShadowPosition.z - d, 0.0)*1000.; + avgBlockerDepth += d * b; + } + + gl_FragData[0].g = avgDepth / VPS_Search_Samples; + gl_FragData[0].b = blockerCount / VPS_Search_Samples; + if (blockerCount >= 0.9){ + avgBlockerDepth /= blockerCount; + float ssample = max(projectedShadowPosition.z - avgBlockerDepth,0.0)*1500.0; + gl_FragData[0].r = clamp(ssample, scales.x, scales.y)/(scales.y)*(mult-minshadowfilt)+minshadowfilt; + } + } + } + #endif + } +} \ No newline at end of file diff --git a/shaders/dimensions/composite.vsh b/shaders/dimensions/composite.vsh index 50ae0c2..476633c 100644 --- a/shaders/dimensions/composite.vsh +++ b/shaders/dimensions/composite.vsh @@ -1,24 +1,21 @@ +//#extension GL_EXT_gpu_shader4 : disable + #include "/lib/settings.glsl" -varying vec2 texcoord; - -flat varying vec3 avgAmbient; - -flat varying float tempOffsets; flat varying vec2 TAA_Offset; -flat varying vec3 zMults; +flat varying vec3 WsunVec; uniform sampler2D colortex4; -uniform float far; -uniform float near; -uniform mat4 gbufferModelViewInverse; -uniform vec3 sunPosition; -uniform float rainStrength; -uniform float sunElevation; uniform int frameCounter; +uniform float sunElevation; +uniform vec3 sunPosition; +uniform mat4 gbufferModelViewInverse; +#include "/lib/util.glsl" +#include "/lib/res_params.glsl" +uniform int framemod8; const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.), vec2(-1.,3.)/8., vec2(5.0,1.)/8., @@ -27,23 +24,14 @@ const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.), vec2(-7.,-1.)/8., vec2(3,7.)/8., vec2(7.,-7.)/8.); - - -#include "/lib/util.glsl" - void main() { gl_Position = ftransform(); - texcoord = gl_MultiTexCoord0.xy; - tempOffsets = HaltonSeq2(frameCounter%10000); + WsunVec = (float(sunElevation > 1e-5)*2-1.)*normalize(mat3(gbufferModelViewInverse) * sunPosition); - TAA_Offset = offsets[frameCounter%8]; - - #ifndef TAA - TAA_Offset = vec2(0.0); + TAA_Offset = offsets[framemod8]; + + #ifdef TAA_UPSCALING + gl_Position.xy = (gl_Position.xy*0.5+0.5)*RENDER_SCALE*2.0-1.0; #endif - - - avgAmbient = texelFetch2D(colortex4,ivec2(0,37),0).rgb; - zMults = vec3((far * near)*2.0,far+near,far-near); } diff --git a/shaders/dimensions/composite1.fsh b/shaders/dimensions/composite1.fsh index 6390521..498fbac 100644 --- a/shaders/dimensions/composite1.fsh +++ b/shaders/dimensions/composite1.fsh @@ -1,117 +1,666 @@ #include "/lib/settings.glsl" +#include "/lib/res_params.glsl" + +const bool colortex5MipmapEnabled = true; -uniform sampler2D noisetex; -uniform sampler2D depthtex0; +#ifdef OVERWORLD_SHADER + const bool shadowHardwareFiltering = true; + uniform sampler2DShadow shadow; -uniform sampler2D colortex2; -uniform sampler2D colortex3; -// uniform sampler2D colortex4; -uniform vec3 sunVec; -uniform float sunElevation; -uniform float far; + flat varying vec3 averageSkyCol_Clouds; + flat varying vec4 lightCol; + + uniform sampler2D colortex14; + #if Sun_specular_Strength != 0 + #define LIGHTSOURCE_REFLECTION + #endif + + #include "/lib/lightning_stuff.glsl" + +#endif +#ifdef NETHER_SHADER + + uniform float nightVision; + uniform sampler2D colortex4; + const bool colortex4MipmapEnabled = true; + uniform vec3 lightningEffect; + // #define LIGHTSOURCE_REFLECTION +#endif + +#ifdef END_SHADER + uniform float nightVision; + uniform sampler2D colortex4; + uniform vec3 lightningEffect; + + flat varying float Flashing; + // #define LIGHTSOURCE_REFLECTION +#endif + +uniform sampler2D noisetex; //noise +uniform sampler2D depthtex1; //depth +uniform sampler2D depthtex0; //depth + +uniform sampler2D colortex0; //clouds +uniform sampler2D colortex1; //albedo(rgb),material(alpha) RGBA16 +uniform sampler2D colortex2; //translucents(rgba) +uniform sampler2D colortex3; //filtered shadowmap(VPS) +// uniform sampler2D colortex4; //LUT(rgb), quarter res depth(alpha) +uniform sampler2D colortex5; //TAA buffer/previous frame +uniform sampler2D colortex6; //Noise +uniform sampler2D colortex7; //water? +uniform sampler2D colortex8; //Specular +// uniform sampler2D colortex10; +uniform sampler2D colortex15; // flat normals(rgb), vanillaAO(alpha) + + + +uniform mat4 shadowModelView; +uniform mat4 shadowModelViewInverse; +uniform mat4 shadowProjection; +uniform mat4 shadowProjectionInverse; +uniform mat4 gbufferProjection; +uniform mat4 gbufferProjectionInverse; +uniform mat4 gbufferModelView; +uniform mat4 gbufferModelViewInverse; +uniform mat4 gbufferPreviousProjection; +uniform mat4 gbufferPreviousModelView; + +uniform vec3 cameraPosition; +uniform vec3 previousCameraPosition; + +// uniform float far; +uniform float near; + +uniform vec2 texelSize; +uniform float viewWidth; +uniform float viewHeight; +uniform float aspectRatio; + +uniform float eyeAltitude; +flat varying vec2 TAA_Offset; uniform int frameCounter; uniform float frameTimeCounter; -varying vec2 texcoord; -uniform vec2 texelSize; -flat varying vec2 TAA_Offset; - -uniform int isEyeInWater; uniform float rainStrength; +uniform int isEyeInWater; uniform ivec2 eyeBrightnessSmooth; +uniform vec3 sunVec; +flat varying vec3 WsunVec; + +#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z) +#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz) + +vec3 toScreenSpace(vec3 p) { + vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw); + vec3 feetPlayerPos = p * 2. - 1.; + vec4 viewPos = iProjDiag * feetPlayerPos.xyzz + gbufferProjectionInverse[3]; + return viewPos.xyz / viewPos.w; +} + #include "/lib/color_transforms.glsl" -#include "/lib/color_dither.glsl" -#include "/lib/projections.glsl" -#include "/lib/res_params.glsl" +#include "/lib/waterBump.glsl" +#include "/lib/sky_gradient.glsl" -#ifdef END_SHADER - #include "/lib/end_fog.glsl" +#include "/lib/Shadow_Params.glsl" +#include "/lib/Shadows.glsl" +#include "/lib/stars.glsl" + +#ifdef OVERWORLD_SHADER + #include "/lib/volumetricClouds.glsl" #endif -#ifdef NETHER_SHADER - #include "/lib/nether_fog.glsl" -#endif +#include "/lib/diffuse_lighting.glsl" +float ld(float dist) { + return (2.0 * near) / (far + near - dist * (far - near)); +} + + +#include "/lib/end_fog.glsl" +#include "/lib/specular.glsl" + + +vec3 normVec (vec3 vec){ + return vec*inversesqrt(dot(vec,vec)); +} +float lengthVec (vec3 vec){ + return sqrt(dot(vec,vec)); +} #define fsign(a) (clamp((a)*1e35,0.,1.)*2.-1.) +float triangularize(float dither) +{ + float center = dither*2.0-1.0; + dither = center*inversesqrt(abs(center)); + return clamp(dither-fsign(center),0.0,1.0); +} +vec3 fp10Dither(vec3 color,float dither){ + const vec3 mantissaBits = vec3(6.,6.,5.); + vec3 exponent = floor(log2(color)); + return color + dither*exp2(-mantissaBits)*exp2(exponent); +} + + + +float facos(float sx){ + float x = clamp(abs( sx ),0.,1.); + return sqrt( 1. - x ) * ( -0.16882 * x + 1.56734 ); +} +vec3 decode (vec2 encn){ + vec3 n = vec3(0.0); + encn = encn * 2.0 - 1.0; + n.xy = abs(encn); + n.z = 1.0 - n.x - n.y; + n.xy = n.z <= 0.0 ? (1.0 - n.yx) * sign(encn) : encn; + return clamp(normalize(n.xyz),-1.0,1.0); +} +vec2 decodeVec2(float a){ + const vec2 constant1 = 65535. / vec2( 256., 65536.); + const float constant2 = 256. / 255.; + return fract( a * constant1 ) * constant2 ; +} +// float linZ(float depth) { +// return (2.0 * near) / (far + near - depth * (far - near)); +// // l = (2*n)/(f+n-d(f-n)) +// // f+n-d(f-n) = 2n/l +// // -d(f-n) = ((2n/l)-f-n) +// // d = -((2n/l)-f-n)/(f-n) + +// } +// float invLinZ (float lindepth){ +// return -((2.0*near/lindepth)-far-near)/(far-near); +// } + +// vec3 toClipSpace3(vec3 viewSpacePosition) { +// return projMAD(gbufferProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5; +// } + + + + +vec2 tapLocation(int sampleNumber,int nb, float nbRot,float jitter,float distort) +{ + float alpha0 = sampleNumber/nb; + float alpha = (sampleNumber+jitter)/nb; + float angle = jitter*6.28 + alpha * 4.0 * 6.28; + + float sin_v, cos_v; + + sin_v = sin(angle); + cos_v = cos(angle); + + return vec2(cos_v, sin_v)*sqrt(alpha); +} + + +vec3 BilateralFiltering(sampler2D tex, sampler2D depth,vec2 coord,float frDepth,float maxZ){ + vec4 sampled = vec4(texelFetch2D(tex,ivec2(coord),0).rgb,1.0); + + return vec3(sampled.x,sampled.yz/sampled.w); +} float interleaved_gradientNoise(){ - return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y)+TAA_Offset.x); + // vec2 coord = gl_FragCoord.xy + (frameCounter%40000); + vec2 coord = gl_FragCoord.xy + frameTimeCounter; + // vec2 coord = gl_FragCoord.xy; + float noise = fract( 52.9829189 * fract( (coord.x * 0.06711056) + (coord.y * 0.00583715)) ); + return noise ; +} + +vec2 R2_dither(){ + vec2 alpha = vec2(0.75487765, 0.56984026); + return vec2(fract(alpha.x * gl_FragCoord.x + alpha.y * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter), fract((1.0-alpha.x) * gl_FragCoord.x + (1.0-alpha.y) * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter)); } float blueNoise(){ - return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter); + return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * (frameCounter*0.5+0.5) ); +} +vec4 blueNoise(vec2 coord){ + return texelFetch2D(colortex6, ivec2(coord)%512 , 0) ; } -void waterVolumetrics(inout vec3 inColor, vec3 rayStart, vec3 rayEnd, float estEndDepth, float estSunDepth, float rayLength, float dither, vec3 waterCoefs, vec3 scatterCoef, vec3 ambient){ - inColor *= exp(-rayLength * waterCoefs); //No need to take the integrated value - - int spCount = rayMarchSampleCount; - vec3 start = toShadowSpaceProjected(rayStart); - vec3 end = toShadowSpaceProjected(rayEnd); - vec3 dV = (end-start); - //limit ray length at 32 blocks for performance and reducing integration error - //you can't see above this anyway - float maxZ = min(rayLength,12.0)/(1e-8+rayLength); - dV *= maxZ; +vec3 toShadowSpaceProjected(vec3 feetPlayerPos){ + feetPlayerPos = mat3(gbufferModelViewInverse) * feetPlayerPos + gbufferModelViewInverse[3].xyz; + feetPlayerPos = mat3(shadowModelView) * feetPlayerPos + shadowModelView[3].xyz; + feetPlayerPos = diagonal3(shadowProjection) * feetPlayerPos + shadowProjection[3].xyz; + + return feetPlayerPos; +} + +vec2 tapLocation(int sampleNumber, float spinAngle,int nb, float nbRot,float r0) +{ + float alpha = (float(sampleNumber*1.0f + r0) * (1.0 / (nb))); + float angle = alpha * (nbRot * 6.28) + spinAngle*6.28; + + float ssR = alpha; + float sin_v, cos_v; + + sin_v = sin(angle); + cos_v = cos(angle); + + return vec2(cos_v, sin_v)*ssR; +} + +vec3 viewToWorld(vec3 viewPos) { + vec4 pos; + pos.xyz = viewPos; + pos.w = 0.0; + pos = gbufferModelViewInverse * pos; + return pos.xyz; +} +vec3 worldToView(vec3 worldPos) { + vec4 pos = vec4(worldPos, 0.0); + pos = gbufferModelView * pos; + return pos.xyz; +} + +void waterVolumetrics_notoverworld(inout vec3 inColor, vec3 rayStart, vec3 rayEnd, float estEndDepth, float estSunDepth, float rayLength, float dither, vec3 waterCoefs, vec3 scatterCoef, vec3 ambient){ + inColor *= exp(-rayLength * waterCoefs); //No need to take the integrated value + int spCount = rayMarchSampleCount; + vec3 start = toShadowSpaceProjected(rayStart); + vec3 end = toShadowSpaceProjected(rayEnd); + vec3 dV = (end-start); + //limit ray length at 32 blocks for performance and reducing integration error + //you can't see above this anyway + float maxZ = min(rayLength,12.0)/(1e-8+rayLength); + dV *= maxZ; + vec3 dVWorld = -mat3(gbufferModelViewInverse) * (rayEnd - rayStart) * maxZ; + rayLength *= maxZ; + float dY = normalize(mat3(gbufferModelViewInverse) * rayEnd).y * rayLength; + estEndDepth *= maxZ; + estSunDepth *= maxZ; + vec3 absorbance = vec3(1.0); + vec3 vL = vec3(0.0); - rayLength *= maxZ; - - float dY = normalize(mat3(gbufferModelViewInverse) * rayEnd).y * rayLength; - estEndDepth *= maxZ; - estSunDepth *= maxZ; + float expFactor = 11.0; + vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition; + for (int i=0;i -near) ? +// (-near -position.z) / dir.z : far*sqrt(3.) ; +// vec3 direction = toClipSpace3(position+dir*rayLength)-clipPosition; //convert to clip space +// direction.xyz = direction.xyz/max(abs(direction.x)/texelSize.x,abs(direction.y)/texelSize.y); //fixed step size +// vec3 stepv = direction * 3.0 * clamp(MC_RENDER_QUALITY,1.,2.0); + +// vec3 spos = clipPosition; +// spos += stepv*dither ; + +// for (int i = 0; i < int(quality); i++) { +// spos += stepv; + +// float sp = texture2D(depthtex1,spos.xy).x; + +// if( sp < spos.z) { +// float dist = abs(linZ(sp)-linZ(spos.z))/linZ(spos.z); +// if (dist < 0.015 ) return i / quality; +// } +// } +// return 1.0; +// } + + +void SSRT_Shadows(vec3 viewPos, vec3 lightDir, float noise, bool isSSS, bool inshadowmap, inout float Shadow, inout float SSS){ + float steps = 16.0; + vec3 clipPosition = toClipSpace3(viewPos); + + //prevents the ray from going behind the camera + float rayLength = ((viewPos.z + lightDir.z * far*sqrt(3.)) > -near) ? + (-near -viewPos.z) / lightDir.z : far*sqrt(3.); + + vec3 direction = toClipSpace3(viewPos + lightDir*rayLength) - clipPosition; //convert to clip space + direction.xyz = direction.xyz / max(abs(direction.x)/texelSize.x, abs(direction.y)/texelSize.y); //fixed step size + + vec3 rayDir = direction * (isSSS ? 1.5 : 3.0) * vec3(RENDER_SCALE,1.0); + + vec3 screenPos = clipPosition*vec3(RENDER_SCALE,1.0) + rayDir*noise; + + if(isSSS) screenPos -= rayDir*0.9; + + float shadowgradient = 0; + for (int i = 0; i < int(steps); i++) { + + screenPos += rayDir; + + float shadowGradient = i/steps; + + float samplePos = texture2D(depthtex1, screenPos.xy).x; + if(samplePos <= screenPos.z) { + vec2 linearZ = vec2(linZ(screenPos.z), linZ(samplePos)); + float calcthreshold = abs(linearZ.x - linearZ.y) / linearZ.x; + + bool depthThreshold1 = calcthreshold < 0.015; + bool depthThreshold2 = calcthreshold < 0.05; + + // if (depthThreshold1) Shadow = inshadowmap ? shadowGradient : 0.0; + if (depthThreshold1) Shadow = 0.0; + + if (depthThreshold2) SSS = shadowGradient; + + } + } +} + +// void SSRT_SkySSS(vec3 viewPos, vec3 lightDir, float noise, inout float SSS, bool isgrass){ +// float steps = 16; +// vec3 clipPosition = toClipSpace3(viewPos); + +// //prevents the ray from going behind the camera +// float rayLength = ((viewPos.z + lightDir.z * far*sqrt(3.)) > -near) ? +// (-near -viewPos.z) / lightDir.z : far*sqrt(3.); + +// vec3 direction = toClipSpace3(viewPos + lightDir*rayLength) - clipPosition; //convert to clip space +// direction.xyz = direction.xyz / max(abs(direction.x)/texelSize.x, abs(direction.y)/texelSize.y); //fixed step size + +// float dist = 1.0 + clamp(viewPos.z*viewPos.z/50.0,0,1); // shrink sample size as distance increases +// vec3 rayDir = direction / dist; + +// vec3 screenPos = clipPosition + rayDir*noise; + +// float dist3 = clamp(1-exp( viewPos.z*viewPos.z / -50),0,1); + + +// float depththing = isgrass ? 1 : 0.05; + +// for (int i = 0; i < int(steps); i++) { +// screenPos += rayDir*3; + +// float shadowgradient = clamp(i/steps,0.0,1.0); + +// float samplePos = texture2D(depthtex1, screenPos.xy).x; + +// if(samplePos <= screenPos.z) { +// vec2 linearZ = vec2(linZ(screenPos.z), linZ(samplePos)); +// float calcthreshold = abs(linearZ.x - linearZ.y) / linearZ.x; + +// bool depthThreshold = calcthreshold < depththing; + + +// if(depthThreshold) SSS = shadowgradient; +// } +// } +// } +#ifdef END_SHADER + float GetShading( vec3 WorldPos, vec3 LightPos, vec3 Normal){ + + float NdotL = clamp(dot(Normal, normalize(-LightPos)),0.0,1.0); + float FogShadow = GetCloudShadow(WorldPos, LightPos); + + return EndLightMie(LightPos) * NdotL * FogShadow; + } +#endif + +float CustomPhase(float LightPos, float S_1, float S_2){ + float SCALE = S_2 + 0.001; // remember the epislons 0.001 is fine. + float N = S_1; + float N2 = N / SCALE; + + float R = 1; + float A = pow(1.0 - pow(max(R-LightPos,0.0), N2 ),N); + + return A; +} + +vec3 SubsurfaceScattering_sun(vec3 albedo, float Scattering, float Density, float lightPos, bool inShadowmapBounds){ + + float labcurve = pow(Density,LabSSS_Curve); + // float density = sqrt(30 - labcurve*15); + float density = 15 - labcurve*10; + + vec3 absorbed = max(1.0 - albedo,0.0); + + vec3 scatter = vec3(0.0); + // if(inShadowmapBounds) { + scatter = exp(absorbed * Scattering * -5) * exp(Scattering * -density); + // }else{ + // scatter = exp(absorbed * Scattering * -10) * exp(Scattering * -max(density,5)); + // } + // vec3 scatter = vec3(1)* exp(Scattering * -density); + + scatter *= labcurve; + scatter *= 0.5 + CustomPhase(lightPos, 1.0,30.0)*20; + + return scatter; + +} +vec3 SubsurfaceScattering_sky(vec3 albedo, float Scattering, float Density){ + + vec3 absorbed = max(luma(albedo) - albedo,0.0); + // vec3 scatter = sqrt(exp(-(absorbed * Scattering * 15))) * (1.0 - Scattering); + vec3 scatter = exp(-5 * Scattering)*vec3(1); + + // scatter *= pow(Density,LabSSS_Curve); + scatter *= clamp(1 - exp(Density * -10),0,1); + + return scatter ; +} +// #ifdef IS_IRIS +// uniform vec4 lightningBoltPosition; +// float Iris_Lightningflash(vec3 feetPlayerPos, vec3 lightningBoltPos, vec3 WorldSpace_normal, inout float Phase){ + +// vec3 LightningPos = feetPlayerPos - vec3(lightningBoltPosition.x, clamp(feetPlayerPos.y, lightningBoltPosition.y+16, lightningBoltPosition.y+116.0),lightningBoltPosition.z); + +// // point light, max distance is ~500 blocks (the maximim entity render distance) +// float lightDistance = 300.0 ; +// float lightningLight = max(1.0 - length(LightningPos) / lightDistance, 0.0); + +// // the light above ^^^ is a linear curve. me no likey. here's an exponential one instead. +// lightningLight = exp((1.0 - lightningLight) * -10.0); + +// // a phase for subsurface scattering. +// vec3 PhasePos = normalize(feetPlayerPos) + vec3(lightningBoltPosition.x, lightningBoltPosition.y + 60, lightningBoltPosition.z); +// float PhaseOrigin = 1.0 - clamp(dot(normalize(feetPlayerPos), normalize(PhasePos)),0.0,1.0); +// Phase = exp(sqrt(PhaseOrigin) * -2.0) * 5.0 * lightningLight; + +// // good old NdotL. only normals facing towards the lightning bolt origin rise to 1.0 +// float NdotL = clamp(dot(LightningPos, -WorldSpace_normal), 0.0, 1.0); + +// return lightningLight * NdotL; +// } +// #endif + + +#include "/lib/indirect_lighting_effects.glsl" +#include "/lib/PhotonGTAO.glsl" + void main() { -/* DRAWBUFFERS:0 */ - vec2 tc = floor(gl_FragCoord.xy)/VL_RENDER_RESOLUTION*texelSize+0.5*texelSize; - float z = texture2D(depthtex0,tc).x; - vec3 fragpos = toScreenSpace(vec3(tc,z)); + vec2 texcoord = gl_FragCoord.xy*texelSize; - if (isEyeInWater == 0){ - - vec4 VolumetricFog = GetVolumetricFog(fragpos, blueNoise(), interleaved_gradientNoise()); - - gl_FragData[0] = clamp(VolumetricFog, 0.000001, 65000.0); - } + ////// --------------- SETUP COORDINATE SPACES --------------- ////// - if (isEyeInWater == 1){ + float z0 = texture2D(depthtex0,texcoord).x; + float z = texture2D(depthtex1,texcoord).x; + + vec2 tempOffset = TAA_Offset; + float noise = blueNoise(); + + vec3 viewPos = toScreenSpace(vec3(texcoord/RENDER_SCALE - TAA_Offset*texelSize*0.5,z)); + vec3 feetPlayerPos = mat3(gbufferModelViewInverse) * viewPos; + vec3 feetPlayerPos_normalized = normVec(feetPlayerPos); + vec3 viewPos_handfix = viewPos; + + if ( z < 0.56) viewPos_handfix.z /= MC_HAND_DEPTH; // fix lighting on hand + + ////// --------------- UNPACK OPAQUE GBUFFERS --------------- ////// + + vec4 data = texture2D(colortex1,texcoord); + vec4 dataUnpacked0 = vec4(decodeVec2(data.x),decodeVec2(data.y)); // albedo, masks + vec4 dataUnpacked1 = vec4(decodeVec2(data.z),decodeVec2(data.w)); // normals, lightmaps + // vec4 dataUnpacked2 = vec4(decodeVec2(data.z),decodeVec2(data.w)); + + vec3 albedo = toLinear(vec3(dataUnpacked0.xz,dataUnpacked1.x)); + vec3 normal = decode(dataUnpacked0.yw); + vec2 lightmap = dataUnpacked1.yz; + + #ifndef OVERWORLD_SHADER + lightmap.y = 1.0; + #endif + + ////// --------------- UNPACK MISC --------------- ////// + + vec4 SpecularTex = texture2D(colortex8,texcoord); + float LabSSS = clamp((-65.0 + SpecularTex.z * 255.0) / 190.0 ,0.0,1.0); + + vec4 normalAndAO = texture2D(colortex15,texcoord); + vec3 FlatNormals = normalAndAO.rgb * 2.0 - 1.0; + vec3 slopednormal = normal; + + #ifdef POM + #ifdef Horrible_slope_normals + vec3 ApproximatedFlatNormal = normalize(cross(dFdx(feetPlayerPos), dFdy(feetPlayerPos))); // it uses depth that has POM written to it. + slopednormal = normalize(clamp(normal, ApproximatedFlatNormal*2.0 - 1.0, ApproximatedFlatNormal*2.0 + 1.0) ); + #endif + #endif + + float vanilla_AO = clamp(normalAndAO.a,0,1); + normalAndAO.a = clamp(pow(normalAndAO.a*5,4),0,1); + + ////// --------------- MASKS/BOOLEANS --------------- ////// + + bool iswater = texture2D(colortex7,texcoord).a > 0.99; + bool lightningBolt = abs(dataUnpacked1.w-0.5) <0.01; + bool isLeaf = abs(dataUnpacked1.w-0.55) <0.01; + bool entities = abs(dataUnpacked1.w-0.45) < 0.01; + // bool isBoss = abs(dataUnpacked1.w-0.60) < 0.01; + bool isGrass = abs(dataUnpacked1.w-0.60) < 0.01; + bool hand = abs(dataUnpacked1.w-0.75) < 0.01; + // bool blocklights = abs(dataUnpacked1.w-0.8) <0.01; + + + ////// --------------- COLORS --------------- ////// float dirtAmount = Dirt_Amount; vec3 waterEpsilon = vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B); @@ -119,12 +668,438 @@ void main() { vec3 totEpsilon = dirtEpsilon*dirtAmount + waterEpsilon; vec3 scatterCoef = dirtAmount * vec3(Dirt_Scatter_R, Dirt_Scatter_G, Dirt_Scatter_B) / 3.14; - vec3 fragpos0 = toScreenSpace(vec3(texcoord - TAA_Offset*texelSize*0.5,z)); + vec3 Indirect_lighting = vec3(1.0); + vec3 AmbientLightColor = vec3(0.0); + vec3 Indirect_SSS = vec3(0.0); - vec3 ambientColVol = max(vec3(1.0,0.5,1.0) * 0.6, vec3(0.2,0.4,1.0) * MIN_LIGHT_AMOUNT*0.01); + vec3 ambientCoefs = slopednormal/dot(abs(slopednormal),vec3(1.)); + + vec3 Direct_lighting = vec3(0.0); + vec3 DirectLightColor = vec3(0.0); + vec3 Direct_SSS = vec3(0.0); + float cloudShadow = 1.0; + float Shadows = 1.0; + float NdotL = 1.0; - gl_FragData[0].a = 1; - waterVolumetrics(gl_FragData[0].rgb, fragpos0, fragpos, 1 , 1, 1, blueNoise(), totEpsilon, scatterCoef, ambientColVol); + #ifdef OVERWORLD_SHADER + #ifndef ambientLight_only + DirectLightColor = lightCol.rgb/80.0; + #endif + AmbientLightColor = averageSkyCol_Clouds; + vec3 filteredShadow = vec3(1.412,1.0,0.0); + if (!hand) filteredShadow = texture2D(colortex3,texcoord).rgb; + float ShadowBlockerDepth = filteredShadow.y; + Shadows = clamp(1.0 - filteredShadow.b,0.0,1.0); + bool inShadowmapBounds = false; + #endif + ///////////////////////////// start drawin :D + + if (z >= 1.0) { + + #ifdef OVERWORLD_SHADER + vec3 Background = vec3(0.0); + vec3 Sky = skyFromTex(feetPlayerPos_normalized, colortex4)/30.0; + vec4 Clouds = texture2D_bicubic(colortex0, texcoord*CLOUDS_QUALITY); + + vec3 orbitstar = vec3(feetPlayerPos_normalized.x,abs(feetPlayerPos_normalized.y),feetPlayerPos_normalized.z); orbitstar.x -= WsunVec.x*0.2; + Background += stars(orbitstar) * 10.0; + + #ifndef ambientLight_only + Background += drawSun(dot(lightCol.a * WsunVec, feetPlayerPos_normalized),0, DirectLightColor,vec3(0.0)); + Background += drawMoon(feetPlayerPos_normalized, lightCol.a * WsunVec, DirectLightColor*20, Background); + #endif + + Background *= clamp( (feetPlayerPos_normalized.y+ 0.02)*5.0 + (eyeAltitude - 319)/800000 ,0.0,1.0); + + Background += Sky; + Background = Background * Clouds.a + Clouds.rgb; + + gl_FragData[0].rgb = clamp(fp10Dither(Background, triangularize(noise)), 0.0, 65000.); + #endif + #ifdef NETHER_SHADER + gl_FragData[0].rgb = vec3(0); + #endif + #ifdef END_SHADER + gl_FragData[0].rgb = vec3(0); + #endif + } else { + + feetPlayerPos += gbufferModelViewInverse[3].xyz; + + //////////////////////////////////////////////////////////////////////////////////// + ///////////////////////////// MAJOR LIGHTSOURCE STUFF //////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + + #ifdef OVERWORLD_SHADER + float LightningPhase = 0.0; + vec3 LightningFlashLighting = Iris_Lightningflash(feetPlayerPos, lightningBoltPosition.xyz, slopednormal, LightningPhase) * pow(lightmap.y,10); + #endif + + #ifdef OVERWORLD_SHADER + + NdotL = clamp((-15 + dot(slopednormal, WsunVec)*255.0) / 240.0 ,0.0,1.0); + + float shadowNDOTL = NdotL; + #ifndef Variable_Penumbra_Shadows + shadowNDOTL += LabSSS; + #endif + + vec3 feetPlayerPos_shadow = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz; + + if(!hand) GriAndEminShadowFix(feetPlayerPos_shadow, viewToWorld(FlatNormals), vanilla_AO, lightmap.y, entities); + + vec3 projectedShadowPosition = mat3(shadowModelView) * feetPlayerPos_shadow + shadowModelView[3].xyz; + projectedShadowPosition = diagonal3(shadowProjection) * projectedShadowPosition + shadowProjection[3].xyz; + + //apply distortion + float distortFactor = calcDistort(projectedShadowPosition.xy); + projectedShadowPosition.xy *= distortFactor; + + + bool ShadowBounds = false; + if(shadowDistanceRenderMul > 0.0) ShadowBounds = length(feetPlayerPos_shadow) < max(shadowDistance - 20,0.0); + + if(shadowDistanceRenderMul < 0.0) ShadowBounds = abs(projectedShadowPosition.x) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.y) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.z) < 6.0; + + //do shadows only if on shadow map + if(ShadowBounds){ + if (shadowNDOTL >= -0.001){ + Shadows = 0.0; + int samples = SHADOW_FILTER_SAMPLE_COUNT; + float smallbias = 0; + + if(hand){ + samples = 1; + smallbias = -0.0005; + noise = 0.5; + } + + projectedShadowPosition = projectedShadowPosition * vec3(0.5,0.5,0.5/6.0) + vec3(0.5); + + #ifdef BASIC_SHADOW_FILTER + float rdMul = filteredShadow.x*distortFactor*d0*k/shadowMapResolution; + + for(int i = 0; i < samples; i++){ + vec2 offsetS = tapLocation(i,samples,1.618, noise,0.0); + + float isShadow = shadow2D(shadow, projectedShadowPosition + vec3(rdMul*offsetS, smallbias) ).x; + Shadows += isShadow/samples; + } + #else + Shadows = shadow2D(shadow, projectedShadowPosition + vec3(0.0,0.0, smallbias)).x; + #endif + } + inShadowmapBounds = true; + } + + float lightmapAsShadows = 1.0 ; + if(!inShadowmapBounds && !iswater){ + lightmapAsShadows = min(max(lightmap.y-0.8, 0.0) * 25,1.0); + + Shadows = lightmapAsShadows; + } + // if(!inShadowmapBounds) Shadows = 1.0; + + + + //////////////////////////////////////////////////////////////////////////////// + //////////////////////////////// SUN SSS //////////////////////////////// + //////////////////////////////////////////////////////////////////////////////// + + #if SSS_TYPE != 0 + #ifndef Variable_Penumbra_Shadows + if(LabSSS > 0 ) { + ShadowBlockerDepth = pow(1.0 - Shadows,2); + } + #endif + + if (!inShadowmapBounds) ShadowBlockerDepth = 0.0; + + float sunSSS_density = LabSSS; + + #ifndef RENDER_ENTITY_SHADOWS + if(entities) sunSSS_density = 0.0; + #endif + + if (!hand){ + #ifdef SCREENSPACE_CONTACT_SHADOWS + + float SS_shadow = 1.0; float SS_shadowSSS = 0.0; + SSRT_Shadows(toScreenSpace(vec3(texcoord/RENDER_SCALE, z)), normalize(WsunVec*mat3(gbufferModelViewInverse)), interleaved_gradientNoise(), !inShadowmapBounds && LabSSS > 0.0, inShadowmapBounds, SS_shadow, SS_shadowSSS); + + Shadows = min(Shadows, SS_shadow); + + // if (!inShadowmapBounds) Direct_SSS *= exp(-5 * SS_shadowSSS) * lightmapAsShadows; + if (!inShadowmapBounds) ShadowBlockerDepth = max(ShadowBlockerDepth, SS_shadowSSS); + #else + + if (!inShadowmapBounds) Direct_SSS = vec3(0.0); + + #endif + + Direct_SSS = SubsurfaceScattering_sun(albedo, ShadowBlockerDepth, sunSSS_density, clamp(dot(feetPlayerPos_normalized, WsunVec),0.0,1.0), inShadowmapBounds) ; + } + + if (isEyeInWater == 0) Direct_SSS *= clamp(pow(eyeBrightnessSmooth.y/240. + lightmap.y,2.0) ,0.0,1.0); // light leak fix + if (!inShadowmapBounds) Direct_SSS *= lightmapAsShadows; + #endif + + + + // #if SSS_TYPE != 0 + // Direct_SSS *= 1.0-clamp(NdotL*Shadows,0,1); + // #endif + + #ifdef CLOUDS_SHADOWS + cloudShadow = GetCloudShadow(feetPlayerPos); + Shadows *= cloudShadow; + Direct_SSS *= cloudShadow; + #endif + + #endif + + + + #ifdef END_SHADER + vec3 LightPos1 = vec3(0); vec3 LightPos2 = vec3(0); + LightSourcePosition(feetPlayerPos+cameraPosition, cameraPosition, LightPos1, LightPos2); + + vec3 LightCol1 = vec3(0); vec3 LightCol2 = vec3(0); + LightSourceColors(LightCol1, LightCol2); + // LightCol1 *= Flashing; + LightCol2 *= Flashing; + + Direct_lighting += LightCol1 * GetShading(feetPlayerPos+cameraPosition, LightPos1, slopednormal) ; + + #if lightsourceCount == 2 + Direct_lighting += LightCol2 * GetShading(feetPlayerPos+cameraPosition, LightPos2, slopednormal); + #endif + + // float RT_Shadows = rayTraceShadow(worldToView(normalize(-LightPos)), viewPos, noise); + // if(!hand) Direct_lighting *= RT_Shadows*RT_Shadows; + #endif + + ///////////////////////////////////////////////////////////////////////////////// + ///////////////////////////// INDIRECT LIGHTING ///////////////////////////// + ///////////////////////////////////////////////////////////////////////////////// + + #ifdef OVERWORLD_SHADER + + vec3 ambientcoefs = slopednormal / dot(abs(slopednormal), vec3(1)); + + float SkylightDir = ambientcoefs.y*1.5; + if(isGrass) SkylightDir = 1.25; + + float skylight = max(pow(viewToWorld(FlatNormals).y*0.5+0.5,0.1) + SkylightDir, 0.25) ; + + // #if indirect_effect == 2 + // skylight = 1.0; + // #endif + + #if indirect_effect != 3 || indirect_effect != 4 + Indirect_lighting = DoAmbientLighting(AmbientLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.xy, skylight); + #endif + + Indirect_lighting += LightningFlashLighting; + #endif + + #ifdef NETHER_SHADER + AmbientLightColor = skyCloudsFromTexLOD2(normal, colortex4, 6).rgb / 10; + + vec3 up = skyCloudsFromTexLOD2(vec3( 0, 1, 0), colortex4, 6).rgb / 10; + vec3 down = skyCloudsFromTexLOD2(vec3( 0,-1, 0), colortex4, 6).rgb / 10; + + up *= pow( max( slopednormal.y, 0), 2); + down *= pow( max(-slopednormal.y, 0), 2); + AmbientLightColor += up + down; + + Indirect_lighting = DoAmbientLighting_Nether(AmbientLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, normal, feetPlayerPos_normalized, feetPlayerPos ); + #endif + + #ifdef END_SHADER + Indirect_lighting = DoAmbientLighting_End(gl_Fog.color.rgb, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.x, normal, feetPlayerPos_normalized); + #endif + + + //////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////// UNDER WATER SHADING //////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////// + #ifdef OVERWORLD_SHADER + if ((isEyeInWater == 0 && iswater) || (isEyeInWater == 1 && !iswater)){ + + vec3 viewPos0 = toScreenSpace(vec3(texcoord/RENDER_SCALE-TAA_Offset*texelSize*0.5,z0)); + float Vdiff = distance(viewPos, viewPos0); + float VdotU = feetPlayerPos_normalized.y; + float estimatedDepth = Vdiff * abs(VdotU); //assuming water plane + estimatedDepth = estimatedDepth; + // make it such that the estimated depth flips to be correct when entering water. + + if (isEyeInWater == 1) estimatedDepth = (1.0-lightmap.y)*16.0; + + float estimatedSunDepth = Vdiff; //assuming water plane + vec3 Absorbtion = exp2(-totEpsilon*estimatedDepth); + + // caustics... + float Direct_caustics = waterCaustics(feetPlayerPos + cameraPosition, WsunVec) * cloudShadow; + // float Ambient_Caustics = waterCaustics(p3 + cameraPosition, vec3(0.5, 1, 0.5)); + + // apply caustics to the lighting + DirectLightColor *= 1.0 + max(pow(Direct_caustics * 3.0, 2.0),0.0); + // Indirect_lighting *= 0.5 + max(pow(Ambient_Caustics, 2.0),0.0); + + DirectLightColor *= Absorbtion; + if(isEyeInWater == 1 ) Indirect_lighting = (Indirect_lighting/exp2(-estimatedDepth*0.5)) * Absorbtion; + + if(isEyeInWater == 0) DirectLightColor *= max(eyeBrightnessSmooth.y/240., 0.0); + DirectLightColor *= cloudShadow; + } + #endif + ///////////////////////////////////////////////////////////////////////////////////// + ///////////////////////////// EFFECTS FOR INDIRECT ///////////////////////////// + ///////////////////////////////////////////////////////////////////////////////////// + + + float SkySSS = 0.0; + + #if indirect_effect == 0 + vec3 AO = vec3( exp( (vanilla_AO*vanilla_AO) * -5) ) ; + Indirect_lighting *= AO; + #endif + + #if indirect_effect == 1 + vec3 AO = vec3( exp( (vanilla_AO*vanilla_AO) * -3) ) ; + // vec3 AO = vec3( exp( (vanilla_AO*vanilla_AO) * -5) ) ; + // if(!hand) Indirect_lighting *= ssao(viewPos,noise,FlatNormals) * AO; + + + // if (!hand) ssAO(AO, SkySSS, viewPos, 1.0, blueNoise(gl_FragCoord.xy).rg, FlatNormals , texcoord, ambientCoefs, lightmap.xy, isLeaf); + + vec2 SSAO_SSS = SSAO(viewPos, FlatNormals, hand, isLeaf); + AO *= exp((1.0-SSAO_SSS.x) * -5.0); + SkySSS = SSAO_SSS.y; + + // SampleSSAO(AO, SkySSS, texcoord); + Indirect_lighting *= AO; + + #endif + // GTAO + #if indirect_effect == 2 + vec3 AO = vec3( exp( (vanilla_AO*vanilla_AO) * -3) ); + + vec2 r2 = fract(R2_samples(frameCounter%40000) + blueNoise(gl_FragCoord.xy).rg); + if (!hand) AO = ambient_occlusion(vec3(texcoord/RENDER_SCALE-TAA_Offset*texelSize*0.5,z), viewPos, worldToView(slopednormal), r2) * vec3(1.0); + + Indirect_lighting *= AO; + #endif + + // RTAO and/or SSGI + #if indirect_effect == 3 || indirect_effect == 4 + if (!hand) ApplySSRT(Indirect_lighting, normal, blueNoise(gl_FragCoord.xy).rg, viewPos, lightmap.xy, AmbientLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), isGrass); + #endif + + #ifdef SSS_view + // albedo = vec3(1); + Indirect_lighting = vec3(0.5); + #endif + + //////////////////////////////// SKY SSS //////////////////////////////// + #ifdef Ambient_SSS + if (!hand){ + + vec3 SSS_forSky = vec3(0.0); + + #if indirect_effect != 1 + SkySSS = ScreenSpace_SSS(viewPos, FlatNormals, hand, isLeaf); + #endif + + vec3 ambientColor = (AmbientLightColor / 30.0 ) * 1.5; + float skylightmap = pow(lightmap.y,3); + float uplimit = clamp(1.0-pow(clamp(ambientCoefs.y + 0.5,0.0,1.0),2),0,1); + + SSS_forSky = SubsurfaceScattering_sky(albedo, SkySSS, LabSSS); + SSS_forSky *= ambientColor; + SSS_forSky *= skylightmap; + // SSS_forSky *= uplimit; + + // Combine with the other SSS + Indirect_SSS += SSS_forSky; + + SSS_forSky = vec3((1.0 - SkySSS) * LabSSS); + SSS_forSky *= ambientColor; + SSS_forSky *= skylightmap; + + ////light up dark parts so its more visible + Indirect_lighting = max(Indirect_lighting, SSS_forSky); + Indirect_lighting += Indirect_SSS; + + #ifdef OVERWORLD_SHADER + if(LabSSS > 0.0) Indirect_lighting += (1.0-SkySSS) * LightningPhase * lightningEffect * pow(lightmap.y,10); + #endif + + } + #endif + + ///////////////////////////////////////////////////////////////////////// + ///////////////////////////// FINALIZE ///////////////////////////// + ///////////////////////////////////////////////////////////////////////// + #ifdef SSS_view + albedo = vec3(1); + #endif + + #ifdef OVERWORLD_SHADER + Direct_lighting = DoDirectLighting(DirectLightColor, Shadows, NdotL, 0.0); + Direct_lighting += Direct_SSS * DirectLightColor; // do this here so it gets underwater absorbtion. + #endif + + gl_FragData[0].rgb = (Indirect_lighting + Direct_lighting) * albedo; + + #ifdef Specular_Reflections + vec3 specNoise = vec3(blueNoise(gl_FragCoord.xy).rg, interleaved_gradientNoise()); + DoSpecularReflections(gl_FragData[0].rgb, viewPos, feetPlayerPos_normalized, WsunVec, specNoise, normal, SpecularTex.r, SpecularTex.g, albedo, DirectLightColor*Shadows*NdotL, lightmap.y, hand); + #endif + + Emission(gl_FragData[0].rgb, albedo, SpecularTex.a); + + if(lightningBolt) gl_FragData[0].rgb = vec3(77.0, 153.0, 255.0); } + + #ifdef OVERWORLD_SHADER + if (iswater && isEyeInWater == 0){ + vec3 viewPos0 = toScreenSpace(vec3(texcoord/RENDER_SCALE-TAA_Offset*texelSize*0.5,z0)); + float Vdiff = distance(viewPos,viewPos0); + float VdotU = feetPlayerPos_normalized.y; + float estimatedDepth = Vdiff * abs(VdotU) ; //assuming water plane + float estimatedSunDepth = estimatedDepth/abs(WsunVec.y); //assuming water plane + + float custom_lightmap_T = clamp(pow(texture2D(colortex14, texcoord).a,3.0),0.0,1.0); + + vec3 lightColVol = lightCol.rgb / 80.; + // if(shadowmapindicator < 1) lightColVol *= clamp((custom_lightmap_T-0.8) * 15,0,1) + + vec3 lightningColor = (lightningEffect / 3) * (max(eyeBrightnessSmooth.y,0)/240.); + vec3 ambientColVol = max((averageSkyCol_Clouds / 30.0) * custom_lightmap_T, vec3(0.2,0.4,1.0) * (MIN_LIGHT_AMOUNT*0.01 + nightVision)) ; + + waterVolumetrics(gl_FragData[0].rgb, viewPos0, viewPos, estimatedDepth , estimatedSunDepth, Vdiff, noise, totEpsilon, scatterCoef, ambientColVol, lightColVol, dot(feetPlayerPos_normalized, WsunVec)); + } + #else + if (iswater && isEyeInWater == 0){ + vec3 viewPos0 = toScreenSpace(vec3(texcoord/RENDER_SCALE-TAA_Offset*texelSize*0.5,z0)); + float Vdiff = distance(viewPos,viewPos0); + float VdotU = feetPlayerPos_normalized.y; + float estimatedDepth = Vdiff * abs(VdotU) ; //assuming water plane + + vec3 ambientColVol = max(vec3(1.0,0.5,1.0) * 0.3, vec3(0.2,0.4,1.0) * (MIN_LIGHT_AMOUNT*0.01 + nightVision)); + + waterVolumetrics_notoverworld(gl_FragData[0].rgb, viewPos0, viewPos, estimatedDepth , estimatedDepth, Vdiff, noise, totEpsilon, scatterCoef, ambientColVol); + } + #endif + // vec3 testPos = feetPlayerPos_normalized + vec3(lightningBoltPosition.x, clamp(feetPlayerPos.y, lightningBoltPosition.y, lightningBoltPosition.y+150.0),lightningBoltPosition.z); + // // vec3 testPos = feetPlayerPos_normalized + vec3(lightningBoltPosition.x, lightningBoltPosition.y + 60,lightningBoltPosition.z); + + // float phaseorigin = 1.0 - clamp(dot(feetPlayerPos_normalized, normalize(testPos) ),0.0,1.0); + + // gl_FragData[0].rgb += lightningEffect * exp(sqrt(phaseorigin) * -10); + +/* DRAWBUFFERS:3 */ } diff --git a/shaders/dimensions/composite1.vsh b/shaders/dimensions/composite1.vsh index a3d9f54..bc514db 100644 --- a/shaders/dimensions/composite1.vsh +++ b/shaders/dimensions/composite1.vsh @@ -1,20 +1,57 @@ -#include "/lib/util.glsl" +#include "/lib/settings.glsl" +#include "/lib/res_params.glsl" -flat varying float tempOffsets; +flat varying float Flashing; +flat varying vec3 WsunVec; +flat varying vec3 averageSkyCol_Clouds; +flat varying vec4 lightCol; + +flat varying vec2 TAA_Offset; +flat varying vec3 zMults; +uniform sampler2D colortex4; + +// uniform float far; +uniform float near; +uniform mat4 gbufferModelViewInverse; +uniform vec3 sunPosition; +uniform float rainStrength; +uniform float sunElevation; uniform int frameCounter; +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.); -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// + +#include "/lib/util.glsl" +#include "/lib/Shadow_Params.glsl" void main() { gl_Position = ftransform(); - tempOffsets = HaltonSeq2(frameCounter%10000); - - gl_Position.xy = (gl_Position.xy*0.5+0.5)*0.51*2.0-1.0; + Flashing = texelFetch2D(colortex4,ivec2(1,1),0).x/150.0; + + zMults = vec3((far * near)*2.0,far+near,far-near); + + lightCol.rgb = texelFetch2D(colortex4,ivec2(6,37),0).rgb; + lightCol.a = float(sunElevation > 1e-5)*2.0 - 1.0; + + averageSkyCol_Clouds = texelFetch2D(colortex4,ivec2(0,37),0).rgb; + + WsunVec = lightCol.a*normalize(mat3(gbufferModelViewInverse) * sunPosition); + // WsunVec = normalize(LightDir); + + + TAA_Offset = offsets[framemod8]; + + #ifdef TAA_UPSCALING + gl_Position.xy = (gl_Position.xy*0.5+0.5)*RENDER_SCALE*2.0-1.0; + #endif } diff --git a/shaders/composite10.fsh b/shaders/dimensions/composite10.fsh similarity index 92% rename from shaders/composite10.fsh rename to shaders/dimensions/composite10.fsh index dcf701b..f81059a 100644 --- a/shaders/composite10.fsh +++ b/shaders/dimensions/composite10.fsh @@ -1,8 +1,3 @@ -#version 120 - -#include "/lib/settings.glsl" -//Merge and upsample the blurs into a 1/4 res bloom buffer -#include "/lib/res_params.glsl" uniform sampler2D colortex3; uniform sampler2D colortex6; @@ -83,9 +78,8 @@ vec4 texture2D_bicubic(sampler2D tex, vec2 uv) void main() { /* DRAWBUFFERS:3 */ -vec2 resScale = vec2(1920.,1080.)/(max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.))/BLOOM_QUALITY); +vec2 resScale = vec2(1920.,1080.)/max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.)); vec2 texcoord = ((gl_FragCoord.xy)*2.+0.5)*texelSize; - vec3 bloom = texture2D_bicubic(colortex3,texcoord/2.0).rgb; //1/4 res bloom += texture2D_bicubic(colortex6,texcoord/4.).rgb; //1/8 res diff --git a/shaders/composite7.vsh b/shaders/dimensions/composite10.vsh similarity index 79% rename from shaders/composite7.vsh rename to shaders/dimensions/composite10.vsh index 74659ca..7a54acb 100644 --- a/shaders/composite7.vsh +++ b/shaders/dimensions/composite10.vsh @@ -1,6 +1,3 @@ -#version 120 -#include "/lib/settings.glsl" -#include "/lib/res_params.glsl" uniform float viewWidth; uniform float viewHeight; //////////////////////////////VOID MAIN////////////////////////////// @@ -14,5 +11,5 @@ void main() { vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.)); gl_Position = ftransform(); //*0.51 to avoid errors when sampling outside since clearing is disabled - gl_Position.xy = (gl_Position.xy*0.5+0.5)*0.26*BLOOM_QUALITY/clampedRes*vec2(1920.0,1080.)*2-1.0; + gl_Position.xy = (gl_Position.xy*0.5+0.5)*0.51/clampedRes*vec2(1920.0,1080.)*2.0-1.0; } diff --git a/shaders/composite11.fsh b/shaders/dimensions/composite11.fsh similarity index 96% rename from shaders/composite11.fsh rename to shaders/dimensions/composite11.fsh index 37e6541..3ec1714 100644 --- a/shaders/composite11.fsh +++ b/shaders/dimensions/composite11.fsh @@ -1,7 +1,3 @@ -#version 120 -//Vignetting, applies bloom, applies exposure and tonemaps the final image -//#extension GL_EXT_gpu_shader4 : disable - #include "/lib/settings.glsl" #include "/lib/res_params.glsl" @@ -106,7 +102,7 @@ void main() { // vec3 bloom = (texture2D(colortex3,texcoord/clampedRes*vec2(1920.,1080.)*0.5*BLOOM_QUALITY).rgb)/2./7.0; - vec3 bloom = texture2D(colortex3, texcoord/clampedRes*vec2(1920.,1080.)*0.5*BLOOM_QUALITY).rgb / 2.0 / 7.0; + vec3 bloom = texture2D(colortex3, texcoord/clampedRes*vec2(1920.,1080.)*BLOOM_QUALITY).rgb / 2.0 / 7.0; float lightScat = clamp(BLOOM_STRENGTH * 0.05 * pow(exposure.a, 0.2) ,0.0,1.0)*vignette; diff --git a/shaders/final.vsh b/shaders/dimensions/composite11.vsh similarity index 88% rename from shaders/final.vsh rename to shaders/dimensions/composite11.vsh index 822a7b0..e77b7c4 100644 --- a/shaders/final.vsh +++ b/shaders/dimensions/composite11.vsh @@ -1,9 +1,8 @@ -#version 120 -//#extension GL_EXT_gpu_shader4 : disable #include "/lib/settings.glsl" varying vec2 texcoord; flat varying vec4 exposure; +flat varying float rodExposure; uniform sampler2D colortex4; //////////////////////////////VOID MAIN////////////////////////////// @@ -17,4 +16,5 @@ void main() { gl_Position = ftransform(); texcoord = gl_MultiTexCoord0.xy; exposure=vec4(texelFetch2D(colortex4,ivec2(10,37),0).r*vec3(FinalR,FinalG,FinalB),texelFetch2D(colortex4,ivec2(10,37),0).r); + rodExposure = texelFetch2D(colortex4,ivec2(14,37),0).r; } diff --git a/shaders/dimensions/composite2.fsh b/shaders/dimensions/composite2.fsh index 251d0f7..66ff7dc 100644 --- a/shaders/dimensions/composite2.fsh +++ b/shaders/dimensions/composite2.fsh @@ -1,305 +1,278 @@ #include "/lib/settings.glsl" -flat varying vec3 zMults; -flat varying vec2 TAA_Offset; - +flat varying vec4 lightCol; +flat varying vec3 averageSkyCol; +// flat varying vec3 averageSkyCol_Clouds; uniform sampler2D noisetex; uniform sampler2D depthtex0; -uniform sampler2D depthtex1; -uniform sampler2D colortex0; -uniform sampler2D colortex1; + uniform sampler2D colortex2; uniform sampler2D colortex3; // uniform sampler2D colortex4; -uniform sampler2D colortex5; -uniform sampler2D colortex6; -uniform sampler2D colortex7; -uniform sampler2D colortex8; -uniform sampler2D colortex9; -uniform sampler2D colortex11; -uniform sampler2D colortex13; -uniform sampler2D colortex15; -uniform vec2 texelSize; -flat varying vec3 noooormal; -flat varying vec4 lightCol; //main light source color (rgb),used light source(1=sun,-1=moon) flat varying vec3 WsunVec; - uniform vec3 sunVec; -uniform float frameTimeCounter; +uniform float sunElevation; +// uniform float far; + uniform int frameCounter; -uniform float far; -uniform float near; -uniform mat4 gbufferModelViewInverse; -uniform mat4 gbufferModelView; -uniform mat4 gbufferPreviousModelView; -uniform mat4 gbufferProjectionInverse; -uniform mat4 gbufferProjection; -uniform mat4 gbufferPreviousProjection; -uniform vec3 cameraPosition; -uniform vec3 previousCameraPosition; +uniform float frameTimeCounter; + +varying vec2 texcoord; +uniform vec2 texelSize; +flat varying vec2 TAA_Offset; uniform int isEyeInWater; -uniform ivec2 eyeBrightnessSmooth; uniform float rainStrength; -uniform float blindness; -uniform float darknessFactor; -uniform float darknessLightFactor; +uniform ivec2 eyeBrightnessSmooth; - -#include "/lib/waterBump.glsl" +#include "/lib/color_transforms.glsl" +#include "/lib/color_dither.glsl" +#include "/lib/projections.glsl" #include "/lib/res_params.glsl" - #include "/lib/sky_gradient.glsl" -#include "/lib/volumetricClouds.glsl" -// #include "/lib/biome_specifics.glsl" +#include "/lib/Shadow_Params.glsl" +#ifdef OVERWORLD_SHADER + + const bool shadowHardwareFiltering = true; + uniform sampler2DShadow shadow; + flat varying vec3 refractedSunVec; + + #define TIMEOFDAYFOG + #include "/lib/lightning_stuff.glsl" + #include "/lib/volumetricClouds.glsl" + #include "/lib/volumetricFog.glsl" +#endif +#ifdef NETHER_SHADER + uniform sampler2D colortex4; + #include "/lib/nether_fog.glsl" +#endif +#ifdef END_SHADER + uniform sampler2D colortex4; + #include "/lib/end_fog.glsl" +#endif - -#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z) -#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz) - -float ld(float depth) { - return 1.0 / (zMults.y - depth * zMults.z); // (-depth * (far - near)) = (2.0 * near)/ld - far - near -} -float luma(vec3 color) { - return dot(color,vec3(0.21, 0.72, 0.07)); -} -vec3 toLinear(vec3 sRGB){ - return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878); -} -vec3 toScreenSpace(vec3 p) { - vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw); - vec3 p3 = p * 2. - 1.; - vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3]; - return fragposition.xyz / fragposition.w; -} - - -// #include "/lib/specular.glsl" - - - - -vec4 BilateralUpscale(sampler2D tex, sampler2D depth,vec2 coord,float frDepth, vec2 distort){ - coord = coord; - vec4 vl = vec4(0.0); - float sum = 0.0; - mat3x3 weights; - const ivec2 scaling = ivec2(1.0/VL_RENDER_RESOLUTION); - ivec2 posD = ivec2(coord*VL_RENDER_RESOLUTION + distort)*scaling; - ivec2 posVl = ivec2(coord*VL_RENDER_RESOLUTION + distort); - float dz = zMults.x; - ivec2 pos = (ivec2(gl_FragCoord.xy+frameCounter) % 2 )*2; - - ivec2 tcDepth = posD + ivec2(-2,-2) * scaling + pos * scaling; - float dsample = ld(texelFetch2D(depth,tcDepth,0).r); - float w = abs(dsample-frDepth) < dz ? 1.0 : 1e-5; - vl += texelFetch2D(tex,posVl+ivec2(-2)+pos,0)*w; - sum += w; - - tcDepth = posD + ivec2(-2,0) * scaling + pos * scaling; - dsample = ld(texelFetch2D(depth,tcDepth,0).r); - w = abs(dsample-frDepth) < dz ? 1.0 : 1e-5; - vl += texelFetch2D(tex,posVl+ivec2(-2,0)+pos,0)*w; - sum += w; - - tcDepth = posD + ivec2(0) + pos * scaling; - dsample = ld(texelFetch2D(depth,tcDepth,0).r); - w = abs(dsample-frDepth) < dz ? 1.0 : 1e-5; - vl += texelFetch2D(tex,posVl+ivec2(0)+pos,0)*w; - sum += w; - - tcDepth = posD + ivec2(0,-2) * scaling + pos * scaling; - dsample = ld(texelFetch2D(depth,tcDepth,0).r); - w = abs(dsample-frDepth) < dz ? 1.0 : 1e-5; - vl += texelFetch2D(tex,posVl+ivec2(0,-2)+pos,0)*w; - sum += w; - - return vl/sum; -} - -vec3 decode (vec2 encn){ - vec3 n = vec3(0.0); - encn = encn * 2.0 - 1.0; - n.xy = abs(encn); - n.z = 1.0 - n.x - n.y; - n.xy = n.z <= 0.0 ? (1.0 - n.yx) * sign(encn) : encn; - return clamp(normalize(n.xyz),-1.0,1.0); -} -vec2 decodeVec2(float a){ - const vec2 constant1 = 65535. / vec2( 256., 65536.); - const float constant2 = 256. / 255.; - return fract( a * constant1 ) * constant2 ; -} - -vec3 worldToView(vec3 worldPos) { - vec4 pos = vec4(worldPos, 0.0); - pos = gbufferModelView * pos; - return pos.xyz; -} -float blueNoise(){ - return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter); -} -vec4 blueNoise(vec2 coord){ - return texelFetch2D(colortex6, ivec2(coord )%512 , 0); -} -vec3 normVec (vec3 vec){ - return vec*inversesqrt(dot(vec,vec)); -} +#define fsign(a) (clamp((a)*1e35,0.,1.)*2.-1.) float interleaved_gradientNoise(){ - vec2 coord = gl_FragCoord.xy; - float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y)); - return noise; + return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y)+ 1.0/1.6180339887 * frameCounter); } -vec3 viewToWorld(vec3 viewPosition) { - vec4 pos; - pos.xyz = viewPosition; - pos.w = 0.0; - pos = gbufferModelViewInverse * pos; - return pos.xyz; +float blueNoise(){ + return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a+ 1.0/1.6180339887 * frameCounter ); } -/// thanks stackoverflow https://stackoverflow.com/questions/944713/help-with-pixel-shader-effect-for-brightness-and-contrast#3027595 -void applyContrast(inout vec3 color, float contrast){ - color = ((color - 0.5) * max(contrast, 0.0)) + 0.5; +void waterVolumetrics_notoverworld(inout vec3 inColor, vec3 rayStart, vec3 rayEnd, float estEndDepth, float estSunDepth, float rayLength, float dither, vec3 waterCoefs, vec3 scatterCoef, vec3 ambient){ + inColor *= exp(-rayLength * waterCoefs); //No need to take the integrated value + + int spCount = rayMarchSampleCount; + vec3 start = toShadowSpaceProjected(rayStart); + vec3 end = toShadowSpaceProjected(rayEnd); + vec3 dV = (end-start); + //limit ray length at 32 blocks for performance and reducing integration error + //you can't see above this anyway + float maxZ = min(rayLength,12.0)/(1e-8+rayLength); + dV *= maxZ; + + + rayLength *= maxZ; + + float dY = normalize(mat3(gbufferModelViewInverse) * rayEnd).y * rayLength; + estEndDepth *= maxZ; + estSunDepth *= maxZ; + + vec3 wpos = mat3(gbufferModelViewInverse) * rayStart + gbufferModelViewInverse[3].xyz; + vec3 dVWorld = (wpos-gbufferModelViewInverse[3].xyz); + + vec3 absorbance = vec3(1.0); + vec3 vL = vec3(0.0); + + float expFactor = 11.0; + for (int i=0;i 0.99; - float translucentAlpha = trpData.a; - // vec4 speculartex = texture2D(colortex8,texcoord); // translucents - // float sunlight = speculartex.b; + if (isEyeInWater == 0){ + + #ifdef OVERWORLD_SHADER + vec4 VolumetricFog = GetVolumetricFog(viewPos, noise_1, lightCol.rgb/80.0, averageSkyCol/30.0); + #endif + #ifdef NETHER_SHADER + vec4 VolumetricFog = GetVolumetricFog(viewPos, noise_1, noise_2); + #endif + #ifdef END_SHADER + vec4 VolumetricFog = GetVolumetricFog(viewPos, noise_1, noise_2); + #endif - //3x3 bilateral upscale from half resolution - float z = texture2D(depthtex0,texcoord).x; - float z2 = texture2D(depthtex1,texcoord).x; - float frDepth = ld(z2); - - // vec4 vl = texture2D(colortex0,texcoord * 0.5); - - ////// --------------- UNPACK OPAQUE GBUFFERS --------------- ////// - vec4 data_opaque = texture2D(colortex1,texcoord); - vec4 dataUnpacked1 = vec4(decodeVec2(data_opaque.z),decodeVec2(data_opaque.w)); // normals, lightmaps - // vec4 dataUnpacked2 = vec4(decodeVec2(data.z),decodeVec2(data.w)); + gl_FragData[0] = clamp(VolumetricFog, 0.0, 65000.0); + } - bool hand = abs(dataUnpacked1.w-0.75) < 0.01; - vec2 lightmap = dataUnpacked1.yz; + if (isEyeInWater == 1){ - ////// --------------- UNPACK TRANSLUCENT GBUFFERS --------------- ////// + float dirtAmount = Dirt_Amount; + vec3 waterEpsilon = vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B); + vec3 dirtEpsilon = vec3(Dirt_Absorb_R, Dirt_Absorb_G, Dirt_Absorb_B); + vec3 totEpsilon = dirtEpsilon*dirtAmount + waterEpsilon; + vec3 scatterCoef = dirtAmount * vec3(Dirt_Scatter_R, Dirt_Scatter_G, Dirt_Scatter_B) / 3.14; - vec3 data = texture2D(colortex11,texcoord).rgb; + #ifdef OVERWORLD_SHADER - vec4 unpack0 = vec4(decodeVec2(data.r),decodeVec2(data.g)) ; - vec4 unpack1 = vec4(decodeVec2(data.b),0,0) ; - - + float estEyeDepth = 1.0-clamp(eyeBrightnessSmooth.y/240.0,0.,1.0); + estEyeDepth = pow(estEyeDepth,3.0) * 32.0; - vec4 albedo = vec4(unpack0.ba,unpack1.rg); + vec3 lightColVol = lightCol.rgb / 80.; - vec2 tangentNormals = unpack0.xy*2.0-1.0; + vec3 lightningColor = (lightningEffect / 3) * (max(eyeBrightnessSmooth.y,0)/240.); + vec3 ambientColVol = (averageSkyCol/30.0); - if(albedo.a <= 0.0) tangentNormals = vec2(0.0); - - vec4 TranslucentShader = texture2D(colortex2,texcoord); - - float lightleakfix = clamp(pow(eyeBrightnessSmooth.y/240.,2) ,0.0,1.0); - - - vec2 tempOffset = TAA_Offset; - vec3 fragpos = toScreenSpace(vec3(texcoord/RENDER_SCALE-vec2(tempOffset)*texelSize*0.5,z)); - vec3 fragpos2 = toScreenSpace(vec3(texcoord/RENDER_SCALE-vec2(tempOffset)*texelSize*0.5,z2)); - - - vec3 p3 = mat3(gbufferModelViewInverse) * fragpos; - vec3 np3 = normVec(p3); - - - vec2 refractedCoord = texcoord; - - /// --- REFRACTION --- /// - #ifdef Refraction - refractedCoord += (tangentNormals * clamp((ld(z2) - ld(z)) * 0.5,0.0,0.15)) * RENDER_SCALE; - // refractedCoord += tangentNormals * 0.1 * RENDER_SCALE; - - float refractedalpha = decodeVec2(texture2D(colortex11,refractedCoord).b).g; - float refractedalpha2 = texture2D(colortex7,refractedCoord).a; - if( refractedalpha <= 0.001 ||z < 0.56) refractedCoord = texcoord; // remove refracted coords on solids - #endif - - /// --- MAIN COLOR BUFFER --- /// - // it is sampled with distorted texcoords - vec3 color = texture2D(colortex3,refractedCoord).rgb; - - vec4 vl = BilateralUpscale(colortex0, depthtex1, gl_FragCoord.xy, frDepth, vec2(0.0)); - float bloomyFogMult = 1.0; - - if (TranslucentShader.a > 0.0){ - #ifdef Glass_Tint - if(albedo.a > 0.2) color = color*albedo.rgb + color * clamp(pow(1.0-luma(albedo.rgb),20.),0.0,1.0); - #endif - - color = color*(1.0-TranslucentShader.a) + TranslucentShader.rgb; - } - - // underwater fog - if (isEyeInWater == 1){ - float dirtAmount = Dirt_Amount; - vec3 waterEpsilon = vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B); - vec3 dirtEpsilon = vec3(Dirt_Absorb_R, Dirt_Absorb_G, Dirt_Absorb_B); - vec3 totEpsilon = dirtEpsilon*dirtAmount + waterEpsilon; - - // float fogfade = clamp( exp(length(fragpos) / -20) ,0.0,1.0); - // vec3 fogfade = clamp( exp( (length(fragpos) / -4) * totEpsilon ) ,0.0,1.0); - vec3 fogfade = clamp( exp( (-length(fragpos)) * totEpsilon ) ,0.0,1.0); - fogfade *= 1.0 - clamp( length(fragpos) / far,0.0,1.0); - - color.rgb *= fogfade ; - bloomyFogMult *= 0.4; - } - - // apply VL fog to the scene - color *= vl.a; - color += vl.rgb; - -// bloomy rain effect - float rainDrops = clamp(texture2D(colortex9,texcoord).a, 0.0,1.0); - if(rainDrops > 0.0) bloomyFogMult *= clamp(1.0 - pow(rainDrops*5.0,2),0.0,1.0); - - /// lava. - if (isEyeInWater == 2){ - color.rgb = vec3(4.0,0.5,0.1); - } - - /// powdered snow - if (isEyeInWater == 3){ - color.rgb = mix(color.rgb,vec3(10,15,20),clamp(length(fragpos)*0.5,0.,1.)); - bloomyFogMult = 0.0; - } - - // blidnesss - color.rgb *= mix(1.0,clamp( exp(pow(length(fragpos)*(blindness*0.2),2) * -1),0.,1.) , blindness); - - // darkness effect - color.rgb *= mix(1.0, (1.0-darknessLightFactor*2.0) * clamp(1.0-pow(length(fragpos2)*(darknessFactor*0.07),2.0),0.0,1.0), darknessFactor); - - #ifdef display_LUT - vec2 movedTC = texcoord; - vec3 thingy = texture2D(colortex4,movedTC).rgb / 150. * 5.0; - if(luma(thingy) > 0.0 ) color.rgb = thingy; - #endif - - gl_FragData[0].r = vl.a * bloomyFogMult; // pass fog alpha so bloom can do bloomy fog - - gl_FragData[1].rgb = clamp(color.rgb,0.0,68000.0); + vec3 vl = vec3(0.0); + waterVolumetrics(vl, vec3(0.0), viewPos, estEyeDepth, estEyeDepth, length(viewPos), noise_1, totEpsilon, scatterCoef, ambientColVol, lightColVol*(1.0-pow(1.0-sunElevation*lightCol.a,5.0)) , dot(normalize(viewPos), normalize(sunVec* lightCol.a ) )); + gl_FragData[0] = clamp(vec4(vl,1.0),0.000001,65000.); + #else + vec3 fragpos0 = toScreenSpace(vec3(texcoord - TAA_Offset*texelSize*0.5,z)); + vec3 ambientColVol = max(vec3(1.0,0.5,1.0) * 0.6, vec3(0.2,0.4,1.0) * MIN_LIGHT_AMOUNT*0.01); + gl_FragData[0].a = 1; + waterVolumetrics_notoverworld(gl_FragData[0].rgb, fragpos0, viewPos, 1 , 1, 1, blueNoise(), totEpsilon, scatterCoef, ambientColVol); + #endif + } } \ No newline at end of file diff --git a/shaders/dimensions/composite2.vsh b/shaders/dimensions/composite2.vsh index 1717e80..0d192bb 100644 --- a/shaders/dimensions/composite2.vsh +++ b/shaders/dimensions/composite2.vsh @@ -1,17 +1,45 @@ +#include "/lib/settings.glsl" +#include "/lib/util.glsl" + +flat varying vec4 lightCol; +flat varying vec3 averageSkyCol; + +flat varying vec3 WsunVec; +flat varying vec3 refractedSunVec; + +flat varying float tempOffsets; + +uniform sampler2D colortex4; + +uniform float sunElevation; +uniform vec3 sunPosition; +uniform mat4 gbufferModelViewInverse; +uniform int frameCounter; + + -varying vec2 texcoord; -flat varying vec3 zMults; -uniform float far; -uniform float near; //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// + +#include "/lib/Shadow_Params.glsl" void main() { - zMults = vec3(1.0/(far * near),far+near,far-near); gl_Position = ftransform(); - texcoord = gl_MultiTexCoord0.xy; + gl_Position.xy = (gl_Position.xy*0.5+0.5)*0.51*2.0-1.0; + + tempOffsets = HaltonSeq2(frameCounter%10000); + + averageSkyCol = texelFetch2D(colortex4,ivec2(1,37),0).rgb; + + lightCol.a = float(sunElevation > 1e-5)*2.0 - 1.0; + lightCol.rgb = texelFetch2D(colortex4,ivec2(6,37),0).rgb; + + WsunVec = lightCol.a * normalize(mat3(gbufferModelViewInverse) * sunPosition); + // WsunVec = normalize(LightDir); + + refractedSunVec = refract(WsunVec, -vec3(0.0,1.0,0.0), 1.0/1.33333); } diff --git a/shaders/dimensions/composite3.fsh b/shaders/dimensions/composite3.fsh index c47e9fc..fd31e57 100644 --- a/shaders/dimensions/composite3.fsh +++ b/shaders/dimensions/composite3.fsh @@ -1,350 +1,347 @@ #include "/lib/settings.glsl" -const int noiseTextureResolution = 32; +flat varying vec3 zMults; +flat varying vec2 TAA_Offset; -/* -const int colortex0Format = RGBA16F; // low res clouds (deferred->composite2) + low res VL (composite5->composite15) -const int colortex1Format = RGBA16; //terrain gbuffer (gbuffer->composite2) -const int colortex2Format = RGBA16F; //forward + transparencies (gbuffer->composite4) -const int colortex3Format = R11F_G11F_B10F; //frame buffer + bloom (deferred6->final) -const int colortex4Format = RGBA16F; //light values and skyboxes (everything) -const int colortex5Format = R11F_G11F_B10F; //TAA buffer (everything) -const int colortex6Format = R11F_G11F_B10F; //additionnal buffer for bloom (composite3->final) -const int colortex7Format = RGBA8; //Final output, transparencies id (gbuffer->composite4) -*/ -//no need to clear the buffers, saves a few fps -const bool colortex0Clear = false; -const bool colortex1Clear = false; -const bool colortex2Clear = true; -const bool colortex3Clear = false; -const bool colortex4Clear = false; -const bool colortex5Clear = false; -const bool colortex6Clear = false; -const bool colortex7Clear = false; - -varying vec2 texcoord; -flat varying float exposureA; -flat varying float tempOffsets; -uniform sampler2D colortex3; -uniform sampler2D colortex5; -uniform sampler2D colortex10; +uniform sampler2D noisetex; uniform sampler2D depthtex0; - +uniform sampler2D depthtex1; +uniform sampler2D colortex0; +uniform sampler2D colortex1; +uniform sampler2D colortex2; +uniform sampler2D colortex3; +// uniform sampler2D colortex4; +uniform sampler2D colortex5; +uniform sampler2D colortex6; +uniform sampler2D colortex7; +uniform sampler2D colortex8; +uniform sampler2D colortex9; +uniform sampler2D colortex11; +uniform sampler2D colortex13; +uniform sampler2D colortex15; uniform vec2 texelSize; + +flat varying vec3 noooormal; +flat varying vec4 lightCol; //main light source color (rgb),used light source(1=sun,-1=moon) +flat varying vec3 WsunVec; + +uniform vec3 sunVec; uniform float frameTimeCounter; -uniform int framemod8; -uniform float viewHeight; -uniform float viewWidth; -uniform vec3 previousCameraPosition; +uniform int frameCounter; +uniform float far; +uniform float near; +uniform mat4 gbufferModelViewInverse; +uniform mat4 gbufferModelView; uniform mat4 gbufferPreviousModelView; +uniform mat4 gbufferProjectionInverse; +uniform mat4 gbufferProjection; +uniform mat4 gbufferPreviousProjection; +uniform vec3 cameraPosition; +uniform vec3 previousCameraPosition; + +uniform int isEyeInWater; +uniform ivec2 eyeBrightnessSmooth; +uniform float rainStrength; +uniform float blindness; +uniform float darknessFactor; +uniform float darknessLightFactor; +#include "/lib/waterBump.glsl" +#include "/lib/res_params.glsl" + +#ifdef OVERWORLD_SHADER + #include "/lib/sky_gradient.glsl" + #include "/lib/lightning_stuff.glsl" + #include "/lib/volumetricClouds.glsl" +#endif +#ifndef OVERWORLD_SHADER + #include "/lib/climate_settings.glsl" +#endif -#define fsign(a) (clamp((a)*1e35,0.,1.)*2.-1.) - -#include "/lib/projections.glsl" - +#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z) +#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz) +float ld(float depth) { + return 1.0 / (zMults.y - depth * zMults.z); // (-depth * (far - near)) = (2.0 * near)/ld - far - near +} float luma(vec3 color) { return dot(color,vec3(0.21, 0.72, 0.07)); } +vec3 toLinear(vec3 sRGB){ + return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878); +} +vec3 toScreenSpace(vec3 p) { + vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw); + vec3 p3 = p * 2. - 1.; + vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3]; + return fragposition.xyz / fragposition.w; +} + + +// #include "/lib/specular.glsl" + + + + +vec4 BilateralUpscale(sampler2D tex, sampler2D depth,vec2 coord,float frDepth){ + coord = coord; + vec4 vl = vec4(0.0); + float sum = 0.0; + mat3x3 weights; + const ivec2 scaling = ivec2(1.0/VL_RENDER_RESOLUTION); + ivec2 posD = ivec2(coord*VL_RENDER_RESOLUTION)*scaling; + ivec2 posVl = ivec2(coord*VL_RENDER_RESOLUTION); + float dz = zMults.x; + ivec2 pos = (ivec2(gl_FragCoord.xy+frameCounter) % 2 )*2; + + ivec2 tcDepth = posD + ivec2(-2,-2) * scaling + pos * scaling; + float dsample = ld(texelFetch2D(depth,tcDepth,0).r); + float w = abs(dsample-frDepth) < dz ? 1.0 : 1e-5; + vl += texelFetch2D(tex,posVl+ivec2(-2)+pos,0)*w; + sum += w; + + tcDepth = posD + ivec2(-2,0) * scaling + pos * scaling; + dsample = ld(texelFetch2D(depth,tcDepth,0).r); + w = abs(dsample-frDepth) < dz ? 1.0 : 1e-5; + vl += texelFetch2D(tex,posVl+ivec2(-2,0)+pos,0)*w; + sum += w; + + tcDepth = posD + ivec2(0) + pos * scaling; + dsample = ld(texelFetch2D(depth,tcDepth,0).r); + w = abs(dsample-frDepth) < dz ? 1.0 : 1e-5; + vl += texelFetch2D(tex,posVl+ivec2(0)+pos,0)*w; + sum += w; + + tcDepth = posD + ivec2(0,-2) * scaling + pos * scaling; + dsample = ld(texelFetch2D(depth,tcDepth,0).r); + w = abs(dsample-frDepth) < dz ? 1.0 : 1e-5; + vl += texelFetch2D(tex,posVl+ivec2(0,-2)+pos,0)*w; + sum += w; + + return vl/sum; +} + +vec3 decode (vec2 encn){ + vec3 n = vec3(0.0); + encn = encn * 2.0 - 1.0; + n.xy = abs(encn); + n.z = 1.0 - n.x - n.y; + n.xy = n.z <= 0.0 ? (1.0 - n.yx) * sign(encn) : encn; + return clamp(normalize(n.xyz),-1.0,1.0); +} +vec2 decodeVec2(float a){ + const vec2 constant1 = 65535. / vec2( 256., 65536.); + const float constant2 = 256. / 255.; + return fract( a * constant1 ) * constant2 ; +} + +vec3 worldToView(vec3 worldPos) { + vec4 pos = vec4(worldPos, 0.0); + pos = gbufferModelView * pos; + return pos.xyz; +} +float blueNoise(){ + return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter); +} +vec4 blueNoise(vec2 coord){ + return texelFetch2D(colortex6, ivec2(coord )%512 , 0); +} +vec3 normVec (vec3 vec){ + return vec*inversesqrt(dot(vec,vec)); +} + float interleaved_gradientNoise(){ - return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y)+tempOffsets); + vec2 coord = gl_FragCoord.xy; + float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y)); + return noise; } -float triangularize(float dither) -{ - float center = dither*2.0-1.0; - dither = center*inversesqrt(abs(center)); - return clamp(dither-fsign(center),0.0,1.0); -} -vec3 fp10Dither(vec3 color,float dither){ - const vec3 mantissaBits = vec3(6.,6.,5.); - vec3 exponent = floor(log2(color)); - return color + dither*exp2(-mantissaBits)*exp2(exponent); +vec3 viewToWorld(vec3 viewPosition) { + vec4 pos; + pos.xyz = viewPosition; + pos.w = 0.0; + pos = gbufferModelViewInverse * pos; + return pos.xyz; } - -//returns the projected coordinates of the closest point to the camera in the 3x3 neighborhood -vec3 closestToCamera3x3() -{ - vec2 du = vec2(texelSize.x, 0.0); - vec2 dv = vec2(0.0, texelSize.y); - - vec3 dtl = vec3(texcoord,0.) + vec3(-texelSize, texture2D(depthtex0, texcoord - dv - du).x); - vec3 dtc = vec3(texcoord,0.) + vec3( 0.0, -texelSize.y, texture2D(depthtex0, texcoord - dv).x); - vec3 dtr = vec3(texcoord,0.) + vec3( texelSize.x, -texelSize.y, texture2D(depthtex0, texcoord - dv + du).x); - - vec3 dml = vec3(texcoord,0.) + vec3(-texelSize.x, 0.0, texture2D(depthtex0, texcoord - du).x); - vec3 dmc = vec3(texcoord,0.) + vec3( 0.0, 0.0, texture2D(depthtex0, texcoord).x); - vec3 dmr = vec3(texcoord,0.) + vec3( texelSize.x, 0.0, texture2D(depthtex0, texcoord + du).x); - - vec3 dbl = vec3(texcoord,0.) + vec3(-texelSize.x, texelSize.y, texture2D(depthtex0, texcoord + dv - du).x); - vec3 dbc = vec3(texcoord,0.) + vec3( 0.0, texelSize.y, texture2D(depthtex0, texcoord + dv).x); - vec3 dbr = vec3(texcoord,0.) + vec3( texelSize.x, texelSize.y, texture2D(depthtex0, texcoord + dv + du).x); - - vec3 dmin = dmc; - - dmin = dmin.z > dtc.z? dtc : dmin; - dmin = dmin.z > dtr.z? dtr : dmin; - - dmin = dmin.z > dml.z? dml : dmin; - dmin = dmin.z > dtl.z? dtl : dmin; - dmin = dmin.z > dmr.z? dmr : dmin; - - dmin = dmin.z > dbl.z? dbl : dmin; - dmin = dmin.z > dbc.z? dbc : dmin; - dmin = dmin.z > dbr.z? dbr : dmin; - - return dmin; +/// thanks stackoverflow https://stackoverflow.com/questions/944713/help-with-pixel-shader-effect-for-brightness-and-contrast#3027595 +void applyContrast(inout vec3 color, float contrast){ + color = ((color - 0.5) * max(contrast, 0.0)) + 0.5; } - -//Modified texture interpolation from inigo quilez -vec4 smoothfilter(in sampler2D tex, in vec2 uv) -{ - vec2 textureResolution = vec2(viewWidth,viewHeight); - uv = uv*textureResolution + 0.5; - vec2 iuv = floor( uv ); - vec2 fuv = fract( uv ); - #ifndef SMOOTHESTSTEP_INTERPOLATION - uv = iuv + (fuv*fuv)*(3.0-2.0*fuv); - #endif - #ifdef SMOOTHESTSTEP_INTERPOLATION - uv = iuv + fuv*fuv*fuv*(fuv*(fuv*6.0-15.0)+10.0); - #endif - uv = (uv - 0.5)/textureResolution; - return texture2D( tex, uv); -} -//Due to low sample count we "tonemap" the inputs to preserve colors and smoother edges -vec3 weightedSample(sampler2D colorTex, vec2 texcoord){ - vec3 wsample = texture2D(colorTex,texcoord).rgb*exposureA; - return wsample/(1.0+luma(wsample)); - -} - - -//from : https://gist.github.com/TheRealMJP/c83b8c0f46b63f3a88a5986f4fa982b1 -vec4 SampleTextureCatmullRom(sampler2D tex, vec2 uv, vec2 texSize ) -{ - // We're going to sample a a 4x4 grid of texels surrounding the target UV coordinate. We'll do this by rounding - // down the sample location to get the exact center of our "starting" texel. The starting texel will be at - // location [1, 1] in the grid, where [0, 0] is the top left corner. - vec2 samplePos = uv * texSize; - vec2 texPos1 = floor(samplePos - 0.5) + 0.5; - - // Compute the fractional offset from our starting texel to our original sample location, which we'll - // feed into the Catmull-Rom spline function to get our filter weights. - vec2 f = samplePos - texPos1; - - // Compute the Catmull-Rom weights using the fractional offset that we calculated earlier. - // These equations are pre-expanded based on our knowledge of where the texels will be located, - // which lets us avoid having to evaluate a piece-wise function. - vec2 w0 = f * ( -0.5 + f * (1.0 - 0.5*f)); - vec2 w1 = 1.0 + f * f * (-2.5 + 1.5*f); - vec2 w2 = f * ( 0.5 + f * (2.0 - 1.5*f) ); - vec2 w3 = f * f * (-0.5 + 0.5 * f); - - // Work out weighting factors and sampling offsets that will let us use bilinear filtering to - // simultaneously evaluate the middle 2 samples from the 4x4 grid. - vec2 w12 = w1 + w2; - vec2 offset12 = w2 / (w1 + w2); - - // Compute the final UV coordinates we'll use for sampling the texture - vec2 texPos0 = texPos1 - vec2(1.0); - vec2 texPos3 = texPos1 + vec2(2.0); - vec2 texPos12 = texPos1 + offset12; - - texPos0 *= texelSize; - texPos3 *= texelSize; - texPos12 *= texelSize; - - vec4 result = vec4(0.0); - result += texture2D(tex, vec2(texPos0.x, texPos0.y)) * w0.x * w0.y; - result += texture2D(tex, vec2(texPos12.x, texPos0.y)) * w12.x * w0.y; - result += texture2D(tex, vec2(texPos3.x, texPos0.y)) * w3.x * w0.y; - - result += texture2D(tex, vec2(texPos0.x, texPos12.y)) * w0.x * w12.y; - result += texture2D(tex, vec2(texPos12.x, texPos12.y)) * w12.x * w12.y; - result += texture2D(tex, vec2(texPos3.x, texPos12.y)) * w3.x * w12.y; - - result += texture2D(tex, vec2(texPos0.x, texPos3.y)) * w0.x * w3.y; - result += texture2D(tex, vec2(texPos12.x, texPos3.y)) * w12.x * w3.y; - result += texture2D(tex, vec2(texPos3.x, texPos3.y)) * w3.x * w3.y; - - return result; -} -//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 clip_aabb(vec3 q,vec3 aabb_min, vec3 aabb_max) - { - vec3 p_clip = 0.5 * (aabb_max + aabb_min); - vec3 e_clip = 0.5 * (aabb_max - aabb_min) + 0.00000001; - - vec3 v_clip = q - vec3(p_clip); - vec3 v_unit = v_clip.xyz / e_clip; - vec3 a_unit = abs(v_unit); - float ma_unit = max(a_unit.x, max(a_unit.y, a_unit.z)); - - if (ma_unit > 1.0) - return vec3(p_clip) + v_clip / ma_unit; - else - return q; - } -vec3 toClipSpace3Prev(vec3 viewSpacePosition) { - return projMAD(gbufferPreviousProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5; -} -vec3 tonemap(vec3 col){ - return col/(1+luma(col)); -} -vec3 invTonemap(vec3 col){ - return col/(1-luma(col)); -} -vec3 closestToCamera5taps(vec2 texcoord, sampler2D depth) -{ - vec2 du = vec2(texelSize.x*2., 0.0); - vec2 dv = vec2(0.0, texelSize.y*2.); - - vec3 dtl = vec3(texcoord,0.) + vec3(-texelSize, texture2D(depth, texcoord - dv - du).x); - vec3 dtr = vec3(texcoord,0.) + vec3( texelSize.x, -texelSize.y, texture2D(depth, texcoord - dv + du).x); - vec3 dmc = vec3(texcoord,0.) + vec3( 0.0, 0.0, texture2D(depth, texcoord).x); - vec3 dbl = vec3(texcoord,0.) + vec3(-texelSize.x, texelSize.y, texture2D(depth, texcoord + dv - du).x); - vec3 dbr = vec3(texcoord,0.) + vec3( texelSize.x, texelSize.y, texture2D(depth, 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; -} -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 TAA_hq(){ - - vec2 adjTC = texcoord; - - - //use velocity from the nearest texel from camera in a 3x3 box in order to improve edge quality in motion - #ifdef CLOSEST_VELOCITY - vec3 closestToCamera = closestToCamera5taps(adjTC, depthtex0); - #endif - - #ifndef CLOSEST_VELOCITY - vec3 closestToCamera = vec3(texcoord,texture2D(depthtex1,adjTC).x); - #endif - - //reproject previous frame - vec3 fragposition = toScreenSpace(closestToCamera); - fragposition = mat3(gbufferModelViewInverse) * fragposition + gbufferModelViewInverse[3].xyz + (cameraPosition - previousCameraPosition); - vec3 previousPosition = mat3(gbufferPreviousModelView) * fragposition + gbufferPreviousModelView[3].xyz; - previousPosition = toClipSpace3Prev(previousPosition); - vec2 velocity = previousPosition.xy - closestToCamera.xy; - previousPosition.xy = texcoord + velocity; - - //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 smoothfilter(colortex3, adjTC + offsets[framemod8]*texelSize*0.5).xyz; - - - vec3 albedoCurrent0 = texture2D(colortex3, adjTC).rgb; - vec3 albedoCurrent1 = texture2D(colortex3, adjTC + vec2(texelSize.x,texelSize.y)).rgb; - vec3 albedoCurrent2 = texture2D(colortex3, adjTC + vec2(texelSize.x,-texelSize.y)).rgb; - vec3 albedoCurrent3 = texture2D(colortex3, adjTC + vec2(-texelSize.x,-texelSize.y)).rgb; - vec3 albedoCurrent4 = texture2D(colortex3, adjTC + vec2(-texelSize.x,texelSize.y)).rgb; - vec3 albedoCurrent5 = texture2D(colortex3, adjTC + vec2(0.0,texelSize.y)).rgb; - vec3 albedoCurrent6 = texture2D(colortex3, adjTC + vec2(0.0,-texelSize.y)).rgb; - vec3 albedoCurrent7 = texture2D(colortex3, adjTC + vec2(-texelSize.x,0.0)).rgb; - vec3 albedoCurrent8 = texture2D(colortex3, adjTC + vec2(texelSize.x,0.0)).rgb; - //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)))))); - albedoCurrent0 = smoothfilter(colortex3, adjTC + offsets[framemod8]*texelSize*0.5).rgb; - - - #ifndef NO_CLIP - vec3 albedoPrev = max(FastCatmulRom(colortex5, previousPosition.xy,vec4(texelSize, 1.0/texelSize), 0.75).xyz, 0.0); - vec3 finalcAcc = clamp(albedoPrev,cMin,cMax); - - //Increases blending factor when far from AABB and in motion, reduces ghosting - float isclamped = distance(albedoPrev,finalcAcc)/luma(albedoPrev) * 0.5; - float movementRejection = (0.12+isclamped)*clamp(length(velocity/texelSize),0.0,1.0); - - float test = 0.05; - - bool isEntities = texture2D(colortex10,texcoord).x > 0.0; - // if(isEntities) test = 0.15; - // if(istranslucent) test = 0.1; - - //Blend current pixel with clamped history, apply fast tonemap beforehand to reduce flickering - // vec3 supersampled = invTonemap(mix(tonemap(finalcAcc),tonemap(albedoCurrent0),clamp(BLEND_FACTOR + movementRejection, min(luma(motionVector) *255,1.0),1.))); - - vec3 supersampled = invTonemap(mix(tonemap(finalcAcc),tonemap(albedoCurrent0),clamp(BLEND_FACTOR + movementRejection, test,1.))); - #endif - - - #ifdef NO_CLIP - vec3 albedoPrev = texture2D(colortex5, previousPosition.xy).xyz; - vec3 supersampled = mix(albedoPrev,albedoCurrent0,clamp(0.05,0.,1.)); - #endif - - //De-tonemap - return supersampled; -} - void main() { + /* DRAWBUFFERS:73 */ -/* DRAWBUFFERS:5 */ - gl_FragData[0].a = 1.0; + vec2 texcoord = gl_FragCoord.xy*texelSize; - #ifdef TAA - vec3 color = TAA_hq(); - gl_FragData[0].rgb = clamp(fp10Dither(color,triangularize(interleaved_gradientNoise())),6.11*1e-5,65000.0); - #endif + vec4 trpData = texture2D(colortex7,texcoord); - #ifndef TAA - vec3 color = clamp(fp10Dither(texture2D(colortex3,texcoord).rgb,triangularize(interleaved_gradientNoise())),0.,65000.); - gl_FragData[0].rgb = color; - #endif + bool iswater = trpData.a > 0.99; + float translucentAlpha = trpData.a; + + // vec4 speculartex = texture2D(colortex8,texcoord); // translucents + // float sunlight = speculartex.b; + + //3x3 bilateral upscale from half resolution + float z = texture2D(depthtex0,texcoord).x; + float z2 = texture2D(depthtex1,texcoord).x; + float frDepth = ld(z2); + + // vec4 vl = texture2D(colortex0,texcoord * 0.5); + + ////// --------------- UNPACK OPAQUE GBUFFERS --------------- ////// + vec4 data_opaque = texture2D(colortex1,texcoord); + vec4 dataUnpacked1 = vec4(decodeVec2(data_opaque.z),decodeVec2(data_opaque.w)); // normals, lightmaps + // vec4 dataUnpacked2 = vec4(decodeVec2(data.z),decodeVec2(data.w)); + + bool hand = abs(dataUnpacked1.w-0.75) < 0.01; + vec2 lightmap = dataUnpacked1.yz; + + ////// --------------- UNPACK TRANSLUCENT GBUFFERS --------------- ////// + + vec3 data = texture2D(colortex11,texcoord).rgb; + + vec4 unpack0 = vec4(decodeVec2(data.r),decodeVec2(data.g)) ; + vec4 unpack1 = vec4(decodeVec2(data.b),0,0) ; + + + + vec4 albedo = vec4(unpack0.ba,unpack1.rg); + + vec2 tangentNormals = unpack0.xy*2.0-1.0; + + if(albedo.a <= 0.0) tangentNormals = vec2(0.0); + + vec4 TranslucentShader = texture2D(colortex2,texcoord); + vec2 tempOffset = TAA_Offset; + vec3 fragpos = toScreenSpace(vec3(texcoord/RENDER_SCALE-vec2(tempOffset)*texelSize*0.5,z)); + vec3 fragpos2 = toScreenSpace(vec3(texcoord/RENDER_SCALE-vec2(tempOffset)*texelSize*0.5,z2)); + + + vec3 p3 = mat3(gbufferModelViewInverse) * fragpos; + vec3 np3 = normVec(p3); -} + vec2 refractedCoord = texcoord; + + /// --- REFRACTION --- /// + #ifdef Refraction + refractedCoord += (tangentNormals * clamp((ld(z2) - ld(z)) * 0.5,0.0,0.15)) * RENDER_SCALE; + // refractedCoord += tangentNormals * 0.1 * RENDER_SCALE; + + float refractedalpha = decodeVec2(texture2D(colortex11,refractedCoord).b).g; + float refractedalpha2 = texture2D(colortex7,refractedCoord).a; + if( refractedalpha <= 0.001 ||z < 0.56) refractedCoord = texcoord; // remove refracted coords on solids + #endif + + /// --- MAIN COLOR BUFFER --- /// + // it is sampled with distorted texcoords + vec3 color = texture2D(colortex3,refractedCoord).rgb; + + float lightleakfix = clamp(pow(eyeBrightnessSmooth.y/240.,2) ,0.0,1.0); + + #if defined OVERWORLD_SHADER && defined BorderFog + vec3 sky = skyFromTex(np3,colortex4) / 150. * 5.0; + float fog = 1.0 - clamp(exp(-pow(length(fragpos / far),10.)*4.0) ,0.0,1.0); + float heightFalloff = clamp( pow(abs(np3.y-1.01),5) ,0,1) ; + + if(z < 1.0 && isEyeInWater == 0) color.rgb = mix(color.rgb, sky, fog * heightFalloff * lightleakfix); + #endif + + vec4 vl = BilateralUpscale(colortex0, depthtex1, gl_FragCoord.xy, frDepth); + float bloomyFogMult = 1.0; + + if (TranslucentShader.a > 0.0){ + #ifdef Glass_Tint + if(albedo.a > 0.2) color = color*albedo.rgb + color * clamp(pow(1.0-luma(albedo.rgb),20.),0.0,1.0); + #endif + + color = color*(1.0-TranslucentShader.a) + TranslucentShader.rgb; + + #ifdef BorderFog + if(z < 1.0 && isEyeInWater == 0) color.rgb = mix(color.rgb, sky, fog * heightFalloff * lightleakfix); + #endif + } + +#ifdef OVERWORLD_SHADER + #ifdef Cave_fog + if (isEyeInWater == 0){ + + float fogdistfade = clamp( pow(length(fragpos) / far, CaveFogFallOff) ,0.0,1.0); + + fogdistfade = fogdistfade*0.95 + clamp( pow(1.0 - exp((length(fragpos) / far) * -5), 2.0) ,0.0,1.0)*0.05; + float fogfade = clamp( exp(clamp(np3.y * 0.5 + 0.5,0,1) * -3.0) ,0.0,1.0); + + vec3 cavefogCol = vec3(CaveFogColor_R,CaveFogColor_G,CaveFogColor_B); + + #ifdef PER_BIOME_ENVIRONMENT + BiomeFogColor(cavefogCol); + #endif + + color.rgb = mix(color.rgb, cavefogCol*fogfade, fogdistfade * (1.0-lightleakfix) * (1.0-darknessFactor) * clamp( 1.5 - np3.y,0.,1)) ; + // color.rgb = mix(color.rgb, vec3(0.), fogdistfade * (1.0-lightleakfix) * (1.0-darknessFactor) * clamp( 1.5 - np3.y,0.,1)) ; + // color.rgb = vec3(CaveFogColor_R,CaveFogColor_G,CaveFogColor_B)*fogfade ; + } + #endif +#endif + + // underwater fog + if (isEyeInWater == 1){ + float dirtAmount = Dirt_Amount; + vec3 waterEpsilon = vec3(Water_Absorb_R, Water_Absorb_G, Water_Absorb_B); + vec3 dirtEpsilon = vec3(Dirt_Absorb_R, Dirt_Absorb_G, Dirt_Absorb_B); + vec3 totEpsilon = dirtEpsilon*dirtAmount + waterEpsilon; + + // float fogfade = clamp( exp(length(fragpos) / -20) ,0.0,1.0); + // vec3 fogfade = clamp( exp( (length(fragpos) / -4) * totEpsilon ) ,0.0,1.0); + vec3 fogfade = clamp( exp( (length(fragpos) / -4) * totEpsilon ) ,0.0,1.0); + fogfade *= 1.0 - clamp( length(fragpos) / far,0.0,1.0); + + color.rgb *= fogfade ; + bloomyFogMult *= 0.4; + } + + // apply VL fog to the scene + color *= vl.a; + color += vl.rgb; + + #ifdef OVERWORLD_SHADER + // bloomy rain effect + float rainDrops = clamp(texture2D(colortex9,texcoord).a, 0.0,1.0); + if(rainDrops > 0.0) bloomyFogMult *= clamp(1.0 - pow(rainDrops*5.0,2),0.0,1.0); + #endif + + /// lava. + if (isEyeInWater == 2){ + color.rgb = vec3(4.0,0.5,0.1); + } + + /// powdered snow + if (isEyeInWater == 3){ + color.rgb = mix(color.rgb,vec3(10,15,20),clamp(length(fragpos)*0.5,0.,1.)); + bloomyFogMult = 0.0; + } + + // blidnesss + color.rgb *= mix(1.0,clamp( exp(pow(length(fragpos)*(blindness*0.2),2) * -5),0.,1.) , blindness); + + // darkness effect + color.rgb *= mix(1.0, (1.0-darknessLightFactor*2.0) * clamp(1.0-pow(length(fragpos2)*(darknessFactor*0.07),2.0),0.0,1.0), darknessFactor); + + #ifdef display_LUT + vec2 movedTC = texcoord; + vec3 thingy = texture2D(colortex4,movedTC).rgb / 30; + if(luma(thingy) > 0.0){ + color.rgb = thingy; + vl.a = 1.0; + } + #endif + + gl_FragData[0].r = vl.a * bloomyFogMult; // pass fog alpha so bloom can do bloomy fog + + gl_FragData[1].rgb = clamp(color.rgb, 0.0,68000.0); +} \ No newline at end of file diff --git a/shaders/dimensions/composite3.vsh b/shaders/dimensions/composite3.vsh index 263f476..1717e80 100644 --- a/shaders/dimensions/composite3.vsh +++ b/shaders/dimensions/composite3.vsh @@ -1,17 +1,17 @@ -#include "/lib/util.glsl" varying vec2 texcoord; -flat varying float exposureA; -flat varying float tempOffsets; -uniform sampler2D colortex4; -uniform int frameCounter; - - +flat varying vec3 zMults; +uniform float far; +uniform float near; +//////////////////////////////VOID MAIN////////////////////////////// +//////////////////////////////VOID MAIN////////////////////////////// +//////////////////////////////VOID MAIN////////////////////////////// +//////////////////////////////VOID MAIN////////////////////////////// +//////////////////////////////VOID MAIN////////////////////////////// void main() { - - tempOffsets = HaltonSeq2(frameCounter%10000); + zMults = vec3(1.0/(far * near),far+near,far-near); gl_Position = ftransform(); texcoord = gl_MultiTexCoord0.xy; - exposureA = texelFetch2D(colortex4,ivec2(10,37),0).r; + } diff --git a/shaders/dimensions/composite4.fsh b/shaders/dimensions/composite4.fsh index c6aa254..505bca7 100644 --- a/shaders/dimensions/composite4.fsh +++ b/shaders/dimensions/composite4.fsh @@ -1,7 +1,8 @@ -uniform sampler2D colortex5; -uniform vec2 texelSize; -uniform float viewWidth; -uniform float viewHeight; +#include "/lib/settings.glsl" + +uniform sampler2D colortex3; +// Compute 3x3 min max for TAA + //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// @@ -9,34 +10,35 @@ uniform float viewHeight; //////////////////////////////VOID MAIN////////////////////////////// void main() { - -/* DRAWBUFFERS:3 */ -vec2 resScale = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.))/vec2(1920.,1080.); -vec2 quarterResTC = gl_FragCoord.xy*2.*resScale*texelSize; - - //0.5 - gl_FragData[0] = texture2D(colortex5,quarterResTC-1.0*vec2(texelSize.x,texelSize.y))/4.*0.5; - gl_FragData[0] += texture2D(colortex5,quarterResTC+1.0*vec2(texelSize.x,texelSize.y))/4.*0.5; - gl_FragData[0] += texture2D(colortex5,quarterResTC+vec2(-1.0*texelSize.x,1.0*texelSize.y))/4.*0.5; - gl_FragData[0] += texture2D(colortex5,quarterResTC+vec2(1.0*texelSize.x,-1.0*texelSize.y))/4.*0.5; - - //0.25 - gl_FragData[0] += texture2D(colortex5,quarterResTC-2.0*vec2(texelSize.x,0.0))/2.*0.125; - gl_FragData[0] += texture2D(colortex5,quarterResTC+2.0*vec2(0.0,texelSize.y))/2.*0.125; - gl_FragData[0] += texture2D(colortex5,quarterResTC+2.0*vec2(0,-texelSize.y))/2*0.125; - gl_FragData[0] += texture2D(colortex5,quarterResTC+2.0*vec2(-texelSize.x,0.0))/2*0.125; - - //0.125 - gl_FragData[0] += texture2D(colortex5,quarterResTC-2.0*vec2(texelSize.x,texelSize.y))/4.*0.125; - gl_FragData[0] += texture2D(colortex5,quarterResTC+2.0*vec2(texelSize.x,texelSize.y))/4.*0.125; - gl_FragData[0] += texture2D(colortex5,quarterResTC+vec2(-2.0*texelSize.x,2.0*texelSize.y))/4.*0.125; - gl_FragData[0] += texture2D(colortex5,quarterResTC+vec2(2.0*texelSize.x,-2.0*texelSize.y))/4.*0.125; - - //0.125 - gl_FragData[0] += texture2D(colortex5,quarterResTC)*0.125; - - gl_FragData[0].rgb = clamp(gl_FragData[0].rgb,0.0,65000.); - if (quarterResTC.x > 1.0 - 3.5*texelSize.x || quarterResTC.y > 1.0 -3.5*texelSize.y || quarterResTC.x < 3.5*texelSize.x || quarterResTC.y < 3.5*texelSize.y) gl_FragData[0].rgb = vec3(0.0); - - +/* DRAWBUFFERS:06 */ + ivec2 center = ivec2(gl_FragCoord.xy); + vec3 current = texelFetch2D(colortex3, center, 0).rgb; + vec3 cMin = current; + vec3 cMax = current; + current = texelFetch2D(colortex3, center + ivec2(-1, -1), 0).rgb; + cMin = min(cMin, current); + cMax = max(cMax, current); + current = texelFetch2D(colortex3, center + ivec2(-1, 0), 0).rgb; + cMin = min(cMin, current); + cMax = max(cMax, current); + current = texelFetch2D(colortex3, center + ivec2(-1, 1), 0).rgb; + cMin = min(cMin, current); + cMax = max(cMax, current); + current = texelFetch2D(colortex3, center + ivec2(0, -1), 0).rgb; + cMin = min(cMin, current); + cMax = max(cMax, current); + current = texelFetch2D(colortex3, center + ivec2(0, 1), 0).rgb; + cMin = min(cMin, current); + cMax = max(cMax, current); + current = texelFetch2D(colortex3, center + ivec2(1, -1), 0).rgb; + cMin = min(cMin, current); + cMax = max(cMax, current); + current = texelFetch2D(colortex3, center + ivec2(1, 0), 0).rgb; + cMin = min(cMin, current); + cMax = max(cMax, current); + current = texelFetch2D(colortex3, center + ivec2(1, 1), 0).rgb; + cMin = min(cMin, current); + cMax = max(cMax, current); + gl_FragData[0].rgb = cMax; + gl_FragData[1].rgb = cMin; } diff --git a/shaders/dimensions/composite4.vsh b/shaders/dimensions/composite4.vsh index 7a54acb..4451d61 100644 --- a/shaders/dimensions/composite4.vsh +++ b/shaders/dimensions/composite4.vsh @@ -1,5 +1,6 @@ -uniform float viewWidth; -uniform float viewHeight; +#include "/lib/settings.glsl" +#include "/lib/res_params.glsl" + //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// @@ -7,9 +8,9 @@ uniform float viewHeight; //////////////////////////////VOID MAIN////////////////////////////// void main() { - //Improves performances and makes sure bloom radius stays the same at high resolution (>1080p) - vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.)); gl_Position = ftransform(); - //*0.51 to avoid errors when sampling outside since clearing is disabled - gl_Position.xy = (gl_Position.xy*0.5+0.5)*0.51/clampedRes*vec2(1920.0,1080.)*2.0-1.0; + + #ifdef TAA_UPSCALING + gl_Position.xy = (gl_Position.xy*0.5+0.5)*RENDER_SCALE*2.0-1.0; + #endif } diff --git a/shaders/dimensions/composite5.fsh b/shaders/dimensions/composite5.fsh index a76a667..b2908cd 100644 --- a/shaders/dimensions/composite5.fsh +++ b/shaders/dimensions/composite5.fsh @@ -1,42 +1,286 @@ +#include "/lib/settings.glsl" +#include "/lib/res_params.glsl" + +/* +const int colortex0Format = RGBA16F; // low res clouds (deferred->composite2) + low res VL (composite5->composite15) +const int colortex1Format = RGBA16; //terrain gbuffer (gbuffer->composite2) +const int colortex2Format = RGBA16F; //forward + transparencies (gbuffer->composite4) +const int colortex3Format = R11F_G11F_B10F; //frame buffer + bloom (deferred6->final) +const int colortex4Format = RGBA16F; //light values and skyboxes (everything) +const int colortex6Format = R11F_G11F_B10F; //additionnal buffer for bloom (composite3->final) +const int colortex7Format = RGBA8; //Final output, transparencies id (gbuffer->composite4) + +const int colortex11Format = RGBA16; // unchanged translucents albedo, alpha and tangent normals +const int colortex15Format = RGBA8; // flat normals and vanilla AO +*/ + +//no need to clear the buffers, saves a few fps +const bool colortex0Clear = false; +const bool colortex1Clear = false; +const bool colortex2Clear = true; +const bool colortex3Clear = false; +const bool colortex4Clear = false; +const bool colortex5Clear = false; +const bool colortex6Clear = false; +const bool colortex7Clear = false; +const bool colortex11Clear = true; + +#ifdef SCREENSHOT_MODE + /* + const int colortex5Format = RGBA32F; //TAA buffer (everything) + */ +#else + /* + const int colortex5Format = R11F_G11F_B10F; //TAA buffer (everything) + */ +#endif + + +varying vec2 texcoord; +flat varying float tempOffsets; +uniform sampler2D colortex0; uniform sampler2D colortex3; +uniform sampler2D colortex5; +uniform sampler2D colortex6; +uniform sampler2D colortex10; +uniform sampler2D depthtex0; + uniform vec2 texelSize; -uniform float viewWidth; +uniform float frameTimeCounter; +uniform int framemod8; uniform float viewHeight; -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// +uniform float viewWidth; +uniform vec3 previousCameraPosition; +uniform mat4 gbufferPreviousModelView; -void main() { - -/* DRAWBUFFERS:6 */ -vec2 resScale = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.))/vec2(1920.,1080.); -vec2 quarterResTC = gl_FragCoord.xy*2.*texelSize; - - //0.5 - gl_FragData[0] = texture2D(colortex3,quarterResTC-1.0*vec2(texelSize.x,texelSize.y))/4.*0.5; - gl_FragData[0] += texture2D(colortex3,quarterResTC+1.0*vec2(texelSize.x,texelSize.y))/4.*0.5; - gl_FragData[0] += texture2D(colortex3,quarterResTC+vec2(-1.0*texelSize.x,1.0*texelSize.y))/4.*0.5; - gl_FragData[0] += texture2D(colortex3,quarterResTC+vec2(1.0*texelSize.x,-1.0*texelSize.y))/4.*0.5; - - //0.25 - gl_FragData[0] += texture2D(colortex3,quarterResTC-2.0*vec2(texelSize.x,0.0))/2.*0.125; - gl_FragData[0] += texture2D(colortex3,quarterResTC+2.0*vec2(0.0,texelSize.y))/2.*0.125; - gl_FragData[0] += texture2D(colortex3,quarterResTC+2.0*vec2(0,-texelSize.y))/2*0.125; - gl_FragData[0] += texture2D(colortex3,quarterResTC+2.0*vec2(-texelSize.x,0.0))/2*0.125; - - //0.125 - gl_FragData[0] += texture2D(colortex3,quarterResTC-2.0*vec2(texelSize.x,texelSize.y))/4.*0.125; - gl_FragData[0] += texture2D(colortex3,quarterResTC+2.0*vec2(texelSize.x,texelSize.y))/4.*0.125; - gl_FragData[0] += texture2D(colortex3,quarterResTC+vec2(-2.0*texelSize.x,2.0*texelSize.y))/4.*0.125; - gl_FragData[0] += texture2D(colortex3,quarterResTC+vec2(2.0*texelSize.x,-2.0*texelSize.y))/4.*0.125; - - //0.125 - gl_FragData[0] += texture2D(colortex3,quarterResTC)*0.125; - - gl_FragData[0].rgb = clamp(gl_FragData[0].rgb,0.0,65000.); +uniform int hideGUI; + +#define fsign(a) (clamp((a)*1e35,0.,1.)*2.-1.) + +#include "/lib/projections.glsl" + + +float luma(vec3 color) { + return dot(color,vec3(0.21, 0.72, 0.07)); +} +float interleaved_gradientNoise(){ + return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y)+tempOffsets); +} +float triangularize(float dither) +{ + float center = dither*2.0-1.0; + dither = center*inversesqrt(abs(center)); + return clamp(dither-fsign(center),0.0,1.0); +} +vec4 fp10Dither(vec4 color ,float dither){ + const vec3 mantissaBits = vec3(6.,6.,5.); + vec3 exponent = floor(log2(color.rgb)); + return vec4(color.rgb + dither*exp2(-mantissaBits)*exp2(exponent), color.a); +} + +//Modified texture interpolation from inigo quilez +vec4 smoothfilter(in sampler2D tex, in vec2 uv) +{ + vec2 textureResolution = vec2(viewWidth,viewHeight); + uv = uv*textureResolution + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + + #ifndef SMOOTHESTSTEP_INTERPOLATION + uv = iuv + (fuv*fuv)*(3.0-2.0*fuv); + #endif + #ifdef SMOOTHESTSTEP_INTERPOLATION + uv = iuv + fuv*fuv*fuv*(fuv*(fuv*6.0-15.0)+10.0); + #endif + + uv = (uv - 0.5)/textureResolution; + + return texture2D( tex, uv); +} +//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 clip_aabb(vec3 q, vec3 aabb_min, vec3 aabb_max) +{ + vec3 p_clip = 0.5 * (aabb_max + aabb_min); + vec3 e_clip = 0.5 * (aabb_max - aabb_min) + 0.00000001; + + vec3 v_clip = q - vec3(p_clip); + vec3 v_unit = v_clip.xyz / e_clip; + vec3 a_unit = abs(v_unit); + float ma_unit = max(a_unit.x, max(a_unit.y, a_unit.z)); + + if (ma_unit > 1.0) + return vec3(p_clip) + v_clip / ma_unit; + else + return q; +} + +vec3 toClipSpace3Prev(vec3 viewSpacePosition) { + return projMAD(gbufferPreviousProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5; +} +vec3 tonemap(vec3 col){ + return col/(1+luma(col)); +} +vec3 invTonemap(vec3 col){ + return col/(1-luma(col)); +} +vec3 closestToCamera5taps(vec2 texcoord, sampler2D depth) +{ + vec2 du = vec2(texelSize.x*2., 0.0); + vec2 dv = vec2(0.0, texelSize.y*2.); + + vec3 dtl = vec3(texcoord,0.) + vec3(-texelSize, texture2D(depth, texcoord - dv - du).x); + vec3 dtr = vec3(texcoord,0.) + vec3( texelSize.x, -texelSize.y, texture2D(depth, texcoord - dv + du).x); + vec3 dmc = vec3(texcoord,0.) + vec3( 0.0, 0.0, texture2D(depth, texcoord).x); + vec3 dbl = vec3(texcoord,0.) + vec3(-texelSize.x, texelSize.y, texture2D(depth, texcoord + dv - du).x); + vec3 dbr = vec3(texcoord,0.) + vec3( texelSize.x, texelSize.y, texture2D(depth, 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; + + #ifdef TAA_UPSCALING + dmin.xy = dmin.xy/RENDER_SCALE; + #endif + + return dmin; +} +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.); + +vec4 TAA_hq(){ + + #ifdef TAA_UPSCALING + vec2 adjTC = clamp(texcoord*RENDER_SCALE, vec2(0.0), RENDER_SCALE - texelSize*2.0); + #else + vec2 adjTC = texcoord; + #endif + + //use velocity from the nearest texel from camera in a 3x3 box in order to improve edge quality in motion + #ifdef CLOSEST_VELOCITY + vec3 closestToCamera = closestToCamera5taps(adjTC, depthtex0); + #endif + + #ifndef CLOSEST_VELOCITY + vec3 closestToCamera = vec3(texcoord,texture2D(depthtex1,adjTC).x); + #endif + + //reproject previous frame + vec3 viewPos = toScreenSpace(closestToCamera); + viewPos = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz + (cameraPosition - previousCameraPosition); + + vec3 previousPosition = mat3(gbufferPreviousModelView) * viewPos + gbufferPreviousModelView[3].xyz; + previousPosition = toClipSpace3Prev(previousPosition); + + vec2 velocity = previousPosition.xy - closestToCamera.xy; + previousPosition.xy = texcoord + velocity; + + //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 vec4(smoothfilter(colortex3, adjTC + offsets[framemod8]*texelSize*0.5).xyz,1.0); + + + #ifdef TAA_UPSCALING + vec3 albedoCurrent0 = smoothfilter(colortex3, adjTC + offsets[framemod8]*texelSize*0.5).xyz; + // Interpolating neighboorhood clampling boundaries between pixels + vec3 cMax = texture2D(colortex0, adjTC).rgb; + vec3 cMin = texture2D(colortex6, adjTC).rgb; + #else + vec3 albedoCurrent0 = texture2D(colortex3, adjTC).rgb; + vec3 albedoCurrent1 = texture2D(colortex3, adjTC + vec2(texelSize.x,texelSize.y)).rgb; + vec3 albedoCurrent2 = texture2D(colortex3, adjTC + vec2(texelSize.x,-texelSize.y)).rgb; + vec3 albedoCurrent3 = texture2D(colortex3, adjTC + vec2(-texelSize.x,-texelSize.y)).rgb; + vec3 albedoCurrent4 = texture2D(colortex3, adjTC + vec2(-texelSize.x,texelSize.y)).rgb; + vec3 albedoCurrent5 = texture2D(colortex3, adjTC + vec2(0.0,texelSize.y)).rgb; + vec3 albedoCurrent6 = texture2D(colortex3, adjTC + vec2(0.0,-texelSize.y)).rgb; + vec3 albedoCurrent7 = texture2D(colortex3, adjTC + vec2(-texelSize.x,0.0)).rgb; + vec3 albedoCurrent8 = texture2D(colortex3, adjTC + vec2(texelSize.x,0.0)).rgb; + //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)))))); + albedoCurrent0 = smoothfilter(colortex3, adjTC + offsets[framemod8]*texelSize*0.5).rgb; + #endif + + #ifndef SCREENSHOT_MODE + vec3 albedoPrev = max(FastCatmulRom(colortex5, previousPosition.xy,vec4(texelSize, 1.0/texelSize), 0.75).xyz, 0.0); + vec3 finalcAcc = clamp(albedoPrev, cMin, cMax); + + //Increases blending factor when far from AABB and in motion, reduces ghosting + float isclamped = distance(albedoPrev,finalcAcc)/luma(albedoPrev) * 0.5; + float movementRejection = (0.12+isclamped)*clamp(length(velocity/texelSize),0.0,1.0); + + //Blend current pixel with clamped history, apply fast tonemap beforehand to reduce flickering + vec4 supersampled = vec4(invTonemap(mix(tonemap(finalcAcc), tonemap(albedoCurrent0), clamp(BLEND_FACTOR + movementRejection, 0.0,1.0))), 1.0); + + //De-tonemap + return supersampled; + #endif + + #ifdef SCREENSHOT_MODE + vec4 albedoPrev = texture2D(colortex5, previousPosition.xy); + vec3 supersampled = albedoPrev.rgb * albedoPrev.a + albedoCurrent0; + + if (length(velocity) > 1e-6 || hideGUI < 1) return vec4(albedoCurrent0,1.0); + return vec4(supersampled/(albedoPrev.a+1.0), albedoPrev.a+1.0); + #endif +} + +void main() { +/* DRAWBUFFERS:5 */ + + gl_FragData[0].a = 1.0; + + #ifdef TAA + vec4 color = TAA_hq(); + + #ifdef SCREENSHOT_MODE + gl_FragData[0] = clamp(color, 0.0, 65000.0); + #else + gl_FragData[0] = clamp(fp10Dither(color, triangularize(interleaved_gradientNoise())), 0.0, 65000.0); + #endif + #endif + + #ifndef TAA + vec3 color = clamp(fp10Dither(texture2D(colortex3,texcoord).rgb, triangularize(interleaved_gradientNoise())),0.0,65000.); + gl_FragData[0].rgb = color; + #endif +} \ No newline at end of file diff --git a/shaders/dimensions/composite5.vsh b/shaders/dimensions/composite5.vsh index c33e780..ba15d67 100644 --- a/shaders/dimensions/composite5.vsh +++ b/shaders/dimensions/composite5.vsh @@ -1,15 +1,29 @@ -uniform float viewWidth; -uniform float viewHeight; -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// +#include "/lib/util.glsl" +#include "/lib/res_params.glsl" +varying vec2 texcoord; +flat varying float tempOffsets; +uniform sampler2D colortex4; +uniform int frameCounter; + + +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.); void main() { - //Improves performances and makes sure bloom radius stays the same at high resolution (>1080p) - vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.)); + gl_Position = ftransform(); - //*0.51 to avoid errors when sampling outside since clearing is disabled - gl_Position.xy = (gl_Position.xy*0.5+0.5)*0.26/clampedRes*vec2(1920.0,1080.)*2-1.0; + texcoord = gl_MultiTexCoord0.xy; + + tempOffsets = HaltonSeq2(frameCounter%10000); + + #ifdef TAA_UPSCALING + gl_Position.xy = (gl_Position.xy*0.5+0.5)*RENDER_SCALE*2.0-1.0; + #endif } diff --git a/shaders/dimensions/composite6.fsh b/shaders/dimensions/composite6.fsh index 4c2f776..7602216 100644 --- a/shaders/dimensions/composite6.fsh +++ b/shaders/dimensions/composite6.fsh @@ -1,22 +1,7 @@ -uniform sampler2D colortex6; +uniform sampler2D colortex5; uniform vec2 texelSize; -varying vec2 texcoord; uniform float viewWidth; uniform float viewHeight; -vec2 resScale = vec2(1920.,1080.)/max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.)); -vec3 gauss1D(vec2 coord,vec2 dir,float alpha,int maxIT){ - vec4 tot = vec4(0.); - float maxTC = 0.25*resScale.x; - float minTC = 0.; - for (int i = -maxIT;i minTC && spCoord.x < maxTC); - } - return tot.rgb/max(1.0,tot.a); -} - //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// @@ -24,34 +9,35 @@ vec3 gauss1D(vec2 coord,vec2 dir,float alpha,int maxIT){ //////////////////////////////VOID MAIN////////////////////////////// void main() { -/* DRAWBUFFERS:6 */ -vec2 texcoord = (gl_FragCoord.xy*vec2(2.0,4.0))*texelSize; -vec2 gaussDir = vec2(1.0,0.0); -gl_FragData[0].rgb = vec3(0.0); -vec2 tc2 = texcoord*vec2(2.0,1.)/2.; -if (tc2.x < 1.0*resScale.x && tc2.y <1.0*resScale.y) -gl_FragData[0].xyz = gauss1D(tc2/2,gaussDir,0.16,0); +/* DRAWBUFFERS:3 */ -vec2 tc4 = texcoord*vec2(4.0,1.)/2.-vec2(0.5*resScale.x+4.0*texelSize.x,0.)*2.0; -if (tc4.x > 0.0 && tc4.y > 0.0 && tc4.x < 1.0*resScale.x && tc4.y <1.0*resScale.y) -gl_FragData[0].xyz = gauss1D(tc4/2,gaussDir,0.16,3); +vec2 resScale = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.))/vec2(1920.,1080.); +vec2 quarterResTC = gl_FragCoord.xy*2.*resScale*texelSize; -vec2 tc8 = texcoord*vec2(8.0,1.)/2.-vec2(0.75*resScale.x+8.*texelSize.x,0.)*4.0; -if (tc8.x > 0.0 && tc8.y > 0.0 && tc8.x < 1.0*resScale.x && tc8.y <1.0*resScale.y) -gl_FragData[0].xyz = gauss1D(tc8/2,gaussDir,0.035,6); + //0.5 + gl_FragData[0] = texture2D(colortex5,quarterResTC-1.0*vec2(texelSize.x,texelSize.y))/4.*0.5; + gl_FragData[0] += texture2D(colortex5,quarterResTC+1.0*vec2(texelSize.x,texelSize.y))/4.*0.5; + gl_FragData[0] += texture2D(colortex5,quarterResTC+vec2(-1.0*texelSize.x,1.0*texelSize.y))/4.*0.5; + gl_FragData[0] += texture2D(colortex5,quarterResTC+vec2(1.0*texelSize.x,-1.0*texelSize.y))/4.*0.5; -vec2 tc16 = texcoord*vec2(8.0,1./2.)-vec2(0.875*resScale.x+12.*texelSize.x,0.)*8.0; -if (tc16.x > 0.0 && tc16.y > 0.0 && tc16.x < 1.0*resScale.x && tc16.y <1.0*resScale.y) -gl_FragData[0].xyz = gauss1D(tc16/2,gaussDir,0.0085,12); + //0.25 + gl_FragData[0] += texture2D(colortex5,quarterResTC-2.0*vec2(texelSize.x,0.0))/2.*0.125; + gl_FragData[0] += texture2D(colortex5,quarterResTC+2.0*vec2(0.0,texelSize.y))/2.*0.125; + gl_FragData[0] += texture2D(colortex5,quarterResTC+2.0*vec2(0,-texelSize.y))/2*0.125; + gl_FragData[0] += texture2D(colortex5,quarterResTC+2.0*vec2(-texelSize.x,0.0))/2*0.125; -vec2 tc32 = texcoord*vec2(16.0,1./2.)-vec2(0.9375*resScale.x+16.*texelSize.x,0.)*16.0; -if (tc32.x > 0.0 && tc32.y > 0.0 && tc32.x < 1.0*resScale.x && tc32.y <1.0*resScale.y) -gl_FragData[0].xyz = gauss1D(tc32/2,gaussDir,0.002,28); + //0.125 + gl_FragData[0] += texture2D(colortex5,quarterResTC-2.0*vec2(texelSize.x,texelSize.y))/4.*0.125; + gl_FragData[0] += texture2D(colortex5,quarterResTC+2.0*vec2(texelSize.x,texelSize.y))/4.*0.125; + gl_FragData[0] += texture2D(colortex5,quarterResTC+vec2(-2.0*texelSize.x,2.0*texelSize.y))/4.*0.125; + gl_FragData[0] += texture2D(colortex5,quarterResTC+vec2(2.0*texelSize.x,-2.0*texelSize.y))/4.*0.125; + + //0.125 + gl_FragData[0] += texture2D(colortex5,quarterResTC)*0.125; + + gl_FragData[0].rgb = clamp(gl_FragData[0].rgb,0.0,65000.); + if (quarterResTC.x > 1.0 - 3.5*texelSize.x || quarterResTC.y > 1.0 -3.5*texelSize.y || quarterResTC.x < 3.5*texelSize.x || quarterResTC.y < 3.5*texelSize.y) gl_FragData[0].rgb = vec3(0.0); -vec2 tc64 = texcoord*vec2(32.0,1./2.)-vec2(0.96875*resScale.x+20.*texelSize.x,0.)*32.0; -if (tc64.x > 0.0 && tc64.y > 0.0 && tc64.x < 1.0*resScale.x && tc64.y <1.0*resScale.y) -gl_FragData[0].xyz = gauss1D(tc64/2,gaussDir,0.0005,60); -gl_FragData[0].rgb = clamp(gl_FragData[0].rgb,0.0,65000.); } diff --git a/shaders/dimensions/composite6.vsh b/shaders/dimensions/composite6.vsh index cbc9838..7a54acb 100644 --- a/shaders/dimensions/composite6.vsh +++ b/shaders/dimensions/composite6.vsh @@ -1,6 +1,5 @@ uniform float viewWidth; uniform float viewHeight; -varying vec2 texcoord; //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// @@ -8,11 +7,9 @@ varying vec2 texcoord; //////////////////////////////VOID MAIN////////////////////////////// void main() { - vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.0)); + //Improves performances and makes sure bloom radius stays the same at high resolution (>1080p) + vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.)); gl_Position = ftransform(); - //0-0.25 - gl_Position.y = (gl_Position.y*0.5+0.5)*0.25/clampedRes.y*1080.0*2.0-1.0; - //0-0.5 - gl_Position.x = (gl_Position.x*0.5+0.5)*0.5/clampedRes.x*1920.0*2.0-1.0; - texcoord = gl_MultiTexCoord0.xy/clampedRes*vec2(1920.,1080.); + //*0.51 to avoid errors when sampling outside since clearing is disabled + gl_Position.xy = (gl_Position.xy*0.5+0.5)*0.51/clampedRes*vec2(1920.0,1080.)*2.0-1.0; } diff --git a/shaders/dimensions/composite7.fsh b/shaders/dimensions/composite7.fsh index 656f295..a76a667 100644 --- a/shaders/dimensions/composite7.fsh +++ b/shaders/dimensions/composite7.fsh @@ -1,21 +1,7 @@ -uniform sampler2D colortex6; +uniform sampler2D colortex3; uniform vec2 texelSize; -varying vec2 texcoord; uniform float viewWidth; uniform float viewHeight; -vec2 resScale = vec2(1920.,1080.)/max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.)); -vec3 gauss1D(vec2 coord,vec2 dir,float alpha,int maxIT){ - vec4 tot = vec4(0.); - float maxTC = 0.25*resScale.y; - float minTC = 0.; - for (int i = -maxIT;i minTC && spCoord.y < maxTC); - } - return tot.rgb/max(1.0,tot.a); -} - //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// @@ -23,34 +9,34 @@ vec3 gauss1D(vec2 coord,vec2 dir,float alpha,int maxIT){ //////////////////////////////VOID MAIN////////////////////////////// void main() { + /* DRAWBUFFERS:6 */ -vec2 texcoord = (gl_FragCoord.xy*vec2(2.0,4.0))*texelSize; +vec2 resScale = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.))/vec2(1920.,1080.); +vec2 quarterResTC = gl_FragCoord.xy*2.*texelSize; -vec2 gaussDir = vec2(0.0,1.0); -gl_FragData[0].rgb = vec3(0.0); -vec2 tc2 = texcoord*vec2(2.0,1.); -if (tc2.x < 1.0*resScale.x && tc2.y <1.0*resScale.y) -gl_FragData[0].xyz = gauss1D(texcoord/vec2(2.0,4.0),gaussDir,0.16,0); + //0.5 + gl_FragData[0] = texture2D(colortex3,quarterResTC-1.0*vec2(texelSize.x,texelSize.y))/4.*0.5; + gl_FragData[0] += texture2D(colortex3,quarterResTC+1.0*vec2(texelSize.x,texelSize.y))/4.*0.5; + gl_FragData[0] += texture2D(colortex3,quarterResTC+vec2(-1.0*texelSize.x,1.0*texelSize.y))/4.*0.5; + gl_FragData[0] += texture2D(colortex3,quarterResTC+vec2(1.0*texelSize.x,-1.0*texelSize.y))/4.*0.5; -vec2 tc4 = texcoord*vec2(4.0,2.)-vec2(0.5*resScale.x+4.0*texelSize.x,0.)*4.0; -if (tc4.x > 0.0 && tc4.y > 0.0 && tc4.x < 1.0*resScale.x && tc4.y <1.0*resScale.y) -gl_FragData[0].xyz = gauss1D(texcoord/vec2(2.0,2.0),gaussDir,0.16,3); + //0.25 + gl_FragData[0] += texture2D(colortex3,quarterResTC-2.0*vec2(texelSize.x,0.0))/2.*0.125; + gl_FragData[0] += texture2D(colortex3,quarterResTC+2.0*vec2(0.0,texelSize.y))/2.*0.125; + gl_FragData[0] += texture2D(colortex3,quarterResTC+2.0*vec2(0,-texelSize.y))/2*0.125; + gl_FragData[0] += texture2D(colortex3,quarterResTC+2.0*vec2(-texelSize.x,0.0))/2*0.125; -vec2 tc8 = texcoord*vec2(8.0,4.)-vec2(0.75*resScale.x+8.*texelSize.x,0.)*8.0; -if (tc8.x > 0.0 && tc8.y > 0.0 && tc8.x < 1.0*resScale.x && tc8.y <1.0*resScale.y) -gl_FragData[0].xyz = gauss1D(texcoord*vec2(1.0,2.0)/vec2(2.0,2.0),gaussDir,0.035,6); + //0.125 + gl_FragData[0] += texture2D(colortex3,quarterResTC-2.0*vec2(texelSize.x,texelSize.y))/4.*0.125; + gl_FragData[0] += texture2D(colortex3,quarterResTC+2.0*vec2(texelSize.x,texelSize.y))/4.*0.125; + gl_FragData[0] += texture2D(colortex3,quarterResTC+vec2(-2.0*texelSize.x,2.0*texelSize.y))/4.*0.125; + gl_FragData[0] += texture2D(colortex3,quarterResTC+vec2(2.0*texelSize.x,-2.0*texelSize.y))/4.*0.125; -vec2 tc16 = texcoord*vec2(16.0,8.)-vec2(0.875*resScale.x+12.*texelSize.x,0.)*16.0; -if (tc16.x > 0.0 && tc16.y > 0.0 && tc16.x < 1.0*resScale.x && tc16.y <1.0*resScale.y) -gl_FragData[0].xyz = gauss1D(texcoord*vec2(1.0,4.0)/vec2(2.0,2.0),gaussDir,0.0085,12); + //0.125 + gl_FragData[0] += texture2D(colortex3,quarterResTC)*0.125; + + gl_FragData[0].rgb = clamp(gl_FragData[0].rgb,0.0,65000.); -vec2 tc32 = texcoord*vec2(32.0,16.)-vec2(0.9375*resScale.x+16.*texelSize.x,0.)*32.0; -if (tc32.x > 0.0 && tc32.y > 0.0 && tc32.x < 1.0*resScale.x && tc32.y <1.0*resScale.y) -gl_FragData[0].xyz = gauss1D(texcoord*vec2(1.0,8.0)/vec2(2.0,2.0),gaussDir,0.002,30); -vec2 tc64 = texcoord*vec2(64.0,32.)-vec2(0.96875*resScale.x+20.*texelSize.x,0.)*64.0; -if (tc64.x > 0.0 && tc64.y > 0.0 && tc64.x < 1.0*resScale.x && tc64.y <1.0*resScale.y) -gl_FragData[0].xyz = gauss1D(texcoord*vec2(1.0,16.0)/vec2(2.0,2.0),gaussDir,0.0005,60); -gl_FragData[0].rgb = clamp(gl_FragData[0].rgb,0.0,65000.); } diff --git a/shaders/dimensions/composite7.vsh b/shaders/dimensions/composite7.vsh index 366226a..c33e780 100644 --- a/shaders/dimensions/composite7.vsh +++ b/shaders/dimensions/composite7.vsh @@ -1,6 +1,5 @@ uniform float viewWidth; uniform float viewHeight; -varying vec2 texcoord; //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// @@ -8,12 +7,9 @@ varying vec2 texcoord; //////////////////////////////VOID MAIN////////////////////////////// void main() { - vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.0)); + //Improves performances and makes sure bloom radius stays the same at high resolution (>1080p) + vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.)); gl_Position = ftransform(); - //0-0.25 - gl_Position.y = (gl_Position.y*0.5+0.5)*0.25/clampedRes.y*1080.0*2.0-1.0; - //0-0.5 - gl_Position.x = (gl_Position.x*0.5+0.5)*0.5/clampedRes.x*1920.0*2.0-1.0; - texcoord = gl_MultiTexCoord0.xy/clampedRes*vec2(1920.,1080.); - + //*0.51 to avoid errors when sampling outside since clearing is disabled + gl_Position.xy = (gl_Position.xy*0.5+0.5)*0.26/clampedRes*vec2(1920.0,1080.)*2-1.0; } diff --git a/shaders/dimensions/composite8.fsh b/shaders/dimensions/composite8.fsh index 49a54fb..4c2f776 100644 --- a/shaders/dimensions/composite8.fsh +++ b/shaders/dimensions/composite8.fsh @@ -1,73 +1,20 @@ -uniform sampler2D colortex3; uniform sampler2D colortex6; - uniform vec2 texelSize; +varying vec2 texcoord; uniform float viewWidth; uniform float viewHeight; - -float w0(float a) -{ - return (1.0/6.0)*(a*(a*(-a + 3.0) - 3.0) + 1.0); -} - -float w1(float a) -{ - return (1.0/6.0)*(a*a*(3.0*a - 6.0) + 4.0); -} - -float w2(float a) -{ - return (1.0/6.0)*(a*(a*(-3.0*a + 3.0) + 3.0) + 1.0); -} - -float w3(float a) -{ - return (1.0/6.0)*(a*a*a); -} - -float g0(float a) -{ - return w0(a) + w1(a); -} - -float g1(float a) -{ - return w2(a) + w3(a); -} - -float h0(float a) -{ - return -1.0 + w1(a) / (w0(a) + w1(a)); -} - -float h1(float a) -{ - return 1.0 + w3(a) / (w2(a) + w3(a)); -} - -vec4 texture2D_bicubic(sampler2D tex, vec2 uv) -{ - vec4 texelSize = vec4(texelSize,1.0/texelSize); - uv = uv*texelSize.zw; - vec2 iuv = floor( uv ); - vec2 fuv = fract( uv ); - - float g0x = g0(fuv.x); - float g1x = g1(fuv.x); - float h0x = h0(fuv.x); - float h1x = h1(fuv.x); - float h0y = h0(fuv.y); - float h1y = h1(fuv.y); - - vec2 p0 = (vec2(iuv.x + h0x, iuv.y + h0y) - 0.5) * texelSize.xy; - vec2 p1 = (vec2(iuv.x + h1x, iuv.y + h0y) - 0.5) * texelSize.xy; - vec2 p2 = (vec2(iuv.x + h0x, iuv.y + h1y) - 0.5) * texelSize.xy; - vec2 p3 = (vec2(iuv.x + h1x, iuv.y + h1y) - 0.5) * texelSize.xy; - - return g0(fuv.y) * (g0x * texture2D(tex, p0) + - g1x * texture2D(tex, p1)) + - g1(fuv.y) * (g0x * texture2D(tex, p2) + - g1x * texture2D(tex, p3)); +vec2 resScale = vec2(1920.,1080.)/max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.)); +vec3 gauss1D(vec2 coord,vec2 dir,float alpha,int maxIT){ + vec4 tot = vec4(0.); + float maxTC = 0.25*resScale.x; + float minTC = 0.; + for (int i = -maxIT;i minTC && spCoord.x < maxTC); + } + return tot.rgb/max(1.0,tot.a); } //////////////////////////////VOID MAIN////////////////////////////// @@ -77,24 +24,34 @@ vec4 texture2D_bicubic(sampler2D tex, vec2 uv) //////////////////////////////VOID MAIN////////////////////////////// void main() { -/* DRAWBUFFERS:3 */ -vec2 resScale = vec2(1920.,1080.)/max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.)); -vec2 texcoord = ((gl_FragCoord.xy)*2.+0.5)*texelSize; -vec3 bloom = texture2D_bicubic(colortex3,texcoord/2.0).rgb; //1/4 res +/* DRAWBUFFERS:6 */ -bloom += texture2D_bicubic(colortex6,texcoord/4.).rgb; //1/8 res +vec2 texcoord = (gl_FragCoord.xy*vec2(2.0,4.0))*texelSize; +vec2 gaussDir = vec2(1.0,0.0); +gl_FragData[0].rgb = vec3(0.0); +vec2 tc2 = texcoord*vec2(2.0,1.)/2.; +if (tc2.x < 1.0*resScale.x && tc2.y <1.0*resScale.y) +gl_FragData[0].xyz = gauss1D(tc2/2,gaussDir,0.16,0); -bloom += texture2D_bicubic(colortex6,texcoord/8.+vec2(0.25*resScale.x+2.5*texelSize.x,.0)).rgb; //1/16 res +vec2 tc4 = texcoord*vec2(4.0,1.)/2.-vec2(0.5*resScale.x+4.0*texelSize.x,0.)*2.0; +if (tc4.x > 0.0 && tc4.y > 0.0 && tc4.x < 1.0*resScale.x && tc4.y <1.0*resScale.y) +gl_FragData[0].xyz = gauss1D(tc4/2,gaussDir,0.16,3); -bloom += texture2D_bicubic(colortex6,texcoord/16.+vec2(0.375*resScale.x+4.5*texelSize.x,.0)).rgb; //1/32 res +vec2 tc8 = texcoord*vec2(8.0,1.)/2.-vec2(0.75*resScale.x+8.*texelSize.x,0.)*4.0; +if (tc8.x > 0.0 && tc8.y > 0.0 && tc8.x < 1.0*resScale.x && tc8.y <1.0*resScale.y) +gl_FragData[0].xyz = gauss1D(tc8/2,gaussDir,0.035,6); -bloom += texture2D_bicubic(colortex6,texcoord/32.+vec2(0.4375*resScale.x+6.5*texelSize.x,.0)).rgb*1.0; //1/64 res -bloom += texture2D_bicubic(colortex6,texcoord/64.+vec2(0.46875*resScale.x+8.5*texelSize.x,.0)).rgb*1.0; //1/128 res -bloom += texture2D_bicubic(colortex6,texcoord/128.+vec2(0.484375*resScale.x+10.5*texelSize.x,.0)).rgb*1.0; //1/256 res +vec2 tc16 = texcoord*vec2(8.0,1./2.)-vec2(0.875*resScale.x+12.*texelSize.x,0.)*8.0; +if (tc16.x > 0.0 && tc16.y > 0.0 && tc16.x < 1.0*resScale.x && tc16.y <1.0*resScale.y) +gl_FragData[0].xyz = gauss1D(tc16/2,gaussDir,0.0085,12); -//bloom = texture2D_bicubic(colortex6,texcoord).rgb*6.; //1/8 res +vec2 tc32 = texcoord*vec2(16.0,1./2.)-vec2(0.9375*resScale.x+16.*texelSize.x,0.)*16.0; +if (tc32.x > 0.0 && tc32.y > 0.0 && tc32.x < 1.0*resScale.x && tc32.y <1.0*resScale.y) +gl_FragData[0].xyz = gauss1D(tc32/2,gaussDir,0.002,28); -gl_FragData[0].rgb = bloom*2.; +vec2 tc64 = texcoord*vec2(32.0,1./2.)-vec2(0.96875*resScale.x+20.*texelSize.x,0.)*32.0; +if (tc64.x > 0.0 && tc64.y > 0.0 && tc64.x < 1.0*resScale.x && tc64.y <1.0*resScale.y) +gl_FragData[0].xyz = gauss1D(tc64/2,gaussDir,0.0005,60); gl_FragData[0].rgb = clamp(gl_FragData[0].rgb,0.0,65000.); } diff --git a/shaders/dimensions/composite8.vsh b/shaders/dimensions/composite8.vsh index 7a54acb..cbc9838 100644 --- a/shaders/dimensions/composite8.vsh +++ b/shaders/dimensions/composite8.vsh @@ -1,5 +1,6 @@ uniform float viewWidth; uniform float viewHeight; +varying vec2 texcoord; //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// @@ -7,9 +8,11 @@ uniform float viewHeight; //////////////////////////////VOID MAIN////////////////////////////// void main() { - //Improves performances and makes sure bloom radius stays the same at high resolution (>1080p) - vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.)); + vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.0)); gl_Position = ftransform(); - //*0.51 to avoid errors when sampling outside since clearing is disabled - gl_Position.xy = (gl_Position.xy*0.5+0.5)*0.51/clampedRes*vec2(1920.0,1080.)*2.0-1.0; + //0-0.25 + gl_Position.y = (gl_Position.y*0.5+0.5)*0.25/clampedRes.y*1080.0*2.0-1.0; + //0-0.5 + gl_Position.x = (gl_Position.x*0.5+0.5)*0.5/clampedRes.x*1920.0*2.0-1.0; + texcoord = gl_MultiTexCoord0.xy/clampedRes*vec2(1920.,1080.); } diff --git a/shaders/dimensions/composite9.fsh b/shaders/dimensions/composite9.fsh index 02e5034..656f295 100644 --- a/shaders/dimensions/composite9.fsh +++ b/shaders/dimensions/composite9.fsh @@ -1,473 +1,56 @@ -#include "/lib/settings.glsl" - -#ifdef DOF - //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 )); - - const vec2 offsets[60] = vec2[60] ( 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.2165, 0.1250 ), - vec2( 0.0000, 0.5000 ), - vec2( -0.2500, 0.4330 ), - vec2( -0.4330, 0.2500 ), - vec2( -0.5000, 0.0000 ), - vec2( -0.4330, -0.2500 ), - vec2( -0.2500, -0.4330 ), - vec2( -0.0000, -0.5000 ), - vec2( 0.2500, -0.4330 ), - vec2( 0.4330, -0.2500 ), - vec2( 0.5000, -0.0000 ), - vec2( 0.4330, 0.2500 ), - vec2( 0.2500, 0.4330 ), - vec2( 0.0000, 0.7500 ), - vec2( -0.2565, 0.7048 ), - vec2( -0.4821, 0.5745 ), - vec2( -0.6495, 0.3750 ), - vec2( -0.7386, 0.1302 ), - vec2( -0.7386, -0.1302 ), - vec2( -0.6495, -0.3750 ), - vec2( -0.4821, -0.5745 ), - vec2( -0.2565, -0.7048 ), - vec2( -0.0000, -0.7500 ), - vec2( 0.2565, -0.7048 ), - vec2( 0.4821, -0.5745 ), - vec2( 0.6495, -0.3750 ), - vec2( 0.7386, -0.1302 ), - vec2( 0.7386, 0.1302 ), - vec2( 0.6495, 0.3750 ), - vec2( 0.4821, 0.5745 ), - vec2( 0.2565, 0.7048 ), - vec2( 0.0000, 1.0000 ), - vec2( -0.2588, 0.9659 ), - vec2( -0.5000, 0.8660 ), - vec2( -0.7071, 0.7071 ), - vec2( -0.8660, 0.5000 ), - vec2( -0.9659, 0.2588 ), - vec2( -1.0000, 0.0000 ), - vec2( -0.9659, -0.2588 ), - vec2( -0.8660, -0.5000 ), - vec2( -0.7071, -0.7071 ), - vec2( -0.5000, -0.8660 ), - vec2( -0.2588, -0.9659 ), - vec2( -0.0000, -1.0000 ), - vec2( 0.2588, -0.9659 ), - vec2( 0.5000, -0.8660 ), - vec2( 0.7071, -0.7071 ), - vec2( 0.8660, -0.5000 ), - vec2( 0.9659, -0.2588 ), - vec2( 1.0000, -0.0000 ), - vec2( 0.9659, 0.2588 ), - vec2( 0.8660, 0.5000 ), - vec2( 0.7071, 0.7071 ), - vec2( 0.5000, 0.8660 ), - vec2( 0.2588, 0.9659 )); - -const vec2 shadow_offsets[209] = vec2[209](vec2(0.8886414f , 0.07936136f), -vec2(0.8190064f , 0.1900164f), -vec2(0.8614115f , -0.06991258f), -vec2(0.7685533f , 0.03792081f), -vec2(0.9970094f , 0.02585129f), -vec2(0.9686818f , 0.1570935f), -vec2(0.9854341f , -0.09172997f), -vec2(0.9330608f , 0.3326486f), -vec2(0.8329557f , -0.2438523f), -vec2(0.664771f , -0.0837701f), -vec2(0.7429124f , -0.1530652f), -vec2(0.9506453f , -0.2174281f), -vec2(0.8192949f , 0.3485171f), -vec2(0.6851269f , 0.2711877f), -vec2(0.7665657f , 0.5014166f), -vec2(0.673241f , 0.3793408f), -vec2(0.6981376f , 0.1465924f), -vec2(0.6521665f , -0.2384985f), -vec2(0.5145761f , -0.05752508f), -vec2(0.5641244f , -0.169443f), -vec2(0.5916035f , 0.06004957f), -vec2(0.57079f , 0.234188f), -vec2(0.509311f , 0.1523665f), -vec2(0.4204576f , 0.05759521f), -vec2(0.8200846f , -0.3601041f), -vec2(0.6893264f , -0.3473432f), -vec2(0.4775535f , -0.3062558f), -vec2(0.438106f , -0.1796866f), -vec2(0.4056528f , -0.08251233f), -vec2(0.5771964f , 0.5502692f), -vec2(0.5094061f , 0.4025192f), -vec2(0.6908483f , 0.572951f), -vec2(0.5379036f , -0.4542191f), -vec2(0.8167359f , -0.4793735f), -vec2(0.6829269f , -0.4557574f), -vec2(0.5725697f , -0.3477072f), -vec2(0.5767449f , -0.5782524f), -vec2(0.3979413f , -0.4172934f), -vec2(0.4282598f , -0.5145645f), -vec2(0.938814f , -0.3239739f), -vec2(0.702452f , -0.5662871f), -vec2(0.2832307f , -0.1285671f), -vec2(0.3230537f , -0.2691054f), -vec2(0.2921676f , -0.3734582f), -vec2(0.2534037f , -0.4906001f), -vec2(0.4343273f , 0.5223463f), -vec2(0.3605334f , 0.3151571f), -vec2(0.3498518f , 0.451428f), -vec2(0.3230703f , 0.00287089f), -vec2(0.1049206f , -0.1476725f), -vec2(0.2063161f , -0.2608192f), -vec2(0.7266634f , 0.6725333f), -vec2(0.4027067f , -0.6185485f), -vec2(0.2655533f , -0.5912259f), -vec2(0.4947965f , 0.3025357f), -vec2(0.5760762f , 0.68844f), -vec2(0.4909205f , -0.6975324f), -vec2(0.8609334f , 0.4559f), -vec2(0.1836646f , 0.03724086f), -vec2(0.2878554f , 0.178938f), -vec2(0.3948484f , 0.1618928f), -vec2(0.3519658f , -0.7628763f), -vec2(0.6338583f , -0.673193f), -vec2(0.5511802f , -0.8283072f), -vec2(0.4090595f , -0.8717521f), -vec2(0.1482169f , -0.374728f), -vec2(0.1050598f , -0.2613987f), -vec2(0.4210334f , 0.6578422f), -vec2(0.2430464f , 0.4383665f), -vec2(0.3329675f , 0.5512741f), -vec2(0.2147711f , 0.3245511f), -vec2(0.1227196f , 0.2529026f), -vec2(-0.03937457f , 0.156439f), -vec2(0.05618772f , 0.06690486f), -vec2(0.06519571f , 0.3974038f), -vec2(0.1360903f , 0.1466078f), -vec2(-0.00170609f , 0.3089452f), -vec2(0.1357622f , -0.5088975f), -vec2(0.1604694f , -0.7453476f), -vec2(0.1245694f , -0.6337074f), -vec2(0.02542936f , -0.3728781f), -vec2(0.02222222f , -0.649554f), -vec2(0.09870815f , 0.5357338f), -vec2(0.2073958f , 0.5452989f), -vec2(0.216654f , -0.8935689f), -vec2(0.2422334f , 0.665805f), -vec2(0.0574713f , 0.6742729f), -vec2(0.2021346f , 0.8144029f), -vec2(0.3086587f , 0.7504997f), -vec2(0.02122174f , -0.7498575f), -vec2(-0.1551729f , 0.1809731f), -vec2(-0.1947583f , 0.06246066f), -vec2(-0.05754202f , -0.03901273f), -vec2(-0.1083095f , 0.2952235f), -vec2(-0.03259534f , -0.492394f), -vec2(-0.02488567f , -0.2081116f), -vec2(-0.1820729f , -0.1829884f), -vec2(-0.1674413f , -0.04529009f), -vec2(0.04342153f , -0.0368562f), -vec2(0.801399f , -0.5845526f), -vec2(0.3158276f , -0.9124843f), -vec2(-0.05945269f , 0.6727523f), -vec2(0.07701834f , 0.8579889f), -vec2(-0.05778154f , 0.5699022f), -vec2(0.1191713f , 0.7542591f), -vec2(-0.2578296f , 0.3630984f), -vec2(-0.1428598f , 0.4557526f), -vec2(-0.3304029f , 0.5055485f), -vec2(-0.3227198f , 0.1847367f), -vec2(-0.4183801f , 0.3412776f), -vec2(0.2538475f , 0.9317476f), -vec2(0.406249f , 0.8423664f), -vec2(0.4718862f , 0.7592828f), -vec2(0.168472f , -0.06605823f), -vec2(0.2632498f , -0.7084918f), -vec2(-0.2816192f , -0.1023492f), -vec2(-0.3161443f , 0.02489911f), -vec2(-0.4677814f , 0.08450397f), -vec2(-0.4156994f , 0.2408664f), -vec2(-0.237449f , 0.2605326f), -vec2(-0.0912179f , 0.06491816f), -vec2(0.01475127f , 0.7670643f), -vec2(0.1216858f , -0.9368939f), -vec2(0.07010741f , -0.841011f), -vec2(-0.1708607f , -0.4152923f), -vec2(-0.1345006f , -0.5842513f), -vec2(-0.09419055f , -0.3213732f), -vec2(-0.2149337f , 0.730642f), -vec2(-0.1102187f , 0.8425013f), -vec2(-0.1808572f , 0.6244397f), -vec2(-0.2414505f , -0.7063725f), -vec2(-0.2410318f , -0.537854f), -vec2(-0.1005938f , -0.7635075f), -vec2(0.1053517f , 0.9678772f), -vec2(-0.3340288f , 0.6926677f), -vec2(-0.2363931f , 0.8464488f), -vec2(-0.4057773f , 0.7786722f), -vec2(-0.5484858f , 0.1686208f), -vec2(-0.64842f , 0.02256887f), -vec2(-0.5544513f , -0.02348978f), -vec2(-0.492855f , -0.1083694f), -vec2(-0.4248196f , 0.4674786f), -vec2(-0.5873146f , 0.4072608f), -vec2(-0.6439911f , 0.3038489f), -vec2(-0.6419188f , 0.1293737f), -vec2(-0.005880734f , 0.4699725f), -vec2(-0.4239455f , 0.6250131f), -vec2(-0.1701273f , 0.9506347f), -vec2(7.665656E-05f , 0.9941212f), -vec2(-0.7070159f , 0.4426281f), -vec2(-0.7481344f , 0.3139496f), -vec2(-0.8330062f , 0.2472693f), -vec2(-0.7271438f , 0.2024286f), -vec2(-0.5179888f , 0.3149576f), -vec2(-0.8258062f , 0.3779382f), -vec2(-0.8063191f , 0.1262931f), -vec2(-0.2690676f , -0.4360798f), -vec2(-0.3714577f , -0.5887412f), -vec2(-0.3736085f , -0.4018324f), -vec2(-0.3228985f , -0.2063406f), -vec2(-0.2414576f , -0.2875458f), -vec2(-0.4720859f , -0.3823904f), -vec2(-0.4937642f , -0.2686005f), -vec2(-0.01500604f , -0.9587054f), -vec2(-0.08535925f , -0.8820614f), -vec2(-0.6436375f , -0.3157263f), -vec2(-0.5736347f , -0.4224878f), -vec2(-0.5026127f , -0.5516239f), -vec2(-0.8200902f , 0.5370023f), -vec2(-0.7196413f , 0.57133f), -vec2(-0.5849072f , 0.5917885f), -vec2(-0.1598758f , -0.9739854f), -vec2(-0.4230629f , -0.01858409f), -vec2(-0.9403627f , 0.2213769f), -vec2(-0.685889f , -0.2192711f), -vec2(-0.6693704f , -0.4884708f), -vec2(-0.7967147f , -0.3078234f), -vec2(-0.596441f , -0.1686891f), -vec2(-0.7366468f , -0.3939891f), -vec2(-0.7963406f , 0.02246814f), -vec2(-0.9177913f , 0.0929693f), -vec2(-0.9284672f , 0.3329005f), -vec2(-0.6497722f , 0.6851863f), -vec2(-0.496019f , 0.7013303f), -vec2(-0.3930301f , -0.6892192f), -vec2(-0.2122009f , -0.8777389f), -vec2(-0.3660335f , -0.801644f), -vec2(-0.386839f , -0.1191898f), -vec2(-0.7020127f , -0.0776734f), -vec2(-0.7760845f , -0.1566844f), -vec2(-0.5444778f , -0.6516482f), -vec2(-0.5331346f , 0.4946506f), -vec2(-0.3288236f , 0.9408244f), -vec2(0.5819826f , 0.8101937f), -vec2(-0.4894184f , -0.8290837f), -vec2(-0.5183194f , 0.8454953f), -vec2(-0.7665774f , -0.5223897f), -vec2(-0.6703191f , -0.6217513f), -vec2(-0.8902924f , -0.2446688f), -vec2(-0.8574848f , -0.09174173f), -vec2(-0.3544409f , -0.9239591f), -vec2(-0.969833f , -0.1172272f), -vec2(-0.8968207f , -0.4079512f), -vec2(-0.5891477f , 0.7724466f), -vec2(-0.2146262f , 0.5286855f), -vec2(-0.3762444f , -0.3014335f), -vec2(-0.9466863f , -0.008970681f), -vec2(-0.596356f , -0.7976127f), -vec2(-0.8877738f , 0.4569088f)); -#endif -flat varying vec4 exposure; -flat varying float rodExposure; -varying vec2 texcoord; -uniform sampler2D colortex4; -uniform sampler2D colortex5; -uniform sampler2D colortex3; -uniform sampler2D colortex7; -uniform sampler2D depthtex0; -uniform sampler2D noisetex; +uniform sampler2D colortex6; uniform vec2 texelSize; - +varying vec2 texcoord; uniform float viewWidth; uniform float viewHeight; -uniform float frameTimeCounter; -uniform int frameCounter; -uniform int isEyeInWater; -uniform float near; -uniform float aspectRatio; -uniform float far; - - -#include "/lib/color_transforms.glsl" -#include "/lib/color_dither.glsl" - - - -float cdist(vec2 coord) { - return max(abs(coord.s-0.5),abs(coord.t-0.5))*2.0; +vec2 resScale = vec2(1920.,1080.)/max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.)); +vec3 gauss1D(vec2 coord,vec2 dir,float alpha,int maxIT){ + vec4 tot = vec4(0.); + float maxTC = 0.25*resScale.y; + float minTC = 0.; + for (int i = -maxIT;i minTC && spCoord.y < maxTC); + } + return tot.rgb/max(1.0,tot.a); } -float blueNoise(){ - return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter); -} -float ld(float depth) { - return (2.0 * near) / (far + near - depth * (far - near)); // (-depth * (far - near)) = (2.0 * near)/ld - far - near -} -vec3 closestToCamera3x3() -{ - vec2 du = vec2(texelSize.x, 0.0); - vec2 dv = vec2(0.0, texelSize.y); - vec3 dtl = vec3(texcoord,0.) + vec3(-texelSize, texture2D(depthtex0, texcoord - dv - du).x); - vec3 dtc = vec3(texcoord,0.) + vec3( 0.0, -texelSize.y, texture2D(depthtex0, texcoord - dv).x); - vec3 dtr = vec3(texcoord,0.) + vec3( texelSize.x, -texelSize.y, texture2D(depthtex0, texcoord - dv + du).x); +//////////////////////////////VOID MAIN////////////////////////////// +//////////////////////////////VOID MAIN////////////////////////////// +//////////////////////////////VOID MAIN////////////////////////////// +//////////////////////////////VOID MAIN////////////////////////////// +//////////////////////////////VOID MAIN////////////////////////////// - vec3 dml = vec3(texcoord,0.) + vec3(-texelSize.x, 0.0, texture2D(depthtex0, texcoord - du).x); - vec3 dmc = vec3(texcoord,0.) + vec3( 0.0, 0.0, texture2D(depthtex0, texcoord).x); - vec3 dmr = vec3(texcoord,0.) + vec3( texelSize.x, 0.0, texture2D(depthtex0, texcoord + du).x); - - vec3 dbl = vec3(texcoord,0.) + vec3(-texelSize.x, texelSize.y, texture2D(depthtex0, texcoord + dv - du).x); - vec3 dbc = vec3(texcoord,0.) + vec3( 0.0, texelSize.y, texture2D(depthtex0, texcoord + dv).x); - vec3 dbr = vec3(texcoord,0.) + vec3( texelSize.x, texelSize.y, texture2D(depthtex0, texcoord + dv + du).x); - - vec3 dmin = dmc; - - dmin = dmin.z > dtc.z? dtc : dmin; - dmin = dmin.z > dtr.z? dtr : dmin; - - dmin = dmin.z > dml.z? dml : dmin; - dmin = dmin.z > dtl.z? dtl : dmin; - dmin = dmin.z > dmr.z? dmr : dmin; - - dmin = dmin.z > dbl.z? dbl : dmin; - dmin = dmin.z > dbc.z? dbc : dmin; - dmin = dmin.z > dbr.z? dbr : dmin; - - return dmin; -} void main() { - /* DRAWBUFFERS:7 */ - float vignette = (1.5-dot(texcoord-0.5,texcoord-0.5)*2.5); - vec3 col = texture2D(colortex5,texcoord).rgb; - #ifdef DOF - /*--------------------------------*/ - float z = ld(texture2D(depthtex0, texcoord.st).r)*far; - #ifdef AUTOFOCUS - float focus = ld(texture2D(depthtex0, vec2(0.5)).r)*far; - #else - float focus = MANUAL_FOCUS; - #endif - float pcoc = min(abs(aperture * (focal/100.0 * (z - focus)) / (z * (focus - focal/100.0))),texelSize.x*15.0); - #ifdef FAR_BLUR_ONLY - pcoc *= float(z > focus); - #endif - float noise = blueNoise()*6.28318530718; - mat2 noiseM = mat2( cos( noise ), -sin( noise ), - sin( noise ), cos( noise ) - ); - vec3 bcolor = vec3(0.); - float nb = 0.0; - vec2 bcoord = vec2(0.0); - /*--------------------------------*/ - #ifndef HQ_DOF - bcolor = col; - #ifdef HEXAGONAL_BOKEH - for ( int i = 0; i < 60; i++) { - bcolor += texture2D(colortex5, texcoord.xy + hex_offsets[i]*pcoc*vec2(1.0,aspectRatio)).rgb; - } - col = bcolor/61.0; - #else - for ( int i = 0; i < 60; i++) { - bcolor += texture2D(colortex5, texcoord.xy + offsets[i]*pcoc*vec2(1.0,aspectRatio)).rgb; - } - /*--------------------------------*/ - col = bcolor/61.0; - #endif - #endif - #ifdef HQ_DOF - for ( int i = 0; i < 209; i++) { - bcolor += texture2D(colortex5, texcoord.xy + noiseM*shadow_offsets[i]*pcoc*vec2(1.0,aspectRatio)).rgb; - } - col = bcolor/209.0; - #endif -#endif - vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.)); +/* DRAWBUFFERS:6 */ +vec2 texcoord = (gl_FragCoord.xy*vec2(2.0,4.0))*texelSize; - vec3 bloom = texture2D(colortex3,texcoord/clampedRes*vec2(1920.,1080.)*0.5).rgb/2./7.0; +vec2 gaussDir = vec2(0.0,1.0); +gl_FragData[0].rgb = vec3(0.0); +vec2 tc2 = texcoord*vec2(2.0,1.); +if (tc2.x < 1.0*resScale.x && tc2.y <1.0*resScale.y) +gl_FragData[0].xyz = gauss1D(texcoord/vec2(2.0,4.0),gaussDir,0.16,0); - float lightScat = clamp(BLOOM_STRENGTH * 0.05 * pow(exposure.a ,0.2) ,0.0,1.0)*vignette; +vec2 tc4 = texcoord*vec2(4.0,2.)-vec2(0.5*resScale.x+4.0*texelSize.x,0.)*4.0; +if (tc4.x > 0.0 && tc4.y > 0.0 && tc4.x < 1.0*resScale.x && tc4.y <1.0*resScale.y) +gl_FragData[0].xyz = gauss1D(texcoord/vec2(2.0,2.0),gaussDir,0.16,3); - float VL_abs = texture2D(colortex7,texcoord).r; - VL_abs = clamp((1.0-VL_abs*1.05)*BLOOMY_FOG*0.5,0.0,1.0)*clamp(1.0-pow(cdist(texcoord.xy),15.0),0.0,1.0); +vec2 tc8 = texcoord*vec2(8.0,4.)-vec2(0.75*resScale.x+8.*texelSize.x,0.)*8.0; +if (tc8.x > 0.0 && tc8.y > 0.0 && tc8.x < 1.0*resScale.x && tc8.y <1.0*resScale.y) +gl_FragData[0].xyz = gauss1D(texcoord*vec2(1.0,2.0)/vec2(2.0,2.0),gaussDir,0.035,6); - col = ( mix(col, bloom, VL_abs) + bloom*lightScat) * exposure.rgb; +vec2 tc16 = texcoord*vec2(16.0,8.)-vec2(0.875*resScale.x+12.*texelSize.x,0.)*16.0; +if (tc16.x > 0.0 && tc16.y > 0.0 && tc16.x < 1.0*resScale.x && tc16.y <1.0*resScale.y) +gl_FragData[0].xyz = gauss1D(texcoord*vec2(1.0,4.0)/vec2(2.0,2.0),gaussDir,0.0085,12); +vec2 tc32 = texcoord*vec2(32.0,16.)-vec2(0.9375*resScale.x+16.*texelSize.x,0.)*32.0; +if (tc32.x > 0.0 && tc32.y > 0.0 && tc32.x < 1.0*resScale.x && tc32.y <1.0*resScale.y) +gl_FragData[0].xyz = gauss1D(texcoord*vec2(1.0,8.0)/vec2(2.0,2.0),gaussDir,0.002,30); - #ifndef USE_ACES_COLORSPACE_APPROXIMATION - col = LinearTosRGB(TONEMAP(col)); - #else - col = col * ACESInputMat; - col = TONEMAP(col); - col = LinearTosRGB(clamp(col * ACESOutputMat, 0.0, 1.0)); - #endif - //col = ACESFitted(texture2D(colortex4,texcoord/3.).rgb/500.); - gl_FragData[0].rgb = clamp(int8Dither(col,texcoord),0.0,1.0); - //if (nightMode < 0.99 && texcoord.x < 0.5) gl_FragData[0].rgb =vec3(0.0,1.0,0.0); +vec2 tc64 = texcoord*vec2(64.0,32.)-vec2(0.96875*resScale.x+20.*texelSize.x,0.)*64.0; +if (tc64.x > 0.0 && tc64.y > 0.0 && tc64.x < 1.0*resScale.x && tc64.y <1.0*resScale.y) +gl_FragData[0].xyz = gauss1D(texcoord*vec2(1.0,16.0)/vec2(2.0,2.0),gaussDir,0.0005,60); +gl_FragData[0].rgb = clamp(gl_FragData[0].rgb,0.0,65000.); } diff --git a/shaders/dimensions/composite9.vsh b/shaders/dimensions/composite9.vsh index e77b7c4..366226a 100644 --- a/shaders/dimensions/composite9.vsh +++ b/shaders/dimensions/composite9.vsh @@ -1,10 +1,6 @@ -#include "/lib/settings.glsl" - +uniform float viewWidth; +uniform float viewHeight; varying vec2 texcoord; -flat varying vec4 exposure; -flat varying float rodExposure; -uniform sampler2D colortex4; - //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// @@ -12,9 +8,12 @@ uniform sampler2D colortex4; //////////////////////////////VOID MAIN////////////////////////////// void main() { - + vec2 clampedRes = max(vec2(viewWidth,viewHeight),vec2(1920.0,1080.0)); gl_Position = ftransform(); - texcoord = gl_MultiTexCoord0.xy; - exposure=vec4(texelFetch2D(colortex4,ivec2(10,37),0).r*vec3(FinalR,FinalG,FinalB),texelFetch2D(colortex4,ivec2(10,37),0).r); - rodExposure = texelFetch2D(colortex4,ivec2(14,37),0).r; + //0-0.25 + gl_Position.y = (gl_Position.y*0.5+0.5)*0.25/clampedRes.y*1080.0*2.0-1.0; + //0-0.5 + gl_Position.x = (gl_Position.x*0.5+0.5)*0.5/clampedRes.x*1920.0*2.0-1.0; + texcoord = gl_MultiTexCoord0.xy/clampedRes*vec2(1920.,1080.); + } diff --git a/shaders/dimensions/deferred.fsh b/shaders/dimensions/deferred.fsh index 2a0e3dc..2f893b5 100644 --- a/shaders/dimensions/deferred.fsh +++ b/shaders/dimensions/deferred.fsh @@ -1,37 +1,33 @@ #include "/lib/settings.glsl" +#define ReflectedFog -// flat varying vec3 ambientUp; -// flat varying vec3 ambientLeft; -// flat varying vec3 ambientRight; -// flat varying vec3 ambientB; -// flat varying vec3 ambientF; -// flat varying vec3 ambientDown; +flat varying vec3 averageSkyCol_Clouds; +flat varying vec3 averageSkyCol; flat varying vec3 lightSourceColor; flat varying vec3 sunColor; -flat varying vec3 sunColorCloud; flat varying vec3 moonColor; -flat varying vec3 moonColorCloud; -flat varying vec3 zenithColor; -flat varying vec3 avgSky; +// flat varying vec3 zenithColor; + +flat varying vec3 WsunVec; + flat varying vec2 tempOffsets; flat varying float exposure; flat varying float rodExposure; flat varying float avgBrightness; flat varying float exposureF; -flat varying float fogAmount; -flat varying float VFAmount; -uniform sampler2D colortex4; +// uniform sampler2D colortex4; uniform sampler2D noisetex; +uniform float frameTime; uniform int frameCounter; +uniform float frameTimeCounter; uniform float rainStrength; uniform float eyeAltitude; uniform vec3 sunVec; uniform vec2 texelSize; -uniform float frameTimeCounter; uniform mat4 gbufferProjection; uniform mat4 gbufferProjectionInverse; uniform mat4 gbufferPreviousProjection; @@ -41,11 +37,15 @@ uniform mat4 shadowModelView; uniform mat4 shadowProjection; uniform float sunElevation; uniform vec3 cameraPosition; -uniform float far; +// uniform float far; uniform ivec2 eyeBrightnessSmooth; +vec4 lightCol = vec4(lightSourceColor, float(sunElevation > 1e-5)*2-1.); + #include "/lib/util.glsl" #include "/lib/ROBOBO_sky.glsl" +#include "/lib/sky_gradient.glsl" +#include "/lib/Shadow_Params.glsl" vec3 toShadowSpaceProjected(vec3 p3){ p3 = mat3(gbufferModelViewInverse) * p3 + gbufferModelViewInverse[3].xyz; @@ -64,42 +64,204 @@ float blueNoise(){ } - +#ifdef OVERWORLD_SHADER + + // const bool shadowHardwareFiltering = true; + uniform sampler2DShadow shadow; + #define TEST + #define TIMEOFDAYFOG + #include "/lib/lightning_stuff.glsl" + #include "/lib/volumetricClouds.glsl" + #include "/lib/volumetricFog.glsl" + +#endif +#ifdef NETHER_SHADER + uniform sampler2D colortex4; + #include "/lib/nether_fog.glsl" +#endif #ifdef END_SHADER + uniform sampler2D colortex4; #include "/lib/end_fog.glsl" #endif -#ifdef NETHER_SHADER - #include "/lib/nether_fog.glsl" -#endif + void main() { /* DRAWBUFFERS:4 */ gl_FragData[0] = vec4(0.0); +float mixhistory = 0.07; -vec2 fogPos = vec2(256.0 - 256.0*0.12,1.0); +#ifdef OVERWORLD_SHADER + /////////////////////////////// + /// --- STORE COLOR LUT --- /// + /////////////////////////////// -//Sky gradient with clouds -if (gl_FragCoord.x > (fogPos.x - fogPos.x*0.22) && gl_FragCoord.y > 0.4 && gl_FragCoord.x < 535){ - // vec2 p = clamp(floor(gl_FragCoord.xy-vec2(18.+257,1.))/256.+tempOffsets/256.,0.0,1.0); - vec2 p = clamp(floor(gl_FragCoord.xy-fogPos)/256.+tempOffsets/256.,-0.2,1.2); + vec3 AmbientLightTint = vec3(AmbientLight_R, AmbientLight_G, AmbientLight_B); + + // --- the color of the atmosphere + the average color of the atmosphere. + vec3 skyGroundCol = skyFromTex(vec3(0, -1 ,0), colortex4).rgb ; + + /// --- Save light values + if (gl_FragCoord.x < 1. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) + gl_FragData[0] = vec4(averageSkyCol_Clouds * AmbientLightTint,1.0); + + if (gl_FragCoord.x > 1. && gl_FragCoord.x < 2. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) + gl_FragData[0] = vec4((skyGroundCol/150.0) * AmbientLightTint,1.0); + + if (gl_FragCoord.x > 6. && gl_FragCoord.x < 7. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) + gl_FragData[0] = vec4(lightSourceColor,1.0); + + if (gl_FragCoord.x > 8. && gl_FragCoord.x < 9. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) + gl_FragData[0] = vec4(sunColor,1.0); + + if (gl_FragCoord.x > 13. && gl_FragCoord.x < 14. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) + gl_FragData[0] = vec4(moonColor,1.0); + +//////////////////////////////// +/// --- ATMOSPHERE IMAGE --- /// +//////////////////////////////// + +/// --- Sky only +if (gl_FragCoord.x > 18. && gl_FragCoord.y > 1. && gl_FragCoord.x < 18+257){ + vec2 p = clamp(floor(gl_FragCoord.xy-vec2(18.,1.))/256.+tempOffsets/256.,0.0,1.0); vec3 viewVector = cartToSphere(p); - vec3 BackgroundColor = vec3(0.0); + vec2 planetSphere = vec2(0.0); + vec3 sky = vec3(0.0); + vec3 skyAbsorb = vec3(0.0); + vec3 WsunVec = mat3(gbufferModelViewInverse)*sunVec; - vec4 VL_Fog = GetVolumetricFog(mat3(gbufferModelView)*viewVector*256., fract(frameCounter/1.6180339887), fract(frameCounter/2.6180339887)); + sky = calculateAtmosphere(averageSkyCol*4000./2.0, viewVector, vec3(0.0,1.0,0.0), WsunVec, -WsunVec, planetSphere, skyAbsorb, 10, blueNoise()); + + // sky = mix(sky, (averageSkyCol + skyAbsorb)*4000./2.0 ,(1.0 - exp(pow(clamp(-viewVector.y+0.5,0.0,1.0),2) * -25))); + + // fade atmosphere conditions for rain away when you pass above the cloud plane. + float heightRelativeToClouds = clamp(1.0 - max(eyeAltitude - Cumulus_height,0.0) / 200.0 ,0.0,1.0); + if(rainStrength > 0.0) sky = mix(sky, 3.0 + averageSkyCol*4000 * (skyAbsorb*0.7+0.3), clamp(1.0 - exp(pow(clamp(-viewVector.y+0.9,0.0,1.0),2) * -5.0),0.0,1.0) * heightRelativeToClouds * rainStrength); - BackgroundColor += VL_Fog.rgb/5.0; + #ifdef AEROCHROME_MODE + sky *= vec3(0.0, 0.18, 0.35); + #endif - gl_FragData[0] = vec4(BackgroundColor, 1.0); + gl_FragData[0] = vec4(sky / 4000.0 * Sky_Brightness, 1.0); +} + +/// --- Sky + clouds + fog +if (gl_FragCoord.x > 18.+257. && gl_FragCoord.y > 1. && gl_FragCoord.x < 18+257+257.){ + vec2 p = clamp(floor(gl_FragCoord.xy-vec2(18.+257,1.))/256.+tempOffsets/256.,0.0,1.0); + vec3 viewVector = cartToSphere(p); + + vec3 WsunVec = mat3(gbufferModelViewInverse)*sunVec; + vec3 sky = texelFetch2D(colortex4,ivec2(gl_FragCoord.xy)-ivec2(257,0),0).rgb/150.0; + + if(viewVector.y < -0.025) sky = sky * clamp( exp(viewVector.y) - 1.0,0.25,1.0) ; + + vec4 clouds = renderClouds(mat3(gbufferModelView)*viewVector*1024.,vec2(fract(frameCounter/1.6180339887),1-fract(frameCounter/1.6180339887)), sunColor, moonColor, skyGroundCol/30.0); + sky = sky*clouds.a + clouds.rgb / 5.0; + + vec4 VL_Fog = GetVolumetricFog(mat3(gbufferModelView)*viewVector*1024., fract(frameCounter/1.6180339887), lightSourceColor*1.75, skyGroundCol/30.0); + sky = sky * VL_Fog.a + VL_Fog.rgb / 5.0; + + gl_FragData[0] = vec4(sky,1.0); } +#endif + +#ifdef NETHER_SHADER + vec2 fogPos = vec2(256.0 - 256.0*0.12,1.0); + + //Sky gradient with clouds + if (gl_FragCoord.x > (fogPos.x - fogPos.x*0.22) && gl_FragCoord.y > 0.4 && gl_FragCoord.x < 535){ + vec2 p = clamp(floor(gl_FragCoord.xy-fogPos)/256.+tempOffsets/256.,-0.2,1.2); + vec3 viewVector = cartToSphere(p); + + vec3 BackgroundColor = vec3(0.0); + + vec4 VL_Fog = GetVolumetricFog(mat3(gbufferModelView)*viewVector*256., fract(frameCounter/1.6180339887), fract(frameCounter/2.6180339887)); + + BackgroundColor += VL_Fog.rgb/5.0; + + gl_FragData[0] = vec4(BackgroundColor, 1.0); + + } +#endif + +#ifdef END_SHADER + + /* ---------------------- FOG SHADER ---------------------- */ + vec2 fogPos = vec2(256.0 - 256.0*0.12,1.0); + + //Sky gradient with clouds + if (gl_FragCoord.x > (fogPos.x - fogPos.x*0.22) && gl_FragCoord.y > 0.4 && gl_FragCoord.x < 535){ + vec2 p = clamp(floor(gl_FragCoord.xy-fogPos)/256.+tempOffsets/256.,-0.2,1.2); + vec3 viewVector = cartToSphere(p); + + vec3 BackgroundColor = vec3(0.0); + + vec4 VL_Fog = GetVolumetricFog(mat3(gbufferModelView)*viewVector*256., fract(frameCounter/1.6180339887), fract(frameCounter/2.6180339887)); + + BackgroundColor += VL_Fog.rgb/5.0; + + gl_FragData[0] = vec4(BackgroundColor, 1.0); + + } + + /* ---------------------- TIMER ---------------------- */ + + float flash = 0.0; + float maxWaitTime = 10; + + float Timer = texelFetch2D(colortex4, ivec2(3,1), 0).x/150.0; + Timer -= frameTime; + + if(Timer <= 0.0){ + flash = 1.0; + + Timer = pow(hash11(frameCounter), 5) * maxWaitTime; + } + + vec2 pixelPos0 = vec2(3,1); + if (gl_FragCoord.x > pixelPos0.x && gl_FragCoord.x < pixelPos0.x + 1 && gl_FragCoord.y > pixelPos0.y && gl_FragCoord.y < pixelPos0.y + 1){ + mixhistory = 1.0; + gl_FragData[0] = vec4(Timer, 0.0, 0.0, 1.0); + } + + /* ---------------------- FLASHING ---------------------- */ + + vec2 pixelPos1 = vec2(1,1); + if (gl_FragCoord.x > pixelPos1.x && gl_FragCoord.x < pixelPos1.x + 1 && gl_FragCoord.y > pixelPos1.y && gl_FragCoord.y < pixelPos1.y + 1){ + mixhistory = clamp(5.0 * frameTime,0.0,1.0); + gl_FragData[0] = vec4(flash, 0.0, 0.0, 1.0); + } + + /* ---------------------- POSITION ---------------------- */ + + vec2 pixelPos2 = vec2(2,1); + if (gl_FragCoord.x > pixelPos2.x && gl_FragCoord.x < pixelPos2.x + 1 && gl_FragCoord.y > pixelPos2.y && gl_FragCoord.y < pixelPos2.y + 1){ + mixhistory = clamp(500.0 * frameTime,0.0,1.0); + + vec3 LastPos = (texelFetch2D(colortex4,ivec2(2,1),0).xyz/150.0) * 2.0 - 1.0; + + LastPos += (hash31(frameCounter / 75) * 2.0 - 1.0); + LastPos = LastPos * 0.5 + 0.5; + + if(Timer > maxWaitTime * 0.7 ){ + LastPos = vec3(0.0); + } + + gl_FragData[0] = vec4(LastPos, 1.0); + } + +#endif + + + //Temporally accumulate sky and light values vec3 temp = texelFetch2D(colortex4,ivec2(gl_FragCoord.xy),0).rgb; vec3 curr = gl_FragData[0].rgb*150.; -gl_FragData[0].rgb = clamp(mix(temp,curr,0.07),0.0,65000.); +gl_FragData[0].rgb = clamp(mix(temp, curr, mixhistory),0.0,65000.); //Exposure values if (gl_FragCoord.x > 10. && gl_FragCoord.x < 11. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) @@ -107,4 +269,4 @@ gl_FragData[0] = vec4(exposure,avgBrightness,exposureF,1.0); if (gl_FragCoord.x > 14. && gl_FragCoord.x < 15. && gl_FragCoord.y > 19.+18. && gl_FragCoord.y < 19.+18.+1 ) gl_FragData[0] = vec4(rodExposure,0.0,0.0,1.0); -} +} \ No newline at end of file diff --git a/shaders/dimensions/deferred.vsh b/shaders/dimensions/deferred.vsh index 7303523..d90f3f5 100644 --- a/shaders/dimensions/deferred.vsh +++ b/shaders/dimensions/deferred.vsh @@ -1,5 +1,16 @@ #include "/lib/settings.glsl" #include "/lib/res_params.glsl" +#include "/lib/Shadow_Params.glsl" + +// #extension GL_EXT_gpu_shader4 : enable + +flat varying vec3 averageSkyCol_Clouds; +flat varying vec3 averageSkyCol; + +flat varying vec3 sunColor; +flat varying vec3 moonColor; +flat varying vec3 lightSourceColor; +flat varying vec3 zenithColor; flat varying vec2 tempOffsets; flat varying float exposure; @@ -18,13 +29,14 @@ uniform vec2 texelSize; uniform float sunElevation; uniform float eyeAltitude; uniform float near; -uniform float far; +// uniform float far; uniform float frameTime; uniform int frameCounter; uniform float rainStrength; // uniform int worldTime; -vec3 sunVec = normalize(mat3(gbufferModelViewInverse) *sunPosition); +vec3 sunVec = normalize(mat3(gbufferModelViewInverse) * sunPosition); +// vec3 sunVec = normalize(LightDir); #include "/lib/sky_gradient.glsl" #include "/lib/util.glsl" @@ -55,6 +67,79 @@ void main() { gl_Position.xy = gl_Position.xy*vec2(18.+258*2,258.)*texelSize; gl_Position.xy = gl_Position.xy*2.-1.0; +#ifdef OVERWORLD_SHADER + +/////////////////////////////////// +/// --- AMBIENT LIGHT STUFF --- /// +/////////////////////////////////// + + averageSkyCol_Clouds = vec3(0.0); + averageSkyCol = vec3(0.0); + + vec2 sample3x3[9] = vec2[]( + + vec2(-1.0, -0.3), + vec2( 0.0, 0.0), + vec2( 1.0, -0.3), + + vec2(-1.0, -0.5), + vec2( 0.0, -0.5), + vec2( 1.0, -0.5), + + vec2(-1.0, -1.0), + vec2( 0.0, -1.0), + vec2( 1.0, -1.0) + ); + + // sample in a 3x3 pattern to get a good area for average color + vec3 pos = normalize(vec3(0,1,0)); + int maxIT = 9; + for (int i = 0; i < maxIT; i++) { + pos = normalize(vec3(0,1,0)); + pos.xy += normalize(sample3x3[i]) * vec2(0.3183,0.90); + + averageSkyCol_Clouds += 2.0*skyCloudsFromTex(pos,colortex4).rgb/maxIT/150.; + + // pos = normalize(vec3(0,1,0)); + // pos.xy += normalize(sample3x3[i]) * vec2(0.3183,0.90); + averageSkyCol += 1.5*skyFromTex(pos,colortex4).rgb/maxIT/150.; // please dont do an infinite feedback loop.... + + } + + /// TOOO DAMN BLUE + // // only need to sample one spot for this + // averageSkyCol += 2.0*skyFromTex(normalize(vec3(0.0,1.0,0.0)),colortex4).rgb/150.; + vec3 minimimlight = vec3(0.2,0.4,1.0) * (MIN_LIGHT_AMOUNT*0.0005 + nightVision); + averageSkyCol_Clouds = max(averageSkyCol_Clouds, minimimlight); + averageSkyCol = max(averageSkyCol, minimimlight); + +//////////////////////////////////////// +/// --- SUNLIGHT/MOONLIGHT STUFF --- /// +//////////////////////////////////////// + + vec2 planetSphere = vec2(0.0); + vec3 sky = vec3(0.0); + vec3 skyAbsorb = vec3(0.0); + + float sunVis = clamp(sunElevation,0.0,0.05)/0.05*clamp(sunElevation,0.0,0.05)/0.05; + float moonVis = clamp(-sunElevation,0.0,0.05)/0.05*clamp(-sunElevation,0.0,0.05)/0.05; + + // zenithColor = calculateAtmosphere(vec3(0.0), vec3(0.0,1.0,0.0), vec3(0.0,1.0,0.0), sunVec, -sunVec, planetSphere, skyAbsorb, 25,tempOffsets.x); + skyAbsorb = vec3(0.0); + vec3 absorb = vec3(0.0); + sunColor = calculateAtmosphere(vec3(0.0), sunVec, vec3(0.0,1.0,0.0), sunVec, -sunVec, planetSphere, skyAbsorb, 25,0.0); + sunColor = sunColorBase/4000. * skyAbsorb; + + skyAbsorb = vec3(1.0); + moonColor = calculateAtmosphere(vec3(0.0), -sunVec, vec3(0.0,1.0,0.0), sunVec, -sunVec, planetSphere, skyAbsorb, 25,0.5); + moonColor = moonColorBase/4000.0; + + lightSourceColor = sunVis >= 1e-5 ? sunColor * sunVis : moonColor * moonVis; + + float lightDir = float( sunVis >= 1e-5)*2.0-1.0; + +#endif + ////////////////////////////// /// --- EXPOSURE STUFF --- /// ////////////////////////////// @@ -71,7 +156,7 @@ void main() { for (int i = 0; i < maxITexp; i++){ vec2 ij = R2_samples((frameCounter%2000)*maxITexp+i); vec2 tc = 0.5 + (ij-0.5) * 0.7; - vec3 sp = texture2D(colortex6,tc/16. * resScale+vec2(0.375*resScale.x+4.5*texelSize.x,.0)).rgb; + vec3 sp = texture2D(colortex6, tc/16. * resScale+vec2(0.375*resScale.x+4.5*texelSize.x,.0)).rgb; avgExp += log(luma(sp)); avgB += log(min(dot(sp,vec3(0.07,0.22,0.71)),8e-2)); } diff --git a/shaders/dimensions/deferred1.fsh b/shaders/dimensions/deferred1.fsh index 44218cd..aa45a0c 100644 --- a/shaders/dimensions/deferred1.fsh +++ b/shaders/dimensions/deferred1.fsh @@ -6,10 +6,10 @@ uniform sampler2D depthtex1; uniform float near; uniform float far; - float linZ(float depth) { return (2.0 * near) / (far + near - depth * (far - near)); } + //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// diff --git a/shaders/deferred1.fsh b/shaders/dimensions/deferred2.fsh similarity index 81% rename from shaders/deferred1.fsh rename to shaders/dimensions/deferred2.fsh index dc33ac0..2c7cbc7 100644 --- a/shaders/deferred1.fsh +++ b/shaders/dimensions/deferred2.fsh @@ -1,4 +1,4 @@ -#version 120 + //#extension GL_EXT_gpu_shader4 : disable #include "/lib/settings.glsl" //Computes volumetric clouds at variable resolution (default 1/4 res) @@ -13,7 +13,7 @@ flat varying vec3 averageSkyCol; flat varying float tempOffsets; -uniform float far; +// uniform float far; uniform float near; uniform sampler2D depthtex0; // uniform sampler2D colortex4; @@ -54,9 +54,9 @@ float interleaved_gradientNoise(){ float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y)); return noise; } -#include "/lib/sky_gradient.glsl" -#include "/lib/volumetricClouds.glsl" -#include "/lib/res_params.glsl" + + + const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.), vec2(-1.,3.)/8., vec2(5.0,1.)/8., @@ -76,6 +76,12 @@ vec3 normVec (vec3 vec){ return vec*inversesqrt(dot(vec,vec)); } +#include "/lib/lightning_stuff.glsl" + +#include "/lib/sky_gradient.glsl" +#include "/lib/volumetricClouds.glsl" +#include "/lib/res_params.glsl" + //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// @@ -86,22 +92,21 @@ vec3 normVec (vec3 vec){ void main() { /* DRAWBUFFERS:0 */ -#ifdef VOLUMETRIC_CLOUDS - // vec2 halfResTC = vec2(floor(gl_FragCoord.xy)/CLOUDS_QUALITY/RENDER_SCALE+0.5+(vec2(tempOffsets)*(texelSize/4))*CLOUDS_QUALITY*RENDER_SCALE*0.5); +#ifdef OVERWORLD_SHADER + #ifdef VOLUMETRIC_CLOUDS + vec2 halfResTC = vec2(floor(gl_FragCoord.xy)/CLOUDS_QUALITY/RENDER_SCALE+0.5+offsets[framemod8]*CLOUDS_QUALITY*RENDER_SCALE*0.5); - vec2 halfResTC = vec2(floor(gl_FragCoord.xy)/CLOUDS_QUALITY/RENDER_SCALE+0.5+offsets[framemod8]*CLOUDS_QUALITY*RENDER_SCALE*0.5); + vec3 viewPos = toScreenSpace(vec3(halfResTC*texelSize,1)); - float z = texture2D(depthtex0,halfResTC*texelSize).x; + vec4 VolumetricClouds = renderClouds(viewPos, vec2(R2_dither(),blueNoise2()), sunColor/80., moonColor/150., averageSkyCol/30.0); - vec3 fragpos = toScreenSpace(vec3(halfResTC*texelSize,1)); + gl_FragData[0] = VolumetricClouds; - vec4 currentClouds = renderClouds(fragpos,vec2(R2_dither(),blueNoise2()), sunColor/80., moonColor/150., averageSkyCol/30.0); - - gl_FragData[0] = currentClouds; - - + #else + gl_FragData[0] = vec4(0.0,0.0,0.0,1.0); + #endif #else gl_FragData[0] = vec4(0.0,0.0,0.0,1.0); -#endif -} +#endif +} \ No newline at end of file diff --git a/shaders/deferred1.vsh b/shaders/dimensions/deferred2.vsh similarity index 93% rename from shaders/deferred1.vsh rename to shaders/dimensions/deferred2.vsh index 6f92d95..87fc6e3 100644 --- a/shaders/deferred1.vsh +++ b/shaders/dimensions/deferred2.vsh @@ -1,4 +1,4 @@ -#version 120 + //#extension GL_EXT_gpu_shader4 : disable #include "/lib/settings.glsl" @@ -19,21 +19,22 @@ uniform int frameCounter; #include "/lib/util.glsl" #include "/lib/res_params.glsl" +#include "/lib/Shadow_Params.glsl" + void main() { - - tempOffsets = HaltonSeq2(frameCounter%10000); gl_Position = ftransform(); gl_Position.xy = (gl_Position.xy*0.5+0.5)*clamp(CLOUDS_QUALITY+0.01,0.0,1.0)*2.0-1.0; - #ifdef TAA_UPSCALING - gl_Position.xy = (gl_Position.xy*0.5+0.5)*RENDER_SCALE*2.0-1.0; - #endif - averageSkyCol = texelFetch2D(colortex4,ivec2(1,37),0).rgb; sunColor = texelFetch2D(colortex4,ivec2(6,37),0).rgb; moonColor = texelFetch2D(colortex4,ivec2(13,37),0).rgb; WsunVec = ( float(sunElevation > 1e-5)*2-1. )*normalize(mat3(gbufferModelViewInverse) *sunPosition); + // WsunVec = normalize(LightDir); -} + tempOffsets = HaltonSeq2(frameCounter%10000); + #ifdef TAA_UPSCALING + gl_Position.xy = (gl_Position.xy*0.5+0.5)*RENDER_SCALE*2.0-1.0; + #endif +} \ No newline at end of file diff --git a/shaders/dimensions/final.fsh b/shaders/dimensions/final.fsh index c4906a5..2f294f5 100644 --- a/shaders/dimensions/final.fsh +++ b/shaders/dimensions/final.fsh @@ -3,15 +3,12 @@ varying vec2 texcoord; uniform sampler2D colortex7; -// uniform sampler2D noisetex; uniform vec2 texelSize; -uniform float viewWidth; -uniform float viewHeight; -uniform float aspectRatio; uniform float frameTimeCounter; -uniform int frameCounter; -uniform int isEyeInWater; +uniform sampler2D shadowcolor0; +uniform sampler2D shadowtex0; +uniform sampler2D shadowtex1; #include "/lib/color_transforms.glsl" #include "/lib/color_dither.glsl" @@ -99,6 +96,30 @@ void applyColorCurve(inout vec3 color, vec4 darks, vec4 brights){ } +#ifdef HURT_AND_DEATH_EFFECT + uniform float hurt; + uniform float dying; + uniform float dead; + + void PlayerDamagedEffect(inout vec3 outColor){ + + if(dying > 0){ + + float vignette2 = clamp(1.0 - exp(-(sin(frameTimeCounter*7)*15+50) * dot(texcoord-0.5,texcoord-0.5)),0.0,1.0); + + outColor = mix(outColor, vec3(0.0), min(dying,1.0)*vignette2); + outColor = mix(outColor, vec3(0.0), dead); + + }else{ + + float vignette = clamp(1.0 - exp(-5 * dot(texcoord-0.5,texcoord-0.5)),0.0,1.0); + + outColor = mix(outColor, vec3(0.3,0.0,0.0), vignette*sqrt(hurt)); + + } + } +#endif + void main() { #ifdef BICUBIC_UPSCALING vec3 col = SampleTextureCatmullRom(colortex7,texcoord,1.0/texelSize).rgb; @@ -119,14 +140,18 @@ void main() { vec3 std = abs(col - m1) + abs(albedoCurrent1 - m1) + abs(albedoCurrent2 - m1) + abs(albedoCurrent3 - m1) + abs(albedoCurrent3 - m1) + abs(albedoCurrent4 - m1); float contrast = 1.0 - luma(std)/5.0; - col = col*(1.0+(SHARPENING)*contrast) - - (SHARPENING)/(1.0-0.5/3.5)*contrast*(m1 - 0.5/3.5*col); + col = col*(1.0+(SHARPENING+UPSCALING_SHARPNENING)*contrast) + - (SHARPENING+UPSCALING_SHARPNENING)/(1.0-0.5/3.5)*contrast*(m1 - 0.5/3.5*col); #endif float lum = luma(col); vec3 diff = col-lum; col = col + diff*(-lum*CROSSTALK + SATURATION); - + + #ifdef HURT_AND_DEATH_EFFECT + PlayerDamagedEffect(col); + #endif + vec3 FINAL_COLOR = clamp(int8Dither(col,texcoord),0.0,1.0); #ifdef COLOR_CURVE @@ -135,5 +160,15 @@ void main() { applyContrast(FINAL_COLOR, CONTRAST); // for fun - gl_FragColor.rgb = FINAL_COLOR ; + gl_FragColor.rgb = FINAL_COLOR; + + + + // uniform sampler2D shadowcolor0; + // uniform sampler2D shadowtex0; + // uniform sampler2D shadowtex1; + // if(texcoord.x > 0.5) gl_FragColor.rgb = texture2D(shadowcolor0, texcoord * vec2(2.0, 1.0) - vec2(1.0, 0.0)).rgb; + // vec2 texrood = texcoord * vec2(2.0, 1.0) - vec2(1.0, 0.0); + + // if(texrood.x > 0.49 && texrood.x < 0.51 && texrood.y > 0.49 && texrood.y < 0.51) gl_FragColor.rgb = vec3(1,0,0); } diff --git a/shaders/dimensions/final.vsh b/shaders/dimensions/final.vsh index a42ee54..e41b357 100644 --- a/shaders/dimensions/final.vsh +++ b/shaders/dimensions/final.vsh @@ -1,8 +1,6 @@ #include "/lib/settings.glsl" varying vec2 texcoord; -flat varying vec4 exposure; -uniform sampler2D colortex4; //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// @@ -11,8 +9,6 @@ uniform sampler2D colortex4; //////////////////////////////VOID MAIN////////////////////////////// void main() { - gl_Position = ftransform(); texcoord = gl_MultiTexCoord0.xy; - exposure=vec4(texelFetch2D(colortex4,ivec2(10,37),0).r*vec3(FinalR,FinalG,FinalB),texelFetch2D(colortex4,ivec2(10,37),0).r); } diff --git a/shaders/entity.properties b/shaders/entity.properties index d68a31b..a3db0ca 100644 --- a/shaders/entity.properties +++ b/shaders/entity.properties @@ -1,15 +1,20 @@ #if MC_VERSION >= 11300 +###### +###### all the different strengths of subsurface scattering and what entities to put them on. +###### -### all the different strengths of subsurface scattering and what entities to put them on. -#medium sss (same as strong sss for blocks) -entity.1100 = slime giant ghast elder_guardian +## medium sss (same as strong sss for blocks) +entity.1100 = slime giant ghast elder_guardian -#weak sss (same as weak sss for blocks) -entity.1200 = ender_dragon player sheep frog chicken snow_golem polar_bear zombie_horse armor_stand arrow squid bat cat cod cow donkey fox horse mooshroom mule ocelot parrot pig piglin polar_bear pufferfish rabbit salmon strider tropical_fish turtle villager wandering_trader bee cave_spider dolphin enderman llama panda spider wolf zombified_piglin blaze creeper drowned endermite evoker guardian hoglin husk magma_cube phantom piglin_brute pillager ravager silverfish stray vex vindicator witch zoglin zombie zombie_villager wither trader_llama +## weak sss (same as weak sss for blocks) +entity.1200 = player sheep frog chicken snow_golem polar_bear zombie_horse armor_stand arrow squid bat cat cod cow donkey fox horse mooshroom mule ocelot parrot pig piglin polar_bear pufferfish rabbit salmon strider tropical_fish turtle villager wandering_trader bee cave_spider dolphin enderman llama panda spider wolf zombified_piglin blaze creeper drowned endermite evoker guardian hoglin husk magma_cube phantom piglin_brute pillager ravager silverfish stray vex vindicator witch zoglin zombie zombie_villager trader_llama +## misc stuff +entity.1300 = ender_dragon wither -# various stuff -entity.12345 = minecraft:lightning_bolt weather2:lightning_bolt +entity.12345 = minecraft:lightning_bolt \ +weather2:lightning_bolt +# all of these get excluded from POM entity.2300 = minecraft:item_frame minecraft:item_display \ No newline at end of file diff --git a/shaders/final.fsh b/shaders/final.fsh deleted file mode 100644 index bf8184e..0000000 --- a/shaders/final.fsh +++ /dev/null @@ -1,143 +0,0 @@ -#version 120 -//Vignetting, applies bloom, applies exposure and tonemaps the final image -//#extension GL_EXT_gpu_shader4 : disable - -#include "/lib/settings.glsl" - -varying vec2 texcoord; - -uniform sampler2D colortex7; -// uniform sampler2D noisetex; -uniform vec2 texelSize; -uniform float viewWidth; -uniform float viewHeight; -uniform float aspectRatio; -uniform float frameTimeCounter; -uniform int frameCounter; -uniform int isEyeInWater; - - -#include "/lib/color_transforms.glsl" -#include "/lib/color_dither.glsl" -#include "/lib/res_params.glsl" - -vec4 SampleTextureCatmullRom(sampler2D tex, vec2 uv, vec2 texSize ) -{ - // We're going to sample a a 4x4 grid of texels surrounding the target UV coordinate. We'll do this by rounding - // down the sample location to get the exact center of our "starting" texel. The starting texel will be at - // location [1, 1] in the grid, where [0, 0] is the top left corner. - vec2 samplePos = uv * texSize; - vec2 texPos1 = floor(samplePos - 0.5) + 0.5; - - // Compute the fractional offset from our starting texel to our original sample location, which we'll - // feed into the Catmull-Rom spline function to get our filter weights. - vec2 f = samplePos - texPos1; - - // Compute the Catmull-Rom weights using the fractional offset that we calculated earlier. - // These equations are pre-expanded based on our knowledge of where the texels will be located, - // which lets us avoid having to evaluate a piece-wise function. - vec2 w0 = f * ( -0.5 + f * (1.0 - 0.5*f)); - vec2 w1 = 1.0 + f * f * (-2.5 + 1.5*f); - vec2 w2 = f * ( 0.5 + f * (2.0 - 1.5*f) ); - vec2 w3 = f * f * (-0.5 + 0.5 * f); - - // Work out weighting factors and sampling offsets that will let us use bilinear filtering to - // simultaneously evaluate the middle 2 samples from the 4x4 grid. - vec2 w12 = w1 + w2; - vec2 offset12 = w2 / (w1 + w2); - - // Compute the final UV coordinates we'll use for sampling the texture - vec2 texPos0 = texPos1 - vec2(1.0); - vec2 texPos3 = texPos1 + vec2(2.0); - vec2 texPos12 = texPos1 + offset12; - - texPos0 *= texelSize; - texPos3 *= texelSize; - texPos12 *= texelSize; - - vec4 result = vec4(0.0); - result += texture2D(tex, vec2(texPos0.x, texPos0.y)) * w0.x * w0.y; - result += texture2D(tex, vec2(texPos12.x, texPos0.y)) * w12.x * w0.y; - result += texture2D(tex, vec2(texPos3.x, texPos0.y)) * w3.x * w0.y; - - result += texture2D(tex, vec2(texPos0.x, texPos12.y)) * w0.x * w12.y; - result += texture2D(tex, vec2(texPos12.x, texPos12.y)) * w12.x * w12.y; - result += texture2D(tex, vec2(texPos3.x, texPos12.y)) * w3.x * w12.y; - - result += texture2D(tex, vec2(texPos0.x, texPos3.y)) * w0.x * w3.y; - result += texture2D(tex, vec2(texPos12.x, texPos3.y)) * w12.x * w3.y; - result += texture2D(tex, vec2(texPos3.x, texPos3.y)) * w3.x * w3.y; - - return result; -} - -/// thanks stackoverflow https://stackoverflow.com/questions/944713/help-with-pixel-shader-effect-for-brightness-and-contrast#3027595 -void applyContrast(inout vec3 color, float contrast){ - color = (color - 0.5) * contrast + 0.5; -} - -float lowerCurve(float x) { - float y = 16 * x * (0.5 - x) * 0.1; - return clamp(y, 0.0, 1.0); -} -float upperCurve(float x) { - float y = 16 * (0.5 - x) * (x - 1.0) * 0.1; - return clamp(y, 0.0, 1.0); -} -void applyLuminanceCurve(inout vec3 color, float darks, float brights){ - - // color.r = color.r < 0.5 ? pow(2.0 * color.r, darks) / 2.0 : 1.0 - (pow(2.0 - 2.0 * color.r, brights) / 2.0); - // color.g = color.g < 0.5 ? pow(2.0 * color.g, darks) / 2.0 : 1.0 - (pow(2.0 - 2.0 * color.g, brights) / 2.0); - // color.b = color.b < 0.5 ? pow(2.0 * color.b, darks) / 2.0 : 1.0 - (pow(2.0 - 2.0 * color.b, brights) / 2.0); - - color.r += darks * lowerCurve(color.r) + brights * upperCurve(color.r); - color.g += darks * lowerCurve(color.g) + brights * upperCurve(color.g); - color.b += darks * lowerCurve(color.b) + brights * upperCurve(color.b); -} - -void applyColorCurve(inout vec3 color, vec4 darks, vec4 brights){ - - color.r += (darks.r + darks.a) * lowerCurve(color.r) + (brights.r + brights.a) * upperCurve(color.r); - color.g += (darks.g + darks.a) * lowerCurve(color.g) + (brights.g + brights.a) * upperCurve(color.g); - color.b += (darks.b + darks.a) * lowerCurve(color.b) + (brights.b + brights.a) * upperCurve(color.b); - -} - -void main() { - #ifdef BICUBIC_UPSCALING - vec3 col = SampleTextureCatmullRom(colortex7,texcoord,1.0/texelSize).rgb; - #else - vec3 col = texture2D(colortex7,texcoord).rgb; - #endif - - - #ifdef CONTRAST_ADAPTATIVE_SHARPENING - //Weights : 1 in the center, 0.5 middle, 0.25 corners - vec3 albedoCurrent1 = texture2D(colortex7, texcoord + vec2(texelSize.x,texelSize.y)/MC_RENDER_QUALITY*0.5).rgb; - vec3 albedoCurrent2 = texture2D(colortex7, texcoord + vec2(texelSize.x,-texelSize.y)/MC_RENDER_QUALITY*0.5).rgb; - vec3 albedoCurrent3 = texture2D(colortex7, texcoord + vec2(-texelSize.x,-texelSize.y)/MC_RENDER_QUALITY*0.5).rgb; - vec3 albedoCurrent4 = texture2D(colortex7, texcoord + vec2(-texelSize.x,texelSize.y)/MC_RENDER_QUALITY*0.5).rgb; - - - vec3 m1 = -0.5/3.5*col + albedoCurrent1/3.5 + albedoCurrent2/3.5 + albedoCurrent3/3.5 + albedoCurrent4/3.5; - vec3 std = abs(col - m1) + abs(albedoCurrent1 - m1) + abs(albedoCurrent2 - m1) + - abs(albedoCurrent3 - m1) + abs(albedoCurrent3 - m1) + abs(albedoCurrent4 - m1); - float contrast = 1.0 - luma(std)/5.0; - col = col*(1.0+(SHARPENING+UPSCALING_SHARPNENING)*contrast) - - (SHARPENING+UPSCALING_SHARPNENING)/(1.0-0.5/3.5)*contrast*(m1 - 0.5/3.5*col); - #endif - - float lum = luma(col); - vec3 diff = col-lum; - col = col + diff*(-lum*CROSSTALK + SATURATION); - - vec3 FINAL_COLOR = clamp(int8Dither(col,texcoord),0.0,1.0); - - #ifdef COLOR_CURVE - applyColorCurve(FINAL_COLOR, vec4(R_LOWER_CURVE, G_LOWER_CURVE, B_LOWER_CURVE, LOWER_CURVE), vec4(R_UPPER_CURVE, G_UPPER_CURVE, B_UPPER_CURVE, UPPER_CURVE)); - #endif - - applyContrast(FINAL_COLOR, CONTRAST); // for fun - - gl_FragColor.rgb = FINAL_COLOR ; -} diff --git a/shaders/gbuffers_all_particles.fsh b/shaders/gbuffers_all_particles.fsh deleted file mode 100644 index c24337c..0000000 --- a/shaders/gbuffers_all_particles.fsh +++ /dev/null @@ -1,177 +0,0 @@ -// #version 120 -varying vec4 lmtexcoord; -varying vec4 color; - -flat varying vec3 averageSkyCol_Clouds; -// flat varying vec3 averageSkyCol; - -flat varying vec4 lightCol; //main light source color (rgb),used light source(1=sun,-1=moon) -// flat varying vec3 sunColor; -// flat varying vec3 moonColor; - -uniform vec3 sunVec; -flat varying vec3 WsunVec; - -uniform sampler2D texture; -uniform sampler2DShadow shadow; -uniform sampler2D gaux1; -uniform sampler2D noisetex; -uniform float frameTimeCounter; -uniform ivec2 eyeBrightnessSmooth; - -uniform float far; -uniform float near; -uniform vec2 texelSize; -uniform float rainStrength; -uniform mat4 gbufferProjectionInverse; -uniform mat4 gbufferModelViewInverse; -uniform mat4 gbufferModelView; -uniform mat4 shadowModelView; -uniform mat4 shadowProjection; -uniform vec3 cameraPosition; - - -#include "/lib/settings.glsl" -#include "/lib/Shadow_Params.glsl" -#include "/lib/res_params.glsl" -#include "/lib/sky_gradient.glsl" -#include "/lib/volumetricClouds.glsl" - -#define OVERWORLD_SHADER -#include "/lib/diffuse_lighting.glsl" - -//faster and actually more precise than pow 2.2 -vec3 toLinear(vec3 sRGB){ - return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878); -} - -#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z) -#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz) -vec3 toScreenSpace(vec3 p) { - vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw); - vec3 p3 = p * 2. - 1.; - vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3]; - return fragposition.xyz / fragposition.w; -} - -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.); - -float shadow2D_bicubic(sampler2DShadow tex, vec3 sc) -{ - vec2 uv = sc.xy*shadowMapResolution; - vec2 iuv = floor( uv ); - vec2 fuv = fract( uv ); - - float g0x = g0(fuv.x); - float g1x = g1(fuv.x); - float h0x = h0(fuv.x); - float h1x = h1(fuv.x); - float h0y = h0(fuv.y); - float h1y = h1(fuv.y); - - vec2 p0 = vec2(iuv.x + h0x, iuv.y + h0y)/shadowMapResolution - 0.5/shadowMapResolution; - vec2 p1 = vec2(iuv.x + h1x, iuv.y + h0y)/shadowMapResolution - 0.5/shadowMapResolution; - vec2 p2 = vec2(iuv.x + h0x, iuv.y + h1y)/shadowMapResolution - 0.5/shadowMapResolution; - vec2 p3 = vec2(iuv.x + h1x, iuv.y + h1y)/shadowMapResolution - 0.5/shadowMapResolution; - - return g0(fuv.y) * (g0x * shadow2D(tex, vec3(p0,sc.z)).x + - g1x * shadow2D(tex, vec3(p1,sc.z)).x) + - g1(fuv.y) * (g0x * shadow2D(tex, vec3(p2,sc.z)).x + - g1x * shadow2D(tex, vec3(p3,sc.z)).x); -} - -vec3 normVec (vec3 vec){ - return vec*inversesqrt(dot(vec,vec)); -} - -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -/* DRAWBUFFERS:29 */ -void main() { - - vec4 TEXTURE = texture2D(texture, lmtexcoord.xy) * color; - - vec2 tempOffset = offsets[framemod8]; - vec3 fragpos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0)); - vec3 p3 = mat3(gbufferModelViewInverse) * fragpos; - vec3 np3 = normVec(p3); - - float cloudOcclusion = 0.0; - - if(TEXTURE.a > 0.0) cloudOcclusion = 1.0 - GetCloudSkyOcclusion(p3 + cameraPosition)*0.8; - gl_FragData[1].a = TEXTURE.a * cloudOcclusion ; // for bloomy rain and stuff - -#ifndef WEATHER - gl_FragData[1].a = 1.0 - TEXTURE.a; - - #ifdef LIT - gl_FragData[1].a = 0.0; - #endif - - gl_FragData[0].a = TEXTURE.a; - - vec3 Albedo = toLinear(TEXTURE.rgb); - - // do the maths only if the pixels exist.... - if(TEXTURE.a > 0.0){ - - float Shadows = 1.0; - - vec3 p3_shadow = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz; - vec3 projectedShadowPosition = mat3(shadowModelView) * p3_shadow + shadowModelView[3].xyz; - projectedShadowPosition = diagonal3(shadowProjection) * projectedShadowPosition + shadowProjection[3].xyz; - - //apply distortion - float distortFactor = calcDistort(projectedShadowPosition.xy); - projectedShadowPosition.xy *= distortFactor; - int shadowmapindicator = 0; - //do shadows only if on shadow map - if (abs(projectedShadowPosition.x) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.y) < 1.0-1.5/shadowMapResolution){ - - projectedShadowPosition = projectedShadowPosition * vec3(0.5,0.5,0.5/6.0) + vec3(0.5); - - Shadows = shadow2D_bicubic(shadow,vec3(projectedShadowPosition + vec3(0.0,0.0,0.0))); - - shadowmapindicator = 1; - } - - if(shadowmapindicator < 1) Shadows = clamp((lmtexcoord.w-0.8) * 5,0,1); - - #ifdef CLOUDS_SHADOWS - Shadows *= GetCloudShadow(p3); - #endif - - vec3 AmbientLightColor = averageSkyCol_Clouds; - vec3 DirectLightColor = lightCol.rgb/80.0; - - AmbientLightColor += (lightningEffect * 10) * pow(lmtexcoord.w,2); - - float lightleakfix = clamp(eyeBrightnessSmooth.y/240.0,0.0,1.0); - float phase = phaseg(clamp(dot(np3, WsunVec),0.0,1.0),(1.0-gl_FragData[0].a) * 0.8 + 0.1) + 1.0 ; - vec3 Direct_lighting = DoDirectLighting(DirectLightColor, Shadows, 1.0, 0.0) * phase * lightleakfix; - vec3 Torch_Color = vec3(TORCH_R,TORCH_G,TORCH_B); - - #ifdef LIT - Torch_Color *= LIT_PARTICLE_BRIGHTNESS; - #endif - - vec3 Indirect_lighting = DoAmbientLighting(AmbientLightColor, Torch_Color, clamp(lmtexcoord.zw,0.0,1.0), 5.0); - - // gl_FragData[0].a = TEXTURE.a; - - gl_FragData[0].rgb = (Direct_lighting + Indirect_lighting) * Albedo; - - } -#endif -} \ No newline at end of file diff --git a/shaders/gbuffers_all_particles.vsh b/shaders/gbuffers_all_particles.vsh deleted file mode 100644 index 4fb1f9d..0000000 --- a/shaders/gbuffers_all_particles.vsh +++ /dev/null @@ -1,110 +0,0 @@ -// #version 120 -//#extension GL_EXT_gpu_shader4 : disable -#include "/lib/settings.glsl" -#include "/lib/res_params.glsl" -#include "/lib/bokeh.glsl" - -/* -!! DO NOT REMOVE !! -This code is from Chocapic13' shaders -Read the terms of modification and sharing before changing something below please ! -!! DO NOT REMOVE !! -*/ - -varying vec4 lmtexcoord; -varying vec4 color; -varying vec4 normalMat; - -#ifdef MC_NORMAL_MAP - varying vec4 tangent; - attribute vec4 at_tangent; - varying vec3 FlatNormals; -#endif - -flat varying vec3 WsunVec; -flat varying vec4 lightCol; //main light source color (rgb),used light source(1=sun,-1=moon) - -flat varying vec3 averageSkyCol_Clouds; -// flat varying vec3 averageSkyCol; - -uniform mat4 gbufferModelViewInverse; -uniform vec3 sunPosition; -uniform float sunElevation; -uniform sampler2D colortex4; - -uniform int frameCounter; -uniform float far; -uniform float aspectRatio; -uniform float viewHeight; -uniform float viewWidth; -uniform int hideGUI; -uniform float screenBrightness; - -uniform vec2 texelSize; -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.); -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// - -void main() { - lmtexcoord.xy = (gl_MultiTexCoord0).xy; - - vec2 lmcoord = gl_MultiTexCoord1.xy/255.; - lmtexcoord.zw = lmcoord; - - gl_Position = ftransform(); - color = gl_Color; - - averageSkyCol_Clouds = texelFetch2D(colortex4,ivec2(0,37),0).rgb; - // averageSkyCol = texelFetch2D(colortex4,ivec2(1,37),0).rgb; - - vec3 sc = texelFetch2D(colortex4,ivec2(6,37),0).rgb; - lightCol.a = float(sunElevation > 1e-5)*2-1.; - lightCol.rgb = sc; - - WsunVec = lightCol.a*normalize(mat3(gbufferModelViewInverse) *sunPosition); - - - FlatNormals = normalize(gl_NormalMatrix *gl_Normal); - - #ifdef MC_NORMAL_MAP - tangent = vec4(normalize(gl_NormalMatrix *at_tangent.rgb),at_tangent.w); - #endif - - normalMat = vec4(normalize(gl_NormalMatrix *gl_Normal),1.0); - - #ifdef TAA_UPSCALING - gl_Position.xy = gl_Position.xy * RENDER_SCALE + RENDER_SCALE * gl_Position.w - gl_Position.w; - #endif - #ifdef TAA - gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize; - #endif - - #if DOF_QUALITY == 5 - vec2 jitter = clamp(jitter_offsets[frameCounter % 64], -1.0, 1.0); - jitter = rotate(radians(float(frameCounter))) * jitter; - jitter.y *= aspectRatio; - jitter.x *= DOF_ANAMORPHIC_RATIO; - - #if MANUAL_FOCUS == -2 - float focusMul = 0; - #elif MANUAL_FOCUS == -1 - float focusMul = gl_Position.z - mix(pow(512.0, screenBrightness), 512.0 * screenBrightness, 0.25); - #else - float focusMul = gl_Position.z - MANUAL_FOCUS; - #endif - - vec2 totalOffset = (jitter * JITTER_STRENGTH) * focusMul * 1e-2; - gl_Position.xy += hideGUI >= 1 ? totalOffset : vec2(0); - #endif -} diff --git a/shaders/gbuffers_all_solid.fsh b/shaders/gbuffers_all_solid.fsh deleted file mode 100644 index 3e3b8c1..0000000 --- a/shaders/gbuffers_all_solid.fsh +++ /dev/null @@ -1,582 +0,0 @@ -//#extension GL_EXT_gpu_shader4 : disable -//#extension GL_ARB_shader_texture_lod : disable - -#include "/lib/settings.glsl" - -flat varying int NameTags; - -#ifdef HAND -#undef POM -#endif - -#ifndef USE_LUMINANCE_AS_HEIGHTMAP -#ifndef MC_NORMAL_MAP -#undef POM -#endif -#endif - -#ifdef POM -#define MC_NORMAL_MAP -#endif - - -varying float VanillaAO; - -const float mincoord = 1.0/4096.0; -const float maxcoord = 1.0-mincoord; - -const float MAX_OCCLUSION_DISTANCE = MAX_DIST; -const float MIX_OCCLUSION_DISTANCE = MAX_DIST*0.9; -const int MAX_OCCLUSION_POINTS = MAX_ITERATIONS; - -uniform vec2 texelSize; -uniform int framemod8; - -// #ifdef POM -varying vec4 vtexcoordam; // .st for add, .pq for mul -varying vec4 vtexcoord; - -vec2 dcdx = dFdx(vtexcoord.st*vtexcoordam.pq)*exp2(Texture_MipMap_Bias); -vec2 dcdy = dFdy(vtexcoord.st*vtexcoordam.pq)*exp2(Texture_MipMap_Bias); -// #endif - -#include "/lib/res_params.glsl" -varying vec4 lmtexcoord; - -varying vec4 color; - -uniform float far; - - -uniform float wetness; -varying vec4 normalMat; - - -#ifdef MC_NORMAL_MAP - uniform sampler2D normals; - varying vec4 tangent; - varying vec3 FlatNormals; -#endif - - -uniform sampler2D specular; - - - -uniform sampler2D texture; -uniform sampler2D colortex1;//albedo(rgb),material(alpha) RGBA16 -uniform float frameTimeCounter; -uniform int frameCounter; -uniform mat4 gbufferProjectionInverse; -uniform mat4 gbufferModelView; -uniform mat4 gbufferProjection; -uniform mat4 gbufferModelViewInverse; -uniform vec3 cameraPosition; -uniform float rainStrength; -uniform sampler2D noisetex;//depth -uniform sampler2D depthtex0; - -uniform vec4 entityColor; - -in vec3 velocity; - -flat varying int PHYSICSMOD_SNOW; -flat varying float blockID; - -flat varying float SSSAMOUNT; -flat varying float EMISSIVE; -flat varying int LIGHTNING; -flat varying int PORTAL; -flat varying int SIGN; - - -flat varying float HELD_ITEM_BRIGHTNESS; -uniform float noPuddleAreas; - - -// float interleaved_gradientNoise(){ -// return fract(52.9829189*fract(0.06711056*gl_FragCoord.x + 0.00583715*gl_FragCoord.y)+frameTimeCounter*51.9521); -// } -float interleaved_gradientNoise_temp(){ - vec2 alpha = vec2(0.75487765, 0.56984026); - vec2 coord = vec2(alpha.x * gl_FragCoord.x,alpha.y * gl_FragCoord.y)+ 1.0/1.6180339887 * frameCounter; - float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y)); - return noise; -} -float interleaved_gradientNoise(){ - vec2 coord = gl_FragCoord.xy; - float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y)); - return noise; -} -float blueNoise(){ - return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter); -} -float R2_dither(){ - vec2 alpha = vec2(0.75487765, 0.56984026); - return fract(alpha.x * gl_FragCoord.x + alpha.y * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter) ; -} - -mat3 inverse(mat3 m) { - float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2]; - float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2]; - float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2]; - - float b01 = a22 * a11 - a12 * a21; - float b11 = -a22 * a10 + a12 * a20; - float b21 = a21 * a10 - a11 * a20; - - float det = a00 * b01 + a01 * b11 + a02 * b21; - - return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11), - b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10), - b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det; -} - -vec3 viewToWorld(vec3 viewPosition) { - vec4 pos; - pos.xyz = viewPosition; - pos.w = 0.0; - pos = gbufferModelViewInverse * pos; - return pos.xyz; -} -vec3 worldToView(vec3 worldPos) { - vec4 pos = vec4(worldPos, 0.0); - pos = gbufferModelView * pos; - return pos.xyz; -} -vec4 encode (vec3 n, vec2 lightmaps){ - n.xy = n.xy / dot(abs(n), vec3(1.0)); - n.xy = n.z <= 0.0 ? (1.0 - abs(n.yx)) * sign(n.xy) : n.xy; - vec2 encn = clamp(n.xy * 0.5 + 0.5,-1.0,1.0); - - return vec4(encn,vec2(lightmaps.x,lightmaps.y)); -} - -//encoding by jodie -float encodeVec2(vec2 a){ - const vec2 constant1 = vec2( 1., 256.) / 65535.; - vec2 temp = floor( a * 255. ); - return temp.x*constant1.x+temp.y*constant1.y; -} -float encodeVec2(float x,float y){ - return encodeVec2(vec2(x,y)); -} - -#ifdef MC_NORMAL_MAP - vec3 applyBump(mat3 tbnMatrix, vec3 bump, float puddle_values){ - float bumpmult = clamp(puddle_values,0.0,1.0); - bump = bump * vec3(bumpmult, bumpmult, bumpmult) + vec3(0.0f, 0.0f, 1.0f - bumpmult); - return normalize(bump*tbnMatrix); - } -#endif - - -#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z) -#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz) - -vec3 toScreenSpace(vec3 p) { - vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw); - vec3 p3 = p * 2. - 1.; - vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3]; - return fragposition.xyz / fragposition.w; -} -vec3 toClipSpace3(vec3 viewSpacePosition) { - return projMAD(gbufferProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5; -} - -#ifdef POM - vec4 readNormal(in vec2 coord) - { - return texture2DGradARB(normals,fract(coord)*vtexcoordam.pq+vtexcoordam.st,dcdx,dcdy); - } - vec4 readTexture(in vec2 coord) - { - return texture2DGradARB(texture,fract(coord)*vtexcoordam.pq+vtexcoordam.st,dcdx,dcdy); - } -#endif - - -float luma(vec3 color) { - return dot(color,vec3(0.21, 0.72, 0.07)); -} - - -vec3 toLinear(vec3 sRGB){ - return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878); -} - - -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 srgbToLinear2(vec3 srgb){ - return mix( - srgb / 12.92, - pow(.947867 * srgb + .0521327, vec3(2.4) ), - step( .04045, srgb ) - ); -} -vec3 blackbody2(float Temp) -{ - float t = pow(Temp, -1.5); - float lt = log(Temp); - - vec3 col = vec3(0.0); - col.x = 220000.0 * t + 0.58039215686; - col.y = 0.39231372549 * lt - 2.44549019608; - col.y = Temp > 6500. ? 138039.215686 * t + 0.72156862745 : col.y; - col.z = 0.76078431372 * lt - 5.68078431373; - col = clamp(col,0.0,1.0); - col = Temp < 1000. ? col * Temp * 0.001 : col; - - return srgbToLinear2(col); -} - -uniform float near; - - -float ld(float dist) { - return (2.0 * near) / (far + near - dist * (far - near)); -} - - -vec4 readNoise(in vec2 coord){ - // return texture2D(noisetex,coord*vtexcoordam.pq+vtexcoord.st); - return texture2DGradARB(noisetex,coord*vtexcoordam.pq + vtexcoordam.st,dcdx,dcdy); -} -float EndPortalEffect( - inout vec4 ALBEDO, - vec3 FragPos, - vec3 WorldPos, - mat3 tbnMatrix -){ - - int maxdist = 25; - int quality = 35; - - vec3 viewVec = normalize(tbnMatrix*FragPos); - if ( viewVec.z < 0.0 && length(FragPos) < maxdist) { - float endportalGLow = 0.0; - float Depth = 0.3; - vec3 interval = (viewVec.xyz /-viewVec.z/quality*Depth) * (0.7 + (blueNoise()-0.5)*0.1); - - vec3 coord = vec3(WorldPos.xz , 1.0); - coord += interval; - - for (int loopCount = 0; (loopCount < quality) && (1.0 - Depth + Depth * ( 1.0-readNoise(coord.st).r - readNoise(-coord.st*3).b*0.2 ) ) < coord.p && coord.p >= 0.0; ++loopCount) { - coord = coord+interval ; - endportalGLow += (0.3/quality); - } - - ALBEDO.rgb = vec3(0.5,0.75,1.0) * sqrt(endportalGLow); - - return clamp(pow(endportalGLow*3.5,3),0,1); - } -} - -float bias(){ - return (Texture_MipMap_Bias + (blueNoise()-0.5)*0.5) - (1.0-RENDER_SCALE.x) * 2.0; -} -vec4 texture2D_POMSwitch( - sampler2D sampler, - vec2 lightmapCoord, - vec4 dcdxdcdy, - bool ifPOM -){ - if(ifPOM){ - return texture2DGradARB(sampler, lightmapCoord, dcdxdcdy.xy, dcdxdcdy.zw); - }else{ - return texture2D(sampler, lightmapCoord, bias()); - } -} - - - -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// - -/* RENDERTARGETS: 1,7,8,15 */ -void main() { - - - bool ifPOM = false; - - #ifdef POM - ifPOM = true; - #endif - - if(SIGN > 0) ifPOM = false; - - vec3 normal = normalMat.xyz; - - #ifdef MC_NORMAL_MAP - vec3 tangent2 = normalize(cross(tangent.rgb,normal)*tangent.w); - mat3 tbnMatrix = mat3(tangent.x, tangent2.x, normal.x, - tangent.y, tangent2.y, normal.y, - tangent.z, tangent2.z, normal.z); - #endif - - vec2 tempOffset=offsets[framemod8]; - - vec3 fragpos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0)); - vec3 worldpos = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz + cameraPosition; - - float torchlightmap = lmtexcoord.z; - - #ifdef Hand_Held_lights - if(HELD_ITEM_BRIGHTNESS > 0.0) torchlightmap = max(torchlightmap, HELD_ITEM_BRIGHTNESS * clamp( pow(max(1.0-length(fragpos)/10,0.0),1.5),0.0,1.0)); - #endif - - float lightmap = clamp( (lmtexcoord.w-0.8) * 10.0,0.,1.); - - float rainfall = rainStrength * noPuddleAreas; - float Puddle_shape = 0.; - - #ifndef ENTITIES - #ifndef HAND - #ifdef WORLD - #ifdef Puddles - Puddle_shape = (1.0 - clamp(exp(-15 * pow(texture2D(noisetex, worldpos.xz * (0.020 * Puddle_Size) ).b ,5)),0,1)) * lightmap ; - Puddle_shape *= clamp( viewToWorld(normal).y*0.5+0.5 ,0.0,1.0); - Puddle_shape *= rainfall; - #endif - #endif - #endif - #endif - - vec2 adjustedTexCoord = lmtexcoord.xy; - -#ifdef POM - #ifdef WORLD - // vec2 tempOffset=offsets[framemod8]; - adjustedTexCoord = fract(vtexcoord.st)*vtexcoordam.pq+vtexcoordam.st; - // vec3 fragpos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0)); - vec3 viewVector = normalize(tbnMatrix*fragpos); - float dist = length(fragpos); - - float maxdist = MAX_OCCLUSION_DISTANCE; - if(!ifPOM) maxdist = 0.0; - - gl_FragDepth = gl_FragCoord.z; - - if (dist < maxdist) { - - float depthmap = readNormal(vtexcoord.st).a; - float used_POM_DEPTH = 1.0; - - if ( viewVector.z < 0.0 && depthmap < 0.9999 && depthmap > 0.00001) { - // float noise = interleaved_gradientNoise_temp(); - #ifdef Adaptive_Step_length - vec3 interval = (viewVector.xyz /-viewVector.z/MAX_OCCLUSION_POINTS * POM_DEPTH) * clamp(1.0-pow(depthmap,2),0.1,1.0); - used_POM_DEPTH = 1.0; - #else - vec3 interval = viewVector.xyz /-viewVector.z/MAX_OCCLUSION_POINTS*POM_DEPTH; - #endif - vec3 coord = vec3(vtexcoord.st , 1.0); - - coord += interval * used_POM_DEPTH; - - float sumVec = 0.5; - for (int loopCount = 0; (loopCount < MAX_OCCLUSION_POINTS) && (1.0 - POM_DEPTH + POM_DEPTH * readNormal(coord.st).a ) < coord.p && coord.p >= 0.0; ++loopCount) { - coord = coord + interval * used_POM_DEPTH; - sumVec += 1.0 * used_POM_DEPTH; - } - - if (coord.t < mincoord) { - if (readTexture(vec2(coord.s,mincoord)).a == 0.0) { - coord.t = mincoord; - discard; - } - } - - adjustedTexCoord = mix(fract(coord.st)*vtexcoordam.pq+vtexcoordam.st, adjustedTexCoord, max(dist-MIX_OCCLUSION_DISTANCE,0.0)/(MAX_OCCLUSION_DISTANCE-MIX_OCCLUSION_DISTANCE)); - - vec3 truePos = fragpos + sumVec*inverse(tbnMatrix)*interval; - // #ifdef Depth_Write_POM - gl_FragDepth = toClipSpace3(truePos).z; - // #endif - } - } - #endif -#endif - - if(!ifPOM) adjustedTexCoord = lmtexcoord.xy; - - - //////////////////////////////// //////////////////////////////// - //////////////////////////////// ALBEDO //////////////////////////////// - //////////////////////////////// //////////////////////////////// - - vec4 Albedo = texture2D_POMSwitch(texture, adjustedTexCoord.xy, vec4(dcdx,dcdy), ifPOM) * color; - - if(LIGHTNING > 0) Albedo = vec4(1); - - float ENDPORTAL_EFFECT = 0.0; - #ifndef ENTITIES - ENDPORTAL_EFFECT = PORTAL > 0 ? EndPortalEffect(Albedo, fragpos, worldpos, tbnMatrix) : 0; - #endif - - #ifdef WhiteWorld - Albedo.rgb = vec3(1.0); - #endif - - #ifdef AEROCHROME_MODE - vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631), AEROCHROME_PINKNESS); - float gray = dot(Albedo.rgb, vec3(0.2, 01.0, 0.07)); - if(blockID == 10001 || blockID == 10003 || blockID == 10004 || blockID == 10006) { - // IR Reflective (Pink-red) - Albedo.rgb = mix(vec3(gray), aerochrome_color, 0.7); - } - else if(blockID == 10008) { - // Special handling for grass block - float strength = 1.0 - color.b; - Albedo.rgb = mix(Albedo.rgb, aerochrome_color, strength); - } - #ifdef AEROCHROME_WOOL_ENABLED - else if(blockID == 200) { - // Wool - Albedo.rgb = mix(Albedo.rgb, aerochrome_color, 0.3); - } - #endif - else if(blockID == 8 || blockID == 10002) - { - // IR Absorbsive? Dark. - Albedo.rgb = mix(Albedo.rgb, vec3(0.01, 0.08, 0.15), 0.5); - } - #endif - - #ifdef WORLD - if (Albedo.a > 0.1) Albedo.a = normalMat.a; - else Albedo.a = 0.0; - #endif - - #ifdef HAND - if (Albedo.a > 0.1) Albedo.a = 0.75; - else Albedo.a = 0.0; - #endif - - - //////////////////////////////// //////////////////////////////// - //////////////////////////////// NORMAL //////////////////////////////// - //////////////////////////////// //////////////////////////////// - - #ifdef WORLD - #ifdef MC_NORMAL_MAP - - vec4 NormalTex = texture2D_POMSwitch(normals, adjustedTexCoord.xy, vec4(dcdx,dcdy), ifPOM); - NormalTex.xy = NormalTex.xy*2.0-1.0; - NormalTex.z = clamp(sqrt(1.0 - dot(NormalTex.xy, NormalTex.xy)),0.0,1.0) ; - - if(PHYSICSMOD_SNOW < 1) normal = applyBump(tbnMatrix, NormalTex.xyz, mix(1.0,1-Puddle_shape,rainfall) ); - #endif - #endif - - //////////////////////////////// //////////////////////////////// - //////////////////////////////// SPECULAR //////////////////////////////// - //////////////////////////////// //////////////////////////////// - - #ifdef WORLD - vec4 SpecularTex = texture2D_POMSwitch(specular, adjustedTexCoord.xy, vec4(dcdx,dcdy), ifPOM); - - SpecularTex.r = max(SpecularTex.r, Puddle_shape); - SpecularTex.g = max(SpecularTex.g, Puddle_shape*0.02); - - gl_FragData[2].rg = SpecularTex.rg; - - #if EMISSIVE_TYPE == 0 - gl_FragData[2].a = 0.0; - #endif - - #if EMISSIVE_TYPE == 1 - gl_FragData[2].a = EMISSIVE; - #endif - - #if EMISSIVE_TYPE == 2 - gl_FragData[2].a = SpecularTex.a; - if(SpecularTex.a <= 0.0) gl_FragData[2].a = EMISSIVE; - #endif - - #if EMISSIVE_TYPE == 3 - gl_FragData[2].a = SpecularTex.a; - #endif - - #if SSS_TYPE == 0 - gl_FragData[2].b = 0.0; - #endif - - #if SSS_TYPE == 1 - gl_FragData[2].b = SSSAMOUNT; - #endif - - #if SSS_TYPE == 2 - gl_FragData[2].b = SpecularTex.b; - if(SpecularTex.b < 65.0/255.0) gl_FragData[2].b = SSSAMOUNT; - #endif - - #if SSS_TYPE == 3 - gl_FragData[2].b = SpecularTex.b; - #endif - - #ifndef ENTITIES - if(PORTAL > 0){ - gl_FragData[2].rgb = vec3(0); - gl_FragData[2].a = clamp(ENDPORTAL_EFFECT * 0.9, 0,0.9); - } - #endif - #endif - - // hit glow effect... - #ifdef ENTITIES - Albedo.rgb = mix(Albedo.rgb, entityColor.rgb, entityColor.a); - gl_FragData[2].a = mix(gl_FragData[2].a, 0.9, entityColor.a);; - #endif - - //////////////////////////////// //////////////////////////////// - //////////////////////////////// FINALIZE //////////////////////////////// - //////////////////////////////// //////////////////////////////// - - #ifdef WORLD - - #ifdef Puddles - float porosity = 0.4; - #ifdef Porosity - porosity = SpecularTex.z >= 64.5/255.0 ? 0.0 : (SpecularTex.z*255.0/64.0)*0.65; - #endif - if(SpecularTex.g < 229.5/255.0) Albedo.rgb = mix(Albedo.rgb, vec3(0), Puddle_shape*porosity); - #endif - - // apply noise to lightmaps to reduce banding. - vec2 PackLightmaps = vec2(torchlightmap,lmtexcoord.w); - - #ifndef ENTITIES - #ifndef HAND - PackLightmaps = max(PackLightmaps*blueNoise()*0.05 + PackLightmaps,0.0); - #endif - #endif - - vec4 data1 = clamp( encode(viewToWorld(normal),PackLightmaps), 0.0, 1.0); - - gl_FragData[0] = vec4(encodeVec2(Albedo.x,data1.x), encodeVec2(Albedo.y,data1.y), encodeVec2(Albedo.z,data1.z), encodeVec2(data1.w,Albedo.w)); - - gl_FragData[1].a = 0.0; - #endif - - - - #ifdef WORLD - - // #ifdef ENTITIES - // gl_FragData[5].xyz = velocity *0.5+0.5; - // #endif - - gl_FragData[3] = vec4(FlatNormals * 0.5 + 0.5, VanillaAO); - #endif -} \ No newline at end of file diff --git a/shaders/gbuffers_all_solid.vsh b/shaders/gbuffers_all_solid.vsh deleted file mode 100644 index 99a24d8..0000000 --- a/shaders/gbuffers_all_solid.vsh +++ /dev/null @@ -1,402 +0,0 @@ -//#extension GL_EXT_gpu_shader4 : disable -#include "/lib/settings.glsl" -#include "/lib/res_params.glsl" -#include "/lib/bokeh.glsl" - -/* -!! DO NOT REMOVE !! -This code is from Chocapic13' shaders -Read the terms of modification and sharing before changing something below please ! -!! DO NOT REMOVE !! -*/ - - -#ifdef HAND -#undef POM -#endif - -#ifndef USE_LUMINANCE_AS_HEIGHTMAP -#ifndef MC_NORMAL_MAP -#undef POM -#endif -#endif - -#ifdef POM -#define MC_NORMAL_MAP -#endif - - -varying vec4 color; -varying float VanillaAO; - -varying vec4 lmtexcoord; -varying vec4 normalMat; - -// #ifdef POM - varying vec4 vtexcoordam; // .st for add, .pq for mul - varying vec4 vtexcoord; -// #endif - -#ifdef MC_NORMAL_MAP - varying vec4 tangent; - attribute vec4 at_tangent; - varying vec3 FlatNormals; -#endif - -uniform float frameTimeCounter; -const float PI48 = 150.796447372*WAVY_SPEED; -float pi2wt = PI48*frameTimeCounter; - -attribute vec4 mc_Entity; -uniform int blockEntityId; -uniform int entityId; -flat varying float blockID; - -uniform int heldItemId; -uniform int heldItemId2; -flat varying float HELD_ITEM_BRIGHTNESS; - - - -flat varying int PHYSICSMOD_SNOW; -flat varying int NameTags; - -uniform int frameCounter; -uniform float far; -uniform float aspectRatio; -uniform float viewHeight; -uniform float viewWidth; -uniform int hideGUI; -uniform float screenBrightness; - -flat varying float SSSAMOUNT; -flat varying float EMISSIVE; -flat varying int LIGHTNING; -flat varying int PORTAL; -flat varying int SIGN; - -in vec3 at_velocity; -out vec3 velocity; - - - -uniform mat4 gbufferModelView; -uniform mat4 gbufferModelViewInverse; -attribute vec4 mc_midTexCoord; -uniform vec3 cameraPosition; -uniform vec2 texelSize; -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.); - -#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z) -#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz) -vec4 toClipSpace3(vec3 viewSpacePosition) { - return vec4(projMAD(gl_ProjectionMatrix, viewSpacePosition),-viewSpacePosition.z); -} - -vec2 calcWave(in vec3 pos) { - - float magnitude = abs(sin(dot(vec4(frameTimeCounter, pos),vec4(1.0,0.005,0.005,0.005)))*0.5+0.72)*0.013; - vec2 ret = (sin(pi2wt*vec2(0.0063,0.0015)*4. - pos.xz + pos.y*0.05)+0.1)*magnitude; - - return ret; -} - -vec3 calcMovePlants(in vec3 pos) { - vec2 move1 = calcWave(pos ); - float move1y = -length(move1); - return vec3(move1.x,move1y,move1.y)*5.*WAVY_STRENGTH; -} - -vec3 calcWaveLeaves(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) { - - float magnitude = abs(sin(dot(vec4(frameTimeCounter, pos),vec4(1.0,0.005,0.005,0.005)))*0.5+0.72)*0.013; - vec3 ret = (sin(pi2wt*vec3(0.0063,0.0224,0.0015)*1.5 - pos))*magnitude; - - return ret; -} - -vec3 calcMoveLeaves(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 = calcWaveLeaves(pos , 0.0054, 0.0400, 0.0400, 0.0127, 0.0089, 0.0114, 0.0063, 0.0224, 0.0015) * amp1; - return move1*5.*WAVY_STRENGTH; -} -vec3 srgbToLinear2(vec3 srgb){ - return mix( - srgb / 12.92, - pow(.947867 * srgb + .0521327, vec3(2.4) ), - step( .04045, srgb ) - ); -} -vec3 blackbody2(float Temp) -{ - float t = pow(Temp, -1.5); - float lt = log(Temp); - - vec3 col = vec3(0.0); - col.x = 220000.0 * t + 0.58039215686; - col.y = 0.39231372549 * lt - 2.44549019608; - col.y = Temp > 6500. ? 138039.215686 * t + 0.72156862745 : col.y; - col.z = 0.76078431372 * lt - 5.68078431373; - col = clamp(col,0.0,1.0); - col = Temp < 1000. ? col * Temp * 0.001 : col; - - return srgbToLinear2(col); -} -// float luma(vec3 color) { -// return dot(color,vec3(0.21, 0.72, 0.07)); -// } - -#define SEASONS_VSH -#include "/lib/climate_settings.glsl" - - -uniform sampler2D noisetex;//depth -float densityAtPos(in vec3 pos){ - pos /= 18.; - pos.xz *= 0.5; - vec3 p = floor(pos); - vec3 f = fract(pos); - vec2 uv = p.xz + f.xz + p.y * vec2(0.0,193.0); - vec2 coord = uv / 512.0; - - //The y channel has an offset to avoid using two textures fetches - vec2 xy = texture2D(noisetex, coord).yx; - - return mix(xy.r,xy.g, f.y); -} -float luma(vec3 color) { - return dot(color,vec3(0.21, 0.72, 0.07)); -} - -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// - - -void main() { - - gl_Position = ftransform(); - - vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz; - - - - /////// ----- COLOR STUFF ----- /////// - color = gl_Color; - - VanillaAO = 1.0 - clamp(color.a,0,1); - if (color.a < 0.3) color.a = 1.0; // fix vanilla ao on some custom block models. - - - - - /////// ----- RANDOM STUFF ----- /////// - - lmtexcoord.xy = (gl_MultiTexCoord0).xy; - - // #ifdef POM - vec2 midcoord = (gl_TextureMatrix[0] * mc_midTexCoord).st; - vec2 texcoordminusmid = lmtexcoord.xy-midcoord; - vtexcoordam.pq = abs(texcoordminusmid)*2; - vtexcoordam.st = min(lmtexcoord.xy,midcoord-texcoordminusmid); - vtexcoord.xy = sign(texcoordminusmid)*0.5+0.5; - // #endif - - vec2 lmcoord = gl_MultiTexCoord1.xy / 255.0; // is this even correct? lol' - lmtexcoord.zw = lmcoord; - - - - #ifdef MC_NORMAL_MAP - tangent = vec4(normalize(gl_NormalMatrix *at_tangent.rgb),at_tangent.w); - #endif - - normalMat = vec4(normalize(gl_NormalMatrix *gl_Normal), 1.0); - FlatNormals = normalMat.xyz; - - blockID = mc_Entity.x; - velocity = at_velocity; - - if(mc_Entity.x == 10009) normalMat.a = 0.60; - - - PORTAL = 0; - SIGN = 0; - - #ifdef WORLD - // disallow POM to work on signs. - if(blockEntityId == 2200) SIGN = 1; - - if(blockEntityId == 2100) PORTAL = 1; - #endif - - NameTags = 0; - PHYSICSMOD_SNOW = 0; - -#ifdef ENTITIES - // disallow POM to work on item frames. - if(entityId == 2300) SIGN = 1; - - #ifdef ENTITY_PHYSICSMOD_SNOW - if(entityId == 829925) PHYSICSMOD_SNOW = 1; - #endif - - - // try and single out nametag text and then discard nametag background - // if( dot(gl_Color.rgb, vec3(1.0/3.0)) < 1.0) NameTags = 1; - // if(gl_Color.a < 1.0) NameTags = 1; - // if(gl_Color.a >= 0.24 && gl_Color.a <= 0.25 ) gl_Position = vec4(10,10,10,1); - - if(entityId == 1100 || entityId == 1200 || entityId == 2468) normalMat.a = 0.45; - -#endif - - if(mc_Entity.x == 10003) normalMat.a = 0.55; - - /////// ----- EMISSIVE STUFF ----- /////// - EMISSIVE = 0.0; - LIGHTNING = 0; - // if(NameTags > 0) EMISSIVE = 0.9; - - // normal block lightsources - if(mc_Entity.x == 10005) EMISSIVE = 0.5; - - // special cases light lightning and beacon beams... - #ifdef ENTITIES - if(entityId == 12345){ - LIGHTNING = 1; - normalMat.a = 0.50; - } - #endif - - /////// ----- SSS STUFF ----- /////// - SSSAMOUNT = 0.0; - - HELD_ITEM_BRIGHTNESS = 0.0; - - #ifdef Hand_Held_lights - if(heldItemId == 100 || heldItemId2 == 100) HELD_ITEM_BRIGHTNESS = 0.9; - #endif - - -#ifdef WORLD - - - /////// ----- SSS ON BLOCKS ----- /////// - // strong - if(mc_Entity.x == 10001 || mc_Entity.x == 10003 || mc_Entity.x == 10004 || mc_Entity.x == 10009) SSSAMOUNT = 1.0; - - // medium - if(mc_Entity.x == 10006 || mc_Entity.x == 200) SSSAMOUNT = 0.75; - - // low - - #ifdef MISC_BLOCK_SSS - if(mc_Entity.x == 10007 || mc_Entity.x == 10008) SSSAMOUNT = 0.5; // weird SSS on blocks like grass and stuff - #endif - - #ifdef ENTITIES - #ifdef MOB_SSS - /////// ----- SSS ON MOBS----- /////// - // strong - if(entityId == 1100) SSSAMOUNT = 0.75; - - // medium - - // low - if(entityId == 1200) SSSAMOUNT = 0.3; - #endif - #endif - - #ifdef BLOCKENTITIES - /////// ----- SSS ON BLOCK ENTITIES----- /////// - // strong - - // medium - if(blockEntityId == 10010) SSSAMOUNT = 0.4; - - // low - - #endif - - - #ifdef WAVY_PLANTS - bool istopv = gl_MultiTexCoord0.t < mc_midTexCoord.t; - - // #ifdef WORLD - // #ifndef HAND - // vec3 worldpos = mat3(gbufferModelViewInverse) * position + gbufferModelViewInverse[3].xyz + cameraPosition; - // // worldpos.xyz += (densityAtPos(worldpos*255 )*2) - cameraPosition; - // worldpos.xyz += sin(worldpos) - cameraPosition; - // position = mat3(gbufferModelView) * worldpos + gbufferModelView[3].xyz; - // #endif - // #endif - - if ((mc_Entity.x == 10001 || mc_Entity.x == 10009) && istopv && abs(position.z) < 64.0) { - vec3 worldpos = mat3(gbufferModelViewInverse) * position + gbufferModelViewInverse[3].xyz + cameraPosition; - worldpos.xyz += calcMovePlants(worldpos.xyz)*lmtexcoord.w - cameraPosition; - position = mat3(gbufferModelView) * worldpos + gbufferModelView[3].xyz; - } - - - - if (mc_Entity.x == 10003 && abs(position.z) < 64.0) { - vec3 worldpos = mat3(gbufferModelViewInverse) * position + gbufferModelViewInverse[3].xyz + cameraPosition; - worldpos.xyz += calcMoveLeaves(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))*lmtexcoord.w - cameraPosition; - position = mat3(gbufferModelView) * worldpos + gbufferModelView[3].xyz; - } - #endif - - gl_Position = toClipSpace3(position); - -#endif - - #ifdef Seasons - #ifdef WORLD - #ifndef BLOCKENTITIES - #ifndef ENTITIES - #ifndef HAND - float blank = 0.0; - YearCycleColor(color.rgb, gl_Color.rgb, blank); - #endif - #endif - #endif - #endif - #endif - - #ifdef TAA_UPSCALING - gl_Position.xy = gl_Position.xy * RENDER_SCALE + RENDER_SCALE * gl_Position.w - gl_Position.w; - #endif - #ifdef TAA - gl_Position.xy += offsets[framemod8] * gl_Position.w * texelSize; - #endif - - -#if DOF_QUALITY == 5 - vec2 jitter = clamp(jitter_offsets[frameCounter % 64], -1.0, 1.0); - jitter = rotate(radians(float(frameCounter))) * jitter; - jitter.y *= aspectRatio; - jitter.x *= DOF_ANAMORPHIC_RATIO; - - #if MANUAL_FOCUS == -2 - float focusMul = 0; - #elif MANUAL_FOCUS == -1 - float focusMul = gl_Position.z - mix(pow(512.0, screenBrightness), 512.0 * screenBrightness, 0.25); - #else - float focusMul = gl_Position.z - MANUAL_FOCUS; - #endif - - vec2 totalOffset = (jitter * JITTER_STRENGTH) * focusMul * 1e-2; - gl_Position.xy += hideGUI >= 1 ? totalOffset : vec2(0); - #endif -} diff --git a/shaders/gbuffers_all_translucent.fsh b/shaders/gbuffers_all_translucent.fsh deleted file mode 100644 index a244ce1..0000000 --- a/shaders/gbuffers_all_translucent.fsh +++ /dev/null @@ -1,521 +0,0 @@ -// #version 120 -//#extension GL_EXT_gpu_shader4 : disable - -varying vec4 lmtexcoord; -varying vec4 color; - - -uniform sampler2D normals; -varying vec4 tangent; - -varying vec4 normalMat; -varying vec3 binormal; - - -varying vec3 viewVector; - -#include "/lib/settings.glsl" -#include "/lib/res_params.glsl" - - -uniform sampler2D texture; -uniform sampler2D noisetex; -uniform sampler2DShadow shadow; -// uniform sampler2D gaux2; -// uniform sampler2D gaux1; - -// uniform sampler2D colortex4; -uniform sampler2D colortex5; -uniform sampler2D depthtex1; - - -uniform vec3 sunVec; -uniform float frameTimeCounter; -uniform float lightSign; -uniform float near; -uniform float far; -uniform float moonIntensity; -uniform float sunIntensity; -uniform vec3 sunColor; -uniform vec3 nsunColor; -uniform vec3 upVec; -uniform float sunElevation; -uniform float fogAmount; -uniform vec2 texelSize; -uniform float rainStrength; -uniform float skyIntensityNight; -uniform float skyIntensity; -flat varying vec3 WsunVec; -uniform mat4 gbufferPreviousModelView; -uniform vec3 previousCameraPosition; -uniform int framemod8; -uniform sampler2D specular; -uniform int frameCounter; -uniform int isEyeInWater; -uniform ivec2 eyeBrightness; -uniform ivec2 eyeBrightnessSmooth; - - -flat varying vec4 lightCol; //main light source color (rgb),used light source(1=sun,-1=moon) - -flat varying vec3 averageSkyCol_Clouds; -// flat varying vec3 averageSkyCol; - - - -#include "/lib/Shadow_Params.glsl" -#include "/lib/color_transforms.glsl" -#include "/lib/projections.glsl" -#include "/lib/sky_gradient.glsl" -#include "/lib/waterBump.glsl" -#include "/lib/clouds.glsl" -#include "/lib/stars.glsl" -#include "/lib/volumetricClouds.glsl" -#define OVERWORLD_SHADER -#include "/lib/diffuse_lighting.glsl" - - -float blueNoise(){ - return fract(texelFetch2D(noisetex, ivec2(gl_FragCoord.xy)%512, 0).a + 1.0/1.6180339887 * frameCounter); -} -float R2_dither(){ - vec2 alpha = vec2(0.75487765, 0.56984026); - return fract(alpha.x * gl_FragCoord.x + alpha.y * gl_FragCoord.y + 1.0/1.6180339887 * frameCounter) ; -} -float interleaved_gradientNoise(){ - vec2 coord = gl_FragCoord.xy + (frameCounter%40000); - // vec2 coord = gl_FragCoord.xy + frameTimeCounter; - // vec2 coord = gl_FragCoord.xy; - float noise = fract( 52.9829189 * fract( (coord.x * 0.06711056) + (coord.y * 0.00583715)) ); - return noise ; -} -float interleaved_gradientNoise(float temporal){ - vec2 coord = gl_FragCoord.xy; - float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y)+temporal); - return noise; -} - -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.); - - - - - - - -#define PW_DEPTH 1.0 //[0.5 1.0 1.5 2.0 2.5 3.0] -#define PW_POINTS 1 //[2 4 6 8 16 32] - -vec3 getParallaxDisplacement(vec3 posxz, float iswater,float bumpmult,vec3 viewVec) { - float waveZ = mix(20.0,0.25,iswater); - float waveM = mix(0.0,4.0,iswater); - - vec3 parallaxPos = posxz; - vec2 vec = viewVector.xy * (1.0 / float(PW_POINTS)) * 22.0 * PW_DEPTH; - float waterHeight = getWaterHeightmap(posxz.xz, waveM, waveZ, iswater) ; - - parallaxPos.xz += waterHeight * vec; - - return parallaxPos; - -} - -vec3 applyBump(mat3 tbnMatrix, vec3 bump, float puddle_values){ - float bumpmult = 1; - bump = bump * vec3(bumpmult, bumpmult, bumpmult) + vec3(0.0f, 0.0f, 1.0f - bumpmult); - return normalize(bump*tbnMatrix); -} - -vec2 tapLocation(int sampleNumber,int nb, float nbRot,float jitter,float distort) -{ - float alpha = (sampleNumber+jitter)/nb; - float angle = jitter*6.28 + alpha * nbRot * 6.28; - - float sin_v, cos_v; - - sin_v = sin(angle); - cos_v = cos(angle); - - return vec2(cos_v, sin_v)*sqrt(alpha); -} - - -vec3 viewToWorld(vec3 viewPosition) { - vec4 pos; - pos.xyz = viewPosition; - pos.w = 0.0; - pos = gbufferModelViewInverse * pos; - return pos.xyz; -} - -vec3 worldToView(vec3 worldPos) { - vec4 pos = vec4(worldPos, 0.0); - pos = gbufferModelView * pos; - return pos.xyz; -} -vec4 encode (vec3 n, vec2 lightmaps){ - n.xy = n.xy / dot(abs(n), vec3(1.0)); - n.xy = n.z <= 0.0 ? (1.0 - abs(n.yx)) * sign(n.xy) : n.xy; - vec2 encn = clamp(n.xy * 0.5 + 0.5,-1.0,1.0); - - return vec4(encn,vec2(lightmaps.x,lightmaps.y)); -} - -//encoding by jodie -float encodeVec2(vec2 a){ - const vec2 constant1 = vec2( 1., 256.) / 65535.; - vec2 temp = floor( a * 255. ); - return temp.x*constant1.x+temp.y*constant1.y; -} -float encodeVec2(float x,float y){ - return encodeVec2(vec2(x,y)); -} - - -float invLinZ (float lindepth){ - return -((2.0*near/lindepth)-far-near)/(far-near); -} -float ld(float dist) { - return (2.0 * near) / (far + near - dist * (far - near)); -} - -vec3 rayTrace(vec3 dir,vec3 position,float dither, float fresnel, bool inwater){ - - float quality = mix(15,SSR_STEPS,fresnel); - vec3 clipPosition = toClipSpace3(position); - float rayLength = ((position.z + dir.z * far*sqrt(3.)) > -near) ? - (-near -position.z) / dir.z : far*sqrt(3.); - vec3 direction = normalize(toClipSpace3(position+dir*rayLength)-clipPosition); //convert to clip space - direction.xy = normalize(direction.xy); - - //get at which length the ray intersects with the edge of the screen - vec3 maxLengths = (step(0.,direction)-clipPosition) / direction; - float mult = min(min(maxLengths.x,maxLengths.y),maxLengths.z); - - - vec3 stepv = direction * mult / quality*vec3(RENDER_SCALE,1.0); - - - vec3 spos = clipPosition*vec3(RENDER_SCALE,1.0) + stepv*dither; - float minZ = clipPosition.z; - float maxZ = spos.z+stepv.z*0.5; - - spos.xy += offsets[framemod8]*texelSize*0.5/RENDER_SCALE; - - float dist = 1.0 + clamp(position.z*position.z/50.0,0,2); // shrink sample size as distance increases - for (int i = 0; i <= int(quality); i++) { - #ifdef USE_QUARTER_RES_DEPTH - // decode depth buffer - float sp = sqrt(texelFetch2D(colortex4,ivec2(spos.xy/texelSize/4),0).w/65000.0); - sp = invLinZ(sp); - - if(sp <= max(maxZ,minZ) && sp >= min(maxZ,minZ)) return vec3(spos.xy/RENDER_SCALE,sp); - #else - float sp = texelFetch2D(depthtex1,ivec2(spos.xy/texelSize),0).r; - if(sp <= max(maxZ,minZ) && sp >= min(maxZ,minZ)) return vec3(spos.xy/RENDER_SCALE,sp); - - - #endif - - spos += stepv; - //small bias - minZ = maxZ-(0.0001/dist)/ld(spos.z); - if(inwater) minZ = maxZ-0.0004/ld(spos.z); - maxZ += stepv.z; - } - - return vec3(1.1); -} - -vec3 GGX (vec3 n, vec3 v, vec3 l, float r, vec3 F0) { - r = pow(r,2.5); -// r*=r; - - vec3 h = l + v; - float hn = inversesqrt(dot(h, h)); - - float dotLH = clamp(dot(h,l)*hn,0.,1.); - float dotNH = clamp(dot(h,n)*hn,0.,1.) ; - float dotNL = clamp(dot(n,l),0.,1.); - float dotNHsq = dotNH*dotNH; - - float denom = dotNHsq * r - dotNHsq + 1.; - float D = r / (3.141592653589793 * denom * denom); - vec3 F = F0 + (1. - F0) * exp2((-5.55473*dotLH-6.98316)*dotLH); - float k2 = .25 * r; - - return dotNL * D * F / (dotLH*dotLH*(1.0-k2)+k2); -} - - - -#define PHYSICSMOD_FRAGMENT -#include "/lib/oceans.glsl" - -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// - -/* RENDERTARGETS:2,7,11,14 */ -void main() { -if (gl_FragCoord.x * texelSize.x < RENDER_SCALE.x && gl_FragCoord.y * texelSize.y < RENDER_SCALE.y ) { - vec2 tempOffset = offsets[framemod8]; - vec3 fragpos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0)); - - gl_FragData[0] = texture2D(texture, lmtexcoord.xy, Texture_MipMap_Bias) * color; - vec3 Albedo = toLinear(gl_FragData[0].rgb); - - float UnchangedAlpha = gl_FragData[0].a; - - float iswater = normalMat.w; - - #ifdef HAND - iswater = 0.1; - #endif - - #ifdef Vanilla_like_water - if (iswater > 0.5) { - gl_FragData[0].a = luma(Albedo.rgb); - Albedo = color.rgb * sqrt(luma(Albedo.rgb)); - } - #else - if (iswater > 0.9) { - Albedo = vec3(0.0); - gl_FragData[0] = vec4(vec3(0.0),1.0/255.0); - } - #endif - - - vec4 COLORTEST = vec4(Albedo,UnchangedAlpha); - - - vec3 p3 = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz; - - vec3 normal = normalMat.xyz; - vec2 TangentNormal = vec2(0); // for refractions - - vec3 tangent2 = normalize(cross(tangent.rgb,normal)*tangent.w); - mat3 tbnMatrix = mat3(tangent.x, tangent2.x, normal.x, - tangent.y, tangent2.y, normal.y, - tangent.z, tangent2.z, normal.z); - - - - - /// ------ NORMALS ------ /// - - vec4 NormalTex = texture2D(normals, lmtexcoord.xy, Texture_MipMap_Bias).rgba; - NormalTex.xy = NormalTex.xy*2.0-1.0; - NormalTex.z = clamp(sqrt(1.0 - dot(NormalTex.xy, NormalTex.xy)),0.0,1.0) ; - TangentNormal = NormalTex.xy*0.5+0.5; - - normal = applyBump(tbnMatrix, NormalTex.xyz, 1.0); - - if (iswater > 0.95){ - #ifdef PhysicsMod_support - if(physics_iterationsNormal < 1.0){ - #endif - float bumpmult = 1.0; - vec3 bump = vec3(0); - vec3 posxz = p3+cameraPosition; - - posxz.xz -= posxz.y; - posxz.xyz = getParallaxDisplacement(posxz,iswater,bumpmult,normalize(tbnMatrix*fragpos)) ; - - bump = normalize(getWaveHeight(posxz.xz,iswater)); - - TangentNormal = bump.xy*0.5+0.5; // tangent space normals for refraction - - bump = bump * vec3(bumpmult, bumpmult, bumpmult) + vec3(0.0f, 0.0f, 1.0f - bumpmult); - normal = normalize(bump * tbnMatrix); - - #ifdef PhysicsMod_support - }else{ - /// ------ PHYSICS MOD OCEAN SHIT ------ /// - - WavePixelData wave = physics_wavePixel(physics_localPosition.xz, physics_localWaviness, physics_iterationsNormal, physics_gameTime); - // float Foam = wave.foam; - - // Albedo = mix(Albedo,vec3(1),Foam); - // gl_FragData[0].a = Foam; - - - normal = normalize(worldToView(wave.normal) + mix(normal, vec3(0.0), clamp(physics_localWaviness,0.0,1.0))); - - vec3 worldSpaceNormal = normal; - - vec3 bitangent = normalize(cross(tangent.xyz, worldSpaceNormal)); - mat3 tbn_new = mat3(tangent.xyz, binormal, worldSpaceNormal); - vec3 tangentSpaceNormal = worldSpaceNormal * tbn_new; - - TangentNormal = tangentSpaceNormal.xy * 0.5 + 0.5; - } - #endif - } - - gl_FragData[2] = vec4(encodeVec2(TangentNormal), encodeVec2(COLORTEST.rg), encodeVec2(COLORTEST.ba), UnchangedAlpha); - - - float NdotL = clamp(lightSign*dot(normal,sunVec) ,0.0,1.0); - NdotL = clamp((-15 + NdotL*255.0) / 240.0 ,0.0,1.0); - - float Shadows = 1.0; - int shadowmapindicator = 0; - //compute shadows only if not backface - if (NdotL > 0.001) { - vec3 p3 = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz; - vec3 projectedShadowPosition = mat3(shadowModelView) * p3 + shadowModelView[3].xyz; - projectedShadowPosition = diagonal3(shadowProjection) * projectedShadowPosition + shadowProjection[3].xyz; - - //apply distortion - float distortFactor = calcDistort(projectedShadowPosition.xy); - projectedShadowPosition.xy *= distortFactor; - //do shadows only if on shadow map - if (abs(projectedShadowPosition.x) < 1.0-1.5/shadowMapResolution && abs(projectedShadowPosition.y) < 1.0-1.5/shadowMapResolution){ - - Shadows = 0.0; - projectedShadowPosition = projectedShadowPosition * vec3(0.5,0.5,0.5/6.0) + vec3(0.5,0.5,0.5); - - #ifdef BASIC_SHADOW_FILTER - const float threshMul = max(2048.0/shadowMapResolution*shadowDistance/128.0,0.95); - float distortThresh = (sqrt(1.0-NdotL*NdotL)/NdotL+0.7)/distortFactor; - float diffthresh = distortThresh/6000.0*threshMul; - - float noise = blueNoise(); - float rdMul = 4.0/shadowMapResolution; - - for(int i = 0; i < 9; i++){ - vec2 offsetS = tapLocation(i,9, 1.618,noise,0.0); - - float weight = 1.0+(i+noise)*rdMul/9.0*shadowMapResolution; - Shadows += shadow2D(shadow,vec3(projectedShadowPosition + vec3(rdMul*offsetS,-diffthresh*weight))).x/9.0; - } - #else - Shadows = shadow2D(shadow, projectedShadowPosition + vec3(0.0,0.0,-0.0001)).x; - #endif - - shadowmapindicator = 1; - } - } - - if(shadowmapindicator < 1) Shadows = clamp((lmtexcoord.w-0.8) * 5,0,1); - - #ifdef CLOUDS_SHADOWS - Shadows *= GetCloudShadow(p3); - #endif - - vec3 AmbientLightColor = averageSkyCol_Clouds; - vec3 DirectLightColor = lightCol.rgb/80.0; - - vec3 WS_normal = viewToWorld(normal); - vec3 ambientCoefs = WS_normal/dot(abs(WS_normal),vec3(1.)); - float skylight = clamp(ambientCoefs.y + 0.5,0.25,2.0); - - vec2 lightmaps2 = lmtexcoord.zw; - - - float lightleakfix = clamp(pow(eyeBrightnessSmooth.y/240. + lightmaps2.y,2) ,0.0,1.0); - - AmbientLightColor += (lightningEffect * 10) * skylight * pow(lightmaps2.y,2); - - vec3 Indirect_lighting = DoAmbientLighting(AmbientLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), lightmaps2, skylight); - vec3 Direct_lighting = DoDirectLighting(DirectLightColor, Shadows, NdotL, 0.0); - - vec3 FinalColor = (Direct_lighting + Indirect_lighting) * Albedo; - - #ifdef Glass_Tint - float alphashit = min(pow(gl_FragData[0].a,2.0),1.0); - FinalColor *= alphashit; - #endif - - #ifdef WATER_REFLECTIONS - vec2 SpecularTex = texture2D(specular, lmtexcoord.xy, Texture_MipMap_Bias).rg; - - SpecularTex = (iswater > 0.0 && iswater < 0.9) && SpecularTex.r > 0.0 && SpecularTex.g < 0.9 ? SpecularTex : vec2(1.0,0.1); - - float roughness = max(pow(1.0-SpecularTex.r,2.0),0.05); - float f0 = SpecularTex.g; - - if (iswater > 0.0){ - vec3 Reflections_Final = vec3(0.0); - vec4 Reflections = vec4(0.0); - vec3 SkyReflection = vec3(0.0); - vec3 SunReflection = vec3(0.0); - - float indoors = clamp((lmtexcoord.w-0.6)*5.0, 0.0,1.0); - - vec3 reflectedVector = reflect(normalize(fragpos), normal); - float normalDotEye = dot(normal, normalize(fragpos)); - float fresnel = pow(clamp(1.0 + normalDotEye,0.0,1.0), 5.0); - - // snells window looking thing - #ifdef PhysicsMod_support - if(isEyeInWater == 1 && physics_iterationsNormal > 0.0) fresnel = clamp( 1.0 - (pow( normalDotEye * 1.66 ,25)),0.02,1.0); - #else - if(isEyeInWater == 1 ) fresnel = pow(clamp(1.66 + normalDotEye,0.0,1.0), 25.0); - #endif - - fresnel = mix(f0, 1.0, fresnel); - - vec3 wrefl = mat3(gbufferModelViewInverse)*reflectedVector; - - // SSR, Sky, and Sun reflections - #ifdef WATER_BACKGROUND_SPECULAR - SkyReflection = skyCloudsFromTex(wrefl,colortex4).rgb / 30.0; - if(isEyeInWater == 1) SkyReflection = vec3(0.0); - #endif - - #ifdef WATER_SUN_SPECULAR - SunReflection = Direct_lighting * GGX(normal, -normalize(fragpos), lightSign*sunVec, roughness, vec3(f0)); - #endif - #ifdef SCREENSPACE_REFLECTIONS - if(iswater > 0.0){ - vec3 rtPos = rayTrace(reflectedVector,fragpos.xyz, interleaved_gradientNoise(), fresnel, isEyeInWater == 1); - if (rtPos.z < 1.){ - vec3 previousPosition = mat3(gbufferModelViewInverse) * toScreenSpace(rtPos) + gbufferModelViewInverse[3].xyz + cameraPosition-previousCameraPosition; - previousPosition = mat3(gbufferPreviousModelView) * previousPosition + gbufferPreviousModelView[3].xyz; - previousPosition.xy = projMAD(gbufferPreviousProjection, previousPosition).xy / -previousPosition.z * 0.5 + 0.5; - if (previousPosition.x > 0.0 && previousPosition.y > 0.0 && previousPosition.x < 1.0 && previousPosition.x < 1.0) { - Reflections.a = 1.0; - Reflections.rgb = texture2D(colortex5,previousPosition.xy).rgb; - } - } - } - #endif - - float visibilityFactor = clamp(exp2((pow(roughness,3.0) / f0) * -4),0,1); - - Reflections_Final = mix(SkyReflection*indoors, Reflections.rgb, Reflections.a); - Reflections_Final = mix(FinalColor, Reflections_Final, fresnel * visibilityFactor); - Reflections_Final += SunReflection * lightleakfix; - - gl_FragData[0].rgb = Reflections_Final; - - //correct alpha channel with fresnel - gl_FragData[0].a = mix(gl_FragData[0].a, 1.0, fresnel); - - if (gl_FragData[0].r > 65000.) gl_FragData[0].rgba = vec4(0.); - - } else { - gl_FragData[0].rgb = FinalColor; - } - #else - gl_FragData[0].rgb = FinalColor; - #endif - - #ifndef HAND - gl_FragData[1] = vec4(Albedo,iswater); - #endif - - gl_FragData[3].a = max(lmtexcoord.w*blueNoise()*0.05 + lmtexcoord.w,0.0); -} -} \ No newline at end of file diff --git a/shaders/gbuffers_all_translucent.vsh b/shaders/gbuffers_all_translucent.vsh deleted file mode 100644 index eb824b0..0000000 --- a/shaders/gbuffers_all_translucent.vsh +++ /dev/null @@ -1,183 +0,0 @@ -// #version 120 -//#extension GL_EXT_gpu_shader4 : disable -#include "/lib/settings.glsl" -#include "/lib/res_params.glsl" -#include "/lib/bokeh.glsl" - -/* -!! DO NOT REMOVE !! -This code is from Chocapic13' shaders -Read the terms of modification and sharing before changing something below please ! -!! DO NOT REMOVE !! -*/ - -flat varying vec3 averageSkyCol_Clouds; -flat varying vec3 averageSkyCol; - -flat varying vec4 lightCol; - - -varying vec4 lmtexcoord; -varying vec4 color; -varying vec4 normalMat; -varying vec3 binormal; -varying vec4 tangent; - -uniform mat4 gbufferModelViewInverse; -varying vec3 viewVector; - -flat varying int glass; - -attribute vec4 at_tangent; -attribute vec4 mc_Entity; - -uniform sampler2D colortex4; - -uniform vec3 sunPosition; -flat varying vec3 WsunVec; -uniform float sunElevation; - -varying vec4 tangent_other; - -uniform int frameCounter; -uniform float far; -uniform float aspectRatio; -uniform float viewHeight; -uniform float viewWidth; -uniform int hideGUI; -uniform float screenBrightness; - -uniform vec2 texelSize; -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.); -#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z) -#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz) -vec4 toClipSpace3(vec3 viewSpacePosition) { - return vec4(projMAD(gl_ProjectionMatrix, viewSpacePosition),-viewSpacePosition.z); -} - - - - - - - - -#define PHYSICSMOD_VERTEX -#include "/lib/oceans.glsl" - -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// - -void main() { - - vec4 Swtich_gl_vertex = gl_Vertex; - - #ifdef PhysicsMod_support - if(physics_iterationsNormal > 0.0){ - // basic texture to determine how shallow/far away from the shore the water is - physics_localWaviness = texelFetch(physics_waviness, ivec2(gl_Vertex.xz) - physics_textureOffset, 0).r; - // transform gl_Vertex (since it is the raw mesh, i.e. not transformed yet) - vec4 finalPosition = vec4(gl_Vertex.x, gl_Vertex.y + physics_waveHeight(gl_Vertex.xz, PHYSICS_ITERATIONS_OFFSET, physics_localWaviness, physics_gameTime), gl_Vertex.z, gl_Vertex.w); - // pass this to the fragment shader to fetch the texture there for per fragment normals - physics_localPosition = finalPosition.xyz; - - Swtich_gl_vertex.xyz = finalPosition.xyz ; - } - #endif - - lmtexcoord.xy = (gl_MultiTexCoord0).xy; - vec2 lmcoord = gl_MultiTexCoord1.xy / 255.0; // is this even correct? lol - lmtexcoord.zw = lmcoord; - - - - vec3 position = mat3(gl_ModelViewMatrix) * vec3(Swtich_gl_vertex) + gl_ModelViewMatrix[3].xyz; - gl_Position = toClipSpace3(position); - - color = vec4(gl_Color.rgb,1.0); - - float mat = 0.0; - - if(mc_Entity.x == 8.0) { - mat = 1.0; - - gl_Position.z -= 1e-4; - } - - if (mc_Entity.x == 10002) mat = 0.2; - if (mc_Entity.x == 72) mat = 0.5; - - #ifdef ENTITIES - mat = 0.2; - #endif - - - tangent = vec4(normalize(gl_NormalMatrix *at_tangent.rgb),at_tangent.w); - - normalMat = vec4(normalize(gl_NormalMatrix *gl_Normal), 1.0); - normalMat.a = mat; - - - - - - vec3 tangent2 = normalize( gl_NormalMatrix *at_tangent.rgb); - binormal = normalize(cross(tangent2.rgb,normalMat.xyz)*at_tangent.w); - - mat3 tbnMatrix = mat3(tangent2.x, binormal.x, normalMat.x, - tangent2.y, binormal.y, normalMat.y, - tangent2.z, binormal.z, normalMat.z); - - viewVector = ( gl_ModelViewMatrix * Swtich_gl_vertex).xyz; - viewVector = normalize(tbnMatrix * viewVector); - - - - #ifdef TAA_UPSCALING - gl_Position.xy = gl_Position.xy * RENDER_SCALE + RENDER_SCALE * gl_Position.w - gl_Position.w; - #endif - #ifdef TAA - gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize; - #endif - - vec3 sc = texelFetch2D(colortex4,ivec2(6,37),0).rgb; - - - lightCol.a = float(sunElevation > 1e-5)*2-1.; - lightCol.rgb = sc; - - WsunVec = lightCol.a*normalize(mat3(gbufferModelViewInverse) *sunPosition); - - #if DOF_QUALITY == 5 - vec2 jitter = clamp(jitter_offsets[frameCounter % 64], -1.0, 1.0); - jitter = rotate(radians(float(frameCounter))) * jitter; - jitter.y *= aspectRatio; - jitter.x *= DOF_ANAMORPHIC_RATIO; - - #if MANUAL_FOCUS == -2 - float focusMul = 0; - #elif MANUAL_FOCUS == -1 - float focusMul = gl_Position.z - mix(pow(512.0, screenBrightness), 512.0 * screenBrightness, 0.25); - #else - float focusMul = gl_Position.z - MANUAL_FOCUS; - #endif - - vec2 totalOffset = (jitter * JITTER_STRENGTH) * focusMul * 1e-2; - gl_Position.xy += hideGUI >= 1 ? totalOffset : vec2(0); - #endif - - averageSkyCol_Clouds = texelFetch2D(colortex4,ivec2(0,37),0).rgb; - // averageSkyCol = texelFetch2D(colortex4,ivec2(1,37),0).rgb; - -} diff --git a/shaders/gbuffers_armor_glint.fsh b/shaders/gbuffers_armor_glint.fsh deleted file mode 100644 index 430bda4..0000000 --- a/shaders/gbuffers_armor_glint.fsh +++ /dev/null @@ -1,25 +0,0 @@ -#version 120 - -#include "/lib/settings.glsl" - -varying vec4 lmtexcoord; -varying vec4 color; -uniform sampler2D texture; - -//faster and actually more precise than pow 2.2 -vec3 toLinear(vec3 sRGB){ - return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878); -} - -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -/* DRAWBUFFERS:2 */ - -void main() { - - gl_FragData[0] = vec4(toLinear( texture2D(texture, lmtexcoord.xy).rgb * color.rgb), 0.1); - -} diff --git a/shaders/gbuffers_armor_glint.vsh b/shaders/gbuffers_armor_glint.vsh deleted file mode 100644 index acb4c70..0000000 --- a/shaders/gbuffers_armor_glint.vsh +++ /dev/null @@ -1,47 +0,0 @@ -#version 120 - -#include "/lib/settings.glsl" -#include "/lib/res_params.glsl" - -/* -!! DO NOT REMOVE !! -This code is from Chocapic13' shaders -Read the terms of modification and sharing before changing something below please ! -!! DO NOT REMOVE !! -*/ - -varying vec4 lmtexcoord; -varying vec4 color; - -uniform vec2 texelSize; -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.); - -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// - -void main() { - gl_Position = ftransform(); - - lmtexcoord.xy = (gl_TextureMatrix[0] * gl_MultiTexCoord0).st; - - vec2 lmcoord = gl_MultiTexCoord1.xy/255.; - - lmtexcoord.zw = lmcoord*lmcoord; - - color = gl_Color; - - #ifdef TAA - gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize; - #endif -} diff --git a/shaders/gbuffers_basic.fsh b/shaders/gbuffers_basic.fsh deleted file mode 100644 index 77dd9a3..0000000 --- a/shaders/gbuffers_basic.fsh +++ /dev/null @@ -1,5 +0,0 @@ -#version 120 - -#define ENTITIES -#define WORLD -#include "gbuffers_all_solid.fsh" \ No newline at end of file diff --git a/shaders/gbuffers_basic.vsh b/shaders/gbuffers_basic.vsh deleted file mode 100644 index e1bf378..0000000 --- a/shaders/gbuffers_basic.vsh +++ /dev/null @@ -1,5 +0,0 @@ -#version 120 - -#define ENTITIES -#define WORLD -#include "gbuffers_all_solid.vsh" \ No newline at end of file diff --git a/shaders/gbuffers_beaconbeam.fsh b/shaders/gbuffers_beaconbeam.fsh deleted file mode 100644 index 4ddf770..0000000 --- a/shaders/gbuffers_beaconbeam.fsh +++ /dev/null @@ -1,47 +0,0 @@ -#version 120 - - -varying vec4 color; -varying vec2 texcoord; - -uniform sampler2D texture; - -//faster and actually more precise than pow 2.2 -vec3 toLinear(vec3 sRGB){ - return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878); -} - -vec4 encode (vec3 n, vec2 lightmaps){ - n.xy = n.xy / dot(abs(n), vec3(1.0)); - n.xy = n.z <= 0.0 ? (1.0 - abs(n.yx)) * sign(n.xy) : n.xy; - vec2 encn = clamp(n.xy * 0.5 + 0.5,-1.0,1.0); - - return vec4(encn,vec2(lightmaps.x,lightmaps.y)); -} - -//encoding by jodie -float encodeVec2(vec2 a){ - const vec2 constant1 = vec2( 1., 256.) / 65535.; - vec2 temp = floor( a * 255. ); - return temp.x*constant1.x+temp.y*constant1.y; -} -float encodeVec2(float x,float y){ - return encodeVec2(vec2(x,y)); -} - -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -/* DRAWBUFFERS:28 */ - -void main() { - - vec4 Albedo = vec4(texture2D(texture, texcoord).rgb*5.0,1.0); - Albedo *= color; - Albedo.rgb = toLinear(Albedo.rgb); - - gl_FragData[0] = Albedo; - gl_FragData[1] = vec4(0.0,0.0,0.0,0.9); -} \ No newline at end of file diff --git a/shaders/gbuffers_beaconbeam.vsh b/shaders/gbuffers_beaconbeam.vsh deleted file mode 100644 index 845f4ba..0000000 --- a/shaders/gbuffers_beaconbeam.vsh +++ /dev/null @@ -1,48 +0,0 @@ -#version 120 -//#extension GL_EXT_gpu_shader4 : disable - -#include "/lib/settings.glsl" -#include "/lib/res_params.glsl" - -/* -!! DO NOT REMOVE !! -This code is from Chocapic13' shaders -Read the terms of modification and sharing before changing something below please ! -!! DO NOT REMOVE !! -*/ - -varying vec4 color; -varying vec2 texcoord; - -uniform vec2 texelSize; -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.); -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// - -void main() { - - gl_Position = ftransform(); - - if(gl_Color.a < 1.0 ) gl_Position = vec4(10,10,10,1); - - texcoord = (gl_MultiTexCoord0).xy; - color = gl_Color; - - #ifdef TAA_UPSCALING - gl_Position.xy = gl_Position.xy * RENDER_SCALE + RENDER_SCALE * gl_Position.w - gl_Position.w; - #endif - #ifdef TAA - gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize; - #endif -} diff --git a/shaders/gbuffers_block.fsh b/shaders/gbuffers_block.fsh deleted file mode 100644 index c7c36b4..0000000 --- a/shaders/gbuffers_block.fsh +++ /dev/null @@ -1,5 +0,0 @@ -#version 120 - -#define WORLD -#define BLOCKENTITIES -#include "gbuffers_all_solid.fsh" \ No newline at end of file diff --git a/shaders/gbuffers_block.vsh b/shaders/gbuffers_block.vsh deleted file mode 100644 index 5decf09..0000000 --- a/shaders/gbuffers_block.vsh +++ /dev/null @@ -1,5 +0,0 @@ -#version 120 - -#define WORLD -#define BLOCKENTITIES -#include "gbuffers_all_solid.vsh" \ No newline at end of file diff --git a/shaders/gbuffers_clouds.vsh b/shaders/gbuffers_clouds.vsh deleted file mode 100644 index d83bef7..0000000 --- a/shaders/gbuffers_clouds.vsh +++ /dev/null @@ -1,5 +0,0 @@ -#version 120 - -void main() { - gl_Position.xyz = vec3(-1.0); -} diff --git a/shaders/gbuffers_damagedblock.fsh b/shaders/gbuffers_damagedblock.fsh deleted file mode 100644 index ef97bfc..0000000 --- a/shaders/gbuffers_damagedblock.fsh +++ /dev/null @@ -1,4 +0,0 @@ -#version 120 - -#define WORLD -#include "gbuffers_all_translucent.fsh" \ No newline at end of file diff --git a/shaders/gbuffers_damagedblock.vsh b/shaders/gbuffers_damagedblock.vsh deleted file mode 100644 index dca46e5..0000000 --- a/shaders/gbuffers_damagedblock.vsh +++ /dev/null @@ -1,4 +0,0 @@ -#version 120 - -#define WORLD -#include "gbuffers_all_translucent.vsh" \ No newline at end of file diff --git a/shaders/gbuffers_entities.fsh b/shaders/gbuffers_entities.fsh deleted file mode 100644 index 2576694..0000000 --- a/shaders/gbuffers_entities.fsh +++ /dev/null @@ -1,8 +0,0 @@ -#version 120 - -#define WORLD -#define ENTITIES - -#define ENTITY_PHYSICSMOD_SNOW 829925 - -#include "gbuffers_all_solid.fsh" \ No newline at end of file diff --git a/shaders/gbuffers_entities.vsh b/shaders/gbuffers_entities.vsh deleted file mode 100644 index 2182ca9..0000000 --- a/shaders/gbuffers_entities.vsh +++ /dev/null @@ -1,7 +0,0 @@ -#version 120 - -#define WORLD -#define ENTITIES - -#define ENTITY_PHYSICSMOD_SNOW 829925 -#include "gbuffers_all_solid.vsh" \ No newline at end of file diff --git a/shaders/gbuffers_hand.fsh b/shaders/gbuffers_hand.fsh deleted file mode 100644 index d8f099d..0000000 --- a/shaders/gbuffers_hand.fsh +++ /dev/null @@ -1,9 +0,0 @@ -#version 120 - -#define WORLD -#define HAND - -// #define GETNORMAL -// #define GETSPECULAR - -#include "gbuffers_all_solid.fsh" \ No newline at end of file diff --git a/shaders/gbuffers_hand.vsh b/shaders/gbuffers_hand.vsh deleted file mode 100644 index 191e977..0000000 --- a/shaders/gbuffers_hand.vsh +++ /dev/null @@ -1,6 +0,0 @@ -#version 120 - -#define WORLD -#define HAND - -#include "gbuffers_all_solid.vsh" \ No newline at end of file diff --git a/shaders/gbuffers_hand_water.fsh b/shaders/gbuffers_hand_water.fsh deleted file mode 100644 index ddf178d..0000000 --- a/shaders/gbuffers_hand_water.fsh +++ /dev/null @@ -1,5 +0,0 @@ -#version 120 - -#define HAND -// #define WORLD -#include "gbuffers_all_translucent.fsh" \ No newline at end of file diff --git a/shaders/gbuffers_hand_water.vsh b/shaders/gbuffers_hand_water.vsh deleted file mode 100644 index 05dca80..0000000 --- a/shaders/gbuffers_hand_water.vsh +++ /dev/null @@ -1,5 +0,0 @@ -#version 120 - -#define HAND -// #define WORLD -#include "gbuffers_all_translucent.vsh" \ No newline at end of file diff --git a/shaders/gbuffers_skytextured.vsh b/shaders/gbuffers_skytextured.vsh deleted file mode 100644 index 7166e51..0000000 --- a/shaders/gbuffers_skytextured.vsh +++ /dev/null @@ -1,5 +0,0 @@ -#version 120 - -void main() { - gl_Position.xyz = vec3(-10.0); -} \ No newline at end of file diff --git a/shaders/gbuffers_terrain.fsh b/shaders/gbuffers_terrain.fsh deleted file mode 100644 index 97072f6..0000000 --- a/shaders/gbuffers_terrain.fsh +++ /dev/null @@ -1,4 +0,0 @@ -#version 120 - -#define WORLD -#include "gbuffers_all_solid.fsh" \ No newline at end of file diff --git a/shaders/gbuffers_terrain.vsh b/shaders/gbuffers_terrain.vsh deleted file mode 100644 index 5078151..0000000 --- a/shaders/gbuffers_terrain.vsh +++ /dev/null @@ -1,4 +0,0 @@ -#version 120 - -#define WORLD -#include "gbuffers_all_solid.vsh" \ No newline at end of file diff --git a/shaders/gbuffers_textured.fsh b/shaders/gbuffers_textured.fsh deleted file mode 100644 index bcc6769..0000000 --- a/shaders/gbuffers_textured.fsh +++ /dev/null @@ -1,5 +0,0 @@ -#version 120 - -// #define WEATHER -#define PARTICLES -#include "gbuffers_all_particles.fsh" \ No newline at end of file diff --git a/shaders/gbuffers_textured.vsh b/shaders/gbuffers_textured.vsh deleted file mode 100644 index 1381905..0000000 --- a/shaders/gbuffers_textured.vsh +++ /dev/null @@ -1,5 +0,0 @@ -#version 120 - -// #define WEATHER -#define PARTICLES -#include "gbuffers_all_particles.vsh" \ No newline at end of file diff --git a/shaders/gbuffers_textured_lit.fsh b/shaders/gbuffers_textured_lit.fsh deleted file mode 100644 index b867265..0000000 --- a/shaders/gbuffers_textured_lit.fsh +++ /dev/null @@ -1,6 +0,0 @@ -#version 120 - -#define LIT -// #define WEATHER -#define PARTICLES -#include "gbuffers_all_particles.fsh" \ No newline at end of file diff --git a/shaders/gbuffers_textured_lit.vsh b/shaders/gbuffers_textured_lit.vsh deleted file mode 100644 index 1381905..0000000 --- a/shaders/gbuffers_textured_lit.vsh +++ /dev/null @@ -1,5 +0,0 @@ -#version 120 - -// #define WEATHER -#define PARTICLES -#include "gbuffers_all_particles.vsh" \ No newline at end of file diff --git a/shaders/gbuffers_water.fsh b/shaders/gbuffers_water.fsh deleted file mode 100644 index 9208bed..0000000 --- a/shaders/gbuffers_water.fsh +++ /dev/null @@ -1,4 +0,0 @@ -#version 120 - -// #define WORLD -#include "gbuffers_all_translucent.fsh" \ No newline at end of file diff --git a/shaders/gbuffers_water.vsh b/shaders/gbuffers_water.vsh deleted file mode 100644 index 5228fab..0000000 --- a/shaders/gbuffers_water.vsh +++ /dev/null @@ -1,4 +0,0 @@ -#version 120 - -// #define WORLD -#include "gbuffers_all_translucent.vsh" \ No newline at end of file diff --git a/shaders/gbuffers_weather.fsh b/shaders/gbuffers_weather.fsh deleted file mode 100644 index eba2476..0000000 --- a/shaders/gbuffers_weather.fsh +++ /dev/null @@ -1,5 +0,0 @@ -#version 120 - -#define WEATHER -#define PARTICLES -#include "gbuffers_all_particles.fsh" \ No newline at end of file diff --git a/shaders/gbuffers_weather.vsh b/shaders/gbuffers_weather.vsh deleted file mode 100644 index b63e120..0000000 --- a/shaders/gbuffers_weather.vsh +++ /dev/null @@ -1,5 +0,0 @@ -#version 120 - -#define WEATHER -#define PARTICLES -#include "gbuffers_all_particles.vsh" \ No newline at end of file diff --git a/shaders/lang/en_us.lang b/shaders/lang/en_us.lang index 6e987a5..6e2557b 100644 --- a/shaders/lang/en_us.lang +++ b/shaders/lang/en_us.lang @@ -121,8 +121,7 @@ screen.Fog = Fog Settings option.Evening_Cloudy_Fog = Cloudy Evening Fog Density option.Night_Cloudy_Fog = Cloudy Night Fog Density - screen.Biome_Fog = Biome Specific Fog - option.Biome_specific_environment = Biome Specific Fog + option.PER_BIOME_ENVIRONMENT = Per Biome Environments screen.Cave_Fog = Cave Fog option.Cave_Fog = Cave Fog @@ -190,7 +189,30 @@ screen.Climate = Climate Settings option.Spring_Leaf_R = Red Amount (for leaves) option.Spring_Leaf_G = Green Amount (for leaves) option.Spring_Leaf_B = Blue Amount (for leaves) + + screen.SWAMP = Swamp + option.SWAMP_ENV = Swamp Environment + option.SWAMP_UNIFORM_DENSITY = Uniform Fog Density + option.SWAMP_CLOUDY_DENSITY = Cloudy Fog Density + option.SWAMP_R = Red Amount + option.SWAMP_G = Green Amount + option.SWAMP_B = Blue Amount + screen.JUNGLE = Jungle + option.JUNGLE_ENV = Jungle Environment + option.JUNGLE_UNIFORM_DENSITY = Uniform Fog Density + option.JUNGLE_CLOUDY_DENSITY = Cloudy Fog Density + option.JUNGLE_R = Red Amount + option.JUNGLE_G = Green Amount + option.JUNGLE_B = Blue Amount + + screen.DARKFOREST = Dark Forest + option.DARKFOREST_ENV = Dark Forest Environment + option.DARKFOREST_UNIFORM_DENSITY = Uniform Fog Density + option.DARKFOREST_CLOUDY_DENSITY = Cloudy Fog Density + option.DARKFOREST_R = Red Amount + option.DARKFOREST_G = Green Amount + option.DARKFOREST_B = Blue Amount screen.World = World screen.Water = Water Settings @@ -252,6 +274,7 @@ screen.LabPBR = Lab PBR screen.POM = Parallax Occlusion Mapping / POM + option.HEIGTHMAP_DEPTH_OFFSET = Heightmap in Depth option.POM = Parallax Occlusion Mapping option.MAX_ITERATIONS = Quality option.POM_DEPTH = Depth @@ -358,6 +381,7 @@ screen.Emissives.comment = §bWhat is this?§r Emissiveness is just how much lig option.Emissive_Curve.comment = This determines how quickly the emissive texture reaches its brightest point. 1.0 is linear. screen.POM.comment = Configure settings related to parallax occlusion mapping that uses information provided by a resourcepack. + option.HEIGTHMAP_DEPTH_OFFSET.comment = §bWhat is this?§r This makes the resourcepack provided "heightmap" offset the depth that a lot of effects use. This allows for finer details nearby, and can work as a "budget POM". §aPERFORMANCE COST:§r low to medium - use this if POM is too hard to run. option.POM.comment = §bWhat is this?§r This effect attempts to create 3D geometry where there previously was none, by using a special image from a resourcepack. This effect basically only pushes inwards, so some artifacts can exist when looking at steep angles. §aPERFORMANCE COST:§r medium to high option.MAX_ITERATIONS.comment = Configure the quality of the parallax occlusion mapping effect. if you see individual layers when looking up close, inscreasing this makes more layers, so they will become harder to see. §aPERFORMANCE COST:§r high option.POM_DEPTH.comment = How deep the parallax occlusion mapping effect can go into a surface. §aPERFORMANCE COST:§r very low @@ -382,9 +406,6 @@ screen.Fog.comment = Configure settings related to the raymarched volumetric fog screen.TOD_fog.comment = Configure the density of fog that appears at specific times of the day. option.TOD_Fog_mult.comment = Configure how much total fog there is that appears at specific times during the day. this does not effect the atmospheric haze. - screen.Biome_Fog.comment = Configure settings for fog that appear only in specific biomes. - option.Biome_specific_environment.comment = Toggle fog that only appears in specific biomes. §aPERFORMANCE COST:§r low - screen.Cave_Fog.comment = Configure settings for fog that appears when you are in very dark places such as caves. option.Cave_Fog.comment = Toggle the fog that appears in dark places. It is impossible to accurately tell when you are in a cave with a shader, so this fog might appear in places that are not a cave. §aPERFORMANCE COST:§r low option.CaveFogFallOff.comment = Configure how quickly the fog gradient reaches its brightest part. @@ -428,6 +449,18 @@ screen.Climate.comment = Configure settings related to the climate, like seasona screen.Fall_colors.comment = Configure the colors of vegetation during fall. screen.Winter_colors.comment = Configure the colors of vegetation during winter. screen.Spring_colors.comment = Configure the colors of vegetation during spring. + + option.PER_BIOME_ENVIRONMENT.comment = Toggle all special environments that only appear in some biomes. §aPERFORMANCE COST:§r low + + screen.SWAMP.comment = Configure the environment in this biome type. + option.SWAMP_ENV.comment = Toggle the environment only for this biome type. The other biome environments remain active even if this one is disabled. + + screen.JUNGLE.comment = Configure the environment in this biome type. + option.JUNGLE_ENV.comment = Toggle the environment only for this biome type. The other biome environments remain active even if this one is disabled. + + screen.DARKFOREST.comment = Configure the environment in this biome type. + option.DARKFOREST_ENV.comment = Toggle the environment only for this biome type. The other biome environments remain active even if this one is disabled. + screen.Waving_Stuff.comment = Configure settings related to waving things. option.WAVY_PLANTS.comment = Toggle waving plants. §aPERFORMANCE COST:§r very low diff --git a/shaders/lang/pt_br.lang b/shaders/lang/pt_br.lang index 55a281d..f6873bf 100644 --- a/shaders/lang/pt_br.lang +++ b/shaders/lang/pt_br.lang @@ -13,7 +13,7 @@ screen.Misc_Settings = Configurações Diversas option.ambientLight_only=Apenas Luz Ambiente option.Glass_Tint=Tintura de Vidro option.display_LUT=Mostrar LUT - option.ambientSSS_view=Visualização de SSS vindo do Céu + option.SSS_view=Visualização de SSS vindo do Céu screen.Sun_and_Moon_Colors = Cores Lua/Sol option.sunPathRotation = Ângulo do Sol @@ -138,8 +138,7 @@ screen.Fog = Ajustes da Névoa option.Evening_Cloudy_Fog = Densidade da Nublagem à Tarde option.Night_Cloudy_Fog = Densidade da Nublagem à Noite - screen.Biome_Fog = Névoa Própria de Bioma - option.Biome_specific_environment = Névoa Própria de Bioma + option.PER_BIOME_ENVIRONMENT = Névoa Própria de Bioma screen.Cave_Fog = Névoa em Caverna option.Cave_Fog = Névoa em Caverna @@ -423,8 +422,7 @@ screen.Fog.comment = Ajustes relacionados à névoa volumétrica ou névoa dista screen.TOD_fog.comment = Ajusta a densidade da névoa que aparece em horários especifícos do dia. option.TOD_Fog_mult.comment = Ajusta quantidade total de névoa que aparece em horários especifícos do dia. Isso não afeta a névoa atmosférica. - screen.Biome_Fog.comment = Ajustes para a névoa que apenas aparece em biomas especifícos. - option.Biome_specific_environment.comment = Habilita uma névoa que apenas aparece em biomas especifícos. §aCUSTO DE PERFORMANCE:§r Baixo + option.PER_BIOME_ENVIRONMENT.comment = Habilita uma névoa que apenas aparece em biomas especifícos. §aCUSTO DE PERFORMANCE:§r Baixo screen.Cave_Fog.comment = Ajustes para a névoa que aparece em lugares escuros, como cavernas. option.Cave_Fog = Névoa de Caverna diff --git a/shaders/lang/zh_cn.lang b/shaders/lang/zh_cn.lang index de3ca95..b1e26c5 100644 --- a/shaders/lang/zh_cn.lang +++ b/shaders/lang/zh_cn.lang @@ -119,8 +119,7 @@ screen.Fog = 雾气设置 option.Night_Uniform_Fog = 夜晚 - 雾气密度 option.Night_Cloudy_Fog =夜 晚 - 云雾密度 - screen.Biome_Fog = 群系雾 - option.Biome_specific_environment = 生物群系特定雾气 + option.PER_BIOME_ENVIRONMENT = 生物群系特定雾气 screen.Cave_Fog = 洞穴雾气 option.Cave_fog = 洞穴雾气 @@ -378,8 +377,7 @@ screen.Fog.comment = 配置和光线行进体积雾, 基于距离的雾气相关 screen.TOD_fog.comment = 配置一天中特定时间出现的雾气的密度. option.TOD_Fog_mult.comment = 配置一天中特定时间出现的总体雾气量. 本选项不影响大气雾霾密度. - screen.Biome_Fog.comment = 配置仅出现在特定群系的的雾气. - option.Biome_specific_environment.comment = 特定群系的特殊雾气效果开关. §a性能消耗水平:§r 低. + option.PER_BIOME_ENVIRONMENT.comment = 特定群系的特殊雾气效果开关. §a性能消耗水平:§r 低. screen.Cave_Fog.comment = 配置仅出现在黑暗区域的雾气设置, 例如洞穴. option.Cave_Fog.comment = 仅出现在黑暗区域的雾气. 因为光影不可能准确地判断出你是否在一个洞穴里, 所以这种雾气可能会出现在不是洞穴的地方. §a性能消耗水平:§r 低. @@ -564,7 +562,7 @@ screen.Post_Processing.comment = 配置所有后处理效果设置, 从抗锯齿 option.Glass_Tint=玻璃色调 option.Glass_Tint.comment=背景通过混合玻璃本身的颜色获得强烈的色调. option.display_LUT=显示 LUT - option.ambientSSS_view=天空光次表面散射视图 + option.SSS_view=天空光次表面散射视图 #Climate diff --git a/shaders/lib/DailyWeatherSettings.glsl b/shaders/lib/DailyWeatherSettings.glsl new file mode 100644 index 0000000..bb31c23 --- /dev/null +++ b/shaders/lib/DailyWeatherSettings.glsl @@ -0,0 +1,3 @@ +#if Cumulus_coverage == 1.0 + variable.float.VariableCoverage = 1.0 +#endif \ No newline at end of file diff --git a/shaders/lib/PhotonGTAO.glsl b/shaders/lib/PhotonGTAO.glsl index dd3478a..d196543 100644 --- a/shaders/lib/PhotonGTAO.glsl +++ b/shaders/lib/PhotonGTAO.glsl @@ -122,7 +122,7 @@ float calculate_maximum_horizon_angle( for (int i = 0; i < GTAO_HORIZON_STEPS; ++i, ray_pos += ray_step) { - float depth = texelFetch(depthtex1, ivec2(clamp(ray_pos,0.0,1.0) * view_res * taau_render_scale - 0.5), 0).x; + float depth = texelFetch2D(depthtex1, ivec2(clamp(ray_pos,0.0,1.0) * view_res * taau_render_scale - 0.5), 0).x; if (depth == 1.0 || depth < hand_depth || depth == screen_pos.z) continue; @@ -142,9 +142,8 @@ float calculate_maximum_horizon_angle( return fast_acos(clamp(max_cos_theta, -1.0, 1.0)); } -float ambient_occlusion(vec3 screen_pos, vec3 view_pos, vec3 view_normal, vec2 dither , inout vec3 debug) { +float ambient_occlusion(vec3 screen_pos, vec3 view_pos, vec3 view_normal, vec2 dither) { float ao = 0.0; - vec3 bent_normal = vec3(0.0); // Construct local working space vec3 viewer_dir = normalize(-view_pos); @@ -176,11 +175,9 @@ float ambient_occlusion(vec3 screen_pos, vec3 view_pos, vec3 view_normal, vec2 d max_horizon_angles = gamma + clamp(vec2(-1.0, 1.0) * max_horizon_angles - gamma, -half_pi, half_pi) ; - vec3 max_horizon_angles2 = mat3(gbufferModelViewInverse) * projected_normal; - ao += integrate_arc(max_horizon_angles, gamma, cos_gamma) * len_sq * norm * max_horizon_angles.y ; + ao += integrate_arc(max_horizon_angles, gamma, cos_gamma) * len_sq * norm ; } - ao *= rcp(float(GTAO_SLICES)); - return ao; + return ao*(ao*0.5+0.5); } diff --git a/shaders/lib/ROBOBO_sky.glsl b/shaders/lib/ROBOBO_sky.glsl index b6a67cb..507e248 100644 --- a/shaders/lib/ROBOBO_sky.glsl +++ b/shaders/lib/ROBOBO_sky.glsl @@ -95,19 +95,19 @@ vec3 sky_transmittance(vec3 position, vec3 direction, const float steps) { vec3 calculateAtmosphere(vec3 background, vec3 viewVector, vec3 upVector, vec3 sunVector, vec3 moonVector, out vec2 pid, out vec3 transmittance, const int iSteps, float noise) { const int jSteps = 4; - vec3 viewPosition = (sky_planetRadius + eyeAltitude) * upVector; + vec3 viewPos = (sky_planetRadius + eyeAltitude) * upVector; - vec2 aid = rsi(viewPosition, viewVector, sky_atmosphereRadius); + vec2 aid = rsi(viewPos, viewVector, sky_atmosphereRadius); if (aid.y < 0.0) {transmittance = vec3(1.0); return vec3(0.0);} - pid = rsi(viewPosition, viewVector, sky_planetRadius * 0.998); + pid = rsi(viewPos, viewVector, sky_planetRadius * 0.998); bool planetIntersected = pid.y >= 0.0; vec2 sd = vec2((planetIntersected && pid.x < 0.0) ? pid.y : max(aid.x, 0.0), (planetIntersected && pid.x > 0.0) ? pid.x : aid.y); float stepSize = (sd.y - sd.x) * (1.0 / iSteps); vec3 increment = viewVector * stepSize; - vec3 position = viewVector * sd.x + viewPosition; + vec3 position = viewVector * sd.x + viewPos; position += increment * (0.34*noise); vec2 phaseSun = sky_phase(dot(viewVector, sunVector ), 0.8); diff --git a/shaders/lib/Shadow_Params.glsl b/shaders/lib/Shadow_Params.glsl index 7f5e5e3..569a972 100644 --- a/shaders/lib/Shadow_Params.glsl +++ b/shaders/lib/Shadow_Params.glsl @@ -1,4 +1,3 @@ - const float k = 1.8; const float d0 = 0.04; const float d1 = 0.61; @@ -12,8 +11,63 @@ vec4 BiasShadowProjection(in vec4 projectedShadowSpacePosition) { return projectedShadowSpacePosition; } - - float calcDistort(vec2 worldpos){ return 1.0/(log(length(worldpos)*b+a)*k); } + +uniform float far; + +/* +mat4 BuildOrthoProjectionMatrix(const in float width, const in float height, const in float zNear, const in float zFar) { + return mat4( + vec4(2.0 / width, 0.0, 0.0, 0.0), + vec4(0.0, 2.0 / height, 0.0, 0.0), + vec4(0.0, 0.0, -2.0 / (zFar - zNear), 0.0), + vec4(0.0, 0.0, -(zFar + zNear)/(zFar - zNear), 1.0)); +} + +mat4 BuildTranslationMatrix(const in vec3 delta) { + return mat4( + vec4(1.0, 0.0, 0.0, 0.0), + vec4(0.0, 1.0, 0.0, 0.0), + vec4(0.0, 0.0, 1.0, 0.0), + vec4(delta, 1.0)); +} + + +vec3 LightDir = vec3(0.0, 1.0, 0.0); + +// vec3 LightDir = vec3(sin(frameTimeCounter*10), 0.2, -cos(frameTimeCounter*10)); +uniform vec3 CamPos; +const float shadowIntervalSize = 2.0f; +vec3 GetShadowIntervalOffset() { + return fract(CamPos / shadowIntervalSize) * shadowIntervalSize - vec3(3,0,1); +} + +mat4 BuildShadowViewMatrix(const in vec3 localLightDir) { + //#ifndef WORLD_END + // return shadowModelView; + //#else + const vec3 worldUp = vec3(0, 0, -1); + + vec3 zaxis = localLightDir; + vec3 xaxis = normalize(cross(worldUp, zaxis)); + vec3 yaxis = normalize(cross(zaxis, xaxis)); + + mat4 shadowModelViewEx = mat4(1.0); + shadowModelViewEx[0].xyz = vec3(xaxis.x, yaxis.x, zaxis.x); + shadowModelViewEx[1].xyz = vec3(xaxis.y, yaxis.y, zaxis.y); + shadowModelViewEx[2].xyz = vec3(xaxis.z, yaxis.z, zaxis.z); + + vec3 intervalOffset = GetShadowIntervalOffset(); + mat4 translation = BuildTranslationMatrix(intervalOffset); + + return shadowModelViewEx * translation ; + //#endif +} + +mat4 BuildShadowProjectionMatrix() { + float maxDist = min(shadowDistance, far); + return BuildOrthoProjectionMatrix(maxDist, maxDist, -far, far); +} +*/ \ No newline at end of file diff --git a/shaders/lib/Shadows.glsl b/shaders/lib/Shadows.glsl new file mode 100644 index 0000000..a5e09ae --- /dev/null +++ b/shaders/lib/Shadows.glsl @@ -0,0 +1,23 @@ +// Emin's and Gri's combined ideas to stop peter panning and light leaking, also has little shadowacne so thats nice +// https://www.complementary.dev/reimagined +// https://github.com/gri573 +void GriAndEminShadowFix( + inout vec3 WorldPos, + vec3 FlatNormal, + float VanillaAO, + float SkyLightmap, + bool Entities +){ + + float DistanceOffset = clamp(0.17 + length(WorldPos) / (shadowMapResolution*0.20), 0.0,1.0) ; + vec3 Bias = FlatNormal * DistanceOffset; // adjust the bias thingy's strength as it gets farther away. + + vec3 finalBias = Bias; + + // stop lightleaking + vec2 scale = vec2(0.5); scale.y *= 0.5; + vec3 zoomShadow = scale.y - scale.x * fract(WorldPos + cameraPosition + Bias*scale.y); + if(SkyLightmap < 0.1 && !Entities) finalBias = mix(Bias, zoomShadow, clamp(VanillaAO*5,0,1)); + + WorldPos += finalBias; +} \ No newline at end of file diff --git a/shaders/lib/climate_settings.glsl b/shaders/lib/climate_settings.glsl index 72fbdbf..e2e67bb 100644 --- a/shaders/lib/climate_settings.glsl +++ b/shaders/lib/climate_settings.glsl @@ -144,45 +144,64 @@ ///////////////////////////// BIOME SPECIFICS ///////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -#ifdef Biome_specific_environment + uniform float nightVision; + uniform float isJungles; uniform float isSwamps; - // uniform float isLush; - // uniform float isDeserts; - + uniform float isDarkForests; uniform float sandStorm; uniform float snowStorm; - + +#ifdef PER_BIOME_ENVIRONMENT + void BiomeFogColor( inout vec3 FinalFogColor - ){ + ){ + + // this is a little complicated? lmao - vec3 BiomeColors; - BiomeColors.r = isSwamps*0.7 + isJungles*0.5 + sandStorm*1.0 + snowStorm*0.5; - BiomeColors.g = isSwamps*1.0 + isJungles*1.0 + sandStorm*0.5 + snowStorm*0.6; - BiomeColors.b = isSwamps*0.35 + isJungles*0.8 + sandStorm*0.3 + snowStorm*1.0; + vec3 BiomeColors = vec3(0.0); + BiomeColors.r = isSwamps*SWAMP_R + isJungles*JUNGLE_R + isDarkForests*DARKFOREST_R + sandStorm*1.0 + snowStorm*0.6; + BiomeColors.g = isSwamps*SWAMP_G + isJungles*JUNGLE_G + isDarkForests*DARKFOREST_G + sandStorm*0.5 + snowStorm*0.8; + BiomeColors.b = isSwamps*SWAMP_B + isJungles*JUNGLE_B + isDarkForests*DARKFOREST_B + sandStorm*0.3 + snowStorm*1.0; // insure the biome colors are locked to the fog shape and lighting, but not its orignal color. - BiomeColors *= dot(FinalFogColor,vec3(0.33333)); + BiomeColors *= max(dot(FinalFogColor,vec3(0.33333)), MIN_LIGHT_AMOUNT*0.025 + nightVision*0.2); // these range 0.0-1.0. they will never overlap. - float Inbiome = isJungles+isSwamps+sandStorm; + float Inbiome = isJungles+isSwamps+isDarkForests+sandStorm+snowStorm; // interpoloate between normal fog colors and biome colors. the transition speeds are conrolled by the biome uniforms. FinalFogColor = mix(FinalFogColor, BiomeColors, Inbiome); } + void BiomeSunlightColor( + inout vec3 FinalSunlightColor + ){ + // this is a little complicated? lmao + vec3 BiomeColors = vec3(0.0); + BiomeColors.r = isSwamps*SWAMP_R + isJungles*JUNGLE_R + isDarkForests*DARKFOREST_R + sandStorm*1.0 + snowStorm*0.6; + BiomeColors.g = isSwamps*SWAMP_G + isJungles*JUNGLE_G + isDarkForests*DARKFOREST_G + sandStorm*0.5 + snowStorm*0.8; + BiomeColors.b = isSwamps*SWAMP_B + isJungles*JUNGLE_B + isDarkForests*DARKFOREST_B + sandStorm*0.3 + snowStorm*1.0; + + // these range 0.0-1.0. they will never overlap. + float Inbiome = isJungles+isSwamps+isDarkForests+sandStorm+snowStorm; + + // interpoloate between normal fog colors and biome colors. the transition speeds are conrolled by the biome uniforms. + FinalSunlightColor = mix(FinalSunlightColor, FinalSunlightColor * (BiomeColors*0.8+0.2), Inbiome); + } + void BiomeFogDensity( inout vec4 UniformDensity, inout vec4 CloudyDensity ){ // these range 0.0-1.0. they will never overlap. - float Inbiome = isJungles+isSwamps+sandStorm+snowStorm; - - vec2 BiomeFogDensity; // x = uniform || y = cloudy - BiomeFogDensity.x = isSwamps*1 + isJungles*5 + sandStorm*15 + snowStorm*15; - BiomeFogDensity.y = isSwamps*5 + isJungles*2 + sandStorm*255 + snowStorm*100; + float Inbiome = isJungles+isSwamps+isDarkForests+sandStorm+snowStorm; + vec2 BiomeFogDensity = vec2(0.0); // x = uniform || y = cloudy + BiomeFogDensity.x = isSwamps*SWAMP_UNIFORM_DENSITY + isJungles*JUNGLE_UNIFORM_DENSITY + isDarkForests*DARKFOREST_UNIFORM_DENSITY + sandStorm*15 + snowStorm*150; + BiomeFogDensity.y = isSwamps*SWAMP_CLOUDY_DENSITY + isJungles*JUNGLE_CLOUDY_DENSITY + isDarkForests*DARKFOREST_CLOUDY_DENSITY + sandStorm*255 + snowStorm*255; + UniformDensity = mix(UniformDensity, vec4(BiomeFogDensity.x), Inbiome); CloudyDensity = mix(CloudyDensity, vec4(BiomeFogDensity.y), Inbiome); } @@ -196,7 +215,7 @@ // uniform int worldTime; void TimeOfDayFog(inout float Uniform, inout float Cloudy) { - float Time = (worldTime%24000)*1.0; + float Time = worldTime%24000; // set schedules for fog to appear at specific ranges of time in the day. float Morning = clamp((Time-22000)/2000,0,1) + clamp((2000-Time)/2000,0,1); @@ -213,7 +232,7 @@ DailyWeather_FogDensity(UniformDensity, CloudyDensity); // let daily weather influence fog densities. #endif - #ifdef Biome_specific_environment + #ifdef PER_BIOME_ENVIRONMENT BiomeFogDensity(UniformDensity, CloudyDensity); // let biome fog hijack to control densities, and overrride any other density controller... #endif diff --git a/shaders/lib/clouds.glsl b/shaders/lib/clouds.glsl index abd35ef..3c0cd79 100644 --- a/shaders/lib/clouds.glsl +++ b/shaders/lib/clouds.glsl @@ -1,10 +1,10 @@ -vec3 cloud2D(vec3 fragpos,vec3 col){ - vec3 wpos = fragpos; +vec3 cloud2D(vec3 viewPos,vec3 col){ + vec3 wpos = viewPos; float wind = frameTimeCounter/200.; vec2 intersection = ((2000.0-cameraPosition.y)*wpos.xz*inversesqrt(wpos.y+cameraPosition.y/512.-50./512.) + cameraPosition.xz+wind)/40000.; - float phase = pow(clamp(dot(fragpos,sunVec),0.,1.),2.)*0.5+0.5; + float phase = pow(clamp(dot(viewPos,sunVec),0.,1.),2.)*0.5+0.5; float fbm = clamp((texture2D(noisetex,intersection*vec2(1.,1.5)).a + texture2D(noisetex,intersection*vec2(2.,7.)+wind*0.4).a/2.)-0.5*(1.0-rainStrength),0.,1.) ; diff --git a/shaders/lib/diffuse_lighting.glsl b/shaders/lib/diffuse_lighting.glsl index fc96bd7..4f4b882 100644 --- a/shaders/lib/diffuse_lighting.glsl +++ b/shaders/lib/diffuse_lighting.glsl @@ -1,6 +1,6 @@ // in this here file im doing all the lighting for sunlight, ambient light, torches, for solids and translucents. -uniform float nightVision; +// uniform float nightVision; void DoRTAmbientLighting (vec3 TorchColor, vec2 Lightmap, inout float SkyLM, inout vec3 TorchLight, inout vec3 SkyLight){ @@ -66,13 +66,14 @@ void DoRTAmbientLighting (vec3 TorchColor, vec2 Lightmap, inout float SkyLM, ino TorchLight *= TORCH_AMOUNT; - FogColor = (FogColor / pow(0.00001 + dot(FogColor,vec3(0.3333)),1.0) ) * 0.1; + FogColor = FogColor / max(dot(FogColor,vec3(0.3333)),0.05); - vec3 FogTint = FogColor*clamp(1.1 + dot(Normal,np3),0.0,1.0) * 0.05; + vec3 FogTint = FogColor*clamp(1.1 + dot(Normal,np3),0.0,1.0) * 0.1; - vec3 AmbientLight = max(vec3(0.5,0.75,1.0) * 0.05, (MIN_LIGHT_AMOUNT*0.01 + nightVision*0.5) ); + vec3 AmbientLight = max(vec3(0.5,0.75,1.0)* 0.1, (MIN_LIGHT_AMOUNT*0.01 + nightVision*0.5) ); - return TorchLight + AmbientLight + FogTint; + return TorchLight + AmbientLight;// + AmbientLight + FogTint; } + #endif \ No newline at end of file diff --git a/shaders/lib/end_fog.glsl b/shaders/lib/end_fog.glsl index cc16f75..2dc3ef2 100644 --- a/shaders/lib/end_fog.glsl +++ b/shaders/lib/end_fog.glsl @@ -1,63 +1,91 @@ -vec3 srgbToLinear2(vec3 srgb){ - return mix( - srgb / 12.92, - pow(.947867 * srgb + .0521327, vec3(2.4) ), - step( .04045, srgb ) - ); -} -vec3 blackbody2(float Temp) -{ - float t = pow(Temp, -1.5); - float lt = log(Temp); +// Hash without Sine +// MIT License... +/* Copyright (c)2014 David Hoskins. - vec3 col = vec3(0.0); - col.x = 220000.0 * t + 0.58039215686; - col.y = 0.39231372549 * lt - 2.44549019608; - col.y = Temp > 6500. ? 138039.215686 * t + 0.72156862745 : col.y; - col.z = 0.76078431372 * lt - 5.68078431373; - col = clamp(col,0.0,1.0); - col = Temp < 1000. ? col * Temp * 0.001 : col; +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: - return srgbToLinear2(col); -} +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.*/ +//---------------------------------------------------------------------------------------- + vec3 hash31(float p) + { + vec3 p3 = fract(vec3(p) * vec3(.1031, .1030, .0973)); + p3 += dot(p3, p3.yzx+33.33); + return fract((p3.xxy+p3.yzz)*p3.zyx); + } + + float hash11(float p) + { + p = fract(p * .1031); + p *= p + 33.33; + p *= p + p; + return fract(p); + } + +//---------------------------------------------------------------------------------------- // Integer Hash - II // - Inigo Quilez, Integer Hash - II, 2017 // https://www.shadertoy.com/view/XlXcW4 -uvec3 iqint2(uvec3 x) -{ - const uint k = 1103515245u; +//---------------------------------------------------------------------------------------- - x = ((x>>8U)^x.yzx)*k; - x = ((x>>8U)^x.yzx)*k; - x = ((x>>8U)^x.yzx)*k; + uvec3 iqint2(uvec3 x) + { + const uint k = 1103515245u; - return x; -} + x = ((x>>8U)^x.yzx)*k; + x = ((x>>8U)^x.yzx)*k; + x = ((x>>8U)^x.yzx)*k; -uvec3 hash(vec2 s) -{ + return x; + } - uvec4 u = uvec4(s, uint(s.x) ^ uint(s.y), uint(s.x) + uint(s.y)); // Play with different values for 3rd and 4th params. Some hashes are okay with constants, most aren't. - - return iqint2(u.xyz); -} -vec3 hash31(float p) -{ - vec3 p3 = fract(vec3(p) * vec3(.1031, .1030, .0973)); - p3 += dot(p3, p3.yzx+33.33); - return fract((p3.xxy+p3.yzz)*p3.zyx); -} + uvec3 hash(vec2 s) + { + uvec4 u = uvec4(s, uint(s.x) ^ uint(s.y), uint(s.x) + uint(s.y)); // Play with different values for 3rd and 4th params. Some hashes are okay with constants, most aren't. + return iqint2(u.xyz); + } -///////////////// POSITION -///////////////// POSITION -///////////////// POSITION +//---------------------------------------------------------------------------------------- -vec3 RandomPosition = hash31(frameTimeCounter); +// vec3 RandomPosition = hash31(frameTimeCounter); vec3 ManualLightPos = vec3(ORB_X, ORB_Y, ORB_Z); +void LightSourcePosition(vec3 WorldPos, vec3 CameraPos, inout vec3 Pos1, inout vec3 Pos2){ + + Pos1 = WorldPos - vec3(0,200,0); + + vec3 Origin = WorldPos - CameraPos - ManualLightPos; + + + float cellSize = 200; + vec3 cellPos = CameraPos ; + + Origin += fract(cellPos/cellSize)*cellSize - cellSize*0.5; + // Origin -= vec3(sin(frameTimeCounter),0,-cos(frameTimeCounter)) * 20; + + vec3 randomPos = texelFetch2D(colortex4,ivec2(2,1),0).xyz / 150.0; + + Origin -= (randomPos * 2.0 - 1.0); + + + Pos2 = Origin; +} + float densityAtPosFog(in vec3 pos){ pos /= 18.; pos.xz *= 0.5; @@ -72,264 +100,215 @@ float densityAtPosFog(in vec3 pos){ return mix(xy.r,xy.g, f.y); } -vec3 LightSourcePosition(vec3 WorldPos, vec3 CameraPos){ - - vec3 Origin = WorldPos ; - // make the swirl only happen within a radius - float SwirlBounds = clamp(sqrt(length(vec3(Origin.x,Origin.y-100,Origin.z)) / 150.0 - 1.0) ,0.0,1.0); +// Create a rising swirl centered around some origin. +void SwirlAroundOrigin(inout vec3 alteredOrigin, vec3 origin){ - if( SwirlBounds < 1.0) { - Origin.y -= 260; - } else { - - Origin = WorldPos - CameraPos ; - - #ifdef THE_ORB - if(ManualLightPos == vec3(0.0)){ - #endif - - float nosie = (densityAtPosFog(Origin / 30 + sin(frameTimeCounter/5)*100)-0.15) * 15 ; - Origin.xz += vec2( sin(nosie),-cos(nosie) )*50; - Origin.y -= sin(nosie)*100; - - #ifdef THE_ORB - } else { - Origin -= ManualLightPos; - } - #endif - - float cellSize = 100.0; - vec3 cellPos = CameraPos - vec3(0,10,0) ; - // cellPos += vec3(frameTimeCounter,0,0)*25.0; - - Origin += (fract(cellPos/cellSize)*cellSize - cellSize*0.5); - } - - return Origin; -} - -///////////////// COLOR -///////////////// COLOR -///////////////// COLOR -vec3 LightSourceColor(float SwirlBounds){ - - vec3 Color = vec3(0.7, 0.8, 1.0); - - #ifndef THE_ORB - if( SwirlBounds < 1.0) { - - // Color = vec3(0.5, 0.5, 1.0); - } else { - - // #ifdef THE_ORB - // Color = vec3(ORB_R, ORB_G, ORB_B) * ORB_ColMult; - // #endif - - - // Color *= blackbody2(RandomPosition.y*4000 + 1000); - - float Timing = dot(RandomPosition, vec3(1.0/3.0)); - float Flash = max(sin(frameTimeCounter) * cos(Timing) ,0.0); - Color *= Flash; - } - #else - Color = vec3(ORB_R, ORB_G, ORB_B) * ORB_ColMult; - #endif - - - return Color; -} - -///////////////// SHAPE -///////////////// SHAPE -///////////////// SHAPE -vec3 LightSourceShape(vec3 WorldPos){ - - vec3 Shapes = vec3(0.0); - vec3 Origin = WorldPos ; + float radiance = 2.39996 + alteredOrigin.y/1.5 + frameTimeCounter/50; + mat2 rotationMatrix = mat2(vec2(cos(radiance), -sin(radiance)), vec2(sin(radiance), cos(radiance))); // make the swirl only happen within a radius - float SwirlBounds = clamp(sqrt(length(Origin) / 200.0 - 1.0) ,0.0,1.0); + float SwirlBounds = clamp(sqrt(length(vec3(origin.x, origin.y-100,origin.z)) / 200.0 - 1.0) ,0.0,1.0); + + alteredOrigin.xz = mix(alteredOrigin.xz * rotationMatrix, alteredOrigin.xz, SwirlBounds); +} - if( SwirlBounds < 1.0) { - // vec3 Origin = WorldPos; - Origin.y -= 200; +// control where the fog volume should and should not be using a sphere. +void VolumeBounds(inout float Volume, vec3 Origin){ - vec3 Origin2 = Origin; - Origin2.y = (Origin2.y + 100.0) * 0.8; + vec3 Origin2 = (Origin - vec3(0,100,0)); + Origin2.y *= 0.8; + float Center1 = length(Origin2); - float Center = length(Origin); - float AltCenter = length(Origin2); - - // the max of a sphere is another smaller sphere. this creates a hollow sphere. - Shapes.r = max(1.0 - AltCenter / 75.0, max(AltCenter / 150.0 - 1.0, 0.0)); - - // donut to make the hurricane shape - float radius = 200.0; - float thickness = 25.0 * radius; - Shapes.r = (thickness - clamp( pow( length( vec2(length(Origin2.xz) - radius, Origin2.y*0.75) ),2.0) - radius, 0.0, thickness) ) / thickness; - - Shapes.r = max(Shapes.r, max(1.0 - AltCenter / 75.0, 0.0)); + float Bounds = max(1.0 - Center1 / 75.0, 0.0) * 5.0; + float radius = 150.0; + float thickness = 50.0 * radius; + float Torus = (thickness - clamp( pow( length( vec2(length(Origin.xz) - radius, Origin2.y) ),2.0) - radius, 0.0, thickness) ) / thickness; + + Origin2.xz *= 0.3; + Origin2.y -= 100; - // debug donut - // radius = 50.0; - // thickness = 5.0 * radius; - // Shapes.b = (thickness - clamp( pow( length( vec2(length(Origin2.xy) - radius, Origin2.z*0.75) ),2.0) - radius, 0.0, thickness) ) / thickness; - } + float orb = clamp((1.0 - length(Origin2) / 15.0) * 1.5,0.0,1.0); + Volume = max(Volume - Bounds - Torus, orb); + +} - return Shapes; +// create the volume shape +float cloudVol(in vec3 pos){ + + float Output = 0.0; + vec3 samplePos = pos*vec3(1.0,1./48.,1.0); + + // swirly swirly :DDDDDDDDDDD + SwirlAroundOrigin(samplePos, pos); + + float NoisePlane = texture2D(noisetex, samplePos.xz/1024 ).b; + + float MainShape = clamp(max(0.5 - densityAtPosFog(samplePos * 16),0.0) * 2,0.0,1.0); + float Erosion = abs(0.6 - densityAtPosFog(samplePos * (160. - MainShape*50) - vec3(0,frameTimeCounter*3,0) )); + + + Output = MainShape; + Output = max(Output - Erosion*0.5,0.0); + // apply limts + VolumeBounds(Output, pos); + + // Output = max(max(100 - pos.y,0.0) - NoisePlane * 50 ,0.0); + return Output; +} + +float EndLightMie(vec3 LightPos){ + + float mie = exp(length(LightPos) / -150); + mie *= mie; + mie *= mie; + mie *= 100; + + return mie; +} + +void LightSourceColors(inout vec3 Color1, inout vec3 Color2){ + Color1 = vec3(0.7,0.88,1.0); + Color2 = vec3(ORB_R,ORB_G,ORB_B); +} + +vec3 LightSourceLighting( vec3 WorldPos, vec3 LightPos, float Dither, float VolumeDensity, vec3 LightColor, float Phase ){ + + float Mie = EndLightMie(LightPos); + float Shadow = 0.0; + + for (int j=0; j < 3; j++){ + vec3 shadowSamplePos = WorldPos - LightPos * (0.05 + j * (0.25 + Dither*0.15)); + Shadow += cloudVol(shadowSamplePos); + } + + vec3 FinalLighting = LightColor * Mie * exp(Shadow * -5.0) ; + + FinalLighting += LightColor * exp2(-5 * max(2.5-Shadow,0.0) * vec3(1.2,1.0,0.8+VolumeDensity*0.4)) * (Mie*Mie) * clamp((1.0 - length(LightPos) / 100.0),0.0,1.0); + + return FinalLighting; } - - -float cloudVol(in vec3 pos, int LOD){ - - - // THE OOOOOOOOOOOOOOOOOOOOOORB - vec3 Shapes = LightSourceShape(pos); - - vec3 samplePos = pos*vec3(1.0,1./32.,1.0); - vec3 samplePos2 = pos*vec3(1.0,1./48.,1.0); - - // #ifndef THE_ORB - float radiance = 2.39996 + samplePos.y + frameTimeCounter/10; - mat2 rotationMatrix = mat2(vec2(cos(radiance), -sin(radiance)), vec2(sin(radiance), cos(radiance))); - - // make the swirl only happen within a radius - float SwirlBounds = clamp(sqrt(length(vec3(pos.x,pos.y-100,pos.z)) / 200.0 - 1.0) ,0.0,1.0); - - samplePos.xz = mix(samplePos.xz * rotationMatrix, samplePos.xz, SwirlBounds); - samplePos2.xz = mix(samplePos2.xz * rotationMatrix, samplePos2.xz, SwirlBounds); - // #endif - - samplePos2.y -= frameTimeCounter/15; - - float finalfog = 0.0; - finalfog += max(0.6-densityAtPosFog(samplePos * 16.0) * 2,0.0); - - float smallnoise = max(densityAtPosFog(samplePos2 * (160. - finalfog*3))-0.1,0.0); - finalfog -= ((1-smallnoise) - max(0.15 - abs(smallnoise * 2.0 - 0.55) * 0.5,0.0)*1.5) * 0.3; - - // make the eye of the swirl have no fog, so you can actually see. - finalfog = max(finalfog - Shapes.r, 0.0); - - finalfog += Shapes.b; - - - return finalfog; -} - +#define lightsourceCount 2 // [1 2] vec4 GetVolumetricFog( - vec3 fragpos, - float dither, - float dither2 -) { - int SAMPLES = 16; - //project pixel position into projected shadowmap space - vec3 wpos = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz; + vec3 viewPos, + float dither, + float dither2 +){ + int SAMPLES = 32; + vec3 vL = vec3(0.0); + float absorbance = 1.0; + + //project pixel position into projected shadowmap space + vec3 wpos = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz; vec3 fragposition = mat3(shadowModelView) * wpos + shadowModelView[3].xyz; fragposition = diagonal3(shadowProjection) * fragposition + shadowProjection[3].xyz; - //project view origin into projected shadowmap space vec3 start = vec3(0.0); //rayvector into projected shadow map space //we can use a projected vector because its orthographic projection //however we still have to send it to curved shadow map space every step - vec3 dV = (fragposition-start); + vec3 dV = fragposition-start; vec3 dVWorld = (wpos-gbufferModelViewInverse[3].xyz); float maxLength = min(length(dVWorld),32.0 * 12.0)/length(dVWorld); + dV *= maxLength; dVWorld *= maxLength; - //apply dither - vec3 progress = start.xyz; - vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition; - vec3 vL = vec3(0.); float dL = length(dVWorld); + vec3 fogcolor = (gl_Fog.color.rgb / max(dot(gl_Fog.color.rgb,vec3(0.3333)),0.05)) ; + + vec3 LightCol1 = vec3(0); vec3 LightCol2 = vec3(0); + LightSourceColors(LightCol1, LightCol2); + + float Flashing = texelFetch2D(colortex4,ivec2(1,1),0).x/150.0; + // LightCol1 *= Flashing; + LightCol2 *= Flashing; + + + vec3 LightPos1 = vec3(0); vec3 LightPos2 = vec3(0); + + LightSourcePosition(cameraPosition, cameraPosition, LightPos1, LightPos2); + + float Phase1 = sqrt(1.0 - clamp( dot(normalize(dVWorld), normalize(-LightPos1)),0.0,1.0)); + Phase1 = exp(Phase1 * -5.0) * 10; + + float Phase2 = sqrt(1.0 - clamp( dot(normalize(dVWorld), normalize(-LightPos2)),0.0,1.0)); + Phase2 = exp(Phase2 * -5.0) * 10; + - float absorbance = 1.0; float expFactor = 11.0; - - vec3 fogColor = (gl_Fog.color.rgb / max(pow(dot(gl_Fog.color.rgb,vec3(0.3333)),1.1),0.01) ) ; - for (int i=0;i= 0 && offset.y >= 0 && offset.x < viewWidth*RENDER_SCALE.x && offset.y < viewHeight*RENDER_SCALE.y ) { + vec3 t0 = toScreenSpace(vec3(offset*texelSize+acc+0.5*texelSize, texelFetch2D(depthtex1, offset,0).x) * vec3(1.0/RENDER_SCALE, 1.0) ); + vec3 vec = (t0.xyz - viewPos); + float dsquared = dot(vec, vec); + + if (dsquared > 1e-5){ + if (dsquared < maxR2){ + float NdotV = clamp(dot(vec*inversesqrt(dsquared), normalize(normal)),0.,1.); + occlusion += NdotV * clamp(1.0-dsquared/maxR2,0.0,1.0); + } + + #ifdef Ambient_SSS + if(dsquared > maxR2_2){ + float NdotV = 1.0 - clamp(dot(vec*dsquared, normalize(normal)),0.,1.); + sss += max((NdotV - (1.0-NdotV)) * clamp(1.0-maxR2_2/dsquared,0.0,1.0) ,0.0); + } + #endif + + n += 1; + } + } + } + return max(1.0 - vec2(occlusion, sss)/n, 0.0); +} +float ScreenSpace_SSS( + vec3 viewPos, vec3 normal, bool hand, bool leaves +){ + if(hand) return 1.0; + + // float radius[7] = float[]( + // 0.15, + // 0.15, + // 0.15, + // 0.15, + // 0.15, + // 0.15, + // 0.15 + // ); + + float dist = 1.0 + clamp(viewPos.z*viewPos.z/50.0,0,5); // shrink sample size as distance increases + float mulfov2 = gbufferProjection[1][1]/(3 * dist); + + float maxR2_2 = viewPos.z*viewPos.z*mulfov2*2.*2./50.0; + + float dist3 = clamp(1-exp( viewPos.z*viewPos.z / -50),0,1); + if(leaves) maxR2_2 = mix(10, maxR2_2, dist3); + + vec2 acc = -(TAA_Offset*(texelSize/2))*RENDER_SCALE ; + + int seed = (frameCounter%40000) * 2 + (1+frameCounter); + float samplePos = fract(R2_samples(seed).x + blueNoise(gl_FragCoord.xy).x) * 1.61803398874; + + int samples = 7; + + float sss = 0.0; + int n = 0; + for (int i = 0; i < samples; i++) { + + vec2 sp = tapLocation_alternate(i, 0.0, samples, 20, samplePos)* 0.2; + float rd = mulfov2 ; + + vec2 sampleOffset = sp * rd; + ivec2 offset = ivec2(gl_FragCoord.xy + sampleOffset*vec2(viewWidth,viewHeight*aspectRatio)*RENDER_SCALE); + + if (offset.x >= 0 && offset.y >= 0 && offset.x < viewWidth*RENDER_SCALE.x && offset.y < viewHeight*RENDER_SCALE.y ) { + vec3 t0 = toScreenSpace(vec3(offset*texelSize+acc+0.5*texelSize, texelFetch2D(depthtex1, offset,0).x) * vec3(1.0/RENDER_SCALE, 1.0) ); + vec3 vec = (t0.xyz - viewPos); + float dsquared = dot(vec, vec); + + if (dsquared > 1e-5){ + + if(dsquared > maxR2_2){ + float NdotV = 1.0 - clamp(dot(vec*dsquared, normalize(normal)),0.,1.); + sss += max((NdotV - (1.0-NdotV)) * clamp(1.0-maxR2_2/dsquared,0.0,1.0) ,0.0); + } + + n += 1; + } + } + } + return max(1.0 - sss/n, 0.0); +} + +//////////////////////////////////////////////////////////////////// +///////////////////////////// RTAO/SSGI //////////////////////// +//////////////////////////////////////////////////////////////////// +vec3 rayTrace_GI(vec3 dir,vec3 position,float dither, float quality){ + + vec3 clipPosition = toClipSpace3(position); + float rayLength = ((position.z + dir.z * far*sqrt(3.)) > -near) ? + (-near -position.z) / dir.z : far*sqrt(3.); + vec3 direction = normalize(toClipSpace3(position+dir*rayLength)-clipPosition); //convert to clip space + direction.xy = normalize(direction.xy); + + //get at which length the ray intersects with the edge of the screen + vec3 maxLengths = (step(0.,direction)-clipPosition) / direction; + float mult = maxLengths.y; + + vec3 stepv = direction * mult / quality*vec3(RENDER_SCALE,1.0) * dither; + vec3 spos = clipPosition*vec3(RENDER_SCALE,1.0) ; + + spos.xy += TAA_Offset*texelSize*0.5/RENDER_SCALE; + + float biasdist = clamp(position.z*position.z/50.0,1,2); // shrink sample size as distance increases + + for(int i = 0; i < int(quality); i++){ + spos += stepv; + float sp = sqrt(texelFetch2D(colortex4,ivec2(spos.xy/texelSize/4),0).w/65000.0); + float currZ = linZ(spos.z); + + if( sp < currZ) { + float dist = abs(sp-currZ)/currZ; + if (abs(dist) < biasdist*0.05) return vec3(spos.xy, invLinZ(sp))/vec3(RENDER_SCALE,1.0); + } + spos += stepv; + } + return vec3(1.1); +} + +vec3 RT(vec3 dir, vec3 position, float noise, float stepsizes){ + float dist = 1.0 + clamp(position.z*position.z/50.0,0,2); // shrink sample size as distance increases + + float stepSize = stepsizes / dist; + int maxSteps = STEPS; + vec3 clipPosition = toClipSpace3(position); + float rayLength = ((position.z + dir.z * sqrt(3.0)*far) > -sqrt(3.0)*near) ? + (-sqrt(3.0)*near -position.z) / dir.z : sqrt(3.0)*far; + vec3 end = toClipSpace3(position+dir*rayLength) ; + vec3 direction = end-clipPosition ; //convert to clip space + + float len = max(abs(direction.x)/texelSize.x,abs(direction.y)/texelSize.y)/stepSize; + //get at which length the ray intersects with the edge of the screen + vec3 maxLengths = (step(0.,direction)-clipPosition) / direction; + + float mult = min(min(maxLengths.x,maxLengths.y),maxLengths.z)*2000.0; + + vec3 stepv = direction/len; + + int iterations = min(int(min(len, mult*len)-2), maxSteps); + + //Do one iteration for closest texel (good contact shadows) + vec3 spos = clipPosition*vec3(RENDER_SCALE,1.0) ; + spos.xy += TAA_Offset*texelSize*0.5*RENDER_SCALE; + spos += stepv/(stepSize/2); + + float distancered = 1.0 + clamp(position.z*position.z/50.0,0,2); // shrink sample size as distance increases + + for(int i = 0; i < iterations; i++){ + if (spos.x < 0.0 || spos.y < 0.0 || spos.z < 0.0 || spos.x > 1.0 || spos.y > 1.0 || spos.z > 1.0) return vec3(1.1); + spos += stepv*noise; + + float sp = sqrt(texelFetch2D(colortex4,ivec2(spos.xy/ texelSize/4),0).w/65000.0); + float currZ = linZ(spos.z); + + if( sp < currZ) { + float dist = abs(sp-currZ)/currZ; + if (dist <= 0.1) return vec3(spos.xy, invLinZ(sp))/vec3(RENDER_SCALE,1.0); + } + } + return vec3(1.1); +} + +vec3 cosineHemisphereSample(vec2 Xi, float roughness){ + float r = sqrt(Xi.x); + float theta = 2.0 * 3.14159265359 * Xi.y; + + float x = r * cos(theta); + float y = r * sin(theta); + + return vec3(x, y, sqrt(clamp(1.0 - Xi.x,0.,1.))); +} + +vec3 TangentToWorld(vec3 N, vec3 H, float roughness){ + vec3 UpVector = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); + vec3 T = normalize(cross(UpVector, N)); + vec3 B = cross(N, T); + + return vec3((T * H.x) + (B * H.y) + (N * H.z)); +} + +void ApplySSRT(inout vec3 lighting, vec3 normal,vec2 noise,vec3 viewPos, vec2 lightmaps, vec3 skylightcolor, vec3 torchcolor, bool isGrass){ + int nrays = RAY_COUNT; + + vec3 radiance = vec3(0.0); + + vec3 occlusion = vec3(0.0); + vec3 skycontribution = vec3(0.0); + + vec3 occlusion2 = vec3(0.0); + vec3 skycontribution2 = vec3(0.0); + + float skyLM = 0.0; + vec3 torchlight = vec3(0.0); + DoRTAmbientLighting(torchcolor, lightmaps, skyLM, torchlight, skylightcolor); + + for (int i = 0; i < nrays; i++){ + int seed = (frameCounter%40000)*nrays+i; + vec2 ij = fract(R2_samples(seed) + noise ); + + vec3 rayDir = TangentToWorld(normal, normalize(cosineHemisphereSample(ij,1.0)) ,1.0); + + #ifdef HQ_SSGI + vec3 rayHit = rayTrace_GI( mat3(gbufferModelView) * rayDir, viewPos, blueNoise(), 50.); // ssr rt + #else + vec3 rayHit = RT(mat3(gbufferModelView)*rayDir, viewPos, blueNoise(), 30.); // choc sspt + #endif + + #ifdef SKY_CONTRIBUTION_IN_SSRT + if(isGrass) rayDir.y = clamp(rayDir.y + 0.5,-1,1); + skycontribution = (skyCloudsFromTex(rayDir, colortex4).rgb / 15.0) * skyLM + torchlight; + #else + if(isGrass) rayDir.y = clamp(rayDir.y + 0.25,-1,1); + + skycontribution = skylightcolor * 2 * (max(rayDir.y,0.0)*0.9+0.1) + torchlight; + + #if indirect_effect == 4 + skycontribution2 = skylightcolor + torchlight; + #endif + + #endif + + if (rayHit.z < 1.){ + + #if indirect_effect == 4 + vec3 previousPosition = mat3(gbufferModelViewInverse) * toScreenSpace(rayHit) + gbufferModelViewInverse[3].xyz + cameraPosition-previousCameraPosition; + previousPosition = mat3(gbufferPreviousModelView) * previousPosition + gbufferPreviousModelView[3].xyz; + previousPosition.xy = projMAD(gbufferPreviousProjection, previousPosition).xy / -previousPosition.z * 0.5 + 0.5; + + if (previousPosition.x > 0.0 && previousPosition.y > 0.0 && previousPosition.x < 1.0 && previousPosition.x < 1.0){ + radiance += (texture2D(colortex5,previousPosition.xy).rgb + skycontribution) * GI_Strength; + } else{ + radiance += skycontribution; + } + + #else + radiance += skycontribution; + #endif + + occlusion += skycontribution * GI_Strength; + + #if indirect_effect == 4 + occlusion2 += skycontribution2 * GI_Strength; + #endif + + } else { + radiance += skycontribution; + } + } + + occlusion *= AO_Strength; + + #if indirect_effect == 4 + lighting = max(radiance/nrays - max(occlusion, occlusion2*0.5)/nrays, 0.0); + #else + lighting = max(radiance/nrays - occlusion/nrays, 0.0); + #endif +} \ No newline at end of file diff --git a/shaders/lib/lightning_stuff.glsl b/shaders/lib/lightning_stuff.glsl new file mode 100644 index 0000000..9f14b2b --- /dev/null +++ b/shaders/lib/lightning_stuff.glsl @@ -0,0 +1,62 @@ +uniform vec3 lightningEffect; +#ifdef IS_IRIS + uniform vec4 lightningBoltPosition; +#else + vec4 lightningBoltPosition = vec4(0.0, 100.0, 0.0, lightningEffect.x); +#endif + +vec3 Iris_Lightningflash(vec3 feetPlayerPos, vec3 lightningBoltPos, vec3 WorldSpace_normal, inout float Phase){ +if(lightningBoltPosition.w > 0.0){ + vec3 LightningPos = feetPlayerPos - vec3(lightningBoltPosition.x, clamp(feetPlayerPos.y, lightningBoltPosition.y+16, lightningBoltPosition.y+116.0),lightningBoltPosition.z); + + // point light, max distance is ~500 blocks (the maximim entity render distance) + float lightDistance = 300.0 ; + float lightningLight = max(1.0 - length(LightningPos) / lightDistance, 0.0); + + // the light above ^^^ is a linear curve. me no likey. here's an exponential one instead. + lightningLight = exp((1.0 - lightningLight) * -10.0); + + // a phase for subsurface scattering. + vec3 PhasePos = normalize(feetPlayerPos) + vec3(lightningBoltPosition.x, lightningBoltPosition.y + 60, lightningBoltPosition.z); + float PhaseOrigin = 1.0 - clamp(dot(normalize(feetPlayerPos), normalize(PhasePos)),0.0,1.0); + Phase = exp(sqrt(PhaseOrigin) * -2.0) * 5.0 * lightningLight; + + // good old NdotL. only normals facing towards the lightning bolt origin rise to 1.0 + float NdotL = clamp(dot(LightningPos, -WorldSpace_normal), 0.0, 1.0); + + return lightningEffect * lightningLight * NdotL; +}else return vec3(0.0); +} + +vec3 Iris_Lightningflash_VLcloud(vec3 feetPlayerPos, vec3 lightningBoltPos){ +if(lightningBoltPosition.w > 0.0){ + vec3 LightningPos = feetPlayerPos - vec3(lightningBoltPosition.x, clamp(feetPlayerPos.y, lightningBoltPosition.y, lightningBoltPosition.y+116.0),lightningBoltPosition.z); + + float lightDistance = 400.0; + float lightningLight = max(1.0 - length(LightningPos) / lightDistance, 0.0); + + lightningLight = exp((1.0 - lightningLight) * -10.0); + + return lightningEffect * lightningLight; +}else return vec3(0.0); +} + +vec3 Iris_Lightningflash_VLfog(vec3 feetPlayerPos, vec3 lightningBoltPos){ +if(lightningBoltPosition.w > 0.0){ + if(lightningBoltPosition.w < 1.0) return vec3(0.0); + + vec3 LightningPos = feetPlayerPos - vec3(lightningBoltPosition.x, clamp(feetPlayerPos.y, lightningBoltPosition.y, lightningBoltPosition.y+116.0),lightningBoltPosition.z); + + #ifdef TEST + float lightningLight = max(1.0 - length(LightningPos) / 50, 0.0); + lightningLight = exp((1.0 - lightningLight) * -15.0) ; + #else + float lightDistance = 300.0; + float lightningLight = max(1.0 - length(LightningPos) / lightDistance, 0.0) ; + + lightningLight = exp((1.0 - lightningLight) * -15.0) ; + #endif + + return lightningEffect * lightningLight; +}else return vec3(0.0); +} diff --git a/shaders/lib/nether_fog.glsl b/shaders/lib/nether_fog.glsl index 5699734..5e37566 100644 --- a/shaders/lib/nether_fog.glsl +++ b/shaders/lib/nether_fog.glsl @@ -37,7 +37,7 @@ float cloudVol(in vec3 pos){ } vec4 GetVolumetricFog( - vec3 fragpos, + vec3 viewPos, float dither, float dither2 ){ @@ -46,7 +46,7 @@ vec4 GetVolumetricFog( float absorbance = 1.0; //project pixel position into projected shadowmap space - vec3 wpos = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz; + vec3 wpos = mat3(gbufferModelViewInverse) * viewPos + gbufferModelViewInverse[3].xyz; vec3 fragposition = mat3(shadowModelView) * wpos + shadowModelView[3].xyz; fragposition = diagonal3(shadowProjection) * fragposition + shadowProjection[3].xyz; @@ -84,13 +84,13 @@ vec4 GetVolumetricFog( // do background fog lighting - float Air = 0.01; + float AirDensity = 0.01; vec3 vL1 = fogcolor / 20.0; - vL += (vL1 - vL1*exp(-Air*dd*dL)) * absorbance; + vL += (vL1 - vL1*exp(-AirDensity*dd*dL)) * absorbance; vL += (vL0 - vL0*exp(-Density*dd*dL)) * absorbance; - absorbance *= exp(-(Density+Air)*dd*dL); + absorbance *= exp(-(Density+AirDensity)*dd*dL); if (absorbance < 1e-5) break; } diff --git a/shaders/lib/settings.glsl b/shaders/lib/settings.glsl index 2faca47..79ed682 100644 --- a/shaders/lib/settings.glsl +++ b/shaders/lib/settings.glsl @@ -36,10 +36,10 @@ #define WAVY_STRENGTH 1.0 // [0.1 0.25 0.5 0.75 1.0 1.25 1.5 1.75 2.0] #define WAVY_SPEED 1.0 // [0.001 0.01 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 1.0 1.25 1.5 2.0 3.0 4.0] -#define Seasons +// #define Seasons #define Season_Length 24 // [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 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91] #define Start_Season 0 // [0 1 2 3] -#define Snowy_Winter +// #define Snowy_Winter #define Summer_R 1.0 // [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 Summer_G 1.0 // [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] @@ -75,11 +75,9 @@ #define MIN_LIGHT_AMOUNT 1.0 // [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 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0] #define ambient_brightness 1.0 // [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 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 ] -#define ambient_colortype 0 // [0 1] -#define ambient_temp 9000 // [1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 15000 50000] -#define AmbientLight_R 0.91 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0] -#define AmbientLight_G 0.86 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0] -#define AmbientLight_B 1.0 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0] +#define AmbientLight_R 1.0 // [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 AmbientLight_G 1.0 // [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 AmbientLight_B 1.0 // [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 Hand_Held_lights #define TORCH_AMOUNT 1.0 // [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 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 6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.8 6.9 7.0 7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 8.5 8.6 8.7 8.8 8.9 9.0 9.1 9.2 9.3 9.4 9.5 9.6 9.7 9.8 9.9 10.0] @@ -176,7 +174,41 @@ const float sunPathRotation = -35; //[-90 -89 -88 -87 -86 -85 -84 -83 -82 -81 -8 // #define BorderFog #define SEA_LEVEL 70 // [0 10 20 30 40 50 60 70 80 90 100 110 120 130 150 170 190] -#define Biome_specific_environment +////////////////////////////////////////////////////// +// ----- BIOME SPECIFIC ENVIORNMENTS SETTINGS ----- // +////////////////////////////////////////////////////// + +#define PER_BIOME_ENVIRONMENT + +#define SWAMP_ENV +#define SWAMP_UNIFORM_DENSITY 50 // [0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 15.0 20.0 25.0 30.0 35.0 40.0 45.0 50.0 75.0 100.0 125.0 150.0 175.0 200.0 255.] +#define SWAMP_CLOUDY_DENSITY 0 // [0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 15.0 20.0 25.0 30.0 35.0 40.0 45.0 50.0 75.0 100.0 125.0 150.0 175.0 200.0 255.] +#define SWAMP_R 0.15 // [0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0] +#define SWAMP_G 0.25 // [0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0] +#define SWAMP_B 0.05 // [0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0] + +#define JUNGLE_ENV +#define JUNGLE_UNIFORM_DENSITY 10 // [0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 15.0 20.0 25.0 30.0 35.0 40.0 45.0 50.0 75.0 100.0 125.0 150.0 175.0 200.0 255.] +#define JUNGLE_CLOUDY_DENSITY 150 // [0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 15.0 20.0 25.0 30.0 35.0 40.0 45.0 50.0 75.0 100.0 125.0 150.0 175.0 200.0 255.] +#define JUNGLE_R 0.5 // [0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0] +#define JUNGLE_G 1.0 // [0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0] +#define JUNGLE_B 0.5 // [0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0] + +#define DARKFOREST_ENV +#define DARKFOREST_UNIFORM_DENSITY 15 // [0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 15.0 20.0 25.0 30.0 35.0 40.0 45.0 50.0 75.0 100.0 125.0 150.0 175.0 200.0 255.] +#define DARKFOREST_CLOUDY_DENSITY 0 // [0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 15.0 20.0 25.0 30.0 35.0 40.0 45.0 50.0 75.0 100.0 125.0 150.0 175.0 200.0 255.] +#define DARKFOREST_R 0.3 // [0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0] +#define DARKFOREST_G 0.4 // [0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0] +#define DARKFOREST_B 1.0 // [0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0] + + +// i have to do this so it shows up in the menu lmao +#ifdef SWAMP_ENV +#endif +#ifdef JUNGLE_ENV +#endif +#ifdef DARKFOREST_ENV +#endif /////////////////////////////////////////////////// // ----- LABPBR MATERIALS RELATED SETTINGS ----- // @@ -187,7 +219,7 @@ const float sunPathRotation = -35; //[-90 -89 -88 -87 -86 -85 -84 -83 -82 -81 -8 // #define Sky_reflection // #define Rough_reflections #define Dynamic_SSR_quality -#define Sun_specular_Strength 3 // [1 2 3 4 5 6 7 8 9 10] +#define Sun_specular_Strength 1 // [0 1 2 3 4 5 6 7 8 9 10] #define reflection_quality 30 // [6.0 7.0 8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 19.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.0 100.0 ] #define Roughness_Threshold 1.5 // [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 ] @@ -207,6 +239,11 @@ const float sunPathRotation = -35; //[-90 -89 -88 -87 -86 -85 -84 -83 -82 -81 -8 #define MAX_ITERATIONS 35 // [5 10 15 20 25 30 40 50 60 70 80 90 100 125 150 200 400] #define MAX_DIST 25.0 // [5.0 10.0 15.0 20.0 25.0 30.0 40.0 50.0 60.0 70.0 80.0 90.0 100.0 125.0 150.0 200.0 400.0] +// #define HEIGTHMAP_DEPTH_OFFSET + +#ifdef POM + #undef HEIGTHMAP_DEPTH_OFFSET +#endif #define SSS_TYPE 2 // [0 1 2 3] #define LabSSS_Curve 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 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 ] @@ -292,13 +329,14 @@ uniform int moonPhase; #define Cumulus_density 0.5 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.00] #define Cumulus_height 250 // [-100 -90 -80 -70 -60 -50 -40 -30 -20 -10 0 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 310 320 330 340 350 360 370 380 390 400 410 420 430 440 450 460 470 480 490 500 510 520 530 540 550 560 570 580 590 600 700 800 900 1000] + #define Altostratus #define Alto_coverage 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] #define Alto_density 0.1 // [0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.00] #define Rain_coverage 1.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] -#define fbmAmount 0.50 // [0.00 0.02 0.04 0.06 0.08 0.10 0.12 0.14 0.16 0.18 0.20 0.22 0.24 0.26 0.28 0.30 0.32 0.34 0.36 0.38 0.40 0.42 0.44 0.46 0.48 0.50 0.52 0.54 0.56 0.58 0.60 0.62 0.64 0.66 0.68 0.70 0.72 0.74 0.76 0.78 0.80 0.82 0.84 0.86 0.88 0.90 0.92 0.94 0.96 0.98 1.00 1.02 1.04 1.06 1.08 1.10 1.12 1.14 1.16 1.18 1.20 1.22 1.24 1.26 1.28 1.30 1.32 1.34 1.36 1.38 1.40 1.42 1.44 1.46 1.48 1.50 1.52 1.54 1.56 1.58 1.60 1.62 1.64 1.66 1.68 1.70 1.72 1.74 1.76 1.78 1.80 1.82 1.84 1.86 1.88 1.90 1.92 1.94 1.96 1.98 2.00 2.02 2.04 2.06 2.08 2.10 2.12 2.14 2.16 2.18 2.20 2.22 2.24 2.26 2.28 2.30 2.32 2.34 2.36 2.38 2.40 2.42 2.44 2.46 2.48 2.50 2.52 2.54 2.56 2.58 2.60 2.62 2.64 2.66 2.68 2.70 2.72 2.74 2.76 2.78 2.80 2.82 2.84 2.86 2.88 2.90 2.92 2.94 2.96 2.98 3.00] +#define fbmAmount 0.5 // [0.00 0.02 0.04 0.06 0.08 0.10 0.12 0.14 0.16 0.18 0.20 0.22 0.24 0.26 0.28 0.30 0.32 0.34 0.36 0.38 0.40 0.42 0.44 0.46 0.48 0.50 0.52 0.54 0.56 0.58 0.60 0.62 0.64 0.66 0.68 0.70 0.72 0.74 0.76 0.78 0.80 0.82 0.84 0.86 0.88 0.90 0.92 0.94 0.96 0.98 1.00 1.02 1.04 1.06 1.08 1.10 1.12 1.14 1.16 1.18 1.20 1.22 1.24 1.26 1.28 1.30 1.32 1.34 1.36 1.38 1.40 1.42 1.44 1.46 1.48 1.50 1.52 1.54 1.56 1.58 1.60 1.62 1.64 1.66 1.68 1.70 1.72 1.74 1.76 1.78 1.80 1.82 1.84 1.86 1.88 1.90 1.92 1.94 1.96 1.98 2.00 2.02 2.04 2.06 2.08 2.10 2.12 2.14 2.16 2.18 2.20 2.22 2.24 2.26 2.28 2.30 2.32 2.34 2.36 2.38 2.40 2.42 2.44 2.46 2.48 2.50 2.52 2.54 2.56 2.58 2.60 2.62 2.64 2.66 2.68 2.70 2.72 2.74 2.76 2.78 2.80 2.82 2.84 2.86 2.88 2.90 2.92 2.94 2.96 2.98 3.00] #define fbmPower1 3.00 // [1.0 1.50 1.52 1.54 1.56 1.58 1.60 1.62 1.64 1.66 1.68 1.70 1.72 1.74 1.76 1.78 1.80 1.82 1.84 1.86 1.88 1.90 1.92 1.94 1.96 1.98 2.00 2.02 2.04 2.06 2.08 2.10 2.12 2.14 2.16 2.18 2.20 2.22 2.24 2.26 2.28 2.30 2.32 2.34 2.36 2.38 2.40 2.42 2.44 2.46 2.48 2.50 2.52 2.54 2.56 2.58 2.60 2.62 2.64 2.66 2.68 2.70 2.72 2.74 2.76 2.78 2.80 2.82 2.84 2.86 2.88 2.90 2.92 2.94 2.96 2.98 3.00 3.02 3.04 3.06 3.08 3.10 3.12 3.14 3.16 3.18 3.20 3.22 3.24 3.26 3.28 3.30 3.32 3.34 3.36 3.38 3.40 3.42 3.44 3.46 3.48 3.50 3.52 3.54 3.56 3.58 3.60 3.62 3.64 3.66 3.68 3.70 3.72 3.74 3.76 3.78 3.80 3.82 3.84 3.86 3.88 3.90 3.92 3.94 3.96 3.98 4.00 5. 6. 7. 8. 9. 10.] #define fbmPower2 2.50 // [1.00 1.50 1.52 1.54 1.56 1.58 1.60 1.62 1.64 1.66 1.68 1.70 1.72 1.74 1.76 1.78 1.80 1.82 1.84 1.86 1.88 1.90 1.92 1.94 1.96 1.98 2.00 2.02 2.04 2.06 2.08 2.10 2.12 2.14 2.16 2.18 2.20 2.22 2.24 2.26 2.28 2.30 2.32 2.34 2.36 2.38 2.40 2.42 2.44 2.46 2.48 2.50 2.52 2.54 2.56 2.58 2.60 2.62 2.64 2.66 2.68 2.70 2.72 2.74 2.76 2.78 2.80 2.82 2.84 2.86 2.88 2.90 2.92 2.94 2.96 2.98 3.00 3.02 3.04 3.06 3.08 3.10 3.12 3.14 3.16 3.18 3.20 3.22 3.24 3.26 3.28 3.30 3.32 3.34 3.36 3.38 3.40 3.42 3.44 3.46 3.48 3.50 3.52 3.54 3.56 3.58 3.60 3.62 3.64 3.66 3.68 3.70 3.72 3.74 3.76 3.78 3.80 3.82 3.84 3.86 3.88 3.90 3.92 3.94 3.96 3.98 4.00 5. 6. 7. 8. 9. 10.] @@ -313,8 +351,6 @@ uniform int moonPhase; #define HQ_CLOUDS - - ////////////////////////////////////// // ----- TAA RELATED SETTINGS ----- // ////////////////////////////////////// @@ -415,7 +451,7 @@ uniform int moonPhase; // #define DEBUG_endfog // #define THE_ORB #define ORB_X 0 // [-200 -195 -190 -185 -180 -175 -170 -165 -160 -155 -150 -145 -140 -135 -130 -125 -120 -115 -110 -105 -100 -95 -90 -85 -80 -75 -70 -65 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 165 170 175 180 185 190 195 200] -#define ORB_Y 0 // [-200 -195 -190 -185 -180 -175 -170 -165 -160 -155 -150 -145 -140 -135 -130 -125 -120 -115 -110 -105 -100 -95 -90 -85 -80 -75 -70 -65 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 165 170 175 180 185 190 195 200] +#define ORB_Y 0 // [-200 -195 -190 -185 -180 -175 -170 -165 -160 -155 -150 -145 -140 -135 -130 -125 -120 -115 -110 -105 -100 -95 -90 -85 -80 -75 -70 -65 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 165 170 175 180 185 190 195 200 210 220 230 240 250] #define ORB_Z 0 // [-200 -195 -190 -185 -180 -175 -170 -165 -160 -155 -150 -145 -140 -135 -130 -125 -120 -115 -110 -105 -100 -95 -90 -85 -80 -75 -70 -65 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 165 170 175 180 185 190 195 200] #define ORB_R 1.0 // [0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.2 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.3 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.4 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.5 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.6 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.7 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.0] @@ -434,7 +470,7 @@ uniform int moonPhase; // #define WhiteWorld // THIS IS A DEBUG VIEW. uses to see AO easier. used to see fake GI better (green light) // #define Compositing_Sky // make the sky some color to make compositing a sky in some photoediting software easier. // #define display_LUT -// #define ambientSSS_view +// #define SSS_view #define Texture_MipMap_Bias 0.0 // [-5.00 -4.75 -4.50 -4.25 -4.00 -3.75 -3.50 -3.25 -3.00 -2.75 -2.50 -2.25 -2.00 -1.75 -1.50 -1.25 -1.00 -0.75 -0.50 -0.25 0.00 0.25 0.50 0.75 1.00 1.25 1.50 1.75 2.00 2.25 2.50 2.75 3.00 3.25 3.50 3.75 4.00 4.25 4.50 4.75 5.00] @@ -446,4 +482,11 @@ uniform int moonPhase; // #define OLD_LIGHTLEAK_FIX -#define LIT_PARTICLE_BRIGHTNESS 2.0 // [1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 15.0 20.0 25.0 30.0 35.0 40.0 45.0 50.0 100.] \ No newline at end of file +#define LIT_PARTICLE_BRIGHTNESS 2.0 // [1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 15.0 20.0 25.0 30.0 35.0 40.0 45.0 50.0 100.] + +#define HURT_AND_DEATH_EFFECT + +#define LIGHTNING_FLASH // FOR OPTIFINE USERS. some mods change the sky color, which can trigger the lightning flash detection. + +#ifdef LIGHTNING_FLASH +#endif \ No newline at end of file diff --git a/shaders/lib/sky_gradient.glsl b/shaders/lib/sky_gradient.glsl index d66e512..49cc5d0 100644 --- a/shaders/lib/sky_gradient.glsl +++ b/shaders/lib/sky_gradient.glsl @@ -1,23 +1,38 @@ - - #define ffstep(x,y) clamp((y - x) * 1e35,0.0,1.0) + vec3 drawSun(float cosY, float sunInt,vec3 nsunlight,vec3 inColor){ return inColor+nsunlight/0.0008821203*pow(smoothstep(cos(0.0093084168595*3.2),cos(0.0093084168595*1.8),cosY),3.)*0.62; } -const float pi = 3.141592653589793238462643383279502884197169; -vec2 sphereToCarte(vec3 dir) { - float lonlat = atan(-dir.x, -dir.z); - return vec2(lonlat * (0.5/pi) +0.5,0.5*dir.y+0.5); + +vec3 drawMoon(vec3 PlayerPos, vec3 WorldSunVec, vec3 Color, inout vec3 occludeStars){ + + float Shape = clamp((exp(1 + -1000 * dot(WorldSunVec+PlayerPos,PlayerPos)) - 1.5),0.0,25.0); + occludeStars *= max(1.0-Shape*5,0.0); + + float shape2 = pow(exp(Shape * -10),0.15) * 255.0; + + vec3 sunNormal = vec3(dot(WorldSunVec+PlayerPos, vec3(shape2,0,0)), dot(PlayerPos+WorldSunVec, vec3(0,shape2,0)), -dot(WorldSunVec, PlayerPos) * 15.0); + + + // even has a little tilt approximation haha.... yeah.... + vec3[8] phase = vec3[8]( + vec3( -1.0, -0.5, 1.0 ), + vec3( -1.0, -0.5, 0.35 ), + vec3( -1.0, -0.5, 0.2 ), + vec3( -1.0, -0.5, 0.1 ), + vec3( 1.0, 0.25, -1.0 ), + vec3( 1.0, 0.25, 0.1 ), + vec3( 1.0, 0.25, 0.2 ), + vec3( 1.0, 0.25, 0.35 ) + ); + + vec3 LightDir = phase[moonPhase]; + + return Shape * pow(clamp(dot(sunNormal,LightDir)/5,0.0,1.5),5) * Color + clamp(Shape * 4.0 * pow(shape2/200,2.0),0.0,1.0)*0.004; } -vec3 skyFromTex(vec3 pos,sampler2D sampler){ - vec2 p = sphereToCarte(pos); - return texture2D(sampler,p*texelSize*256.+vec2(18.5,1.5)*texelSize).rgb; -} -vec3 skyFromTexLOD(vec3 pos,sampler2D sampler, float LOD){ - vec2 p = sphereToCarte(pos); - return texture2DLod(sampler,p*texelSize*256.+vec2(18.5,1.5)*texelSize,LOD).rgb; -} +const float pi = 3.141592653589793238462643383279502884197169; + float w0(float a) @@ -84,6 +99,19 @@ vec4 texture2D_bicubic(sampler2D tex, vec2 uv) g1(fuv.y) * (g0x * texture2D(tex, p2) + g1x * texture2D(tex, p3)); } +vec2 sphereToCarte(vec3 dir) { + float lonlat = atan(-dir.x, -dir.z); + return vec2(lonlat * (0.5/pi) +0.5,0.5*dir.y+0.5); +} + +vec3 skyFromTex(vec3 pos,sampler2D sampler){ + vec2 p = sphereToCarte(pos); + return texture2D(sampler,p*texelSize*256.+vec2(18.5,1.5)*texelSize).rgb; +} +vec3 skyFromTexLOD(vec3 pos,sampler2D sampler, float LOD){ + vec2 p = sphereToCarte(pos); + return texture2DLod(sampler,p*texelSize*256.+vec2(18.5,1.5)*texelSize,LOD).rgb; +} vec4 skyCloudsFromTex(vec3 pos,sampler2D sampler){ vec2 p = sphereToCarte(pos); return texture2D(sampler,p*texelSize*256.+vec2(18.5+257.,1.5)*texelSize); @@ -92,12 +120,8 @@ vec4 skyCloudsFromTexLOD(vec3 pos,sampler2D sampler, float LOD){ vec2 p = sphereToCarte(pos); return texture2DLod(sampler,p*texelSize*256. + vec2(18.5 + 257., 1.5)*texelSize,LOD); } - // vec2 p = clamp(floor(gl_FragCoord.xy-vec2(18.+257,1.))/256.+tempOffsets/256.,0.0,1.0); - // vec2 p = clamp(floor(gl_FragCoord.xy-vec2(256*0.75,256*0.25))/150.+tempOffsets/150.,0.0,1.0); - - // vec2 p = clamp(floor(gl_FragCoord.xy-fogPos)/256.+tempOffsets/256.,-0.33,1.0); vec4 skyCloudsFromTexLOD2(vec3 pos,sampler2D sampler, float LOD){ vec2 p = sphereToCarte(pos); return texture2DLod(sampler,p*texelSize*256. + vec2(256.0 - 256.0*0.12,1.5)*texelSize,LOD); -} +} \ No newline at end of file diff --git a/shaders/lib/specular.glsl b/shaders/lib/specular.glsl index 28ed9a8..83edcbc 100644 --- a/shaders/lib/specular.glsl +++ b/shaders/lib/specular.glsl @@ -1,4 +1,3 @@ - uniform int framemod8; const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.), @@ -10,11 +9,11 @@ const vec2[8] offsets = vec2[8](vec2(1./8.,-3./8.), vec2(3,7.)/8., vec2(7.,-7.)/8.); -vec3 mix_vec3(vec3 X, vec3 Y, float A){ +vec3 lerp(vec3 X, vec3 Y, float A){ return X * (1.0 - A) + Y * A; } -float mix_float(float X, float Y, float A){ +float lerp(float X, float Y, float A){ return X * (1.0 - A) + Y * A; } @@ -22,14 +21,14 @@ float square(float x){ return x*x; } -float invLinZ (float lindepth){ - return -((2.0*near/lindepth)-far-near)/(far-near); -} + vec3 toClipSpace3(vec3 viewSpacePosition) { return projMAD(gbufferProjection, viewSpacePosition) / -viewSpacePosition.z * 0.5 + 0.5; } - +float invLinZ (float lindepth){ + return -((2.0*near/lindepth)-far-near)/(far-near); +} float linZ(float depth) { return (2.0 * near) / (far + near - depth * (far - near)); // l = (2*n)/(f+n-d(f-n)) @@ -57,11 +56,6 @@ mat3 CoordBase(vec3 n){ return mat3(x,y,n); } -float unpackRoughness(float x){ - float r = 1.0 - x; - return clamp(r*r,0,1); -} - vec2 R2_Sample(int n){ vec2 alpha = vec2(0.75487765, 0.56984026); return fract(alpha * n); @@ -194,7 +188,8 @@ void DoSpecularReflections( Lightmap = clamp((Lightmap-0.6)*5.0, 0.0,1.0); - Roughness = unpackRoughness(Roughness); + // Roughness = unpackRoughness(Roughness); + Roughness = 1.0 - Roughness; Roughness *= Roughness; F0 = F0 == 0.0 ? 0.02 : F0; // Roughness = 0.0; @@ -214,7 +209,7 @@ void DoSpecularReflections( vec3 L = Basis * Ln; float Fresnel = pow(clamp(1.0 + dot(-Ln, SamplePoints),0.0,1.0), 5.0); // Schlick's approximation - float RayContribution = mix_float(F0, 1.0, Fresnel); // ensure that when the angle is 0 that the correct F0 is used. + float RayContribution = lerp(F0, 1.0, Fresnel); // ensure that when the angle is 0 that the correct F0 is used. #ifdef Rough_reflections if(Hand) RayContribution = RayContribution * pow(1.0-Roughness,3.0); @@ -225,7 +220,7 @@ void DoSpecularReflections( bool hasReflections = Roughness_Threshold == 1.0 ? true : F0 * (1.0 - Roughness * Roughness_Threshold) > 0.01; // mulitply all reflections by the albedo if it is a metal. - vec3 Metals = F0 > 229.5/255.0 ? mix_vec3(Albedo, vec3(1.0), Fresnel) : vec3(1.0); + vec3 Metals = F0 > 229.5/255.0 ? lerp(Albedo, vec3(1.0), Fresnel) : vec3(1.0); // --------------- BACKGROUND REFLECTIONS // apply background reflections to the final color. make sure it does not exist based on the lightmap @@ -238,7 +233,7 @@ void DoSpecularReflections( #endif // take fresnel and lightmap levels into account and write to the final color - Final_Reflection = mix_vec3(Output, Background_Reflection, Lightmap * RayContribution); + Final_Reflection = lerp(Output, Background_Reflection, Lightmap * RayContribution); #endif // --------------- SCREENSPACE REFLECTIONS @@ -246,15 +241,17 @@ void DoSpecularReflections( #ifdef Screen_Space_Reflections if(hasReflections){ #ifdef Dynamic_SSR_quality - float SSR_Quality = mix_float(reflection_quality, 6.0, RayContribution); // Scale quality with ray contribution + float SSR_Quality = lerp(reflection_quality, 6.0, RayContribution); // Scale quality with ray contribution #else float SSR_Quality = reflection_quality; #endif float reflectLength = 0.0; - vec3 RaytracePos = rayTraceSpeculars(mat3(gbufferModelView) * L, FragPos, Noise.z, SSR_Quality, Hand, reflectLength); + vec3 RaytracePos = rayTraceSpeculars(mat3(gbufferModelView) * L, FragPos, Noise.z, float(SSR_Quality), Hand, reflectLength); float LOD = clamp(pow(reflectLength, pow(1.0-sqrt(Roughness),5.0) * 3.0) * 6.0, 0.0, 6.0); // use higher LOD as the reflection goes on, to blur it. this helps denoise a little. + if(Roughness <= 0.0) LOD = 0.0; + if (RaytracePos.z < 1.0){ vec3 previousPosition = mat3(gbufferModelViewInverse) * toScreenSpace(RaytracePos) + gbufferModelViewInverse[3].xyz + cameraPosition-previousCameraPosition; previousPosition = mat3(gbufferPreviousModelView) * previousPosition + gbufferPreviousModelView[3].xyz; @@ -266,10 +263,10 @@ void DoSpecularReflections( } } // make sure it takes the fresnel into account for SSR. - SS_Reflections.rgb = mix_vec3(Output, SS_Reflections.rgb, RayContribution); + SS_Reflections.rgb = lerp(Output, SS_Reflections.rgb, RayContribution); // occlude the background with the SSR and write to the final color. - Final_Reflection = mix_vec3(Final_Reflection, SS_Reflections.rgb, SS_Reflections.a); + Final_Reflection = lerp(Final_Reflection, SS_Reflections.rgb, SS_Reflections.a); } #endif @@ -277,7 +274,7 @@ void DoSpecularReflections( // slap the main lightsource reflections to the final color. #ifdef LIGHTSOURCE_REFLECTION Lightsource_Reflection = Diffuse * GGX(Normal, -WorldPos, LightPos, Roughness, F0) * Metals; - Final_Reflection += Lightsource_Reflection; + Final_Reflection += Lightsource_Reflection * Sun_specular_Strength; #endif Output = Final_Reflection; diff --git a/shaders/lib/stars.glsl b/shaders/lib/stars.glsl index 44d42e7..b4309ed 100644 --- a/shaders/lib/stars.glsl +++ b/shaders/lib/stars.glsl @@ -39,10 +39,10 @@ float StableStarField( in vec2 vSamplePos, float fThreshhold ) return StarVal; } -float stars(vec3 fragpos){ +float stars(vec3 viewPos){ - float elevation = clamp(fragpos.y,0.,1.); - vec2 uv = fragpos.xz/(1.5+elevation); + float elevation = clamp(viewPos.y,0.,1.); + vec2 uv = viewPos.xz/(1.5+elevation); - return StableStarField(uv*1000.,0.999)*0.5*(0.3-0.3*rainStrength); + return StableStarField(uv*1000.,0.999)*0.5*0.3; } diff --git a/shaders/lib/volumetricClouds.glsl b/shaders/lib/volumetricClouds.glsl index 7f0a394..e0673c0 100644 --- a/shaders/lib/volumetricClouds.glsl +++ b/shaders/lib/volumetricClouds.glsl @@ -14,19 +14,13 @@ const int cloudShadowLoD = cloud_ShadowLevelOfDetailLQ; #endif -uniform float viewHeight; -uniform float viewWidth; - -uniform sampler2D colortex4;//Skybox +// uniform float viewHeight; +// uniform float viewWidth; +uniform int worldTime; #define WEATHERCLOUDS - -uniform int worldTime; #include "/lib/climate_settings.glsl" -// #ifdef Daily_Weather - // uniform float CloudHeight; -// #endif float CumulusHeight = Cumulus_height; float MaxCumulusHeight = CumulusHeight + 100; float AltostratusHeight = 2000; @@ -56,6 +50,7 @@ float cloudCov(in vec3 pos,vec3 samplePos){ float CloudLarge = texture2D(noisetex, (samplePos.xz + cloud_movement) / 5000 ).b; float CloudSmall = texture2D(noisetex, (samplePos.xz - cloud_movement) / 500 ).r; + float Topshape = max(pos.y - (MaxCumulusHeight - 75), 0.0) / 200; Topshape += max(exp((pos.y - MaxCumulusHeight) / 10.0 ), 0.0) ; @@ -63,10 +58,10 @@ float cloudCov(in vec3 pos,vec3 samplePos){ float FinalShape = DailyWeather_Cumulus(coverage) - Topshape; // cap the top and bottom for reasons - float capbase = sqrt(max((CumulusHeight+12.5) - pos.y, 0.0)/50) ; + float capbase = sqrt(max((CumulusHeight+12.5) - pos.y, 0.0)/50) * (1-rainStrength); float captop = max(pos.y - MaxCumulusHeight, 0.0); - FinalShape = max(FinalShape - capbase - captop, 0.0); + FinalShape = max(FinalShape - capbase - captop , 0.0); return FinalShape; } @@ -83,26 +78,24 @@ float cloudVol(in vec3 pos,in vec3 samplePos,in float cov, in int LoD){ samplePos.xz += pow( max(pos.y - (CumulusHeight+20), 0.0) / 20.0,1.50); noise += 1.0-densityAtPos(samplePos * 200.) ; - - float smallnoise = densityAtPos(samplePos * 600.); - if (LoD > 0) noise += ((1-smallnoise) - max(0.15 - abs(smallnoise * 2.0 - 0.55) * 0.5,0.0)*1.5) * 0.5; + float smallnoise = densityAtPos(samplePos * 600.); + if (LoD > 0) noise += ((1-smallnoise) - max(0.15 - abs(smallnoise * 2.0 - 0.55) * 0.5,0.0)*1.5) * 0.6 * sqrt(noise); noise *= 1.0-cov; + noise = noise*noise; float cloud = max(cov - noise*noise*fbmAmount,0.0); return cloud; } - float GetCumulusDensity(in vec3 pos, in int LoD){ vec3 samplePos = pos*vec3(1.0,1./48.,1.0)/4; - + float coverageSP = cloudCov(pos,samplePos); - if (coverageSP > 0.001) { if (LoD < 0) return max(coverageSP - 0.27*fbmAmount,0.0); return cloudVol(pos,samplePos,coverageSP,LoD); @@ -113,9 +106,12 @@ float GetAltostratusDensity(vec3 pos){ float large = texture2D(noisetex, (pos.xz + cloud_movement)/100000. ).b; float small = texture2D(noisetex, (pos.xz - cloud_movement)/10000. - vec2(-large,1-large)/5).b; - + float shape = (small + pow((1.0-large),2.0))/2.0; + // float erode = 1-texture2D(noisetex, (pos.xz / ((1-small)*0.5+1.0) - cloud_movement)/1000. + vec2(-small,1-small)/5).b; + // float shape = max((small + pow((1.0-large),2.0))/2.0 - erode*0.05,0.0); + float Coverage; float Density; DailyWeather_Alto(Coverage, Density); @@ -125,6 +121,17 @@ float GetAltostratusDensity(vec3 pos){ return shape; } +#ifndef CLOUDSHADOWSONLY + +uniform sampler2D colortex4;//Skybox + + + +//Mie phase function +float phaseg(float x, float g){ + float gg = g * g; + return (gg * -0.25 + 0.25) * pow(-2.0 * (g * x) + (gg + 1.0), -1.5) / 3.14; +} // random magic number bullshit go! @@ -142,9 +149,8 @@ vec3 Cloud_lighting( vec3 pos, float time ){ - float coeeff = -30; // float powder = 1.0 - exp((CloudShape*CloudShape) * -800); - float powder = 1.0 - exp(CloudShape * coeeff/3); + float powder = 1.0 - exp(CloudShape * -10); float lesspowder = powder*0.4+0.6; vec3 skyLighting = SkyColors; @@ -154,45 +160,31 @@ vec3 Cloud_lighting( float cov = 0.0; float den = 0.0; DailyWeather_Alto(cov, den); - skyLighting += (sunContributionMulti * exp(-SunShadowing)) * clamp( 1.0 - pow( abs(den - 0.35) * 4.0 , 5.0) ,0.0,1.0) * cov; + + skyLighting += sunContributionMulti * 0.3 * exp2(AmbientShadow * SkyShadowing * -20) * clamp( 1.0 - pow( abs(den - 0.35) * 4.0 , 5.0) ,0.0,1.0) * cov; #endif - skyLighting *= exp(SkyShadowing * AmbientShadow * coeeff/2.0 ) * lesspowder ; + // skyLighting *= (1.0 - sqrt(exp2((1.0-SkyShadowing) * AmbientShadow * -10))) * lesspowder ; + skyLighting *= exp2((AmbientShadow*AmbientShadow) * SkyShadowing * -35) * lesspowder; + + + vec3 sunLighting = exp(SunShadowing * -15 + powder ) * sunContribution ; + sunLighting += exp(SunShadowing * -4) * sunContributionMulti * (powder*0.7+0.3); + + vec3 moonLighting = exp(MoonShadowing * -7 + powder) * moonContribution; + if(cloudType == 1){ - coeeff = -10; - skyLighting = SkyColors * exp(SkyShadowing * coeeff/15) * lesspowder; + skyLighting = SkyColors * exp(-sqrt(SkyShadowing)) * lesspowder; + + sunLighting = exp(SunShadowing * -5 ) * sunContribution; + sunLighting += exp(SunShadowing * -1) * sunContributionMulti * powder; } - vec3 sunLighting = exp(SunShadowing * coeeff + powder) * sunContribution; - sunLighting += exp(SunShadowing * coeeff/4 + powder*2) * sunContributionMulti; - - vec3 moonLighting = exp(MoonShadowing * coeeff/4 + powder) * moonContribution; - - return skyLighting + moonLighting + sunLighting ; + return skyLighting + moonLighting + sunLighting ; } - -//Mie phase function -float phaseg(float x, float g){ - float gg = g * g; - return (gg * -0.25 + 0.25) * pow(-2.0 * (g * x) + (gg + 1.0), -1.5) / 3.14; -} - -float CustomPhase(float LightPos, float S_1, float S_2){ - float SCALE = S_2 + 0.001; // remember the epislons 0.001 is fine. - float N = S_1; - float N2 = N / SCALE; - - float R = 1; - float A = pow(1.0 - pow(max(R-LightPos,0.0), N2 ),N); - - return A; -} - -uniform vec3 lightningEffect; - vec4 renderClouds( vec3 FragPosition, vec2 Dither, @@ -203,66 +195,80 @@ vec4 renderClouds( #ifndef VOLUMETRIC_CLOUDS return vec4(0.0,0.0,0.0,1.0); #endif + + + float total_extinction = 1.0; vec3 color = vec3(0.0); //project pixel position into projected shadowmap space - vec4 fragpos = normalize(gbufferModelViewInverse*vec4(FragPosition,1.0)); + vec4 viewPos = normalize(gbufferModelViewInverse*vec4(FragPosition,1.0)); + vec3 eyeplayepos = normalize(mat3(gbufferModelViewInverse) * FragPosition.xyz); - maxIT_clouds = int(clamp( maxIT_clouds / sqrt(exp2(fragpos.y)),0.0, maxIT)); + maxIT_clouds = int(clamp(maxIT_clouds / sqrt(exp2(viewPos.y)),0.0, maxIT)); - vec3 dV_view = normalize(fragpos.xyz); + vec3 dV_view = normalize(viewPos.xyz); + vec3 dV_view2 = dV_view; dV_view.y += 0.05; - vec3 dV_view2 = dV_view; - float mult2 = length(dV_view2); - //setup ray to start at the start of the cloud plane and end at the end of the cloud plane dV_view *= max(MaxCumulusHeight - CumulusHeight, 0.0)/abs(dV_view.y)/maxIT_clouds; + float mult = length(dV_view); // i want the samples to stay at one point in the world, but as the height coordinates go negative everything goes insideout, so this is a work around.... float startFlip = mix(max(cameraPosition.y - MaxCumulusHeight,0.0), max(CumulusHeight-cameraPosition.y,0), clamp(dV_view.y,0,1)); - // vec3 progress_view = dV_view*Dither.x + cameraPosition + (dV_view/abs(dV_view.y))*startFlip; - vec3 progress_view = dV_view*Dither.x + cameraPosition + (dV_view/abs(dV_view.y))*startFlip; + vec3 progress_view = dV_view*Dither.x + cameraPosition + (dV_view/abs(dV_view.y))*startFlip ; - // thank you emin for this world interseciton thing // float lViewPosM = length(FragPosition) < far * 1.5 ? length(FragPosition) - 1.0 : 1000000000.0; // bool IntersecTerrain = false; - ////// lighitng stuff + ////// lighting stuff float shadowStep = 200.; - vec3 dV_Sun = normalize(mat3(gbufferModelViewInverse)*sunVec)*shadowStep; - vec3 dV_Sun_small = dV_Sun/shadowStep; + // vec3 dV_Sun = normalize(mat3(gbufferModelViewInverse)*sunVec)*shadowStep; + + vec3 dV_Sun = WsunVec*shadowStep; + // vec3 dV_Sun_small = dV_Sun/shadowStep; - float SdotV = dot(sunVec,normalize(FragPosition)); + float SdotV = dot(mat3(gbufferModelView)*WsunVec,normalize(FragPosition)); - SkyColor *= clamp(abs(dV_Sun.y)/100.,0.75,1.0); + SkyColor *= clamp(abs(dV_Sun.y)/100.,0.5,1.0); SunColor = SunColor * clamp(dV_Sun.y ,0.0,1.0); MoonColor *= clamp(-dV_Sun.y,0.0,1.0); if(dV_Sun.y/shadowStep < -0.1) dV_Sun = -dV_Sun; - float mieDay = phaseg(SdotV, 0.75) * 3.14; - float mieDayMulti = phaseg(SdotV, 0.35) * 2; + float mieDay = phaseg(SdotV, 0.75); + float mieDayMulti = (phaseg(SdotV, 0.35) + phaseg(-SdotV, 0.35) * 0.5) ; - vec3 sunContribution = SunColor * mieDay; - vec3 sunContributionMulti = SunColor * mieDayMulti ; + vec3 sunContribution = SunColor * mieDay * 3.14; + vec3 sunContributionMulti = SunColor * mieDayMulti * 4.0; float mieNight = (phaseg(-SdotV,0.8) + phaseg(-SdotV, 0.35)*4); vec3 moonContribution = MoonColor * mieNight; float timing = 1.0 - clamp(pow(abs(dV_Sun.y)/150.0,2.0),0.0,1.0); - vec3 lightningColor = lightningEffect * 4.0; + + #ifdef Cumulus + + // float shadowStepSize[3] = float[]( + // 0.05, + // 0.25 + Dither.y*0.1, + // 0.50 + Dither.y*0.1 + // ); + for(int i=0;i lViewPosM; // if(IntersecTerrain) break; - float cumulus = GetCumulusDensity(progress_view, 1); + + float cumulus = GetCumulusDensity(progress_view, 1) ; + // cumulus = max(cumulus - (1-texture2D(noisetex, (eyeplayepos + cameraPosition / 500).xz*10).b)*0.1, 0.0 ); float alteredDensity = Cumulus_density * clamp(exp( (progress_view.y - (MaxCumulusHeight - 75)) / 9.0 ),0.0,1.0); @@ -271,16 +277,16 @@ vec4 renderClouds( float Sunlight = 0.0; float MoonLight = 0.0; - for (int j=0; j < 3; j++){ - vec3 shadowSamplePos = progress_view + (dV_Sun * 0.15) * (1 + Dither.y/2 + j); + // vec3 shadowSamplePos = progress_view + dV_Sun * (shadowStepSize[j] + Dither.y*shadowdither[j]); + // float shadow = GetCumulusDensity(shadowSamplePos, max(1-j,0)) * Cumulus_density; + vec3 shadowSamplePos = progress_view + dV_Sun * (0.1 + j * (0.1 + Dither.y*0.05)); float shadow = GetCumulusDensity(shadowSamplePos, 0) * Cumulus_density; - Sunlight += shadow / (1 + j); + Sunlight += shadow; MoonLight += shadow; - } #ifdef Altostratus @@ -291,15 +297,19 @@ vec4 renderClouds( #endif - float ambientlightshadow = 1.0 - clamp(exp((progress_view.y - (MaxCumulusHeight - 50)) / 100.0),0.0,1.0) ; + // float ambientlightshadow = 1.0 - clamp(exp((progress_view.y - (MaxCumulusHeight - 50)) / 100.0),0.0,1.0) ; + float ambientlightshadow = clamp((MaxCumulusHeight - progress_view.y - 50) / 100.0, 0.0,1.0); + + vec3 S = Cloud_lighting(muE, cumulus*Cumulus_density, Sunlight, MoonLight, SkyColor, sunContribution, sunContributionMulti, moonContribution, ambientlightshadow, 0, progress_view, WsunVec.y); + + #ifndef TEST + S += Iris_Lightningflash_VLcloud(progress_view - cameraPosition, lightningBoltPosition.xyz) * ambientlightshadow * exp(muE * -10.0) ; + #endif - vec3 S = Cloud_lighting(muE, cumulus*Cumulus_density, Sunlight, MoonLight, SkyColor, sunContribution, sunContributionMulti, moonContribution, ambientlightshadow, 0, progress_view, 1); - S += lightningColor * exp((1.0-cumulus) * -10) * ambientlightshadow; - - vec3 Sint = (S - S * exp(-mult*muE)) / muE; + vec3 Sint = (S - S * exp(-mult*muE)) / max(muE,1e-5); color += max(muE*Sint*total_extinction,0.0); - total_extinction *= max(exp(-mult*muE),0.0); - + total_extinction *= max(exp(-mult*muE),0.0); + if (total_extinction < 1e-5) break; } progress_view += dV_view; @@ -318,80 +328,101 @@ vec4 renderClouds( if(altostratus > 1e-5){ for (int j = 0; j < 2; j++){ - vec3 shadowSamplePos_high = progress_view_high + dV_Sun * float(j+Dither.y); + + vec3 shadowSamplePos_high = progress_view_high + (dV_Sun * (1.0 - abs(WsunVec.y))) * (1 + j + Dither.y); float shadow = GetAltostratusDensity(shadowSamplePos_high); - Sunlight += shadow; + Sunlight += shadow / (1 + j); + + // vec3 shadowSamplePos_high = progress_view_high + dV_Sun * float(j+Dither.y); + // float shadow = GetAltostratusDensity(shadowSamplePos_high); + // Sunlight += shadow; } vec3 S = Cloud_lighting(altostratus, altostratus, Sunlight, MoonLight, SkyColor, sunContribution, sunContributionMulti, moonContribution, 1, 1, progress_view_high, timing); - vec3 Sint = (S - S * exp(-20*altostratus)) / altostratus; + vec3 Sint = (S - S * exp(-mult*altostratus)) / max(altostratus,1e-5); color += max(altostratus*Sint*total_extinction,0.0); - total_extinction *= max(exp(-20*altostratus),0.0); + total_extinction *= max(exp(-mult*altostratus),0.0); + } } #endif vec3 normView = normalize(dV_view); + // Assume fog color = sky gradient at long distance - vec3 fogColor = skyFromTex(normView, colortex4)/150. * 5.0; - float dist = max(cameraPosition.y+CumulusHeight,max(CumulusHeight,150))/(abs(normView.y)+0.001); - float fog = exp(dist / -5000.0 * (1.0+rainCloudwetness*8.)); - - return mix(vec4(fogColor,0.0), vec4(color,total_extinction), fog); - // return vec4(color,total_extinction); + vec4 fogColor = vec4(skyFromTex(normView, colortex4)/30.0, 0.0); + float fog = clamp(abs(max(cameraPosition.y, 255.0) + MaxCumulusHeight) / max(abs(CumulusHeight-cameraPosition.y),0.00001) * abs(normView.y/1.5),0,1); + + // fog = pow(1.0 - exp(fog * -(5 - rainStrength*3)),2.0); + fog = 1.0 - clamp(exp((fog*fog) * -5.0),0.0,1.0); + + // fog = 1.0; + + // if(IntersecTerrain) fog = 1.0; + // return vec4(vec3(fog),0.0); + return mix(fogColor, vec4(color, total_extinction), clamp(fog,0.0,1.0)); } +#endif +float GetCloudShadow(vec3 feetPlayerPos){ +#ifdef CLOUDS_SHADOWS + vec3 playerPos = feetPlayerPos + cameraPosition; -float GetCloudShadow(vec3 eyePlayerPos){ - vec3 playerPos = eyePlayerPos + cameraPosition; - playerPos.y += 0.05; float shadow = 0.0; // assume a flat layer of cloud, and stretch the sampled density along the sunvector, starting from some vertical layer in the cloud. #ifdef Cumulus vec3 lowShadowStart = playerPos + WsunVec/abs(WsunVec.y) * max((MaxCumulusHeight - 70) - playerPos.y,0.0) ; - shadow += GetCumulusDensity(lowShadowStart,1)*Cumulus_density; + shadow += GetCumulusDensity(lowShadowStart, 1)*Cumulus_density; #endif #ifdef Altostratus vec3 highShadowStart = playerPos + WsunVec/abs(WsunVec.y) * max(AltostratusHeight - playerPos.y,0.0); - shadow += GetAltostratusDensity(highShadowStart); + shadow += GetAltostratusDensity(highShadowStart) * 0.5; #endif - shadow = shadow/2.0; // perhaps i should average the 2 shadows being added.... - shadow = clamp(exp(-shadow*20.0),0.0,1.0); + shadow = clamp(shadow,0.0,1.0); + shadow *= shadow; + + shadow = exp2(shadow * -100.0); return shadow; + +#else + return 1.0; +#endif } float GetCloudShadow_VLFOG(vec3 WorldPos, vec3 WorldSpace_sunVec){ - +#ifdef CLOUDS_SHADOWS float shadow = 0.0; // assume a flat layer of cloud, and stretch the sampled density along the sunvector, starting from some vertical layer in the cloud. #ifdef Cumulus vec3 lowShadowStart = WorldPos + WorldSpace_sunVec/abs(WorldSpace_sunVec.y) * max((MaxCumulusHeight - 60) - WorldPos.y,0.0) ; - shadow += max(GetCumulusDensity(lowShadowStart,0) - 0.2,0.0)*Cumulus_density; + shadow += max(GetCumulusDensity(lowShadowStart, 0) , 0.0)*Cumulus_density; #endif #ifdef Altostratus vec3 highShadowStart = WorldPos + WorldSpace_sunVec/abs(WorldSpace_sunVec.y) * max(AltostratusHeight - WorldPos.y,0.0); - shadow += GetAltostratusDensity(highShadowStart); + shadow += GetAltostratusDensity(highShadowStart)*0.5; #endif - // shadow = shadow/2.0; // perhaps i should average the 2 shadows being added.... - - shadow = clamp(exp(-shadow*255.0),0.0,1.0); + shadow = clamp(shadow,0.0,1.0); + shadow *= shadow; - // do not allow it to exist above the lowest cloud plane - // shadow *= clamp(((MaxCumulusHeight + CumulusHeight)*0.435 - WorldPos.y)/100,0.0,1.0) ; + shadow = exp2(shadow * -150.0); return shadow; + +#else + return 1.0; +#endif } float GetCloudSkyOcclusion(vec3 WorldPos){ - +#ifdef CLOUDS_SHADOWS float shadow = 0.0; vec3 shadowDir = vec3(0,1,0); @@ -407,4 +438,7 @@ float GetCloudSkyOcclusion(vec3 WorldPos){ shadow = clamp(exp(-shadow*25.0) ,0.0,1.0); return shadow; +#else + return 1.0; +#endif } \ No newline at end of file diff --git a/shaders/lib/volumetricFog.glsl b/shaders/lib/volumetricFog.glsl index ed27cc8..c1237f8 100644 --- a/shaders/lib/volumetricFog.glsl +++ b/shaders/lib/volumetricFog.glsl @@ -2,8 +2,6 @@ vec3 normVec (vec3 vec){ return vec*inversesqrt(dot(vec,vec)); } - - float phaseRayleigh(float cosTheta) { const vec2 mul_add = vec2(0.1, 0.28) /acos(-1.0); return cosTheta * mul_add.x + mul_add.y; // optimized version from [Elek09], divided by 4 pi for energy conservation @@ -27,23 +25,24 @@ float cloudVol(in vec3 pos){ vec3 samplePos = pos*vec3(1.0,1./24.,1.0); vec3 samplePos2 = pos*vec3(1.0,1./48.,1.0); + float fogYstart = SEA_LEVEL-6; - float mult = exp( -max((pos.y - SEA_LEVEL) / 35.,0.0)); + float mult = exp( -max((pos.y - fogYstart) / 35.,0.0)); float fog_shape = 1.0 - densityAtPosFog(samplePos * 24.0 ); float fog_eroded = 1.0 - densityAtPosFog(samplePos2 * 200.0 ); // float CloudyFog = max( (fog_shape*2.0 - fog_eroded*0.5) - 1.2, max(fog_shape-0.8,0.0)) * mult; - float heightlimit = exp2( -max((pos.y - SEA_LEVEL) / 25.,0.0)); + float heightlimit = exp2( -max((pos.y - fogYstart * (1.0+snowStorm)) / 25.,0.0)); float CloudyFog = max((fog_shape*1.2 - fog_eroded*0.2) - 0.75,0.0) * heightlimit ; - - float UniformFog = exp2( -max((pos.y - SEA_LEVEL) / 25.,0.0)); + float UniformFog = exp( max(pos.y - fogYstart,0.0) / -25) + 0.05; + // UniformFog = 1.0; - float RainFog = max(fog_shape*10. - 7.,0.5) * exp2( -max((pos.y - SEA_LEVEL) / 25.,0.0)) * 5. * rainStrength * noPuddleAreas * RainFog_amount; + // float RainFog = max(fog_shape*10. - 7.,0.5) * exp2( -max((pos.y - SEA_LEVEL) / 25.,0.0)) * 72. * rainStrength * noPuddleAreas * RainFog_amount; + float RainFog = (2 + max(fog_shape*10. - 7.,0.5)*2.0) * UniformFog * rainStrength * noPuddleAreas * RainFog_amount; - - #ifdef Biome_specific_environment + #ifdef PER_BIOME_ENVIRONMENT // sandstorms and snowstorms if(sandStorm > 0 || snowStorm > 0) CloudyFog = mix(CloudyFog, max(densityAtPosFog((samplePos2 - vec3(frameTimeCounter,0,frameTimeCounter)*10) * 100.0 ) - 0.2,0.0) * heightlimit, sandStorm+snowStorm); #endif @@ -53,27 +52,50 @@ float cloudVol(in vec3 pos){ return CloudyFog + UniformFog + RainFog; } +// // uniform vec4 lightningBoltPosition; +// float Iris_Lightningflash_VLfog(vec3 feetPlayerPos, vec3 lightningBoltPos){ -vec4 getVolumetricRays( - vec3 fragpos, +// vec3 LightningPos = feetPlayerPos - vec3(lightningBoltPosition.x, clamp(feetPlayerPos.y, lightningBoltPosition.y, lightningBoltPosition.y+116.0),lightningBoltPosition.z); + +// // point light, max distance is ~500 blocks (the maximim entity render distance) +// float lightDistance = 300.0; + +// #ifdef TEST +// float lightningLight = 0.0; +// #else + +// float lightningLight = max(1.0 - length(LightningPos) / lightDistance, 0.0) ; + +// lightningLight = exp((1.0 - lightningLight) * -15.0) ; +// #endif + +// // lightningLight = pow(lightningLight,5.0); + +// return lightningLight ; +// } + +uniform bool inSpecialBiome; +vec4 GetVolumetricFog( + vec3 viewPosition, float dither, + vec3 LightColor, vec3 AmbientColor ){ //project pixel position into projected shadowmap space - vec3 wpos = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz; + vec3 wpos = mat3(gbufferModelViewInverse) * viewPosition + gbufferModelViewInverse[3].xyz; vec3 fragposition = mat3(shadowModelView) * wpos + shadowModelView[3].xyz; fragposition = diagonal3(shadowProjection) * fragposition + shadowProjection[3].xyz; //project view origin into projected shadowmap space - vec3 start = toShadowSpaceProjected(vec3(0.)); + vec3 start = toShadowSpaceProjected(vec3(0.0)); //rayvector into projected shadow map space //we can use a projected vector because its orthographic projection //however we still have to send it to curved shadow map space every step - vec3 dV = fragposition-start; + vec3 dV = fragposition - start; vec3 dVWorld = (wpos-gbufferModelViewInverse[3].xyz); - float maxLength = min(length(dVWorld),far)/length(dVWorld); + float maxLength = min(length(dVWorld), far)/length(dVWorld); dV *= maxLength; dVWorld *= maxLength; @@ -82,33 +104,42 @@ vec4 getVolumetricRays( vec3 vL = vec3(0.); - float SdotV = dot(sunVec,normalize(fragpos))*lightCol.a; + float SdotV = dot(sunVec,normalize(viewPosition))*lightCol.a; float dL = length(dVWorld); //Mie phase + somewhat simulates multiple scattering (Horizon zero down cloud approx) - float mie = phaseg(SdotV,0.7)*5.0 + 1.0; + float mie = phaseg(SdotV,0.7)*5.0 + 0.1; float rayL = phaseRayleigh(SdotV); - - // Makes fog more white idk how to simulate it correctly - vec3 sunColor = lightCol.rgb / 80.0; - vec3 skyCol0 = AmbientColor / 150. * 5. ; // * max(abs(WsunVec.y)/150.0,0.); - - vec3 lightningColor = (lightningEffect / 10) * (max(eyeBrightnessSmooth.y,0)/240.); - - vec3 np3 = normVec(wpos); - float ambfogfade = clamp(exp(np3.y* 2 - 2),0.0,1.0) * 4 ; - skyCol0 += lightningColor * ambfogfade; - - - #ifdef Biome_specific_environment - // recolor change sun and sky color to some color, but make sure luminance is preserved. - BiomeFogColor(sunColor); - BiomeFogColor(skyCol0); - #endif - vec3 rC = vec3(fog_coefficientRayleighR*1e-6, fog_coefficientRayleighG*1e-5, fog_coefficientRayleighB*1e-5); vec3 mC = vec3(fog_coefficientMieR*1e-6, fog_coefficientMieG*1e-6, fog_coefficientMieB*1e-6); + + // Makes fog more white idk how to simulate it correctly + vec3 LightSourceColor = LightColor; + vec3 skyCol0 = AmbientColor / 2.0; + + // recolor change sun and sky color to a color, but make sure luminance is preserved. + #ifdef PER_BIOME_ENVIRONMENT + BiomeFogColor(LightSourceColor); + BiomeFogColor(skyCol0); + #endif + + // float upGradient = 1.0 - (normalize(wpos).y*0.5 + 0.5); + // skyCol0 *= exp(upGradient * -5.0)*1.5 + 0.5; + + // float upGradient = np3.y; + // skyCol0 = max(skyCol0 + skyCol0*upGradient,0.0); + + // #if defined Cave_fog && defined TEST + // vec3 cavefogCol = vec3(CaveFogColor_R,CaveFogColor_G,CaveFogColor_B); + + // #ifdef PER_BIOME_ENVIRONMENT + // BiomeFogColor(cavefogCol); + // #endif + + // cavefogCol = cavefogCol * clamp(1.0 - normalize(wpos).y, 0.0, 1.0) * 0.001 ; + // #endif + float mu = 1.0; float muS = mu; @@ -117,7 +148,7 @@ vec4 getVolumetricRays( vec3 WsunVec = mat3(gbufferModelViewInverse) * sunVec * lightCol.a; - vec3 progressW = gbufferModelViewInverse[3].xyz+cameraPosition; + vec3 progressW = gbufferModelViewInverse[3].xyz + cameraPosition; float lightleakfix = clamp(pow(eyeBrightnessSmooth.y/240.,2) ,0.0,1.0); for (int i=0;i TORCH_R TORCH_G TORCH_B screen.Ambient_Colors.columns=1 - screen.Ambient_Colors = ambient_brightness MIN_LIGHT_AMOUNT ambient_colortype ambient_temp AmbientLight_R AmbientLight_G AmbientLight_B + screen.Ambient_Colors = ambient_brightness MIN_LIGHT_AMOUNT AmbientLight_R AmbientLight_G AmbientLight_B @@ -100,17 +117,23 @@ PhysicsMod_support [LabPBR] screen.Waving_Stuff = WAVY_PLANTS WAVY_STRENGTH WAVY_SPEED ## POM screen.POM.columns=1 - screen.POM = POM Adaptive_Step_length MAX_ITERATIONS POM_DEPTH MAX_DIST Horrible_slope_normals + screen.POM = HEIGTHMAP_DEPTH_OFFSET POM Adaptive_Step_length MAX_ITERATIONS POM_DEPTH MAX_DIST Horrible_slope_normals ######## CLIMATE screen.Climate.columns=1 - screen.Climate = [Seasons] Biome_specific_environment Daily_Weather + screen.Climate = Daily_Weather [Seasons] PER_BIOME_ENVIRONMENT [SWAMP] [JUNGLE] [DARKFOREST] ## BIOME SPECIFICS - screen.Biome_Fog.columns=1 - screen.Biome_Fog = Biome_specific_environment + screen.SWAMP.columns=1 + screen.SWAMP = SWAMP_ENV SWAMP_UNIFORM_DENSITY SWAMP_CLOUDY_DENSITY SWAMP_R SWAMP_G SWAMP_B + + screen.JUNGLE.columns=1 + screen.JUNGLE = JUNGLE_ENV JUNGLE_UNIFORM_DENSITY JUNGLE_CLOUDY_DENSITY JUNGLE_R JUNGLE_G JUNGLE_B + + screen.DARKFOREST.columns=1 + screen.DARKFOREST = DARKFOREST_ENV DARKFOREST_UNIFORM_DENSITY DARKFOREST_CLOUDY_DENSITY DARKFOREST_R DARKFOREST_G DARKFOREST_B ## SEASONS @@ -132,7 +155,7 @@ PhysicsMod_support [LabPBR] ######## ATMOSPHERICS screen.Atmospherics.columns=1 - screen.Atmospherics = [Sky] [Fog] [Biome_Fog] [Clouds] Altostratus Cumulus_Clouds Allow_Vanilla_sky + screen.Atmospherics = [Sky] [Fog] [Clouds] Altostratus Cumulus_Clouds Allow_Vanilla_sky ### SKY screen.Sky.columns=1 @@ -147,7 +170,7 @@ PhysicsMod_support [LabPBR] ### FOG screen.Fog.columns=2 - screen.Fog = VL_RENDER_RESOLUTION Haze_amount VL_SAMPLES RainFog_amount BLOOMY_FOG [TOD_fog] Cloud_Fog [Biome_Fog] BorderFog [Cave_Fog] [NETHER_END_FOG] + screen.Fog = VL_RENDER_RESOLUTION Haze_amount VL_SAMPLES RainFog_amount BLOOMY_FOG [TOD_fog] Cloud_Fog BorderFog [Cave_Fog] [NETHER_END_FOG] screen.TOD_fog.columns=2 @@ -197,7 +220,7 @@ PhysicsMod_support [LabPBR] ######## MISC SETTINGS screen.Misc_Settings.columns=1 - screen.Misc_Settings = [the_orb] WhiteWorld ambientLight_only Glass_Tint display_LUT ambientSSS_view LIT_PARTICLE_BRIGHTNESS + screen.Misc_Settings = [the_orb] display_LUT WhiteWorld SSS_view ambientLight_only Glass_Tint LIGHTNING_FLASH HURT_AND_DEATH_EFFECT LIT_PARTICLE_BRIGHTNESS screen.the_orb.columns = 1 screen.the_orb = THE_ORB ORB_X ORB_Y ORB_Z ORB_ColMult ORB_R ORB_G ORB_B @@ -216,12 +239,16 @@ PhysicsMod_support [LabPBR] screen.Advanced = Dirt_Scatter_R Dirt_Scatter_G Dirt_Scatter_B Dirt_Absorb_R Dirt_Absorb_G Dirt_Absorb_B Water_Absorb_R Water_Absorb_G Water_Absorb_B -######## moonphase based weather + + +##################################### +####### WEATHER RELATED STUFF ####### +##################################### # in seconds... -variable.int.TransitionTime = 30 +variable.int.WeatherTransitionTime = 30 -uniform.float.Cumulus_Cov = smooth(1, if( \ +uniform.float.Cumulus_Cov = smooth(if( \ moonPhase == 0, 0.7, \ moonPhase == 1, 0.9, \ moonPhase == 2, 0.0, \ @@ -229,9 +256,9 @@ uniform.float.Cumulus_Cov = smooth(1, if( \ moonPhase == 4, 0.0, \ moonPhase == 5, 1.2, \ moonPhase == 6, 0.6, \ - 0.0 ), TransitionTime, TransitionTime) + 0.0 ), WeatherTransitionTime, WeatherTransitionTime) -uniform.float.Alto_Cov = smooth(2, if( \ +uniform.float.Alto_Cov = smooth(if( \ moonPhase == 0, 0.1, \ moonPhase == 1, 1.0, \ moonPhase == 2, 1.0, \ @@ -239,9 +266,9 @@ uniform.float.Alto_Cov = smooth(2, if( \ moonPhase == 4, 0.3, \ moonPhase == 5, 0.0, \ moonPhase == 6, 1.5, \ - 0.0 ), TransitionTime, TransitionTime) + 0.0 ), WeatherTransitionTime, WeatherTransitionTime) -uniform.float.Alto_Den = smooth(3, if( \ +uniform.float.Alto_Den = smooth(if( \ moonPhase == 0, 0.1, \ moonPhase == 1, 0.25, \ moonPhase == 2, 0.1, \ @@ -249,73 +276,101 @@ uniform.float.Alto_Den = smooth(3, if( \ moonPhase == 4, 0.7, \ moonPhase == 5, 0.0, \ moonPhase == 6, 0.05, \ - 0.0 ), TransitionTime, TransitionTime) + 0.0 ), WeatherTransitionTime, WeatherTransitionTime) -uniform.float.Uniform_Den = smooth(4, if( \ +uniform.float.Uniform_Den = smooth(if( \ moonPhase == 0, 0, \ moonPhase == 1, 0, \ - moonPhase == 2, 4, \ + moonPhase == 2, 10, \ moonPhase == 3, 0, \ moonPhase == 4, 0, \ moonPhase == 5, 0, \ - moonPhase == 6, 2, \ - 0 ), TransitionTime, TransitionTime) + moonPhase == 6, 5, \ + 0 ), WeatherTransitionTime, WeatherTransitionTime) -uniform.float.Cloudy_Den = smooth(5, if( \ +uniform.float.Cloudy_Den = smooth(if( \ moonPhase == 0, 0, \ moonPhase == 1, 0, \ moonPhase == 2, 0, \ moonPhase == 3, 0, \ moonPhase == 4, 0, \ moonPhase == 5, 0, \ - moonPhase == 6, 5, \ - 0 ), TransitionTime, TransitionTime) - -# uniform.float.CloudHeight = smooth(5, if( \ -# moonPhase == 0, 1.0, \ -# moonPhase == 1, 0.5, \ -# moonPhase == 2, 1.0, \ -# moonPhase == 3, 1.5, \ -# moonPhase == 4, 1.0, \ -# moonPhase == 5, 1.0, \ -# moonPhase == 6, 1.0, \ -# 1.0 ), TransitionTime, TransitionTime) - - -# Biome uniforms - -variable.int.BiomeTransitionTime = 30 - -uniform.float.isJungles = smooth(6, if(in(biome,23,24,25), 1,0), BiomeTransitionTime,BiomeTransitionTime) -uniform.float.isSwamps = smooth(7, if(in(biome,6,7,52), 1,0), BiomeTransitionTime,BiomeTransitionTime) - -uniform.float.sandStorm = smooth(8, if(in(biome,5,26,27,28), rainStrength,0), 15,15) -uniform.float.snowStorm = smooth(9, if(in(biome,31,32,33,34), rainStrength,0), 15,15) - -uniform.float.noPuddleAreas = smooth(10, if(in(biome,5,16,17,18,26, 27, 28, 3, 4, 16,31,32,33,34, 37, 39, 48), 0,1), 5,5) - + moonPhase == 6, 50, \ + 0 ), WeatherTransitionTime, WeatherTransitionTime) # uniform.float.ifEndBoss = smooth(if(bossBattle == 2, 1, 0 ), 1, 1) - # uniform.float.EndSequence1 = smooth(if(hideGUI == 1, 1.0, 0.0), 30, 0) - # uniform.float.EndSequence2 = smooth(if(EndSequence1 > 0.95, 1.0, 0.0), 1.25, 0) -# uniform.float.Winter = smooth(14, if( worldDay > 0 && worldDay < 10), 5, 5) - - # thank you sixthsurge! -uniform.float.lightningFlash = smooth(16,if(equals(skyColor.r, skyColor.g, 0.01) && skyColor.r > 0.3, 1.0, 0.0), 0.0, 0.2) +#ifdef LIGHTNING_FLASH + #ifdef IS_IRIS + variable.float.lightningFlash = smooth(if(lightningBoltPosition.w > 0.0, 1.0, 0.0), 0.0, 0.0) + #else + variable.float.lightningFlash = smooth(if(equals(skyColor.r, skyColor.g, 0.01) && skyColor.r > 0.3, 1.0, 0.0), 0.0, 0.0) + #endif +#else + variable.float.lightningFlash = 0.0 +#endif -uniform.vec3.lightningEffect = vec3(77.0*lightningFlash, 153.0*lightningFlash, 255.0*lightningFlash) +uniform.vec3.lightningEffect = vec3(77.0 * lightningFlash, 153.0 * lightningFlash, 255.0 * lightningFlash) -texture.noise=texture/noises.png -texture.composite.colortex6=texture/blueNoise.png -separateAo=true -alphaTest.shadow= GREATER 0.1 -beacon.beam.depth=true -rain.depth=false + +################################### +####### BIOME RELATED STUFF ####### +################################### + +variable.int.BiomeTransitionTime = 1 + +#ifdef SWAMP_ENV + uniform.float.isSwamps = smooth(if(in(biome, 6, 52, 7), 1,0), BiomeTransitionTime, BiomeTransitionTime) +#else + uniform.float.isSwamps = 0.0 +#endif + +#ifdef JUNGLE_ENV + uniform.float.isJungles = smooth(if(in(biome, 23, 24, 25), 1,0), BiomeTransitionTime, BiomeTransitionTime) +#else + uniform.float.isJungles = 0.0 +#endif + +#ifdef DARKFOREST_ENV + uniform.float.isDarkForests = smooth(if(in(biome, 11), 1,0), BiomeTransitionTime, BiomeTransitionTime) +#else + uniform.float.isDarkForests = 0.0 +#endif + +#ifdef MANGROVE_ENV + uniform.float.isMangroveSwamp = smooth(if(in(biome, 7), 1,0), BiomeTransitionTime, BiomeTransitionTime) +#else + uniform.float.isMangroveSwamp = 0.0 +#endif + +# set to only happen in dry deserts. +uniform.float.sandStorm = smooth(if(in(biome, 5, 26, 27, 28), rainStrength, 0), 15,30) + +# set to only happen in cold mountains. +uniform.float.snowStorm = smooth(if(in(biome, 31, 32, 33, 34), rainStrength, 0), 15,30) + +uniform.float.noPuddleAreas = smooth(if(in(biome, 3, 4, 16, 37, 39, 48, 49, 31, 32, 33, 34, 5, 17, 18, 26, 27, 28), 0,1), 5,5) + + + +############################ +####### RANDOM STUFF ####### +############################ + +#ifdef HURT_AND_DEATH_EFFECT + uniform.float.hurt = smooth(if(is_hurt,1,0),0,1) + uniform.float.dying = smooth(if(!is_alive,2,0),3,0) + uniform.float.dead = smooth(if(dying >= 1.99, 1,0),1,0) +#endif + +uniform.vec3.CamPos = vec3(cameraPosition.x,cameraPosition.y,cameraPosition.z) + +texture.noise = texture/noises.png +texture.composite.colortex6 = texture/blueNoise.png variable.float.texelSizeX = 1.0/viewWidth variable.float.texelSizeY = 1.0/viewHeight diff --git a/shaders/world-1/composite.vsh b/shaders/world-1/composite.vsh deleted file mode 100644 index 5d659b9..0000000 --- a/shaders/world-1/composite.vsh +++ /dev/null @@ -1,5 +0,0 @@ -#version 120 - -#define NETHER_SHADER - -#include "/dimensions/composite.vsh" \ No newline at end of file diff --git a/shaders/world-1/composite10.fsh b/shaders/world-1/composite10.fsh new file mode 100644 index 0000000..6fdc6a5 --- /dev/null +++ b/shaders/world-1/composite10.fsh @@ -0,0 +1,5 @@ +#version 120 + +#define NETHER_SHADER + +#include "/dimensions/composite10.fsh" \ No newline at end of file diff --git a/shaders/world-1/composite10.vsh b/shaders/world-1/composite10.vsh new file mode 100644 index 0000000..7a5a31a --- /dev/null +++ b/shaders/world-1/composite10.vsh @@ -0,0 +1,5 @@ +#version 120 + +#define NETHER_SHADER + +#include "/dimensions/composite10.vsh" \ No newline at end of file diff --git a/shaders/world-1/composite11.fsh b/shaders/world-1/composite11.fsh new file mode 100644 index 0000000..c8dd09f --- /dev/null +++ b/shaders/world-1/composite11.fsh @@ -0,0 +1,5 @@ +#version 120 + +#define NETHER_SHADER + +#include "/dimensions/composite11.fsh" \ No newline at end of file diff --git a/shaders/world-1/composite11.vsh b/shaders/world-1/composite11.vsh new file mode 100644 index 0000000..ae59f60 --- /dev/null +++ b/shaders/world-1/composite11.vsh @@ -0,0 +1,5 @@ +#version 120 + +#define NETHER_SHADER + +#include "/dimensions/composite11.vsh" \ No newline at end of file diff --git a/shaders/world-1/gbuffers_armor_glint.fsh b/shaders/world-1/gbuffers_armor_glint.fsh index 430bda4..5501d52 100644 --- a/shaders/world-1/gbuffers_armor_glint.fsh +++ b/shaders/world-1/gbuffers_armor_glint.fsh @@ -1,25 +1,5 @@ #version 120 -#include "/lib/settings.glsl" +#define ENCHANT_GLINT -varying vec4 lmtexcoord; -varying vec4 color; -uniform sampler2D texture; - -//faster and actually more precise than pow 2.2 -vec3 toLinear(vec3 sRGB){ - return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878); -} - -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -/* DRAWBUFFERS:2 */ - -void main() { - - gl_FragData[0] = vec4(toLinear( texture2D(texture, lmtexcoord.xy).rgb * color.rgb), 0.1); - -} +#include "/dimensions/all_vanilla_emissives.fsh" \ No newline at end of file diff --git a/shaders/world-1/gbuffers_armor_glint.vsh b/shaders/world-1/gbuffers_armor_glint.vsh index acb4c70..87ad965 100644 --- a/shaders/world-1/gbuffers_armor_glint.vsh +++ b/shaders/world-1/gbuffers_armor_glint.vsh @@ -1,47 +1,5 @@ #version 120 -#include "/lib/settings.glsl" -#include "/lib/res_params.glsl" +#define ENCHANT_GLINT -/* -!! DO NOT REMOVE !! -This code is from Chocapic13' shaders -Read the terms of modification and sharing before changing something below please ! -!! DO NOT REMOVE !! -*/ - -varying vec4 lmtexcoord; -varying vec4 color; - -uniform vec2 texelSize; -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.); - -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// - -void main() { - gl_Position = ftransform(); - - lmtexcoord.xy = (gl_TextureMatrix[0] * gl_MultiTexCoord0).st; - - vec2 lmcoord = gl_MultiTexCoord1.xy/255.; - - lmtexcoord.zw = lmcoord*lmcoord; - - color = gl_Color; - - #ifdef TAA - gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize; - #endif -} +#include "/dimensions/all_vanilla_emissives.vsh" \ No newline at end of file diff --git a/shaders/world-1/gbuffers_basic.fsh b/shaders/world-1/gbuffers_basic.fsh index b6c50e0..524ea00 100644 --- a/shaders/world-1/gbuffers_basic.fsh +++ b/shaders/world-1/gbuffers_basic.fsh @@ -1,9 +1,7 @@ #version 120 -// #define ENTITIES -#define BLOCKENTITIES -#define WORLD +#define LINES #define NETHER_SHADER -#include "/dimensions/all_solid.fsh" \ No newline at end of file +#include "/dimensions/all_particles.fsh" \ No newline at end of file diff --git a/shaders/world-1/gbuffers_basic.vsh b/shaders/world-1/gbuffers_basic.vsh index 47026d7..9b48b38 100644 --- a/shaders/world-1/gbuffers_basic.vsh +++ b/shaders/world-1/gbuffers_basic.vsh @@ -1,10 +1,7 @@ #version 120 -// #define ENTITIES -// #define LINE -#define BLOCKENTITIES -#define WORLD +#define LINES #define NETHER_SHADER -#include "/dimensions/all_solid.vsh" \ No newline at end of file +#include "/dimensions/all_particles.vsh" \ No newline at end of file diff --git a/shaders/world-1/gbuffers_beaconbeam.fsh b/shaders/world-1/gbuffers_beaconbeam.fsh index 6c6a7bf..3e666de 100644 --- a/shaders/world-1/gbuffers_beaconbeam.fsh +++ b/shaders/world-1/gbuffers_beaconbeam.fsh @@ -1,29 +1,5 @@ #version 120 -#include "/lib/settings.glsl" +#define BEACON_BEAM -varying vec4 lmtexcoord; -varying vec2 texcoord; -varying vec4 color; -uniform sampler2D texture; - -//faster and actually more precise than pow 2.2 -vec3 toLinear(vec3 sRGB){ - return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878); -} - -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -/* DRAWBUFFERS:28 */ - -void main() { - - vec4 Albedo = texture2D(texture, texcoord.xy) * color * 1.5; - - gl_FragData[0] = vec4(toLinear(Albedo.rgb), 1.0); - gl_FragData[1] = vec4(0.0, 0.0, 0.0, 0.5); - -} +#include "/dimensions/all_vanilla_emissives.fsh" \ No newline at end of file diff --git a/shaders/world-1/gbuffers_beaconbeam.vsh b/shaders/world-1/gbuffers_beaconbeam.vsh index 32726c5..f285c00 100644 --- a/shaders/world-1/gbuffers_beaconbeam.vsh +++ b/shaders/world-1/gbuffers_beaconbeam.vsh @@ -1,44 +1,5 @@ #version 120 -//#extension GL_EXT_gpu_shader4 : disable -#include "/lib/settings.glsl" -#include "/lib/res_params.glsl" +#define BEACON_BEAM -/* -!! DO NOT REMOVE !! -This code is from Chocapic13' shaders -Read the terms of modification and sharing before changing something below please ! -!! DO NOT REMOVE !! -*/ - -varying vec4 color; -varying vec2 texcoord; - -uniform vec2 texelSize; -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.); -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// - -void main() { - - gl_Position = ftransform(); - if(gl_Color.a < 1.0 ) gl_Position = vec4(10,10,10,1); - - texcoord = (gl_MultiTexCoord0).xy; - color = gl_Color; - - #ifdef TAA - gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize; - #endif -} +#include "/dimensions/all_vanilla_emissives.vsh" \ No newline at end of file diff --git a/shaders/world-1/gbuffers_damagedblock.fsh b/shaders/world-1/gbuffers_damagedblock.fsh index d51ec5d..bae444a 100644 --- a/shaders/world-1/gbuffers_damagedblock.fsh +++ b/shaders/world-1/gbuffers_damagedblock.fsh @@ -1,116 +1,6 @@ #version 120 -//#extension GL_EXT_gpu_shader4 : disable -#define PCF +#define DAMAGE_BLOCK_EFFECT +#define NETHER_SHADER - - - -varying vec4 lmtexcoord; -varying vec4 color; -varying vec4 normalMat; - - -uniform sampler2D texture; -uniform sampler2D gaux1; -uniform vec4 lightCol; -uniform vec3 sunVec; -uniform vec3 upVec; - -uniform vec2 texelSize; -uniform float skyIntensityNight; -uniform float skyIntensity; -uniform float sunElevation; -uniform float rainStrength; -uniform mat4 gbufferProjectionInverse; -uniform mat4 gbufferModelViewInverse; -uniform mat4 shadowModelView; -uniform mat4 shadowProjection; - -//faster and actually more precise than pow 2.2 -vec3 toLinear(vec3 sRGB){ - return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878); -} - -#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z) -#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz) -vec3 toScreenSpace(vec3 p) { - vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw); - vec3 p3 = p * 2. - 1.; - vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3]; - return fragposition.xyz / fragposition.w; -} -float interleaved_gradientNoise(float temporal){ - vec2 coord = gl_FragCoord.xy; - float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y)+temporal); - return noise; -} - -#ifdef PCF -const vec2 shadowOffsets[4] = vec2[4](vec2( 0.1250, 0.0000 ), -vec2( -0.1768, -0.1768 ), -vec2( -0.0000, 0.3750 ), -vec2( 0.3536, -0.3536 ) -); -#endif -float facos(float sx){ - float x = clamp(abs( sx ),0.,1.); - float a = sqrt( 1. - x ) * ( -0.16882 * x + 1.56734 ); - return sx > 0. ? a : 3.14159265359 - a; -} - - -vec2 tapLocation(int sampleNumber, float spinAngle,int nb, float nbRot) -{ - float startJitter = (spinAngle/6.28); - float alpha = sqrt(sampleNumber + startJitter/nb ); - float angle = alpha * (nbRot * 6.28) + spinAngle*2.; - - float ssR = alpha; - float sin_v, cos_v; - - sin_v = sin(angle); - cos_v = cos(angle); - - return vec2(cos_v, sin_v)*ssR; -} -uniform int framemod8; -uniform int framecouter; - 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.); - - -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -/* DRAWBUFFERS:2 */ -void main() { - - gl_FragData[0] = texture2D(texture, lmtexcoord.xy)*color; - vec2 tempOffset=offsets[framemod8]; - - if (gl_FragData[0].a>0.1){ - vec3 albedo = toLinear(gl_FragData[0].rgb); - - vec3 normal = normalMat.xyz; - - - vec3 ambient = texture2D(gaux1,(lmtexcoord.zw*15.+0.5)*texelSize).rgb; - - vec3 diffuseLight = ambient; - - - gl_FragData[0].rgb = diffuseLight*albedo*8./1500.*0.1; - } - - - -} +#include "/dimensions/all_translucent.fsh" \ No newline at end of file diff --git a/shaders/world-1/gbuffers_damagedblock.vsh b/shaders/world-1/gbuffers_damagedblock.vsh index 7b641d2..1cf93e3 100644 --- a/shaders/world-1/gbuffers_damagedblock.vsh +++ b/shaders/world-1/gbuffers_damagedblock.vsh @@ -1,54 +1,6 @@ #version 120 -//#extension GL_EXT_gpu_shader4 : disable -#define TAA -/* -!! DO NOT REMOVE !! -This code is from Chocapic13' shaders -Read the terms of modification and sharing before changing something below please ! -!! DO NOT REMOVE !! -*/ +#define DAMAGE_BLOCK_EFFECT +#define NETHER_SHADER -varying vec4 lmtexcoord; -varying vec4 color; -varying vec4 normalMat; -#ifdef MC_NORMAL_MAP -varying vec4 tangent; -attribute vec4 at_tangent; -#endif - -uniform vec2 texelSize; -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.); -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// - -void main() { - lmtexcoord.xy = (gl_MultiTexCoord0).xy; - - vec2 lmcoord = gl_MultiTexCoord1.xy/255.; - lmtexcoord.zw = lmcoord; - - gl_Position = ftransform(); - color = gl_Color; - - - #ifdef MC_NORMAL_MAP - tangent = vec4(normalize(gl_NormalMatrix *at_tangent.rgb),at_tangent.w); - #endif - - normalMat = vec4(normalize(gl_NormalMatrix *gl_Normal),1.0); - #ifdef TAA - gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize; - #endif -} +#include "/dimensions/all_translucent.vsh" \ No newline at end of file diff --git a/shaders/world-1/gbuffers_entities_glowing.fsh b/shaders/world-1/gbuffers_entities_glowing.fsh new file mode 100644 index 0000000..2f75507 --- /dev/null +++ b/shaders/world-1/gbuffers_entities_glowing.fsh @@ -0,0 +1,5 @@ +#version 120 + +#define GLOWING + +#include "/dimensions/all_vanilla_emissives.fsh" \ No newline at end of file diff --git a/shaders/world-1/gbuffers_entities_glowing.vsh b/shaders/world-1/gbuffers_entities_glowing.vsh new file mode 100644 index 0000000..a8a4292 --- /dev/null +++ b/shaders/world-1/gbuffers_entities_glowing.vsh @@ -0,0 +1,5 @@ +#version 120 + +#define GLOWING + +#include "/dimensions/all_vanilla_emissives.vsh" \ No newline at end of file diff --git a/shaders/world-1/gbuffers_hand_water.fsh b/shaders/world-1/gbuffers_hand_water.fsh index 27407c9..f5f3ea6 100644 --- a/shaders/world-1/gbuffers_hand_water.fsh +++ b/shaders/world-1/gbuffers_hand_water.fsh @@ -1,7 +1,6 @@ #version 120 -#define NETHER - +#define HAND #define NETHER_SHADER #include "/dimensions/all_translucent.fsh" \ No newline at end of file diff --git a/shaders/world-1/gbuffers_hand_water.vsh b/shaders/world-1/gbuffers_hand_water.vsh index 1aaf6cc..6bc5096 100644 --- a/shaders/world-1/gbuffers_hand_water.vsh +++ b/shaders/world-1/gbuffers_hand_water.vsh @@ -1,7 +1,6 @@ #version 120 -#define NETHER - +#define HAND #define NETHER_SHADER #include "/dimensions/all_translucent.vsh" \ No newline at end of file diff --git a/shaders/world-1/gbuffers_spidereyes.fsh b/shaders/world-1/gbuffers_spidereyes.fsh index 8255274..538421d 100644 --- a/shaders/world-1/gbuffers_spidereyes.fsh +++ b/shaders/world-1/gbuffers_spidereyes.fsh @@ -1,29 +1,5 @@ #version 120 -#include "/lib/settings.glsl" +#define SPIDER_EYES -varying vec4 lmtexcoord; -varying vec2 texcoord; -varying vec4 color; -uniform sampler2D texture; - -//faster and actually more precise than pow 2.2 -vec3 toLinear(vec3 sRGB){ - return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878); -} - -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -/* DRAWBUFFERS:28 */ - -void main() { - - vec4 Albedo = texture2D(texture, texcoord.xy) * color; - - gl_FragData[0] = vec4(toLinear(Albedo.rgb), Albedo.a); - gl_FragData[1] = vec4(0.0, 0.0, 0.0, 0.5); - -} +#include "/dimensions/all_vanilla_emissives.fsh" \ No newline at end of file diff --git a/shaders/world-1/gbuffers_spidereyes.vsh b/shaders/world-1/gbuffers_spidereyes.vsh index 70f53ae..ad968cc 100644 --- a/shaders/world-1/gbuffers_spidereyes.vsh +++ b/shaders/world-1/gbuffers_spidereyes.vsh @@ -1,43 +1,5 @@ #version 120 -//#extension GL_EXT_gpu_shader4 : disable -#include "/lib/settings.glsl" -#include "/lib/res_params.glsl" +#define SPIDER_EYES -/* -!! DO NOT REMOVE !! -This code is from Chocapic13' shaders -Read the terms of modification and sharing before changing something below please ! -!! DO NOT REMOVE !! -*/ - -varying vec4 color; -varying vec2 texcoord; - -uniform vec2 texelSize; -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.); -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// - -void main() { - - gl_Position = ftransform(); - - texcoord = (gl_MultiTexCoord0).xy; - color = gl_Color; - - #ifdef TAA - gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize; - #endif -} +#include "/dimensions/all_vanilla_emissives.vsh" \ No newline at end of file diff --git a/shaders/world-1/gbuffers_terrain.fsh b/shaders/world-1/gbuffers_terrain.fsh index 620bdc2..6277091 100644 --- a/shaders/world-1/gbuffers_terrain.fsh +++ b/shaders/world-1/gbuffers_terrain.fsh @@ -1,7 +1,6 @@ #version 120 +#define WORLD #define NETHER_SHADER -#define WORLD - #include "/dimensions/all_solid.fsh" \ No newline at end of file diff --git a/shaders/world-1/gbuffers_terrain.vsh b/shaders/world-1/gbuffers_terrain.vsh index ee6cf82..f09d3fe 100644 --- a/shaders/world-1/gbuffers_terrain.vsh +++ b/shaders/world-1/gbuffers_terrain.vsh @@ -1,7 +1,7 @@ #version 120 +#define WORLD #define NETHER_SHADER -#define WORLD #include "/dimensions/all_solid.vsh" \ No newline at end of file diff --git a/shaders/world-1/gbuffers_textured.fsh b/shaders/world-1/gbuffers_textured.fsh index a9b24b2..4c1dc0c 100644 --- a/shaders/world-1/gbuffers_textured.fsh +++ b/shaders/world-1/gbuffers_textured.fsh @@ -1,6 +1,6 @@ #version 120 - +#define PARTICLES #define NETHER_SHADER #include "/dimensions/all_particles.fsh" \ No newline at end of file diff --git a/shaders/world-1/gbuffers_textured.vsh b/shaders/world-1/gbuffers_textured.vsh index d5d05e9..480a2c8 100644 --- a/shaders/world-1/gbuffers_textured.vsh +++ b/shaders/world-1/gbuffers_textured.vsh @@ -1,6 +1,7 @@ #version 120 +#define PARTICLES #define NETHER_SHADER #include "/dimensions/all_particles.vsh" \ No newline at end of file diff --git a/shaders/world-1/gbuffers_textured_lit.fsh b/shaders/world-1/gbuffers_textured_lit.fsh index b86b50a..3256567 100644 --- a/shaders/world-1/gbuffers_textured_lit.fsh +++ b/shaders/world-1/gbuffers_textured_lit.fsh @@ -1,5 +1,7 @@ #version 120 +#define LIT +#define PARTICLES #define NETHER_SHADER -#include "/dimensions/all_particles.fsh" \ No newline at end of file +#include "/dimensions/all_particles.fsh" diff --git a/shaders/world-1/gbuffers_textured_lit.vsh b/shaders/world-1/gbuffers_textured_lit.vsh index e484278..a8f3ebb 100644 --- a/shaders/world-1/gbuffers_textured_lit.vsh +++ b/shaders/world-1/gbuffers_textured_lit.vsh @@ -1,8 +1,7 @@ #version 120 -// #define WEATHER +#define LIT #define PARTICLES - #define NETHER_SHADER #include "/dimensions/all_particles.vsh" \ No newline at end of file diff --git a/shaders/world-1/gbuffers_weather.fsh b/shaders/world-1/gbuffers_weather.fsh index f169e8b..6202ff0 100644 --- a/shaders/world-1/gbuffers_weather.fsh +++ b/shaders/world-1/gbuffers_weather.fsh @@ -1,49 +1,6 @@ #version 120 +#define WEATHER +#define NETHER_SHADER -varying vec4 lmtexcoord; -varying vec4 color; - -uniform sampler2D texture; -uniform sampler2D gaux1; -uniform vec4 lightCol; -uniform vec3 sunVec; - -uniform vec2 texelSize; -uniform float skyIntensityNight; -uniform float skyIntensity; -uniform float rainStrength; - -uniform mat4 gbufferProjectionInverse; - -#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z) -#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz) -vec3 toLinear(vec3 sRGB){ - return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878); -} - - -vec3 toScreenSpaceVector(vec3 p) { - vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw); - vec3 p3 = p * 2. - 1.; - vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3]; - return normalize(fragposition.xyz); -} -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// - -void main() { -/* DRAWBUFFERS:2 */ - gl_FragData[0] = texture2D(texture, lmtexcoord.xy)*color; - gl_FragData[0].a = clamp(gl_FragData[0].a -0.1,0.0,1.0)*0.5; - vec3 albedo = toLinear(gl_FragData[0].rgb*color.rgb); - vec3 ambient = texture2D(gaux1,(lmtexcoord.zw*15.+0.5)*texelSize).rgb; - - gl_FragData[0].rgb = dot(albedo,vec3(1.0))*ambient*10./3.0/150.*0.1; - - - -} +#include "/dimensions/all_particles.fsh" \ No newline at end of file diff --git a/shaders/world-1/gbuffers_weather.vsh b/shaders/world-1/gbuffers_weather.vsh index b7c44aa..4cc6ec6 100644 --- a/shaders/world-1/gbuffers_weather.vsh +++ b/shaders/world-1/gbuffers_weather.vsh @@ -1,44 +1,6 @@ #version 120 -#define TAA -/* -!! DO NOT REMOVE !! -This code is from Chocapic13' shaders -Read the terms of modification and sharing before changing something below please ! -!! DO NOT REMOVE !! -*/ +#define WEATHER +#define NETHER_SHADER -varying vec4 lmtexcoord; -varying vec4 color; - -uniform vec2 texelSize; -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.); -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// - -void main() { - - lmtexcoord.xy = (gl_MultiTexCoord0).xy; - - vec2 lmcoord = gl_MultiTexCoord1.xy/255.; - lmtexcoord.zw = lmcoord*lmcoord; - - - gl_Position = ftransform(); - - color = gl_Color; - #ifdef TAA - gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize; - #endif -} \ No newline at end of file +#include "/dimensions/all_particles.vsh" \ No newline at end of file diff --git a/shaders/world-1/composite.fsh b/shaders/world0/composite.fsh similarity index 67% rename from shaders/world-1/composite.fsh rename to shaders/world0/composite.fsh index 6f2293a..4392112 100644 --- a/shaders/world-1/composite.fsh +++ b/shaders/world0/composite.fsh @@ -1,5 +1,5 @@ #version 120 -#define NETHER_SHADER +#define OVERWORLD_SHADER #include "/dimensions/composite.fsh" \ No newline at end of file diff --git a/shaders/world1/composite.vsh b/shaders/world0/composite.vsh similarity index 67% rename from shaders/world1/composite.vsh rename to shaders/world0/composite.vsh index 032f8fa..481d1c6 100644 --- a/shaders/world1/composite.vsh +++ b/shaders/world0/composite.vsh @@ -1,5 +1,5 @@ #version 120 -#define END_SHADER +#define OVERWORLD_SHADER #include "/dimensions/composite.vsh" \ No newline at end of file diff --git a/shaders/world0/composite1.fsh b/shaders/world0/composite1.fsh new file mode 100644 index 0000000..46e557b --- /dev/null +++ b/shaders/world0/composite1.fsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/composite1.fsh" \ No newline at end of file diff --git a/shaders/world0/composite1.vsh b/shaders/world0/composite1.vsh new file mode 100644 index 0000000..36d76b5 --- /dev/null +++ b/shaders/world0/composite1.vsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/composite1.vsh" \ No newline at end of file diff --git a/shaders/world0/composite10.fsh b/shaders/world0/composite10.fsh new file mode 100644 index 0000000..684023c --- /dev/null +++ b/shaders/world0/composite10.fsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/composite10.fsh" \ No newline at end of file diff --git a/shaders/world0/composite10.vsh b/shaders/world0/composite10.vsh new file mode 100644 index 0000000..497490c --- /dev/null +++ b/shaders/world0/composite10.vsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/composite10.vsh" \ No newline at end of file diff --git a/shaders/world0/composite11.fsh b/shaders/world0/composite11.fsh new file mode 100644 index 0000000..56efeb7 --- /dev/null +++ b/shaders/world0/composite11.fsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/composite11.fsh" \ No newline at end of file diff --git a/shaders/world0/composite11.vsh b/shaders/world0/composite11.vsh new file mode 100644 index 0000000..03e95e7 --- /dev/null +++ b/shaders/world0/composite11.vsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/composite11.vsh" \ No newline at end of file diff --git a/shaders/world0/composite2.fsh b/shaders/world0/composite2.fsh new file mode 100644 index 0000000..df6c56d --- /dev/null +++ b/shaders/world0/composite2.fsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/composite2.fsh" \ No newline at end of file diff --git a/shaders/world0/composite2.vsh b/shaders/world0/composite2.vsh new file mode 100644 index 0000000..a54cc5c --- /dev/null +++ b/shaders/world0/composite2.vsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/composite2.vsh" \ No newline at end of file diff --git a/shaders/world0/composite3.fsh b/shaders/world0/composite3.fsh new file mode 100644 index 0000000..704ae81 --- /dev/null +++ b/shaders/world0/composite3.fsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/composite3.fsh" \ No newline at end of file diff --git a/shaders/world0/composite3.vsh b/shaders/world0/composite3.vsh new file mode 100644 index 0000000..3b5fa07 --- /dev/null +++ b/shaders/world0/composite3.vsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/composite3.vsh" \ No newline at end of file diff --git a/shaders/world0/composite4.fsh b/shaders/world0/composite4.fsh new file mode 100644 index 0000000..16de56b --- /dev/null +++ b/shaders/world0/composite4.fsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/composite4.fsh" \ No newline at end of file diff --git a/shaders/world0/composite4.vsh b/shaders/world0/composite4.vsh new file mode 100644 index 0000000..8fcd849 --- /dev/null +++ b/shaders/world0/composite4.vsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/composite4.vsh" \ No newline at end of file diff --git a/shaders/world0/composite5.fsh b/shaders/world0/composite5.fsh new file mode 100644 index 0000000..48ea36a --- /dev/null +++ b/shaders/world0/composite5.fsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/composite5.fsh" \ No newline at end of file diff --git a/shaders/world0/composite5.vsh b/shaders/world0/composite5.vsh new file mode 100644 index 0000000..719c1ce --- /dev/null +++ b/shaders/world0/composite5.vsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/composite5.vsh" \ No newline at end of file diff --git a/shaders/world0/composite6.fsh b/shaders/world0/composite6.fsh new file mode 100644 index 0000000..b749c02 --- /dev/null +++ b/shaders/world0/composite6.fsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/composite6.fsh" \ No newline at end of file diff --git a/shaders/world0/composite6.vsh b/shaders/world0/composite6.vsh new file mode 100644 index 0000000..8569ecc --- /dev/null +++ b/shaders/world0/composite6.vsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/composite6.vsh" \ No newline at end of file diff --git a/shaders/world0/composite7.fsh b/shaders/world0/composite7.fsh new file mode 100644 index 0000000..5847d03 --- /dev/null +++ b/shaders/world0/composite7.fsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/composite7.fsh" \ No newline at end of file diff --git a/shaders/world0/composite7.vsh b/shaders/world0/composite7.vsh new file mode 100644 index 0000000..d517409 --- /dev/null +++ b/shaders/world0/composite7.vsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/composite7.vsh" \ No newline at end of file diff --git a/shaders/world0/composite8.fsh b/shaders/world0/composite8.fsh new file mode 100644 index 0000000..cab88f9 --- /dev/null +++ b/shaders/world0/composite8.fsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/composite8.fsh" \ No newline at end of file diff --git a/shaders/world0/composite8.vsh b/shaders/world0/composite8.vsh new file mode 100644 index 0000000..cf1f994 --- /dev/null +++ b/shaders/world0/composite8.vsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/composite8.vsh" \ No newline at end of file diff --git a/shaders/world0/composite9.fsh b/shaders/world0/composite9.fsh new file mode 100644 index 0000000..7f12057 --- /dev/null +++ b/shaders/world0/composite9.fsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/composite9.fsh" \ No newline at end of file diff --git a/shaders/world0/composite9.vsh b/shaders/world0/composite9.vsh new file mode 100644 index 0000000..803cf3b --- /dev/null +++ b/shaders/world0/composite9.vsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/composite9.vsh" \ No newline at end of file diff --git a/shaders/world0/deferred.fsh b/shaders/world0/deferred.fsh new file mode 100644 index 0000000..c72bd8a --- /dev/null +++ b/shaders/world0/deferred.fsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/deferred.fsh" \ No newline at end of file diff --git a/shaders/world0/deferred.vsh b/shaders/world0/deferred.vsh new file mode 100644 index 0000000..ef2d3ae --- /dev/null +++ b/shaders/world0/deferred.vsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/deferred.vsh" \ No newline at end of file diff --git a/shaders/world0/deferred1.fsh b/shaders/world0/deferred1.fsh new file mode 100644 index 0000000..4a8b2df --- /dev/null +++ b/shaders/world0/deferred1.fsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/deferred1.fsh" \ No newline at end of file diff --git a/shaders/world0/deferred1.vsh b/shaders/world0/deferred1.vsh new file mode 100644 index 0000000..c120dd3 --- /dev/null +++ b/shaders/world0/deferred1.vsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/deferred1.vsh" \ No newline at end of file diff --git a/shaders/world0/deferred2.fsh b/shaders/world0/deferred2.fsh new file mode 100644 index 0000000..0ccb382 --- /dev/null +++ b/shaders/world0/deferred2.fsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/deferred2.fsh" \ No newline at end of file diff --git a/shaders/world0/deferred2.vsh b/shaders/world0/deferred2.vsh new file mode 100644 index 0000000..53f7634 --- /dev/null +++ b/shaders/world0/deferred2.vsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/deferred2.vsh" \ No newline at end of file diff --git a/shaders/world0/final.fsh b/shaders/world0/final.fsh new file mode 100644 index 0000000..c5f8c4f --- /dev/null +++ b/shaders/world0/final.fsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/final.fsh" \ No newline at end of file diff --git a/shaders/world0/final.vsh b/shaders/world0/final.vsh new file mode 100644 index 0000000..e447a55 --- /dev/null +++ b/shaders/world0/final.vsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/final.vsh" \ No newline at end of file diff --git a/shaders/world0/gbuffers_armor_glint.fsh b/shaders/world0/gbuffers_armor_glint.fsh new file mode 100644 index 0000000..5501d52 --- /dev/null +++ b/shaders/world0/gbuffers_armor_glint.fsh @@ -0,0 +1,5 @@ +#version 120 + +#define ENCHANT_GLINT + +#include "/dimensions/all_vanilla_emissives.fsh" \ No newline at end of file diff --git a/shaders/world0/gbuffers_armor_glint.vsh b/shaders/world0/gbuffers_armor_glint.vsh new file mode 100644 index 0000000..87ad965 --- /dev/null +++ b/shaders/world0/gbuffers_armor_glint.vsh @@ -0,0 +1,5 @@ +#version 120 + +#define ENCHANT_GLINT + +#include "/dimensions/all_vanilla_emissives.vsh" \ No newline at end of file diff --git a/shaders/world0/gbuffers_basic.fsh b/shaders/world0/gbuffers_basic.fsh new file mode 100644 index 0000000..5dc1306 --- /dev/null +++ b/shaders/world0/gbuffers_basic.fsh @@ -0,0 +1,7 @@ +#version 120 + + +#define LINES +#define OVERWORLD_SHADER + +#include "/dimensions/all_particles.fsh" \ No newline at end of file diff --git a/shaders/world0/gbuffers_basic.vsh b/shaders/world0/gbuffers_basic.vsh new file mode 100644 index 0000000..a7735a3 --- /dev/null +++ b/shaders/world0/gbuffers_basic.vsh @@ -0,0 +1,7 @@ +#version 120 + + +#define LINES +#define OVERWORLD_SHADER + +#include "/dimensions/all_particles.vsh" \ No newline at end of file diff --git a/shaders/world0/gbuffers_beaconbeam.fsh b/shaders/world0/gbuffers_beaconbeam.fsh new file mode 100644 index 0000000..3e666de --- /dev/null +++ b/shaders/world0/gbuffers_beaconbeam.fsh @@ -0,0 +1,5 @@ +#version 120 + +#define BEACON_BEAM + +#include "/dimensions/all_vanilla_emissives.fsh" \ No newline at end of file diff --git a/shaders/world0/gbuffers_beaconbeam.vsh b/shaders/world0/gbuffers_beaconbeam.vsh new file mode 100644 index 0000000..f285c00 --- /dev/null +++ b/shaders/world0/gbuffers_beaconbeam.vsh @@ -0,0 +1,5 @@ +#version 120 + +#define BEACON_BEAM + +#include "/dimensions/all_vanilla_emissives.vsh" \ No newline at end of file diff --git a/shaders/world0/gbuffers_block.fsh b/shaders/world0/gbuffers_block.fsh new file mode 100644 index 0000000..348ea12 --- /dev/null +++ b/shaders/world0/gbuffers_block.fsh @@ -0,0 +1,8 @@ +#version 120 + +#define WORLD +#define BLOCKENTITIES + +#define OVERWORLD_SHADER + +#include "/dimensions/all_solid.fsh" \ No newline at end of file diff --git a/shaders/world0/gbuffers_block.vsh b/shaders/world0/gbuffers_block.vsh new file mode 100644 index 0000000..dba7f49 --- /dev/null +++ b/shaders/world0/gbuffers_block.vsh @@ -0,0 +1,8 @@ +#version 120 + +#define WORLD +#define BLOCKENTITIES + +#define OVERWORLD_SHADER + +#include "/dimensions/all_solid.vsh" \ No newline at end of file diff --git a/shaders/world0/gbuffers_damagedblock.fsh b/shaders/world0/gbuffers_damagedblock.fsh new file mode 100644 index 0000000..49c7bb0 --- /dev/null +++ b/shaders/world0/gbuffers_damagedblock.fsh @@ -0,0 +1,6 @@ +#version 120 + +#define OVERWORLD_SHADER +#define DAMAGE_BLOCK_EFFECT + +#include "/dimensions/all_translucent.fsh" \ No newline at end of file diff --git a/shaders/world0/gbuffers_damagedblock.vsh b/shaders/world0/gbuffers_damagedblock.vsh new file mode 100644 index 0000000..f063bd6 --- /dev/null +++ b/shaders/world0/gbuffers_damagedblock.vsh @@ -0,0 +1,6 @@ +#version 120 + +#define OVERWORLD_SHADER +#define DAMAGE_BLOCK_EFFECT + +#include "/dimensions/all_translucent.vsh" \ No newline at end of file diff --git a/shaders/world0/gbuffers_entities.fsh b/shaders/world0/gbuffers_entities.fsh new file mode 100644 index 0000000..5952881 --- /dev/null +++ b/shaders/world0/gbuffers_entities.fsh @@ -0,0 +1,8 @@ +#version 120 + +#define WORLD +#define ENTITIES + +#define OVERWORLD_SHADER + +#include "/dimensions/all_solid.fsh" \ No newline at end of file diff --git a/shaders/world0/gbuffers_entities.vsh b/shaders/world0/gbuffers_entities.vsh new file mode 100644 index 0000000..330a017 --- /dev/null +++ b/shaders/world0/gbuffers_entities.vsh @@ -0,0 +1,9 @@ +#version 120 + + +// #define WORLD +#define ENTITIES + +#define OVERWORLD_SHADER + +#include "/dimensions/all_solid.vsh" \ No newline at end of file diff --git a/shaders/world0/gbuffers_entities_glowing.fsh b/shaders/world0/gbuffers_entities_glowing.fsh new file mode 100644 index 0000000..2f75507 --- /dev/null +++ b/shaders/world0/gbuffers_entities_glowing.fsh @@ -0,0 +1,5 @@ +#version 120 + +#define GLOWING + +#include "/dimensions/all_vanilla_emissives.fsh" \ No newline at end of file diff --git a/shaders/world0/gbuffers_entities_glowing.vsh b/shaders/world0/gbuffers_entities_glowing.vsh new file mode 100644 index 0000000..a8a4292 --- /dev/null +++ b/shaders/world0/gbuffers_entities_glowing.vsh @@ -0,0 +1,5 @@ +#version 120 + +#define GLOWING + +#include "/dimensions/all_vanilla_emissives.vsh" \ No newline at end of file diff --git a/shaders/world0/gbuffers_hand.fsh b/shaders/world0/gbuffers_hand.fsh new file mode 100644 index 0000000..3cfa9af --- /dev/null +++ b/shaders/world0/gbuffers_hand.fsh @@ -0,0 +1,8 @@ +#version 120 + +#define WORLD +#define HAND + +#define OVERWORLD_SHADER + +#include "/dimensions/all_solid.fsh" \ No newline at end of file diff --git a/shaders/world0/gbuffers_hand.vsh b/shaders/world0/gbuffers_hand.vsh new file mode 100644 index 0000000..06b7be5 --- /dev/null +++ b/shaders/world0/gbuffers_hand.vsh @@ -0,0 +1,8 @@ +#version 120 + +#define WORLD +#define HAND + +#define OVERWORLD_SHADER + +#include "/dimensions/all_solid.vsh" \ No newline at end of file diff --git a/shaders/world0/gbuffers_hand_water.fsh b/shaders/world0/gbuffers_hand_water.fsh new file mode 100644 index 0000000..50e69eb --- /dev/null +++ b/shaders/world0/gbuffers_hand_water.fsh @@ -0,0 +1,6 @@ +#version 120 + +#define HAND +#define OVERWORLD_SHADER + +#include "/dimensions/all_translucent.fsh" \ No newline at end of file diff --git a/shaders/world0/gbuffers_hand_water.vsh b/shaders/world0/gbuffers_hand_water.vsh new file mode 100644 index 0000000..e2cb1f3 --- /dev/null +++ b/shaders/world0/gbuffers_hand_water.vsh @@ -0,0 +1,6 @@ +#version 120 + +#define HAND +#define OVERWORLD_SHADER + +#include "/dimensions/all_translucent.vsh" \ No newline at end of file diff --git a/shaders/gbuffers_clouds.fsh b/shaders/world0/gbuffers_skybasic.fsh similarity index 95% rename from shaders/gbuffers_clouds.fsh rename to shaders/world0/gbuffers_skybasic.fsh index 8b76841..9bdb083 100644 --- a/shaders/gbuffers_clouds.fsh +++ b/shaders/world0/gbuffers_skybasic.fsh @@ -2,4 +2,4 @@ void main() { discard; -} \ No newline at end of file +} diff --git a/shaders/world0/gbuffers_skybasic.vsh b/shaders/world0/gbuffers_skybasic.vsh new file mode 100644 index 0000000..0a2f94b --- /dev/null +++ b/shaders/world0/gbuffers_skybasic.vsh @@ -0,0 +1,5 @@ +#version 120 + +void main() { + gl_Position = ftransform(); +} diff --git a/shaders/gbuffers_skytextured.fsh b/shaders/world0/gbuffers_skytextured.fsh similarity index 95% rename from shaders/gbuffers_skytextured.fsh rename to shaders/world0/gbuffers_skytextured.fsh index 8b76841..9bdb083 100644 --- a/shaders/gbuffers_skytextured.fsh +++ b/shaders/world0/gbuffers_skytextured.fsh @@ -2,4 +2,4 @@ void main() { discard; -} \ No newline at end of file +} diff --git a/shaders/world0/gbuffers_skytextured.vsh b/shaders/world0/gbuffers_skytextured.vsh new file mode 100644 index 0000000..0a2f94b --- /dev/null +++ b/shaders/world0/gbuffers_skytextured.vsh @@ -0,0 +1,5 @@ +#version 120 + +void main() { + gl_Position = ftransform(); +} diff --git a/shaders/world0/gbuffers_spidereyes.fsh b/shaders/world0/gbuffers_spidereyes.fsh new file mode 100644 index 0000000..538421d --- /dev/null +++ b/shaders/world0/gbuffers_spidereyes.fsh @@ -0,0 +1,5 @@ +#version 120 + +#define SPIDER_EYES + +#include "/dimensions/all_vanilla_emissives.fsh" \ No newline at end of file diff --git a/shaders/world0/gbuffers_spidereyes.vsh b/shaders/world0/gbuffers_spidereyes.vsh new file mode 100644 index 0000000..ad968cc --- /dev/null +++ b/shaders/world0/gbuffers_spidereyes.vsh @@ -0,0 +1,5 @@ +#version 120 + +#define SPIDER_EYES + +#include "/dimensions/all_vanilla_emissives.vsh" \ No newline at end of file diff --git a/shaders/world0/gbuffers_terrain.fsh b/shaders/world0/gbuffers_terrain.fsh new file mode 100644 index 0000000..c87cd88 --- /dev/null +++ b/shaders/world0/gbuffers_terrain.fsh @@ -0,0 +1,7 @@ +#version 120 + +#define OVERWORLD_SHADER + +#define WORLD + +#include "/dimensions/all_solid.fsh" \ No newline at end of file diff --git a/shaders/world0/gbuffers_terrain.vsh b/shaders/world0/gbuffers_terrain.vsh new file mode 100644 index 0000000..43043a3 --- /dev/null +++ b/shaders/world0/gbuffers_terrain.vsh @@ -0,0 +1,7 @@ +#version 120 + +#define OVERWORLD_SHADER + +#define WORLD + +#include "/dimensions/all_solid.vsh" \ No newline at end of file diff --git a/shaders/world0/gbuffers_textured.fsh b/shaders/world0/gbuffers_textured.fsh new file mode 100644 index 0000000..7b3352f --- /dev/null +++ b/shaders/world0/gbuffers_textured.fsh @@ -0,0 +1,7 @@ +#version 120 + + +#define PARTICLES +#define OVERWORLD_SHADER + +#include "/dimensions/all_particles.fsh" \ No newline at end of file diff --git a/shaders/world0/gbuffers_textured.vsh b/shaders/world0/gbuffers_textured.vsh new file mode 100644 index 0000000..73e3207 --- /dev/null +++ b/shaders/world0/gbuffers_textured.vsh @@ -0,0 +1,7 @@ +#version 120 + + +#define PARTICLES +#define OVERWORLD_SHADER + +#include "/dimensions/all_particles.vsh" \ No newline at end of file diff --git a/shaders/world0/gbuffers_textured_lit.fsh b/shaders/world0/gbuffers_textured_lit.fsh new file mode 100644 index 0000000..f6b24c8 --- /dev/null +++ b/shaders/world0/gbuffers_textured_lit.fsh @@ -0,0 +1,7 @@ +#version 120 + +#define LIT +#define PARTICLES +#define OVERWORLD_SHADER + +#include "/dimensions/all_particles.fsh" \ No newline at end of file diff --git a/shaders/world0/gbuffers_textured_lit.vsh b/shaders/world0/gbuffers_textured_lit.vsh new file mode 100644 index 0000000..785116c --- /dev/null +++ b/shaders/world0/gbuffers_textured_lit.vsh @@ -0,0 +1,7 @@ +#version 120 + +#define LIT +#define PARTICLES +#define OVERWORLD_SHADER + +#include "/dimensions/all_particles.vsh" \ No newline at end of file diff --git a/shaders/world0/gbuffers_water.fsh b/shaders/world0/gbuffers_water.fsh new file mode 100644 index 0000000..a6005b4 --- /dev/null +++ b/shaders/world0/gbuffers_water.fsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/all_translucent.fsh" \ No newline at end of file diff --git a/shaders/world0/gbuffers_water.vsh b/shaders/world0/gbuffers_water.vsh new file mode 100644 index 0000000..afb2f14 --- /dev/null +++ b/shaders/world0/gbuffers_water.vsh @@ -0,0 +1,5 @@ +#version 120 + +#define OVERWORLD_SHADER + +#include "/dimensions/all_translucent.vsh" \ No newline at end of file diff --git a/shaders/world0/gbuffers_weather.fsh b/shaders/world0/gbuffers_weather.fsh new file mode 100644 index 0000000..dabb41b --- /dev/null +++ b/shaders/world0/gbuffers_weather.fsh @@ -0,0 +1,6 @@ +#version 120 + +#define WEATHER +#define OVERWORLD_SHADER + +#include "/dimensions/all_particles.fsh" \ No newline at end of file diff --git a/shaders/world0/gbuffers_weather.vsh b/shaders/world0/gbuffers_weather.vsh new file mode 100644 index 0000000..8e24a6c --- /dev/null +++ b/shaders/world0/gbuffers_weather.vsh @@ -0,0 +1,6 @@ +#version 120 + +#define WEATHER +#define OVERWORLD_SHADER + +#include "/dimensions/all_particles.vsh" \ No newline at end of file diff --git a/shaders/shadow.fsh b/shaders/world0/shadow.fsh similarity index 95% rename from shaders/shadow.fsh rename to shaders/world0/shadow.fsh index 6ab0a6b..6d43fc3 100644 --- a/shaders/shadow.fsh +++ b/shaders/world0/shadow.fsh @@ -1,6 +1,6 @@ #version 120 //#extension GL_ARB_shader_texture_lod : disable -//#extension GL_EXT_gpu_shader4 : disable +#extension GL_EXT_gpu_shader4 : enable #include "/lib/settings.glsl" diff --git a/shaders/shadow.vsh b/shaders/world0/shadow.vsh similarity index 85% rename from shaders/shadow.vsh rename to shaders/world0/shadow.vsh index 93c82bd..0d49ee4 100644 --- a/shaders/shadow.vsh +++ b/shaders/world0/shadow.vsh @@ -1,5 +1,5 @@ #version 120 -//#extension GL_EXT_gpu_shader4 : disable +#extension GL_EXT_gpu_shader4 : enable /* @@ -98,8 +98,17 @@ bool intersectCone(float coneHalfAngle, vec3 coneTip , vec3 coneAxis, vec3 rayOr vec4 toClipSpace3(vec3 viewSpacePosition) { return vec4(projMAD(gl_ProjectionMatrix, viewSpacePosition),1.0); } + + + + + + + + void main() { + vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz; // HHHHHHHHH ITS THE JITTER DOF HERE TO SAY HELLO @@ -138,25 +147,33 @@ void main() { // } // #endif - #ifdef WAVY_PLANTS - bool istopv = gl_MultiTexCoord0.t < mc_midTexCoord.t; - if ((mc_Entity.x == 10001&&istopv) && length(position.xy) < 24.0) { - vec3 worldpos = mat3(shadowModelViewInverse) * position + shadowModelViewInverse[3].xyz; - worldpos.xyz += calcMovePlants(worldpos.xyz + cameraPosition)*gl_MultiTexCoord1.y; - position = mat3(shadowModelView) * worldpos + shadowModelView[3].xyz ; - } + #ifdef WAVY_PLANTS + bool istopv = gl_MultiTexCoord0.t < mc_midTexCoord.t; + if ((mc_Entity.x == 10001&&istopv) && length(position.xy) < 24.0) { + vec3 worldpos = mat3(shadowModelViewInverse) * position + shadowModelViewInverse[3].xyz; + worldpos.xyz += calcMovePlants(worldpos.xyz + cameraPosition)*gl_MultiTexCoord1.y; + position = mat3(shadowModelView) * worldpos + shadowModelView[3].xyz ; + } - if ((mc_Entity.x == 10003) && length(position.xy) < 24.0) { - vec3 worldpos = mat3(shadowModelViewInverse) * position + shadowModelViewInverse[3].xyz; - worldpos.xyz += calcMoveLeaves(worldpos.xyz + cameraPosition, 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))*gl_MultiTexCoord1.y; - position = mat3(shadowModelView) * worldpos + shadowModelView[3].xyz ; - } - #endif + if ((mc_Entity.x == 10003) && length(position.xy) < 24.0) { + vec3 worldpos = mat3(shadowModelViewInverse) * position + shadowModelViewInverse[3].xyz; + worldpos.xyz += calcMoveLeaves(worldpos.xyz + cameraPosition, 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))*gl_MultiTexCoord1.y; + position = mat3(shadowModelView) * worldpos + shadowModelView[3].xyz ; + } + #endif + + + + + // mat4 Custom_ViewMatrix = BuildShadowViewMatrix(LightDir); + // mat4 Custom_ProjectionMatrix = BuildShadowProjectionMatrix(); + + // vec3 position = mat3(Custom_ViewMatrix) * vec3(gl_Vertex) + Custom_ViewMatrix[3].xyz; + // vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz; - // gl_Position = BiasShadowProjection_altered(toClipSpace3(position),mat3(shadowProjection),mat3(shadowModelView), gl_NormalMatrix * gl_Normal); - gl_Position = BiasShadowProjection(toClipSpace3(position)); + texcoord.xy = gl_MultiTexCoord0.xy; if(mc_Entity.x == 8 || mc_Entity.x == 9) gl_Position.w = -1.0; @@ -173,4 +190,7 @@ void main() { } gl_Position.z /= bias; + + + } diff --git a/shaders/world1/composite.fsh b/shaders/world1/composite.fsh deleted file mode 100644 index 598bc16..0000000 --- a/shaders/world1/composite.fsh +++ /dev/null @@ -1,5 +0,0 @@ -#version 120 - -#define END_SHADER - -#include "/dimensions/composite.fsh" \ No newline at end of file diff --git a/shaders/world1/composite10.fsh b/shaders/world1/composite10.fsh new file mode 100644 index 0000000..ee3281f --- /dev/null +++ b/shaders/world1/composite10.fsh @@ -0,0 +1,5 @@ +#version 120 + +#define END_SHADER + +#include "/dimensions/composite10.fsh" \ No newline at end of file diff --git a/shaders/world1/composite10.vsh b/shaders/world1/composite10.vsh new file mode 100644 index 0000000..f2237a9 --- /dev/null +++ b/shaders/world1/composite10.vsh @@ -0,0 +1,5 @@ +#version 120 + +#define END_SHADER + +#include "/dimensions/composite10.vsh" \ No newline at end of file diff --git a/shaders/world1/composite11.fsh b/shaders/world1/composite11.fsh new file mode 100644 index 0000000..cd9deae --- /dev/null +++ b/shaders/world1/composite11.fsh @@ -0,0 +1,5 @@ +#version 120 + +#define END_SHADER + +#include "/dimensions/composite11.fsh" \ No newline at end of file diff --git a/shaders/world1/composite11.vsh b/shaders/world1/composite11.vsh new file mode 100644 index 0000000..6d5a44b --- /dev/null +++ b/shaders/world1/composite11.vsh @@ -0,0 +1,5 @@ +#version 120 + +#define END_SHADER + +#include "/dimensions/composite11.vsh" \ No newline at end of file diff --git a/shaders/world1/gbuffers_armor_glint.fsh b/shaders/world1/gbuffers_armor_glint.fsh index 430bda4..5501d52 100644 --- a/shaders/world1/gbuffers_armor_glint.fsh +++ b/shaders/world1/gbuffers_armor_glint.fsh @@ -1,25 +1,5 @@ #version 120 -#include "/lib/settings.glsl" +#define ENCHANT_GLINT -varying vec4 lmtexcoord; -varying vec4 color; -uniform sampler2D texture; - -//faster and actually more precise than pow 2.2 -vec3 toLinear(vec3 sRGB){ - return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878); -} - -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -/* DRAWBUFFERS:2 */ - -void main() { - - gl_FragData[0] = vec4(toLinear( texture2D(texture, lmtexcoord.xy).rgb * color.rgb), 0.1); - -} +#include "/dimensions/all_vanilla_emissives.fsh" \ No newline at end of file diff --git a/shaders/world1/gbuffers_armor_glint.vsh b/shaders/world1/gbuffers_armor_glint.vsh index acb4c70..87ad965 100644 --- a/shaders/world1/gbuffers_armor_glint.vsh +++ b/shaders/world1/gbuffers_armor_glint.vsh @@ -1,47 +1,5 @@ #version 120 -#include "/lib/settings.glsl" -#include "/lib/res_params.glsl" +#define ENCHANT_GLINT -/* -!! DO NOT REMOVE !! -This code is from Chocapic13' shaders -Read the terms of modification and sharing before changing something below please ! -!! DO NOT REMOVE !! -*/ - -varying vec4 lmtexcoord; -varying vec4 color; - -uniform vec2 texelSize; -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.); - -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// - -void main() { - gl_Position = ftransform(); - - lmtexcoord.xy = (gl_TextureMatrix[0] * gl_MultiTexCoord0).st; - - vec2 lmcoord = gl_MultiTexCoord1.xy/255.; - - lmtexcoord.zw = lmcoord*lmcoord; - - color = gl_Color; - - #ifdef TAA - gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize; - #endif -} +#include "/dimensions/all_vanilla_emissives.vsh" \ No newline at end of file diff --git a/shaders/world1/gbuffers_beaconbeam.fsh b/shaders/world1/gbuffers_beaconbeam.fsh index 6c6a7bf..3e666de 100644 --- a/shaders/world1/gbuffers_beaconbeam.fsh +++ b/shaders/world1/gbuffers_beaconbeam.fsh @@ -1,29 +1,5 @@ #version 120 -#include "/lib/settings.glsl" +#define BEACON_BEAM -varying vec4 lmtexcoord; -varying vec2 texcoord; -varying vec4 color; -uniform sampler2D texture; - -//faster and actually more precise than pow 2.2 -vec3 toLinear(vec3 sRGB){ - return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878); -} - -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -/* DRAWBUFFERS:28 */ - -void main() { - - vec4 Albedo = texture2D(texture, texcoord.xy) * color * 1.5; - - gl_FragData[0] = vec4(toLinear(Albedo.rgb), 1.0); - gl_FragData[1] = vec4(0.0, 0.0, 0.0, 0.5); - -} +#include "/dimensions/all_vanilla_emissives.fsh" \ No newline at end of file diff --git a/shaders/world1/gbuffers_beaconbeam.vsh b/shaders/world1/gbuffers_beaconbeam.vsh index 32726c5..f285c00 100644 --- a/shaders/world1/gbuffers_beaconbeam.vsh +++ b/shaders/world1/gbuffers_beaconbeam.vsh @@ -1,44 +1,5 @@ #version 120 -//#extension GL_EXT_gpu_shader4 : disable -#include "/lib/settings.glsl" -#include "/lib/res_params.glsl" +#define BEACON_BEAM -/* -!! DO NOT REMOVE !! -This code is from Chocapic13' shaders -Read the terms of modification and sharing before changing something below please ! -!! DO NOT REMOVE !! -*/ - -varying vec4 color; -varying vec2 texcoord; - -uniform vec2 texelSize; -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.); -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// - -void main() { - - gl_Position = ftransform(); - if(gl_Color.a < 1.0 ) gl_Position = vec4(10,10,10,1); - - texcoord = (gl_MultiTexCoord0).xy; - color = gl_Color; - - #ifdef TAA - gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize; - #endif -} +#include "/dimensions/all_vanilla_emissives.vsh" \ No newline at end of file diff --git a/shaders/world1/gbuffers_damagedblock.fsh b/shaders/world1/gbuffers_damagedblock.fsh index d51ec5d..117d0f4 100644 --- a/shaders/world1/gbuffers_damagedblock.fsh +++ b/shaders/world1/gbuffers_damagedblock.fsh @@ -1,116 +1,6 @@ #version 120 -//#extension GL_EXT_gpu_shader4 : disable -#define PCF +#define END_SHADER +#define DAMAGE_BLOCK_EFFECT - - - -varying vec4 lmtexcoord; -varying vec4 color; -varying vec4 normalMat; - - -uniform sampler2D texture; -uniform sampler2D gaux1; -uniform vec4 lightCol; -uniform vec3 sunVec; -uniform vec3 upVec; - -uniform vec2 texelSize; -uniform float skyIntensityNight; -uniform float skyIntensity; -uniform float sunElevation; -uniform float rainStrength; -uniform mat4 gbufferProjectionInverse; -uniform mat4 gbufferModelViewInverse; -uniform mat4 shadowModelView; -uniform mat4 shadowProjection; - -//faster and actually more precise than pow 2.2 -vec3 toLinear(vec3 sRGB){ - return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878); -} - -#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z) -#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz) -vec3 toScreenSpace(vec3 p) { - vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x, gbufferProjectionInverse[1].y, gbufferProjectionInverse[2].zw); - vec3 p3 = p * 2. - 1.; - vec4 fragposition = iProjDiag * p3.xyzz + gbufferProjectionInverse[3]; - return fragposition.xyz / fragposition.w; -} -float interleaved_gradientNoise(float temporal){ - vec2 coord = gl_FragCoord.xy; - float noise = fract(52.9829189*fract(0.06711056*coord.x + 0.00583715*coord.y)+temporal); - return noise; -} - -#ifdef PCF -const vec2 shadowOffsets[4] = vec2[4](vec2( 0.1250, 0.0000 ), -vec2( -0.1768, -0.1768 ), -vec2( -0.0000, 0.3750 ), -vec2( 0.3536, -0.3536 ) -); -#endif -float facos(float sx){ - float x = clamp(abs( sx ),0.,1.); - float a = sqrt( 1. - x ) * ( -0.16882 * x + 1.56734 ); - return sx > 0. ? a : 3.14159265359 - a; -} - - -vec2 tapLocation(int sampleNumber, float spinAngle,int nb, float nbRot) -{ - float startJitter = (spinAngle/6.28); - float alpha = sqrt(sampleNumber + startJitter/nb ); - float angle = alpha * (nbRot * 6.28) + spinAngle*2.; - - float ssR = alpha; - float sin_v, cos_v; - - sin_v = sin(angle); - cos_v = cos(angle); - - return vec2(cos_v, sin_v)*ssR; -} -uniform int framemod8; -uniform int framecouter; - 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.); - - -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -/* DRAWBUFFERS:2 */ -void main() { - - gl_FragData[0] = texture2D(texture, lmtexcoord.xy)*color; - vec2 tempOffset=offsets[framemod8]; - - if (gl_FragData[0].a>0.1){ - vec3 albedo = toLinear(gl_FragData[0].rgb); - - vec3 normal = normalMat.xyz; - - - vec3 ambient = texture2D(gaux1,(lmtexcoord.zw*15.+0.5)*texelSize).rgb; - - vec3 diffuseLight = ambient; - - - gl_FragData[0].rgb = diffuseLight*albedo*8./1500.*0.1; - } - - - -} +#include "/dimensions/all_translucent.fsh" \ No newline at end of file diff --git a/shaders/world1/gbuffers_damagedblock.vsh b/shaders/world1/gbuffers_damagedblock.vsh index 7b641d2..5b3e965 100644 --- a/shaders/world1/gbuffers_damagedblock.vsh +++ b/shaders/world1/gbuffers_damagedblock.vsh @@ -1,54 +1,6 @@ #version 120 -//#extension GL_EXT_gpu_shader4 : disable -#define TAA -/* -!! DO NOT REMOVE !! -This code is from Chocapic13' shaders -Read the terms of modification and sharing before changing something below please ! -!! DO NOT REMOVE !! -*/ +#define END_SHADER +#define DAMAGE_BLOCK_EFFECT -varying vec4 lmtexcoord; -varying vec4 color; -varying vec4 normalMat; -#ifdef MC_NORMAL_MAP -varying vec4 tangent; -attribute vec4 at_tangent; -#endif - -uniform vec2 texelSize; -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.); -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// - -void main() { - lmtexcoord.xy = (gl_MultiTexCoord0).xy; - - vec2 lmcoord = gl_MultiTexCoord1.xy/255.; - lmtexcoord.zw = lmcoord; - - gl_Position = ftransform(); - color = gl_Color; - - - #ifdef MC_NORMAL_MAP - tangent = vec4(normalize(gl_NormalMatrix *at_tangent.rgb),at_tangent.w); - #endif - - normalMat = vec4(normalize(gl_NormalMatrix *gl_Normal),1.0); - #ifdef TAA - gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize; - #endif -} +#include "/dimensions/all_translucent.vsh" \ No newline at end of file diff --git a/shaders/world1/gbuffers_entities_glowing.fsh b/shaders/world1/gbuffers_entities_glowing.fsh new file mode 100644 index 0000000..2f75507 --- /dev/null +++ b/shaders/world1/gbuffers_entities_glowing.fsh @@ -0,0 +1,5 @@ +#version 120 + +#define GLOWING + +#include "/dimensions/all_vanilla_emissives.fsh" \ No newline at end of file diff --git a/shaders/world1/gbuffers_entities_glowing.vsh b/shaders/world1/gbuffers_entities_glowing.vsh new file mode 100644 index 0000000..a8a4292 --- /dev/null +++ b/shaders/world1/gbuffers_entities_glowing.vsh @@ -0,0 +1,5 @@ +#version 120 + +#define GLOWING + +#include "/dimensions/all_vanilla_emissives.vsh" \ No newline at end of file diff --git a/shaders/world1/gbuffers_hand_water.fsh b/shaders/world1/gbuffers_hand_water.fsh index 9b0ad76..f0eebaf 100644 --- a/shaders/world1/gbuffers_hand_water.fsh +++ b/shaders/world1/gbuffers_hand_water.fsh @@ -1,5 +1,6 @@ #version 120 +#define HAND #define END_SHADER #include "/dimensions/all_translucent.fsh" \ No newline at end of file diff --git a/shaders/world1/gbuffers_hand_water.vsh b/shaders/world1/gbuffers_hand_water.vsh index 9a4a869..37d503d 100644 --- a/shaders/world1/gbuffers_hand_water.vsh +++ b/shaders/world1/gbuffers_hand_water.vsh @@ -1,5 +1,6 @@ #version 120 +#define HAND #define END_SHADER #include "/dimensions/all_translucent.vsh" \ No newline at end of file diff --git a/shaders/world1/gbuffers_spidereyes.fsh b/shaders/world1/gbuffers_spidereyes.fsh index 8255274..538421d 100644 --- a/shaders/world1/gbuffers_spidereyes.fsh +++ b/shaders/world1/gbuffers_spidereyes.fsh @@ -1,29 +1,5 @@ #version 120 -#include "/lib/settings.glsl" +#define SPIDER_EYES -varying vec4 lmtexcoord; -varying vec2 texcoord; -varying vec4 color; -uniform sampler2D texture; - -//faster and actually more precise than pow 2.2 -vec3 toLinear(vec3 sRGB){ - return sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878); -} - -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -/* DRAWBUFFERS:28 */ - -void main() { - - vec4 Albedo = texture2D(texture, texcoord.xy) * color; - - gl_FragData[0] = vec4(toLinear(Albedo.rgb), Albedo.a); - gl_FragData[1] = vec4(0.0, 0.0, 0.0, 0.5); - -} +#include "/dimensions/all_vanilla_emissives.fsh" \ No newline at end of file diff --git a/shaders/world1/gbuffers_spidereyes.vsh b/shaders/world1/gbuffers_spidereyes.vsh index 70f53ae..ad968cc 100644 --- a/shaders/world1/gbuffers_spidereyes.vsh +++ b/shaders/world1/gbuffers_spidereyes.vsh @@ -1,43 +1,5 @@ #version 120 -//#extension GL_EXT_gpu_shader4 : disable -#include "/lib/settings.glsl" -#include "/lib/res_params.glsl" +#define SPIDER_EYES -/* -!! DO NOT REMOVE !! -This code is from Chocapic13' shaders -Read the terms of modification and sharing before changing something below please ! -!! DO NOT REMOVE !! -*/ - -varying vec4 color; -varying vec2 texcoord; - -uniform vec2 texelSize; -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.); -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// -//////////////////////////////VOID MAIN////////////////////////////// - -void main() { - - gl_Position = ftransform(); - - texcoord = (gl_MultiTexCoord0).xy; - color = gl_Color; - - #ifdef TAA - gl_Position.xy += offsets[framemod8] * gl_Position.w*texelSize; - #endif -} +#include "/dimensions/all_vanilla_emissives.vsh" \ No newline at end of file diff --git a/yarhar.zip b/yarhar.zip new file mode 100644 index 0000000..5d67676 Binary files /dev/null and b/yarhar.zip differ