Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: OpenGL- Shadow Mapping

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2011
    Location
    Québec,Canada
    Posts
    9

    OpenGL- Shadow Mapping

    Hi guys, it's my first post here . I've try to implement shadow mapping in my game engine and i have some issue.

    I really need someone to help me figure 2 or 3 thing. You can see a big part of my source code here: http://pastebin.com/sXTr2ets.
    I have post on Gamedev too so if you want to see a screenshot that show where my work is going, click:
    http://www.gamedev.net/topic/616709-opengl-lighting/

    okay what i need help with is:

    1- find a place and a way to squeeze my texture back in the code.
    2- find a way to use multiple light (should i use 1 shadowMap for every light or 1 per light)

  2. #2
    Senior Member Regular Contributor
    Join Date
    Oct 2010
    Location
    France
    Posts
    458

    Re: OpenGL- Shadow Mapping

    I haven't read your code but what I can say from your questions is that you should use a shadow map for each light. Shadow maps are rendered in the light view space.

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2011
    Location
    Québec,Canada
    Posts
    9

    Re: OpenGL- Shadow Mapping

    Is it very bad to have many lights? Because i'm planning to use maybe 10-12 lights in my map.

    And for the multiple shadowmap, do i have to repeat the 3 drawing pass for every light with a different shadow map and lightmatix? that sound excessive...

    And i have another question: My shadow map try to apply to the whole map everytime. What i mean by that is: is that when it reach a certain distance from the light, it just stretch the limit to the map border. That create false lit area. Is there a way to shadow everything that go pass the limit of what he can generate?

  4. #4
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,674

    Re: OpenGL- Shadow Mapping

    Generally, you only pick one or two lights for shadow-mapping. This is just for performance reasons. The rest don't cast shadows.

  5. #5
    Junior Member Newbie
    Join Date
    Dec 2011
    Location
    Québec,Canada
    Posts
    9

    Re: OpenGL- Shadow Mapping

    Okay so basically i shadow map the nearest light that the camera can see? Because the way i have drawn the map, i would need a light for every room and outside too. + one on the player if he have a flashlight or whatever.

    Is it better to use another technique if i want to cast shadow for that much light?

  6. #6
    Senior Member Regular Contributor
    Join Date
    Oct 2010
    Location
    France
    Posts
    458

    Re: OpenGL- Shadow Mapping

    Use the most influencing lights, ie the sun, the main light of each room and the player's light.

    "Render" only the lights that have an influence on the scene. For example the light two rooms far away or far behind and that is hidden by walls does not have to be "rendered". Otherwise, it can have a bad influence on the scene (it can lit parts of the scene that it should not - because of walls).

  7. #7
    Junior Member Newbie
    Join Date
    Dec 2011
    Location
    Québec,Canada
    Posts
    9

    Re: OpenGL- Shadow Mapping

    kk... so for example outside i render the sun light + mine. Inside main room i render the main room light + mine and the same for other room... That sound hard to implement considering the fact that it took me about 1 week to make shadow the way it's looking now :P But yeah i will give it a try.

    I had another idea (not sure if that would work)
    Say that every room have a light but one that doesn't cast shadow. and imagine the only light that cast shadow, is the player light (so basically, all the map is not in complete dark, the shadow isn't really what not being lit, but what the player don't see). Does that make sense?

  8. #8
    Senior Member Regular Contributor nickels's Avatar
    Join Date
    Feb 2000
    Location
    Colorado
    Posts
    284

    Re: OpenGL- Shadow Mapping

    Using a simple forward shader you run out of varyings very quickly with multiple lights and shadow maps.
    I switched to deferred and can pretty easily accomodate at least 5 or 6 shadow map lights with no problems. The next step is to implement lighting occlusion/level of detail (i.e. switch off the shadow map when far away)...

    Oh yeah, another thought: I have shadow maps embedded in my quake levels and I intersect the light cone with the quake visibility clusters, which allows me to only draw a subset of the quake world in the shadow map depth buffer pass (the faces in the active visibility clusters).

    Its a rabbit hold for sure, but fun stuff...

    e.g.
    deferred plus shadow maps

  9. #9
    Junior Member Newbie
    Join Date
    Dec 2011
    Location
    Québec,Canada
    Posts
    9

    Re: OpenGL- Shadow Mapping

    Okay cool thank you, but i don't think i'm ready to handle something as complex as defered... I'm not sure either if my game really need such a technique. The graphic i'm trying to get seem so less complicated than what is hsown in your video. Have you played Subvein? (http://www.youtube.com/watch?v=fwr2CxrbXA8)
    That's about the same kind of shadow/graphic i'm trying to implement in my engine.

  10. #10
    Senior Member Regular Contributor nickels's Avatar
    Join Date
    Feb 2000
    Location
    Colorado
    Posts
    284

    Re: OpenGL- Shadow Mapping

    Cool looking game. Lots of cool particle effects; never quite got that far with things.
    A lot of the lights in that game might be precomputed as well (although I guess that doesn't really help with shadows....)
    Its those darn dynamic objects that cause all the problems!!!

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 1
    Last Post: 04-13-2017, 02:23 AM
  2. Cascaded Shadow Mapping in OpenGL
    By OpenGL_man in forum OpenGL: Advanced Coding
    Replies: 8
    Last Post: 11-08-2014, 09:23 AM
  3. OpenGL Shadow Mapping problem
    By Donnie in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 09-05-2014, 08:28 AM
  4. Is Shadow Mapping possible in OpenGL ES 1.0 ?
    By lgmcben in forum OpenGL ES
    Replies: 2
    Last Post: 03-08-2010, 03:44 PM
  5. Shadow Mapping in OpenGL
    By royconejo in forum OpenGL: Advanced Coding
    Replies: 20
    Last Post: 05-11-2001, 03:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean