14.1 C
New York
Sunday, April 13, 2025

opengl – How can I effectively render a number of transferring objects in a sport?


I perceive that for environment friendly rendering in video games, you wish to decrease communication between the CPU and GPU. … is not this the CPU speaking to the GPU? Is not this very sluggish and what we’re presupposed to keep away from?

It doesn’t matter what, you all the time must ship one thing to the GPU each body. Absolutely the minimal attainable knowledge to ship can be a single command “draw the subsequent body based mostly on the information you have already got”, however that’s not how video games work, since video games are interactive. Even “GPU-driven rendering” nonetheless wants the most recent body’s scene knowledge to be transferred to the GPU.

However definitely, for effectivity, it is best to keep away from sending pointless knowledge to the GPU. Up to date transforms are obligatory knowledge (until you have got, say, a GPU particle simulation).

You may be pondering of the recommendation to keep away from studying knowledge from the GPU (e.g. with glReadPixels). This is “sluggish” as a result of it has to attend for the GPU to complete writing the information you wish to learn, whereas so long as you do not learn something, the CPU and GPU can work in parallel, getting ready the subsequent body whereas rendering the present one. (And you may nonetheless learn effectively by cautious scheduling and selecting to learn knowledge from a earlier body’s computation.)

However consideration of the quantity of knowledge you write to the GPU needs to be approached similar to some other program optimization downside: take into consideration what number of operations you are operating, take into consideration how a lot knowledge you must switch over the reminiscence bus and the way it may be represented extra compactly, and many others. And all the time benchmark/profile a attainable change or various design moderately than assuming that it should be higher.

I perceive we will use uniform buffer objects as a substitute of updating uniforms individually

Try to be utilizing an occasion buffer to ship mannequin transforms to the GPU. That means you don’t must challenge a separate draw name for each object.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles