Procedural animated texture generation

Prior to Java Edition 1.5 snapshot 13w02a, the textures for animated blocks were generated on-the-fly using certain algorithms, rather than being defined image files.

Nether portals
Due to the large number of Atan2 and Sine operations, all of the animation frames for the portal block are generated once at-startup, with each frame's data being stored in an array of all the frames.

To generate a frame of the Nether portal animation: Assume width = 16, height = 16, and frame_count = 32. Additionally, assume {hw, hh} = {width / 2, height / 2}, rounding down.

for every frame, with frame_index being the iterator: for every pixel, with {x, y} being the iterators: let float n = 0 // we repeat this twice to create two spirals. one rotating clockwise and another offset // to the top right of our position that rotates anti-clockwise. This is so the texture can // tile reasonably well (at this low resolution). repeat twice, with i being the iteration: let floats {spiral_x, spiral_y} = ({x, y} - (i * {hw, hh})) / {w, h} * 2. if {spiral_x, spiral_y} is less than -1, add 2. If greater or equal to 1, subtract 2 let float mag = power(spiral_x, 2) + power(spiral_y, 2) let float out_spiral = atan2(spiral_y, spiral_x) out_spiral += ((frame_index / frame_count * PI * 2) - (mag * 10) + (i * 2)) * (i * 2 - 1) // this will bring the results of the sine operation into the range of 0 to 1 rather than -1 to 1 out_spiral = sin(out_spiral) * 0.5 + 0.5 // this makes the intensity of our spiral fall off with distance from the centre of the spiral out_spiral /= mag + 1 n += spiral / 2 n += random(0.0, 1.0) * 0.1 let byte r = floor(n * n * 200 + 55) let byte g = floor(power(n, 4) * 255) let byte b = floor(n * 100 + 155) let byte a = b           frames[frame_index].frame_data.rgba at {x, y} = {r, g, b, a}

Fluids
Fluid textures are generated via 3-layer non-deterministic cellular automata, which modify the RGB and alpha values of the texture accordingly, along with shifting of the texture to emulate flowing. Each layer is represented as an array of floats, each with 256 elements, corresponding to the 256 (16x16) texture pixels within the block.

As can be seen when loading up a world with water or lava in view, the textures start as a solid color before the cellular automaton starts generating the texture.

Indexes which end up outside of the bounds of the texture reappear at the opposite respective side.

For the purposes of explanation, the variables used have been named (arbitrarily) as attributes of a boiling pot of soup over a fire. The first layer represents the flame_heat value (which can be either negative or positive), the second layer represents the pot_heat value and the third layer represents the soup_heat value.

Note that and  used different pseudorandom generators for generating all random numbers in the game (Java Edition using a LCG whereas Pocket Edition used a MT19937), which includes the random numbers used for water and lava. Due to being random, however, this likely has negligible visual impact.

Placeholder textures
Animated blocks and fluids had backup "placeholder textures" in terrain.png, overwritten in VRAM with the generated animations, which would be used if the animated texture could not be loaded.

In some versions, they could be triggered to appear if the game is paused upon first loading the world, which can be done by having another window which is not the game be in focus while the game loads the world.

It is worth noting here that flowing liquids use a texture twice the size of most block textures (32x32 as opposed to the usual 16x16). This is not unique to placeholder textures, and can also be noted when viewing the raw textures for liquids in 13w02a and above, as well as applying internally for generated liquid textures. A larger texture is used here since the texture is rotated accordingly to match the flow direction, while otherwise remaining at the same resolution. As a result, 16x16 textures would be too small to show a continuous texture if rotated at all, as with the most extreme case, a 45 degree rotation, there would be clear gaps at the corners, as one corner to the other would cross 16√2 pixels rather than 16.

When the generated animation was added for water in 0.0.19a, the old water texture used before that point was kept in for use as a placeholder texture.

A second copy of the water texture was added in the 20091223-1 Indev build, which was without a doubt linked to the addition of the flowing water texture.

In the 20100616 build of Infdev, the water placeholder textures were moved to the bottom-right of terrain.png. The still water texture remained as a single texture square, and the flowing water texture became a 2x2 square of water textures, as explained earlier.

With the addition of animated texture images in 13w02a, these textures were decommissioned and removed soon after.

Due to the first terrain.png in Pocket Edition being based off of the terrain.png from Beta 1.3, both the still and flowing water texture placeholders from said version are there by default. It was used as the water texture on certain devices, seemingly on either very new or very old devices relative to 2011-12. It seems that as of v0.7.0 alpha, the generated water texture would always be used, and the placeholder texture's use in later versions is unknown.

