DirectX 与 OpenGL 游戏开发

发布于 2024-12-01 11:37:33 字数 340 浏览 0 评论 0原文

我有一些关于制作专业游戏(例如《魔兽世界》、《星际争霸2》、《暗黑破坏神3》等)时使用哪些图形平台的问题。

首先,如果用 OpenGL 而不是 Direct X 渲染,WoW 看起来会有所不同吗?如果用 OpenGL 渲染,性能会显着不同吗?

其次,创建游戏时的主要流程是什么,特别是在视频游戏中使用在 Maya 或 3DS Max 中创建的模型方面?是否创建模型,然后将模型导出为可读的 OpenGL/DirectX 代码,导出所有着色器程序,并在代码中创建所有顶点和三角形,最后在 C++/c 程序中使用代码?

总的来说,我很好奇视频游戏设计师/程序员如何将实际的 3DS MAX/Maya 模型导出到他们的代码中

I have a few questions regarding what graphics platforms are utilized when making professional games (like WoW, starcraft2, diablo 3.. etc).

First, would WoW look different if rendered in OpenGL, rather than Direct X? Would performance be significantly different if rendered in OpenGL?

Second, What is the main process when creating a game, specifically in terms of using a model created in Maya, or 3DS Max in the video game? Does one create the model, then export the model to readable OpenGL/DirectX code, with all of the shader programs exported, and all vertices and triangles created in code, and finally utilize the code in a C++/c program?

OVerall, I'm curious on how video game designer/programmers export actual 3DS MAX/Maya models into their code

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

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

发布评论

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

