Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/images/cargo-ship.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/train.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/localisation/en-US/settings.csv
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ graphics_details_label;Graphics
graphics_details_0;Ugly
graphics_details_1;Classic
graphics_details_2;Modern
graphics_details_3;Gores
disband_confirmation_label;Unit disband confirmation
195 changes: 173 additions & 22 deletions assets/shaders/glsl/map_f.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,34 @@ vec4 get_land_terrain() {
return get_terrain_mix();
}

float get_good_hatching(float frequency) {
float s = space_coords.z;
float t = space_coords.y;
float h = space_coords.x;
float angle = atan(t, s);
float vertical_angle = asin(h);
float radius = sqrt(s * s + t * t);
float equator_segment_x = fract(angle * 36.f / 2.f / PI);
float equator_segment_number = floor(angle * 36.f / 2.f / PI);
float vertical_segment = fract(vertical_angle * 2.f / PI * 8.f);
float vertical_segment_number = floor(vertical_angle * 2.f / PI * 8.f);
float horisontal_coord_before_cutting_paper = (equator_segment_x - 0.5f) * radius + 0.5f;
float hatching = texture(hatching, vec2(horisontal_coord_before_cutting_paper * (mod(vertical_segment_number, 2.f) * 2.f - 1.f), vertical_segment * (mod(equator_segment_number, 2.f) * 2.f - 1.f)) * frequency).r;
return hatching;
}

// if we display data, ignore pretty effects
vec4 get_land_data_modern() {
vec4 terrain = get_terrain_mix();
float is_land = terrain.a;
vec4 province_sample = texture(provinces_texture_sampler, gl_FragCoord.xy / screen_size);
vec2 prov_id = province_sample.xy;
return vec4(texture(province_color, vec3(prov_id, 0.)).rgb * 0.8f, is_land);

vec4 base_color = texture(province_color, vec3(prov_id, 0.));
vec4 secondary_color = texture(province_color, vec3(prov_id, 1.));
vec4 result = mix(base_color, secondary_color, get_good_hatching(10.f));

return vec4(result.rgb * 0.8f, is_land);
}

