有一个简单的方法来获得阴影在OpenGL吗? [英] Is there an easy way to get shadows in OpenGL?

查看:187
本文介绍了有一个简单的方法来获得阴影在OpenGL吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近创建了一些景观代码,并添加了一些漫射照明的场景,但是,对我的失望,没有阴影。我在网上找了很多时间寻找在OpenGL中获得阴影的方法,但是它们看起来都非常复杂;

I recently created some landscape code and added some diffuse lighting to the scene, however, to my disappointment, there are no shadows. I looked around the web for hours looking for ways to get shadows in OpenGL, however they all seemed terribly complicated; and very unique to their own demo programs.

有没有任何简单的方法来创建阴影?

Are there any simple ways to make shadows?

推荐答案

否。光栅化是非常糟糕的(即使最近的AAA游戏有明显的影子文物),但每个人都与它一起生活。

No. Rasterization is very bad at this (even recent AAA games have noticeable shadow artefacts), but everybody lives with it.

解决方案包括(从最简单/最贫穷到最好/最难):

Solutions include (approx. from easiest/poorest to best/hardest) :

  • No shadows. Simply account for occlusion with darker colors. xNormal, Blender.
  • If you want an approximate shadow for a character, a simple flat polygon on the ground with a transparent and blurry texture will do. See Zelda screenshots, for instance. Even some recent games still use this.
  • Lightmaps. Static geometry only, but perfect lighting (precomputed). Reasonnably simple to implement. Lots of tools exist.
  • Shadow volumes, popularised by Carmack. Pixel perfect, reasonnably simple to implement, quite slow. Good for a few objects. No soft shadows.
  • Shadow maps. A little hard to implement if you never made any openGL. Hard to get right. Pixellated shadows. Deals with lots of polygons. Doesn't deal with big worlds.
  • Myriads of Shadow maps variants. Lots of research these recent years. Current best is Cascaded Shadow Maps : Difficult, still hard to make it look good, but fast, deals with loads of polygons and huge worlds.
  • Raytraced shadows : This may be the next-gen. Nobody really uses that except for some research papers. Very complicated, doesn't do well with dynamic worlds (yet), huge static scenes ok. Pixel perfect or soft shadows, depending on how much spare GPU you have. Several variants; as of 2014 this still didn't make in any game for performance reasons.

所以通常的伎俩是混合美丽但静态方法与动态但不是那么好的方法。例如,请参阅我的光照贴图阴影映射

So the usual trick is to mix beautiful-but-static-only approaches with dynamic-but-not-that-good approaches. For instance, see my tutorials on lightmapping and shadowmapping.

这篇关于有一个简单的方法来获得阴影在OpenGL吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