Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I implemented 2d fluid simulator. Solver runs entirely on GPU. All works fine... on my work PC. But on home PC I have some awful glitches, and I can`t understand how to fix them. Empirically I discovered that problem is localized somewhere in advect program. This is very strange cause at work I have integrated video, and at home — NVIDIA GeForce 9800 GT. Here is the GLSL source of advect program (some lines were dropped for clearness):

#version 130

out vec3 value;

uniform sampler2D q;
uniform sampler2D velocity;
uniform float dt;
uniform float inverseSize;

void main()
  vec2 p = gl_FragCoord.xy * inverseSize; 

  vec2 np = p - dt * texture(velocity, p).xy;

  value = texture(q, np).xyz;

And some screenshots.

Work PC:

view of swirling colors like two or more fluids mixing

Home PC:

distorted view of similar colors, clearly in error

share|improve this question
It looks like the visualization of a vector field and it seems ok, conceptually. Are any buffers swapped somewhere, or is this just a single simulation step? Interesting question from an interesting field, hopefully someone will answer this. To debug it, I would check if my uniforms are passed correctly: use constants/floats instead of uniforms and see the difference. – teodron Apr 21 '12 at 9:13
This is just a single simulation step. I have a C++ function Advect(). It takes target texture, quantity texture (q) and a velocity texture. I followed your advice and tried to use consts instead of uniforms, but result is the same. – iodiot Apr 21 '12 at 9:52
Difficult problem u got there, P = NP (joke) – XiaoChuan Yu Apr 24 '12 at 6:03
@iodiot You might have invoked something bad. Integrated drivers can be more permissive than NVidia. – Bartek Banachewicz Feb 15 '13 at 15:08
Could you answer the question with a before and after? I think it would be highly useful to anyone who meets this challenge in the future. – zehelvion Jan 29 '14 at 17:14

Per the OP's response, substituting

vec2 np = p - dt * texture(velocity, p).xy;


vec2 np = p - dt * vec2(0.01);

solved the problem. The field and density moves smoothly in the (0.01, 0.01) direction.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.