diff --git a/Block.cpp b/Block.cpp index 7ece489f..c5b28afd 100644 --- a/Block.cpp +++ b/Block.cpp @@ -602,8 +602,8 @@ void drawFloorBlood ( Block *b, int32_t drawx, int32_t drawy ) int sheetOffsetX = TILEWIDTH * (sprite.sheetIndex % SHEET_OBJECTSWIDE), sheetOffsetY = 0; - al_draw_tinted_bitmap_region( IMGBloodSheet, b->bloodcolor, sheetOffsetX, sheetOffsetY, TILEWIDTH, TILEHEIGHT+FLOORHEIGHT, drawx, drawy, 0); - al_draw_tinted_bitmap_region( IMGBloodSheet, al_map_rgb(255,255,255), sheetOffsetX, sheetOffsetY+TILEHEIGHT+FLOORHEIGHT, TILEWIDTH, TILEHEIGHT+FLOORHEIGHT, drawx, drawy, 0); + al_draw_tinted_bitmap_region( IMGBloodSheet, premultiply(b->bloodcolor), sheetOffsetX, sheetOffsetY, TILEWIDTH, TILEHEIGHT+FLOORHEIGHT, drawx, drawy, 0); + al_draw_bitmap_region( IMGBloodSheet, sheetOffsetX, sheetOffsetY+TILEHEIGHT+FLOORHEIGHT, TILEWIDTH, TILEHEIGHT+FLOORHEIGHT, drawx, drawy, 0); } } diff --git a/Config.cpp b/Config.cpp index 3d47c3d4..d1bbf4fe 100644 --- a/Config.cpp +++ b/Config.cpp @@ -160,27 +160,19 @@ void parseConfigLine( string line ){ } if( line.find("[FOG_RED") != -1){ int value = parseIntFromLine( "FOG_RED", line); - if(value > 255) value = 255; - if(value < 0) value = 0; - config.fogr = value; + config.fogr = value / 255.0; } if( line.find("[FOG_GREEN") != -1){ int value = parseIntFromLine( "FOG_GREEN", line); - if(value > 255) value = 255; - if(value < 0) value = 0; - config.fogg = value; + config.fogg = value / 255.0; } if( line.find("[FOG_BLUE") != -1){ int value = parseIntFromLine( "FOG_BLUE", line); - if(value > 255) value = 255; - if(value < 0) value = 0; - config.fogb = value; + config.fogb = value / 255.0; } if( line.find("[FOG_ALPHA") != -1){ int value = parseIntFromLine( "FOG_ALPHA", line); - if(value > 255) value = 255; - if(value < 0) value = 0; - config.foga = value; + config.foga = value / 255.0; } if( line.find("[SHOW_FOG") != -1){ string result = parseStrFromLine( "SHOW_FOG", line ); diff --git a/GUI.cpp b/GUI.cpp index 0534ff30..1820a6f6 100644 --- a/GUI.cpp +++ b/GUI.cpp @@ -47,11 +47,23 @@ vector IMGFilenames; GLhandleARB tinter; GLhandleARB tinter_shader; Crd3D debugCursor; + +ALLEGRO_COLOR premultiply(ALLEGRO_COLOR input) +{ + ALLEGRO_COLOR out; + out.a = input.a; + out.r = input.r * input.a; + out.g = input.g * input.a; + out.b = input.b * input.a; + return out; +} + void draw_diamond(float x, float y, ALLEGRO_COLOR color) { al_draw_filled_triangle(x, y, x+4, y+4, x-4, y+4, color); al_draw_filled_triangle(x+4, y+4, x, y+8, x-4, y+4, color); } + void draw_borders(float x, float y, uint8_t borders) { if(borders & 1) @@ -618,7 +630,7 @@ void DrawSpriteFromSheet( int spriteNum, ALLEGRO_BITMAP* spriteSheet, ALLEGRO_CO color.g *= 0.25f; color.b *= 0.25f; } - al_draw_tinted_bitmap_region(spriteSheet, color, sheetx * SPRITEWIDTH, sheety * SPRITEHEIGHT, SPRITEWIDTH, SPRITEHEIGHT, x, y - (WALLHEIGHT), 0); + al_draw_tinted_bitmap_region(spriteSheet, premultiply(color), sheetx * SPRITEWIDTH, sheety * SPRITEHEIGHT, SPRITEWIDTH, SPRITEHEIGHT, x, y - (WALLHEIGHT), 0); } ALLEGRO_BITMAP * CreateSpriteFromSheet( int spriteNum, ALLEGRO_BITMAP* spriteSheet) @@ -641,7 +653,7 @@ void DrawSpriteIndexOverlay(int imageIndex){ currentImage=IMGFilelist[imageIndex]; } al_clear_to_color(al_map_rgb(255, 0, 255)); - al_draw_tinted_bitmap(currentImage, al_map_rgb(255,255,255),0,0,0); + al_draw_bitmap(currentImage,0,0,0); for(int i =0; i<= 20*SPRITEWIDTH; i+=SPRITEWIDTH) al_draw_line(i,0,i, al_get_bitmap_height(al_get_target_bitmap()), al_map_rgb(0,0,0), 0); for(int i =0; i< al_get_bitmap_height(al_get_target_bitmap()); i+=SPRITEHEIGHT) diff --git a/SpriteObjects.cpp b/SpriteObjects.cpp index a63e8614..ddd38a51 100644 --- a/SpriteObjects.cpp +++ b/SpriteObjects.cpp @@ -676,9 +676,9 @@ void c_sprite::draw_world_offset(int x, int y, int z, Block * b, int tileoffset, if(chop && ( halftile == HALFTILECHOP)) { if(fileindex < 0) - al_draw_tinted_bitmap_region(defaultsheet, shade_color, sheetx, sheety+WALL_CUTOFF_HEIGHT, spritewidth, spriteheight-WALL_CUTOFF_HEIGHT, drawx + offset_x + offset_user_x, drawy + offset_user_y + (offset_y - WALLHEIGHT)+WALL_CUTOFF_HEIGHT, 0); + al_draw_tinted_bitmap_region(defaultsheet, premultiply(shade_color), sheetx, sheety+WALL_CUTOFF_HEIGHT, spritewidth, spriteheight-WALL_CUTOFF_HEIGHT, drawx + offset_x + offset_user_x, drawy + offset_user_y + (offset_y - WALLHEIGHT)+WALL_CUTOFF_HEIGHT, 0); else - al_draw_tinted_bitmap_region(getImgFile(fileindex), shade_color, sheetx, (sheety)+WALL_CUTOFF_HEIGHT, spritewidth, spriteheight-WALL_CUTOFF_HEIGHT, drawx + offset_x + offset_user_x, drawy + offset_user_y + (offset_y - WALLHEIGHT)+WALL_CUTOFF_HEIGHT, 0); + al_draw_tinted_bitmap_region(getImgFile(fileindex), premultiply(shade_color), sheetx, (sheety)+WALL_CUTOFF_HEIGHT, spritewidth, spriteheight-WALL_CUTOFF_HEIGHT, drawx + offset_x + offset_user_x, drawy + offset_user_y + (offset_y - WALLHEIGHT)+WALL_CUTOFF_HEIGHT, 0); //draw cut-off floor thing al_draw_bitmap_region(IMGObjectSheet, TILEWIDTH * SPRITEFLOOR_CUTOFF, 0, @@ -690,9 +690,9 @@ void c_sprite::draw_world_offset(int x, int y, int z, Block * b, int tileoffset, if((isoutline == OUTLINENONE) || ((isoutline == OUTLINERIGHT) && (b->depthBorderNorth)) || ((isoutline == OUTLINELEFT) && (b->depthBorderWest)) || ((isoutline == OUTLINEBOTTOM) && (b->depthBorderDown))) { if(fileindex < 0) - al_draw_tinted_bitmap_region(defaultsheet, shade_color, sheetx, sheety, spritewidth, spriteheight, drawx + offset_x + offset_user_x, drawy + offset_user_y + (offset_y - WALLHEIGHT), 0); + al_draw_tinted_bitmap_region(defaultsheet, premultiply(shade_color), sheetx, sheety, spritewidth, spriteheight, drawx + offset_x + offset_user_x, drawy + offset_user_y + (offset_y - WALLHEIGHT), 0); else - al_draw_tinted_bitmap_region(getImgFile(fileindex), shade_color, sheetx, sheety, spritewidth, spriteheight, drawx + offset_x + offset_user_x, drawy + offset_user_y + (offset_y - WALLHEIGHT), 0); + al_draw_tinted_bitmap_region(getImgFile(fileindex), premultiply(shade_color), sheetx, sheety, spritewidth, spriteheight, drawx + offset_x + offset_user_x, drawy + offset_user_y + (offset_y - WALLHEIGHT), 0); } if(needoutline) { diff --git a/WorldSegment.cpp b/WorldSegment.cpp index e9c3a741..c8801e4d 100644 --- a/WorldSegment.cpp +++ b/WorldSegment.cpp @@ -199,9 +199,6 @@ void WorldSegment::drawAllBlocks(){ int32_t vsymax = viewedSegment->sizey-1; int32_t vszmax = viewedSegment->sizez-1; // grabbing one tile +z more than we should for tile rules //al_hold_bitmap_drawing(true); - int op, src, dst, alpha_op, alpha_src, alpha_dst; - ALLEGRO_COLOR color; - al_get_separate_blender(&op, &src, &dst, &alpha_op, &alpha_src, &alpha_dst); for(int32_t vsz=0; vsz < vszmax; vsz++) { @@ -213,7 +210,7 @@ void WorldSegment::drawAllBlocks(){ { fog = al_create_bitmap(al_get_bitmap_width(temp), al_get_bitmap_height(temp)); al_set_target_bitmap(fog); - al_clear_to_color(al_map_rgb(config.fogr, config.fogg, config.fogb)); + al_clear_to_color(premultiply(al_map_rgba_f(config.fogr, config.fogg, config.fogb, config.foga))); al_set_target_bitmap(temp); } if(!((al_get_bitmap_width(fog) == al_get_bitmap_width(temp)) && (al_get_bitmap_height(fog) == al_get_bitmap_height(temp)))) @@ -221,10 +218,10 @@ void WorldSegment::drawAllBlocks(){ al_destroy_bitmap(fog); fog = al_create_bitmap(al_get_bitmap_width(temp), al_get_bitmap_height(temp)); al_set_target_bitmap(fog); - al_clear_to_color(al_map_rgb(config.fogr, config.fogg, config.fogb)); + al_clear_to_color(al_map_rgba_f(config.fogr*config.foga, config.fogg*config.foga, config.fogb*config.foga, config.foga)); al_set_target_bitmap(temp); } - al_draw_tinted_bitmap(fog, al_map_rgba(255, 255, 255, config.foga), 0, 0, 0); + al_draw_bitmap(fog, 0, 0, 0); } if(vsz == vszmax-1) { diff --git a/common.h b/common.h index 720576a7..bc3d563d 100644 --- a/common.h +++ b/common.h @@ -245,3 +245,5 @@ extern ALLEGRO_MOUSE_STATE mouse; #define FORM_LOG 4 extern int randomCube[RANDOM_CUBE][RANDOM_CUBE][RANDOM_CUBE]; + +ALLEGRO_COLOR premultiply(ALLEGRO_COLOR input); diff --git a/commonTypes.h b/commonTypes.h index d4ad7299..0ec25eb2 100644 --- a/commonTypes.h +++ b/commonTypes.h @@ -140,10 +140,10 @@ typedef struct { int screenHeight; bool Fullscreen; bool show_intro; - int fogr; - int fogg; - int fogb; - int foga; + float fogr; + float fogg; + float fogb; + float foga; int backr; int backg; int backb; diff --git a/init.txt b/init.txt index 1cdbc2fc..db6f7a09 100644 --- a/init.txt +++ b/init.txt @@ -54,7 +54,7 @@ Sets weather screenshots should have transparent backgrounds Fog color, and alpha at the bottom z-level. Setting the alpha to 0, or SHOW_FOG to NO disables fog, for a slight performance increase. Color and alpha ranges are 0 (min) to 255 (max) -[SHOW_FOG:NO] +[SHOW_FOG:YES] [FOG_RED:128] [FOG_GREEN:158] [FOG_BLUE:177] diff --git a/stonesense.exe b/stonesense.exe index 0184eeec..ec92c195 100644 Binary files a/stonesense.exe and b/stonesense.exe differ