评论(5

丑疤怪 2024-12-08 11:37:33

首先,如果用 OpenGL 而不是 Direct X 渲染,WoW 看起来会有所不同吗?

在OpenGL中渲染(当然,它可以通过设置)。不,它在 D3D 渲染中看起来并没有什么不同。 (注意:DirectX 不仅仅是 Direct3D。)

如果在 OpenGL 中渲染,性能会显着不同吗?

不太可能。有些事情 OpenGL 实现可以更快,但 WoW 没有使用其中任何一个。

是否创建模型,然后将模型导出为可读的 OpenGL/DirectX 代码

OpenGL 和 Direct3D 都没有模型格式。此时,甚至 .x 文件也已被弃用;这些是 D3DX 库的一部分,而 D3DX 库只是 Microsoft 在 D3D 之上编写的层。

其次,您不将它们导出到“代码”中。您可以将它们导出到文件中,然后在游戏中读取这些文件。嗯,一般来说,您会将这些文件处理为游戏更容易理解的格式,因为导出商倾向于以与您在游戏中想要的不同的方式优化网格。

所以它导出到文件 ->处理最终文件 ->在游戏中阅读。

First, would WoW look different if rendered in OpenGL, rather than Direct X?

It is rendered in OpenGL (well, it can be with a setting). And no, it doesn't look different in D3D rendering. (note: DirectX is more than just Direct3D.)

Would performance be significantly different if rendered in OpenGL?

Unlikely. There are some things that OpenGL implementations can be faster at, but WoW doesn't use any of them.

Does one create the model, then export the model to readable OpenGL/DirectX code

Neither OpenGL nor Direct3D has a model format. Even .x files are deprecated at this point; those were part of the D3DX library, which was just a Microsoft-written layer on top of D3D.

Second, you don't export them into "code". You export them into files, which you then read in your game. Well, generally, you process those files into more digestible formats for you game, as exporters tend to optimize meshes differently from what you might want in your game.

So it's export to file -> process to final file -> read in game.

故人爱我别走 2024-12-08 11:37:33

首先,如果用 OpenGL 而不是 Direct X 渲染,WoW 看起来会有所不同吗?如果在 OpenGL 中渲染,性能会显着不同吗?

OpenGL 和 Direct3D 遵循类似的原理:顶点流进入,进行变换(固定函数或通过顶点着色器),变换后,顶点被分组为图元(点、线、三角形),并且图元被光栅化,即对于每个像素基元涵盖了执行一些计算(同样是固定函数或由可自由编程的片段着色器)来确定所谓的“片段”颜色。最后,它测试了片段的可见性并混合到正在绘制的图片中。

OpenGL 和 DirectX 的更高版本添加了几何和曲面细分阶段,但这些只是细节。

在所有其他方面,它们的工作方式非常相似,渲染结果之间几乎没有区别,除了不同剪辑空间映射在顶点位置上引入的舍入误差之外。

第二,创建游戏时的主要流程是什么,特别是在视频游戏中使用在 Maya 或 3DS Max 中创建的模型方面?是否创建模型,然后将模型导出为可读的 OpenGL/DirectX 代码,导出所有着色器程序,并在代码中创建所有顶点和三角形,最后在 C++/c 程序中使用代码?

不!模型及其辅助数据与代码分开存储。虽然肯定可以在代码中存储几何图形,但这是一个相当糟糕的主意,不应该这样做。我解释了基本思想,即如何在 如何将 Maya 等 3D 软件中的模型导入 OpenGL?

总的来说,我很好奇视频游戏设计师/程序员如何将实际的 3DS MAX/Maya 模型导出到他们的代码中

他们没有。他们将模型导出为经过优化的文件格式,以便 3D 引擎高效加载,然后引擎从文件中加载模型和辅助数据。这不是某种黑巫术。整个过程与从文件加载图像并显示它或向扬声器播放一些音乐没有太大区别。为了制作 3D 模型的动画,模型包含额外的控制信息(骨架、骨骼等),允许根据相当少量的参数(手臂旋转、观察方向等)对其进行变形,然后这些参数会发生变化。

First, would WoW look different if rendered in OpenGL, rather than Direct X? Would performance be significantly different if rendered in OpenGL?

OpenGL and Direct3D follow similar principles: A stream of vertices goes in, gets transformed (either fixed function or by a vertex shader), after transformation the vertices are grouped into primitives (points, lines, triangles) and the primitives rasterized, i.e. for each pixel the primitive covers some calculation (again either fixed function or by a freely programmable fragment shader) is performed that determines the so called "fragment" color. Finally the fragment it tested for visibility and blended into the picture-in-drawing-progress.

Later versions of OpenGL and DirectX added geometry and tesselation stages, but those are just details.

In all other aspects the ways they work are so similar, that there's virtually no difference between rendering results, except the rounding errors introduced on the vertex positions by the different clip space mappings.

Second, What is the main process when creating a game, specifically in terms of using a model created in Maya, or 3DS Max in the video game? Does one create the model, then export the model to readable OpenGL/DirectX code, with all of the shader programs exported, and all vertices and triangles created in code, and finally utilize the code in a C++/c program?

No! The model and its auxiliary data are stored separately from the code. While it most certainly is possible to store geometry in code, this is a rather bad idea and should not be done. I explained the basic idea, how a model is loaded in How to Import models from 3D software, like Maya into OpenGL?

OVerall, I'm curious on how video game designer/programmers export actual 3DS MAX/Maya models into their code

They don't. They export their models into a file format optimized for efficient loading by a 3D engine, and then the engine loads the models and auxiliary data from files. This is not some kind of black voodoo magic. The whole process is not very different from loading an image from a file and displaying it or some music playing it to the speakers. To animate a 3D model, the model contains additional control information (armatures, bones, etc.) which allow to deform it based on a rather small number of parameters (arm rotation, looking direction, etc.) Then those parameters are varied.

長街聽風 2024-12-08 11:37:33

您问的是一个很大的问题,但至少是它的“第二”部分 - 正如您所描述的那样,在软件包中创建了不平凡的模型,但它们通常会导出到基本上表示几何形状列表的数据文件中。然后,这些文件由游戏的资源加载器读入,并放入顶点数组或缓冲区对象等中。这样数据就独立于代码。

硬编码几何体通常用于小型、固定的事物和教程项目。 :)

You're asking a large question, but to at least the "second" part of it-- nontrivial models are created in software packages as you describe, but they're then usually exported into data files that basically represent lists of geometry. Those files are then read in by the game's resource loader, and put into vertex arrays or buffer objects or etc. This way the data is independent from the code.

Hardcoded geometry is usually used for small, fixed things, and for tutorial projects. :)

关于从前 2024-12-08 11:37:33

你的第一个问题确实无法回答——两个图形库都让我可以通过 API 访问底层图形硬件。游戏的外观很大程度上取决于 API 的使用方式。如果我在 OpenGL 中将后备缓冲区设置为红色,它看起来就像我在 DirectX 中将后备缓冲区设置为红色一样。如果我在 OpenGL 中进行与在 DirectX 中相同的光照计算,我将看到相同的结果,依此类推。所产生的任何差异都可能是由于 API 不相同而导致的,因此程序员可以解决这个问题。

