Skip to content

Fall back to owning mod's jar when a shader isn't found in VulkanMod'… - #882

Open
GreenSurge wants to merge 1 commit into
xCollateral:devfrom
GreenSurge:fix/namespaced-shader-lookup
Open

Fall back to owning mod's jar when a shader isn't found in VulkanMod'…#882
GreenSurge wants to merge 1 commit into
xCollateral:devfrom
GreenSurge:fix/namespaced-shader-lookup

Conversation

@GreenSurge

Copy link
Copy Markdown

What this fixes

Any mod that registers its own RenderPipeline pointing at shaders bundled in that mod's own jar fails to render correctly under VulkanMod. Confirmed case: malilib's custom terrain pipelines (LEGACY_SOLID_TERRAIN_MASA, etc.), which Litematica uses for schematic rendering schematics render blank, invisible, or miscolored with VulkanMod enabled, and work fine with the vanilla renderer.

Root cause

ShaderLoadUtil.getShaderSource(Identifier, ShaderType) builds its file path from resourceLocation.getPath() only the namespace half of the Identifier is discarded and only ever searches inside VulkanMod's own jar (RESOURCES_PATH is hardcoded to /assets/vulkanmod). So when a pipeline like malilib:legacy_terrain needs compiling, this method only looks for legacy_terrain... inside VulkanMod's own jar, never finds it (the file actually lives in malilib's jar, at assets/malilib/shaders/legacy_terrain.vsh/.fsh), returns null, and the pipeline fails to build correctly.

This isn't specific to Litematica/malilib it'll happen for any mod using the standard RenderPipeline API with shaders bundled in its own jar, since that's a completely normal, spec-compliant thing to do.

The fix

When the existing in-jar lookup misses, fall back to resolving the Identifier's namespace to its actual owning mod via Fabric Loader's ModContainer API (FabricLoader.getInstance().getModContainer(namespace) ModContainer#findPath(...)), and read the shader from that mod's real resource root. This works identically in a dev environment or a packaged jar, and mirrors the same two-tier path/name.ext -> path.ext lookup order already used for VulkanMod's own shaders, so behavior for VulkanMod's own shaders is completely unchanged the fallback only ever runs on the specific case where the current lookup already returns null.

FabricLoader is already a dependency used elsewhere in the codebase (ModSettingsRegistry, Initializer), so this doesn't introduce anything new.

Testing

Built and tested against Fabric 1.21.11 + malilib + Litematica (both on their LTS/1.21.11 branches). Schematics that previously rendered blank/blue with VulkanMod enabled now render correctly, with no change in behavior for VulkanMod's own shaders or other rendering.

I also have a standalone compat-mod version of this same fix (external mixin, for anyone who wants it before this merges) if that's useful context: [litematica-vulkan-shim].

Diff

Single file changed: src/main/java/net/vulkanmod/render/shader/ShaderLoadUtil.java (+46/-1). Patch attached / see commit.

…s own jar

ShaderLoadUtil.getShaderSource(Identifier, ShaderType) discards the
Identifier's namespace and only ever looks inside VulkanMod's own jar
(RESOURCES_PATH is hardcoded to /assets/vulkanmod). Any mod that
registers a custom RenderPipeline pointing at shaders bundled in its
own jar -- e.g. malilib's legacy terrain pipelines, used by Litematica
for schematic rendering -- silently fails to resolve, breaking
compilation of that pipeline (manifests as blank/miscolored
schematics under VulkanMod).

This adds a fallback: when the in-jar lookup misses, resolve the
Identifier's namespace to its actual owning mod via Fabric Loader's
ModContainer API and read the shader from that mod's real resource
root, using the same two-tier path/name.ext -> path.ext lookup order
already used for VulkanMod's own shaders.

Tested against Litematica + malilib on 1.21.11: schematic rendering
that was previously blank now renders correctly with VulkanMod
enabled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant