简体   繁体   English

OpenGL ES液体着色器

[英]Opengl Es liquid shader

I currently have a particle system in place in android opengl. 我目前在android opengl中有一个粒子系统。 The physics are all taken care of and the particles draw to the screen great. 所有的物理过程都得到了照顾,粒子很容易吸引到屏幕上。 Only problem is that they render as GL_Points. 唯一的问题是它们渲染为GL_Points。 So they are just colored squares. 因此,它们只是彩色正方形。 I was wondering if anyone knows how to combine the points into blobs that looks like liquid when the particles are close enough. 我想知道是否有人知道当粒子足够接近时如何将这些点组合成看起来像液体的斑点。 It would be nice being able to avoid textures but any shader suggestions would be much appreciated. 能够避免纹理会很好,但是任何着色器建议将不胜感激。

There are techniques like marching cubes to create a mesh out of a cloud of points. 有一些技术,如行进立方体以从点云中创建网格。 but this would never run on a smart phone in real time. 但这永远无法在智能手机上实时运行。 unless you simulate a super tiny blob of liquid. 除非您模拟了液体的超小斑点。

You could raytrace the rendering using grid marching and particules in vicinity could have a distance threshold that would get the pixel to exit the marching loop and render some color according to the distance of the nearby particles at this point. 您可以使用网格行进来射线追踪渲染,并且附近的粒子可能具有距离阈值,该距离阈值将使像素退出行进循环并根据附近粒子在此点的距离来渲染一些颜色。 which would be very very heavy for a smartphone (but perfecly doable for, say, a GTX480). 对于智能手机来说,这将是非常沉重的负担(但对于GTX480而言确实可以做到)。

you could give up high technology and use billboard rendering, each point becomes 4 points (either thanks to a geometry shader or thanks to some CPU side particle field expansion copy pass into a buffer of quads) then use spherical billboard rendering with the correct blending setup (additive would be nice) to avoid billboards from walking over each other and need sorting, which would kill your perf on a small device. 您可以放弃高科技并使用广告牌渲染,每个点变为4点(这要归功于几何体着色器或某些CPU端的粒子场扩展复制传递到四边形的缓冲区中),然后使用具有正确混合设置的球形广告牌渲染(最好使用添加剂),以避免广告牌彼此走动并需要分类,这会杀死您在小型设备上的性能。

here some resource about spherical billboards: http://www.gamerendering.com/category/particle-systems/ 这里是有关球形广告牌的一些资源: http : //www.gamerendering.com/category/particle-systems/

You could invent your own billboard rendering shader based on a field-evaluation for each pixel. 您可以根据每个像素的场评估发明自己的广告牌渲染着色器。 the billboard geometry would only be a "support" that would work like a space partitionning optimization. 广告牌的几何形状只能是“支持”,就像空间分区优化一样。 Instead of marching a grid you would know that if you are evaluating a fragment right now, it is BECAUSE you ARE in the vicinity of a particle field. 您无需知道如何行进网格,而是知道如果您现在正在评估片段,那是因为您位于粒子场附近。 Thus you could accelerate the research of narby particles and calculating the blob field out of those, and decide of the rendering of your pixel from that. 因此,您可以加快对narby粒子的研究并从中计算出blob场,并由此确定像素的渲染。 note that the result could be a discard if the influence function returns something under the threshold. 请注意,如果影响函数返回阈值以下的值,则结果可能是丢弃。 this would help create surfaces with clear interface, like water. 这将有助于创建具有清晰界面的表面,例如水。 (and not gases like smoke or vapor). (而不是烟雾或蒸气之类的气体)。 but it would require to prepare a nice lookup structure into a texture at each frame. 但需要在每个帧的纹理中准备一个不错的查找结构。 like say a cube texture with particles information in it, for fast lookup in the shaders. 例如说带有粒子信息的立方体纹理,以便在着色器中快速查找。 i doubt this can be done on smartphone excepts for super small simulations. 我怀疑这可以在智能手机上完成,但超小型模拟除外。

You are looking for a technology called meta balls . 您正在寻找一种称为元球的技术。 Here is a reference: http://nullcandy.com/2d-metaballs-in-xna/ 这是参考: http : //nullcandy.com/2d-metaballs-in-xna/

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

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