来自 3D 建模程序(例如 Maya 或 3DsMax)的模型不会被“编码”,它们会导出为游戏可以理解的格式。这些格式可以是基于 XML 的格式(例如 Collada)、基于文本的格式(例如 OBJ),甚至是专有的二进制格式。重要的是,来自建模程序的数据以游戏可以读取并转换为几何图形内部表示的格式提供给游戏。几乎每个游戏引擎处理几何体的方式都略有不同。

从技术上讲,我可以只保存以下文件:

V1  0.0, 0.5, 0.5
V2 -0.5,-0.5, 0.5
V3  0.5, 0.5, 0.5

M1 V1, V2, V3

只要游戏知道该文件包含三个顶点(V1V2V3)和一个由这三个顶点组成的网格 (M1),并且知道如何将其读取为我们可以渲染的格式,我们就可以将这个三角形作为一个三角形绘制到场景中网。顺便说一句,这种格式与 OBJ 格式相差不远。

大多数导出器都比这复杂得多,并且大多数引擎都支持更复杂的几何表示,以解释这些(强大的)建模工具可以为我们提供的所有额外数据。

Your first question is really not answerable - both graphics libraries give me access to the underlying graphics hardware through an API. How the game looks depends largely on how that API is used. If I set the backbuffer to red in OpenGL, it will look the same as if I set the backbuffer to red in DirectX. If I do the same lighting calculations in OpenGL that I do in DirectX, I will see the same results, and so on. Any differences that result are likely a result of the APIs not being identical so the programmers work around it.

Models from a 3D modeling program (such as Maya or 3DsMax) are not 'coded', they are exported into a format that the game can understand. These can be XML based formats such as Collada, text based formats such as OBJ, or even proprietary binary formats. What is important is that the data from the modelling program is made available to the game in a format which it can read in and convert into an internal representation of the geometry. Pretty much every game engine handles geometry in a slightly different fashion.

Technically, I could just save the following file:

V1  0.0, 0.5, 0.5
V2 -0.5,-0.5, 0.5
V3  0.5, 0.5, 0.5

M1 V1, V2, V3

As long as the game understood that this file contained three vertices (V1, V2, V3) and one mesh (M1) consisting of those three vertices, and knew how to read it in to a format that we could then render, we would be in business and could draw this triangle to the scene as a mesh. Incidentally, this format is not far from the OBJ format.

Most exporters are much more complicated than this, and most engines support a more complicated geometric representation to account for all the extra data that these (powerful) modeling tools can provide for us.

空城之時有危險 2024-12-08 11:37:33

这是一个很大的问题,很难简单地回答。

关于directX和Opengl,它们在功能和性能方面并没有太大区别(也许)。

DirectX 始终领先 Opengl 一步。例如,它首先支持硬件曲面细分功能,然后过了一段时间,这个功能出现在Opengl中。但这并不是什么大问题,因为当你开发游戏时,你将必须支持一系列机器,包括那些低性能的机器。因此,在新功能变得非常普遍之前,您可能无法使用它。

是的,游戏开发人员使用 Maya 和 3Ds max 等软件来创建游戏模型,通常他们将模型输出到模型文件。该文件由游戏的游戏引擎读入。

我不建议你从opengl或directx开始,我认为最好使用游戏(或图形)引擎。例如食人魔3D。 http://www.ogre3d.org/

因为它同时支持directx和opengl,而且它也有现成的3Ds max,Maya 导出器,可以轻松加载模型。

This is a very big question that is hard to answer briefly.

About directX and Opengl, they are not very different in terms of functionality and performance (maybe).

DirectX is always one step ahead of Opengl. For example, it first supported the hardware tessellation feature, and then after a while, this feature appeared in Opengl. But this is not a big deal, because when you develop a game, you will have to support a range of machines, including those low performance machines. So you may not be able to use the new features until it becomes very common.

Yes, game developers use Maya, and 3Ds max kind of software to create the models of a game, and normally they output the model to a model file. this file is read in by the game engine of the game.

I don't suggest you to start with opengl or directx, I think it is better to use a game (or graphics) engine instead. For example, ogre 3D. http://www.ogre3d.org/

because it supports both directx and opengl, and it also has ready made 3Ds max, Maya exporter, which makes loading models easily.

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