Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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
2  
Difficult problem u got there, P = NP (joke) –  XiaoChuan Yu Apr 24 '12 at 6:03
2  
@iodiot You might have invoked something bad. Integrated drivers can be more permissive than NVidia. –  Bartek Banachewicz Feb 15 '13 at 15:08
2  
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. –  Arthur Wulf White Jan 29 at 17:14
show 4 more comments

1 Answer

Per the OP's response, substituting

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

for

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
add comment

Your Answer

 
discard

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.