Improved the fade transitions between [time_area]s

The n,ne,se,s,sw,nw-style transitions don't work well with transparency, so this makes the transitions corner-based which allows the fade to be longer and smoother.
This commit is contained in:
ln-zookeeper 2016-12-19 21:10:32 +02:00
parent 3621a38a29
commit e02df2f21c
29 changed files with 90 additions and 12 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 701 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 701 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 873 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 625 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 445 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 571 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 623 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 538 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 699 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 498 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 679 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 615 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 596 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 622 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 608 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 510 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 698 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 837 B

View file

@ -1110,20 +1110,90 @@ std::vector<surface> display::get_terrain_images(const map_location &loc,
//get all the light transitions
map_location adjs[6];
get_adjacent_tiles(loc,adjs);
for(int d=0; d<6; ++d){
const time_of_day& atod = get_time_of_day(adjs[d]);
if(atod.color == tod.color)
/* concave
_____
/ \
/ atod1 \_____
\ !tod / \
\_____/ atod2 \
/ \__\ !tod /
/ \_____/
\ tod /
\_____/*/
const time_of_day& atod1 = get_time_of_day(adjs[d]);
const time_of_day& atod2 = get_time_of_day(adjs[(d + 1) % 6]);
if(atod1.color == tod.color || atod2.color == tod.color || atod1.color != atod2.color)
continue;
if(lt.empty()) {
//color the full hex before adding transitions
tod_color col = tod.color + color_adjust_;
lt = image::get_light_string(6, col.r, col.g, col.b);
lt = image::get_light_string(0, col.r, col.g, col.b);
}
// add the directional transitions
tod_color acol = atod.color + color_adjust_;
lt += image::get_light_string(d, acol.r, acol.g, acol.b);
tod_color acol = atod1.color + color_adjust_;
lt += image::get_light_string(d + 1, acol.r, acol.g, acol.b);
}
for(int d=0; d<6; ++d){
/* convex 1
_____
/ \
/ atod1 \_____
\ !tod / \
\_____/ atod2 \
/ \__\ tod /
/ \_____/
\ tod /
\_____/*/
const time_of_day& atod1 = get_time_of_day(adjs[d]);
const time_of_day& atod2 = get_time_of_day(adjs[(d + 1) % 6]);
if(atod1.color == tod.color || atod1.color == atod2.color)
continue;
if(lt.empty()) {
//color the full hex before adding transitions
tod_color col = tod.color + color_adjust_;
lt = image::get_light_string(0, col.r, col.g, col.b);
}
// add the directional transitions
tod_color acol = atod1.color + color_adjust_;
lt += image::get_light_string(d + 7, acol.r, acol.g, acol.b);
}
for(int d=0; d<6; ++d){
/* convex 2
_____
/ \
/ atod1 \_____
\ tod / \
\_____/ atod2 \
/ \__\ !tod /
/ \_____/
\ tod /
\_____/*/
const time_of_day& atod1 = get_time_of_day(adjs[d]);
const time_of_day& atod2 = get_time_of_day(adjs[(d + 1) % 6]);
if(atod2.color == tod.color || atod1.color == atod2.color)
continue;
if(lt.empty()) {
//color the full hex before adding transitions
tod_color col = tod.color + color_adjust_;
lt = image::get_light_string(0, col.r, col.g, col.b);
}
// add the directional transitions
tod_color acol = atod2.color + color_adjust_;
lt += image::get_light_string(d + 13, acol.r, acol.g, acol.b);
}
if(lt.empty()){

View file

@ -593,12 +593,16 @@ static surface apply_light(surface surf, const light_string& ls){
if(i != lightmaps_.end()) {
lightmap = i->second;
} else {
//build all the 7 paths for lightmap sources
static const std::string p = "terrain/light";
static const std::string lm_img[7] = {
p+"-n.png", p+"-ne.png", p+"-se.png",
p+"-s.png", p+"-sw.png", p+"-nw.png",
p+".png"
//build all the paths for lightmap sources
static const std::string p = "terrain/light/light";
static const std::string lm_img[19] = {
p+".png",
p+"-concave-2-tr.png", p+"-concave-2-r.png", p+"-concave-2-br.png",
p+"-concave-2-bl.png", p+"-concave-2-l.png", p+"-concave-2-tl.png",
p+"-convex-br-bl.png", p+"-convex-bl-l.png", p+"-convex-l-tl.png",
p+"-convex-tl-tr.png", p+"-convex-tr-r.png", p+"-convex-r-br.png",
p+"-convex-l-bl.png", p+"-convex-tl-l.png", p+"-convex-tr-tl.png",
p+"-convex-r-tr.png", p+"-convex-br-r.png", p+"-convex-bl-br.png"
};
//decompose into atomic lightmap operations (4 chars)

View file

@ -136,7 +136,11 @@ namespace image {
///light_string store colors info of central and adjacent hexes.
///The structure is one or several 4 chars blocks (L,R,G,B)
///where RGB is the color and L is the lightmap to use:
///(-1:none, 0-5:transition in each direction, 6:full hex)
/// -1: none
/// 0: full hex
/// 1-6: concave corners
/// 7-12: convex half-corners 1
///13-19: convex half-corners 2
typedef std::basic_string<signed char> light_string;
///return light_string of one light operation(see above)
light_string get_light_string(int op, int r, int g, int b);