1

I'm new to direct3d , graphics, HLSL , c++ , and I'm trying to write a program to render different geometric multidimensional shapes (for example a hypercube), the program is supposed to receive vertices from the user after the user has defined the number of dimensions , draw , rotate and translate the shape .

  • The first problem is how to define a dynamic vertex structure (is it okay to use pointers).

  • Second: Where to project the shape from x-dimensional to 3-dimensional space ,should I do that in the code (CPU), or is it possible to pass the object vertices and projection matrices to the shader(HLSL) and if so how (especially that the matrices are of varying size defined at runtime).

  • Same problem as the above for the view matrix (let's say that the object is 4-d I want the program to zoom in/out-> approach , or move in x-direction in 4-d space "I want to deal with the object's space rather than it's projection's space")

  • Third: If all of the above wasn't possible in the shader can I use c++amp(or it's alternatives) to accelerate the execution of such operations in the main program or will this cause performance degradation for the "Draw()" function.

I have searched the web and "Stackoverflow" but I couldn't find anything of use.

4

1 回答 1

1

免责声明:我不是 GPU 和着色器方面的专家;我使用的是 OpenGL/WebGL/GLSL 而不是 Direct3D/HLSL。所以我只回答这个问题,因为没有其他人有。:-)

关于指针:我很确定您不能在 GPU 中使用指针,因为您发送到 GPU 的数据将在 GPU 内存中具有不可预测的地址(位置)。

但是对于动态数据结构(可变维数),您似乎可以通过改变传递给的“大小”参数vertexAttribPointer()或等效参数来做到这一点。你传入一个包含所有顶点坐标的平面数组,每个顶点有 n 个坐标;并使用 size 参数告诉着色器 n 是什么。

然后在顶点着色器中,您可以使用您在着色器中根据传入的参数构造的投影矩阵将数据从 n 维投影到 3 维。

我认为类似地,在片段(像素)着色器中,您可以使用从传入参数在着色器中构造的视图矩阵将数据从 3 维投影到 2 维。

希望这能让你开始,这样你就可以提出更具体的问题。老实说,我还没有发现 SO 是一个像 Python 等其他主题那样高效地回答有关图形问题的地方。在特定于 Direct3D 的网站上询问可能会更好。

于 2013-05-03T20:51:59.963 回答