Skip to content

Colormaps

MehVahdJukaar edited this page May 25, 2024 · 40 revisions

Colormaps

Colormaps are a special object added by the mod. By themselves they do nothing but they can be Attached to many things via other Polytone concepts to alter how their colors are choosen. These are:

  • Fluids -> Fluid Modifiers
  • Blocks -> Block Properties Modifiers
  • Particles -> Particle Modifiers
  • Sky/Fog -> Dimension Effects

Note

If you are using Sodium, due to this issue, Colormaps will be completely off until they fix.

Consider using Embeddium (fabric) instead.

The Colormaps Folder

When defined in their own /colormaps folder, colormaps will be able to be referenced and used elswhere.

You can however also add them to either the /block_properties folder or the /fluid_properties to have them automatically attached to either entries. This mainly servers as a shorthand. We'll first go over how to add one in /colormaps.

To function, Colormaps need a .png and/or a .json file in /colormaps.

Png Texture

A Colormap .png needs to be added for each tint index you intend to use (texture can be any size). These will be placed right next the Colormap .json at the following path: assets/[your pack namespace]/polytone/colormaps/[your colormap name]_[tint index].png.

If you are only using 1 tint index you can omit the tint index information.

Aa an Example let's say you have a blockmodel that uses "tintindex = 1" for one of its face. The texture file will be called something like mì my_colormap_1.png. Note the last underscore matching the ting index.

Json Configuration

Json configuration file is used to precisely define the sampler behavior of the colormap. You can omit it to have the vanilla biome temperature/humidity sampler used in grass color (refer to Minecraft Wiki for more info).

It must be placed in the same folder as the .png file, so in: assets/[your pack namespace]/polytone/colormaps/[your colormap name].json

Each Json can needs to have the following attributes:

Attribute Name Default Value Explanation
x_axis - (not optinlal) X Sampler. A math expression that determines the colormap texture x coordinate. Output has to be from 0 to 1 (will be clamped if not)
y_axis - (not optinlal) Y Sampler. A math expression that determines the colormap texture y coordinate. Output has to be from 0 to 1 (will be clamped if not)
default_color Color at texture 0.5, 0.5 The default color that blocks will have. Mainly relevant when said blocks will have an item form. If blank it will pick the center color.
triangular true Boolean. Determines if only lower half of the colormap will be used (like vanilla grass color). By default is off so the entire texture will be used.
biome_blend true* Boolean. If colors should blend in between biomes. Active by default for all maps that use the TEMPERATURE or DOWNFALL values in their samplers

For more info about Math Expressions Scripting visit its respective Page.

Here's an example Colormap .json for Tint Index 0 and 1. Note that you can use -1 to apply the colormap to all Tint Inexes.

{
  "default_color": 23433,
  "x_axis": "0.5+cos(POS_X*0.2)*0.5",
  "y_axis": "0.5+sin(POS_Z*0.1)*0.5 + TEMPERATURE"
}

Once you have added your Colormap file the only thing you need to do is reference it in all your Block Properties, Fluid Properties or Particle Modifers Json files like so:

{
   "colormap": "[your pack namespace]:[your colormap name]"
}

Inlining

If this is too much and you just want a simple colormap with vanilla sampler you can place your texture file(s) directly in /block_properties or /fluid_properties with the name of any block/fluid of your choosing and it will be assigned to that block/fluid.

Note however that it is NOT RECCOMENDED to do so if you are using the SAME COLORMAP MULTIPLE TIMES. This is because the game will create MULTIPLE Colormap instances which needlessly wastes resources. Expecially relevant if those maps have Biome Blend on.

In Block Properties

As an example, to give a custom Colormap to minecraft:sugar_cane you'll just have to place (one or more depending on tint index) file at the location assets/[your pack name]/polytone/block_properties/minecraft/sugar_cane_[tint index].png. (Once again you can omit /minecraft or _[tint index] if you so choose.)

Note that when done this way the Colormap .png must be placed in the ./block_properties/[my property].json folder, following same convention as its json file.

{
   "colormap": {
      "1": {
         "x_axis": "state_prop(0)",
         "y_axis": "0",
         "default_color": 4764952
      }
   }
}

In this specific example we are creating a colormap for Wheat Block using a 7x1 texture. The sampler will look up the AGE BlockState Property (the only property that block has, hence why index 0) and sample one of the 15 columns accordingly.

