<tfoot id='Qz5bW'></tfoot>
  • <small id='Qz5bW'></small><noframes id='Qz5bW'>

    <i id='Qz5bW'><tr id='Qz5bW'><dt id='Qz5bW'><q id='Qz5bW'><span id='Qz5bW'><b id='Qz5bW'><form id='Qz5bW'><ins id='Qz5bW'></ins><ul id='Qz5bW'></ul><sub id='Qz5bW'></sub></form><legend id='Qz5bW'></legend><bdo id='Qz5bW'><pre id='Qz5bW'><center id='Qz5bW'></center></pre></bdo></b><th id='Qz5bW'></th></span></q></dt></tr></i><div id='Qz5bW'><tfoot id='Qz5bW'></tfoot><dl id='Qz5bW'><fieldset id='Qz5bW'></fieldset></dl></div>

        <legend id='Qz5bW'><style id='Qz5bW'><dir id='Qz5bW'><q id='Qz5bW'></q></dir></style></legend>
          <bdo id='Qz5bW'></bdo><ul id='Qz5bW'></ul>
      1. 我应该如何渲染 2D 手电筒效果?

        时间:2023-05-19
          <tbody id='vQUw5'></tbody>
      2. <legend id='vQUw5'><style id='vQUw5'><dir id='vQUw5'><q id='vQUw5'></q></dir></style></legend>

        <small id='vQUw5'></small><noframes id='vQUw5'>

          <bdo id='vQUw5'></bdo><ul id='vQUw5'></ul>
          <tfoot id='vQUw5'></tfoot>

          1. <i id='vQUw5'><tr id='vQUw5'><dt id='vQUw5'><q id='vQUw5'><span id='vQUw5'><b id='vQUw5'><form id='vQUw5'><ins id='vQUw5'></ins><ul id='vQUw5'></ul><sub id='vQUw5'></sub></form><legend id='vQUw5'></legend><bdo id='vQUw5'><pre id='vQUw5'><center id='vQUw5'></center></pre></bdo></b><th id='vQUw5'></th></span></q></dt></tr></i><div id='vQUw5'><tfoot id='vQUw5'></tfoot><dl id='vQUw5'><fieldset id='vQUw5'></fieldset></dl></div>

                  本文介绍了我应该如何渲染 2D 手电筒效果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我正在尝试在我的 2D 游戏中制作手电筒效果.我的手电筒表示为从实体以特定角度延伸的线段.手电筒可以指向任何方向.手电筒的强度也不同(手电筒光束的长度).

                  I'm trying to make a flashlight effect in my 2D game. My flashlight is represented as a line segment extending from the entity at a specific angle. The flashlight can point in any direction. The flashlight also varies in intensity (length of the flashlight beam).

                  我在试图找出渲染手电筒效果的最佳(最简单?)和最灵活的方法时遇到了问题.尤其是平铺地图.

                  I'm have a problem trying to figure out the best (easiest?) and most flexible way to render the flashlight effect. Particularly with the tiled map.

                  我可以想到两种方法.但我不知道要实现它们:

                  I can think of two methods. But I have no idea to implement them:

                  1. 仅绘制平铺地图的锥形/圆形部分
                  2. 用黑色纹理覆盖屏幕,并用代码在黑色纹理上打孔.这样我可以改变洞的属性.

                  我不知道从哪里开始/这些被称为什么/如果 libGDX 可以做到.

                  I'm clueless as to where to start with this/what these are called/if libGDX can do them.

                  推荐答案

                  一号称为模板缓冲区.但是你会发现很难达到柔和的效果.-- 简单.

                  Number one is called stencil buffer. But you'll find it difficult to achieve soft effects. -- Easy.

                  第二个:你只需要一个有光的纹理.可以绘制完全黑色的区域,在灯光精灵周围重复一个黑色精灵(左、右、上、下).或者您可以将它与模板缓冲区混合.或者您可以仔细计算纹理坐标并使用 GL.clamp_to_edge 传播所有黑色像素.根据渲染场景的方式,您可以先使用 alpha 信息渲染灯光,然后混合场景(根据 dst_alpha 变暗).-- 实现起来并不难.

                  Number two: You just need a texture with the light. The completely black areas can be drawn repeating a black sprite around the light sprite (left, right, up, down). Or you can mix it with the stencil buffer. Or you can carefully calculate your texture coordinates and use GL.clamp_to_edge to propagate all the black pixels. Depending on how you render your scene, you can render your light first with alpha information and then blend the scene (darkening according to the dst_alpha). -- Not that hard to implement.

                  第三个是对着色器的研究(GLES 2.0).您可以渲染网格以填充孔屏幕并通过一些着色器计算使其变暗.-- 这是最灵活的选择,也是最困难的(反正远非火箭科学).

                  Number three would be research on shaders (GLES 2.0). You can render a mesh to fill the hole screen and darken it with some shader calculations. -- This is the most flexible option, and the most difficult (far from rocket science anyway).

                  有些选项听起来比其他选项更好,但提供您提供的信息,我无法告诉您更多信息.你有一个很好的起点,可以从哪里开始研究.

                  Some options sound better than others, but providing the info you gave, there's nothing more I can tell you. You have a good start point from where to start to research on.

                  **如果您选择使用纹理,请考虑使用几种不同的纹理,具体取决于电池.您可以稍微缩放它们或给它们着色,但是使用不同的纹理更加灵活.

                  **If you choose working with textures, consider to have a couple of different textures depending on the battery. You can scale them a bit or tint them, but having different textures is way more flexible.

                  这篇关于我应该如何渲染 2D 手电筒效果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:来自 LibGDX 中的 texturepacker 的纹理 下一篇:libGDX - 添加分数和显示在屏幕的左上角?

                  相关文章

                  最新文章

                  • <bdo id='14oOi'></bdo><ul id='14oOi'></ul>
                • <legend id='14oOi'><style id='14oOi'><dir id='14oOi'><q id='14oOi'></q></dir></style></legend>

                  <i id='14oOi'><tr id='14oOi'><dt id='14oOi'><q id='14oOi'><span id='14oOi'><b id='14oOi'><form id='14oOi'><ins id='14oOi'></ins><ul id='14oOi'></ul><sub id='14oOi'></sub></form><legend id='14oOi'></legend><bdo id='14oOi'><pre id='14oOi'><center id='14oOi'></center></pre></bdo></b><th id='14oOi'></th></span></q></dt></tr></i><div id='14oOi'><tfoot id='14oOi'></tfoot><dl id='14oOi'><fieldset id='14oOi'></fieldset></dl></div>

                  <tfoot id='14oOi'></tfoot>

                    <small id='14oOi'></small><noframes id='14oOi'>