PDA

View Full Version : Boundary Conditions for Cellular Automata



sek
10-28-2003, 09:30 AM
Hello:

I am doing 2D physical simulations of cellular automata with multi-pass rendering. My GL_NV_fragment_program performs update equations using textures as input data. The update equations are something like:

Q_new[i][j] = Q_old[i][j] + K*(T[i-1][j] - T[i][j+1])

where i-1, j+1 correspond to neighbors and Q_old and T are color components of textures.

However, At the borders I want to do something like:

Q_new[i][j] = (1/3) * ( Q_old[i-1][j+1] + Q_old[i-1][j] + Q_old[i-1][j-1] )

That is, to take the average of three neighbors. Is it possible for me to do this without performing calculations on the interior nodes/textels?

Thanks.

simongreen
10-28-2003, 10:09 AM
The easiest way to do this is to render separate geometry for the borders. Render the inner quad with one fragment program, and then render the 4 border edges as lines, using a different fragment program.

-S.

zeckensack
10-28-2003, 10:19 AM
Thin quads are IMO better than lines as it's easier to get 'watertight' rendering.

sek
10-28-2003, 10:32 AM
Thanks guys:


Originally posted by zeckensack:
Thin quads are IMO better than lines as it's easier to get 'watertight' rendering.

Do you mean that I should use a quad that is one texel wide and however many texels long? Also, I need to handle corners differently that edges. Should I use a quad that is one texel wide and one texel long?

zeckensack
10-28-2003, 11:14 AM
Yes. This might sound terribly inefficient (binding a different shader for a single pixel quad ...) but I think in your case the chip will be spending most of its time on rendering the interior anyway.