BlitzMax - 生成 2D 霓虹灯发光线效果到 png 文件

发布于 2024-10-03 05:39:21 字数 750 浏览 0 评论 0原文

我希望在 BlitzMax 中创建发光线效果,类似于星球大战光剑或激光束。不必是实时的,而只是 TImage 对象,然后可能保存为 PNG 以便以后在动画中使用。我很高兴使用 3D 功能,但它将用于 2D 游戏。

由于它将在黑色/太空背景上,我的策略是绘制一系列具有颜色和高透明度的白色模糊线,然后最终中心线不那么模糊并且更加白色。我要画的其实是贝塞尔曲线。绘制曲线很容易,但我无法使用上面的技术来创建良好的激光/霓虹灯效果,因为它看起来非常分段。因此,我认为最好在渲染良好的部分(即 1 像素贝塞尔曲线)上使用模糊效果/着色器。

我一直遇到的问题是:

  • 将着色器仅应用于屏幕上绘制线条的特定区域。如果有一种方法可以在纹理上绘制线条,然后模糊该纹理并保存 png,那就太好了。一定有办法做到这一点,但我还没有让正确的元素一起工作。任何熟悉这些东西的人的帮助将不胜感激。
  • 仅使用 2D 调用可能是有利的,更易于理解和重用。
  • 如果知道如何保存保留透明度/alpha 内容的 PNG,那就太好了。

ps 我已经审阅了这篇文章(以及其他文章),让示例正常工作,甚至开发了我自己的 5x5 着色器。但是,它是 3D 和场景范围的东西,似乎不能很好地转换为 2D 或只是某个区域。 http://www.blitzbasic.com/Community/posts.php?topic=85263

I'm looking to create a glowing line effect in BlitzMax, something like a Star Wars lightsaber or laserbeam. Doesn't have to be realtime, but just to TImage objects and then maybe saved to PNG for later use in animation. I'm happy to use 3D features, but it will be for use in a 2D game.

Since it will be on black/space background, my strategy is to draw a series of white blurred lines with color and high transparency, then eventually central lines less blurred and more white. What I want to draw is actually bezier curved lines. Drawing curved lines is easy enough, but I can't use the technique above to create a good laser/neon effect because it comes out looking very segmented. So, I think it may be better to use a blur effect/shader on what does render well, which is a 1-pixel bezier curve.

The problems I've been having are:

  • Applying a shader to just a certain area of the screen where lines are drawn. If there's a way to do draw lines to a texture and then blur that texture and save the png, that would be great to hear about. There's got to be a way to do this, but I just haven't gotten the right elements working together yet. Any help from someone familiar with this stuff would be greatly appreciated.
  • Using just 2D calls could be advantageous, simpler to understand and re-use.
  • It would be very nice to know how to save a PNG that preserves the transparency/alpha stuff.

p.s. I've reviewed this post (and others), have the samples working, and even developed my own 5x5 shader. But, it's 3D and a scene-wide thing that doesn't seem to convert to 2D or just a certain area very well.
http://www.blitzbasic.com/Community/posts.php?topic=85263

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝海似她心 2024-10-10 05:39:21

好吧,我不了解 BlitzMax,所以我无法详细介绍实现过程,但可以给您一些指导:

  • 为了仅将着色器应用于图像的特定部分,您可能需要使用多个渲染通道来构图你的场景。
  • 如果您有像素访问权限,那么当然可以在 2D 中采用“oldskool 方式”,即与片段着色器执行相同的操作。像 getpixel/setpixel 这样的东西。然而,这样你的性能会差很多。
  • 如果你有一个完整的 alpha 通道纹理,保存为带有 alpha 通道的 PNG 应该就可以了(抱歉,再次不知道如何在 BlitzMax 中具体执行此操作)。只要确保您始终使用 RGBA 模式即可。

Ok, well I don't know about BlitzMax, so I can't go into much detail regarding implementation, but to give you some pointers:

  • For applying shaders to specific parts of the image only, you will probably want to use multiple rendering passes to compose your scene.
  • If you have pixel access, doing the same things that fragment shaders do is, of course, possible "the oldskool way" in 2D, ie. something like getpixel/setpixel. However, you'll have much poorer performance this way.
  • If you have a texture with an alpha channel intact, saving in PNG with an alpha channel should Just Work (sorry, once again no idea how to do this in BlitzMax specifically). Just make sure you're using RGBA modes all along.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文