简体   繁体   English

如何在OpenGL中渲染.vox体素模型?

[英]How to render a .vox voxel model in OpenGL?

I need help with rendering a .vox model in OpenGL. 我需要在OpenGL中渲染.vox模型的帮助。

The .VOX file format is described here . .VOX文件格式在此处描述

Here is an example VOX file reader. 这是一个示例VOX文件阅读器。

And here is where I come across the problem - how would I go about rendering a .vox model in OpenGL? 这就是我遇到的问题-我将如何在OpenGL中渲染.vox模型? I know how to render standard .obj models with textures using the Phong reflection model, but how do I handle voxel data? 我知道如何使用Phong反射模型渲染带有纹理的标准.obj模型,但是如何处理体素数据? What kind of data should I pass to the shaders? 我应该传递给着色器什么样的数据? Should I parse the data somehow, to get the index of each individual voxel to parse? 我是否应该以某种方式解析数据,以获取要解析的每个个体素的索引? How should I create vertices based on voxel data (should I even do that)? 如何基于体素数据创建顶点(我什至应该这样做)? Should I pass all the chunks or is there a simple way to filter out those that won't be visible? 我应该传递所有块,还是有一种简单的方法来过滤掉那些不可见的块?

I tried searching for information on this topic, but came up empty. 我尝试搜索有关此主题的信息,但结果空白。 What I am trying to accomplish is something like MagicaVoxel Viewer, but much simpler, without all those customizable options and with only a single light source. 我要完成的工作类似于MagicaVoxel Viewer,但要简单得多,没有所有这些可自定义的选项,并且只有一个光源。

I'm not trying to look for a ready solution, but if anyone could even point me in the right direction, I would be very grateful. 我并不是想寻找一个现成的解决方案,但是如果有人能指出正确的方向,我将不胜感激。

After some more searching I decided to render the cubes in two ways: 经过更多搜索之后,我决定以两种方式渲染多维数据集:

1) Based on voxel data, I will generate vertices and feed them to the pipeline. 1)基于体素数据,我将生成顶点并将其馈送到管线中。 2) Using the geometric shader, I'll emit vertices based on indexes of voxels to render I feed to the pipeline. 2)使用几何着色器,我将基于体素的索引发出顶点,以渲染输入到管线。 I'll store the entire model as a 3D texture. 我将整个模型存储为3D纹理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM