7

I made a visualization a little like yours years ago, and used a similar technique, because it's the natural approach to the problem. After I spent a few years writing drivers for modern GPUs, I wouldn't use this approach at all, because it creates a dependency from one frame to the next, which introduces pipeline stalls and/or false sharing. Today, I'd ...


6

The basic equation for alpha blending is as follows: $$ c_\text{final} = c_\text{source} \cdot \alpha + c_\text{dest} \cdot (1 - \alpha) $$ Here, $c_\text{source}$ is the color of the thing being blended, $c_\text{dest}$ is the background onto which you're blending it, and $\alpha$ is between 0 and 1. In your case, $c_\text{source} = 0$ (black fading ...


4

For rendering of gases, I think the usual approach is to simply render each particle as a tiny disc. Gases don't really coalesce into surfaces like liquids do, so this should produce acceptable results. You could perhaps apply a light blur over the gas layer afterwards to soften it and hide the fact that it is made of discrete elements. Liquids, on the ...


4

A very simple low memory approach If you really want to use as little memory as possible, it can be done with not much more memory than that required to store a single image (the first frame) provided it is acceptable to do some preprocessing in advance. If you copy the following jumbled image, this jsfiddle will take it as input: It will then move the ...


4

First option should be to make all particles able to go through the same pipeline. Perhaps with an uber shader. That way you can batch them all. Positive ieee floating point numbers can be sorted like unsigned integer. And there are O(n) algorithms to sort those for example radix sort.


3

For culling faraway particles: as lightxbulb said, the keyword to search for is "acceleration structure". There are a variety of options: BVH, octree, kd-tree, uniform grid, or some combination of these. Which one will be most suitable is going to depend on the details of your situation—how large/dense is the simulation, how much you care about ...


3

Change the projection to always be the same no matter which face is being rendered. The simplest way is you use the direction from billboard to the camera instead of the direction the camera is facing to rotate the billboard.


2

You could do this entirely within an OpenGL/WebGL fragment shader: Attach the image you wish to emerge as a texture/sampler2D. Attach uniforms for the current time, as well as the time you want the effect to finish. uniform sampler2D myTexture; uniform float currentTime; uniform float finishTime; #define TWO_PI 6.283185307179586476925286766559 Next, ...


1

I typically like to define a "GPUData" struct containing the fields that are going to the shader, and keep the GPUDatas for all the particles in an array. Then, when it's time to update the GPU buffer, you can just memcpy out of that array to your mapped buffer (or you can pass the array to glBufferSubData, etc). For the CPU state, rather than ...


1

Updating the position/rotation/scale in the vertex buffer will use less memory bandwidth—that’s 9 values, where a transform matrix would be either 12 or 16—and the GPU can parallelize the work of turning the position/rotation/scale into a transform for the vertices. I’d go with 1.


1

Solution: Check for the minimum x,y,z value for all points. Add these values multiplied by (-1) to all points in order to guarantee that all points are not negative. Then take the largest point and subtract with the minimum point (max and minimum x y z) in order to get a cube-like bound for the object. Then divide this cube by an arbitrary size constant ...


1

The damping force you mentioned $f=-k \frac{\dot{l} \cdot l}{|l|} \frac{l}{|l|}$ is a special case of $f=-k \dot{C} \frac{\partial C}{\partial \mathbf{x}}$. Let $$ \begin{align} C(\mathbf{x}) &= \lVert\mathbf{l}\rVert-l_0 \\ \mathbf{l} &= \mathbf{x}_1 - \mathbf{x}_2 \\ \mathbf{\dot{l}} &= \mathbf{v}_1 - \mathbf{v}_2 \\ \mathbf{v} &= \dot{\...


1

Sort the particles by Z each rendering cycle using an algorithm such as bubble sort which is good when element changes position in small steps. If the perspective does not change much the errors would be few enough over time to be unnoticable. The technique is easy to configure between quality and performance dependning on the target platform by adjusting ...


1

PBRT handles only the rendering part, not the simulation part. There are several books out on game physics that handle fluid simulation, the one on my bookshelf is David Eberly's "Game Physics".


Only top voted, non community-wiki answers of a minimum length are eligible