Merge branch 'zesterer/worldsim' into 'master'

Rtsim, HDR rendering, various worldgen improvements, map improvements

See merge request veloren/veloren!1533
This commit is contained in:
Joshua Barretto 2020-11-23 16:59:31 +00:00
commit d52b595240
190 changed files with 4611 additions and 1035 deletions

View File

@ -6,8 +6,8 @@ rustflags = [
[alias]
generate = "run --package tools --"
test-server = "-Zpackage-features run --bin veloren-server-cli --no-default-features"
tracy-server = "-Zunstable-options -Zpackage-features run --bin veloren-server-cli --no-default-features --features tracy --profile dev"
tracy-server = "-Zunstable-options -Zpackage-features run --bin veloren-server-cli --no-default-features --features tracy,simd --profile no_overflow"
test-voxygen = "-Zpackage-features run --bin veloren-voxygen --no-default-features --features gl,simd"
tracy-voxygen = "-Zunstable-options -Zpackage-features run --bin veloren-voxygen --no-default-features --features tracy,gl,simd --profile dev"
tracy-voxygen = "-Zunstable-options -Zpackage-features run --bin veloren-voxygen --no-default-features --features tracy,gl,simd --profile no_overflow"
server = "run --bin veloren-server-cli"

View File

@ -44,6 +44,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Wind SFX system
- Added Norwegian language
- Roll can now interrupt attacks
- Birch forests
- Willow forests
- More significant temperature variation across the world
- Initial implementation of real-time world simulation
- Travellers that explore the world
- HDR rendering
- Map site icons
- Map panning
- Innumerable minor improvements to world generation
- Variable dungeon difficulty
- Aurora Borealis (localised entirely within the kitchen)
- Block-based voxel lighting
### Changed
@ -81,7 +93,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Adjusted some keybindings
- Consumables can now trigger multiple effects and buffs
- Overhauled overworld spawns depending on chunk attributes
- Fixed a bug which caused campfires and other stuff to duplicate
- Improved cloud and water shader quality
### Removed
@ -96,6 +108,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed a bug where a nearby item would also be collected when collecting collectible blocks
- Fixed a bug where firing fast projectile at a downwards angle caused them to veer off at a higher angle
- Fixed a bug where ui scale in the login menu was not updated when changed in-game
- Fixed a bug which caused campfires and other stuff to duplicate
- Significantly improved water movement AI to stop entities getting stuck
- Prevented entities, sprites and particles being lit when not visible to the sun
## [0.7.0] - 2020-08-15

1
Cargo.lock generated
View File

@ -5406,6 +5406,7 @@ dependencies = [
"scan_fmt",
"serde",
"serde_json",
"slab",
"specs",
"specs-idvs",
"tiny_http",

View File

@ -0,0 +1,12 @@
ItemDef(
name: "Traveler's Backpack",
description: "Comfort and capacity united.",
kind: Armor(
(
kind: Back("Backpack0"),
stats: (
protection: Normal(0.0)),
)
),
quality: High,
)

View File

@ -0,0 +1,12 @@
ItemDef(
name: "Warlock cape",
description: "Belong to a mighty warlock.",
kind: Armor(
(
kind: Back("Warlock"),
stats: (
protection: Normal(4.0)),
)
),
quality: Moderate,
)

View File

@ -0,0 +1,12 @@
ItemDef(
name: "Warlord cape",
description: "Belong to a mighty warlord.",
kind: Armor(
(
kind: Back("Warlord"),
stats: (
protection: Normal(4.0)),
)
),
quality: Moderate,
)

View File

@ -5,8 +5,8 @@ ItemDef(
(
kind: Belt("Assassin"),
stats: (
protection: Normal(1.0)
),
protection: Normal(2.0)
),
)
),
quality: Moderate,

View File

@ -0,0 +1,13 @@
ItemDef(
name: "Warlock Belt",
description: "Belong to a mighty warlock.",
kind: Armor(
(
kind: Belt("Warlock"),
stats: (
protection: Normal(8.0)
),
)
),
quality: Moderate,
)

View File

@ -0,0 +1,13 @@
ItemDef(
name: "Warlord Belt",
description: "Belong to a mighty warlord.",
kind: Armor(
(
kind: Belt("Warlord"),
stats: (
protection: Normal(8.0)
),
)
),
quality: Moderate,
)

View File

@ -5,8 +5,8 @@ ItemDef(
(
kind: Chest("Assassin"),
stats: (
protection: Normal(6.0)
),
protection: Normal(15.0)
),
)
),
quality: Moderate,

View File

@ -0,0 +1,13 @@
ItemDef(
name: "Warlock Vest",
description: "Belong to a mighty warlock.",
kind: Armor(
(
kind: Chest("Warlock"),
stats: (
protection: Normal(40.0)
),
)
),
quality: Moderate,
)

View File

@ -0,0 +1,13 @@
ItemDef(
name: "Warlord Cuirass",
description: "Belong to a mighty warlord.",
kind: Armor(
(
kind: Chest("Warlord"),
stats: (
protection: Normal(40.0)
),
)
),
quality: Moderate,
)

View File

@ -5,8 +5,8 @@ ItemDef(
(
kind: Foot("Assassin"),
stats: (
protection: Normal(1.0)
),
protection: Normal(4.0)
),
)
),
quality: Moderate,

View File

@ -0,0 +1,13 @@
ItemDef(
name: "Warlock Slippers",
description: "Belong to a mighty warlock.",
kind: Armor(
(
kind: Foot("Warlock"),
stats: (
protection: Normal(8.0)
),
)
),
quality: Moderate,
)

View File

@ -0,0 +1,13 @@
ItemDef(
name: "Warlord Feet",
description: "Belong to a mighty warlord.",
kind: Armor(
(
kind: Foot("Warlord"),
stats: (
protection: Normal(8.0)
),
)
),
quality: Moderate,
)

View File

@ -5,8 +5,8 @@ ItemDef(
(
kind: Hand("Assassin"),
stats: (
protection: Normal(2.0)
),
protection: Normal(6.0)
),
)
),
quality: Moderate,

View File

@ -0,0 +1,12 @@
ItemDef(
name: "Warlock Gloves",
description: "Belong to a mighty warlock.",
kind: Armor(
(
kind: Hand("Warlock"),
stats: (
protection: Normal(15.0)),
)
),
quality: Common,
)

View File

@ -0,0 +1,12 @@
ItemDef(
name: "Warlord Handguards",
description: "Belong to a mighty warlord.",
kind: Armor(
(
kind: Hand("Warlord"),
stats: (
protection: Normal(15.0)),
)
),
quality: Common,
)

View File

@ -0,0 +1,12 @@
ItemDef(
name: "Warlock",
description: "Belong to a mighty warlock.",
kind: Armor(
(
kind: Head("Warlock"),
stats: (
protection: Normal(10.0)),
)
),
quality: Common,
)

View File

@ -0,0 +1,12 @@
ItemDef(
name: "Warlord Helmet",
description: "Belong to a mighty warlord.",
kind: Armor(
(
kind: Head("Warlord"),
stats: (
protection: Normal(10.0)),
)
),
quality: Common,
)

View File

@ -5,8 +5,8 @@ ItemDef(
(
kind: Pants("Assassin"),
stats: (
protection: Normal(5.0)
),
protection: Normal(10.0)
),
)
),
quality: Moderate,

View File

@ -0,0 +1,13 @@
ItemDef(
name: "Warlock Kilt",
description: "Belong to a mighty warlock.",
kind: Armor(
(
kind: Pants("Warlock"),
stats: (
protection: Normal(30.0)
),
)
),
quality: Moderate,
)

View File

@ -0,0 +1,13 @@
ItemDef(
name: "Warlord Legguards",
description: "Belong to a mighty warlord.",
kind: Armor(
(
kind: Pants("Warlord"),
stats: (
protection: Normal(30.0)
),
)
),
quality: Moderate,
)

View File

@ -5,8 +5,8 @@ ItemDef(
(
kind: Shoulder("Assassin"),
stats: (
protection: Normal(3.0)
),
protection: Normal(8.0)
),
)
),
quality: Moderate,

View File

@ -0,0 +1,12 @@
ItemDef(
name: "Warlock Shoulders",
description: "Belong to a mighty warlock.",
kind: Armor(
(
kind: Shoulder("Warlock"),
stats: (
protection: Normal(22.0)),
)
),
quality: Common,
)

View File

@ -0,0 +1,12 @@
ItemDef(
name: "Warlord Shoulderguards",
description: "Belong to a mighty warlord.",
kind: Armor(
(
kind: Shoulder("Warlord"),
stats: (
protection: Normal(22.0)),
)
),
quality: Common,
)

View File

@ -0,0 +1,12 @@
ItemDef(
name: "Blue Traveler Coat",
description: "",
kind: Armor(
(
kind: Back("LeatherBlue0"),
stats: (
protection: Normal(1.0)),
)
),
quality: Moderate,
)

View File

@ -0,0 +1,12 @@
ItemDef(
name: "Blue Leather Cuirass",
description: "",
kind: Armor(
(
kind: Chest("LeatherBlue0"),
stats: (
protection: Normal(5.0)),
)
),
quality: Moderate,
)

View File

@ -0,0 +1,12 @@
ItemDef(
name: "Blue Leather Guards",
description: "",
kind: Armor(
(
kind: Pants("LeatherBlue0"),
stats: (
protection: Normal(10.0)),
)
),
quality: Low,
)

BIN
assets/voxygen/element/icons/m2.png (Stored with Git LFS)

Binary file not shown.

BIN
assets/voxygen/element/icons/m_move.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/icons/m_scroll.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/map/castle.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/map/castle_bg.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/map/castle_hover.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/map/dif_0.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/map/dif_1.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/map/dif_2.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/map/dif_3.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/map/dif_4.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/map/dif_5.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/map/dungeon.png (Stored with Git LFS)

Binary file not shown.

BIN
assets/voxygen/element/map/dungeon_bg.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/map/dungeon_bg2.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/map/dungeon_hover.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/map/town.png (Stored with Git LFS)

Binary file not shown.

