2

I'm drawing a contour map representing gravity.

The algorithm is:

For each point on the screen (1 pixel per point) I calculate the gravitational pull for each object and combine (using Newtons law of universal gravitation) where M1 is a unit point mass.

Next I get the min and max values and create a palette of 10 colors scaled over this range.

I then generate a texture from this data.

For resolutions such as 1024 * 768 or greater this is expensive (takes > 1sec)

I'd like to be able to move the masses and see the contour map change in real time.

Any suggestions on how to optimise?

  • 3
    You may need to add relevant code but this should be pretty easy to paralellisize and use the GPU for calculation. How many objects are we talking about. – joojaa Jan 22 '16 at 16:39
  • 1
    Welcome to Computer Graphics Stack Exchange. As joojaa already said, it's quite hard to help you to improve your code without seeing it. Please edit your question and add relevant parts of your code. Additionally, a screenshot of the result then also helps understanding what your code does. – Nero Jan 22 '16 at 19:26
  • Off the cuff, I'd say render the objects in a floating-point texture using additive blending to accumulate their gravitational potential. Then use a second pass to convert the texture into a color map. – Nathan Reed Jan 22 '16 at 19:39
  • @NathanReed Right my thoughts exactly... – joojaa Jan 23 '16 at 07:57
  • I'd still have to calculate for each point gravity for each object. This seems to be the expensive part – iasksillyquestions Jan 31 '16 at 20:33

0 Answers0