├── pack_icon.png ├── .docs └── how_to_config.md ├── textures ├── blocks │ ├── magma.png │ ├── gold_ore.png │ ├── iron_ore.png │ ├── copper_ore.png │ ├── diamond_ore.png │ ├── emerald_ore.png │ ├── lapis_ore.png │ ├── quartz_ore.png │ ├── redstone_ore.png │ ├── warped_fungus.png │ ├── amethyst_block.png │ ├── amethyst_cluster.png │ ├── budding_amethyst.png │ ├── crimson_fungus.png │ ├── crying_obsidian.png │ ├── nether_gold_ore.png │ ├── large_amethyst_bud.png │ ├── observer_back_lit.png │ ├── small_amethyst_bud.png │ ├── medium_amethyst_bud.png │ ├── rail_detector_powered.png │ ├── rail_golden_powered.png │ ├── cave_vines_body_berries.png │ ├── cave_vines_head_berries.png │ ├── rail_activator_powered.png │ ├── deepslate │ │ ├── deepslate_gold_ore.png │ │ ├── deepslate_iron_ore.png │ │ ├── deepslate_copper_ore.png │ │ ├── deepslate_diamond_ore.png │ │ ├── deepslate_emerald_ore.png │ │ ├── deepslate_lapis_ore.png │ │ └── deepslate_redstone_ore.png │ └── huge_fungus │ │ ├── crimson_log_side.png │ │ ├── crimson_log_top.png │ │ ├── warped_stem_side.png │ │ └── warped_stem_top.png ├── environment │ ├── sun.png │ ├── clouds.png │ ├── end_sky.png │ ├── weather.png │ ├── moon_phases.png │ └── overworld_cubemap │ │ ├── cubemap_0.png │ │ ├── cubemap_1.png │ │ ├── cubemap_2.png │ │ ├── cubemap_3.png │ │ └── cubemap_5.png └── particle │ └── particles.png ├── .gitattributes ├── shaders └── glsl │ ├── flat_white.fragment │ ├── shadow_stencil_overlay.fragment │ ├── cubemap.fragment │ ├── sun_moon.vertex │ ├── end_sky.vertex │ ├── config_utilities │ ├── extra.h │ ├── color.h │ ├── global.h │ ├── clouds.h │ ├── terrain.h │ └── sky.h │ ├── cubemap.vertex │ ├── utilities │ ├── noise.glsl │ └── detectors.glsl │ ├── sky.fragment │ ├── end_sky.fragment │ ├── sky.vertex │ ├── banner.fragment │ ├── cloud.vertex │ ├── terrain.fragment │ ├── banner.vertex │ ├── entity.fragment │ ├── entity.vertex │ └── terrain.vertex ├── materials ├── sad.material ├── fancy.material ├── sky.material └── terrain.material ├── fogs ├── the_end_fog_setting.json └── default_fog_setting.json ├── manifest.json ├── README.md ├── LICENSE └── biomes_client.json /pack_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/pack_icon.png -------------------------------------------------------------------------------- /.docs/how_to_config.md: -------------------------------------------------------------------------------- 1 | ###See [Customisation](https://devendrn.github.io/newb-shader/customization.html) -------------------------------------------------------------------------------- /textures/blocks/magma.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/magma.png -------------------------------------------------------------------------------- /textures/blocks/gold_ore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/gold_ore.png -------------------------------------------------------------------------------- /textures/blocks/iron_ore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/iron_ore.png -------------------------------------------------------------------------------- /textures/environment/sun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/environment/sun.png -------------------------------------------------------------------------------- /textures/blocks/copper_ore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/copper_ore.png -------------------------------------------------------------------------------- /textures/blocks/diamond_ore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/diamond_ore.png -------------------------------------------------------------------------------- /textures/blocks/emerald_ore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/emerald_ore.png -------------------------------------------------------------------------------- /textures/blocks/lapis_ore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/lapis_ore.png -------------------------------------------------------------------------------- /textures/blocks/quartz_ore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/quartz_ore.png -------------------------------------------------------------------------------- /textures/environment/clouds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/environment/clouds.png -------------------------------------------------------------------------------- /textures/particle/particles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/particle/particles.png -------------------------------------------------------------------------------- /textures/blocks/redstone_ore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/redstone_ore.png -------------------------------------------------------------------------------- /textures/blocks/warped_fungus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/warped_fungus.png -------------------------------------------------------------------------------- /textures/environment/end_sky.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/environment/end_sky.png -------------------------------------------------------------------------------- /textures/environment/weather.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/environment/weather.png -------------------------------------------------------------------------------- /textures/blocks/amethyst_block.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/amethyst_block.png -------------------------------------------------------------------------------- /textures/blocks/amethyst_cluster.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/amethyst_cluster.png -------------------------------------------------------------------------------- /textures/blocks/budding_amethyst.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/budding_amethyst.png -------------------------------------------------------------------------------- /textures/blocks/crimson_fungus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/crimson_fungus.png -------------------------------------------------------------------------------- /textures/blocks/crying_obsidian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/crying_obsidian.png -------------------------------------------------------------------------------- /textures/blocks/nether_gold_ore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/nether_gold_ore.png -------------------------------------------------------------------------------- /textures/environment/moon_phases.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/environment/moon_phases.png -------------------------------------------------------------------------------- /textures/blocks/large_amethyst_bud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/large_amethyst_bud.png -------------------------------------------------------------------------------- /textures/blocks/observer_back_lit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/observer_back_lit.png -------------------------------------------------------------------------------- /textures/blocks/small_amethyst_bud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/small_amethyst_bud.png -------------------------------------------------------------------------------- /textures/blocks/medium_amethyst_bud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/medium_amethyst_bud.png -------------------------------------------------------------------------------- /textures/blocks/rail_detector_powered.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/rail_detector_powered.png -------------------------------------------------------------------------------- /textures/blocks/rail_golden_powered.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/rail_golden_powered.png -------------------------------------------------------------------------------- /textures/blocks/cave_vines_body_berries.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/cave_vines_body_berries.png -------------------------------------------------------------------------------- /textures/blocks/cave_vines_head_berries.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/cave_vines_head_berries.png -------------------------------------------------------------------------------- /textures/blocks/rail_activator_powered.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/rail_activator_powered.png -------------------------------------------------------------------------------- /textures/blocks/deepslate/deepslate_gold_ore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/deepslate/deepslate_gold_ore.png -------------------------------------------------------------------------------- /textures/blocks/deepslate/deepslate_iron_ore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/deepslate/deepslate_iron_ore.png -------------------------------------------------------------------------------- /textures/blocks/huge_fungus/crimson_log_side.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/huge_fungus/crimson_log_side.png -------------------------------------------------------------------------------- /textures/blocks/huge_fungus/crimson_log_top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/huge_fungus/crimson_log_top.png -------------------------------------------------------------------------------- /textures/blocks/huge_fungus/warped_stem_side.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/huge_fungus/warped_stem_side.png -------------------------------------------------------------------------------- /textures/blocks/huge_fungus/warped_stem_top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/huge_fungus/warped_stem_top.png -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.h linguist-detectable=false 2 | 3 | *.h text eol=crlf 4 | *.vertex text eol=crlf 5 | *.fragment text eol=crlf 6 | *.glsl text eol=crlf 7 | -------------------------------------------------------------------------------- /textures/blocks/deepslate/deepslate_copper_ore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/deepslate/deepslate_copper_ore.png -------------------------------------------------------------------------------- /textures/blocks/deepslate/deepslate_diamond_ore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/deepslate/deepslate_diamond_ore.png -------------------------------------------------------------------------------- /textures/blocks/deepslate/deepslate_emerald_ore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/deepslate/deepslate_emerald_ore.png -------------------------------------------------------------------------------- /textures/blocks/deepslate/deepslate_lapis_ore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/deepslate/deepslate_lapis_ore.png -------------------------------------------------------------------------------- /textures/blocks/deepslate/deepslate_redstone_ore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/blocks/deepslate/deepslate_redstone_ore.png -------------------------------------------------------------------------------- /textures/environment/overworld_cubemap/cubemap_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/environment/overworld_cubemap/cubemap_0.png -------------------------------------------------------------------------------- /textures/environment/overworld_cubemap/cubemap_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/environment/overworld_cubemap/cubemap_1.png -------------------------------------------------------------------------------- /textures/environment/overworld_cubemap/cubemap_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/environment/overworld_cubemap/cubemap_2.png -------------------------------------------------------------------------------- /textures/environment/overworld_cubemap/cubemap_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/environment/overworld_cubemap/cubemap_3.png -------------------------------------------------------------------------------- /textures/environment/overworld_cubemap/cubemap_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devendrn/newb-shader-mcbe/HEAD/textures/environment/overworld_cubemap/cubemap_5.png -------------------------------------------------------------------------------- /shaders/glsl/flat_white.fragment: -------------------------------------------------------------------------------- 1 | // __multiversion__ 2 | 3 | #if __VERSION__ >= 300 4 | out vec4 FragColor; 5 | #define gl_FragColor FragColor 6 | #endif 7 | 8 | #include "config_utilities/extra.h" 9 | 10 | void main(){ 11 | // touch circle overlay 12 | gl_FragColor = vec4(vec3(circle_invert_value),1.0); 13 | } 14 | -------------------------------------------------------------------------------- /shaders/glsl/shadow_stencil_overlay.fragment: -------------------------------------------------------------------------------- 1 | // __multiversion__ 2 | 3 | #if __VERSION__ >= 300 4 | #define varying in 5 | out vec4 FragColor; 6 | #define gl_FragColor FragColor 7 | #endif 8 | 9 | uniform vec4 CURRENT_COLOR; 10 | 11 | varying vec4 color; 12 | 13 | void main(){ 14 | gl_FragColor = vec4(mix(color.rgb, CURRENT_COLOR.rgb, color.a*0.8),1.0); 15 | } 16 | -------------------------------------------------------------------------------- /shaders/glsl/cubemap.fragment: -------------------------------------------------------------------------------- 1 | // __multiversion__ 2 | 3 | #if __VERSION__ >= 300 4 | #define varying in 5 | out vec4 FragColor; 6 | #define gl_FragColor FragColor 7 | #endif 8 | 9 | #include "config_utilities/color.h" 10 | 11 | varying vec4 color; 12 | 13 | void main(){ 14 | // this cubemap is used to draw over region which skyplane doesn't occupy 15 | highp vec3 col = colorCorrection(color.rgb); 16 | gl_FragColor = vec4(col,clamp(color.a,0.0,1.0)); 17 | } 18 | -------------------------------------------------------------------------------- /materials/sad.material: -------------------------------------------------------------------------------- 1 | { 2 | "materials": { 3 | "version": "1.0.0", 4 | 5 | "clouds": { 6 | "+states": [ "Blending", "DisableAlphaWrite" ], 7 | "vertexShader": "shaders/cloud.vertex", 8 | "vrGeometryShader": "shaders/cloud.geometry", 9 | "fragmentShader": "shaders/color.fragment", 10 | "vertexFields": [ 11 | { "field": "Position" }, 12 | { "field": "Color" }, 13 | { "field": "UV0" } 14 | ], 15 | "msaaSupport": "Both" 16 | 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /fogs/the_end_fog_setting.json: -------------------------------------------------------------------------------- 1 | /* end uses a custom color to help in detection */ 2 | { 3 | "format_version": "1.16.100", 4 | "minecraft:fog_settings": { 5 | "description": { 6 | "identifier": "newb:fog_the_end" 7 | }, 8 | "distance": { 9 | "air": { 10 | "fog_start": 0.92, 11 | "fog_end": 1.0, 12 | "fog_color": "#400040", 13 | "render_distance_type": "render" 14 | }, 15 | "water": { 16 | "fog_start": 0.0, 17 | "fog_end": 15.0, 18 | "fog_color": "#62529e", 19 | "render_distance_type": "fixed" 20 | } 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /shaders/glsl/sun_moon.vertex: -------------------------------------------------------------------------------- 1 | // __multiversion__ 2 | 3 | #include "vertexVersionCentroidUV.h" 4 | 5 | #include "uniformWorldConstants.h" 6 | 7 | #include "config_utilities/extra.h" 8 | 9 | #ifdef ROTATE_SUNMOON 10 | const float angle = ROTATE_SUNMOON*0.0174533; 11 | const float sinA = sin(angle); 12 | const float cosA = cos(angle); 13 | const mat2 rotate = mat2(cosA,-sinA,sinA,cosA); 14 | #endif 15 | 16 | attribute POS4 POSITION; 17 | attribute vec2 TEXCOORD_0; 18 | 19 | void main(){ 20 | POS4 pos = POSITION; 21 | 22 | #ifdef ROTATE_SUNMOON 23 | pos.xz = rotate*pos.xz; 24 | #endif 25 | 26 | gl_Position = WORLDVIEWPROJ * pos; 27 | uv = TEXCOORD_0; 28 | } 29 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "format_version": 2, 3 | "header": { 4 | "description": " An aesthetic shader for Minecraft!\n \n v1.2.0beta §3https://mcpedl.com/newb-shader/", 5 | "name": "Newb Shader", 6 | "uuid": "95f774cf-4afa-73e7-a21a-72146307b1d2", 7 | "version": [1, 1, 97], 8 | "min_engine_version": [1, 14, 10] 9 | }, 10 | "modules": [ 11 | { 12 | "description": " An aesthetic shader for Minecraft!", 13 | "type": "resources", 14 | "uuid": "900f3d8b-37b4-465f-8f56-941687e36c35", 15 | "version": [1, 1, 97] 16 | } 17 | ], 18 | "metadata": { 19 | "authors": ["devendrn"], 20 | "license": "MIT License", 21 | "url": "https://mcpedl.com/newb-shader/" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /shaders/glsl/end_sky.vertex: -------------------------------------------------------------------------------- 1 | // __multiversion__ 2 | 3 | #include "vertexVersionCentroidUV.h" 4 | 5 | #include "uniformWorldConstants.h" 6 | #include "uniformShaderConstants.h" 7 | 8 | #include "config_utilities/color.h" 9 | 10 | varying vec3 horizon_color; 11 | varying vec3 pos; 12 | 13 | uniform highp float TOTAL_REAL_WORLD_TIME; 14 | 15 | attribute POS4 POSITION; 16 | attribute vec2 TEXCOORD_0; 17 | 18 | void main() 19 | { 20 | pos = -POSITION.xyz; 21 | 22 | vec4 rotatedPos = POSITION; 23 | 24 | // pi/1800 (one complete rotation per hour) 25 | highp float t = 0.00174532925*TOTAL_REAL_WORLD_TIME; 26 | 27 | // rotate skybox 28 | float sinA = sin(t); 29 | float cosA = cos(t); 30 | rotatedPos.xz = mat2(cosA,-sinA,sinA,cosA)*rotatedPos.xz; 31 | 32 | gl_Position = WORLDVIEWPROJ * rotatedPos; 33 | 34 | uv = 0.1*(UV_TRANSFORM * vec4(TEXCOORD_0, 0, 1)).xy; 35 | 36 | horizon_color = colorCorrection(vec3(0.16,0.06,0.2)); 37 | } -------------------------------------------------------------------------------- /shaders/glsl/config_utilities/extra.h: -------------------------------------------------------------------------------- 1 | // Newb Shader 2 | 3 | /*""""""""""""""""""""""""""""""""""""""*/ 4 | /* SUN & MOON */ 5 | 6 | // Toggle + Value - Rotate sun/moon (angle in degrees) 7 | //#define ROTATE_SUNMOON 45.0 8 | 9 | /*""""""""""""""""""""""""""""""""""""""*/ 10 | 11 | 12 | /*""""""""""""""""""""""""""""""""""""""*/ 13 | /* GLOW TEXTURES */ 14 | 15 | // Toggle + Value - Glow textures (brightness) 16 | #define GLOW_TEX 1.7 17 | 18 | /*""""""""""""""""""""""""""""""""""""""*/ 19 | 20 | 21 | /*""""""""""""""""""""""""""""""""""""""*/ 22 | /* GUI TOUCH CIRCLE */ 23 | 24 | // Value - Touch circle visibility 25 | #define circle_invert_value 0.5 26 | 27 | /*""""""""""""""""""""""""""""""""""""""*/ 28 | 29 | 30 | /*""""""""""""""""""""""""""""""""""""""*/ 31 | /* WATER TEXTURE DETAILS */ 32 | 33 | // Value - Vanilla water texture details (0-1) 34 | #define WATER_TEX_OPACITY 0.0 35 | 36 | /*""""""""""""""""""""""""""""""""""""""*/ 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Newb Shader MCPE 2 | 3 | ![Language](https://img.shields.io/badge/GLSL-8A2BE2) 4 | ![Status](https://img.shields.io/badge/status-unmaintained-red) 5 | ![All release downloads](https://img.shields.io/github/downloads/devendrn/newb-shader-mcbe/total) 6 | ![License](https://img.shields.io/github/license/devendrn/newb-shader-mcbe) 7 | ![Code size](https://img.shields.io/github/languages/code-size/devendrn/newb-shader-mcbe) 8 | 9 | Newb Shader is a vanilla styled lightweight Minecraft PE Shader that enhances the default aesthetics 10 | 11 | Only works for MCPE versions **1.18.12 and below** (Android/iOS) 12 | 13 | **For MCPE 1.20+ (Android/Windows), try [Newb X Legacy](https://github.com/devendrn/newb-x-mcbe)** 14 | 15 | #### [Download Newb Shader (MCPE 1.18)](https://github.com/devendrn/newb-shader-mcbe/archive/main.zip) 16 | #### [Customisation](https://devendrn.github.io/newb-shader/customization.html) 17 | #### [MCPEDL Post](https://mcpedl.com/newb-shader/) 18 | #### [Discord Server](https://discord.gg/newbshader) 19 | -------------------------------------------------------------------------------- /shaders/glsl/cubemap.vertex: -------------------------------------------------------------------------------- 1 | // __multiversion__ 2 | 3 | #if __VERSION__ >= 300 4 | #define attribute in 5 | #define varying out 6 | #endif 7 | 8 | #include "uniformWorldConstants.h" 9 | 10 | uniform vec4 FOG_COLOR; 11 | uniform vec2 FOG_CONTROL; 12 | uniform float RENDER_DISTANCE; 13 | 14 | #include "utilities/detectors.glsl" 15 | #include "config_utilities/sky.h" 16 | 17 | attribute POS4 POSITION; 18 | //attribute vec2 TEXCOORD_0; 19 | 20 | varying vec4 color; 21 | 22 | void main(){ 23 | vec4 newPos = POSITION; 24 | newPos.y += 0.6*float(POSITION.y<0.5); // no need to render top half 25 | 26 | // detections 27 | bool underWater = detectUnderwater(); 28 | float rainFactor = detectRain(); 29 | 30 | // horizon color 31 | color.rgb = getHorizonCol(rainFactor); 32 | color.rgb = getHorizonEdgeCol(color.rgb,rainFactor); 33 | if(underWater){ color.rgb = getUnderwaterCol(); } 34 | 35 | color.a = (newPos.y-0.15)*10.0; // will be clamped in fragment shader 36 | 37 | gl_Position = WORLDVIEWPROJ * newPos; 38 | } 39 | -------------------------------------------------------------------------------- /shaders/glsl/utilities/noise.glsl: -------------------------------------------------------------------------------- 1 | // Newb shader 2 | 3 | // noise functions 4 | 5 | // 1D noise - used in plants,lantern wave 6 | highp float noise1D(highp float x){ 7 | float x0 = floor(x); 8 | float t0 = x-x0; 9 | t0 *= t0*(3.0-2.0*t0); 10 | return mix(fract(sin(x0)*84.85),fract(sin(x0+1.0)*84.85),t0); 11 | } 12 | 13 | // hash function for noise (for highp only) 14 | highp float rand(highp vec2 n){ 15 | return fract(sin(dot(n, vec2(12.9898, 4.1414))) * 43758.5453); 16 | } 17 | 18 | // hash function (lowp supported) 19 | //float rand(vec2 n){ 20 | // return fract((sin(n.x+n.y)+sin((n.x-n.y)))*53.968); 21 | //} 22 | 23 | // interpolation of noise - used by rainy air blow 24 | float noise2D(vec2 p){ 25 | vec2 p0 = floor(p); 26 | vec2 u = p-p0; 27 | 28 | u *= u*(3.0-2.0*u); 29 | vec2 v = 1.0 - u; 30 | 31 | float c1 = rand(p0); 32 | float c2 = rand(p0+vec2(1.0,0.0)); 33 | float c3 = rand(p0+vec2(0.0,1.0)); 34 | float c4 = rand(p0+vec2(1.0)); 35 | 36 | float n = v.y*(c1*v.x+c2*u.x) + u.y*(c3*v.x+c4*u.x); 37 | return min(n*n,1.0); 38 | } 39 | -------------------------------------------------------------------------------- /fogs/default_fog_setting.json: -------------------------------------------------------------------------------- 1 | { 2 | "format_version": "1.16.100", 3 | "minecraft:fog_settings": { 4 | "description": { 5 | "identifier": "newb:fog_default" 6 | }, 7 | "distance": { 8 | "air": { 9 | "fog_start": 0.92, 10 | "fog_end": 1.0, 11 | "fog_color": "#ABD2FF", 12 | "render_distance_type": "render" 13 | }, 14 | "water": { 15 | "fog_start": 0, 16 | "fog_end": 60.0, 17 | "fog_color": "#44AFF5", 18 | "render_distance_type": "fixed" 19 | }, 20 | "weather": { 21 | "fog_start": 0.23, 22 | "fog_end": 0.7, 23 | "fog_color": "#666666", 24 | "render_distance_type": "render" 25 | }, 26 | "lava": { 27 | "fog_start": 0.0, 28 | "fog_end": 0.64, 29 | "fog_color": "#991A00", 30 | "render_distance_type": "fixed" 31 | }, 32 | "lava_resistance": { 33 | "fog_start": 0.0, 34 | "fog_end": 6.0, 35 | "fog_color": "#991A00", 36 | "render_distance_type": "fixed" 37 | } 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /shaders/glsl/sky.fragment: -------------------------------------------------------------------------------- 1 | // __multiversion__ 2 | 3 | #if __VERSION__ >= 300 4 | #define varying in 5 | out vec4 FragColor; 6 | #define gl_FragColor FragColor 7 | #endif 8 | 9 | #include "config_utilities/color.h" 10 | 11 | varying vec3 zenith_color; 12 | varying vec3 horizon_color; 13 | varying vec3 horizon_edge_color; 14 | varying vec3 wPos; 15 | 16 | vec3 renderSky(vec3 reddishTint, vec3 horizonColor, vec3 zenithColor, float h){ 17 | h = 1.0-h*h; 18 | float hsq = h*h; 19 | 20 | // gradient 1 h^16 21 | // gradient 2 h^8 mix h^2 22 | float gradient1 = hsq*hsq*hsq*hsq; 23 | float gradient2 = 0.6*gradient1 + 0.4*hsq; 24 | gradient1 *= gradient1; 25 | 26 | horizonColor = mix(horizonColor, reddishTint, gradient1); 27 | return mix(zenithColor,horizonColor, gradient2 ); 28 | } 29 | 30 | void main(){ 31 | //vec3 spherePos = normalize(wPos.xyz); 32 | float sphereY = max(0.0,wPos.y/sqrt(dot(wPos.xyz,wPos.xyz))); 33 | 34 | vec3 skyColor = renderSky(horizon_edge_color,horizon_color,zenith_color,sphereY); 35 | 36 | skyColor = colorCorrection(skyColor); 37 | 38 | gl_FragColor = vec4(skyColor,1.0); 39 | } 40 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 devendrn 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /materials/fancy.material: -------------------------------------------------------------------------------- 1 | { 2 | "materials": { 3 | "version": "1.0.0", 4 | 5 | "clouds": { 6 | "+states": [ "Blending", "DisableAlphaWrite" ], 7 | "vertexShader": "shaders/cloud.vertex", 8 | "vrGeometryShader": "shaders/cloud.geometry", 9 | "fragmentShader": "shaders/color.fragment", 10 | "vertexFields": [ 11 | { "field": "Position" }, 12 | { "field": "Color" }, 13 | { "field": "UV0" } 14 | ], 15 | "msaaSupport": "Both" 16 | }, 17 | 18 | "passthru_postprocess": { 19 | 20 | "states": [ 21 | "DisableDepthTest", 22 | "DisableDepthWrite" 23 | ], 24 | 25 | "msaaSupport": "Both", 26 | 27 | "vertexShader": "shaders/uv.vertex", 28 | "vrGeometryShader": "shaders/uv.geometry", 29 | "fragmentShader": "shaders/passthru.fragment", 30 | "vertexFields": [ 31 | { "field": "Position" }, 32 | { "field": "UV0" } 33 | ], 34 | "samplerStates": [ 35 | { 36 | "samplerIndex": 0, 37 | "textureFilter": "Point" 38 | } 39 | ] 40 | 41 | } 42 | 43 | } 44 | } -------------------------------------------------------------------------------- /shaders/glsl/end_sky.fragment: -------------------------------------------------------------------------------- 1 | // __multiversion__ 2 | 3 | #include "fragmentVersionCentroid.h" 4 | 5 | #if __VERSION__ >= 300 6 | #if defined(TEXEL_AA) && defined(TEXEL_AA_FEATURE) 7 | _centroid in highp vec2 uv; 8 | #else 9 | _centroid in vec2 uv; 10 | #endif 11 | #else 12 | varying vec2 uv; 13 | #endif 14 | 15 | #include "uniformShaderConstants.h" 16 | #include "util.h" 17 | 18 | varying vec3 horizon_color; 19 | varying vec3 pos; 20 | 21 | LAYOUT_BINDING(0) uniform sampler2D TEXTURE_0; 22 | 23 | void main(){ 24 | #if !defined(TEXEL_AA) || !defined(TEXEL_AA_FEATURE) 25 | vec4 diffuse = texture2D( TEXTURE_0, uv ); 26 | #else 27 | vec4 diffuse = texture2D_AA(TEXTURE_0, uv ); 28 | #endif 29 | 30 | float sphereY = pos.y/sqrt(dot(pos.xyz,pos.xyz)); 31 | float grad = 1.0-max(sphereY,0.0); 32 | grad *= grad; 33 | 34 | // end sky gradient 35 | vec3 color = horizon_color*smoothstep(0.0,1.0,grad); 36 | color += diffuse.rgb*(1.0-grad*grad); // stars 37 | 38 | // end void gradient 39 | float glow = max((-sphereY-0.5)*2.0,0.0); 40 | color += horizon_color*glow*glow*glow; 41 | 42 | gl_FragColor = vec4(color,1.0); 43 | } 44 | -------------------------------------------------------------------------------- /shaders/glsl/sky.vertex: -------------------------------------------------------------------------------- 1 | // __multiversion__ 2 | 3 | #if __VERSION__ >= 300 4 | #define attribute in 5 | #define varying out 6 | #endif 7 | 8 | #include "uniformWorldConstants.h" 9 | 10 | uniform vec4 FOG_COLOR; 11 | uniform vec2 FOG_CONTROL; 12 | uniform float RENDER_DISTANCE; 13 | 14 | #include "utilities/detectors.glsl" 15 | #include "config_utilities/sky.h" 16 | 17 | attribute mediump vec4 POSITION; 18 | attribute vec4 COLOR; 19 | 20 | varying vec3 zenith_color; 21 | varying vec3 horizon_color; 22 | varying vec3 horizon_edge_color; 23 | varying vec3 wPos; 24 | 25 | void main(){ 26 | vec4 pos = POSITION; 27 | pos.y -= COLOR.r*COLOR.r*0.4; // make sky curved 28 | 29 | //wPos = (WORLD * pos).xyz; 30 | wPos = pos.xyz; 31 | wPos.y += 0.148; 32 | 33 | // detections 34 | bool underWater = detectUnderwater(); 35 | float rainFactor = detectRain(); 36 | 37 | // sky colors 38 | zenith_color = getZenithCol(rainFactor); 39 | horizon_color = getHorizonCol(rainFactor); 40 | horizon_edge_color = getHorizonEdgeCol(horizon_color,rainFactor); 41 | if(underWater){ 42 | vec3 fogcol = getUnderwaterCol(); 43 | zenith_color = fogcol; 44 | horizon_color = fogcol; 45 | horizon_edge_color = fogcol; 46 | } 47 | 48 | gl_Position = WORLDVIEWPROJ * pos; 49 | } 50 | -------------------------------------------------------------------------------- /shaders/glsl/banner.fragment: -------------------------------------------------------------------------------- 1 | // __multiversion__ 2 | 3 | #include "fragmentVersionCentroid.h" 4 | #include "uniformShaderConstants.h" 5 | #include "config_utilities/color.h" 6 | 7 | #if __VERSION__ >= 300 8 | _centroid varying vec4 uv; 9 | #else 10 | varying vec4 uv; 11 | #endif 12 | 13 | #ifdef ENABLE_FOG 14 | varying vec4 mistColor; 15 | #endif 16 | 17 | #ifdef ENABLE_LIGHT 18 | varying vec3 light; 19 | #endif 20 | 21 | #ifndef DISABLE_TINTING 22 | varying vec4 color; 23 | #endif 24 | 25 | LAYOUT_BINDING(0) uniform sampler2D TEXTURE_0; 26 | 27 | void main(){ 28 | vec4 diffuse = texture2D(TEXTURE_0, uv.xy); 29 | vec4 base = texture2D(TEXTURE_0, uv.zw); 30 | 31 | #ifndef DISABLE_TINTING 32 | base.a = mix(diffuse.r*diffuse.a,diffuse.a,color.a); 33 | base.rgb *= color.rgb; 34 | #endif 35 | 36 | // converting to linear space 37 | base.rgb *= base.rgb; 38 | 39 | #ifdef ENABLE_LIGHT 40 | // apply lighting 41 | base.rgb *= light.rgb; 42 | #endif 43 | 44 | #ifdef ENABLE_FOG 45 | //apply mist and fog 46 | base.rgb = mix(base.rgb,mistColor.rgb,mistColor.a); 47 | #endif 48 | 49 | // color correction 50 | base.rgb = colorCorrection(base.rgb); 51 | 52 | #ifdef UI_ENTITY 53 | base.a *= HUD_OPACITY; 54 | #endif 55 | 56 | gl_FragColor = base; 57 | } 58 | -------------------------------------------------------------------------------- /shaders/glsl/cloud.vertex: -------------------------------------------------------------------------------- 1 | // __multiversion__ 2 | 3 | #include "vertexVersionSimple.h" 4 | 5 | #include "uniformWorldConstants.h" 6 | #include "uniformPerFrameConstants.h" 7 | #include "uniformShaderConstants.h" 8 | 9 | #include "utilities/noise.glsl" 10 | #include "utilities/detectors.glsl" 11 | #include "config_utilities/clouds.h" 12 | 13 | #include "config_utilities/global.h" 14 | 15 | uniform highp float TOTAL_REAL_WORLD_TIME; 16 | 17 | attribute mediump vec4 POSITION; 18 | 19 | varying vec4 color; 20 | 21 | void main(){ 22 | //// smooth clouds 23 | POS4 worldPos = WORLD * POSITION; 24 | 25 | vec4 newPos = POSITION; 26 | newPos.y *= 0.1; 27 | float len = length(worldPos.xz)*0.004; 28 | newPos.y -= len*len*clamp(0.2*worldPos.y,-1.0,1.0); // curve the cloud plane 29 | 30 | POS4 pos = WORLDVIEWPROJ * newPos; 31 | 32 | highp float t = TOTAL_REAL_WORLD_TIME; 33 | #ifdef TIME_FLIPPING 34 | // remap 0-3600s to 0-1800-0s 35 | t = 1800.0 - abs(t-1800.0); 36 | #endif 37 | 38 | float rain = detectRain(); 39 | 40 | color = vec4(CURRENT_COLOR.rgb,1.0); 41 | color = renderClouds(color, worldPos.xz*cloud_size, t, rain); 42 | color.rgb = mix(color.rgb,vec3(color.g*FOG_COLOR.g*3.5),rain*0.8); 43 | 44 | // displace cloud vertex 45 | pos.y += color.a*cloud_depth*(10.0-7.0*rain); 46 | 47 | color.a *= cloud_alpha; 48 | 49 | #ifdef AURORA 50 | vec4 auroras = renderAurora(0.05*worldPos.xz,t,rain); 51 | auroras *= max(1.0-(1.7*color.a),0.0); 52 | auroras *= 1.0-min(4.5*max(FOG_COLOR.r,FOG_COLOR.b),1.0); 53 | auroras.rgb *= AURORA; 54 | color += auroras; 55 | #endif 56 | 57 | color.a *= clamp(2.0-2.0*length(worldPos.xyz)*0.002,0.0,1.0); 58 | 59 | gl_Position = pos; 60 | } 61 | -------------------------------------------------------------------------------- /shaders/glsl/utilities/detectors.glsl: -------------------------------------------------------------------------------- 1 | // Newb shader 2 | 3 | // uniforms FOG_COLOR, FOG_CONTROL are used 4 | 5 | bool detectEnd(){ 6 | // end is given a custom fog color in biomes_client.json to help in detection 7 | // dark color (issue- rain transition when entering end) 8 | return FOG_COLOR.r==FOG_COLOR.b && FOG_COLOR.r > 0.1 && FOG_COLOR.g < FOG_COLOR.r*0.4; 9 | } 10 | 11 | bool detectNether(){ 12 | // FOG_CONTROL x and y varies with renderdistance 13 | // x range (0.03,0.14) 14 | 15 | // reverse plotted relation (5,6,7,8,9,11,12,20,96 chunks data) with an accuracy of 0.02 16 | float expectedFogX = 0.029 + (0.09*FOG_CONTROL.y*FOG_CONTROL.y); // accuracy of 0.015 17 | 18 | // nether wastes, basalt delta, crimson forest, wrapped forest, soul sand valley 19 | bool netherFogCtrl = (FOG_CONTROL.x<0.14 && abs(FOG_CONTROL.x-expectedFogX) < 0.02); 20 | bool netherFogCol = (FOG_COLOR.r+FOG_COLOR.g)>0.0; 21 | 22 | // consider underlava as nether 23 | bool underLava = FOG_CONTROL.x==0.0 && FOG_COLOR.b==0.0 && FOG_COLOR.g<0.18 && FOG_COLOR.r-FOG_COLOR.g>0.1; 24 | 25 | return (netherFogCtrl && netherFogCol) || underLava; 26 | } 27 | 28 | bool detectUnderwater(){ 29 | return FOG_CONTROL.x<0.001 && max(FOG_COLOR.b,FOG_COLOR.g)>FOG_COLOR.r; 30 | } 31 | 32 | 33 | float detectRain(){ 34 | // FOG_CONTROL values when clear/rain 35 | // clear FOG_CONTROL.x varies with RENDER_DISTANCE 36 | // reverse plotted (low accuracy) as 0.5 + 1.09/(k-0.8) where k is renderdistance in chunks 37 | // remaining values are equal to those specified in json file 38 | vec2 start = vec2(0.5 + (1.09/((RENDER_DISTANCE*0.0625)-0.8)),0.99); 39 | const vec2 end = vec2(0.2305,0.7005); 40 | 41 | vec2 factor = clamp((start-FOG_CONTROL)/(start-end),vec2(0.0),vec2(1.0)); 42 | 43 | // ease in ease out 44 | factor.y = factor.y*factor.y*(3.0 - 2.0*factor.y); 45 | 46 | return factor.x*factor.y; 47 | } 48 | 49 | 50 | -------------------------------------------------------------------------------- /shaders/glsl/config_utilities/color.h: -------------------------------------------------------------------------------- 1 | // Newb shader 2 | 3 | /*""""""""""""""""""""""""""""""""""""""*/ 4 | /* COLOR CORRECTION */ 5 | 6 | 7 | // Type - Tone mapping type 8 | // 1 - Exponential 9 | // 2 - Simple Reinhard 10 | // 3 - Extended Reinhard (Default) 11 | // 4 - ACES 12 | #define TONEMAPPING_TYPE 3 13 | 14 | // Toggle + Value - Exposure 15 | //#define EXPOSURE 1.3 16 | 17 | // Value - Contrast 18 | #define CONTRAST 0.74 19 | 20 | // Toggle + Value - Saturation 21 | //#define SATURATION 1.4 22 | 23 | // Toggle + Color - Tinting 24 | //#define TINT vec3(1.0,0.75,0.5) 25 | 26 | 27 | /*""""""""""""""""""""""""""""""""""""""*/ 28 | 29 | 30 | // Code starts here - Users shouldn't mess down here 31 | // Color correction and tone mapping 32 | 33 | // see https://64.github.io/tonemapping/ 34 | 35 | #if TONEMAPPING_TYPE==3 36 | // extended reinhard tonemapping 37 | vec3 tonemap(vec3 x){ 38 | //float white = 4.0; 39 | //float white_scale = 1.0/(white*white); 40 | float white_scale = 0.063; 41 | 42 | x = (x*(1.0+(x*white_scale)))/(1.0+x); 43 | 44 | //x = (x*1.32)/(1.0+x); 45 | 46 | return x; 47 | } 48 | 49 | #elif TONEMAPPING_TYPE==4 50 | // aces tone mapping 51 | vec3 tonemap(vec3 x){ 52 | x *= 0.85; 53 | const float a = 1.04; 54 | const float b = 0.03; 55 | const float c = 0.93; 56 | const float d = 0.56; 57 | const float e = 0.14; 58 | return clamp((x * (a * x + b)) / (x * (c * x + d) + e), 0.0, 1.0); 59 | } 60 | 61 | #elif TONEMAPPING_TYPE==2 62 | // simple reinhard tonemapping 63 | vec3 tonemap(vec3 x){ 64 | return x/(1.0 + x); 65 | } 66 | 67 | #elif TONEMAPPING_TYPE==1 68 | // exponential tonemapping 69 | vec3 tonemap(vec3 x){ 70 | return 1.0-exp(-x*0.8); 71 | } 72 | 73 | #endif 74 | 75 | vec3 colorCorrection(vec3 color){ 76 | #ifdef EXPOSURE 77 | color *= EXPOSURE; 78 | #endif 79 | 80 | color = tonemap(color); 81 | 82 | // actually supposed to be gamma correction 83 | color = pow(color, vec3(CONTRAST)); 84 | 85 | #ifdef SATURATION 86 | color = mix(vec3(dot(color,vec3(0.21, 0.71, 0.08))), color, SATURATION); 87 | #endif 88 | 89 | #ifdef TINT 90 | color *= TINT; 91 | #endif 92 | 93 | return color; 94 | } 95 | 96 | -------------------------------------------------------------------------------- /shaders/glsl/config_utilities/global.h: -------------------------------------------------------------------------------- 1 | // Newb Shader 2 | 3 | /*""""""""""""""""""""""""""""""""""""""*/ 4 | /* TIME */ 5 | 6 | // Toggle - Flip time after 1800 seconds 7 | // Disable this if you have static wave bug 8 | #define TIME_FLIPPING 9 | 10 | /*""""""""""""""""""""""""""""""""""""""*/ 11 | 12 | 13 | /*""""""""""""""""""""""""""""""""""""""*/ 14 | /* LIGHTING */ 15 | 16 | // Value - Sunlight brightness 17 | #define sun_intensity 2.95 18 | 19 | /*""""""""""""""""""""""""""""""""""""""*/ 20 | 21 | 22 | /*""""""""""""""""""""""""""""""""""""""*/ 23 | /* FOG & MIST */ 24 | 25 | // Type - Fog type 26 | // 0 - Off 27 | // 1 - Vanilla fog 28 | // 2 - Smoother vanilla fog (Default) 29 | #define FOG_TYPE 2 30 | 31 | // Value - Density of mist 32 | #define mist_density 0.18 33 | 34 | /*""""""""""""""""""""""""""""""""""""""*/ 35 | 36 | 37 | 38 | // Code starts here - Users shouldn't mess down here 39 | 40 | // mist & fog 41 | 42 | vec4 renderMist(vec3 fog, float dist, float lit, float rain, bool nether, bool underwater, bool end){ 43 | 44 | float density = mist_density; 45 | if(!(nether||end)){ 46 | // increase density based on darkness 47 | density += density*(0.99-FOG_COLOR.g)*18.0; 48 | } 49 | 50 | vec4 mist; 51 | if(nether){ 52 | mist.rgb = FOG_COLOR.rgb; 53 | mist.rgb = mix(2.6*mist.rgb*mist.rgb,vec3(2.1,0.7,0.2),lit*0.7); 54 | } 55 | else{ 56 | mist.rgb = fog*vec3(1.0,1.1-0.1*rain,1.4-0.4*rain); 57 | } 58 | 59 | // exponential mist 60 | mist.a = 0.31-0.3*exp(-dist*dist*density); 61 | 62 | if(underwater){ 63 | mist.rgb = fog; 64 | mist.a = 0.2+0.5*min(dist*dist,1.0); 65 | } 66 | 67 | return mist; 68 | } 69 | 70 | vec4 renderFog(vec3 fogColor, float len, bool nether){ 71 | 72 | #if FOG_TYPE > 0 73 | 74 | vec4 fog; 75 | if(nether){ 76 | // inverse color correction 77 | fog.rgb = FOG_COLOR.rgb; 78 | fog.rgb = pow(fog.rgb,vec3(1.37)); 79 | vec3 w = vec3(0.7966); 80 | fog.rgb = fog.rgb*(w + fog.rgb)/(w + fog.rgb*(vec3(1.0) - w)); 81 | } 82 | else{ fog.rgb = fogColor; } 83 | 84 | fog.a = clamp( (len - FOG_CONTROL.x)/(FOG_CONTROL.y - FOG_CONTROL.x), 0.0, 1.0); 85 | 86 | #if FOG_TYPE > 1 87 | fog.a = (fog.a*fog.a)*(3.0-2.0*fog.a); 88 | #endif 89 | 90 | return fog; 91 | 92 | #else 93 | return vec4(0.0); 94 | #endif 95 | 96 | 97 | } 98 | 99 | 100 | -------------------------------------------------------------------------------- /materials/sky.material: -------------------------------------------------------------------------------- 1 | { 2 | "sun_moon": { 3 | "states": [ 4 | "DisableDepthWrite", 5 | "DisableAlphaWrite", 6 | "Blending" 7 | ], 8 | 9 | "blendSrc": "SourceAlpha", 10 | "blendDst": "One", 11 | 12 | "vertexShader" : "shaders/sun_moon.vertex", 13 | "vrGeometryShader": "shaders/uv.geometry", 14 | "fragmentShader" : "shaders/texture_ccolor.fragment", 15 | "vertexFields": [ 16 | { "field": "Position" }, 17 | { "field": "UV0" } 18 | ], 19 | 20 | "samplerStates": [ 21 | { 22 | "samplerIndex": 0, 23 | "textureFilter": "Point" 24 | } 25 | ], 26 | 27 | "msaaSupport": "Both" 28 | }, 29 | 30 | "stars": { 31 | "states": [ 32 | "DisableDepthWrite", 33 | "DisableAlphaWrite", 34 | "Blending" 35 | ], 36 | 37 | "blendSrc": "OneMinusDestColor", 38 | "blendDst": "One", 39 | 40 | "vertexShader" : "shaders/color.vertex", 41 | "vrGeometryShader" : "shaders/color.geometry", 42 | "fragmentShader" : "shaders/stars.fragment", 43 | "vertexFields": [ 44 | { "field": "Position" }, 45 | { "field": "Color" } 46 | ], 47 | 48 | "samplerStates": [ 49 | { 50 | "samplerIndex": 0, 51 | "textureFilter": "Point" 52 | } 53 | ], 54 | 55 | "msaaSupport": "Both" 56 | }, 57 | 58 | "cubemap": { 59 | "states": [ 60 | "DisableDepthWrite", 61 | "DisableAlphaWrite", 62 | "Blending" 63 | ], 64 | 65 | "vertexShader": "shaders/cubemap.vertex", 66 | "vrGeometryShader": "shaders/uv.geometry", 67 | "fragmentShader": "shaders/cubemap.fragment", 68 | "samplerStates": [ 69 | { 70 | "samplerIndex": 0, 71 | "textureFilter": "Point" 72 | } 73 | ], 74 | "vertexFields": [ 75 | { "field": "Position" }, 76 | { "field": "UV0" } 77 | ], 78 | 79 | "msaaSupport": "Both" 80 | 81 | }, 82 | 83 | "skyplane": { 84 | "states": [ "DisableDepthWrite", "DisableAlphaWrite" ], 85 | 86 | "vertexShader" : "shaders/sky.vertex", 87 | "vrGeometryShader" : "shaders/sky.geometry", 88 | "fragmentShader" : "shaders/sky.fragment", 89 | "vertexFields": [ 90 | { "field": "Position" }, 91 | { "field": "Color" } 92 | ], 93 | "msaaSupport": "Both" 94 | }, 95 | 96 | "end_sky": { 97 | "states":[ "DisableDepthWrite", "DisableAlphaWrite" ], 98 | 99 | "msaaSupport": "Both", 100 | 101 | "vertexShader" : "shaders/end_sky.vertex" , 102 | "vrGeometryShader": "shaders/uv.geometry", 103 | "fragmentShader" : "shaders/end_sky.fragment", 104 | 105 | "vertexFields": [ 106 | { "field": "Position" }, 107 | { "field": "Color" }, 108 | { "field": "UV0" } 109 | ], 110 | 111 | "samplerStates": [ 112 | { "samplerIndex": 0, "textureWrap": "Repeat" } 113 | ] 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /shaders/glsl/config_utilities/clouds.h: -------------------------------------------------------------------------------- 1 | // Newb shader 2 | 3 | /*""""""""""""""""""""""""""""""""""""""*/ 4 | /* SMOOTH CLOUDS */ 5 | 6 | // Value - Cloud size when raining (0-1) 7 | #define rain_cloud_size 0.9 8 | 9 | // Value - Normal cloud size (0-1) 10 | #define normal_cloud_size 0.27 11 | 12 | // Value - Cloud map size (0-100) 13 | #define cloud_noise_size 36.0 14 | 15 | // Value - Cloud depth (0-3) 16 | #define cloud_depth 1.3 17 | 18 | // Value - Cloud movement speed 19 | #define cloud_speed 0.04 20 | 21 | // Value - Cloud shadow intensity (0-1) 22 | #define cloud_shadow 0.54 23 | 24 | // Value - Cloud transparency (0-1) 25 | #define cloud_alpha 0.8 26 | 27 | /*""""""""""""""""""""""""""""""""""""""*/ 28 | 29 | 30 | /*""""""""""""""""""""""""""""""""""""""*/ 31 | /* AURORA EFFECT */ 32 | 33 | //️ Toggle - Enable aurora effect for night sky 34 | //️ Value - Aurora borealis brightness 35 | #define AURORA 1.0 36 | 37 | /*""""""""""""""""""""""""""""""""""""""*/ 38 | 39 | 40 | 41 | // Code starts here - Users shouldn't mess down here 42 | // Clouds noise 43 | 44 | const vec2 cloud_size = vec2(0.7,1.0)/cloud_noise_size; 45 | 46 | const float start_rain = 1.0-rain_cloud_size; 47 | const float start_normal = 1.0-normal_cloud_size; 48 | 49 | // clamp rand for cloud noise 50 | highp float rand01(highp vec2 seed,float start){ 51 | float result = rand(seed); 52 | result = clamp((result-start)*3.4,0.0,1.0); 53 | return result*result; 54 | } 55 | 56 | // 2D cloud noise - used by clouds 57 | float cloudNoise2D(vec2 p, highp float t, float rain){ 58 | 59 | t *= cloud_speed; 60 | 61 | // start threshold - for bigger clouds during rain 62 | float start = start_normal + (normal_cloud_size)*(0.1+0.1*sin(t + p.y*0.3)); 63 | start = mix(start,start_rain,rain); 64 | 65 | p += vec2(t); 66 | p.x += sin(p.y*0.4 + t); 67 | 68 | vec2 p0 = floor(p); 69 | vec2 u = p-p0; 70 | 71 | u *= u*(3.0-2.0*u); 72 | vec2 v = 1.0-u; 73 | 74 | float c1 = rand01(p0,start); 75 | float c2 = rand01(p0+vec2(1.0,0.0),start); 76 | float c3 = rand01(p0+vec2(0.0,1.0),start); 77 | float c4 = rand01(p0+vec2(1.0),start); 78 | 79 | return v.y*(c1*v.x+c2*u.x) + u.y*(c3*v.x+c4*u.x); 80 | } 81 | 82 | // simple cloud 83 | vec4 renderClouds(vec4 color, vec2 uv, highp float t, float rain){ 84 | 85 | float cloudAlpha = cloudNoise2D(uv,t,rain); 86 | float cloudShadow = cloudNoise2D(uv,(t+0.16),rain)*0.2; 87 | 88 | cloudAlpha = max(cloudAlpha-cloudShadow,0.0); 89 | 90 | // rainy clouds color 91 | color.rgb = mix(color.rgb,vec3(0.7),rain*0.5); 92 | 93 | // highlight at edge 94 | color.rgb += vec3(0.6,0.6,1.0)*(0.2-cloudShadow); 95 | 96 | // cloud shadow 97 | color.rgb *= (1.0-cloudShadow*3.0*cloud_shadow); 98 | 99 | return vec4(color.rgb,cloudAlpha); 100 | } 101 | 102 | // simple northern night sky effect 103 | vec4 renderAurora(vec2 uv, highp float t, float rain){ 104 | float auroraCurves = sin(uv.x*0.09 + 0.07*t) + 0.3*sin(uv.x*0.5 + 0.09*t) + 0.03*sin((uv.x+uv.y)*3.0 + 0.2*t); 105 | float auroraBase = uv.y*0.4 + 2.0*auroraCurves; 106 | float auroraFlow = 0.5+0.5*sin(uv.x*0.3 + 0.07*t + 0.7*sin(auroraBase*0.9) ); 107 | 108 | float auroraCol = sin(uv.y*0.06 + 0.07*t); 109 | auroraCol = abs(auroraCol*auroraCol*auroraCol); 110 | 111 | float aurora = sin(auroraBase)*sin(auroraBase*0.3); 112 | aurora = abs(aurora*auroraFlow); 113 | 114 | return vec4( 115 | 0.0, 116 | (1.0-auroraCol)*aurora, 117 | auroraCol*aurora, 118 | aurora*aurora*(0.5-0.5*rain) ); 119 | } 120 | -------------------------------------------------------------------------------- /shaders/glsl/config_utilities/terrain.h: -------------------------------------------------------------------------------- 1 | // Newb Shader 2 | 3 | /*""""""""""""""""""""""""""""""""""""""*/ 4 | /* TERRAIN LIGHTING */ 5 | 6 | // Toggle - Flickering torch light 7 | //#define BLINKING_TORCH 8 | 9 | // Value - Change to 0.87 to fix slab bug (makes shadow smaller) 10 | #define shadow_edge 0.876 11 | 12 | // Value - Intensity of soft shadow (0-1) 13 | #define shadow_intensity 0.7 14 | 15 | // Value - Night extra brightness 16 | #define night_brightness 0.1 17 | 18 | // Value - Cave extra brightness 19 | #define cave_brightness 0.1 20 | 21 | // Value - Torch brightness 22 | #define torch_intensity 1.0 23 | 24 | // Color - Top light color (Sunlight color) 25 | const vec3 morning_color = vec3(1.0,0.45,0.14); 26 | const vec3 noon_color = vec3(1.0,0.75,0.57); 27 | const vec3 night_color = vec3(0.5,0.64,1.0); 28 | 29 | // Color - Torch light color 30 | const vec3 overworld_torch = vec3(1.0,0.52,0.18); 31 | const vec3 underwater_torch = vec3(1.0,0.52,0.18); 32 | const vec3 nether_torch = vec3(1.0,0.52,0.18); 33 | const vec3 end_torch = vec3(1.0,0.52,0.18); 34 | 35 | 36 | /*""""""""""""""""""""""""""""""""""""""*/ 37 | 38 | 39 | /*""""""""""""""""""""""""""""""""""""""*/ 40 | /* WAVE */ 41 | 42 | // Toggle - Plants Wave (leaves/plants) 43 | // Value - Wave animation intensity (Plants) 44 | #define PLANTS_WAVE 0.04 45 | 46 | // Toggle - Lantern swing 47 | // Value - Lantern swing intensity (0-0.6) 48 | #define LANTERN_WAVE 0.16 49 | 50 | // Toggle - Non-transparent leaves wave (might cause white lines at edges) 51 | //#define ALL_LEAVES_WAVE 52 | 53 | // Toggle - Extra plants Wave for 1.18 (won't work with add-ons which add new blocks) 54 | //#define EXTRA_PLANTS_WAVE 55 | 56 | // Value - Wave animation speed (Plants,leaves) 57 | #define wave_speed 2.8 58 | 59 | // Value - Rainy wind blow transparency (0-0.3) 60 | #define rain_blow_opacity 0.19 61 | 62 | /*""""""""""""""""""""""""""""""""""""""*/ 63 | 64 | 65 | /*""""""""""""""""""""""""""""""""""""""*/ 66 | /* WATER */ 67 | 68 | // Toggle - Water wave 69 | // Value - Wave intensity of water surface 70 | #define WATER_WAVE 0.02 71 | 72 | // Toggle - Cloud reflection on water 73 | #define CLOUD_REFLECTION 74 | 75 | // Toggle - Use only surface angle for water transparency fade (gives more transparency) 76 | //#define USE_ANGLE_BLEND_FADE 77 | 78 | // Value - Water transparency (0-1) 79 | #define water_transparency 0.47 80 | 81 | // Value - Water noise bump height (0-0.2) 82 | #define water_bump 0.07 83 | 84 | // Color - Water color 85 | const vec3 sea_water_color = vec3(0.13,0.65,0.87); 86 | const vec3 fresh_water_color = vec3(0.07,0.55,0.55); 87 | const vec3 marshy_water_color = vec3(0.27,0.4,0.1); 88 | 89 | /*""""""""""""""""""""""""""""""""""""""*/ 90 | 91 | 92 | /*""""""""""""""""""""""""""""""""""""""*/ 93 | /* UNDERWATER */ 94 | 95 | // Toggle - Underwater Wave 96 | // Value - Wave intensity 97 | #define UNDERWATER_WAVE 0.06 98 | 99 | // Value - Underwater brightness 100 | #define underwater_brightness 0.8 101 | 102 | // Value - Underwater soft caustic intensity 103 | #define caustic_intensity 2.5 104 | 105 | // Color - Underwater lighting color 106 | const vec3 underwater_color = vec3(0.2,0.6,1.0); 107 | 108 | /*""""""""""""""""""""""""""""""""""""""*/ 109 | 110 | 111 | /*""""""""""""""""""""""""""""""""""""""*/ 112 | /* VOXEL SHADOW SCRIPT SUPPORT */ 113 | 114 | // For removing old mcpe shadows 115 | // This method of removal has issues with nearby torch lights 116 | 117 | // Toggle - Remove old shadow in all cases 118 | //#define REMOVE_OLD_SHADOW 119 | 120 | /*""""""""""""""""""""""""""""""""""""""*/ 121 | 122 | -------------------------------------------------------------------------------- /shaders/glsl/terrain.fragment: -------------------------------------------------------------------------------- 1 | // __multiversion__ 2 | 3 | #include "fragmentVersionCentroid.h" 4 | 5 | #ifndef BYPASS_PIXEL_SHADER 6 | #if __VERSION__ >= 300 7 | #if defined(TEXEL_AA) && defined(TEXEL_AA_FEATURE) 8 | _centroid in highp vec2 uv0; 9 | _centroid in highp vec2 uv1; 10 | #else 11 | _centroid in vec2 uv0; 12 | _centroid in vec2 uv1; 13 | #endif 14 | #else 15 | varying vec2 uv0; 16 | varying vec2 uv1; 17 | #endif 18 | 19 | varying vec4 color; 20 | varying vec4 mistColor; 21 | 22 | varying lowp float shade; 23 | 24 | #ifdef SEASONS 25 | varying vec3 sCol; 26 | #endif 27 | 28 | #ifdef FOG 29 | varying float wPosY; 30 | varying lowp vec4 wetRefl; 31 | #endif 32 | 33 | #if defined(BLEND) || defined(FAR_BLEND) 34 | #define MAYBE_WATER 35 | varying lowp float water; 36 | #endif 37 | #endif // !BYPASS_PIXEL_SHADER 38 | 39 | #include "uniformShaderConstants.h" 40 | #include "util.h" 41 | 42 | #include "config_utilities/color.h" 43 | #include "config_utilities/extra.h" 44 | 45 | LAYOUT_BINDING(0) uniform sampler2D TEXTURE_0; 46 | LAYOUT_BINDING(1) uniform sampler2D TEXTURE_1; 47 | LAYOUT_BINDING(2) uniform sampler2D TEXTURE_2; 48 | 49 | void main(){ 50 | #ifdef BYPASS_PIXEL_SHADER 51 | gl_FragColor = vec4(0, 0, 0, 0); 52 | return; 53 | #else 54 | 55 | #if USE_TEXEL_AA 56 | vec4 diffuse = texture2D_AA(TEXTURE_0, uv0); 57 | #else 58 | vec4 diffuse = texture2D(TEXTURE_0, uv0); 59 | #endif 60 | 61 | // we need textures in linear-space colors 62 | diffuse.rgb *= diffuse.rgb; 63 | 64 | #ifdef SEASONS_FAR 65 | diffuse.a = 1.0; 66 | #endif 67 | 68 | // clip alpha 69 | #if USE_ALPHA_TEST 70 | #ifdef ALPHA_TO_COVERAGE 71 | if(diffuse.a < 0.05){ discard; } 72 | #else 73 | if(diffuse.a < 0.5){ discard; } 74 | #endif 75 | #endif 76 | 77 | vec4 inColor = color; 78 | 79 | // day night tint 80 | #ifndef ALWAYS_LIT 81 | vec3 tint = texture2D( TEXTURE_1, uv1).rgb; 82 | tint = mix(tint.bbb,tint*tint,0.35+(0.65*uv1.y*uv1.y*uv1.y)); 83 | 84 | // glowy ores 85 | #ifdef GLOW_TEX 86 | #ifdef ALPHA_TEST 87 | if(diffuse.a>0.9875 && diffuse.a<0.9925 && abs(diffuse.r-diffuse.b)+abs(diffuse.b-diffuse.g)>0.02){ 88 | #else 89 | if(diffuse.a>0.9875 && diffuse.a<0.9925){ 90 | #endif 91 | inColor.rgb = max(inColor.rgb,(vec3(GLOW_TEX*(diffuse.a>0.989 ? 0.4 : 1.0)) + 0.6*diffuse.rgb)*(1.0-uv1.y)); 92 | tint = vec3(0.2) + 0.8*tint; 93 | } 94 | #endif 95 | 96 | diffuse.rgb *= tint; 97 | #endif 98 | 99 | #if defined(BLEND) 100 | // transparency 101 | diffuse.a *= inColor.a; 102 | #endif 103 | 104 | #ifndef SEASONS 105 | #if !USE_ALPHA_TEST && !defined(BLEND) 106 | diffuse.a = inColor.a; 107 | #endif 108 | #else 109 | diffuse.rgb *= mix(vec3(1.0), texture2D( TEXTURE_2, sCol.rg).rgb*2.0, sCol.b); 110 | diffuse.rgb *= inColor.a; 111 | diffuse.a = 1.0; 112 | #endif 113 | 114 | #ifdef MAYBE_WATER 115 | // edit water texture and apply transparency 116 | if(water>0.5){ 117 | diffuse.rgb = vec3(mix(1.0,diffuse.b*1.8,WATER_TEX_OPACITY)); 118 | diffuse.a = inColor.a; 119 | } 120 | #endif 121 | 122 | // apply color and lighting 123 | diffuse.rgb *= inColor.rgb; 124 | 125 | #ifdef FOG 126 | if(wetRefl.a > 0.0){ // wet effect - only on xz plane 127 | if(wPosY<0.0 && dFdy(wPosY)<0.0001){ 128 | float mask = wetRefl.a*(clamp(shade*10.0,8.2,8.8)-7.8); 129 | diffuse.rgb = diffuse.rgb*(1.0 - 0.5*mask) + wetRefl.rgb*mask; 130 | } 131 | } 132 | #endif 133 | 134 | diffuse.rgb = mix(diffuse.rgb, mistColor.rgb, mistColor.a ); 135 | diffuse.rgb = colorCorrection(diffuse.rgb); 136 | 137 | gl_FragColor = diffuse; 138 | #endif // BYPASS_PIXEL_SHADER 139 | } 140 | -------------------------------------------------------------------------------- /shaders/glsl/config_utilities/sky.h: -------------------------------------------------------------------------------- 1 | // Newb shader 2 | 3 | /*""""""""""""""""""""""""""""""""""""""*/ 4 | /* SKY */ 5 | 6 | // color - Night sky color 7 | const vec3 nightSkyCol = vec3(0.01,0.06,0.1); 8 | 9 | // color - Sky base color 10 | const vec3 skyBaseCol = vec3(0.15,0.45,1.0); 11 | 12 | // value - Day sky clarity (0-1) 13 | const float daySkyClarity = 0.3; 14 | 15 | // color - Sunrise base color 16 | const vec3 horizonBaseCol = vec3(1.0,0.4,0.3); 17 | 18 | // color - Sunrise edge color 19 | const vec3 horizonEdgeCol = vec3(1.0,0.4,0.2); 20 | 21 | // color - Underwater fog color 22 | const vec3 underwaterBaseCol = vec3(0.0,0.6,1.0); 23 | 24 | 25 | /*""""""""""""""""""""""""""""""""""""""*/ 26 | 27 | 28 | // Code starts here - Users shouldn't mess down here 29 | // functions related to sky 30 | 31 | // uniform FOG_COLOR is used 32 | 33 | const vec3 horizonEdgeAbsCol = 1.0-horizonEdgeCol; 34 | 35 | // sky colors - needs more tweaking 36 | 37 | vec3 getUnderwaterCol(){ 38 | return underwaterBaseCol*FOG_COLOR.b; 39 | } 40 | 41 | vec3 getZenithCol(float rainFactor){ 42 | 43 | // value needs tweaking 44 | float val = max(FOG_COLOR.r*0.6,max(FOG_COLOR.g,FOG_COLOR.b)); 45 | 46 | // zenith color 47 | vec3 zenithCol = (0.77*val*val + 0.33*val)*skyBaseCol; 48 | zenithCol += nightSkyCol*(0.4-0.4*FOG_COLOR.b); 49 | 50 | // rain sky 51 | float brightness = min(FOG_COLOR.g,0.26); 52 | brightness *= brightness*13.2; 53 | zenithCol = mix(zenithCol*(1.0+0.5*rainFactor),vec3(0.85,0.9,1.0)*brightness,rainFactor); 54 | 55 | return zenithCol; 56 | } 57 | 58 | vec3 getHorizonCol(float rainFactor){ 59 | 60 | // value needs tweaking 61 | float val = max(FOG_COLOR.r*0.65,max(FOG_COLOR.g*1.1,FOG_COLOR.b)); 62 | 63 | float sun = max(FOG_COLOR.r-FOG_COLOR.b,0.0); 64 | 65 | // horizon color 66 | vec3 horizonCol = horizonBaseCol*(((0.7*val*val) + (0.4*val) + sun)*2.4); 67 | 68 | horizonCol += nightSkyCol; 69 | 70 | horizonCol = mix( 71 | horizonCol, 72 | 2.0*val*mix(vec3(0.7,1.0,0.9),skyBaseCol,daySkyClarity), 73 | val*val); 74 | 75 | // rain horizon 76 | float brightness = min(FOG_COLOR.g,0.26); 77 | brightness *= brightness*19.6; 78 | horizonCol = mix(horizonCol,vec3(brightness),rainFactor); 79 | 80 | return horizonCol; 81 | } 82 | 83 | vec3 getHorizonEdgeCol(vec3 horizonCol, float rainFactor){ 84 | float val = (1.1-FOG_COLOR.b)*FOG_COLOR.g*2.1; 85 | val *= 1.0-rainFactor; 86 | 87 | vec3 tint = vec3(1.0)-val*horizonEdgeAbsCol; 88 | return horizonCol*tint; 89 | } 90 | 91 | 92 | // sunlight tinting 93 | vec3 sunLightTint(vec3 night_color,vec3 morning_color,vec3 day_color,float dayFactor,float rain){ 94 | 95 | float tintFactor = FOG_COLOR.g + 0.1*FOG_COLOR.r; 96 | float noon = clamp((tintFactor-0.37)/0.45,0.0,1.0); 97 | float morning = clamp((tintFactor-0.05)*3.125,0.0,1.0); 98 | 99 | float r = 1.0-rain; 100 | r *= r; 101 | 102 | return mix(vec3(0.65,0.65,0.75),mix( 103 | mix(night_color,morning_color,morning), 104 | mix(morning_color,day_color,noon), 105 | dayFactor),r*r); 106 | } 107 | 108 | // Colors end 109 | 110 | 111 | // 1D sky with three color gradient 112 | // A copy of this is in sky.fragment, make changes there aswell 113 | vec3 renderSky(vec3 reddishTint, vec3 horizonColor, vec3 zenithColor, float h){ 114 | 115 | //h = h+0.04; 116 | //if(h > 0.0){h /= 1.04;} 117 | //else{h /= -0.96;} 118 | 119 | h = 1.0-h*h; 120 | 121 | float hsq = h*h; 122 | 123 | // gradient 1 h^16 124 | // gradient 2 h^8 mix h^2 125 | float gradient1 = hsq*hsq*hsq*hsq; 126 | float gradient2 = 0.6*gradient1 + 0.4*hsq; 127 | gradient1 *= gradient1; 128 | 129 | horizonColor = mix(horizonColor, reddishTint, gradient1); 130 | return mix(zenithColor,horizonColor, gradient2 ); 131 | 132 | } 133 | 134 | 135 | -------------------------------------------------------------------------------- /materials/terrain.material: -------------------------------------------------------------------------------- 1 | { 2 | "materials": { 3 | "version": "1.0.0", 4 | 5 | "terrain_base": { 6 | "vertexShader": "shaders/terrain.vertex", 7 | "vrGeometryShader": "shaders/renderchunk.geometry", 8 | "fragmentShader": "shaders/terrain.fragment", 9 | 10 | "+defines": [ "LOW_PRECISION", "TEXEL_AA", "ATLAS_TEXTURE" ], 11 | "+states": [ "DisableAlphaWrite" ], 12 | 13 | "+samplerStates": [ 14 | { 15 | "samplerIndex": 0, 16 | "textureFilter": "TexelAA" 17 | }, 18 | { 19 | "samplerIndex": 1, 20 | "textureFilter": "Bilinear" 21 | }, 22 | { 23 | "samplerIndex": 3, 24 | "textureFilter": "Point" 25 | }, 26 | { 27 | "samplerIndex": 4, 28 | "textureFilter": "Point" 29 | } 30 | ], 31 | 32 | "vertexFields": [ 33 | { "field": "Position" }, 34 | { "field": "UV1" }, 35 | { "field": "Color" }, 36 | { "field": "UV0" } 37 | ], 38 | "msaaSupport": "Both", 39 | 40 | "variants": [ 41 | { "fog": { "+defines": [ "FOG" ] } }, 42 | { "lit": { "+defines": [ "ALWAYS_LIT" ] } }, 43 | { "underwater": { "+defines": [ "FOG" ] } }, 44 | { "fog.underwater": { "+defines": [ "UNDERWATER" ] } }, 45 | { "fading": { "+defines": [ "FOG", "ALLOW_FADE" ] } } 46 | ] 47 | }, 48 | "terrain_opaque:terrain_base": { 49 | 50 | "+variants": [ 51 | { "underlava": { "+states": [ "DisableCulling" ] } } 52 | ] 53 | }, 54 | "terrain_opaque_seasons:terrain_base": { 55 | "+defines": [ "SEASONS" ], 56 | "+samplerStates": [ 57 | { 58 | "samplerIndex": 0, 59 | "textureFilter": "TexelAA" 60 | }, 61 | { 62 | "samplerIndex": 1, 63 | "textureFilter": "Bilinear" 64 | }, 65 | { 66 | "samplerIndex": 2, 67 | "textureFilter": "Point" 68 | } 69 | ] 70 | 71 | }, 72 | 73 | "terrain_blend:terrain_base": { 74 | "+defines": [ "BLEND" ], 75 | "+states": [ 76 | "Blending" 77 | ], 78 | "+variants": [ 79 | { "underwater": { } }, 80 | { "fog.underwater": { "+defines": [ "UNDERWATER" ] } } 81 | ] 82 | }, 83 | 84 | "terrain_blend_far:terrain_blend": { 85 | "+defines": [ "FOG" , "FAR_BLEND" ] 86 | }, 87 | 88 | "terrain_blend_no_culling:terrain_blend": { 89 | "+states": [ 90 | "DisableCulling" 91 | ] 92 | }, 93 | 94 | "terrain_doubleside:terrain_base": { }, 95 | "terrain_alpha_single_side:terrain_base": { 96 | "+defines": [ "ALPHA_TEST" ], 97 | "+states": [ "EnableAlphaToCoverage" ] 98 | }, 99 | "terrain_alpha_seasons:terrain_base": { 100 | "+defines": [ "ALPHA_TEST", "SEASONS" ], 101 | "+states": [ "DisableCulling", "EnableAlphaToCoverage" ], 102 | "+samplerStates": [ 103 | { 104 | "samplerIndex": 0, 105 | "textureFilter": "TexelAA" 106 | }, 107 | { 108 | "samplerIndex": 1, 109 | "textureFilter": "Bilinear" 110 | }, 111 | { 112 | "samplerIndex": 2, 113 | "textureFilter": "Point" 114 | } 115 | ] 116 | 117 | }, 118 | "terrain_alpha:terrain_alpha_single_side": { 119 | "+states": [ "DisableCulling" ], 120 | 121 | // z-fighting fix 122 | "depthBias": 0.0, 123 | "slopeScaledDepthBias": 0.1, 124 | "depthBiasOGL": 0.0, 125 | "slopeScaledDepthBiasOGL": 0.5 126 | }, 127 | "terrain_far:terrain_base": { 128 | "+defines": [ 129 | "FOG", 130 | "LOW_PRECISION" 131 | ] 132 | }, 133 | "terrain_seasons_far:terrain_opaque_seasons": { 134 | "+defines": [ 135 | "FOG", 136 | "LOW_PRECISION" 137 | ] 138 | }, 139 | "terrain_seasons_far_alpha:terrain_opaque_seasons": { 140 | "+defines": [ 141 | "FOG", 142 | "LOW_PRECISION", 143 | "SEASONS_FAR" 144 | ] 145 | }, 146 | "terrain_inside_block": { 147 | "depthFunc": "LessEqual", 148 | 149 | "vertexShader": "shaders/position.vertex", 150 | "vrGeometryShader": "shaders/position.geometry", 151 | "fragmentShader": "shaders/current_color.fragment", 152 | "vertexFields": [ 153 | { "field": "Position" } 154 | ], 155 | "msaaSupport": "Both" 156 | 157 | } 158 | 159 | } 160 | } -------------------------------------------------------------------------------- /shaders/glsl/banner.vertex: -------------------------------------------------------------------------------- 1 | // __multiversion__ 2 | 3 | #include "vertexVersionCentroid.h" 4 | #include "uniformWorldConstants.h" 5 | #include "uniformEntityConstants.h" 6 | #include "uniformPerFrameConstants.h" 7 | #include "uniformBannerConstants.h" 8 | #include "utilities/detectors.glsl" 9 | #include "config_utilities/sky.h" 10 | #include "config_utilities/global.h" 11 | 12 | #ifdef USE_SKINNING 13 | #include "uniformAnimationConstants.h" 14 | #endif 15 | 16 | attribute mediump vec4 POSITION; 17 | attribute vec2 TEXCOORD_0; 18 | attribute vec4 NORMAL; 19 | attribute vec4 COLOR; 20 | 21 | #if defined(USE_SKINNING) 22 | 23 | #ifdef MCPE_PLATFORM_NX 24 | attribute uint BONEID_0; 25 | #else 26 | attribute float BONEID_0; 27 | #endif 28 | 29 | #endif 30 | 31 | #if __VERSION__ >= 300 32 | _centroid varying vec4 uv; 33 | #else 34 | varying vec4 uv; 35 | #endif 36 | 37 | #ifdef ENABLE_FOG 38 | varying vec4 mistColor; 39 | #endif 40 | 41 | #ifdef ENABLE_LIGHT 42 | varying vec3 light; 43 | #endif 44 | 45 | #ifndef DISABLE_TINTING 46 | varying vec4 color; 47 | #endif 48 | 49 | vec3 matmulxyz(mat4 w, vec4 p){ 50 | return vec3( 51 | dot(vec4(w[0][0],w[1][0],w[2][0],w[3][0]),p), 52 | dot(vec4(w[0][1],w[1][1],w[2][1],w[3][1]),p), 53 | dot(vec4(w[0][2],w[1][2],w[2][2],w[3][2]),p) 54 | ); 55 | } 56 | 57 | vec3 lighting(){ 58 | float intensity; 59 | vec3 light; 60 | 61 | #ifdef FANCY 62 | 63 | #ifdef USE_SKINNING 64 | #if defined(LARGE_VERTEX_SHADER_UNIFORMS) 65 | vec3 N = normalize(matmulxyz(BONES[int(BONEID_0)],NORMAL)); 66 | #else 67 | vec3 N = normalize(matmulxyz(BONE,NORMAL)); 68 | #endif 69 | #else 70 | vec3 N = matmulxyz(WORLD,NORMAL); 71 | #endif 72 | 73 | //take care of double sided polygons on materials without culling 74 | #ifdef FLIP_BACKFACES 75 | 76 | #ifdef USE_SKINNING 77 | #if defined(LARGE_VERTEX_SHADER_UNIFORMS) 78 | vec3 viewDir = normalize(matmulxyz(BONES[int(BONEID_0)],POSITION)); 79 | #else 80 | vec3 viewDir = normalize(matmulxyz(BONE,POSITION)); 81 | #endif 82 | #else 83 | vec3 viewDir = matmulxyz(WORLD,POSITION); 84 | #endif 85 | 86 | N *= -sign(dot(N,viewDir)); 87 | 88 | #endif //FLIP_BACKFACES 89 | 90 | N.y *= TILE_LIGHT_COLOR.w; //TILE_LIGHT_COLOR.w contains the direction of the light 91 | N.xz *= N.xz; 92 | 93 | intensity = (0.5 + N.y*0.5)*(1.0-0.45) - N.x*0.1 + N.z*0.1 + 0.45; 94 | intensity *= intensity; 95 | #else 96 | intensity = (0.7+abs(NORMAL.y)*0.3)*(0.9+abs(NORMAL.x)*0.1); 97 | #endif 98 | 99 | intensity *= TILE_LIGHT_COLOR.b*TILE_LIGHT_COLOR.b*sun_intensity*1.3; 100 | 101 | float factor = TILE_LIGHT_COLOR.b-TILE_LIGHT_COLOR.r; 102 | light = intensity*vec3(1.0-2.8*factor,1.0-2.7*factor,1.0); 103 | light *= vec3(1.0) + FOG_COLOR.rgb*0.3; 104 | 105 | return light; 106 | } 107 | 108 | void main(){ 109 | #ifdef USE_SKINNING 110 | 111 | #if defined(LARGE_VERTEX_SHADER_UNIFORMS) 112 | POS4 pos = WORLDVIEWPROJ * BONES[int(BONEID_0)] * POSITION; 113 | #else 114 | POS4 pos = WORLDVIEWPROJ * BONE * POSITION; 115 | #endif 116 | #else 117 | POS4 pos = WORLDVIEWPROJ * POSITION; 118 | #endif 119 | 120 | gl_Position = pos; 121 | 122 | int frameIndex = int((COLOR.a*255.0) + 0.5); 123 | uv.xy = (TEXCOORD_0.xy * BANNER_UV_OFFSETS_AND_SCALES[frameIndex].zw) + BANNER_UV_OFFSETS_AND_SCALES[frameIndex].xy; 124 | uv.zw = (TEXCOORD_0.xy * BANNER_UV_OFFSETS_AND_SCALES[0].zw) + BANNER_UV_OFFSETS_AND_SCALES[0].xy; 125 | 126 | #ifndef DISABLE_TINTING 127 | color = BANNER_COLORS[frameIndex]; 128 | color.a = float(frameIndex<=0); 129 | #endif 130 | 131 | #ifdef ENABLE_LIGHT 132 | light.rgb = lighting(); 133 | #endif 134 | 135 | #ifdef ENABLE_FOG 136 | // detections 137 | bool end = detectEnd(); 138 | bool nether = detectNether(); 139 | bool underWater = detectUnderwater(); 140 | float rainFactor = detectRain(); 141 | 142 | // horizon color 143 | vec3 newFog = getHorizonCol(rainFactor); 144 | newFog = getHorizonEdgeCol(newFog,rainFactor); 145 | if(underWater){ newFog = getUnderwaterCol(); } 146 | 147 | float len = pos.z/RENDER_DISTANCE; 148 | 149 | mistColor = renderMist(newFog, len, TILE_LIGHT_COLOR.x, rainFactor, nether,underWater,end); 150 | vec4 fogColor = renderFog(newFog, len , nether); 151 | 152 | // nether,end,underwater tint 153 | if(nether){ 154 | light.rgb *= TILE_LIGHT_COLOR.x*vec3(1.4,0.96,0.9); 155 | } 156 | if(end){ 157 | light.rgb *= vec3(2.1,1.5,2.3); 158 | fogColor.rgb = vec3(0.16,0.06,0.2); 159 | } 160 | if(underWater){ 161 | #ifndef DISABLE_TINTING 162 | light.rgb *= vec3(0.4,1.12,1.28); 163 | #else 164 | light.rgb *= vec3(0.5,1.4,1.6); 165 | #endif 166 | } 167 | 168 | if(rainFactor > 0.0){ light.rgb *= 1.0-rainFactor*0.3; } 169 | 170 | // mix fog with mist 171 | mistColor = mix(mistColor,vec4(fogColor.rgb,1.0),fogColor.a); 172 | #endif //ENABLE_FOG 173 | } 174 | -------------------------------------------------------------------------------- /shaders/glsl/entity.fragment: -------------------------------------------------------------------------------- 1 | // __multiversion__ 2 | 3 | #include "fragmentVersionCentroidUV.h" 4 | 5 | #include "uniformEntityConstants.h" 6 | #include "uniformShaderConstants.h" 7 | #include "util.h" 8 | 9 | #include "config_utilities/color.h" 10 | 11 | LAYOUT_BINDING(0) uniform sampler2D TEXTURE_0; 12 | LAYOUT_BINDING(1) uniform sampler2D TEXTURE_1; 13 | 14 | #ifdef USE_MULTITEXTURE 15 | LAYOUT_BINDING(2) uniform sampler2D TEXTURE_2; 16 | #endif 17 | 18 | varying vec4 mistColor; 19 | varying lowp vec4 wetRefl; 20 | varying vec3 light; 21 | varying lowp float rainFactor; 22 | 23 | #ifdef USE_SKINNING 24 | varying lowp vec4 edgeMap; 25 | #endif 26 | 27 | #ifdef COLOR_BASED 28 | varying vec4 vertColor; 29 | #endif 30 | 31 | #ifdef USE_OVERLAY 32 | // When drawing horses on specific android devices, overlay color ends up being garbage data. 33 | // Changing overlay color to high precision appears to fix the issue on devices tested 34 | varying highp vec4 overlayColor; 35 | #endif 36 | 37 | #ifdef TINTED_ALPHA_TEST 38 | varying float alphaTestMultiplier; 39 | #endif 40 | 41 | #ifdef GLINT 42 | varying vec2 layer1UV; 43 | varying vec2 layer2UV; 44 | varying vec4 tileLightColor; 45 | varying vec4 glintColor; 46 | #endif 47 | 48 | #ifdef USE_EMISSIVE 49 | 50 | #ifdef USE_ONLY_EMISSIVE 51 | #define NEEDS_DISCARD(C) (C.a == 0.0 || C.a == 1.0 ) 52 | #else 53 | #define NEEDS_DISCARD(C) (C.a + C.r + C.g + C.b == 0.0) 54 | #endif 55 | 56 | #else 57 | 58 | #ifndef USE_COLOR_MASK 59 | #define NEEDS_DISCARD(C) (C.a < 0.5) 60 | #else 61 | #define NEEDS_DISCARD(C) (C.a == 0.0) 62 | #endif 63 | 64 | #endif //USE_EMISSIVE 65 | 66 | void main() 67 | { 68 | vec4 color = vec4(1.0); 69 | 70 | #ifndef NO_TEXTURE 71 | 72 | #if !defined(TEXEL_AA) || !defined(TEXEL_AA_FEATURE) 73 | color = texture2D( TEXTURE_0, uv ); 74 | #else 75 | color = texture2D_AA(TEXTURE_0, uv); 76 | #endif // !defined(TEXEL_AA) || !defined(TEXEL_AA_FEATURE) 77 | 78 | #ifdef MASKED_MULTITEXTURE 79 | vec4 tex1 = texture2D( TEXTURE_1, uv ); 80 | 81 | // If tex1 has a non-black color and no alpha, use color; otherwise use tex1 82 | float maskedTexture = ceil( dot( tex1.rgb, vec3(1.0, 1.0, 1.0) ) * ( 1.0 - tex1.a ) ); 83 | color = mix(tex1, color, clamp(maskedTexture, 0.0, 1.0)); 84 | #endif // MASKED_MULTITEXTURE 85 | 86 | #if defined(ALPHA_TEST) && !defined(USE_MULTITEXTURE) && !defined(MULTIPLICATIVE_TINT) 87 | if(NEEDS_DISCARD(color)) 88 | discard; 89 | #endif // ALPHA_TEST 90 | 91 | #ifdef TINTED_ALPHA_TEST 92 | vec4 testColor = color; 93 | testColor.a *= alphaTestMultiplier; 94 | if(NEEDS_DISCARD(testColor)) 95 | discard; 96 | #endif // TINTED_ALPHA_TEST 97 | 98 | #endif // NO_TEXTURE 99 | 100 | #ifdef COLOR_BASED 101 | color *= vertColor; 102 | #endif 103 | 104 | #ifdef MULTI_COLOR_TINT 105 | // Texture is a mask for tinting with two colors 106 | vec2 colorMask = color.rg; 107 | 108 | // Apply the base color tint 109 | color.rgb = colorMask.r * CHANGE_COLOR.rgb; 110 | 111 | // Apply the secondary color mask and tint so long as its grayscale value is not 0 112 | color.rgb = mix(color.rgb, colorMask.g*MULTIPLICATIVE_TINT_CHANGE_COLOR.rgb, ceil(colorMask.g)); 113 | #else 114 | 115 | #ifdef USE_COLOR_MASK 116 | color.rgb = mix(color.rgb, color.rgb*CHANGE_COLOR.rgb, color.a); 117 | color.a *= CHANGE_COLOR.a; 118 | #endif 119 | 120 | #ifdef ITEM_IN_HAND 121 | color.rgb = mix(color.rgb, color.rgb*CHANGE_COLOR.rgb, vertColor.a); 122 | #if defined(MCPE_PLATFORM_NX) && defined(NO_TEXTURE) && defined(GLINT) 123 | // TODO(adfairfi): This needs to be properly fixed soon. We have a User Story for it in VSO: 102633 124 | vec3 dummyColor = texture2D(TEXTURE_0, vec2(0.0, 0.0)).rgb; 125 | color.rgb += dummyColor * 0.000000001; 126 | #endif 127 | #endif // MULTI_COLOR_TINT 128 | 129 | #endif 130 | 131 | #ifdef USE_MULTITEXTURE 132 | vec4 tex1 = texture2D( TEXTURE_1, uv ); 133 | vec4 tex2 = texture2D( TEXTURE_2, uv ); 134 | color.rgb = mix(color.rgb, tex1.rgb, tex1.a); 135 | #ifdef ALPHA_TEST 136 | if(color.a < 0.5 && tex1.a == 0.0){ 137 | discard; 138 | } 139 | #endif 140 | 141 | #ifdef COLOR_SECOND_TEXTURE 142 | if(tex2.a > 0.0){ 143 | color.rgb = tex2.rgb + (tex2.rgb * CHANGE_COLOR.rgb - tex2.rgb)*tex2.a;//lerp(tex2.rgb, tex2 * changeColor.rgb, tex2.a) 144 | } 145 | #else 146 | color.rgb = mix(color.rgb,tex2.rgb,tex2.a); 147 | #endif 148 | #endif 149 | 150 | #ifdef MULTIPLICATIVE_TINT 151 | vec4 tintTex = texture2D(TEXTURE_1, uv); 152 | #ifdef MULTIPLICATIVE_TINT_COLOR 153 | tintTex.rgb = tintTex.rgb * MULTIPLICATIVE_TINT_CHANGE_COLOR.rgb; 154 | #endif 155 | 156 | #ifdef ALPHA_TEST 157 | color.rgb = mix(color.rgb, tintTex.rgb, tintTex.a); 158 | if(color.a + tintTex.a <= 0.0){ 159 | discard; 160 | } 161 | #endif 162 | 163 | #endif 164 | 165 | #ifdef USE_OVERLAY 166 | //use either the diffuse or the OVERLAY_COLOR 167 | color.rgb = mix(color.rgb,overlayColor.rgb,overlayColor.a); 168 | #endif 169 | 170 | // convert texture to linear space 171 | color.rgb *= color.rgb; 172 | 173 | #ifdef USE_EMISSIVE 174 | // make glowy stuff 175 | color.rgb *= vec3(2.9*(1.0-color.a)) + light*color.a; 176 | #else 177 | color.rgb *= light; 178 | #endif 179 | 180 | #ifdef USE_SKINNING 181 | // entity edge effect 182 | vec2 len = min(abs(edgeMap.xy),abs(edgeMap.zw)); 183 | float ambient = max(len.x,len.y); 184 | ambient = min(ambient*ambient,1.0); 185 | #else 186 | float ambient = 0.0; 187 | #endif 188 | 189 | color.rgb *= (0.7-rainFactor*0.25)+ambient*(0.45-rainFactor*0.1); 190 | 191 | // wet effect 192 | if(wetRefl.a != 0.0){ 193 | color.rgb = mix(color.rgb,wetRefl.rgb,wetRefl.a*(1.0-ambient*0.25)); 194 | } 195 | 196 | // apply mist and fog 197 | color.rgb = mix(color.rgb,mistColor.rgb,mistColor.a); 198 | 199 | // color correction 200 | color.rgb = colorCorrection(color.rgb); 201 | 202 | // enchanted effect 203 | #ifdef GLINT 204 | vec4 layer1 = texture2D(TEXTURE_1, fract(layer1UV)).rgbr * glintColor; 205 | vec4 layer2 = texture2D(TEXTURE_1, fract(layer2UV)).rgbr * glintColor; 206 | vec4 glint = (layer1 + layer2) * tileLightColor; 207 | 208 | // glBlendFuncSeparate(GL_SRC_COLOR, GL_ONE, GL_ONE, GL_ZERO) 209 | color.rgb += glint.rgb*glint.rgb; 210 | color.a = abs(glint.a); 211 | #endif 212 | 213 | //WARNING do not refactor this 214 | #ifdef UI_ENTITY 215 | color.a *= HUD_OPACITY; 216 | #endif 217 | 218 | gl_FragColor = color; 219 | } 220 | -------------------------------------------------------------------------------- /shaders/glsl/entity.vertex: -------------------------------------------------------------------------------- 1 | // __multiversion__ 2 | 3 | #include "vertexVersionCentroidUV.h" 4 | 5 | #include "uniformWorldConstants.h" 6 | #include "uniformEntityConstants.h" 7 | #include "uniformPerFrameConstants.h" 8 | 9 | #include "utilities/detectors.glsl" 10 | #include "config_utilities/sky.h" 11 | #include "config_utilities/global.h" 12 | 13 | #ifdef USE_SKINNING 14 | #include "uniformAnimationConstants.h" 15 | #endif 16 | 17 | #line 13 18 | 19 | attribute mediump vec4 POSITION; 20 | attribute vec2 TEXCOORD_0; 21 | attribute vec4 NORMAL; 22 | 23 | #if defined(USE_SKINNING) 24 | 25 | #ifdef MCPE_PLATFORM_NX 26 | attribute uint BONEID_0; 27 | #else 28 | attribute float BONEID_0; 29 | #endif 30 | 31 | varying lowp vec4 edgeMap; 32 | 33 | #endif 34 | 35 | #ifdef COLOR_BASED 36 | attribute vec4 COLOR; 37 | varying vec4 vertColor; 38 | #endif 39 | 40 | varying vec4 mistColor; 41 | varying lowp vec4 wetRefl; 42 | varying vec3 light; 43 | varying float rainFactor; 44 | 45 | #ifdef USE_OVERLAY 46 | // When drawing horses on specific android devices, overlay color ends up being garbage data. 47 | // Changing overlay color to high precision appears to fix the issue on devices tested 48 | varying highp vec4 overlayColor; 49 | #endif 50 | 51 | #ifdef TINTED_ALPHA_TEST 52 | varying float alphaTestMultiplier; 53 | #endif 54 | 55 | #ifdef GLINT 56 | varying vec2 layer1UV; 57 | varying vec2 layer2UV; 58 | varying vec4 tileLightColor; 59 | varying vec4 glintColor; 60 | #endif 61 | 62 | highp vec3 matmulxyz(highp mat4 w, highp vec4 p){ 63 | return vec3( 64 | dot(vec4(w[0][0],w[1][0],w[2][0],w[3][0]),p), 65 | dot(vec4(w[0][1],w[1][1],w[2][1],w[3][1]),p), 66 | dot(vec4(w[0][2],w[1][2],w[2][2],w[3][2]),p) 67 | ); 68 | } 69 | 70 | vec3 lighting(vec4 position, vec4 normal){ 71 | 72 | float intensity; 73 | vec3 light; 74 | 75 | #ifdef FANCY 76 | highp vec3 N = normalize(matmulxyz(WORLD,normal)); 77 | 78 | //take care of double sided polygons on materials without culling 79 | #ifdef FLIP_BACKFACES 80 | vec3 viewDir = normalize(matmulxyz(WORLD,position)); 81 | N *= -sign(dot(N,viewDir)); 82 | #endif 83 | 84 | N.y *= TILE_LIGHT_COLOR.w; //TILE_LIGHT_COLOR.w contains the direction of the light 85 | N.xz *= N.xz; 86 | 87 | intensity = (0.5 + N.y*0.5)*(1.0-0.45) - N.x*0.1 + N.z*0.1 + 0.45; 88 | intensity *= intensity; 89 | #else 90 | intensity = (0.7+abs(NORMAL.y)*0.3)*(0.9+abs(NORMAL.x)*0.1); 91 | #endif 92 | 93 | intensity *= TILE_LIGHT_COLOR.b*TILE_LIGHT_COLOR.b*sun_intensity*1.3; 94 | 95 | #ifdef USE_OVERLAY 96 | intensity += OVERLAY_COLOR.a * 0.35; 97 | #endif 98 | 99 | float factor = TILE_LIGHT_COLOR.b-TILE_LIGHT_COLOR.r; 100 | light = intensity*vec3(1.0-2.8*factor,1.0-2.7*factor,1.0); 101 | light *= vec3(1.0) + FOG_COLOR.rgb*0.3; 102 | 103 | return light; 104 | } 105 | 106 | #ifdef GLINT 107 | vec2 calculateLayerUV(float offset, float rotation) { 108 | vec2 uv = TEXCOORD_0-vec2(0.5); 109 | float rsin = sin(rotation); 110 | float rcos = cos(rotation); 111 | uv = mat2(rcos, -rsin, rsin, rcos) * uv; 112 | uv += vec2(offset+0.5,0.5); 113 | 114 | return uv * GLINT_UV_SCALE; 115 | } 116 | #endif 117 | void main(){ 118 | POS4 entitySpacePosition; 119 | POS4 entitySpaceNormal; 120 | 121 | #ifdef USE_SKINNING 122 | #if defined(LARGE_VERTEX_SHADER_UNIFORMS) 123 | entitySpacePosition = BONES[int(BONEID_0)] * POSITION; 124 | entitySpaceNormal = BONES[int(BONEID_0)] * NORMAL; 125 | #else 126 | entitySpacePosition = BONE * POSITION; 127 | entitySpaceNormal = BONE * NORMAL; 128 | #endif 129 | #else 130 | entitySpacePosition = POSITION; 131 | entitySpaceNormal = NORMAL; 132 | entitySpaceNormal.w = 0.0; 133 | #endif 134 | 135 | POS4 pos = WORLDVIEWPROJ * entitySpacePosition; 136 | 137 | gl_Position = pos; 138 | 139 | 140 | #ifdef TINTED_ALPHA_TEST 141 | alphaTestMultiplier = OVERLAY_COLOR.a; 142 | #endif 143 | 144 | #ifdef COLOR_BASED 145 | vertColor = COLOR; 146 | #endif 147 | 148 | #ifdef USE_OVERLAY 149 | overlayColor = OVERLAY_COLOR; 150 | #endif 151 | 152 | #ifndef NO_TEXTURE 153 | uv = TEXCOORD_0; 154 | #endif 155 | 156 | #ifdef USE_UV_ANIM 157 | uv.xy = UV_ANIM.xy + (uv.xy * UV_ANIM.zw); 158 | #endif 159 | 160 | #ifdef GLINT 161 | glintColor = GLINT_COLOR; 162 | layer1UV = calculateLayerUV(UV_OFFSET.x, UV_ROTATION.x); 163 | layer2UV = calculateLayerUV(UV_OFFSET.y, UV_ROTATION.y); 164 | tileLightColor = TILE_LIGHT_COLOR; 165 | #endif 166 | 167 | #ifdef USE_SKINNING 168 | // don't do for small entities like item drops 169 | edgeMap = fract(vec4(uv.xy*128.0,uv.xy*256.0)); 170 | edgeMap.x = float(edgeMap.x<0.5); 171 | edgeMap.y = float(edgeMap.y<0.5); 172 | edgeMap.z = float(edgeMap.z<0.5); 173 | edgeMap.w = float(edgeMap.w<0.5); 174 | 175 | edgeMap = 2.0*edgeMap - 1.0; 176 | #endif 177 | 178 | // detections 179 | bool end = detectEnd(); 180 | bool nether = detectNether(); 181 | bool underWater = detectUnderwater(); 182 | rainFactor = detectRain(); 183 | 184 | // horizon color 185 | vec3 newFog = getHorizonCol(rainFactor); 186 | newFog = getHorizonEdgeCol(newFog,rainFactor); 187 | if(underWater){newFog = getUnderwaterCol();} 188 | 189 | float camDist = pos.z/RENDER_DISTANCE; 190 | 191 | mistColor = renderMist(newFog, camDist, TILE_LIGHT_COLOR.x, rainFactor, nether,underWater,end); 192 | vec4 fogColor = renderFog(newFog, camDist, nether); 193 | 194 | // mix fog with mist 195 | mistColor = mix(mistColor,vec4(fogColor.rgb,1.0),fogColor.a); 196 | 197 | // lighting 198 | light = lighting(entitySpacePosition, entitySpaceNormal); 199 | 200 | // soft shadow 201 | light *= 1.05-0.3*float(POSITION.y>0.0); 202 | 203 | #ifndef UI_ENTITY 204 | // nether,end,underwater tint 205 | if(nether){ 206 | light *= TILE_LIGHT_COLOR.x*vec3(1.4,0.96,0.9); 207 | } 208 | if(end){ 209 | light *= vec3(2.1,1.5,2.3); 210 | fogColor.rgb = vec3(0.16,0.06,0.2); 211 | } 212 | if(underWater){ 213 | light *= vec3(0.5,1.4,1.6); 214 | highp float t = TIME; 215 | float caustic = max(TILE_LIGHT_COLOR.x-0.46,0.0)*(0.5+0.5*sin(t + dot(POSITION.xyz,vec3(1.5)) )); 216 | light += (vec3(1.0)+1.5*underwaterBaseCol)*caustic; 217 | } 218 | #endif 219 | 220 | // wet effect 221 | wetRefl.a = 0.0; 222 | if(rainFactor>0.0 && pos.z<24.0){ 223 | highp vec3 wPos = matmulxyz(WORLD,entitySpacePosition); 224 | highp vec3 dir = matmulxyz(WORLD,entitySpaceNormal); 225 | 226 | float nrmY = dir.y/sqrt(dot(dir,dir)); 227 | 228 | if(nrmY>0.0){ 229 | float viewDirY = wPos.y/sqrt(dot(wPos,wPos)); 230 | 231 | float cosR = nrmY*(1.0-abs(viewDirY)); 232 | 233 | float fresnel = cosR*cosR; 234 | fresnel *= fresnel*cosR; 235 | 236 | wetRefl.rgb = newFog; 237 | wetRefl.a = fresnel*rainFactor*TILE_LIGHT_COLOR.y; 238 | } 239 | } 240 | } 241 | -------------------------------------------------------------------------------- /biomes_client.json: -------------------------------------------------------------------------------- 1 | /* water_surface_color is used to calculate water properties and to detect water: 2 | (R-Tint,G-Lightness,B-Detection) */ 3 | { 4 | "biomes" : { 5 | "bamboo_jungle" : { 6 | "fog_identifier" : "minecraft:fog_bamboo_jungle", 7 | "fog_ids_to_merge" : [ "minecraft:fog_bamboo_jungle" ], 8 | "inherit_from_prior_fog" : false, 9 | "water_surface_color" : "#7FBF00" 10 | }, 11 | "bamboo_jungle_hills" : { 12 | "fog_identifier" : "minecraft:fog_bamboo_jungle_hills", 13 | "fog_ids_to_merge" : [ "minecraft:fog_bamboo_jungle_hills" ], 14 | "inherit_from_prior_fog" : false, 15 | "water_surface_color" : "#7FBF00" 16 | }, 17 | "basalt_deltas" : { 18 | "fog_identifier" : "minecraft:fog_basalt_deltas", 19 | "fog_ids_to_merge" : [ "minecraft:fog_basalt_deltas" ], 20 | "inherit_from_prior_fog" : false, 21 | "water_surface_color" : "#7FBF00" 22 | }, 23 | "beach" : { 24 | "fog_identifier" : "minecraft:fog_beach", 25 | "fog_ids_to_merge" : [ "minecraft:fog_beach" ], 26 | "inherit_from_prior_fog" : false, 27 | "water_surface_color" : "#FFFF00" 28 | }, 29 | "birch_forest" : { 30 | "fog_identifier" : "minecraft:fog_birch_forest", 31 | "fog_ids_to_merge" : [ "minecraft:fog_birch_forest" ], 32 | "inherit_from_prior_fog" : false, 33 | "water_surface_color" : "#7FBF00" 34 | }, 35 | "birch_forest_hills" : { 36 | "fog_identifier" : "minecraft:fog_birch_forest_hills", 37 | "fog_ids_to_merge" : [ "minecraft:fog_birch_forest_hills" ], 38 | "inherit_from_prior_fog" : false, 39 | "water_surface_color" : "#7FBF00" 40 | }, 41 | "cold_beach" : { 42 | "fog_identifier" : "minecraft:fog_cold_beach", 43 | "fog_ids_to_merge" : [ "minecraft:fog_cold_beach" ], 44 | "inherit_from_prior_fog" : false, 45 | "water_surface_color" : "#AABF00" 46 | }, 47 | "cold_ocean" : { 48 | "fog_identifier" : "minecraft:fog_cold_ocean", 49 | "fog_ids_to_merge" : [ "minecraft:fog_cold_ocean" ], 50 | "inherit_from_prior_fog" : false, 51 | "water_surface_color" : "#FFBF00" 52 | }, 53 | "cold_taiga" : { 54 | "fog_identifier" : "minecraft:fog_cold_taiga", 55 | "fog_ids_to_merge" : [ "minecraft:fog_cold_taiga" ], 56 | "inherit_from_prior_fog" : false, 57 | "water_surface_color" : "#AABF00" 58 | }, 59 | "cold_taiga_hills" : { 60 | "fog_identifier" : "minecraft:fog_cold_taiga_hills", 61 | "fog_ids_to_merge" : [ "minecraft:fog_cold_taiga_hills" ], 62 | "inherit_from_prior_fog" : false, 63 | "water_surface_color" : "#AABF00" 64 | }, 65 | "cold_taiga_mutated" : { 66 | "fog_identifier" : "minecraft:fog_cold_taiga_mutated", 67 | "fog_ids_to_merge" : [ "minecraft:fog_cold_taiga_mutated" ], 68 | "inherit_from_prior_fog" : false, 69 | "water_surface_color" : "#AABF00" 70 | }, 71 | "crimson_forest" : { 72 | "fog_identifier" : "minecraft:fog_crimson_forest", 73 | "fog_ids_to_merge" : [ "minecraft:fog_crimson_forest" ], 74 | "inherit_from_prior_fog" : false, 75 | "water_surface_color" : "#7FBF00" 76 | }, 77 | "deep_cold_ocean" : { 78 | "fog_identifier" : "minecraft:fog_deep_cold_ocean", 79 | "fog_ids_to_merge" : [ "minecraft:fog_deep_cold_ocean" ], 80 | "inherit_from_prior_fog" : false, 81 | "water_surface_color" : "#FFAA00" 82 | }, 83 | "deep_frozen_ocean" : { 84 | "fog_identifier" : "minecraft:fog_deep_frozen_ocean", 85 | "fog_ids_to_merge" : [ "minecraft:fog_deep_frozen_ocean" ], 86 | "inherit_from_prior_fog" : false, 87 | "water_surface_color" : "#FFBF00" 88 | }, 89 | "deep_lukewarm_ocean" : { 90 | "fog_identifier" : "minecraft:fog_deep_lukewarm_ocean", 91 | "fog_ids_to_merge" : [ "minecraft:fog_deep_lukewarm_ocean" ], 92 | "inherit_from_prior_fog" : false, 93 | "water_surface_color" : "#FFBF00" 94 | }, 95 | "deep_ocean" : { 96 | "fog_identifier" : "minecraft:fog_deep_ocean", 97 | "fog_ids_to_merge" : [ "minecraft:fog_deep_ocean" ], 98 | "inherit_from_prior_fog" : false, 99 | "water_surface_color" : "#FFAA00" 100 | }, 101 | "deep_warm_ocean" : { 102 | "fog_identifier" : "minecraft:fog_deep_warm_ocean", 103 | "fog_ids_to_merge" : [ "minecraft:fog_deep_warm_ocean" ], 104 | "inherit_from_prior_fog" : false, 105 | "water_surface_color" : "#FFBF00" 106 | }, 107 | "default" : { 108 | "fog_identifier" : "newb:fog_default", 109 | "inherit_from_prior_fog" : false, 110 | "remove_all_prior_fog" : false, 111 | "water_surface_color" : "#7FBF00", 112 | "water_surface_transparency" : 0.650 113 | }, 114 | "desert" : { 115 | "fog_identifier" : "minecraft:fog_desert", 116 | "fog_ids_to_merge" : [ "minecraft:fog_desert" ], 117 | "inherit_from_prior_fog" : false, 118 | "water_surface_color" : "#AAFB00" 119 | }, 120 | "desert_hills" : { 121 | "fog_identifier" : "minecraft:fog_desert_hills", 122 | "fog_ids_to_merge" : [ "minecraft:fog_desert_hills" ], 123 | "inherit_from_prior_fog" : false, 124 | "water_surface_color" : "#FFBF00" 125 | }, 126 | "extreme_hills" : { 127 | "fog_identifier" : "minecraft:fog_extreme_hills", 128 | "fog_ids_to_merge" : [ "minecraft:fog_extreme_hills" ], 129 | "inherit_from_prior_fog" : false, 130 | "water_surface_color" : "#7FBF00" 131 | }, 132 | "extreme_hills_edge" : { 133 | "fog_identifier" : "minecraft:fog_extreme_hills_edge", 134 | "fog_ids_to_merge" : [ "minecraft:fog_extreme_hills_edge" ], 135 | "inherit_from_prior_fog" : false, 136 | "water_surface_color" : "#7FBF00" 137 | }, 138 | "extreme_hills_mutated" : { 139 | "fog_identifier" : "minecraft:fog_extreme_hills_mutated", 140 | "fog_ids_to_merge" : [ "minecraft:fog_extreme_hills_mutated" ], 141 | "inherit_from_prior_fog" : false, 142 | "water_surface_color" : "#7FBF00" 143 | }, 144 | "extreme_hills_plus_trees" : { 145 | "fog_identifier" : "minecraft:fog_extreme_hills_plus_trees", 146 | "fog_ids_to_merge" : [ "minecraft:fog_extreme_hills_plus_trees" ], 147 | "inherit_from_prior_fog" : false, 148 | "water_surface_color" : "#7FBF00" 149 | }, 150 | "extreme_hills_plus_trees_mutated" : { 151 | "fog_identifier" : "minecraft:fog_extreme_hills_plus_trees_mutated", 152 | "fog_ids_to_merge" : [ "minecraft:fog_extreme_hills_plus_trees_mutated" ], 153 | "inherit_from_prior_fog" : false, 154 | "water_surface_color" : "#7FBF00" 155 | }, 156 | "flower_forest" : { 157 | "fog_identifier" : "minecraft:fog_flower_forest", 158 | "fog_ids_to_merge" : [ "minecraft:fog_flower_forest" ], 159 | "inherit_from_prior_fog" : false, 160 | "water_surface_color" : "#7FBF00" 161 | }, 162 | "forest" : { 163 | "fog_identifier" : "minecraft:fog_forest", 164 | "fog_ids_to_merge" : [ "minecraft:fog_forest" ], 165 | "inherit_from_prior_fog" : false, 166 | "water_surface_color" : "#7FBF00" 167 | }, 168 | "forest_hills" : { 169 | "fog_identifier" : "minecraft:fog_forest_hills", 170 | "fog_ids_to_merge" : [ "minecraft:fog_forest_hills" ], 171 | "inherit_from_prior_fog" : false, 172 | "water_surface_color" : "#7FBF00" 173 | }, 174 | "frozen_ocean" : { 175 | "fog_identifier" : "minecraft:fog_frozen_ocean", 176 | "fog_ids_to_merge" : [ "minecraft:fog_frozen_ocean" ], 177 | "inherit_from_prior_fog" : false, 178 | "water_surface_color" : "#FFBF00" 179 | }, 180 | "frozen_river" : { 181 | "fog_identifier" : "minecraft:fog_frozen_river", 182 | "fog_ids_to_merge" : [ "minecraft:fog_frozen_river" ], 183 | "inherit_from_prior_fog" : false, 184 | "water_surface_color" : "#FFBF00" 185 | }, 186 | "hell" : { 187 | "fog_identifier" : "minecraft:fog_hell", 188 | "fog_ids_to_merge" : [ "minecraft:fog_hell" ], 189 | "inherit_from_prior_fog" : false, 190 | "water_surface_color" : "#7FBF00" 191 | }, 192 | "ice_mountains" : { 193 | "fog_identifier" : "minecraft:fog_ice_mountains", 194 | "fog_ids_to_merge" : [ "minecraft:fog_ice_mountains" ], 195 | "inherit_from_prior_fog" : false, 196 | "water_surface_color" : "#FFBF00" 197 | }, 198 | "ice_plains" : { 199 | "fog_identifier" : "minecraft:fog_ice_plains", 200 | "fog_ids_to_merge" : [ "minecraft:fog_ice_plains" ], 201 | "inherit_from_prior_fog" : false, 202 | "water_surface_color" : "#FFBF00" 203 | }, 204 | "ice_plains_spikes" : { 205 | "fog_identifier" : "minecraft:fog_ice_plains_spikes", 206 | "fog_ids_to_merge" : [ "minecraft:fog_ice_plains_spikes" ], 207 | "inherit_from_prior_fog" : false, 208 | "water_surface_color" : "#FFBF00" 209 | }, 210 | "jungle" : { 211 | "fog_identifier" : "minecraft:fog_jungle", 212 | "fog_ids_to_merge" : [ "minecraft:fog_jungle" ], 213 | "inherit_from_prior_fog" : false, 214 | "water_surface_color" : "#7FBF00" 215 | }, 216 | "jungle_edge" : { 217 | "fog_identifier" : "minecraft:fog_jungle_edge", 218 | "fog_ids_to_merge" : [ "minecraft:fog_jungle_edge" ], 219 | "inherit_from_prior_fog" : false, 220 | "water_surface_color" : "#7FBF00" 221 | }, 222 | "jungle_hills" : { 223 | "fog_identifier" : "minecraft:fog_jungle_hills", 224 | "fog_ids_to_merge" : [ "minecraft:fog_jungle_hills" ], 225 | "inherit_from_prior_fog" : false, 226 | "water_surface_color" : "#7FBF00" 227 | }, 228 | "jungle_mutated" : { 229 | "fog_identifier" : "minecraft:fog_jungle_mutated", 230 | "fog_ids_to_merge" : [ "minecraft:fog_jungle_mutated" ], 231 | "inherit_from_prior_fog" : false, 232 | "water_surface_color" : "#7FBF00" 233 | }, 234 | "lukewarm_ocean" : { 235 | "fog_identifier" : "minecraft:fog_lukewarm_ocean", 236 | "fog_ids_to_merge" : [ "minecraft:fog_lukewarm_ocean" ], 237 | "inherit_from_prior_fog" : false, 238 | "water_surface_color" : "#FFBF00" 239 | }, 240 | "mega_spruce_taiga" : { 241 | "fog_identifier" : "minecraft:fog_mega_spruce_taiga", 242 | "fog_ids_to_merge" : [ "minecraft:fog_mega_spruce_taiga" ], 243 | "inherit_from_prior_fog" : false, 244 | "water_surface_color" : "#7FBF00" 245 | }, 246 | "mega_spruce_taiga_mutated" : { 247 | "fog_identifier" : "minecraft:fog_mega_spruce_taiga_mutated", 248 | "fog_ids_to_merge" : [ "minecraft:fog_mega_spruce_taiga_mutated" ], 249 | "inherit_from_prior_fog" : false, 250 | "water_surface_color" : "#7FBF00" 251 | }, 252 | "mega_taiga" : { 253 | "fog_identifier" : "minecraft:fog_mega_taiga", 254 | "fog_ids_to_merge" : [ "minecraft:fog_mega_taiga" ], 255 | "inherit_from_prior_fog" : false, 256 | "water_surface_color" : "#7FBF00" 257 | }, 258 | "mega_taiga_hills" : { 259 | "fog_identifier" : "minecraft:fog_mega_taiga_hills", 260 | "fog_ids_to_merge" : [ "minecraft:fog_mega_taiga_hills" ], 261 | "inherit_from_prior_fog" : false, 262 | "water_surface_color" : "#7FBF00" 263 | }, 264 | "mega_taiga_mutated" : { 265 | "fog_identifier" : "minecraft:fog_mega_taiga_mutated", 266 | "fog_ids_to_merge" : [ "minecraft:fog_mega_taiga_mutated" ], 267 | "inherit_from_prior_fog" : false, 268 | "water_surface_color" : "#7FBF00" 269 | }, 270 | "mesa" : { 271 | "fog_identifier" : "minecraft:fog_mesa", 272 | "fog_ids_to_merge" : [ "minecraft:fog_mesa" ], 273 | "inherit_from_prior_fog" : false, 274 | "water_surface_color" : "#7FBF00" 275 | }, 276 | "mesa_bryce" : { 277 | "fog_identifier" : "minecraft:fog_mesa_bryce", 278 | "fog_ids_to_merge" : [ "minecraft:fog_mesa_bryce" ], 279 | "inherit_from_prior_fog" : false, 280 | "water_surface_color" : "#7FBF00" 281 | }, 282 | "mesa_mutated" : { 283 | "fog_identifier" : "minecraft:fog_mesa_mutated", 284 | "fog_ids_to_merge" : [ "minecraft:fog_mesa_mutated" ], 285 | "inherit_from_prior_fog" : false, 286 | "water_surface_color" : "#7FBF00" 287 | }, 288 | "mesa_plateau" : { 289 | "fog_identifier" : "minecraft:fog_mesa_plateau", 290 | "fog_ids_to_merge" : [ "minecraft:fog_mesa_plateau" ], 291 | "inherit_from_prior_fog" : false, 292 | "water_surface_color" : "#7FBF00" 293 | }, 294 | "mesa_plateau_stone" : { 295 | "fog_identifier" : "minecraft:fog_mesa_plateau_stone", 296 | "fog_ids_to_merge" : [ "minecraft:fog_mesa_plateau_stone" ], 297 | "inherit_from_prior_fog" : false, 298 | "water_surface_color" : "#7FBF00" 299 | }, 300 | "mushroom_island" : { 301 | "fog_identifier" : "minecraft:fog_mushroom_island", 302 | "fog_ids_to_merge" : [ "minecraft:fog_mushroom_island" ], 303 | "inherit_from_prior_fog" : false, 304 | "water_surface_color" : "#7FAA00" 305 | }, 306 | "mushroom_island_shore" : { 307 | "fog_identifier" : "minecraft:fog_mushroom_island_shore", 308 | "fog_ids_to_merge" : [ "minecraft:fog_mushroom_island_shore" ], 309 | "inherit_from_prior_fog" : false, 310 | "water_surface_color" : "#7FBF00" 311 | }, 312 | "ocean" : { 313 | "fog_identifier" : "minecraft:fog_ocean", 314 | "fog_ids_to_merge" : [ "minecraft:fog_ocean" ], 315 | "inherit_from_prior_fog" : false, 316 | "water_surface_color" : "#FFBF00" 317 | }, 318 | "plains" : { 319 | "fog_identifier" : "minecraft:fog_plains", 320 | "fog_ids_to_merge" : [ "minecraft:fog_plains" ], 321 | "inherit_from_prior_fog" : false, 322 | "water_surface_color" : "#7FBF00" 323 | }, 324 | "river" : { 325 | "fog_identifier" : "minecraft:fog_river", 326 | "fog_ids_to_merge" : [ "minecraft:fog_river" ], 327 | "inherit_from_prior_fog" : false, 328 | "water_surface_color" : "#7FBF00" 329 | }, 330 | "roofed_forest" : { 331 | "fog_identifier" : "minecraft:fog_roofed_forest", 332 | "fog_ids_to_merge" : [ "minecraft:fog_roofed_forest" ], 333 | "inherit_from_prior_fog" : false, 334 | "water_surface_color" : "#7FBF00" 335 | }, 336 | "savanna" : { 337 | "fog_identifier" : "minecraft:fog_savanna", 338 | "fog_ids_to_merge" : [ "minecraft:fog_savanna" ], 339 | "inherit_from_prior_fog" : false, 340 | "water_surface_color" : "#7FBF00" 341 | }, 342 | "savanna_mutated" : { 343 | "fog_identifier" : "minecraft:fog_savanna_mutated", 344 | "fog_ids_to_merge" : [ "minecraft:fog_savanna_mutated" ], 345 | "inherit_from_prior_fog" : false, 346 | "water_surface_color" : "#7FBF00" 347 | }, 348 | "savanna_plateau" : { 349 | "fog_identifier" : "minecraft:fog_savanna_plateau", 350 | "fog_ids_to_merge" : [ "minecraft:fog_savanna_plateau" ], 351 | "inherit_from_prior_fog" : false, 352 | "water_surface_color" : "#7FBF00" 353 | }, 354 | "soulsand_valley" : { 355 | "fog_identifier" : "minecraft:fog_soulsand_valley", 356 | "fog_ids_to_merge" : [ "minecraft:fog_soulsand_valley" ], 357 | "inherit_from_prior_fog" : false, 358 | "water_surface_color" : "#7FBF00" 359 | }, 360 | "stone_beach" : { 361 | "fog_identifier" : "minecraft:fog_stone_beach", 362 | "fog_ids_to_merge" : [ "minecraft:fog_stone_beach" ], 363 | "inherit_from_prior_fog" : false, 364 | "water_surface_color" : "#7FBF00" 365 | }, 366 | "sunflower_plains" : { 367 | "fog_identifier" : "minecraft:fog_sunflower_plains", 368 | "fog_ids_to_merge" : [ "minecraft:fog_sunflower_plains" ], 369 | "inherit_from_prior_fog" : false, 370 | "water_surface_color" : "#7FBF00" 371 | }, 372 | "swampland" : { 373 | "fog_identifier" : "minecraft:fog_swampland", 374 | "fog_ids_to_merge" : [ "minecraft:fog_swampland" ], 375 | "inherit_from_prior_fog" : false, 376 | "water_surface_color" : "#00BF00", 377 | "water_surface_transparency" : 1.0 378 | }, 379 | "swampland_mutated" : { 380 | "fog_identifier" : "minecraft:fog_swampland_mutated", 381 | "fog_ids_to_merge" : [ "minecraft:fog_swampland_mutated" ], 382 | "inherit_from_prior_fog" : false, 383 | "water_surface_color" : "#00BF00", 384 | "water_surface_transparency" : 1.0 385 | }, 386 | "taiga" : { 387 | "fog_identifier" : "minecraft:fog_taiga", 388 | "fog_ids_to_merge" : [ "minecraft:fog_taiga" ], 389 | "inherit_from_prior_fog" : false, 390 | "water_surface_color" : "#7FBF00" 391 | }, 392 | "taiga_hills" : { 393 | "fog_identifier" : "minecraft:fog_taiga_hills", 394 | "fog_ids_to_merge" : [ "minecraft:fog_taiga_hills" ], 395 | "inherit_from_prior_fog" : false, 396 | "water_surface_color" : "#7FBF00" 397 | }, 398 | "taiga_mutated" : { 399 | "fog_identifier" : "minecraft:fog_taiga_mutated", 400 | "fog_ids_to_merge" : [ "minecraft:fog_taiga_mutated" ], 401 | "inherit_from_prior_fog" : false, 402 | "water_surface_color" : "#7FBF00" 403 | }, 404 | "the_end" : { 405 | "fog_identifier" : "newb:fog_the_end", 406 | "inherit_from_prior_fog" : false, 407 | "water_surface_color" : "#FFBF00" 408 | }, 409 | "warm_ocean" : { 410 | "fog_identifier" : "minecraft:fog_warm_ocean", 411 | "fog_ids_to_merge" : [ "minecraft:fog_warm_ocean" ], 412 | "inherit_from_prior_fog" : false, 413 | "water_surface_color" : "#FFBF00", 414 | "water_surface_transparency" : 0.550 415 | }, 416 | "warped_forest" : { 417 | "fog_identifier" : "minecraft:fog_warped_forest", 418 | "fog_ids_to_merge" : [ "minecraft:fog_warped_forest" ], 419 | "inherit_from_prior_fog" : false, 420 | "water_surface_color" : "#7FBF00" 421 | } 422 | } 423 | } 424 | -------------------------------------------------------------------------------- /shaders/glsl/terrain.vertex: -------------------------------------------------------------------------------- 1 | // __multiversion__ 2 | 3 | #ifndef BYPASS_PIXEL_SHADER 4 | 5 | #if __VERSION__ >= 300 6 | #ifdef MSAA_FRAMEBUFFER_ENABLED 7 | centroid out vec2 uv0; 8 | centroid out vec2 uv1; 9 | #else 10 | out vec2 uv0; 11 | out vec2 uv1; 12 | #endif 13 | 14 | #define attribute in 15 | #define varying out 16 | #define texture2D texture 17 | #else 18 | varying vec2 uv0; 19 | varying vec2 uv1; 20 | #endif 21 | 22 | varying vec4 color; 23 | varying vec4 mistColor; 24 | varying lowp float shade; 25 | 26 | #ifdef SEASONS 27 | varying vec3 sCol; 28 | #endif 29 | 30 | #ifdef FOG 31 | varying float wPosY; 32 | varying lowp vec4 wetRefl; 33 | #endif 34 | 35 | #if defined(BLEND) || defined(FAR_BLEND) 36 | #define MAYBE_WATER 37 | varying lowp float water; 38 | #endif 39 | 40 | #endif // !BYPASS_PIXEL_SHADER 41 | 42 | #include "uniformWorldConstants.h" 43 | #include "uniformPerFrameConstants.h" 44 | #include "uniformShaderConstants.h" 45 | #include "uniformRenderChunkConstants.h" 46 | 47 | #include "utilities/detectors.glsl" 48 | #include "config_utilities/sky.h" 49 | #include "utilities/noise.glsl" 50 | #include "config_utilities/clouds.h" 51 | #include "config_utilities/global.h" 52 | #include "config_utilities/terrain.h" 53 | 54 | uniform highp float TOTAL_REAL_WORLD_TIME; 55 | uniform lowp sampler2D TEXTURE_0; 56 | 57 | attribute POS4 POSITION; 58 | attribute vec4 COLOR; 59 | attribute vec2 TEXCOORD_0; 60 | attribute vec2 TEXCOORD_1; 61 | 62 | const float rd = 1.57079; // pi by 2 63 | const float shadowIntensity = 1.0-shadow_intensity; 64 | 65 | // bool between function 66 | bool is(float val,float val1,float val2){ 67 | return (val>val1 && val0.9) && uv0.y<0.3; 155 | #endif 156 | isTree = (isTree && (bPos.x+bPos.y+bPos.z<0.001)) || (color.a < 0.005 && max(COLOR.g,COLOR.r)>0.37); 157 | 158 | // environment detections 159 | bool end = detectEnd(); 160 | bool nether = detectNether(); 161 | #ifdef FOG 162 | bool underWater = detectUnderwater(); 163 | float rainFactor = detectRain(); 164 | #else 165 | bool underWater = false; 166 | float rainFactor = 0.0; 167 | #endif 168 | 169 | #ifdef MAYBE_WATER 170 | bool isWater = COLOR.b<0.02; 171 | water = float(isWater); 172 | #else 173 | bool isWater = false; 174 | #endif 175 | 176 | // sky colors 177 | vec3 zenithCol = getZenithCol(rainFactor); 178 | vec3 horizonCol = getHorizonCol(rainFactor); 179 | vec3 horizonEdgeCol = getHorizonEdgeCol(horizonCol,rainFactor); 180 | if(underWater){ 181 | vec3 fogcol = getUnderwaterCol(); 182 | zenithCol = fogcol; 183 | horizonCol = fogcol; 184 | horizonEdgeCol = fogcol; 185 | } 186 | 187 | highp float t = TOTAL_REAL_WORLD_TIME; 188 | #ifdef TIME_FLIPPING 189 | // remap 0-3600s to 0-1800-0s 190 | t = 1800.0 - abs(t-1800.0); 191 | #endif 192 | 193 | #ifdef SEASONS 194 | // season tree leaves are colored in fragment using sCol values 195 | sCol = COLOR.rgb; 196 | color.rgb = vec3(1.0); 197 | 198 | uv1.y *= 1.00151; 199 | #else 200 | // convert color to linear space for color correction 201 | // and tree leaves, slab lighting fix 202 | if(isColored){color.rgb *= color.rgb*1.2;} 203 | if(isTree || (fract(cPos.y)==0.5 && fract(cPos.x)==0.0) ){uv1.y *= 1.00151;} 204 | #endif 205 | 206 | 207 | // Lighting 208 | // will be multiplied by tex uv1 in frag so values should be divided by uv1 here 209 | 210 | vec3 torchColor = end ? end_torch : (nether ? nether_torch : overworld_torch); 211 | #ifdef UNDERWATER 212 | torchColor = underwater_torch; 213 | #endif 214 | float torch_attenuation = (torch_intensity*uv1.x)/(0.5-0.45*lit.x); 215 | #ifdef BLINKING_TORCH 216 | torch_attenuation *= 1.0 - 0.19*noise1D(t*8.0); 217 | #endif 218 | vec3 torchLight = torchColor*torch_attenuation; 219 | 220 | vec3 light; 221 | if(nether || end){ 222 | // ambient - end and nether 223 | light = end ? vec3(1.98,1.25,2.3) : vec3(1.98,1.44,1.26); 224 | 225 | // torch light 226 | light += torchLight; 227 | } 228 | else{ 229 | // overworld lighting 230 | float dayFactor = min(dot(FOG_COLOR.rgb,vec3(0.5,0.4,0.4))*(1.0 + 1.9*rainFactor),1.0); 231 | float nightFactor = 1.0-dayFactor*dayFactor; 232 | float rainDim = min(FOG_COLOR.g,0.25)*rainFactor; 233 | float lightIntensity = sun_intensity*(1.0 - rainDim)*(1.0 + night_brightness*nightFactor); 234 | 235 | // min ambient in caves 236 | light = vec3((1.35+cave_brightness)*(1.0-uv1.x)*(1.0-uv1.y)); 237 | 238 | // sky ambient 239 | light += mix(horizonCol,zenithCol,0.5+uv1.y-0.5*lit.y)*(lit.y*(3.0-2.0*uv1.y)*(1.3 + (4.0*nightFactor) - rainDim)); 240 | 241 | // shadow cast by top light 242 | float shadow = float(uv1.y > shadow_edge); 243 | #ifdef REMOVE_OLD_SHADOW 244 | if(uv1.y < shadow_edge && uv1.x>0.0){shadow = uv1.y;} 245 | #endif 246 | 247 | // make shadow a bit softer and more softer when raining 248 | shadow += uv1.y > 0.85 ? (0.2+0.3*rainFactor)*(1.0-shadow) : 0.0; 249 | 250 | shadow = max(shadow,(shadowIntensity + (0.6*shadow_intensity*nightFactor))*lit.y); 251 | shadow *= shade>0.8 ? 1.0 : 0.8; 252 | 253 | // direct light from top 254 | float dirLight = shadow*(1.0-uv1.x*nightFactor)*lightIntensity; 255 | light += dirLight*sunLightTint(night_color,morning_color,noon_color,dayFactor,rainFactor); 256 | 257 | // extra indirect light 258 | light += vec3(0.3*lit.y*uv1.y*(1.2-shadow)*lightIntensity); 259 | 260 | // torch light 261 | light += torchLight*(1.0-(max(shadow,0.65*lit.y)*dayFactor*(1.0-0.3*rainFactor))); 262 | } 263 | 264 | // darken at crevices 265 | light *= COLOR.g > 0.35 ? 1.0 : 0.8; 266 | 267 | // brighten tree leaves 268 | if(isTree){light *= 1.25;} 269 | 270 | // distance from the camera (used by mist, fog, water) 271 | float camDist = length(wPos); 272 | 273 | #ifdef ALPHA_TEST 274 | // texture space - (64x32) textures in uv0.xy 275 | vec2 texMap = uv0*vec2(64.0,32.0); 276 | float texPosY = fract(texMap.y); 277 | vec4 tex0 = texture2D(TEXTURE_0,uv0); 278 | 279 | int texNoX = int(texMap.x); 280 | int texNoY = int(texMap.y); 281 | 282 | // x and z distance from block center 283 | vec2 bPosC = abs(bPos.xz-0.5); 284 | 285 | float windStrength = lit.y*(noise1D(t*0.36) + (rainFactor*0.4)); 286 | 287 | #ifdef PLANTS_WAVE 288 | 289 | #ifdef SEASONS 290 | bool shouldWave = true; 291 | #else 292 | 293 | float tex0lum = tex0.r+tex0.g+tex0.b; 294 | 295 | bool isTop = texPosY<0.5; 296 | bool isTreeLeaves = (COLOR.a==0.0 || tex0.a>0.99) && max(COLOR.g,COLOR.r)>0.37 && bPos.x+bPos.y+bPos.z<0.01; 297 | bool isPlants = (COLOR.r/COLOR.g<1.9); 298 | bool isVines = (bPos.y + bPos.x*bPos.z)<0.00005 && is(bPosC.x+bPosC.y,0.94921,0.94922); 299 | bool isFarmPlant = (bPos.y==0.9375) && (bPosC.x==0.25 || bPosC.y==0.25); 300 | bool shouldWave = ((isTreeLeaves || isPlants || isVines) && isColored) || (isFarmPlant && isTop && !underWater); 301 | bool isGrassTop = (tex0.a<0.01 && tex0lum>2.99 && bPos.y==0.0); 302 | 303 | // darken plants bottom - better to not move it elsewhere 304 | light *= isFarmPlant && !isTop ? 0.65 : 1.0; 305 | if(isColored && !isTreeLeaves && texNoY==12){ 306 | light *= isTop ? 1.2 : 1.2 - (bPos.y>0.0 ? 1.5-bPos.y : 0.5); 307 | } 308 | 309 | #ifdef EXTRA_PLANTS_WAVE 310 | // bamboo pot plant leaves 311 | shouldWave = shouldWave || ( (bPos.y==0.0 || bPos.y==0.125) && bPos.z==0.5 && bPos.x==0.9375); 312 | 313 | // spore blossom petal 314 | shouldWave = shouldWave || ( (bPos.x==0.5 || bPos.z==0.5) && bPos.y==0.46875); 315 | 316 | shouldWave = shouldWave || ( ( ( ( 317 | (texNoY==4 && texNoX>60) || // long bush bottom 1 318 | (texNoY==5 && texNoX>0 && texNoX<4) || // long bush bottom 2 319 | (texNoY==9 && texNoX>45) || // flowers 320 | (texNoY==10 && texNoX>19 && texNoX<27) || // tree shurbs 321 | (texNoY==12 && texNoX>31 && texNoX<37) || // berry bush 322 | (texNoY==13 && (texNoX==47 || texNoX==27)) // wither rose & dandelion 323 | ) && isTop) || ( 324 | (texNoY==5 && texNoX>4 && texNoX<13) || // long bushes top 325 | (texNoY==12 && texNoX==31) // sunflower green pad 326 | ) ) && tex0.a<0.01 && (tex0lum<0.01 || tex0lum>2.99)); 327 | #endif 328 | #endif 329 | 330 | if(shouldWave && camDist<20.0){ 331 | // values must be a multiple of pi/4 332 | float phaseDiff = dot(cPos,vec3(0.7854)) + fastRand(tiledCpos.xz + tiledCpos.y); 333 | float amplitude = PLANTS_WAVE*windStrength; 334 | 335 | #ifdef SEASONS 336 | amplitude *= 0.5; 337 | #else 338 | amplitude *= isTreeLeaves ? 0.5 : 1.0; 339 | amplitude = isVines ? min(0.024,amplitude*fract(0.01+tiledCpos.y*0.5)) : amplitude; 340 | 341 | // wave the bottom of plants in opposite direction to make it look fixed 342 | if(isPlants && isColored && !(isGrassTop || isVines || isTreeLeaves || isTop)){amplitude *= bPos.y>0.0 ? bPos.y-1.0 : 0.0 ;} 343 | #endif 344 | 345 | float wave = 1.0+mix( 346 | sin(t*wave_speed + phaseDiff), 347 | sin(t*wave_speed*1.5 + phaseDiff), 348 | rainFactor); 349 | wave *= amplitude; 350 | 351 | //worldPos.y -= 1.0-sqrt(1.0-wave*wave); 352 | worldPos.xyz -= vec3(wave,wave*wave*0.5,wave); 353 | } 354 | #endif //PLANTS_WAVE 355 | 356 | #ifdef LANTERN_WAVE 357 | bool y6875 = bPos.y==0.6875; 358 | bool y5625 = bPos.y==0.5625; 359 | bool isLantern = ( (y6875 || y5625) && bPosC.x==0.125 ) || ( (y5625 || bPos.y==0.125) && (bPosC.x==0.1875) ); 360 | bool isChain = bPosC.x==0.0625 && y6875; 361 | 362 | // fix non-hanging lanterns waving top (works only if texPosY is correct) 363 | if( texPosY<0.3 || is(texPosY,0.67,0.69) || is(texPosY,0.55,0.6) ){ 364 | isLantern = isLantern && !y5625; 365 | } 366 | 367 | // X,Z rotation 368 | if( (isChain||isLantern) && uv1.x>0.6){ 369 | // phase diff for individual lanterns 370 | float offset = dot(floor(cPos),vec3(0.3927)); 371 | 372 | // simple random wave for angle 373 | highp vec2 theta = vec2(t + offset,t*1.4 + offset); 374 | theta = sin(vec2(theta.x,theta.x+0.7)) + rainFactor*sin(vec2(theta.y,theta.y+0.7)); 375 | theta *= LANTERN_WAVE*windStrength; 376 | 377 | vec2 sinA = sin(theta); 378 | vec2 cosA = cos(theta); 379 | 380 | vec3 pivotPos = vec3(0.5,1.0,0.5)-bPos; 381 | 382 | worldPos.x += dot(pivotPos.xy,vec2(1.0-cosA.x,-sinA.x)); 383 | worldPos.y += dot(pivotPos,vec3(sinA.x*cosA.y,1.0-cosA.x*cosA.y,sinA.y)); 384 | worldPos.z += dot(pivotPos,vec3(sinA.x*sinA.y,-cosA.x*sinA.y,1.0-cosA.y)); 385 | } 386 | #endif //LANTERN_WAVE 387 | 388 | #else 389 | #if defined(MAYBE_WATER) && defined(WATER_WAVE) 390 | if(isWater && camDist < 16.0){ 391 | worldPos.y += 0.002; 392 | worldPos.xy += WATER_WAVE*vec2(1.0,min(15.0*fract(cPos.y),1.5))*sin( t*2.0 + dot(cPos,vec3(rd))); 393 | } 394 | #endif 395 | #endif // ALPHA_TEST 396 | #endif //!BYPASS_PIXEL_SHADER 397 | 398 | #ifndef AS_ENTITY_RENDERER 399 | // Not needed for entities - they are already offset by camera translation before rendering 400 | POS4 pos = WORLDVIEW * worldPos; 401 | pos = PROJ * pos; 402 | #endif 403 | gl_Position = pos; 404 | 405 | #ifndef BYPASS_PIXEL_SHADER 406 | 407 | float relativeDist = camDist / RENDER_DISTANCE; 408 | 409 | #ifdef BLEND 410 | // vertex based transparency (mostly for water) 411 | if(color.a < 0.95) { 412 | #ifdef FANCY 413 | // fade out blended water layer to opaque layer 414 | float alphaFadeOut = clamp(camDist/FAR_CHUNKS_DISTANCE, 0.0, 1.0); 415 | color.a = getWaterAlpha(COLOR.rgb); 416 | color.a = color.a + (0.5-0.5*color.a)*alphaFadeOut; 417 | #else 418 | color.a = 1.0; 419 | #endif 420 | } 421 | #endif 422 | 423 | mistColor = renderMist(horizonEdgeCol, relativeDist, lit.x, rainFactor, nether,underWater,end); 424 | 425 | mistColor.rgb *= max(0.75,uv1.y); 426 | mistColor.rgb += torchColor*torch_intensity*lit.x*0.3; 427 | 428 | #if defined(FOG) || defined(BLEND) 429 | 430 | vec3 viewDir = -wPos/camDist; 431 | 432 | #ifdef MAYBE_WATER 433 | if(isWater){ 434 | // get water color (r-tint,g-lightness) 435 | vec3 waterCol = fresh_water_color; 436 | waterCol = COLOR.r < 0.5 ? mix(marshy_water_color,waterCol,COLOR.r*2.0) : mix(waterCol,sea_water_color,(COLOR.r*2.0)-1.0); 437 | waterCol *= COLOR.g; 438 | 439 | waterCol *= 0.3 + (FOG_COLOR.g*(2.0-2.0*FOG_COLOR.g)*rainFactor); 440 | waterCol *= light*max(max(FOG_COLOR.b,0.2+lit.x),FOG_COLOR.r*1.2)*max(0.3+0.7*uv1.y,uv1.x); 441 | 442 | float cosR; 443 | vec3 waterRefl; 444 | float fractCposY = fract(cPos.y); 445 | if(fractCposY>0.0){ // reflection for top plane 446 | // reflection y angle 447 | float bump = disp(tiledCpos,t) + 0.12*sin(t*2.0 + dot(cPos,vec3(rd))); 448 | bump *= water_bump; 449 | cosR = abs(viewDir.y); 450 | cosR = mix(cosR,(1.0-cosR*cosR),bump); 451 | 452 | // sky reflection 453 | waterRefl = getSkyRefl(horizonEdgeCol,horizonCol,zenithCol,cosR,-wPos.y); 454 | waterRefl += getSunRefl(viewDir.x,horizonEdgeCol.r); 455 | 456 | // cloud reflection 457 | #if defined(FANCY) && defined(CLOUD_REFLECTION) 458 | vec2 parallax = viewDir.xz/viewDir.y; 459 | vec2 projectedPos = (0.7*wPos.xz*cloud_size) - parallax; 460 | 461 | float fade = 0.1*length(projectedPos); 462 | fade = wPos.y<0.0 ? (clamp(2.0-(fade*2.0),0.0,1.0)) : 0.0; 463 | 464 | projectedPos += ((1.0-fade) - bump)*parallax; 465 | 466 | float renderedClouds = cloudNoise2D(projectedPos,t,rainFactor); 467 | 468 | vec3 cloudColor = waterRefl.ggg+mix(vec3(1.0,0.5,0.2),vec3(1.0),FOG_COLOR.g*1.1)*FOG_COLOR.g; 469 | cloudColor = mix(cloudColor,vec3(2.1*FOG_COLOR.g),rainFactor); 470 | 471 | waterRefl = mix(waterRefl,cloudColor,renderedClouds*fade*0.9); 472 | #endif 473 | 474 | // mask reflection 475 | if(uv1.y < 0.93 && !end){waterRefl *= 0.7*uv1.y;} 476 | 477 | // ambient,torch light reflection 478 | waterRefl += vec3(0.02-(0.02*uv1.y)) + torchColor*torch_intensity*((uv1.x>0.83 ? 0.6 : 0.0) + lit.x*bump*10.0); 479 | 480 | // flat plane 481 | if( is(fractCposY,0.8,0.9) ){ waterRefl *= 1.0 - 0.66*clamp(wPos.y,0.0,1.0); } 482 | 483 | // slanted plane and highly slanted plane 484 | else{ waterRefl *= (0.1*sin(t*2.0+cPos.y*12.566)) + (fractCposY > 0.9 ? 0.2 : 0.4);} 485 | } 486 | else{ // reflection for side plane 487 | cosR = max(sqrt(dot(viewDir.xz,viewDir.xz)),float(wPos.y<0.5)); 488 | cosR += (1.0-cosR*cosR)*water_bump*(0.5 + 0.5*sin(1.5*t + dot(cPos,vec3(rd)) )); 489 | 490 | waterRefl = zenithCol*lit.y*1.3; 491 | } 492 | 493 | float fresnel = calculateFresnel(cosR,0.03); 494 | float opacity = 1.0-cosR; 495 | 496 | color.rgb = waterCol*(1.0-0.4*fresnel) + waterRefl*fresnel; 497 | #ifdef USE_ANGLE_BLEND_FADE 498 | color.a = getWaterAlpha(COLOR.rgb) + opacity*(1.0-color.a); 499 | #else 500 | color.a = color.a + (1.0-color.a)*opacity*opacity; 501 | #endif 502 | } //isWater 503 | #endif // MAYBE_WATER 504 | #endif // defined(FOG) || defined(BLEND) 505 | 506 | 507 | #ifdef FOG 508 | // when raining or underwater, all chunks define FOG 509 | 510 | #ifdef UNDERWATER 511 | #ifdef UNDERWATER_WAVE 512 | gl_Position.xy += vec2(UNDERWATER_WAVE*min(0.05*pos.z,0.6)*sin(t*1.2 + dot(cPos,vec3(rd)))); 513 | #endif 514 | if(uv1.y < 0.9){ // underwater lighting 515 | vec3 underWaterColor = mix(underwater_color,vec3(1.0),lit.y*0.7); 516 | light = underWaterColor*(light*0.7 + vec3(underwater_brightness)); 517 | 518 | float caustics = disp(tiledCpos*vec3(1.0,0.1,1.0), t); 519 | caustics += 0.25+0.25*sin(t + (cPos.x + cPos.z)*rd); 520 | 521 | light += caustics*underWaterColor*(0.1+lit.y+(lit.x*0.7))*caustic_intensity; 522 | } 523 | #endif //UNDERWATER 524 | 525 | // out wPos.y for Y-normal calculation in fragment 526 | wPosY = wPos.y; 527 | 528 | // rain effects 529 | wetRefl.a = 0.0; 530 | if(rainFactor > 0.0){ 531 | 532 | float lit2 = lit.y*lit.y; 533 | 534 | // humid air blow 535 | float humidAir = max(noise2D( (pos.xy*vec2(1.5,1.0)/(1.0+pos.z)) + (t*vec2(1.4,0.7)) ),0.0); 536 | humidAir *= rainFactor*lit2; 537 | mistColor.a = min(mistColor.a + humidAir*rain_blow_opacity,1.0); 538 | 539 | // wet effect 540 | float endDist = RENDER_DISTANCE*0.6; 541 | 542 | if(!isWater && camDist < endDist){ 543 | // puddles map 544 | float wetness = lit2*min(0.4+0.6*fastRand(tiledCpos.xz*1.4),1.0); 545 | 546 | float cosR = max(viewDir.y,float(wPos.y > 0.0)); 547 | 548 | wetRefl.rgb = getRainSkyRefl(horizonCol,zenithCol,cosR); 549 | wetRefl.rgb += 0.9*torchLight; 550 | wetRefl.a = calculateFresnel(cosR,0.03)*rainFactor*wetness; 551 | wetRefl.a *= clamp(2.0-(2.0*camDist/endDist),0.0,0.9); // fade out 552 | 553 | // darken wet parts 554 | color.rgb *= 1.0-0.5*wetness*rainFactor; 555 | } 556 | else{ 557 | color.rgb *= 1.0-0.4*lit2*rainFactor; 558 | } 559 | 560 | } 561 | 562 | // loading chunks 563 | #ifdef ALLOW_FADE 564 | relativeDist += RENDER_CHUNK_FOG_ALPHA; 565 | #endif 566 | 567 | vec4 fogColor = renderFog(horizonEdgeCol, relativeDist, nether); 568 | 569 | #ifndef UNDERWATER 570 | if(nether){ 571 | fogColor.rgb = mix(fogColor.rgb,vec3(0.8,0.2,0.12)*1.5,lit.x*(1.67-fogColor.a*1.67)); 572 | } 573 | else{ 574 | if(end){fogColor.rgb = vec3(0.16,0.06,0.2);} 575 | 576 | // remove fog in heights 577 | float fogGradient = 1.0-max(-viewDir.y+0.1,0.0); 578 | fogGradient *= fogGradient*fogGradient; 579 | fogColor.a *= fogGradient; 580 | } 581 | #endif 582 | 583 | mistColor = mix(mistColor,vec4(fogColor.rgb,1.0),fogColor.a); 584 | #endif // FOG 585 | 586 | // apply light to color 587 | #ifdef MAYBE_WATER 588 | if(!isWater){ color.rgb *= light; } 589 | #else 590 | color.rgb *= light; 591 | #endif 592 | 593 | #endif //!BYPASS_PIXEL_SHADER 594 | } 595 | --------------------------------------------------------------------------------