vec4 get_land_political_modern() {
Expand Down Expand Up @@ -237,38 +258,101 @@ vec4 get_land_political_modern() {
return OutColor;
}

vec4 get_land_political_gores() {
float s = space_coords.z;
float t = space_coords.y;
float h = space_coords.x;
float angle = tex_coord.x * PI * 2.f;
float vertical_angle = (tex_coord.y - 0.5f) * PI; //asin(h);
float radius = cos(vertical_angle);
float big_line_divisor = 3.f;
float equator_segment_x = fract(angle * 48.f / 2.f / PI * big_line_divisor);
float equator_segment_number = mod(floor(angle * 48.f / 2.f / PI * big_line_divisor + 0.5f), 36.f);
float equator_segment_number_area = mod(floor(angle * 48.f / 2.f / PI * big_line_divisor), 36.f);
float vertical_segment = fract(vertical_angle * 2.f / PI * 12.f * big_line_divisor);
float vertical_segment_number = floor(vertical_angle * 2.f / PI * 12.f * big_line_divisor + 0.5f);
float vertical_segment_number_area = floor(vertical_angle * 2.f / PI * 12.f * big_line_divisor);
float horisontal_coord_before_cutting_paper = (equator_segment_x - 0.5f) * radius + 0.5f;
float line_width = 0.015f / min(1.f, zoom / 6.f);
float line_width_v = line_width;
float line_width_h = line_width;
float softness_mult = (1.2f + abs(vertical_angle) / 2.f) / sqrt(min(1.f, zoom / 6.f));
float softness_mod = 1.f;
float inside_v = 1.f;
if (mod(round(equator_segment_number), 4.f) == 0.f) {
line_width_v = line_width_v * 3.f / 2.f;
inside_v = 0.f;
}
float inside_h = 1.f;
if (mod(round(vertical_segment_number), 4.f) == 0.f) {
line_width_h = line_width_h * 3.f / 2.f;
inside_h = 0.f;
}
float base_unit = cos(vertical_angle);
float length_mult = 1.f / base_unit;
if (radius < 0.2f) {
length_mult = 1.f / radius;
}
float line_mult = 1.f;
float v1 = abs(fract(equator_segment_x + 0.5f) - 0.5f);
if (v1 < line_width_v * length_mult) {
line_mult = min(line_mult, 0.2f * softness_mult * (1.f + 0.5f * inside_v) + max(0.5f - zoom / 100.f, smootherstep(v1 / (line_width_v * length_mult))));
}
float v2 = abs(fract(vertical_segment + 0.5f) - 0.5f);
if (v2 < line_width_h) {
line_mult = min(line_mult, 0.2f * softness_mult * (1.f + 0.5f * inside_h) + max(0.5f - zoom / 100.f, smootherstep(v2 / (line_width_h))));
}

vec4 get_land_political_paper() {
vec2 uv = tex_coord * 300.f;
vec4 wc = texture(watercolor, vec2(horisontal_coord_before_cutting_paper, vertical_segment) * 10.f);
vec4 wc_global = texture(watercolor, vec2(horisontal_coord_before_cutting_paper, vertical_segment) / 2.f);

float hatching = texture(hatching, vec2(horisontal_coord_before_cutting_paper * (mod(vertical_segment_number_area, 2.f) * 2.f - 1.f), vertical_segment * (mod(equator_segment_number_area, 2.f) * 2.f - 1.f)) * 4.f).r;

vec4 terrain = get_terrain_mix();
float is_land = terrain.a;
vec4 province_sample = texture(provinces_texture_sampler, gl_FragCoord.xy / screen_size);
vec2 prov_id = province_sample.xy;
float to_national_border = province_sample.z;
vec4 hatching = texture(hatching, uv / 2.f);

vec4 prov_highlight = vec4(1.f, 1.f, 1.f, 1.f);
float highlight = texture(province_highlight, prov_id).r;

if (highlight > 0.f) {
prov_highlight = vec4(hatching.rgb * 0.2f * (hatching.a) + 0.5f * (1.f - hatching.a), 1.f);
prov_highlight = vec4(hatching, hatching, hatching, 1.f);
}

vec4 prov_color = texture(province_color, vec3(prov_id, 0.));
vec4 stripe_color = texture(province_color, vec3(prov_id, 1.));
//float stripeFactor = texture(stripes_texture, stripe_coord).a;
//vec4 base_color = vec4(1.f, 247.f / 255.f, 220.f / 255.f, 1.f) * 0.9f;
vec4 base_color = vec4(0.80, 0.76, 0.63, 1.f);
float gradient = sqrt(to_national_border);

const vec3 GREYIFY = vec3( 0.212671, 0.715160, 0.072169 );
float grey = dot( terrain.rgb, GREYIFY ) * 2.f;

vec4 base_color = vec4(1.f, 247.f / 255.f, 240.f / 255.f, 1.f);
float wc_base = texture(watercolor, uv).b;
float gradient = 1.f;
if (int(graphics_mode) == 2) {
gradient = (0.7f + sqrt(to_national_border) * 0.3f);
float weight_base = 0.0015f;
float weight_hatching = 0.05f;
float weight_border = 3.0f * clamp(0.1f + hatching, 0.f, 1.f);
float weight_watercolor = 0.005f;
//float total_weight = weight_base + weight_hatching + weight_border + weight_watercolor;
float wc_g = dot(wc.xyz, GREYIFY);

float final_weight = min(1, sqrt(
weight_base
+ wc_g * weight_watercolor
+ weight_border * (1.f - gradient)
+ hatching * weight_hatching
));

if (stripe_color != prov_color) {
base_color = stripe_color * final_weight + base_color * (1.f - final_weight);
}
float wc_texture = max(0.f, wc_base * wc_base * wc_base) * gradient;
vec4 mixed_color = prov_color * (1.f - wc_texture) + base_color * wc_texture;
vec4 mixed_color = prov_color * final_weight + base_color * (1.f - final_weight);

vec4 terrain = get_terrain_mix();
const vec3 GREYIFY = vec3( 0.212671, 0.715160, 0.072169 );
float grey = dot( terrain.rgb, GREYIFY ) * 2.f;
float is_land = terrain.a;
return mixed_color * prov_highlight * is_land + texture(watercolor, uv) * gradient * (1 - is_land);
//vec4 color = prov_color * wc

vec4 result = (mixed_color - 0.f * hatching) * min(1.f, line_mult) * (0.85f + 0.05f * wc + 0.10f * dot(wc_global.xyz, GREYIFY)) * min(1.f, 0.2f + gradient);
result.a = is_land;

return result;
}

vec4 get_land_political_close() {
Expand Down Expand Up @@ -319,6 +403,7 @@ vec4 get_land_political_close() {
return terrain;
}


vec4 get_land_political_far() {
//vec4 terrain = get_terrain(vec2(0, 0), vec2(0));
vec4 terrain = get_terrain_mix();
Expand Down Expand Up @@ -386,27 +471,93 @@ vec4 get_land() {
return get_land_terrain();
}


if (int(graphics_mode) == 2) {
if (map_mode_is_data == 0) {
return get_land_political_modern();
} else {
return get_land_data_modern();
}
return get_land_political_far();
}

if (int(graphics_mode) == 3) {
if (map_mode_is_data == 0) {
return get_land_political_gores();
} else {
return get_land_data_modern();
}
}

if (int(graphics_mode) == 0) {
return get_land_political_far();
}


switch(int(subroutines_index_2)) {
case 0: return get_land_terrain();
case 1: return get_land_political_close();
case 2: return get_land_political_far();
default: break;
}
}

vec4 get_water_gores() {
float s = space_coords.z;
float t = space_coords.y;
float h = space_coords.x;
float angle = tex_coord.x * PI * 2.f;
float vertical_angle = (tex_coord.y - 0.5f) * PI; //asin(h);
float radius = cos(vertical_angle);
float big_line_divisor = 3.f;
float equator_segment_x = fract(angle * 48.f / 2.f / PI * big_line_divisor);
float equator_segment_number = mod(floor(angle * 48.f / 2.f / PI * big_line_divisor + 0.5f), 36.f);
float equator_segment_number_area = mod(floor(angle * 48.f / 2.f / PI * big_line_divisor), 36.f);
float vertical_segment = fract(vertical_angle * 2.f / PI * 12.f * big_line_divisor);
float vertical_segment_number = floor(vertical_angle * 2.f / PI * 12.f * big_line_divisor + 0.5f);
float vertical_segment_number_area = floor(vertical_angle * 2.f / PI * 12.f * big_line_divisor);
float horisontal_coord_before_cutting_paper = (equator_segment_x - 0.5f) * radius + 0.5f;
float line_width = 0.015f / min(1.f, zoom / 6.f);
float line_width_v = line_width;
float line_width_h = line_width;
float softness_mult = (1.f + abs(vertical_angle) / 2.f) / sqrt(min(1.f, zoom / 6.f));
float softness_mod = 1.f;
float inside_v = 1.f;
if (mod(round(equator_segment_number), 4.f) == 0.f) {
line_width_v = line_width_v * 3.f / 2.f;
inside_v = 0.f;
}
float inside_h = 1.f;
if (mod(round(vertical_segment_number), 4.f) == 0.f) {
line_width_h = line_width_h * 3.f / 2.f;
inside_h = 0.f;
}
float base_unit = cos(vertical_angle);
float length_mult = 1.f / base_unit;
if (radius < 0.2f) {
length_mult = 1.f / radius;
}
float line_mult = 1.f;
float v1 = abs(fract(equator_segment_x + 0.5f) - 0.5f);
if (v1 < line_width_v * length_mult) {
line_mult = min(line_mult, 0.2f * softness_mult * (1.f + 0.5f * inside_v) + max(0.5f - zoom / 100.f, smootherstep(v1 / (line_width_v * length_mult))));
}
float v2 = abs(fract(vertical_segment + 0.5f) - 0.5f);
if (v2 < line_width_h) {
line_mult = min(line_mult, 0.2f * softness_mult * (1.f + 0.5f * inside_h) + max(0.5f - zoom / 100.f, smootherstep(v2 / (line_width_h))));
}

vec4 wc = texture(watercolor, vec2(horisontal_coord_before_cutting_paper, vertical_segment) * 10.f);
vec4 wc_global = texture(watercolor, vec2(horisontal_coord_before_cutting_paper, vertical_segment) / 2.f);

float hatching = 0.4f * texture(hatching, vec2(horisontal_coord_before_cutting_paper * (mod(vertical_segment_number_area, 2.f) * 2.f - 1.f), vertical_segment * (mod(equator_segment_number_area, 2.f) * 2.f - 1.f)) * 4.f).r;
return vec4(0.57f - hatching, 0.65f - hatching, 0.70f, 1.f) * (0.25f + 0.5f * wc + 0.25f * wc_global) * vec4(0.2f + 0.8f * line_mult, 0.2f + 0.8f *line_mult, 1.f, 1.f);
}

vec4 get_water() {
if (int(graphics_mode) == 3) {
return get_water_gores();
}

switch(int(subroutines_index_2)) {
case 0: return get_water_terrain();
case 1: return get_water_terrain();
Expand All @@ -429,7 +580,7 @@ void main() {
float light = max(0.f, dot(light_direction, space_coords));
float darkness = max(0.f, -dot(light_direction, space_coords));

if (int(graphics_mode) == 2) {
if (int(graphics_mode) == 2 || int(graphics_mode) == 3) {
vec4 province_sample = texture(provinces_texture_sampler, gl_FragCoord.xy / screen_size);
float to_national_border = province_sample.z;
//light += (1.f - to_national_border) * 1.5f * darkness;
Expand Down
2 changes: 1 addition & 1 deletion assets/shaders/glsl/map_font_v.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void main() {
vec4 temp_result = calc_gl_position(vertex_position);

float pixels_thickness = thickness * zoom;
float min_thickness = 0.01f;
float min_thickness = 0.003f;
float max_thickness = 1.f;
opacity = clamp((min_thickness / pixels_thickness - 1.f) * (pixels_thickness / max_thickness - 1.f), 0.f, 1.f);

Expand Down
20 changes: 18 additions & 2 deletions assets/shaders/glsl/wavy_textured_line_f.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ uniform vec3 light_direction;
uniform float ignore_light;
uniform float gamma;
uniform vec2 screen_size;
uniform float railroad_level;

uniform sampler2D provinces_texture_sampler;
uniform sampler2D province_fow;
Expand All @@ -20,10 +21,24 @@ vec4 gamma_correct(vec4 colour) {
}

void main() {

float value = abs(0.5f - tex_coord);
vec2 prov_id = texture(provinces_texture_sampler, gl_FragCoord.xy / screen_size).xy;

if (ignore_light > 0.f) {
if (texture(provinces_sea_mask, prov_id).x > 0) {
frag_color = vec4(0.0f, 0.0f, 0.0f, sin(o_dist * 2.f));
} else {
float rail = max(0.f, sin(railroad_level * o_dist * 2.f));
rail = rail * rail;
frag_color = vec4(0.0f, 0.0f, 0.0f, (value) * (value) * 4.f + rail);
}
return ;
}

float darkness = max(0.f, -dot(light_direction, space_coords) + 0.1f);

float texture_mask = texture(line_texture, vec2(o_dist, tex_coord)).r;
vec2 prov_id = texture(provinces_texture_sampler, gl_FragCoord.xy / screen_size).xy;
if (texture(provinces_sea_mask, prov_id).x > 0 || (prov_id.x == 0.f && prov_id.y == 0.f)) {
discard;
}
Expand All @@ -33,7 +48,8 @@ void main() {
float dotted_line = max(0.f, sin(o_dist * 10.f) - 0.5f);
//float value = abs( (0.5f + sin(o_dist * 1.f) * 0.2) - tex_coord);

float value = abs(0.5f - tex_coord);



vec3 inner_color = vec3(0.8f, 0.2, 0.2f);
if (ignore_light == 0.f) {
Expand Down
2 changes: 1 addition & 1 deletion src/common_types/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ enum class color_blind_mode {
};

enum class graphics_mode {
ugly, classic, modern, total
ugly, classic, modern, modern_classic, total
};


Expand Down
9 changes: 9 additions & 0 deletions src/gamestate/serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ uint8_t const* read_handwritten_scenario_section(uint8_t const* ptr_in, uint8_t
ptr_in = deserialize(ptr_in, state.map_state.map_data.coastal_vertices);
ptr_in = deserialize(ptr_in, state.map_state.map_data.coastal_starts);
ptr_in = deserialize(ptr_in, state.map_state.map_data.coastal_counts);
ptr_in = deserialize(ptr_in, state.map_state.map_data.railroad_vertices);
ptr_in = deserialize(ptr_in, state.map_state.map_data.railroad_starts);
ptr_in = deserialize(ptr_in, state.map_state.map_data.railroad_counts);
ptr_in = deserialize(ptr_in, state.map_state.map_data.province_border_vertices);
ptr_in = deserialize(ptr_in, state.map_state.map_data.province_border_starts);
ptr_in = deserialize(ptr_in, state.map_state.map_data.province_border_counts);
Expand Down Expand Up @@ -373,6 +376,9 @@ uint8_t* write_handwritten_scenario_section(uint8_t* ptr_in, sys::state& state,
ptr_in = serialize(ptr_in, state.map_state.map_data.coastal_vertices);
ptr_in = serialize(ptr_in, state.map_state.map_data.coastal_starts);
ptr_in = serialize(ptr_in, state.map_state.map_data.coastal_counts);
ptr_in = serialize(ptr_in, state.map_state.map_data.railroad_vertices);
ptr_in = serialize(ptr_in, state.map_state.map_data.railroad_starts);
ptr_in = serialize(ptr_in, state.map_state.map_data.railroad_counts);
ptr_in = serialize(ptr_in, state.map_state.map_data.province_border_vertices);
ptr_in = serialize(ptr_in, state.map_state.map_data.province_border_starts);
ptr_in = serialize(ptr_in, state.map_state.map_data.province_border_counts);
Expand Down Expand Up @@ -585,6 +591,9 @@ size_t sizeof_handwritten_scenario_section(sys::state& state, bool exclude_local
sz += serialize_size(state.map_state.map_data.coastal_vertices);
sz += serialize_size(state.map_state.map_data.coastal_starts);
sz += serialize_size(state.map_state.map_data.coastal_counts);
sz += serialize_size(state.map_state.map_data.railroad_vertices);
sz += serialize_size(state.map_state.map_data.railroad_starts);
sz += serialize_size(state.map_state.map_data.railroad_counts);
sz += serialize_size(state.map_state.map_data.province_border_vertices);
sz += serialize_size(state.map_state.map_data.province_border_starts);
sz += serialize_size(state.map_state.map_data.province_border_counts);
Expand Down
Loading
Loading