BIN
assets/voxygen/element/map/town_bg.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/map/town_hover.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/misc_bg/map_bg.png (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

View File

@ -400,8 +400,17 @@ magischen Gegenstände ergattern?"#,
"hud.free_look_indicator": "Freie Sicht aktiv",
"hud.auto_walk_indicator": "Automatisches Laufen aktiv",
"hud.map.difficulty": "Schwierigkeit",
"hud.map.towns": "Dörfer",
"hud.map.castles": "Festungen",
"hud.map.dungeons": "Dungeons",
"hud.map.town": "Dorf",
"hud.map.castle": "Festung",
"hud.map.dungeon": "Dungeon",
"hud.map.difficulty_dungeon": "Dungeon\n\nSchwierigkeit: {difficulty}",
"hud.map.drag": "Ziehen",
"hud.map.zoom": "Zoomen",
"hud.map.recenter": "Zurücksetzen",
/// End HUD section
/// Start GameInput section
@ -530,7 +539,7 @@ Willenskraft
"NPCs mit demselben Level können unterschiedlich schwierig zu besiegen sein.",
"Behaltet den Boden um euch im Blick! Dort gibt es Nahrung, Kisten und Anderes zu finden.",
"Ist Euer Inventar voll mit Nahrung? Wertet es einfach durch Crafting auf!",
"Ihr sucht nach einem Abenteuer? Dungeons sind mit braunen Markierungen auf der Karte vermerkt!",
"Ihr sucht nach einem Abenteuer? Dungeons sind mit Markierungen auf der Karte vermerkt!",
"Vergesst nicht Eure Grafikeinstellungen anzupassen! Mit 'N' kommt ihr in die Einstellungen.",
"Zusammen kämpfen macht mehr Spaß! Drückt 'O' um Eure Mitspieler anzuzeigen.",
"Ein NPC mit einem Schädel unter seiner Lebensanzeige ist deutlich stärker als Ihr.",

View File

@ -335,6 +335,7 @@ magically infused items?"#,
"hud.settings.maximum_fps": "Maximum FPS",
"hud.settings.fov": "Field of View (deg)",
"hud.settings.gamma": "Gamma",
"hud.settings.exposure": "Exposure",
"hud.settings.ambiance": "Ambiance Brightness",
"hud.settings.antialiasing_mode": "AntiAliasing Mode",
"hud.settings.upscale_factor": "Upscale Factor",
@ -346,6 +347,7 @@ magically infused items?"#,
"hud.settings.cloud_rendering_mode.low": "Low",
"hud.settings.cloud_rendering_mode.medium": "Medium",
"hud.settings.cloud_rendering_mode.high": "High",
"hud.settings.cloud_rendering_mode.ultra": "Ultra",
"hud.settings.fullscreen": "Fullscreen",
"hud.settings.fullscreen_mode": "Fullscreen Mode",
"hud.settings.fullscreen_mode.exclusive": "Exclusive",
@ -412,6 +414,18 @@ magically infused items?"#,
"hud.free_look_indicator": "Free look active. Press {key} to disable.",
"hud.auto_walk_indicator": "Auto walk active",
"hud.map.difficulty": "Difficulty",
"hud.map.towns": "Towns",
"hud.map.castles": "Castles",
"hud.map.dungeons": "Dungeons",
"hud.map.town": "Town",
"hud.map.castle": "Castle",
"hud.map.dungeon": "Dungeon",
"hud.map.difficulty_dungeon": "Dungeon\n\nDifficulty: {difficulty}",
"hud.map.drag": "Drag",
"hud.map.zoom": "Zoom",
"hud.map.recenter": "Recenter",
/// End HUD section
@ -551,7 +565,7 @@ Protection
"NPCs with the same level can have a different difficulty.",
"Keep an eye out for food, chests and other loot spread all around the world!",
"Inventory filled with food? Try crafting better food from it!",
"Wondering what's there to do? Dungeons are marked with brown spots on the map!",
"Wondering what's there to do? Try out one of the dungeons marked on the map!",
"Don't forget to adjust the graphics for your system. Press 'N' to open the settings.",
"Playing with others is fun! Press 'O' to see who is online.",
"An NPC with a skull beneath their healthbar is quite powerful compared to yourself.",

View File

@ -1198,6 +1198,56 @@
"voxel.armor.shoulder.bonerattler_right",
(0.0, 0.0, 0.0), (-90.0, 130.0, 0.0), 1.2,
),
//Warlord Set
Armor(Chest("Warlord")): VoxTrans(
"voxel.armor.chest.warlord",
(0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2,
),
Armor(Pants("Warlord")): VoxTrans(
"voxel.armor.pants.warlord",
(0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2,
),
Armor(Belt("Warlord")): VoxTrans(
"voxel.armor.belt.warlord",
(0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.4,
),
Armor(Foot("Warlord")): VoxTrans(
"voxel.armor.foot.warlord",
(0.0, 0.0, 0.0), (-95.0, 140.0, 0.0), 1.1,
),
Armor(Hand("Warlord")): VoxTrans(
"voxel.armor.hand.warlord_right",
(0.0, -1.0, 0.0), (-90.0, 135.0, 0.0), 1.0,
),
Armor(Shoulder("Warlord")): VoxTrans(
"voxel.armor.shoulder.warlord_right",
(0.0, 0.0, 0.0), (-90.0, 130.0, 0.0), 1.2,
),
//Warlock Set
Armor(Chest("Warlock")): VoxTrans(
"voxel.armor.chest.warlock",
(0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2,
),
Armor(Pants("Warlock")): VoxTrans(
"voxel.armor.pants.warlock",
(0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.2,
),
Armor(Belt("Warlock")): VoxTrans(
"voxel.armor.belt.warlock",
(0.0, 0.0, 0.0), (-90.0, 180.0, 0.0), 1.4,
),
Armor(Foot("Warlock")): VoxTrans(
"voxel.armor.foot.warlock",
(0.0, 0.0, 0.0), (-95.0, 140.0, 0.0), 1.1,
),
Armor(Hand("Warlock")): VoxTrans(
"voxel.armor.hand.warlock_right",
(0.0, -1.0, 0.0), (-90.0, 135.0, 0.0), 1.0,
),
Armor(Shoulder("Warlock")): VoxTrans(
"voxel.armor.shoulder.warlock_right",
(0.0, 0.0, 0.0), (-90.0, 130.0, 0.0), 1.2,
),
//misc
Armor(Pants("Hunting")): VoxTrans(
"voxel.armor.pants.grayscale",
@ -1232,6 +1282,14 @@
"voxel.armor.back.backpack-0",
(0.0, 0.0, 0.0), (-90.0, 0.0, 0.0), 1.0,
),
Armor(Back("Warlord")): VoxTrans(
"voxel.armor.back.warlord",
(0.0, 0.0, 0.0), (-90.0, 0.0, 0.0), 1.0,
),
Armor(Back("Warlock")): VoxTrans(
"voxel.armor.back.warlock",
(0.0, 0.0, 0.0), (-90.0, 0.0, 0.0), 1.0,
),
// Rings
Armor(Ring("Ring0")): VoxTrans(
"voxel.armor.ring.simple_purp-0",

View File

@ -49,6 +49,7 @@ layout (std140)
uniform u_locals {
mat4 model_mat;
vec4 highlight_col;
vec4 model_light;
ivec4 atlas_offs;
vec3 model_pos;
// bit 0 - is player
@ -82,13 +83,8 @@ void main() {
// vec3 f_col = f_col_light.rgb;
// float f_ao = f_col_light.a;
// vec2 f_uv_pos = f_uv_pos + atlas_offs.xy;
vec4 f_col_light = texelFetch(t_col_light, ivec2(f_uv_pos)/* + uv_delta*//* - f_norm * 0.00001*/, 0);
// vec4 f_col_light = texelFetch(t_col_light, ivec2(int(f_uv_pos.x), int(f_uv_pos.y)/* + uv_delta*//* - f_norm * 0.00001*/), 0);
vec3 f_col = /*linear_to_srgb*//*srgb_to_linear*/(f_col_light.rgb);
// vec3 f_col = vec3(1.0);
// vec2 texSize = textureSize(t_col_light, 0);
float f_ao = texture(t_col_light, (f_uv_pos + 0.5) / textureSize(t_col_light, 0)).a;//1.0;//f_col_light.a * 4.0;// f_light = float(v_col_light & 0x3Fu) / 64.0;
float f_ao, f_glow;
vec3 f_col = greedy_extract_col_light_glow(t_col_light, f_uv_pos, f_ao, f_glow);
// float /*f_light*/f_ao = textureProj(t_col_light, vec3(f_uv_pos, texSize)).a;//1.0;//f_col_light.a * 4.0;// f_light = float(v_col_light & 0x3Fu) / 64.0;
// vec3 my_chunk_pos = (vec3((uvec3(f_pos_norm) >> uvec3(0, 9, 18)) & uvec3(0x1FFu)) - 256.0) / 2.0;
@ -164,6 +160,10 @@ void main() {
vec3 emitted_light, reflected_light;
// Make voxel shadows block the sun and moon
sun_info.block *= model_light.x;
moon_info.block *= model_light.x;
// vec3 light_frac = /*vec3(1.0);*//*vec3(max(dot(f_norm, -sun_dir) * 0.5 + 0.5, 0.0));*/light_reflection_factor(f_norm, view_dir, vec3(0, 0, -1.0), vec3(1.0), vec3(R_s), alpha);
// vec3 point_light = light_at(f_pos, f_norm);
// vec3 light, diffuse_light, ambient_light;
@ -181,6 +181,9 @@ void main() {
float ao = f_ao * sqrt(f_ao);//0.25 + f_ao * 0.75; ///*pow(f_ao, 0.5)*/f_ao * 0.85 + 0.15;
vec3 glow = pow(model_light.y, 3) * 4 * GLOW_COLOR;
emitted_light += glow;
reflected_light *= ao;
emitted_light *= ao;
/* reflected_light *= cloud_shadow(f_pos); */

View File

@ -27,6 +27,7 @@ layout (std140)
uniform u_locals {
mat4 model_mat;
vec4 highlight_col;
vec4 model_light;
ivec4 atlas_offs;
vec3 model_pos;
// bit 0 - is player

View File

@ -179,12 +179,12 @@ void main() {
// float reflected_light_point = /*length*/(diffuse_light_point.r) + f_light * point_shadow;
// reflected_light += k_d * (diffuse_light_point + f_light * point_shadow * shade_frac) + specular_light_point;
float passthrough = /*pow(*/dot(cam_norm, -cam_to_frag/*view_dir*/)/*, 0.5)*/;
float passthrough = clamp(dot(cam_norm, -cam_to_frag) * 1.0 - 0.2, 0, 1);
float min_refl = min(emitted_light.r, min(emitted_light.g, emitted_light.b));
vec3 surf_color = illuminate(max_light, view_dir, water_color * /* fog_color * */emitted_light, /*surf_color * */water_color * reflected_light);
// vec4 color = vec4(surf_color, passthrough * 1.0 / (1.0 + min_refl));// * (1.0 - /*log(1.0 + cam_attenuation)*//*cam_attenuation*/1.0 / (2.0 - log_cam)));
vec4 color = mix(vec4(surf_color, 1.0), vec4(surf_color, 1.0 / (1.0 + /*diffuse_light*//*(f_light * point_shadow + point_light)*//*4.0 * reflected_light_point*/min_refl/* * 0.25*/)), passthrough);
vec4 color = vec4(surf_color, (1.0 - passthrough) * 1.0 / (1.0 + min_refl));
tgt_color = color;
}

View File

@ -77,13 +77,13 @@ float wave_height(vec3 pos) {
);
float height = (
(texture(t_noise, pos.xy * 0.03 + big_warp.xy + timer * 0.05).y - 0.5) * 1.0 +
(texture(t_noise, pos.yx * 0.03 + big_warp.yx - timer * 0.05).y - 0.5) * 1.0 +
(texture(t_waves, pos.xy * 0.1 + warp.xy + timer * 0.1).x - 0.5) * 0.5 +
(texture(t_waves, pos.yx * 0.1 + warp.yx - timer * 0.1).x - 0.5) * 0.5 +
(texture(t_noise, pos.yx * 0.3 + warp.xy * 0.5 + timer * 0.1).x - 0.5) * 0.2 +
(texture(t_noise, pos.yx * 0.3 + warp.yx * 0.5 - timer * 0.1).x - 0.5) * 0.2 +
(texture(t_noise, pos.yx * 1.0 + warp.yx * 0.0 - timer * 0.1).x - 0.5) * 0.05 +
(texture(t_noise, (pos.xy + pos.z) * 0.03 + big_warp.xy + timer * 0.05).y - 0.5) * 1.0 +
(texture(t_noise, (pos.yx + pos.z) * 0.03 + big_warp.yx - timer * 0.05).y - 0.5) * 1.0 +
(texture(t_waves, (pos.xy + pos.z) * 0.1 + warp.xy + timer * 0.1).x - 0.5) * 0.5 +
(texture(t_waves, (pos.yx + pos.z) * 0.1 + warp.yx - timer * 0.1).x - 0.5) * 0.5 +
(texture(t_noise, (pos.yx + pos.z) * 0.3 + warp.xy * 0.5 + timer * 0.1).x - 0.5) * 0.2 +
(texture(t_noise, (pos.xy + pos.z) * 0.3 + warp.yx * 0.5 - timer * 0.1).x - 0.5) * 0.2 +
(texture(t_noise, (pos.yx + pos.z) * 1.0 + warp.yx * 0.0 - timer * 0.1).x - 0.5) * 0.05 +
0.0
);
@ -99,7 +99,9 @@ void main() {
// Increase array access by 3 to access positive values
uint norm_dir = ((f_pos_norm >> 29) & 0x1u) * 3u;
// Use an array to avoid conditional branching
vec3 f_norm = normals[norm_axis + norm_dir];
// Temporarily assume all water faces up (this is incorrect but looks better)
vec3 f_norm = vec3(0, 0, 1);//normals[norm_axis + norm_dir];
vec3 cam_to_frag = normalize(f_pos - cam_pos.xyz);
// vec4 light_pos[2];
//#if (SHADOW_MODE == SHADOW_MODE_MAP)
@ -111,7 +113,6 @@ void main() {
// vec4 sun_pos = vec4(0.0);
//#endif
vec3 cam_to_frag = normalize(f_pos - cam_pos.xyz);
// vec4 vert_pos4 = view_mat * vec4(f_pos, 1.0);
// vec3 view_dir = normalize(-vec3(vert_pos4)/* / vert_pos4.w*/);
vec3 view_dir = -cam_to_frag;
@ -145,6 +146,7 @@ void main() {
nmap = mix(f_norm, normalize(nmap), min(1.0 / pow(frag_dist, 0.75), 1));
//float suppress_waves = max(dot(), 0);
vec3 norm = vec3(0, 0, 1) * nmap.z + b_norm * nmap.x + c_norm * nmap.y;
// vec3 norm = f_norm;
@ -176,8 +178,8 @@ void main() {
// vec3 cam_to_frag = normalize(f_pos - cam_pos.xyz);
// Squared to account for prior saturation.
float f_light = 1.0;// pow(f_light, 1.5);
vec3 reflect_color = get_sky_color(/*reflect_ray_dir*/beam_view_dir, time_of_day.x, f_pos, vec3(-100000), 0.25, true);
reflect_color = get_cloud_color(reflect_color, reflect_ray_dir, cam_pos.xyz, time_of_day.x, 100000.0, 1.0);
vec3 reflect_color = get_sky_color(/*reflect_ray_dir*/beam_view_dir, time_of_day.x, f_pos, vec3(-100000), 0.125, true);
reflect_color = get_cloud_color(reflect_color, reflect_ray_dir, cam_pos.xyz, time_of_day.x, 100000.0, 0.25);
reflect_color *= f_light;
// /*const */vec3 water_color = srgb_to_linear(vec3(0.2, 0.5, 1.0));
// /*const */vec3 water_color = srgb_to_linear(vec3(0.8, 0.9, 1.0));
@ -289,7 +291,8 @@ void main() {
// diffuse_light += point_light;
// reflected_light += point_light;
// vec3 surf_color = srgb_to_linear(vec3(0.2, 0.5, 1.0)) * light * diffuse_light * ambient_light;
vec3 surf_color = illuminate(max_light, view_dir, water_color * emitted_light/* * log(1.0 - MU_WATER)*/, /*cam_attenuation * *//*water_color * */reflect_color * reflected_light/* * log(1.0 - MU_WATER)*/);
const float REFLECTANCE = 0.5;
vec3 surf_color = illuminate(max_light, view_dir, water_color * emitted_light/* * log(1.0 - MU_WATER)*/, /*cam_attenuation * *//*water_color * */reflect_color * REFLECTANCE/** reflected_light*//* * log(1.0 - MU_WATER)*/);
// passthrough = pow(passthrough, 1.0 / (1.0 + water_depth_to_camera));
/* surf_color = cam_attenuation.g < 0.5 ?

View File

@ -7,66 +7,114 @@ const float CLOUD_DENSITY = 150.0;
vec2 get_cloud_heights(vec2 pos) {
const float CLOUD_HALF_WIDTH = 300;
const float CLOUD_HEIGHT_VARIATION = 1000.0;
float cloud_alt = CLOUD_AVG_ALT + (texture(t_noise, pos.xy * 0.0001).x - 0.5) * CLOUD_HEIGHT_VARIATION;
#if (CLOUD_MODE != CLOUD_MODE_MINIMAL)
const float CLOUD_HEIGHT_VARIATION = 1500.0;
float cloud_alt = CLOUD_AVG_ALT + (texture(t_noise, pos.xy * 0.00005).x - 0.5) * CLOUD_HEIGHT_VARIATION;
#if (CLOUD_MODE > CLOUD_MODE_MINIMAL)
cloud_alt += (texture(t_noise, pos.xy * 0.001).x - 0.5) * 0.1 * CLOUD_HEIGHT_VARIATION;
#endif
return vec2(cloud_alt, CLOUD_HALF_WIDTH);
}
float emission_strength = clamp((sin(time_of_day.x / (3600 * 24)) - 0.8) / 0.1, 0, 1);
// Returns vec4(r, g, b, density)
vec3 cloud_at(vec3 pos, float dist) {
vec4 cloud_at(vec3 pos, float dist, out vec3 emission) {
// Natural attenuation of air (air naturally attenuates light that passes through it)
// Simulate the atmosphere thinning above 3000 metres down to nothing at 5000 metres
float air = 0.00005 * clamp((3000.0 - pos.z) / 2000, 0, 1);
// Simulate the atmosphere thinning as you get higher. Not physically accurate, but then
// it can't be since Veloren's world is flat, not spherical.
float air = 0.00035 * clamp((10000.0 - pos.z) / 7000, 0, 1);
// Mist sits close to the ground in valleys (TODO: use base_alt to put it closer to water)
float MIST_MIN = 300;
const float MIST_FADE_HEIGHT = 250;
float mist = 0.00025 * pow(clamp(1.0 - (pos.z - MIST_MIN) / MIST_FADE_HEIGHT, 0.0, 1), 2) / (1.0 + pow(1.0 + dist / 20000.0, 2.0));
float mist_min_alt = 0.5;
#if (CLOUD_MODE > CLOUD_MODE_LOW)
mist_min_alt = (texture(t_noise, pos.xy * 0.00015).x - 0.5) * 1.25 + 0.5;
#endif
mist_min_alt *= 250;
const float MIST_FADE_HEIGHT = 500;
float mist = 0.005 * pow(clamp(1.0 - (pos.z - mist_min_alt) / MIST_FADE_HEIGHT, 0.0, 1), 4.0) / (1.0 + pow(1.0 + dist / 20000.0, 2.0));
vec3 wind_pos = vec3(pos.xy + wind_offset, pos.z);
// Clouds
float cloud_tendency = cloud_tendency_at(pos.xy);
float sun_access = 0.05;
float cloud = 0;
vec2 cloud_attr = get_cloud_heights(wind_pos.xy);
float cloud_factor = 0.0;
float turb_noise = 0.0;
float sun_access = 0.0;
float moon_access = 0.0;
// This is a silly optimisation but it actually nets us a fair few fps by skipping quite a few expensive calcs
if (cloud_tendency > 0 || mist > 0.0) {
// Turbulence (small variations in clouds/mist)
const float turb_speed = -1.0; // Turbulence goes the opposite way
vec3 turb_offset = vec3(1, 1, 0) * time_of_day.x * turb_speed;
#if (CLOUD_MODE == CLOUD_MODE_MINIMAL)
float turb_noise = 0.0;
#else
float turb_noise = noise_3d((wind_pos + turb_offset) * 0.001) - 0.5;
#if (CLOUD_MODE >= CLOUD_MODE_MINIMAL)
turb_noise = noise_3d((wind_pos + turb_offset) * 0.001) - 0.5;
#endif
#if (CLOUD_MODE == CLOUD_MODE_MEDIUM || CLOUD_MODE == CLOUD_MODE_HIGH)
turb_noise += (noise_3d((wind_pos + turb_offset * 0.3) * 0.004) - 0.5) * 0.25;
#if (CLOUD_MODE >= CLOUD_MODE_MEDIUM)
turb_noise += (noise_3d((wind_pos + turb_offset * 0.3) * 0.004) - 0.5) * 0.35;
#endif
mist *= (1.0 + turb_noise);
#if (CLOUD_MODE >= CLOUD_MODE_HIGH)
turb_noise += (noise_3d((wind_pos + turb_offset * 0.3) * 0.01) - 0.5) * 0.125;
#endif
mist *= 1.0 + turb_noise;
cloud_factor = 0.25 * (1.0 - pow(min(abs(pos.z - cloud_attr.x) / (cloud_attr.y * pow(max(cloud_tendency * 20.0, 0), 0.5)), 1.0), 2.0));
cloud_factor = 0.25 * (1.0 - pow(min(abs(pos.z - cloud_attr.x) / (cloud_attr.y * pow(max(cloud_tendency * 20.0, 0), 0.5)), 1.0), 1.0));
float cloud_flat = min(cloud_tendency, 0.07) * 0.05;
cloud_flat *= (1.0 + turb_noise * 7.0 * max(0, 1.0 - cloud_factor * 5));
cloud = cloud_flat * pow(cloud_factor, 2) * 20 / (1 + pow(1.0 + dist / 10000.0, 2.0));
cloud = cloud_flat * pow(cloud_factor, 2) * 20;
// What proportion of sunlight is *not* being blocked by nearby cloud? (approximation)
sun_access = clamp((pos.z - cloud_attr.x + turb_noise * 250.0) * 0.002 + 0.35 + max(mist * 20000, 0), 0, 1);
// Since we're assuming the sun/moon is always above (not always correct) it's the same for the moon
moon_access = sun_access;
#if (CLOUD_MODE >= CLOUD_MODE_HIGH)
// Try to calculate a reasonable approximation of the cloud normal
float cloud_tendency_x = cloud_tendency_at(pos.xy + vec2(100, 0));
float cloud_tendency_y = cloud_tendency_at(pos.xy + vec2(0, 100));
vec3 cloud_norm = vec3(
(cloud_tendency - cloud_tendency_x) * 4,
(cloud_tendency - cloud_tendency_y) * 4,
(pos.z - cloud_attr.x) / 250 + turb_noise + 0.25
);
sun_access = mix(max(dot(-sun_dir.xyz, cloud_norm) + 0.0, 0.025), sun_access, 0.25);
moon_access = mix(max(dot(-moon_dir.xyz, cloud_norm) + 0.35, 0.025), moon_access, 0.25);
#endif
}
// What proportion of sunlight is *not* being blocked by nearby cloud? (approximation)
sun_access = clamp((pos.z - cloud_attr.x) * 0.002 + 0.35 + mist * 10000, 0.0, 1);
// Prevent mist (i.e: vapour beneath clouds) being accessible to the sun to avoid visual problems
//float suppress_mist = clamp((pos.z - cloud_attr.x + cloud_attr.y) / 300, 0, 1);
//sun_access *= suppress_mist;
//moon_access *= suppress_mist;
// Prevent clouds and mist appearing underground (but fade them out gently)
float not_underground = clamp(1.0 - (alt_at(pos.xy - focus_off.xy) - (pos.z - focus_off.z)) / 80.0, 0, 1);
air *= not_underground;
float vapor_density = (mist + cloud) * not_underground;
if (emission_strength <= 0.0) {
emission = vec3(0);
} else {
float z = clamp(pos.z, 0, 10000);
float emission_alt = 4000.0;
#if (CLOUD_MODE >= CLOUD_MODE_LOW)
emission_alt += (noise_3d(vec3(wind_pos.xy * 0.00003 + cloud_tendency * 0.2, time_of_day.x * 0.0001)) - 0.5) * 6000;
#endif
float tail = (texture(t_noise, wind_pos.xy * 0.00005).x - 0.5) * 10 + (z - emission_alt) * 0.001;
vec3 emission_col = vec3(0.6 + tail * 0.6, 1.0, 0.3 + tail * 0.2);
float emission_nz = max(texture(t_noise, wind_pos.xy * 0.00003).x - 0.6, 0) / (10.0 + abs(z - emission_alt) / 40);
#if (CLOUD_MODE >= CLOUD_MODE_MEDIUM)
emission_nz *= (1.0 + (noise_3d(vec3(wind_pos.xy * 0.05, time_of_day.x * 0.15) * 0.004) - 0.5) * 4.0);
#endif
emission = emission_col * emission_nz * emission_strength * max(sun_dir.z, 0) * 20;
}
// We track vapor density and air density separately. Why? Because photons will ionize particles in air
// leading to rayleigh scattering, but water vapor will not. Tracking these indepedently allows us to
// get more correct colours.
return vec3(sun_access, vapor_density, air);
return vec4(sun_access, moon_access, vapor_density, air);
}
float atan2(in float y, in float x) {
@ -75,24 +123,26 @@ float atan2(in float y, in float x) {
}
const float DIST_CAP = 50000;
#if (CLOUD_MODE == CLOUD_MODE_HIGH)
const uint QUALITY = 100u;
#if (CLOUD_MODE == CLOUD_MODE_ULTRA)
const uint QUALITY = 200u;
#elif (CLOUD_MODE == CLOUD_MODE_HIGH)
const uint QUALITY = 50u;
#elif (CLOUD_MODE == CLOUD_MODE_MEDIUM)
const uint QUALITY = 40u;
const uint QUALITY = 30u;
#elif (CLOUD_MODE == CLOUD_MODE_LOW)
const uint QUALITY = 20u;
const uint QUALITY = 16u;
#elif (CLOUD_MODE == CLOUD_MODE_MINIMAL)
const uint QUALITY = 7u;
const uint QUALITY = 5u;
#endif
const float STEP_SCALE = DIST_CAP / (10.0 * float(QUALITY));
float step_to_dist(float step) {
return pow(step, 2) * STEP_SCALE;
float step_to_dist(float step, float quality) {
return pow(step, 2) * STEP_SCALE / quality;
}
float dist_to_step(float dist) {
return pow(dist / STEP_SCALE, 0.5);
float dist_to_step(float dist, float quality) {
return pow(dist / STEP_SCALE * quality, 0.5);
}
vec3 get_cloud_color(vec3 surf_color, vec3 dir, vec3 origin, const float time_of_day, float max_dist, const float quality) {
@ -107,47 +157,51 @@ vec3 get_cloud_color(vec3 surf_color, vec3 dir, vec3 origin, const float time_of
vec3 dir_diff = vec3(0);
#if (CLOUD_MODE == CLOUD_MODE_MINIMAL)
/* splay += (texture(t_noise, vec2(atan2(dir.x, dir.y) * 2 / PI, dir.z) * 1.5 - time_of_day * 0.000025).x - 0.5) * 0.4 / (1.0 + pow(dir.z, 2) * 10); */
dir_diff = vec3(
(texture(t_noise, vec2(atan2(dir.x, dir.y) * 2 / PI, dir.z) * 1.0 - time_of_day * 0.00005).x - 0.5) * 0.2 / (1.0 + pow(dir.z, 2) * 10),
(texture(t_noise, vec2(atan2(dir.x, dir.y) * 2 / PI, dir.z) * 1.0 - time_of_day * 0.00005).x - 0.5) * 0.2 / (1.0 + pow(dir.z, 2) * 10),
(texture(t_noise, vec2(atan2(dir.x, dir.y) * 2 / PI, dir.z) * 1.0 - time_of_day * 0.00005).x - 0.5) * 0.2 / (1.0 + pow(dir.z, 2) * 10)
) * 2000;
#endif
#if (CLOUD_MODE == CLOUD_MODE_MINIMAL || CLOUD_MODE == CLOUD_MODE_LOW)
splay += (texture(t_noise, vec2(atan2(dir.x, dir.y) * 2 / PI, dir.z) * 10.0 - time_of_day * 0.00005).x - 0.5) * 0.075 / (1.0 + pow(dir.z, 2) * 10);
/* dir_diff = vec3( */
/* (texture(t_noise, vec2(atan2(dir.x, dir.y) * 2 / PI, dir.z) * 1.0 - time_of_day * 0.00005).x - 0.5) * 0.2 / (1.0 + pow(dir.z, 2) * 10), */
/* (texture(t_noise, vec2(atan2(dir.x, dir.y) * 2 / PI, dir.z) * 1.0 - time_of_day * 0.00005).x - 0.5) * 0.2 / (1.0 + pow(dir.z, 2) * 10), */
/* (texture(t_noise, vec2(atan2(dir.x, dir.y) * 2 / PI, dir.z) * 1.0 - time_of_day * 0.00005).x - 0.5) * 0.2 / (1.0 + pow(dir.z, 2) * 10) */
/* ) * 1500; */
splay += (texture(t_noise, vec2(atan2(dir.x, dir.y) * 2 / PI, dir.z) * 5.0 - time_of_day * 0.00005).x - 0.5) * 0.075 / (1.0 + pow(dir.z, 2) * 10);
#endif
// Proportion of sunlight that get scattered back into the camera by clouds
float sun_scatter = max(dot(-dir, sun_dir.xyz), 0.5);
float moon_scatter = max(dot(-dir, moon_dir.xyz), 0.5);
vec3 sky_color = get_sky_color();
vec3 directed_scatter =
// Sun scatter
get_sun_color() * get_sun_brightness() * sun_scatter +
// Moon scatter
get_moon_color() * get_moon_brightness() * moon_scatter;
float net_light = get_sun_brightness() + get_moon_brightness();
float cdist = max_dist;
while (cdist > 1) {
float ndist = step_to_dist(trunc(dist_to_step(cdist - 0.25)));
vec3 sample = cloud_at(origin + (dir + dir_diff / ndist) * ndist * splay, ndist);
float ldist = cdist;
// i is an emergency brake
float min_dist = clamp(max_dist / 4, 0.25, 24);
for (int i = 0; cdist > min_dist && i < 250; i ++) {
ldist = cdist;
cdist = step_to_dist(trunc(dist_to_step(cdist - 0.25, quality)), quality);
vec2 density_integrals = max(sample.yz, vec2(0)) * (cdist - ndist);
vec3 emission;
vec4 sample = cloud_at(origin + (dir + dir_diff / ldist) * ldist * splay, cdist, emission);
vec2 density_integrals = max(sample.zw, vec2(0)) * (ldist - cdist);
float sun_access = sample.x;
float moon_access = sample.y;
float scatter_factor = 1.0 - 1.0 / (1.0 + density_integrals.x);
surf_color =
// Attenuate light passing through the clouds, removing light due to rayleigh scattering (transmission component)
surf_color * (1.0 - scatter_factor) - surf_color * density_integrals.y * sky_color +
// This is not rayleigh scattering, but it's good enough for our purposes
sky_color * density_integrals.y +
// Add the directed light light scattered into the camera by the clouds
directed_scatter * sun_access * scatter_factor +
// Global illumination (uniform scatter from the sky)
sky_color * sun_access * scatter_factor;
const float RAYLEIGH = 0.25;
cdist = ndist;
surf_color =
// Attenuate light passing through the clouds
surf_color * (1.0 - scatter_factor) +
// This is not rayleigh scattering, but it's good enough for our purposes (only considers sun)
(1.0 - surf_color) * net_light * sky_color * density_integrals.y * RAYLEIGH +
// Add the directed light light scattered into the camera by the clouds
get_sun_color() * sun_scatter * sun_access * scatter_factor * get_sun_brightness() +
get_moon_color() * moon_scatter * moon_access * scatter_factor * get_moon_brightness() +
emission * density_integrals.y +
// Global illumination (uniform scatter from the sky)
sky_color * sun_access * scatter_factor * get_sun_brightness() +
sky_color * moon_access * scatter_factor * get_moon_brightness();
}
return surf_color;

View File

@ -14,6 +14,7 @@
#define CLOUD_MODE_LOW 2
#define CLOUD_MODE_MEDIUM 3
#define CLOUD_MODE_HIGH 4
#define CLOUD_MODE_ULTRA 5
#define LIGHTING_ALGORITHM_LAMBERTIAN 0
#define LIGHTING_ALGORITHM_BLINN_PHONG 1

View File

@ -16,7 +16,7 @@ uniform u_globals {
vec4 shadow_proj_factors;
uvec4 medium;
ivec4 select_pos;
vec4 gamma;
vec4 gamma_exposure;
float ambiance;
// 0 - FirstPerson
// 1 - ThirdPerson

View File

@ -205,6 +205,9 @@ vec2 splay(vec2 pos) {
// /const float CBRT_2 = cbrt(2.0) / 2.0;
// vec2 splayed = pos * (view_distance.x * SQRT_2 + pow(len * 0.5, 3.0) * (SPLAY_MULT - view_distance.x));
vec2 splayed = pos * (view_distance.x * SQRT_2 + len_pow * (textureSize(t_alt, 0) * 32.0/* - view_distance.x*/));
if (abs(pos.x) > 0.99 || abs(pos.y) > 0.99) {
splayed *= 10.0;
}
return splayed;
// Radial: pos.x = r - view_distance.x from focus_pos, pos.y = θ from cam_pos to focus_pos on xy plane.

View File

@ -7,6 +7,8 @@
struct DirectionalLight {
// vec3 dir;
float shadow;
// Fully blocks all light, including ambience
float block;
// vec3 color;
// float brightness;
};
@ -16,19 +18,19 @@ const float PI = 3.141592;
const vec3 SKY_DAY_TOP = vec3(0.1, 0.5, 0.9);
const vec3 SKY_DAY_MID = vec3(0.02, 0.28, 0.8);
const vec3 SKY_DAY_BOT = vec3(0.1, 0.2, 0.3);
const vec3 DAY_LIGHT = vec3(1.9, 1.75, 0.9);//vec3(1.5, 1.4, 1.0);
const vec3 SUN_HALO_DAY = vec3(0.35, 0.35, 0.0);
const vec3 DAY_LIGHT = vec3(2.8, 3.5, 1.8);
const vec3 SUN_HALO_DAY = vec3(0.06, 0.06, 0.005);
const vec3 SKY_DUSK_TOP = vec3(0.06, 0.1, 0.20);
const vec3 SKY_DUSK_MID = vec3(0.35, 0.1, 0.15);
const vec3 SKY_DUSK_BOT = vec3(0.0, 0.1, 0.23);
const vec3 DUSK_LIGHT = vec3(9.0, 1.5, 0.15);
const vec3 SUN_HALO_DUSK = vec3(1.2, 0.25, 0.0);
const vec3 DUSK_LIGHT = vec3(8.0, 1.5, 0.15);
const vec3 SUN_HALO_DUSK = vec3(1.2, 0.15, 0.01);
const vec3 SKY_NIGHT_TOP = vec3(0.001, 0.001, 0.0025);
const vec3 SKY_NIGHT_MID = vec3(0.001, 0.005, 0.02);
const vec3 SKY_NIGHT_BOT = vec3(0.002, 0.004, 0.004);
const vec3 NIGHT_LIGHT = vec3(0.002, 0.02, 0.02);
const vec3 NIGHT_LIGHT = vec3(5.0, 0.75, 0.2);
// const vec3 NIGHT_LIGHT = vec3(0.0, 0.0, 0.0);
// Linear RGB, scattering coefficients for atmosphere at roughly R, G, B wavelengths.
@ -42,6 +44,9 @@ const float UNDERWATER_MIST_DIST = 100.0;
const float PERSISTENT_AMBIANCE = 1.0 / 32.0;// 1.0 / 80; // 1.0 / 512; // 0.00125 // 0.1;// 0.025; // 0.1;
// Allowed to be > 1 due to HDR
const vec3 GLOW_COLOR = vec3(2, 1.30, 0.1);
//vec3 get_sun_dir(float time_of_day) {
// const float TIME_FACTOR = (PI * 2.0) / (3600.0 * 24.0);
//
@ -70,11 +75,16 @@ const float wind_speed = 0.25;
vec2 wind_offset = vec2(time_of_day.x * wind_speed);
float cloud_tendency_at(vec2 pos) {
return clamp(texture(t_noise, (pos + wind_offset) * 0.000075).x - 0.5, 0, 1);
float nz = texture(t_noise, (pos + wind_offset) * 0.000075).x - 0.5;
nz = clamp(nz, 0, 1);
#if (CLOUD_MODE >= CLOUD_MODE_MEDIUM)
nz += (texture(t_noise, (pos + wind_offset) * 0.00035).x - 0.5) * 0.15;
#endif
return nz;
}
float cloud_shadow(vec3 pos, vec3 light_dir) {
#if (CLOUD_MODE == CLOUD_MODE_NONE || CLOUD_MODE == CLOUD_MODE_MINIMAL)
#if (CLOUD_MODE <= CLOUD_MODE_MINIMAL)
return 1.0;
#else
vec2 xy_offset = light_dir.xy * ((CLOUD_AVG_ALT - pos.z) / -light_dir.z);
@ -82,17 +92,20 @@ float cloud_shadow(vec3 pos, vec3 light_dir) {
// Fade out shadow if the sun angle is too steep (simulates a widening penumbra with distance)
const vec2 FADE_RANGE = vec2(1500, 10000);
float fade = 1.0 - clamp((length(xy_offset) - FADE_RANGE.x) / (FADE_RANGE.y - FADE_RANGE.x), 0, 1);
float cloud = cloud_tendency_at(pos.xy + focus_off.xy - xy_offset);
return max(0, 1 - fade * cloud_tendency_at(pos.xy + focus_off.xy - xy_offset) * 3.0);
cloud = cloud * 2.0;
return clamp(1 - fade * cloud * 1.65, 0, 1);
#endif
}
float get_sun_brightness(/*vec3 sun_dir*/) {
return max(-sun_dir.z + 0.6, 0.0) * 0.9;
return max(-sun_dir.z + 0.5, 0.0);
}
float get_moon_brightness(/*vec3 moon_dir*/) {
return max(-moon_dir.z + 0.6, 0.0) * 0.1;
return max(-moon_dir.z + 0.6, 0.0) * 0.2;
}
vec3 get_sun_color(/*vec3 sun_dir*/) {
@ -127,6 +140,7 @@ vec3 get_moon_color(/*vec3 moon_dir*/) {
DirectionalLight get_sun_info(vec4 _dir, float shade_frac/*, vec4 light_pos[2]*/, /*vec4 sun_pos*/vec3 f_pos) {
float shadow = shade_frac;
float block = 1.0;
#ifdef HAS_SHADOW_MAPS
#if (SHADOW_MODE == SHADOW_MODE_MAP)
if (sun_dir.z < /*0.6*/0.0) {
@ -143,15 +157,16 @@ DirectionalLight get_sun_info(vec4 _dir, float shade_frac/*, vec4 light_pos[2]*/
}
#endif
#endif
return DirectionalLight(/*dir, */shadow/*, get_sun_color(dir), get_sun_brightness(dir)*/);
return DirectionalLight(/*dir, */shadow, block/*, get_sun_color(dir), get_sun_brightness(dir)*/);
}
DirectionalLight get_moon_info(vec4 _dir, float shade_frac/*, vec4 light_pos[2]*/) {
float shadow = shade_frac;
float block = 1.0;
// #ifdef HAS_SHADOW_MAPS
// shadow = min(shade_frac, ShadowCalculationDirected(light_pos, 1u));
// #endif
return DirectionalLight(/*dir, */shadow/*, get_moon_color(dir), get_moon_brightness(dir)*/);
return DirectionalLight(/*dir, */shadow, block/*, get_moon_color(dir), get_moon_brightness(dir)*/);
}
// // Calculates extra emission and reflectance (due to sunlight / moonlight).
@ -219,8 +234,8 @@ float get_sun_diffuse2(DirectionalLight sun_info, DirectionalLight moon_info, ve
vec3 sun_dir = sun_dir.xyz;
vec3 moon_dir = moon_dir.xyz;
float sun_light = get_sun_brightness(/*sun_dir*/);//sun_info.brightness;;
float moon_light = get_moon_brightness(/*moon_dir*/);//moon_info.brightness;
float sun_light = get_sun_brightness(/*sun_dir*/) * sun_info.block;//sun_info.brightness;;
float moon_light = get_moon_brightness(/*moon_dir*/) * moon_info.block;//moon_info.brightness;
vec3 sun_color = get_sun_color(/*sun_dir*/) * SUN_COLOR_FACTOR;//sun_info.color * SUN_COLOR_FACTOR;
vec3 moon_color = get_moon_color(/*moon_dir*/);//moon_info.color;
@ -372,6 +387,7 @@ float get_sun_diffuse2(DirectionalLight sun_info, DirectionalLight moon_info, ve
// This has been extracted into a function to allow quick exit when detecting a star.
float is_star_at(vec3 dir) {
float star_scale = 80.0;
// Star positions
@ -384,11 +400,13 @@ float is_star_at(vec3 dir) {
float dist = length(pos - dir);
// Star threshold
if (dist < 0.0015) {
return 1.0;
}
//if (dist < 0.0015) {
// return 2.5;
//}
return 0.0;
//return 0.0;
return 1.0 / (1.0 + pow(dist * 1000, 8));
}
vec3 get_sky_color(vec3 dir, float time_of_day, vec3 origin, vec3 f_pos, float quality, bool with_features, float refractionIndex) {
@ -409,7 +427,7 @@ vec3 get_sky_color(vec3 dir, float time_of_day, vec3 origin, vec3 f_pos, float q
}
// Sun
const vec3 SUN_SURF_COLOR = vec3(1.5, 0.9, 0.35) * 200.0;
const vec3 SUN_SURF_COLOR = vec3(1.5, 0.9, 0.35) * 3.0;
vec3 sun_halo_color = mix(
SUN_HALO_DUSK,
@ -417,21 +435,24 @@ vec3 get_sky_color(vec3 dir, float time_of_day, vec3 origin, vec3 f_pos, float q
max(-sun_dir.z, 0.0)
);
vec3 sun_halo = pow(max(dot(dir, -sun_dir) + 0.1, 0.0), 8.0) * sun_halo_color;
vec3 sun_halo = sun_halo_color * 16 * pow(max(dot(dir, -sun_dir), 0), 8.0);
vec3 sun_surf = vec3(0);
if (with_features) {
sun_surf = pow(max(dot(dir, -sun_dir) - 0.001, 0.0), 5000.0) * SUN_SURF_COLOR * SUN_COLOR_FACTOR; // Hack to prevent sun vanishing too early
float angle = 0.00035;
sun_surf = clamp((dot(dir, -sun_dir) - (1.0 - angle)) * 4 / angle, 0, 1) * SUN_SURF_COLOR * SUN_COLOR_FACTOR;
}
vec3 sun_light = sun_halo + sun_surf;
// Moon
const vec3 MOON_SURF_COLOR = vec3(0.7, 1.0, 1.5) * 500.0;
const vec3 MOON_HALO_COLOR = vec3(0.015, 0.015, 0.05);
const vec3 MOON_SURF_COLOR = vec3(0.7, 1.0, 1.5) * 3.0;
const vec3 MOON_HALO_COLOR = vec3(0.015, 0.015, 0.05) * 25;
vec3 moon_halo = pow(max(dot(dir, -moon_dir) + 0.1, 0.0), 8.0) * MOON_HALO_COLOR;
vec3 moon_halo_color = MOON_HALO_COLOR;
vec3 moon_halo = moon_halo_color * pow(max(dot(dir, -moon_dir), 0), 500.0);
vec3 moon_surf = vec3(0);
if (with_features) {
moon_surf = pow(max(dot(dir, -moon_dir) - 0.001, 0.0), 5000.0) * MOON_SURF_COLOR; // Hack to prevent moon vanishing too early
float angle = 0.00035;
moon_surf = clamp((dot(dir, -moon_dir) - (1.0 - angle)) * 4 / angle, 0, 1) * MOON_SURF_COLOR;
}
vec3 moon_light = moon_halo + moon_surf;

View File

@ -617,3 +617,28 @@ vec3 compute_attenuation_point(vec3 wpos, vec3 ray_dir, vec3 mu, float surface_a
// return 1.0;
//}
//#endif
vec3 greedy_extract_col_light_glow(sampler2D t_col_light, vec2 f_uv_pos, out float f_light, out float f_glow) {
uvec4 f_col_light = uvec4(texelFetch(t_col_light, ivec2(f_uv_pos), 0) * 255);
vec3 f_col = vec3(
float(((f_col_light.r << 1u) & 0xFu) | (((f_col_light.b >> 4u) & 0xFu) << 4u)),
float(f_col_light.a),
float(((f_col_light.g << 1u) & 0xFu) | (((f_col_light.b >> 0u) & 0xFu) << 4u))
) / 255.0;
// TODO: Figure out how to use `texture` and modulation to avoid needing to do manual filtering
vec2 light_00 = vec2(uvec2(f_col_light.rg) >> 3u);
vec2 light_10 = vec2(uvec2(texelFetch(t_col_light, ivec2(f_uv_pos) + ivec2(1, 0), 0).rg * 255.0) >> 3u);
vec2 light_01 = vec2(uvec2(texelFetch(t_col_light, ivec2(f_uv_pos) + ivec2(0, 1), 0).rg * 255.0) >> 3u);
vec2 light_11 = vec2(uvec2(texelFetch(t_col_light, ivec2(f_uv_pos) + ivec2(1, 1), 0).rg * 255.0) >> 3u);
vec2 light_0 = mix(light_00, light_01, fract(f_uv_pos.y));
vec2 light_1 = mix(light_10, light_11, fract(f_uv_pos.y));
vec2 light = mix(light_0, light_1, fract(f_uv_pos.x));
// TODO: Use `texture` instead
//vec2 light = texture(t_col_light, f_uv_pos).xy / 31;
f_light = light.x / 31.0;
f_glow = light.y / 31.0;
return srgb_to_linear(f_col);
}

View File

@ -39,6 +39,7 @@ layout (std140)
uniform u_locals {
mat4 model_mat;
vec4 highlight_col;
vec4 model_light;
ivec4 atlas_offs;
vec3 model_pos;
// bit 0 - is player

View File

@ -278,8 +278,8 @@ void main() {
// return true;
// }
bvec3 hit_yz_xz_xy;
vec3 dist_yz_xz_xy;
//bvec3 hit_yz_xz_xy;
//vec3 dist_yz_xz_xy;
/* {
// vec3 rDotn = -f_orig_view_dir * -sides;
// vec3 rDotn = f_orig_view_dir * sides;
@ -301,8 +301,8 @@ void main() {
// vec3 s = -sides * (f_pos + delta_sides - cam_pos.xyz) / (-f_orig_view_dir * -sides);
// vec3 s = (f_pos + delta_sides - cam_pos.xyz) / -f_orig_view_dir;
// dist_yz_xz_xy = abs(s);
hit_yz_xz_xy = greaterThanEqual(f_orig_view_dir * sides, vec3(0.000001));
dist_yz_xz_xy = abs((f_pos + delta_sides - cam_pos.xyz) / f_orig_view_dir);
//hit_yz_xz_xy = greaterThanEqual(f_orig_view_dir * sides, vec3(0.000001));
//dist_yz_xz_xy = abs((f_pos + delta_sides - cam_pos.xyz) / f_orig_view_dir);
}
// vec3 xy_point = f_pos, xz_point = f_pos, yz_point = f_pos;
@ -310,11 +310,12 @@ void main() {
// bool hit_xz = (/*ao_xy < 1.0 || ao_yz < 1.0*//*min(f_ao_vec.x, f_ao_vec.z)*//*f_ao_vec.y < 1.0*/true/*min(corner_xy.y, corner_yz.x) < 1.0*//*min(corner_xz.x, corner_xz.y) < 1.0*/) && IntersectRayPlane(cam_pos.xyz, -f_orig_view_dir, vec3(f_pos.x, f_pos.y + delta_sides.y/* - sides.y*/, f_pos.z), vec3(0.0, -sides.y, 0.0), xz_point);
// bool hit_yz = (/*ao_xy < 1.0 || ao_xz < 1.0*//*min(f_ao_vec.y, f_ao_vec.z) < 1.0*//*f_ao_vec.x < 1.0*/true/*true*//*min(corner_xy.x, corner_xz.x) < 1.0*//*min(corner_yz.x, corner_yz.y) < 1.0*/) && IntersectRayPlane(cam_pos.xyz, -f_orig_view_dir, vec3(f_pos.x + delta_sides.x/* - sides.x*/, f_pos.y, f_pos.z), vec3(-sides.x, 0.0, 0.0), yz_point);
// float xy_dist = distance(cam_pos.xyz, xy_point), xz_dist = distance(cam_pos.xyz, xz_point), yz_dist = distance(cam_pos.xyz, yz_point);
bool hit_xy = hit_yz_xz_xy.z, hit_xz = hit_yz_xz_xy.y, hit_yz = hit_yz_xz_xy.x;
float xy_dist = dist_yz_xz_xy.z, xz_dist = dist_yz_xz_xy.y, yz_dist = dist_yz_xz_xy.x;
//bool hit_xy = hit_yz_xz_xy.z, hit_xz = hit_yz_xz_xy.y, hit_yz = hit_yz_xz_xy.x;
//float xy_dist = dist_yz_xz_xy.z, xz_dist = dist_yz_xz_xy.y, yz_dist = dist_yz_xz_xy.x;
// hit_xy = hit_xy && distance(f_pos.xy + delta_sides.xy, xy_point.xy) <= 1.0;
// hit_xz = hit_xz && distance(f_pos.xz + delta_sides.xz, xz_point.xz) <= 1.0;
// hit_yz = hit_yz && distance(f_pos.yz + delta_sides.yz, yz_point.yz) <= 1.0;
/*
vec3 voxel_norm =
hit_yz ?
hit_xz ?
@ -325,6 +326,29 @@ void main() {
hit_xz ?
hit_xy ? xz_dist < xy_dist ? vec3(0.0, sides.y, 0.0) : vec3(0.0, 0.0, sides.z) : vec3(0.0, sides.y, 0.0) :
hit_xy ? vec3(0.0, 0.0, sides.z) : vec3(0.0, 0.0, 0.0);
*/
vec3 voxel_norm;
const float VOXELIZE_DIST = 2000;
float voxelize_factor = clamp(1.0 - (distance(focus_pos.xy, f_pos.xy) - view_distance.x) / VOXELIZE_DIST, 0, 1);
vec3 cam_dir = normalize(cam_pos.xyz - f_pos.xyz);
vec3 side_norm = normalize(vec3(my_norm.xy, 0));
vec3 top_norm = vec3(0, 0, 1);
float side_factor = 1.0 - my_norm.z;
// min(dot(vec3(0, -sign(cam_dir.y), 0), -cam_dir), dot(vec3(-sign(cam_dir.x), 0, 0), -cam_dir))
if (max(abs(my_norm.x), abs(my_norm.y)) < 0.01 || fract(my_alt) * clamp(dot(normalize(vec3(cam_dir.xy, 0)), side_norm), 0, 1) < cam_dir.z / my_norm.z) {
f_ao *= mix(1.0, clamp(fract(my_alt) / length(my_norm.xy) + clamp(dot(side_norm, -cam_dir), 0, 1), 0, 1), voxelize_factor);
voxel_norm = top_norm;
} else {
f_ao *= mix(1.0, clamp(pow(fract(my_alt), 0.5), 0, 1), voxelize_factor);
if (fract(f_pos.x) * abs(my_norm.y / cam_dir.x) < fract(f_pos.y) * abs(my_norm.x / cam_dir.y)) {
voxel_norm = vec3(sign(cam_dir.x), 0, 0);
} else {
voxel_norm = vec3(0, sign(cam_dir.y), 0);
}
}
// vec3 f_ao_view = max(vec3(dot(f_orig_view_dir.yz, sides.yz), dot(f_orig_view_dir.xz, sides.xz), dot(f_orig_view_dir.xy, sides.xy)), 0.0);
// delta_sides *= sqrt(1.0 - f_ao_view * f_ao_view);
// delta_sides *= 1.0 - mix(view_dir / f_ao_view, vec3(0.0), equal(f_ao_view, vec3(0.0)));// sqrt(1.0 - f_ao_view * f_ao_view);
@ -446,7 +470,7 @@ void main() {
voxel_norm = normalize(mix(voxel_norm, lerpy_norm, clamp(my_norm.z * my_norm.z - (1.0 - DIST), 0, 1) / DIST));
f_pos.xyz += abs(voxel_norm) * delta_sides;
voxel_norm = mix(voxel_norm == vec3(0.0) ? f_norm : voxel_norm, my_norm, clamp((f_orig_len - view_distance.x) / 3500, 0, 1));
voxel_norm = mix(my_norm, voxel_norm == vec3(0.0) ? f_norm : voxel_norm, voxelize_factor);
vec3 hash_pos = f_pos + focus_off.xyz;
const float A = 0.055;
@ -470,7 +494,7 @@ void main() {
// f_ao = 1.0;
// f_ao = dot(f_ao_vec, sqrt(1.0 - delta_sides * delta_sides));
f_ao = dot(f_ao_vec, abs(voxel_norm));
f_ao *= dot(f_ao_vec, abs(voxel_norm));
// f_ao = sqrt(dot(f_ao_vec * abs(voxel_norm), sqrt(1.0 - delta_sides * delta_sides)) / 3.0);
// vec3 ao_pos2 = min(fract(f_pos), 1.0 - fract(f_pos));

View File

@ -36,8 +36,8 @@ out float pull_down;
// out float f_light;
void main() {
// Find distances between vertices.
f_pos = lod_pos(v_pos, focus_pos.xy);
// Find distances between vertices. Pull down a tiny bit more to reduce z fighting near the ocean.
f_pos = lod_pos(v_pos, focus_pos.xy) - vec3(0, 0, 0.1);
vec2 dims = vec2(1.0 / view_distance.y);
vec4 f_square = focus_pos.xyxy + vec4(splay(v_pos - dims), splay(v_pos + dims));
f_norm = lod_norm(f_pos.xy, f_square);

View File

@ -19,6 +19,7 @@
in vec3 f_pos;
flat in vec3 f_norm;
in vec4 f_col;
in float f_reflect;
out vec4 tgt_color;
@ -59,12 +60,19 @@ void main() {
const float R_s1s2 = pow((1.3325 - 1.0) / (1.3325 + 1.0), 2);
float R_s = (f_pos.z < f_alt) ? mix(R_s2s1 * R_s1s0, R_s1s0, medium.x) : mix(R_s2s0, R_s1s2 * R_s2s0, medium.x);
vec3 k_a = vec3(1.0);
vec3 k_d = vec3(1.0);
vec3 k_s = vec3(R_s);
vec3 k_a = vec3(1.0) * f_reflect;
vec3 k_d = vec3(1.0) * f_reflect;
vec3 k_s = vec3(R_s) * f_reflect;
vec3 emitted_light, reflected_light;
// This is a bit of a hack. Because we can't find the volumetric lighting of each particle (they don't talk to the
// CPU) we need to some how find an approximation of how much the sun is blocked. We do this by fading out the sun
// as the particle moves underground. This isn't perfect, but it does at least mean that particles don't look like
// they're exposed to the sun when in dungeons
const float SUN_FADEOUT_DIST = 20.0;
sun_info.block *= clamp((f_pos.z - f_alt) / SUN_FADEOUT_DIST + 1, 0, 1);
// To account for prior saturation.
float max_light = 0.0;
max_light += get_sun_diffuse2(sun_info, moon_info, f_norm, view_dir, k_a, k_d, k_s, alpha, emitted_light, reflected_light);
@ -75,7 +83,8 @@ void main() {
// TODO: Not this
emitted_light += max(f_col.rgb - 1.0, vec3(0));
surf_color = illuminate(max_light, view_dir, surf_color * emitted_light, surf_color * reflected_light);
surf_color = illuminate(max_light, view_dir, surf_color * emitted_light, surf_color * reflected_light * f_reflect);
tgt_color = vec4(surf_color, f_col.a);
// Temporarily disable particle transparency to avoid artifacts
tgt_color = vec4(surf_color, 1.0 /*f_col.a*/);
}

View File

@ -31,6 +31,7 @@ flat out vec3 f_norm;
out vec4 f_col;
out float f_ao;
out float f_light;
out float f_reflect;
const float SCALE = 1.0 / 11.0;
@ -53,6 +54,7 @@ const int HEALING_BEAM = 13;
const int ENERGY_NATURE = 14;
const int FLAMETHROWER = 15;
const int FIRE_SHOCKWAVE = 16;
const int FIRE_BOWL = 17;
// meters per second squared (acceleration)
const float earth_gravity = 9.807;
@ -139,6 +141,7 @@ void main() {
float rand9 = hash(vec4(inst_entropy + 9));
Attr attr;
f_reflect = 1.0;
if (inst_mode == SMOKE) {
attr = Attr(
@ -147,24 +150,36 @@ void main() {
vec3(rand2 * 0.02, rand3 * 0.02, 1.0 + rand4 * 0.1)
),
vec3(linear_scale(0.5)),
vec4(1, 1, 1, start_end(1.0, 0.0)),
vec4(vec3(0.8, 0.8, 1) * 0.5, start_end(1.0, 0.0)),
spin_in_axis(vec3(rand6, rand7, rand8), rand9 * 3 + lifetime * 0.5)
);
} else if (inst_mode == FIRE) {
f_reflect = 0.0; // Fire doesn't reflect light, it emits it
attr = Attr(
linear_motion(
vec3(rand0 * 0.25, rand1 * 0.25, 0.3),
vec3(normalize(vec2(rand0, rand1)) * 0.25, 0.3),
vec3(rand2 * 0.1, rand3 * 0.1, 2.0 + rand4 * 1.0)
),
vec3(1.0),
vec4(2, 0.8 + rand5 * 0.3, 0, 1),
vec4(2, 1.5 + rand5 * 0.5, 0, start_end(1.0, 0.0)),
spin_in_axis(vec3(rand6, rand7, rand8), rand9 * 3)
);
} else if (inst_mode == FIRE_BOWL) {
f_reflect = 0.0; // Fire doesn't reflect light, it emits it
attr = Attr(
linear_motion(
vec3(normalize(vec2(rand0, rand1)) * 0.1, 0.6),
vec3(rand2 * 0.2, rand3 * 0.5, 0.8 + rand4 * 0.5)
),
vec3(0.2), // Size
vec4(2, 1.5 + rand5 * 0.5, 0, start_end(1.0, 0.0)), // Colour
spin_in_axis(vec3(rand6, rand7, rand8), rand9 * 3)
);
} else if (inst_mode == GUN_POWDER_SPARK) {
attr = Attr(
linear_motion(
vec3(rand0, rand1, rand3) * 0.3,
vec3(rand4, rand5, rand6) * 2.0 + grav_vel(earth_gravity)
normalize(vec3(rand0, rand1, rand3)) * 0.3,
normalize(vec3(rand4, rand5, rand6)) * 2.0 + grav_vel(earth_gravity)
),
vec3(1.0),
vec4(3.5, 3 + rand7, 0, 1),
@ -174,57 +189,62 @@ void main() {
attr = Attr(
linear_motion(
vec3(0),
vec3(rand4, rand5, rand6) * 30.0 + grav_vel(earth_gravity)
normalize(vec3(rand4, rand5, rand6)) * 30.0 + grav_vel(earth_gravity)
),
vec3(2.0 + rand0),
vec4(vec3(0.6 + rand7 * 0.4), 1),
spin_in_axis(vec3(1,0,0),0)
);
} else if (inst_mode == FIREWORK_BLUE) {
f_reflect = 0.0; // Fire doesn't reflect light, it emits it
attr = Attr(
linear_motion(
vec3(0),
vec3(rand1, rand2, rand3) * 40.0 + grav_vel(earth_gravity)
normalize(vec3(rand1, rand2, rand3)) * 40.0 + grav_vel(earth_gravity)
),
vec3(3.0 + rand0),
vec4(0.15, 0.4, 1, 1),
identity()
);
} else if (inst_mode == FIREWORK_GREEN) {
f_reflect = 0.0; // Fire doesn't reflect light, it emits it
attr = Attr(
linear_motion(
vec3(0),
vec3(rand1, rand2, rand3) * 40.0 + grav_vel(earth_gravity)
normalize(vec3(rand1, rand2, rand3)) * 40.0 + grav_vel(earth_gravity)
),
vec3(3.0 + rand0),
vec4(0, 1, 0, 1),
identity()
);
} else if (inst_mode == FIREWORK_PURPLE) {
f_reflect = 0.0; // Fire doesn't reflect light, it emits it
attr = Attr(
linear_motion(
vec3(0),
vec3(rand1, rand2, rand3) * 40.0 + grav_vel(earth_gravity)
normalize(vec3(rand1, rand2, rand3)) * 40.0 + grav_vel(earth_gravity)
),
vec3(3.0 + rand0),
vec4(0.7, 0.0, 1.0, 1.0),
identity()
);
} else if (inst_mode == FIREWORK_RED) {
f_reflect = 0.0; // Fire doesn't reflect light, it emits it
attr = Attr(
linear_motion(
vec3(0),
vec3(rand1, rand2, rand3) * 40.0 + grav_vel(earth_gravity)
normalize(vec3(rand1, rand2, rand3)) * 40.0 + grav_vel(earth_gravity)
),
vec3(3.0 + rand0),
vec4(1, 0, 0, 1),
identity()
);
} else if (inst_mode == FIREWORK_YELLOW) {
f_reflect = 0.0; // Fire doesn't reflect light, it emits it
attr = Attr(
linear_motion(
vec3(0),
vec3(rand1, rand2, rand3) * 40.0 + grav_vel(earth_gravity)
normalize(vec3(rand1, rand2, rand3)) * 40.0 + grav_vel(earth_gravity)
),
vec3(3.0 + rand0),
vec4(1, 1, 0, 1),
@ -272,34 +292,38 @@ void main() {
spin_in_axis(vec3(1,0,0),0)
);
} else if (inst_mode == HEALING_BEAM) {
f_reflect = 0.0;
attr = Attr(
spiral_motion(inst_dir, 0.3 * (floor(2 * rand0 + 0.5) - 0.5) * min(linear_scale(10), 1), lifetime / inst_lifespan),
vec3((1.7 - 0.7 * abs(floor(2 * rand0 - 0.5) + 0.5)) * (1.5 + 0.5 * sin(tick.x * 10 - lifetime * 4))),
vec4(vec3(0.3, 0.7 + 0.4 * sin(tick.x * 8 - lifetime * 3), 0.3 + 0.1 * sin (tick.x * 2)), 0.3),
vec4(vec3(0.4, 2.7 + 0.4 * sin(tick.x * 8 - lifetime * 3 + 4), 0.5 + 0.6 * sin(tick.x * 7)), start_end(1.0, 0.0) /*0.3*/),
spin_in_axis(inst_dir, tick.z)
);
} else if (inst_mode == ENERGY_NATURE) {
f_reflect = 0.0;
attr = Attr(
linear_motion(
vec3(rand0 * 1, rand1 * 1, rand2 * 1),
vec3(rand3 * 2, rand4 * 2, rand5 * 2)
),
vec3(0.8),
vec4(vec3(0, 1, 0), 1),
vec4(vec3(0, 2.5, 1.5 + rand7 * 0.7), start_end(1.0, 0.0)),
spin_in_axis(vec3(rand6, rand7, rand8), rand9 * 3)
);
} else if (inst_mode == FLAMETHROWER) {
f_reflect = 0.0; // Fire doesn't reflect light, it emits it
attr = Attr(
(inst_dir * lifetime / inst_lifespan) + vec3(rand0, rand1, rand2) * (lifetime * 5 + 0.25),
vec3(0.6 + rand3 * 0.5 + lifetime / inst_lifespan * 5),
vec4(1, 0.6 + rand5 * 0.3 - 0.6 * lifetime / inst_lifespan, 0, 0.8 - 0.6 * lifetime / inst_lifespan),
vec4(3, 1.6 + rand5 * 0.3 - 0.4 * lifetime / inst_lifespan, 0.2, start_end(1.0, 0.0) /*0.8 - 0.6 * lifetime / inst_lifespan*/),
spin_in_axis(vec3(rand6, rand7, rand8), lifetime / inst_lifespan * 10 + 3 * rand9)
);
} else if (inst_mode == FIRE_SHOCKWAVE) {
f_reflect = 0.0; // Fire doesn't reflect light, it emits it
attr = Attr(
vec3(rand0, rand1, lifetime * 10 + rand2),
vec3(1.6 + rand3 * 1.5 + 10 * (lifetime + inst_lifespan)),
vec4(1, 0.6 + rand7 * 0.3 - 5 * inst_lifespan + 2 * lifetime, 0, 0.8 - 3.5 * inst_lifespan),
vec4(3, 1.6 + rand7 * 0.3 - 5 * inst_lifespan + 2 * lifetime, 0.2, start_end(1.0, 0.0) /*0.8 - 3.5 * inst_lifespan*/),
spin_in_axis(vec3(rand3, rand4, rand5), rand6)
);
} else {
@ -314,6 +338,9 @@ void main() {
);
}
// Temporary: use shrinking particles as a substitute for fading ones
attr.scale *= pow(attr.col.a, 0.25);
f_pos = (inst_pos - focus_off.xyz) + (v_pos * attr.scale * SCALE * mat3(attr.rot) + attr.offs);
// First 3 normals are negative, next 3 are positive
@ -324,7 +351,7 @@ void main() {
((normals[(v_norm_ao >> 0) & 0x7u]) * attr.rot).xyz;
//vec3 col = vec3((uvec3(v_col) >> uvec3(0, 8, 16)) & uvec3(0xFFu)) / 255.0;
f_col = vec4(srgb_to_linear(attr.col.rgb), attr.col.a);
f_col = vec4(attr.col.rgb, attr.col.a);
gl_Position =
all_mat *

View File

@ -25,6 +25,7 @@ layout (std140)
uniform u_locals {
mat4 model_mat;
vec4 highlight_col;
vec4 model_light;
ivec4 atlas_offs;
vec3 model_pos;
int flags;

View File

@ -204,6 +204,14 @@ void main() {
vec4 aa_color = aa_apply(src_color, uv * screen_res.xy, screen_res.xy);
// Tonemapping
float exposure_offset = 1.0;
// Adding an in-code offset to gamma and exposure let us have more precise control over the game's look
float gamma_offset = 0.3;
aa_color.rgb = vec3(1.0) - exp(-aa_color.rgb * (gamma_exposure.y + exposure_offset));
// gamma correction
aa_color.rgb = pow(aa_color.rgb, vec3(gamma_exposure.x + gamma_offset));
/*
// Apply clouds to `aa_color`
#if (CLOUD_MODE != CLOUD_MODE_NONE)
@ -238,7 +246,7 @@ void main() {
//hsva_color.z = 1.0 - 1.0 / (1.0 * hsva_color.z + 1.0);
//vec4 final_color = vec4(hsv2rgb(hsva_color.rgb), hsva_color.a);
vec4 final_color = pow(aa_color, gamma);
vec4 final_color = aa_color;
#if (FLUID_MODE == FLUID_MODE_CHEAP)
if (medium.x == 1u) {

View File

@ -21,6 +21,7 @@ flat in vec3 f_norm;
flat in float f_light;
// flat in vec3 f_pos_norm;
in vec2 f_uv_pos;
in vec2 f_inst_light;
// flat in uint f_atlas_pos;
// in vec3 f_col;
// in float f_ao;
@ -61,17 +62,8 @@ void main() {
// vec3 dv = dFdy(f_pos);
// vec3 f_norm = normalize(cross(du, dv));
// vec4 f_col_light = texture(t_col_light, (f_uv_pos + 0.5) / textureSize(t_col_light, 0)/* + uv_delta*//* - f_norm * 0.00001*/);
// vec4 f_col_light = textureGrad(t_col_light, (f_uv_pos + 0.5) / textureSize(t_col_light, 0), vec2(0.5), vec2(0.5));
vec4 f_col_light = texelFetch(t_col_light, ivec2(f_uv_pos)/* + uv_delta*//* - f_norm * 0.00001*/, 0);
vec3 f_col = /*linear_to_srgb*//*srgb_to_linear*/(f_col_light.rgb);
// vec3 f_col = vec3(1.0);
// vec2 texSize = textureSize(t_col_light, 0);
// float f_ao = f_col_light.a;
// float f_ao = f_col_light.a + length(vec2(dFdx(f_col_light.a), dFdy(f_col_light.a)));
float f_ao = texture(t_col_light, (f_uv_pos + 0.5) / textureSize(t_col_light, 0)).a;//1.0;//f_col_light.a * 4.0;// f_light = float(v_col_light & 0x3Fu) / 64.0;
// float f_ao = 1.0;
// float /*f_light*/f_ao = textureProj(t_col_light, vec3(f_uv_pos, texSize)).a;//1.0;//f_col_light.a * 4.0;// f_light = float(v_col_light & 0x3Fu) / 64.0;
float f_ao, f_glow;
vec3 f_col = greedy_extract_col_light_glow(t_col_light, f_uv_pos, f_ao, f_glow);
// vec3 my_chunk_pos = f_pos_norm;
// tgt_color = vec4(hash(floor(vec4(my_chunk_pos.x, 0, 0, 0))), hash(floor(vec4(0, my_chunk_pos.y, 0, 1))), hash(floor(vec4(0, 0, my_chunk_pos.z, 2))), 1.0);
@ -142,6 +134,10 @@ void main() {
vec3 emitted_light, reflected_light;
// Make voxel shadows block the sun and moon
sun_info.block = f_inst_light.x;
moon_info.block = f_inst_light.x;
// To account for prior saturation.
// float vert_light = pow(f_light, 1.5);
// vec3 light_frac = light_reflection_factor(f_norm/*vec3(0, 0, 1.0)*/, view_dir, vec3(0, 0, -1.0), vec3(1.0), vec3(R_s), alpha);
@ -178,6 +174,9 @@ void main() {
reflected_light += point_light; */
// float ao = /*pow(f_ao, 0.5)*/f_ao * 0.85 + 0.15;
vec3 glow = pow(f_inst_light.y, 3) * 4 * GLOW_COLOR;
emitted_light += glow;
float ao = f_ao;
emitted_light *= ao;
reflected_light *= ao;

View File

@ -25,7 +25,7 @@ in vec4 inst_mat0;
in vec4 inst_mat1;
in vec4 inst_mat2;
in vec4 inst_mat3;
// in vec3 inst_col;
in vec4 inst_light;
in float inst_wind_sway;
struct SpriteLocals {
@ -77,6 +77,7 @@ flat out float f_light;
// out vec3 f_col;
// out float f_ao;
out vec2 f_uv_pos;
out vec2 f_inst_light;
// flat out uint f_atlas_pos;
// out vec3 light_pos[2];
// out float f_light;
@ -117,6 +118,8 @@ void main() {
// float inst_wind_sway = wind_sway.w;
// vec3 inst_offs = model_offs - focus_off.xyz;
f_inst_light = inst_light.xy;
// vec3 sprite_pos = floor(inst_mat3.xyz * SCALE) + inst_offs;
// f_pos_norm = v_pos;
@ -139,6 +142,9 @@ void main() {
// f_pos = v_pos + (model_offs - focus_off.xyz);
f_pos = (inst_mat * vec4(v_pos_, 1.0)).xyz * SCALE + inst_offs;
// Terrain 'pop-in' effect
f_pos.z -= 250.0 * (1.0 - min(1.0001 - 0.02 / pow(tick.x - load_time, 10.0), 1.0));
// f_pos = (inst_mat * v_pos_) * SCALE + sprite_pos;
// f_pos = (inst_mat * vec4(v_pos * SCALE, 1)).xyz + (model_offs - focus_off.xyz);

View File

@ -27,6 +27,7 @@ in vec3 f_pos;
// in vec3 f_chunk_pos;
// #ifdef FLUID_MODE_SHINY
flat in uint f_pos_norm;
flat in float f_load_time;
// #else
// const uint f_pos_norm = 0u;
// #endif
@ -60,6 +61,13 @@ out vec4 tgt_color;
#include <lod.glsl>
void main() {
/*
float nz = abs(hash(vec4(floor((f_pos + focus_off.xyz) * 5.0), 0)));
if (nz > (tick.x - load_time) / 0.5 || distance(focus_pos.xy, f_pos.xy) / view_distance.x + nz * 0.1 > 1.0) {
discard;
}
*/
// discard;
// vec4 f_col_light = textureGrad(t_col_light, f_uv_pos / texSize, 0.25, 0.25);
// vec4 f_col_light = texture(t_col_light, (f_uv_pos) / texSize);
@ -73,12 +81,9 @@ void main() {
vec2 f_uv_pos = f_uv_pos + atlas_offs.xy;
// vec4 f_col_light = textureProj(t_col_light, vec3(f_uv_pos + 0.5, textureSize(t_col_light, 0)));//(f_uv_pos/* + 0.5*/) / texSize);
// float f_light = textureProj(t_col_light, vec3(f_uv_pos + 0.5, textureSize(t_col_light, 0))).a;//1.0;//f_col_light.a * 4.0;// f_light = float(v_col_light & 0x3Fu) / 64.0;
vec4 f_col_light = texelFetch(t_col_light, ivec2(f_uv_pos)/* + uv_delta*//* - f_norm * 0.00001*/, 0);
// float f_light = f_col_light.a;
// vec4 f_col_light = texelFetch(t_col_light, ivec2(int(f_uv_pos.x), int(f_uv_pos.y)/* + uv_delta*//* - f_norm * 0.00001*/), 0);
vec3 f_col = /*linear_to_srgb*//*srgb_to_linear*/(f_col_light.rgb);
// vec3 f_col = vec3(1.0);
float f_light = texture(t_col_light, (f_uv_pos + 0.5) / textureSize(t_col_light, 0)).a;//1.0;//f_col_light.a * 4.0;// f_light = float(v_col_light & 0x3Fu) / 64.0;
float f_light, f_glow;
vec3 f_col = greedy_extract_col_light_glow(t_col_light, f_uv_pos, f_light, f_glow);
//float f_light = (uint(texture(t_col_light, (f_uv_pos + 0.5) / textureSize(t_col_light, 0)).r * 255.0) & 0x1Fu) / 31.0;
// vec2 texSize = textureSize(t_col_light, 0);
// float f_light = texture(t_col_light, f_uv_pos/* + vec2(atlas_offs.xy)*/).a;//1.0;//f_col_light.a * 4.0;// f_light = float(v_col_light & 0x3Fu) / 64.0;
// float f_light = textureProj(t_col_light, vec3(f_uv_pos/* + vec2(atlas_offs.xy)*/, texSize.x)).a;//1.0;//f_col_light.a * 4.0;// f_light = float(v_col_light & 0x3Fu) / 64.0;
@ -260,6 +265,11 @@ void main() {
reflected_light *= f_light;
max_light *= f_light;
// TODO: Apply AO after this
vec3 glow = GLOW_COLOR * (pow(f_glow, 6) * 8 + pow(f_glow, 2) * 0.5);
emitted_light += glow;
reflected_light += glow;
max_light += lights_at(f_pos, f_norm, view_dir, mu, cam_attenuation, fluid_alt, k_a, k_d, k_s, alpha, f_norm, 1.0, emitted_light, reflected_light);
// float f_ao = 1.0;

View File

@ -48,6 +48,7 @@ uniform u_locals {
out vec3 f_pos;
// #ifdef FLUID_MODE_SHINY
flat out uint f_pos_norm;
flat out float f_load_time;
// #if (SHADOW_MODE == SHADOW_MODE_MAP)
// out vec4 sun_pos;
@ -73,7 +74,10 @@ void main() {
vec3 f_chunk_pos = vec3(ivec3((uvec3(v_pos_norm) >> uvec3(0, 6, 12)) & uvec3(0x3Fu, 0x3Fu, 0xFFFFu)) - ivec3(0, 0, EXTRA_NEG_Z));
f_pos = f_chunk_pos + model_offs - focus_off.xyz;
// f_pos.z -= 250.0 * (1.0 - min(1.0001 - 0.02 / pow(tick.x - load_time, 10.0), 1.0));
f_load_time = load_time;
// Terrain 'pop-in' effect
f_pos.z -= 250.0 * (1.0 - min(1.0001 - 0.02 / pow(tick.x - load_time, 10.0), 1.0));
// f_pos.z -= min(32.0, 25.0 * pow(distance(focus_pos.xy, f_pos.xy) / view_distance.x, 20.0));
// vec3 light_col = vec3(

BIN
assets/voxygen/voxel/armor/back/leather_blue-0.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/armor/back/warlock.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/armor/back/warlord.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/armor/belt/warlock.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/armor/belt/warlord.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/armor/chest/leather_blue-0.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/armor/chest/warlock.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/armor/chest/warlord.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/armor/foot/warlock.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/armor/foot/warlord.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/armor/hand/warlock_left.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/armor/hand/warlock_right.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/armor/hand/warlord_left.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/armor/hand/warlord_right.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/armor/head/warlock.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/armor/head/warlord.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/armor/pants/leather_blue-0.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/armor/pants/warlock.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/armor/pants/warlord.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/armor/shoulder/warlock_left.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/armor/shoulder/warlock_right.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/armor/shoulder/warlord_left.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/armor/shoulder/warlord_right.vox (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -4,37 +4,49 @@
color: None
),
map: {
"Short0": (
vox_spec: ("armor.back.short-0", (-5.0, -1.0, -11.0)),
color: None
),
"Admin": (
vox_spec: ("armor.back.admin", (-5.0, -1.0, -11.0)),
color: None
),
"DungPurp0": (
vox_spec: ("armor.back.dung_purp-0", (-5.0, -1.0, -14.0)),
color: None
),
"Short1": (
vox_spec: ("armor.back.short-1", (-5.0, -1.0, -11.0)),
color: None
),
"Short2": (
vox_spec: ("armor.back.short-2", (-5.0, -1.0, -11.0)),
color: None
),
"Backpack0": (
vox_spec: ("armor.back.backpack-0", (-7.0, -5.0, -10.0)),
color: None
),
"BackpackBlue0": (
vox_spec: ("armor.back.backpack-grey", (-7.0, -5.0, -10.0)),
color: Some((76, 72, 178))
),
"VeloriteMage0": (
vox_spec: ("armor.back.velorite_battlemage", (-5.0, -1.0, -14.0)),
color: None
),
"Short0": (
vox_spec: ("armor.back.short-0", (-5.0, -1.0, -11.0)),
color: None
),
"Admin": (
vox_spec: ("armor.back.admin", (-5.0, -1.0, -11.0)),
color: None
),
"DungPurp0": (
vox_spec: ("armor.back.dung_purp-0", (-5.0, -1.0, -14.0)),
color: None
),
"Short1": (
vox_spec: ("armor.back.short-1", (-5.0, -1.0, -11.0)),
color: None
),
"Short2": (
vox_spec: ("armor.back.short-2", (-5.0, -1.0, -11.0)),
color: None
),
"Backpack0": (
vox_spec: ("armor.back.backpack-0", (-7.0, -5.0, -10.0)),
color: None
),
"BackpackBlue0": (
vox_spec: ("armor.back.backpack-grey", (-7.0, -5.0, -10.0)),
color: Some((76, 72, 178))
),
"VeloriteMage0": (
vox_spec: ("armor.back.velorite_battlemage", (-5.0, -1.0, -14.0)),
color: None
),
"LeatherBlue0": (
vox_spec: ("armor.back.leather_blue-0", (-5.0, -1.0, -11.0)),
color: None
),
"Warlord": (
vox_spec: ("armor.back.warlord", (-5.0, -1.0, -14.0)),
color: None
),
"Warlock": (
vox_spec: ("armor.back.warlock", (-5.0, -1.5, -15.5)),
color: None
),
},
))

View File

@ -87,6 +87,14 @@
"VeloriteMage0": (
vox_spec: ("armor.belt.velorite_battlemage", (-5.0, -3.5, 2.0)),
color: None
),
),
"Warlord":(
vox_spec: ("armor.belt.warlord", (-4.0, -3.5, 1.0)),
color: None
),
"Warlock":(
vox_spec: ("armor.belt.warlock", (-4.0, -3.0, 2.0)),
color: None
),
},
))

View File

@ -48,6 +48,10 @@
vox_spec: ("armor.chest.leather-0", (-7.0, -3.5, 2.0)),
color: None
),
"LeatherBlue0": (
vox_spec: ("armor.chest.leather_blue-0", (-7.0, -3.5, 2.0)),
color: None
),
"ClothPurple0": (
vox_spec: ("armor.chest.cloth_purple-0", (-7.0, -3.5, 1.0)),
color: None
@ -84,27 +88,27 @@
"WorkerPurple0": (
vox_spec: ("armor.chest.worker_white-0", (-7.0, -3.5, 2.0)),
color: Some((64, 47, 56))
),
),
"WorkerPurple1": (
vox_spec: ("armor.chest.shirt_white-0", (-7.0, -3.5, 2.0)),
color: Some((64, 47, 56))
),
),
"WorkerYellow0": (
vox_spec: ("armor.chest.worker_white-0", (-7.0, -3.5, 2.0)),
color: Some((184, 132, 40))
),
),
"WorkerYellow1": (
vox_spec: ("armor.chest.shirt_white-0", (-7.0, -3.5, 2.0)),
color: Some((184, 132, 40))
),
color: Some((184, 132, 40))
),
"WorkerOrange0": (
vox_spec: ("armor.chest.worker_white-0", (-7.0, -3.5, 2.0)),
color: Some((135, 82, 67))
),
),
"WorkerOrange1": (
vox_spec: ("armor.chest.shirt_white-0", (-7.0, -3.5, 2.0)),
color: Some((135, 82, 67))
),
),
"Druid": (
vox_spec: ("armor.chest.druid", (-7.0, -3.5, 2.0)),
color: None
@ -149,7 +153,14 @@
"VeloriteMage0": (
vox_spec: ("armor.chest.velorite_battlemage", (-7.0, -3.5, 0.5)),
color: None
),
),
"Warlord": (
vox_spec: ("armor.chest.warlord", (-7.0, -3.5, -0.5)),
color: None
),
"Warlock": (
vox_spec: ("armor.chest.warlock", (-7.0, -3.5, 0.5)),
color: None
),
},
)
)
))

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