---
title: Adding Emissive Maps
hide_meta: true
---

# How to use the Emissive Map feature

## Overview

The **Emissive Map** feature allows you to control the glow intensity of individual pixels on your model using a single grayscale texture. Unlike the Auto Glow Texture feature, which uses `_glowmask` textures, an emissive map allows different parts of the same texture to glow at different intensities without requiring separate bones or render layers.

For instance, if your base texture is:

`example_model.png`

The emissive map texture would be:

`example_model_emissive.png`

The `AzEmissiveMapLayer` handles applying the emissive map automatically. The original base texture remains unchanged, and its colors are used for the emissive effect.

This feature is separate from `AzAutoGlowingLayer`. Existing `_glowmask` textures continue to work as before. Use the appropriate layer for your desired effect. Avoid overlapping automatically generated legacy glowmasks with emissive maps on the same base texture; custom direct glow overlays do not remove base pixels.

## Setup Instructions

### Step 1: Prepare Your Textures

1. **Base Texture**: Prepare a normal texture for your model as you usually would (e.g., `example_model.png`).

2. **Emissive Map Texture**: Create a grayscale texture with the same dimensions as your base texture (e.g., `example_model_emissive.png`). Paint each pixel according to how strongly it should glow.

   - Black pixels do not emit light and retain their normal environmental lighting.
   - White pixels render at full emissive brightness.
   - Gray pixels blend between normal lighting and full emissive brightness.
   - Transparent pixels do not glow. Partial transparency further reduces the emission intensity.
   - Make sure the `_emissive` texture matches the dimensions of the base texture.

| Emissive Map Color | Hex Value | Emission Intensity |
| --- | --- | --- |
| Black | `#000000` | 0% |
| Dark Gray | `#404040` | ~25% |
| Gray | `#808080` | ~50% |
| Light Gray | `#C0C0C0` | ~75% |
| White | `#FFFFFF` | 100% |

The emissive map controls **intensity**, not color. For example, a gray pixel over a red area of your base texture produces partial red emission, while the same gray pixel over a blue area produces partial blue emission.

The effect makes the model's surfaces appear self-lit. It does not produce dynamic world lighting or a bloom effect by itself.

### Step 2: Add the Emissive Map Layer to Your Renderer

The `AzEmissiveMapLayer` is designed to be added to your renderer's pipeline to apply the emissive effect automatically.

Here's how you can integrate it into your custom renderer:

```java
import mod.azure.azurelib.common.render.layer.AzEmissiveMapLayer;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.resources.ResourceLocation;

public class ExampleEntityRenderer extends AzEntityRenderer<ExampleEntity> {
    private static final ResourceLocation MODEL_LOCATION =
        ResourceLocation.fromNamespaceAndPath("yourmodid", "geo/example_model.geo.json");

    private static final ResourceLocation TEXTURE_LOCATION =
        ResourceLocation.fromNamespaceAndPath("yourmodid", "textures/entity/example_model.png");

    public ExampleEntityRenderer(EntityRendererProvider.Context context) {
        super(
            AzEntityRendererConfig.<ExampleEntity>builder(MODEL_LOCATION, TEXTURE_LOCATION)
                .addRenderLayer(new AzEmissiveMapLayer<>()) // Add the emissive map layer
                .build(), context
        );
    }
}
```

### Step 3: Tint the Emission (Optional)

You can tint the emission by passing a color to `AzEmissiveMapLayer`, without needing a custom layer.

**Fixed tint:**

```java
.addRenderLayer(new AzEmissiveMapLayer<>(Color.RED))
```

You can use any `Color`, such as `Color.ofRGB(64, 255, 96)` for a custom shade.

**Dynamic tint:**

For a tint that changes with the entity's state, pass a function instead. It receives the render context every frame and returns an ARGB color as an `int`:

```java
.addRenderLayer(new AzEmissiveMapLayer<>(context ->
    context.animatable().isOnFire() ? 0xFFFF4040 : 0xFF40FF60
))
```

**Dynamic intensity:**

