Overview
The Auto Glow Texture feature allows you to easily apply glowing effects to textures specific to your model without requiring additional code for handling emissive layers. AzureLib achieves this by using a second texture file with the _glowmask suffix in its name, which defines the emissive parts of your model.
For instance, if your base texture is:
example_model.png
The glow layer texture would be:
example_model_glowmask.png
The AzAutoGlowingLayer handles applying the glow automatically, saving time and effort for developers.
Setup Instructions
Step 1: Prepare Your Textures
-
Base Texture: Prepare a normal texture for your model as you usually would (e.g.,
example_model.png). -
Glow Layer Texture: Create the glow texture by duplicating your base texture and making any areas that shouldn’t glow fully transparent. Keep the glowing parts visible (e.g.,
example_model_glowmask.png).- Only the parts in the glow texture that are visible will glow in-game.
- Make sure the
_glowmasktexture matches the dimensions of the base texture.
Step 2: Add the Auto Glow Layer to Your Renderer
The AzAutoGlowingLayer is designed to be added to your renderer’s pipeline to apply the glowing effect automatically.
Here’s how you can integrate it into your custom renderer:
import mod.azure.azurelib.common.render.layer.AzAutoGlowingLayer;import net.minecraft.client.renderer.entity.EntityRendererProvider;import net.minecraft.resources.ResourceLocation;public class ExampleEntityRenderer extends AzEntityRenderer<ExampleEntity> {private static final ResourceLocation MODEL_LOCATION =new ResourceLocation("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 AzAutoGlowingLayer<>()) // Add the auto glow layer.build(), context);}}
Step 3: Tint the Glow (Optional)
You can tint the glow by passing a color to AzAutoGlowingLayer, without needing a custom layer.
Fixed tint:
.addRenderLayer(new AzAutoGlowingLayer<>(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:
.addRenderLayer(new AzAutoGlowingLayer<>(context ->context.animatable().isAggressive() ? 0xFFFF4040 : 0xFF40FF60))
Because the function runs every frame, you can also use it to pulse the glow, for example by driving the color from context.animatable().tickCount and context.partialTick().
How tinting works:
- The tint is multiplied with the glow texture's colors. Tinting works best when the glowing parts of your
_glowmasktexture are white or grey. A colored glow mask will mix with the tint (for example, a red glow tinted green turns dark). - The tint is also multiplied with the renderer's own color, so it stacks with any tint your renderer already applies instead of replacing it.
Color.WHITE(0xFFFFFFFF) means no tint, and is the same as usingnew AzAutoGlowingLayer<>().- The tint's alpha fades the glow. It multiplies the renderer's own alpha, so an already translucent entity's glow fades further.
- The tint only affects the glow layer. The rest of the model renders as normal.
Step 4: Custom Glow Textures and Multiple Layers (Optional)
By default, AzAutoGlowingLayer automatically generates the glow texture from the paired _glowmask asset. Use withTexture to supply a custom colored RGBA overlay instead. Custom overlays are rendered directly without removing pixels from the base texture.
private static final ResourceLocation HEART_GLOW =ResourceLocation.fromNamespaceAndPath("yourmodid", "textures/entity/example_heart.png");private static final ResourceLocation BODY_GLOW =ResourceLocation.fromNamespaceAndPath("yourmodid", "textures/entity/example_body.png");
Register a separate layer for each overlay:
.addRenderLayer(new AzAutoGlowingLayer<UUID, ExampleEntity>(Color.WHITE).withTexture(BODY_GLOW)).addRenderLayer(new AzAutoGlowingLayer<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_GLOW))
The body glow remains constant while the heart glow pulses independently.
- Custom overlays do not require the
_glowmasksuffix. - Use transparent pixels wherever the overlay should not appear.
- Match the model's UV layout. Each overlay can have its own tint and alpha.
- Custom direct glow textures can use their own
.png.mcmetaanimation metadata, independent of the base texture. - Custom direct overlays bypass the generated glowmask's quad coverage filtering.
- Multiple overlays are separate blended passes, not additive light sources.
Dynamic texture selection:
.addRenderLayer(new AzAutoGlowingLayer<UUID, ExampleEntity>().withTexture(context ->context.animatable().isOnFire() ? ACTIVE_TEXTURE : IDLE_TEXTURE))
Returning null from the texture provider skips that layer for the current render. When chaining withTexture, specify the renderer's key and entity types explicitly (for example, <UUID, ExampleEntity>, with java.util.UUID imported). Replace the resource constants with your own texture locations.
For grayscale per-pixel emission intensity using the base texture's colors, use AzEmissiveMapLayer instead. Avoid overlapping automatically generated legacy glowmasks and emissive maps on the same base texture, since legacy glowmask generation removes pixels from the base.
Troubleshooting
-
Glow Effect Not Visible:
- Symptom: Entity model renders completely black on the exterior of the model.
- Verify that your
_glowmasktexture is in the correct file path, or check the custom location supplied towithTexture. - For automatic lookup, ensure the glow texture uses the
_glowmasksuffix.
-
Texture Not Found:
- Double-check that your main texture file is correctly registered in the renderer.
- Confirm the model uses a texture location that matches your
_glowmasktexture pairing logic, or verify the custom overlay location.
-
Render Issues:
- For generated glowmasks, make sure the texture dimensions match the base texture. For direct overlays, verify the UV layout and any animation metadata.
- Test with a simple texture first to isolate potential issues.
-
Tint Looks Wrong or Too Dark:
- Make the glowing parts of your
_glowmasktexture white or grey, since the tint multiplies the texture's colors. - Make sure your tint includes full alpha (
0xFFat the start, e.g.0xFFFF4040). A tint like0xFF4040has an alpha of zero, which makes the glow invisible.
- Make the glowing parts of your
Advanced Configuration (Optional)
The AzAutoGlowingLayer renders the glow at full brightness (LightTexture.FULL_BRIGHT) by default. If you want to customize the glow brightness or other behaviors, extend the AzAutoGlowingLayer class and override its methods:
getPackedLight(context): the light value used for the glow render.getGlowColor(context): the ARGB tint for the glow. Override this instead of passing a function to the constructor if your tint logic is easier to keep in a subclass.determineRenderType(context): the render type used for the glow, including how invisible and glowing (outlined) entities are handled.glowFilter(context): the quad filter for generated glow textures. Custom direct overlays bypass this filter by default; returnnullto disable filtering in a custom implementation.sortsTranslucency(): returnsfalse, so the glow stays drawn on top of the model when its renderer has translucency sorting on. There's rarely a reason to change this.
public class PulsingGlowLayer<K, T> extends AzAutoGlowingLayer<K, T> {@Overrideprotected int getGlowColor(AzRendererPipelineContext<K, T> context) {// Your tint logic here, returning an ARGB colorreturn 0xFF40FF60;}}