帮助我使用 WebGL 和带有许多纹理喷溅/混合的高度图

发布于 2024-11-28 08:02:22 字数 211 浏览 2 评论 0原文

我想开始一个新的爱好项目,这是一个基于 WebGL 的实时策略游戏。我过去的 RTS 游戏很简单,是用 XNA/C# 制作的。现在我想要它在网络上并且我想要一个合适的地形。我发现地形飞溅很难理解/实现,是否有一个好的实现可以在我的下一个游戏中烘焙?

或者,是否有支持此功能的库/框架?

我正在寻找资源/文章/教程/库/框架来帮助我使用多个纹理很好地混合在一起来制作高度图地形。

I would like to begin a new hobby project which is a real-time strategy game on WebGL. My past RTS game was simple and it was made with XNA/C#. Now I want it on the web and I want a proper terrain. I find terrain splatting hard to understand/implement, is there a good implementation available already that I could bake in my next game?

Alternatively, is there a library/framework that has a support for this?

I am looking for resources/articles/tutorials/libraries/frameworks that help me out with a height map terrain using multiple textures blended nicely together.

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

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

发布评论

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

评论(1

盛装女皇 2024-12-05 08:02:22

我将把我的答案分成两部分,这样你就有了你要问的和你“应该”问的:-)。

最好的选择是充分掌握 GLSL。如果您正在这样做或从中获得乐趣,您应该学习这个之类的教程。使用着色器实现地形引擎非常简单(您可以根据任意纹理轻松地“喷射”纹理,以传达应在何处绘制纹理),并且凭借当前显卡的强大功能,您几乎不需要地形优化,因为一切都是在视频卡中并行完成。请记住,WebGL 比 1.0 更像 OpenGL 2.0+,并且没有立即函数,一切都在 VBO 的保留模式下工作。

然而,除了地形渲染之外,您的项目还会遇到某些问题。

目前,浏览器中的鼠标锁定存在某些问题,音频处理普遍存在问题,并且在没有用户干预的情况下,全屏在大多数浏览器中是禁忌。我正在(曾经)编写一个基于 WebGL 的游戏,但在遇到主要障碍之前,您可以做很多事情,相信我,在这些问题得到解决之前,您将无法取得太大进展:

我没有不包括其他浏览器,因为如果您的目标是 WebGL Chromium/Chrome,那么您现在只有 Firefox。

I will divide my answer in two, so you have what you're asking and what you "should" ask :-).

Your best bet is to get a good grasp on GLSL. If you're doing it gor the joy of it, you should learn from tutorials like this one. Implementing a terrain engine is very straightwforward using shaders (you can "splat" textures easily based on arbitrary textures that convey what texture should be drawn where) and with the horsepower in current-gen video cards, you almost need no terrain optimization because everything is done in parallel in the video card. Remember that WebGL is much more like OpenGL 2.0+ than 1.0, and there are no immediate functions, everything works in retained mode with VBOs.

However, your project will stumble upon certain problems besides Terrain rendering.

Currently, there are certain issues with mouse locking in the browser, widespread issues with audio handling and fullscreen is a no-no in most browsers without user intervention. I'm (was) coding a game based on WebGL but there's so much you can do before hitting a major stumbling block, and believe me, you won't be able to make much progress until these issues are solved:

I haven't included other browsers because if you're targetting WebGL Chromium/Chrome and Firefox is all you have right now.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文