简体   繁体   中英

OpenGL C++ SDL 2D Shadows

Currently I'm working on my game, I'm stuck with lights and shadows. I figured out how to make shadows with only 1 light source, but how to do it if you have more light sources? How to pass OpenGL 8 light sources limit?

I'm working with C++, OpenGL and SDL.

These two videos show exactly what i want.

My suggestion is to skip all the tutorials about fixed function pipeline and go straight to the GL3.3+ era: see: https://github.com/McNopper/OpenGL for some tutorials.

Anyway, if you are talking about shadow-mapping, then you decide how many lights an object can support (even on a per-object basis) and in your shader :

  • receive one shadow map for each supported light
  • receive one set of light parameters for each supported light
  • at each pixel determine if the light is visible, for each light
  • if the light is visible (not in shadow), calculate the contribution of the light
  • sum all the contributions for the final luminance value

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM