Use a comment for including rpo in vanilla resource packs instead of #include
This commit is contained in:
parent
a06823a63c
commit
ec01ab3ff7
|
@ -1,6 +1,11 @@
|
|||
# Usage in fabulous/canvas/frex shaders
|
||||
## Getting started
|
||||
All you need to do to access respackotps values is paste the following in a file where you want them: `#include respackopts:config_supplier`
|
||||
All you need to do to access respackotps values is paste the following in a file where you want them according to your renderer:
|
||||
| Renderer | Include snippet |
|
||||
| --- | --- |
|
||||
| Canvas | `#include respackopts:config_supplier` |
|
||||
| Vanilla/Fabulous | `//include respackopts:config_supplier` (this is done to avoid problems when loading shaders without respackopts) |
|
||||
|
||||
However, usually you will want to still have a pack that works if respackotps is not present. In that case, canvas will still load the file,
|
||||
however, values that respackotps registers will not be available leading to compile errors.
|
||||
To avoid this, I recommend creating a source file in your own shader which will load default values if respackotps isn't present. You can do that as follows:
|
||||
|
|
|
@ -120,10 +120,12 @@ public class Respackopts implements ClientModInitializer {
|
|||
if (CONFIG.debugLogs)
|
||||
LOGGER.info("Generating FREX shader code");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("#define respackopts_loaded");
|
||||
sb.append("#ifndef respackopts_loaded");
|
||||
sb.append("\n#define respackopts_loaded");
|
||||
for (Map.Entry<String, ConfigBranch> e : CONFIG_BRANCH.entrySet()) {
|
||||
e.getValue().buildShader(sb, sanitizeString(e.getKey()));
|
||||
}
|
||||
sb.append("\n#endif");
|
||||
shaderImportSource = sb.toString();
|
||||
});
|
||||
DirFilterEventImpl.init();
|
||||
|
|
|
@ -10,6 +10,6 @@ import org.spongepowered.asm.mixin.injection.ModifyArg;
|
|||
public class GLImportProcessorMixin {
|
||||
@ModifyArg(method = "readSource(Ljava/lang/String;)Ljava/util/List;", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gl/GLImportProcessor;parseImports(Ljava/lang/String;Lnet/minecraft/client/gl/GLImportProcessor$Context;Ljava/lang/String;)Ljava/util/List;"), index = 0)
|
||||
private String modify(String value) {
|
||||
return value.replace("#include " + Respackopts.RPO_SHADER_ID, Respackopts.getShaderImportSource());
|
||||
return value.replace("\n//include " + Respackopts.RPO_SHADER_ID, "\n" + Respackopts.getShaderImportSource());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue