简体   繁体   English

OpenGL C ++ SDL 2D阴影

[英]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? 我想出了如何仅用1个光源制作阴影,但是如果您有更多光源,该怎么办呢? How to pass OpenGL 8 light sources limit? 如何通过OpenGL 8光源限制?

I'm working with C++, OpenGL and SDL. 我正在使用C ++,OpenGL和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. 我的建议是跳过所有有关固定功能管道的教程,直接进入GL3.3 +时代:有关某些教程,请参见: https//github.com/McNopper/OpenGL

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 将最终亮度值的所有贡献相加

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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