Procedural animated texture generation/Lava

This section is missing information about: c0.0.19a era lava.
 
Please expand the section to include this information. Further details may exist on the talk page.

Still lava

Adapted from https://github.com/UnknownShadow200/ClassiCube/wiki/MInecraft-Classic-lava-animation-algorithm#lava

Every frame, for each position in the still water texture array, the respective values for soup_heat, pot_heat and flame_heat are calculated as detailed below:

  • Calculates a local_soup_heat equal to the sum of the 3×3 soup_heat neighborhood around the current element but offset vertically by colSin******* and offset horizontally by rowSin*********.
    • rowSin is 1.2 times the sign of an angle that starts at 0 and changes by 22.5 degrees every row.
    • colSin is 1.2 times the sign of an angle that starts at 0 and changes by 22.5 degrees every column.
  • Calculates a local_pot_heat equal to the sum of a 2×2 pot_heat neighborhood around the current pot_heat, with the current position being the upper left of the 2×2 neighborhood.
  • Calculates the new soup_heat as the sum of the local_soup_heat divided by 10 plus the local_pot_heat divided by 4 times 0.8.
  • Calculates the new pot_heat as the current pot_heat plus the flame_heat times 0.01***************. pot_heat is clamped to a minimum of 0.
  • Calculates the new flame_heat as the current flame_heat minus 0.06.
    • However, there is a 0.005 in 1 random chance that flame_heat is set to 1.5.

Once the above arrays have been updated, for each pixel in the lava texture, the color values are calculated based on soup_heat (alpha is always opaque for lava):

  • Calculates a color_heat as double the soup_heat clamped between 0 and 1 inclusive.
  • Then it calculates the color components of the pixel as follows:
    • float red = color_heat * 100F + 155F
    • float green = color_heat^2 * 255F
    • float blue = color_heat^4 * 128F

The red, green and blue values are then converted to bytes and assigned to the texture accordingly.

Flowing lava

Flowing lava uses the exact same algorithm as still lava to generate its texture, however there is also a spatial translation to give the appearance of movement. This transformation moves the lava texture downward by one pixel every 3 game ticks, wrapping the bottom layer of the texture back to the top.