It was updated in v0.10.0 alpha to more closely resemble the generated water texture, becoming opaque as a result.

Due to the first terrain.png in Xbox 360 Edition being the same as the terrain.png from Beta 1.6.6, both the still and flowing water texture placeholders from said version are there by default, and would carry on into the other respective consoles. What the water placeholder textures were used for in this edition is unknown.

It was updated in TU25 and equivalent versions to more closely resemble the generated water texture, and was updated again in TU31 and equivalent versions alongside all other translucent textures to appear more translucent.

When the generated animation was added for lava in 0.0.19a, the old lava texture used before that point was kept in for use as a placeholder texture.

A second copy of the lava texture was added in the 20100110 Indev build, presumably for flowing lava, despite flowing lava not appearing visually distinct from still lava until the 20100616 build of Infdev. Whether this even represents where flowing lava would be at all, or if versions before 20100110 and inclusively after 20091223-1 would use the same placeholder texture for would-be "flowing" lava (in an identical situation to water) as it would still lava or if it would use the texture at this position instead which was a duplicate of the top of grass at the time, is currently unknown.

In the 20100616 build of Infdev, the lava placeholder textures were moved to the bottom-right of terrain.png. The still lava texture remained as a single texture square, and the flowing lava texture became a 2x2 square of lava textures, as explained earlier.

With the addition of animated texture images in 13w02a, these textures were decommissioned and removed soon after.

Due to the first terrain.png in Pocket Edition being based off of the terrain.png from Beta 1.3, both the still and flowing water texture placeholders from said version are there by default. It was used for all lava seemingly regardless of device up until v0.7.0 alpha, when lava became animated on seemingly all devices.

It was updated in v0.14.2 to more closely resemble the generated lava.

Due to the first terrain.png in Xbox 360 Edition being the same as the terrain.png from Beta 1.6.6, both the still and flowing lava texture placeholders from said version are there by default, and would carry on into the other respective consoles. What the lava placeholder textures were used for in this edition is unknown.

It was updated in TU25 and equivalent versions to more closely resemble the generated lava texture.

Despite fire being added in early Indev in January, a dedicated placeholder texture for fire was not added until late Infdev in June. Initially, the placeholder texture was a hilarious red-orange scribble, but was changed several days later to a red square with "FIRE TEX! HNST" (Fire texture!, honest!) cut out of it.

In Beta 1.2, a second copy of the placeholder texture was added to terrain.png below the original copy. This is very likely linked to there being two similar but different fire textures, with there now being one placeholder texture each.

Due to the first terrain.png in Pocket Edition being based off of the terrain.png from Beta 1.3, both of the spaces that held fire texture placeholders also hold fire texture placeholders here. Interestingly, however, all of the fire placeholders which exist throughout Pocket Edition are much different from any of those encountered in Java Edition. The first texture, in v0.1.0 alpha, resembles a red U-shape. This texture was quickly changed to a translucent orange texture in v0.1.3 alpha, which, upon further investigation, can be seen to be based off of the water placeholder texture. In v0.8.0 alpha build 1, despite the scrapping of terrain.png, two new fire texture placeholders were created, which could be seen in terrain-atlas.tga , resembling small orange rectangles.

In earlier versions, the fire placeholder texture would appear in front of burning players, successfully functioning as a stand-in for the fire texture. It also appeared as the item texture for fire as an item until v0.7.0 alpha, which made fire render correctly.

Due to the first terrain.png in Xbox 360 Edition being the same as the terrain.png from Beta 1.6.6, both fire texture placeholders from said version are there by default, and would carry on into the other respective consoles. What the fire placeholder textures were used for in this edition is unknown.

The nether portal placeholder texture was added in Alpha v1.2.0, alongside the nether portal block itself.

Due to the first terrain.png in Pocket Edition being based off of the terrain.png from Beta 1.3, the nether portal texture placeholder from said version is there by default. However, due to the absence of nether portals in this version, it remained unused until its removal in v0.8.0 alpha build 2. A second placeholder texture was added when nether portals were actually added in v0.12.1 alpha build 1.

Due to the first terrain.png in Xbox 360 Edition being the same as the terrain.png from Beta 1.6.6, the nether portal texture placeholder from said version are there by default, and would carry on into the other respective consoles. What the nether portal placeholder texture was used for in this edition is unknown.

The gear placeholder textures were added in the January 28, 2010 build of Indev, alongside gears themselves. There were two gear placeholders, likely corresponding to the two possible rotation directions.