-
Notifications
You must be signed in to change notification settings - Fork 27
Render Types
Lodestone makes it easier to create custom RenderTypes for all of your rendering needs. It's simply an extension of the vanilla RenderType system, so it's advised you familiarize yourself with that.
To make a LodestoneRenderType, either use an existing rendertype provider and apply your texture, or make your own. Most of the existing RenderTypeProviders are located in LodestoneRenderTypeRegistry.
public static final ResourceLocation TEXTURE = new ResourceLocation("modid", "path/to/texture.png");
//Using an existing RenderTypeProvider
public static final LodestoneRenderType MY_RENDER_TYPE = LodestoneRenderTypeRegistry.TRANSPARENT_TEXTURE.apply(RenderTypeToken.createToken(TEXTURE);
//Existing RenderTypeProvider with modifications
public static final LodestoneRenderType RENDER_TYPE_MODIFIED = LodestoneRenderTypeRegistry.TRANSPARENT_TEXTURE.applyWithModifier(RenderTypeToken.createToken(TEXTURE), builder -> {
builder
.setShaderState(MY_SHADER)
.setCullState(LodestoneRenderTypeRegistry.NO_CULL);
//etc.
}
);
//Creating your own RenderTypeProvider
public static final RenderTypeProvider MY_PROVIDER = new RenderTypeProvider(token ->
LodestoneRenderType.createGenericRenderType("name", DefaultVertexFormat.POSITION_COLOR_TEX_LIGHTMAP, VertexFormat.Mode.QUADS, LodestoneRenderTypeRegistry.builder()
.setShaderState(MY_SHADER)
.setTransparencyState(StateShards.ADDITIVE_TRANSPARENCY)
.setLightmapState(LodestoneRenderTypeRegistry.LIGHTMAP)
.setTextureState(token.get())
)
);
public static final LodestoneRenderType RENDER_TYPE_CUSTOM = MY_PROVIDER.apply(RenderTypeToken.create(TEXTURE));
Note: generally, try to create rendertypes in a static context. If you need to create a rendertype in a nonstatic context use RenderTypeProvider#applyAndCache
instead of RenderTypeProvider#apply
.
WIP
By default, any RenderTypes using Lodestone's Delayed Renderers will have the depth buffer ("SceneDepthBuffer"
) and inverse projection matrix ("InvProjMat"
) passed in automatically.
TODO: Add code snippets demonstrating how to pass in custom uniforms.