Skip to main content
added 5 characters in body
Source Link
Engineer
  • 30.4k
  • 4
  • 76
  • 124

It's a bad idea if you are talking about 3D / GPU rendering.

It's fine if you're rendering 2D / non-GPU, as it may make more sense to you organisationally.

The reason is that GPU rendering, for optimal (or even reasonable) performance, requires individual render passes that render groups of game objects with similar properties (ii.e. materials, since each material uses different shaders and sometimes, different textures... switching between different textures and shaders can cost considerable time on the GPU, hence this is best avoided).

Allowing each object to render itself (rather than being observed and rendered by a single monolithic renderer) breaks this grouping which allowswould allow the GPU to perform optimally. Some game objects can consist of multiple different materials, which would also break this grouping.

Even so, for small numbers of objects and low-cost shaders, this doesn't really matter much running on modern GPUs. But as soon as you have complex materials and many game objects, it is a far better idea to render from a single class / function, by inspecting game object properties.

It's a bad idea if you are talking about 3D / GPU rendering.

It's fine if you're rendering 2D, as it may make more sense to you organisationally.

The reason is that GPU rendering, for optimal (or even reasonable) performance, requires individual render passes that render groups of game objects with similar properties (i.e. materials, since each material uses different shaders and sometimes, different textures... switching between different textures and shaders can cost considerable time on the GPU, hence best avoided).

Allowing each object to render itself (rather than being observed and rendered by a single monolithic renderer) breaks this grouping which allows the GPU to perform optimally. Some game objects can consist of multiple different materials, which would also break this grouping.

Even so, for small numbers of objects and low-cost shaders, this doesn't really matter much running on modern GPUs. But as soon as you have complex materials and many game objects, it is a far better idea to render from a single class / function, by inspecting game object properties.

It's a bad idea if you are talking about 3D / GPU rendering.

It's fine if you're rendering 2D / non-GPU, as it may make more sense to you organisationally.

The reason is that GPU rendering, for optimal (or even reasonable) performance, requires individual render passes that render groups of game objects with similar properties i.e. materials, since each material uses different shaders and sometimes, different textures... switching between different textures and shaders can cost considerable time on the GPU, hence this is best avoided.

Allowing each object to render itself (rather than being observed and rendered by a single monolithic renderer) breaks this grouping which would allow the GPU to perform optimally. Some game objects can consist of multiple different materials, which would also break this grouping.

Even so, for small numbers of objects and low-cost shaders, this doesn't really matter much running on modern GPUs. But as soon as you have complex materials and many game objects, it is a far better idea to render from a single class / function, by inspecting game object properties.

Source Link
Engineer
  • 30.4k
  • 4
  • 76
  • 124

It's a bad idea if you are talking about 3D / GPU rendering.

It's fine if you're rendering 2D, as it may make more sense to you organisationally.

The reason is that GPU rendering, for optimal (or even reasonable) performance, requires individual render passes that render groups of game objects with similar properties (i.e. materials, since each material uses different shaders and sometimes, different textures... switching between different textures and shaders can cost considerable time on the GPU, hence best avoided).

Allowing each object to render itself (rather than being observed and rendered by a single monolithic renderer) breaks this grouping which allows the GPU to perform optimally. Some game objects can consist of multiple different materials, which would also break this grouping.

Even so, for small numbers of objects and low-cost shaders, this doesn't really matter much running on modern GPUs. But as soon as you have complex materials and many game objects, it is a far better idea to render from a single class / function, by inspecting game object properties.