Class ShaderPreDefinitions
java.lang.Object
com.hbm_m.client.render.shader.modification.ShaderPreDefinitions
Wraps a
ResourceProvider so that resources matching a target ResourceLocation
are intercepted, their content is run through a ShaderModification, and the modified
bytes are exposed back to the caller as a synthetic Resource.
This is the entry point used by ClientSetup.onRegisterShaders to compile multiple
variants of the same shader source with different preprocessor defines (e.g. with and
without #define USE_INSTANCING).
-
Method Summary
Modifier and TypeMethodDescriptionstatic net.minecraft.server.packs.resources.ResourceProviderwrap(net.minecraft.server.packs.resources.ResourceProvider delegate, net.minecraft.resources.ResourceLocation target, ShaderModification modification) Returns aResourceProviderthat delegates todelegatefor every resource excepttarget.static net.minecraft.server.packs.resources.ResourceProviderwrapRedirect(net.minecraft.server.packs.resources.ResourceProvider delegate, net.minecraft.resources.ResourceLocation virtualTarget, net.minecraft.resources.ResourceLocation realSource, ShaderModification modification) Same aswrap(net.minecraft.server.packs.resources.ResourceProvider, net.minecraft.resources.ResourceLocation, com.hbm_m.client.render.shader.modification.ShaderModification), but whenvirtualTargetis requested the bytes are loaded fromrealSource(which DOES exist in resource packs), then patched and returned as if they were thevirtualTarget's content.
-
Method Details
-
wrap
public static net.minecraft.server.packs.resources.ResourceProvider wrap(net.minecraft.server.packs.resources.ResourceProvider delegate, net.minecraft.resources.ResourceLocation target, ShaderModification modification) Returns aResourceProviderthat delegates todelegatefor every resource excepttarget. Whentargetis requested the original bytes are loaded, passed throughmodification.apply(...), and re-wrapped as aResource. -
wrapRedirect
public static net.minecraft.server.packs.resources.ResourceProvider wrapRedirect(net.minecraft.server.packs.resources.ResourceProvider delegate, net.minecraft.resources.ResourceLocation virtualTarget, net.minecraft.resources.ResourceLocation realSource, ShaderModification modification) Same aswrap(net.minecraft.server.packs.resources.ResourceProvider, net.minecraft.resources.ResourceLocation, com.hbm_m.client.render.shader.modification.ShaderModification), but whenvirtualTargetis requested the bytes are loaded fromrealSource(which DOES exist in resource packs), then patched and returned as if they were thevirtualTarget's content. This is essential when registering multipleShaderInstances that share the same source but need DIFFERENT compiled programs — vanillaProgram.getOrCreatecaches by the "vertex"/"fragment" name from the JSON, so two variants pointing at the same name will collide and only the first compilation wins.Example:
block_lit_simple.jsonreferences"vertex": "hbm_m:block_lit",block_lit_instanced.jsonreferences"vertex": "hbm_m:block_lit_instanced". Only the latter file does not exist on disk; this provider fabricates it fromhbm_m:shaders/core/block_lit.vsh+#define USE_INSTANCING.
-