Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

LEAF - Lighting effects setting made easier.

arev

Sponsor

Lighting Effects with Additional Fogs

This script automatically loads additional light maps and shadow maps for every map for which proper pictures are present if the "Fogs" folder. Those maps act like fogs, but still let us use the normal fog. Detailed instructions are in the script, but if you'll have some questions regarding the functioning of the script post them in here.

Script:
Code:
#=============================================================================
# ** Lighting Effects with Additional Fogs
#
# ** coded by arevulopapo, concept by Ludzix
#    Jul 8th 2007
#=============================================================================
# This script automatically sets a light map and a shadow map for every game map
# if required files are present in the fogs folder. For shadow maps the file must
# be named sID.png, where ID is the Map ID. For example: for map with ID of 3
# the file should be named s3.png (only .png files are accepted for shadow maps).
# For light maps the file can be in either .png, .jpg or .bmp format. The name
# of the light map file must include the type of blending in which the file will
# be displayed over the game map. General file name is lID b_TYPE.EXT, where
# ID is the Map ID, TYPE is the blending type (0 - normal, 1 - additive,
# 2 - substractive) and EXT is of the extensions mentioned above.
# For game map No. 3, and additive blending the file should be named as follows:
# l3 b_1.jpg (the SPACE between Map ID and blending is required).
# Both maps are displayed over the tilemap/events and under the fog.
#=============================================================================
class Spriteset_Map
  
  alias ssm_initialize initialize
  alias ssm_dispose dispose
  alias ssm_update update
  
  def initialize
    @shadow_layer = Sprite.new
    @shadow_layer.z = 2900
    @lighting_layer = Sprite.new
    @lighting_layer.z = 2950
    ssm_initialize
  end
  
  def dispose
    @shadow_layer.dispose
    @lighting_layer.dispose
    ssm_dispose
  end
  
  def update
    shadow = "Graphics/Fogs/s" + $game_map.map_id.to_s
    light = "Graphics/Fogs/l" + $game_map.map_id.to_s
    if FileTest.exist?(shadow + ".png")
      @shadow_layer.bitmap = RPG::Cache.fog("s" + $game_map.map_id.to_s, 0)
    else
      @shadow_layer.bitmap = nil
    end
    if FileTest.exist?(light + " b_0.png") or FileTest.exist?(light + " b_0.jpg") or FileTest.exist?(light + " b_0.bmp")
      @lighting_layer.bitmap = RPG::Cache.fog("l" + $game_map.map_id.to_s, 0)
      @lighting_layer.blend_type = 0
    elsif FileTest.exist?(light + " b_1.png") or FileTest.exist?(light + " b_1.jpg") or FileTest.exist?(light + " b_1.bmp")
      @lighting_layer.bitmap = RPG::Cache.fog("l" + $game_map.map_id.to_s + " b_1", 0)
      @lighting_layer.blend_type = 1
    elsif FileTest.exist?(light + " b_2.png") or FileTest.exist?(light + " b_2.jpg") or FileTest.exist?(light + " b_2.bmp")
      @lighting_layer.bitmap = RPG::Cache.fog("l" + $game_map.map_id.to_s + " b_2", 0)
      @lighting_layer.blend_type = 2
    else
      @lighting_layer.bitmap = nil
    end
    @shadow_layer.ox = $game_map.display_x / 4
    @shadow_layer.oy = $game_map.display_y / 4
    @lighting_layer.ox = $game_map.display_x / 4
    @lighting_layer.oy = $game_map.display_y / 4
    ssm_update
  end
  
end

Screen:
http://kushi.nazwa.pl/ar/rgss/images/leaf.jpg[/img]

Demo:
http://kushi.nazwa.pl/ar/rgss/demos/leaf.exe

Credits to Ludzix for the idea, and to me for bringing it to life :)

Compatibility issues not yet known.
 
You should post some pictures on how it works... I don't really understand what this script does. A demo would be nice to show us how to make the lighting effects.
 
I agree with itachi about adding a demo, From what was said I think this is a script that lets you use two fogs to create better lighting effects.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top