Skip to content

Emissive Textures (Geckolib3)

Tslat edited this page Jul 3, 2023 · 5 revisions

GeckoLib provides built-in functionality for allowing your animatable objects to have fullbright textures or texture parts. You may also know this as emissive textures, or glow textures. This is similar to the functionality that vanilla Spider eyes have. where they glow in the dark.

To do this, GeckoLib implements a GeoRenderLayer called LayerGlowingAreasGeo.

Usage

To use the emissive rendering functionality that GeckoLib provides, you'll first need to add an instance of LayerGlowingAreasGeo to your animatable renderer, in its constructor. This is similar to how you would normally add render layers to any other renderer.

The constructor of LayerGlowingAreasGeo takes the renderer instance you're registering it to, a function that returns the texture to render, a function that returns the model to render, and a function that takes the id of the generated glowing texture, and returns the RenderType instance to render with. This can be a little bit confusing to understand at face value, so an example has been provided below to help show its usage.

Example Usage

public class ExampleRenderer extends GeoEntityRenderer<ExampleEntity> {
	public ExampleRenderer(EntityRendererProvider.Context renderManager) {
		super(renderManager, new ExampleEntityModel());

		addRenderLayer(new LayerGlowingAreasGeo(this, 
				entity -> getGeoModel().getTextureResource(entity),
				entity -> getGeoModel().getModelResource(entity),
				RenderType::eyes));
	}
}

Preparing the Texture

GeckoLib generates a special texture automatically that is used to render the glowing parts of your texture. To do this however, it needs some information provided in the form of an .mcmeta json file. This .mcmeta file should be placed in the same location as your texture file, and be named the same as your texture file, with .mcmeta appended to the end.

E.G.

my_entity_texture.png

my_entity_texture.png.mcmeta

Inside the .mcmeta file, you will need to create a glowsections section, which contains a sections section, which is an array of coordinates. which represent the pixels in your texture file that you want to glow.

To reduce confusion, an example has been provided below:

{
  "glowsections": {
    "sections": [
	  {
		"x": 0,
		"y": 0,
		"w": 5,
		"h": 10
	  },
	  {
		"x": 5,
		"y": 0,
		"w": 5,
		"h": 5
	  }
	]
  }
}

This example file tells GeckoLib that the regions of the original texture from x0,y0 -> x5,y10 and x5,y0 -> x10,y5 should be made to glow. Coordinates 0,0 are the top-left pixel in the .png file.

For clarity, the four values in the json are as follows:

  • x -> The left-most coordinate of the glowing region
  • y -> The top-most coordinate of the glowing region
  • w -> The width of the glowing region, starting from x and going right
  • h -> The height of the glowing region, starting from y and going down

Table of Contents

Geckolib 3
Geckolib 4

Hosted By: Cloudsmith

Package repository hosting is graciously provided by Cloudsmith.

Cloudsmith is the only fully hosted, cloud-native, universal package management solution that enables your organization to create, store and share packages in any format, to any place, with total confidence.

Clone this wiki locally