The alpha channel of the tint can also be used to control the overall emission intensity. This multiplies the intensity of each pixel in the emissive map rather than replacing it.

```java
.addRenderLayer(new AzEmissiveMapLayer<>(context -> {
    double time = context.animatable().tickCount + context.partialTick();
    double intensity = 0.5D + Math.sin(time * 0.1D) * 0.5D;
    int alpha = (int) Math.round(intensity * 255D);

    return (alpha << 24) | 0x00FFFFFF;
}))
```

This example smoothly pulses the emission while preserving the relative intensities defined in the emissive map.

**How tinting works:**

- The tint is **multiplied** with the base texture's colors in the emissive pass. A red area tinted green may appear dark, even if its emissive map is white.
- The tint is also multiplied with the renderer's own color and alpha.
- `Color.WHITE` (`0xFFFFFFFF`) means no tint, and is the same as using `new AzEmissiveMapLayer<>()`.
- The tint's alpha fades the entire emissive effect. An alpha of zero disables the emission without hiding the normally rendered model.
- The tint only affects the emissive layer. The rest of the model renders as normal.

### Step 4: Animated Emissive Maps (Optional)

Emissive maps also support animated textures. The emissive map follows the animation of the base texture, including its frame sequence, frame durations, repeated frame indices and interpolation setting.

For example, your texture files could be arranged as follows:

```text
textures/entity/
├── example_model.png
├── example_model.png.mcmeta
└── example_model_emissive.png
```

The emissive map must use the same dimensions and frame layout as the base texture. For example, if your base texture contains four 64 × 64 frames stacked vertically in a 64 × 256 image, your emissive map must also be 64 × 256.

Configure the animation using the base texture's `.mcmeta` file:

```json
{
    "animation": {
        "frametime": 12,
        "interpolate": true,
        "frames": [
            0,
            { "index": 1, "time": 6 },
            2,
            3,
            2,
            1
        ]
    }
}
```

No separate `_emissive.png.mcmeta` file is required. The emissive map uses the base texture's animation timing.

When `interpolate` is enabled, AzureLib interpolates both the color and emission intensity of the emissive frames, allowing smooth fades between black, gray and white pixels. When disabled, emission changes immediately as the animation advances to the next frame.

You can animate the emissive map even when every frame of the base texture has identical colors, which is useful for pulsing lights, charging indicators and other animated effects.

### Step 5: Custom Emissive Maps and Multiple Layers (Optional)

By default, `AzEmissiveMapLayer` looks for the `_emissive` texture paired with the base texture. Use `withTexture` to select a different grayscale emissive map, without requiring the default filename or directory.

```java
private static final ResourceLocation HEART_EMISSIVE =
    ResourceLocation.fromNamespaceAndPath("yourmodid", "textures/entity/example_heart.png");

private static final ResourceLocation BODY_EMISSIVE =
    ResourceLocation.fromNamespaceAndPath("yourmodid", "textures/entity/example_body.png");
```

Register a separate layer for each map:

```java
.addRenderLayer(
    new AzEmissiveMapLayer<UUID, ExampleEntity>()
        .withTexture(BODY_EMISSIVE)
)
.addRenderLayer(
    new AzEmissiveMapLayer<UUID, ExampleEntity>(context -> {
        double time = context.animatable().tickCount + context.partialTick();
        int alpha = (int) Math.round(
            (0.5D + Math.sin(time * 0.1D) * 0.5D) * 255D
        );

        return (alpha << 24) | 0x00FFFFFF;
    }).withTexture(HEART_EMISSIVE)
)
```

The body emission remains constant while the heart emission pulses independently. Both maps use the base texture's colors; the supplied locations refer to grayscale intensity maps, not colored glow overlays.

- Each map must match the base texture's dimensions and UV layout.
- Animated maps must also match its frame layout. All maps inherit the base texture's `.mcmeta` timing and interpolation settings.
- Each generated emissive texture has its own animation attachment and quad coverage. The same source map can be reused with different base textures.
- Multiple maps are drawn as separate blended passes, not added together as light values. Prefer non-overlapping masks when independent intensity control is desired.

