Hi Everyone,
I am trying to solve shallow water equations (partial differential form) using GLSL. I have my psuedocode setup, but I am trying to think how I can implement it in GLSL.
Here is a brief description
- read in elevation data into a 2d texture (this texture doesn’t change throughout)
- a grid mesh is created using another 2d texture (same dimensions) that is updated each time step
- each texel is a grid cell of the mesh
- shallow water equations are solved using upwinding finite difference scheme
- At each time step, the texture is updated according to the numerical scheme
- boundary conditions are implemented along the edges of the mesh/texture
- the time step for the next iteration is calculated based on the lowest output value in the current time step
I am able to create a texture, define its texture coordinates in vertex processor. I think I can also code the numerical solution in the fragment processor.
I am stuck at: 1) how to implement the boundary conditions of the mesh, and, 2) how to find the lowest output value, which I will use to calculate the next time step value.
I hope I made my problem clear. Can somebody please help with this. I appreciate any suggestions.
Thanks,
Alfred
p.s.:
I searched around and I came up with a vague idea. for 1), can we do “stencil” buffer for boundary conditions?, and 2), can we do depth test or Z-culling for finding the minimum value in a single texture?
I don’t know to do these. If this is what you think I should do, I will be really grateful if you can point me to some resources or examples of solving partial differential equations.