Jump to content
  • Advertisement
  • entries
  • comments
  • views

Added Fog Of War via Lighting

Sign in to follow this  


For a while, I've been looking for an easy way to add lighting to my games. Well, I stumbled across Light There Be Light (discussed here Sourceforge project here) and I've found what seems to be a really simple lighting library, used with SFML.

Using this library, I've added a Fog Of War element to the game. Basically, I'm just assigning a view range for my soldiers/towers/bases and making the lighting reach that radius:

// In EntityFactory::CreateSoldier()
ltbl::Light_Point *light = NULL;
// if local User, set light source for Fog of War
if (LocalUserId == userId) {
light = CreateLight(Soldier.ViewRange, position);
// Add light to graphics component for this soldier

TGraphicsObject *graphicComp = new TGraphicsObject(Soldier.ImageName, SOLDIERS_LAYER, light);

ltbl::Light_Point* TEntityFactory::CreateLight(cpFloat radius, cpVect position)
sf::Vector2u size = pApp->getSize();
double xPos = position.x;
double yPos = (double)size.y - position.y;
// Create a light
ltbl::Light_Point* light = new ltbl::Light_Point();
light->m_intensity = 1.0f;
light->m_center = Vec2f(xPos, yPos);
light->m_radius = radius;
light->m_size = 10.0f;
light->m_spreadAngle = ltbl::pifTimes2;
light->m_softSpreadAngle = 0.0f;
light->m_color = Color3f(1.0f, 1.0f, 1.0f);
light->m_bleed = 0.0f;
light->m_linearizeFactor = 1.0f;
return light;

This produces what I'm looking for. Granted, it looks a little weird as a typical Fog Of War, but I'm excited about the library, so I'm using it! smile.png

Here are a few pics of it with my base footsoldiers.
Sign in to follow this  


Recommended Comments

very good I am just looking for it but it's not natural what do you think ?
btw Are you making a rts game too??

Share this comment

Link to comment
Hi face08. No, I've made an RTS game in the past, but this is much simpler type game. The lighting for FOW does look a little odd, but I'm not trying to make a production-level game, but something I can have fun with.

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!