在 OpenGL 中渲染火焰

发布于 2024-10-07 13:38:57 字数 136 浏览 0 评论 0原文

我想基于粒子模拟在 OpenGL 中渲染火焰效果。我有数百个粒子,它们具有位置和温度(因此具有颜色)以及所有其他属性。简单地使用 glut 渲染 solidSphere 看起来不太现实,因为粒子分布得太宽。如何根据粒子信息绘制火焰?

I want to render a fire effect in OpenGL based on a particle simulation. I have hundreds of particles which have a position and a temperature (and therefore a color) as well as with all their other properties. Simply rendering a solidSphere using glut doesn't look very realistic, as the particles are spread too wide. How can I draw the fire based on the particles information?

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

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

发布评论

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

评论(2

左耳近心 2024-10-14 13:38:57

如果您只是想创建逼真的火焰效果,我会使用其他答案中推荐的某种重新存在的库。但在我看来,你似乎是在追求模拟的展示。

一个值得尝试的直接解决方案可能是用广告牌(即始终面向相机的图形图像)替换您当前的球体,广告牌在中间为纯白色,并向边缘褪色为透明 - 显然根据您的粒子对图像进行定位和着色。

我认为更好的解决方案是将火焰视为一组 2D 网格,您可以在其中控制网格上每个顶点的透明度和颜色。人们可以在 OpenGL 中通过从四边形构建一个平面并使用粒子系统来计算(通过从最近的粒子进行插值)每个顶点的颜色和透明度来实现这一点。 OpenGL 将为您在顶点之间插入每个像素,并为您提供“区域中的平均粒子”的平滑图像。

If you are just trying to create a realistic fire effect I would use some kind of re-existing library as recommended in other answers. But it seems to me you that you are after a display of the simulation.

A direct solution worth trying might be replace your current spheres with billboards (i.e. graphic image that always faces toward the camera) which are solid white in the middle and fade to transparent towards the edges - obviously positioning and colouring the images according to your particles.

A better solution I feel is to approach the flame as a set of 2D Grids on which you can control the transparency and colour of each vertex on the grid. One could do this in OpenGL by constructing a plane from quads and use you particle system to calculate (via interpolation from the nearest particles you have) the colour and transparency of each vertex. OpenGL will interpolate each pixel between vertexes for you and give you a smooth looking picture of the 'average particles in the area'.

独享拥抱 2024-10-14 13:38:57

您可能想使用粒子系统来渲染火焰效果,这里有一个关于如何做到这一点的 NeHe 教程:http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=19

You probably want to use a particle system to render a fire effect, here's a NeHe tutorial on how to do just that: http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=19

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