Note that if you intend to only have a tint applied to ALL tint indexes you can omit the "[tint index]":{} part and straight out define a colormap like you would in Fluid Properties here below.

In Fluid Properties

These work exactly the same as block properties except you wont have to define any logic related to the tint index. As such the json can be as follows:

{
   "colormap": {
      "x_axis": "TEMPERATURE",
      "y_axis": "DOWNFALL",
   }
}

Default Colormaps

Below follows a list of all the already defined colormaps (types) you can use incase you dont want to define your own. Note that the first 3 types already have a texture associated as those are the 3 vanilla existing colormaps so you won't need to add a texture when using those.

Default Colormap Types Requires Custom Texture Description
grass_color false Vanilla grass biome color resolver (grasscolor.png)
foliage_color false Vanilla foliage biome color resolver (foliagecolor.png)
water_color false Vanilla biome water color resolver (watercolor.png)
biome_sample true Samples with same logic as grass_color but its NOT triangular and requires a custom texture file
triangular_biome_sample true Samples with same logic as grass_color and requires a custom texture file
fixed true Just gets a single pixel at 0,0
grid true Assigns each biome its Registry numerical ID divided by 256 and uses it to sample the X axis. Y axis is sampled based on block y position. Just used for Optifine backwards compat. Only use with biome_id_mapper. This interns uses biome_id sampler explained below.

Example of using a pre defined (or custom) colormap by reference in Block Properties Modifier Json

{
  "colormap": "fixed"
}

Default Samplers

Default Samplers Description
temperature equivalent of writing TEMPERATURE. gets the temperature of the biome at that pos
downfall equivalent of DOWNFALL. gets the downfall of the biome at that pos
legacy_temperature returns height dependant temperature. This is how colormaps used to operate before 1.17
biome_id returns the current biome Registry Index divided by 255 or the value given by biome_id_mapper. Ideally only use when paired with biome_id_mapper

Example of using a pre defined sampler (on the y axis). Showing here a Colormap Json instead. As you can see the second one is an expression while the first one is equivalent of having written just "TEMPERATURE" and will use the pre defined temperature sampler.

{
  "y_axis": "temperature"
  "x_axis": "TEMPERATURE+2"
}

If you want to have something simple like a single color colormap, just set the samplers to 0 and give it a single pixel texture as colormap. At that point however you should consider using for your model a different colored texture instead

Biome Id (Grid) Colormap

When using the biome_id sampler or the pre defined grid colormap type it is recommended that you also include a biome_id_mapper to manually define the numerical "ID" of each biome.

See in modern versions registry entries such as biomes dont have a static numerical ID associated with them and instead they have a resource location (i.e. minecraft:forest). Moreover in a modded enrivonment the registry order of them could vary depending on the installed mods and thus is not static.

For these reason its necessary to have a way to tell the mod what numerical value to associated to each biome such that the biome texture can be sampled accordingly.

To do so you'll have to add a biome_id_mapper to your colormap json or alternatively define it in the /polytone/biome_id_mappers/ folder and reference it by ID like we did many times before.

Note that when this is omitted, the mod will assign to each biome registry index divided by 255. It's clear how in a modded environment this isnt nearly enough control to guarantee that modded biomes work as expected.

To proceed, simply add this block to your colormap json. It contains a map of biome IDs to numerical values. These values will have to be from 0 to 1. Note that we use "biome_id" as sampler as that is the only one that will use the biome id mapper object.

{
  "x_axis": "biome_id",
  "y_axis": "0",
  "biome_id_mapper": {
    "minecraft:forest": 0.01,
    "swamp": 0.9
  }  
}

Note that all biomes that are NOT included will map to 0.

If you wish to work with pixel coordinates instead, you can add the texture_size string to it. This will divide all your values by that amount, essentially letting you workwith pixel coordinates instead of relative ones. Obviousluy texture size will have to match your colormap dimension.

{
  "biome_id_mapper": {
    "minecraft:forest": 1,
    "swamp": 14,
    "plains": 15,

    "texture_size": 16
  }  
}

Finally if you do not wish to copy paste these into all your colormaps, you can also statically define them in assets/[your pack namespace]/polytone/biome_id_mappers/[your mapper name].json.

Once you have done that you can simply reference them in your colormaps as follows

{
  "biome_id_mapper": "my_pack_name:my_mapper_name"
}