Jump to content
  • Advertisement
Sign in to follow this  
nimda

OpenGL Spotlight wallhacks my maze

This topic is 3341 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

OPENGL-GLUT I'm currently trying to make a maze with 5 different rooms. In which I want to put different spotlights. Problem is that the light isn't stopped by the walls.
        ROOM1           ROOM2
______________________________________
|                 ||                 |
|                 ||                 |
|                 ||    this room    |
|spotlight ->     || is lit as well  |
|                 ||                 |
|_________________||_________________|


I have no idea how to solve this, at the moment all spotlights point outwards from the middle but it's not a solution in the long run. Is this maybe a shadow thing? Well all help is appreciated, hope there's someone with knowledge about this that have a minute to spare. Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
Yes, you're right, this problem is about shadows.
Since there's a wall separating both rooms, no light would reach Room2, and it would be in shadow. But OpenGl doesnt know about walls, so you have at least two options.
1- Implement some form of shadows, look for stencil shadows or shadowmaps. This is a complex topic.
2- The easy way is to calculate the spotlights that light each room, and when you drawing the room, disable the lights that are blocked by walls.

Share this post


Link to post
Share on other sites
Have you implemented shadows yet? Because light just illuminates an area - it is the wall's shadow which prevents light from affecting anything behind the wall.

Share this post


Link to post
Share on other sites
Thanks for the help. This is actually a school project and there was nothing mentioned about shadows in the task. Also I'm on a tight schedule so I go with number 2 and just disable them.

Share this post


Link to post
Share on other sites
A simple solution would be to render each room one by one with its own light (i.e. set light pos + colour, render room, change light pos + colour, render room, etc.)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!