**Dynamic texture selection:**

The `withTexture` method also accepts a function that receives the render context and returns a `ResourceLocation`. For example:

```java
.addRenderLayer(
    new AzEmissiveMapLayer<UUID, ExampleEntity>()
        .withTexture(context ->
            context.animatable().isOnFire() ? ACTIVE_TEXTURE : IDLE_TEXTURE
        )
)
```

Returning `null` from the function skips that layer for the current render. Each layer can have its own fixed or dynamic tint, including alpha for independently fading the effect.

When chaining `withTexture`, specify the renderer's key and entity types explicitly (for example, `<UUID, ExampleEntity>` for an entity renderer, with `java.util.UUID` imported). Replace the resource constants with your own texture locations.

### Troubleshooting

1. **Emission Not Visible:**
   - Verify that `AzEmissiveMapLayer` is registered in your renderer.
   - Ensure the default emissive texture uses `_emissive`, or verify the explicit source location passed to `withTexture`.
   - Check that the areas you want to glow are not black or fully transparent in the emissive map.
   - Test in a dark environment, where differences in emission intensity are easier to see.

2. **Texture Not Found or Incorrect Dimensions:**
   - Double-check that your main texture file is correctly registered in the renderer.
   - For automatic lookup, confirm the emissive map is in the same directory and uses the same filename with the `_emissive` suffix. For custom maps, verify the supplied resource location.
   - Make sure both textures have matching dimensions.

3. **Animated Emission Not Working:**
   - Make sure the base texture has a valid `.png.mcmeta` animation file.
   - Confirm the emissive map uses the same frame layout as the base texture.
   - Enable `"interpolate": true` if you want smooth transitions between emission intensities.

4. **Tint Looks Wrong or Too Dark:**
   - Remember that the emissive color comes from the base texture, not the grayscale map. The tint multiplies those colors.
   - Make sure your tint includes full alpha (`0xFF` at the start, e.g. `0xFFFF4040`) unless you intend to fade the emission. A tint like `0xFF4040` has an alpha of zero.

5. **Existing Glowmask Looks Different:**
   - Use `AzAutoGlowingLayer` with `_glowmask` textures to retain the existing glowmask behavior.
   - Use `AzEmissiveMapLayer` with `_emissive` textures for variable-intensity emission. Avoid overlapping generated legacy glowmasks and emissive maps on the same base texture, since the legacy glowmask removes pixels from the base. Custom direct glow overlays do not perform that removal.

### Advanced Configuration (Optional)

The `AzEmissiveMapLayer` extends `AzAutoGlowingLayer` and reuses its tinting and rendering functionality. The default emissive render types draw unlit; the emissive map controls how much of that unlit color is blended over the normally lit model.

To customize its behavior, extend the `AzEmissiveMapLayer` class and override its methods:

- `getGlowColor(context)`: the ARGB tint for the emissive layer. Override this instead of passing a function to the constructor if your tint or intensity logic is easier to keep in a subclass.
- `getPackedLight(context)`: the packed light value passed for the emissive render, defaulting to `LightTexture.FULL_BRIGHT`. The default glow shader renders the overlay without normal environmental lighting.
- `determineRenderType(context)`: the render type used for emission, including how invisible and glowing (outlined) entities are handled.
- `glowFilter(context)`: the quad filter used to skip geometry with no visible emissive pixels. If you select a different emissive texture in a subclass, ensure the filter matches that texture or return `null` to disable filtering.
- `sortsTranslucency()`: returns `false`, so the emissive layer stays drawn on top of the model when its renderer has translucency sorting on. There's rarely a reason to change this.

```java
public class PulsingEmissiveLayer<K, T> extends AzEmissiveMapLayer<K, T> {

    @Override
    protected int getGlowColor(AzRendererPipelineContext<K, T> context) {
        // Your tint and intensity logic here, returning an ARGB color
        return 0x8040FF60;
    }
}
```
