All Questions

Community

A
ThePirateKing

Data-texture size standards

The lesson mentions the following:

The GPU expects a texture with a particular size for the amount of data we use. This size is 2048 pixels in width, and a height equal to the number of positions we have as a proportion of 2048. We round up to avoid having 0 pixels.

var new_width := 2048
var new_height := (positions.size() / 2048) + 1


I was wondering where this information could be found so that I know where to look for it in the future. I didn't see it in the in-editor Godot docs for Particles2D, ParticlesMaterial, emission_shape, or emission_point_texture.

Is 2048x2048 a GPU standard, and are there times where other textures sizes are appropriate?

  • Nathan Lovato replied

    This one is a particular case: there are no built-in tools exposed to create these texture masks, and I think Razoric had to look into the engine's source code to figure out how to use the feature.

    Now, GPUs work best with textures that use powers of two for their dimensions: that's why you'll almost always see textures with sizes like 256, 512, 1024, 2048 pixels.

    It's due to how computers and processors work with binary numbers. A suite of binary numbers can always hold a corresponding power of two: 4 bits offer 2^4 possibilities, etc.

    One thing I've seen back when I made 3D art is that engines or GPUs back then would treat textures that used arbitrary sizes as if their dimensions matched the next power of two.

    For example, using a texture of size 200 * 500 on a 3D mesh would cause the allocation of 256*512 pixels in graphics memory.

    But I don't know if it's still the case today.