-
Notifications
You must be signed in to change notification settings - Fork 30
Mod API Documentation
io.homo.superresolution.api
Core entry class: SuperResolutionAPI
-
EVENT_BUS: Unified event bus (based on NeoForged EventBus). -
getOriginMinecraftFrameBuffer(): Returns the original Minecraft render target. -
getMinecraftFrameBuffer(): Returns the current render target. -
getScreenWidth() / getScreenHeight(): Screen resolution. -
getRenderWidth() / getRenderHeight(): Actual render resolution. -
getCurrentAlgorithmDescription(): Description of the current algorithm. -
getCurrentAlgorithm(): Current algorithm instance. -
debugRenderdocCapture*()anddebugRenderdocTriggerCapture(): RenderDoc debug capture entry points.
SuperResolutionAPI.EVENT_BUS.addListener((LevelRenderStartEvent event) -> {
// your code here
});You are required to implement the following methods:
-
init(): Initialize algorithm resources (shaders, buffers, contexts, etc.). Called only once when the algorithm is created. -
dispatch(DispatchResource dispatchResource): Executed every frame. The default implementation writes intoresources; you may callsuper.dispatch(...)first. -
resize(int width, int height): Update internal resources when the resolution changes. Called whenever the resolution changes. -
destroy(): Release resources. Called when the game shuts down or the algorithm is unloaded. -
getOutputFrameBuffer(): Returns the output framebuffer.
Note
AlgorithmDescription.createNewInstance() automatically calls init(); ensure that a no-argument constructor is available.
Note
AlgorithmRegistry.isAlgorithmSupported(...) has caching semantics; consider cache invalidation if runtime capabilities change.
Optional overrides:
-
getJitterOffset(...): Returns the jitter offset (default0, 0; unit: pixels; range[-1.0, 1.0]). -
isSupportJitter(): Whether jitter is supported (defaultfalse). -
getQualityPresets(): Returns the list of available quality presets (default empty). -
isCustomUpscaleRatio(): Whether a custom upscale ratio is allowed (defaulttrue). -
getOutputTextureId(): Directly retrieves the output color texture ID (typically obtained from the output FBO).
InputResourceSet is a record that holds the set of input textures:
-
colorTextureβ Color texture -
depthTextureβ Depth texture -
motionVectorsTextureβ Motion vector texture. Format: RG16F, containing screen-space motion vectors (x: horizontal, y: vertical; range[-1.0, 1.0])
Access these in dispatch(...) via dispatchResource.resources().
QualityPreset describes an available quality tier:
-
upscaleRatio: Upscale multiplier. -
name: Display name (Component). -
codeName: Internal code name (must be unique across all algorithms).
This class uses a fluent setter design and can be constructed as follows:
QualityPreset preset = new QualityPreset()
.setCodeName("quality")
.setName(Component.literal("Quality"))
.setUpscaleRatio(1.5f);Describes a registerable algorithm.
-
briefName: Short name. -
codeName: Unique code name (used as the index key). -
displayName: Display name. -
requirement: Runtime environment requirements. -
extraResources: Additional resources (e.g. DLL files).
-
createNewInstance(): Creates a new algorithm instance via reflection and automatically callsinit(). -
getId(): Returns the internal random UUID.
-
registry(AlgorithmDescription<?>): Registers an algorithm. -
getAlgorithmMap(): Returns the current registry map. -
getDescriptionByID(String id): Looks up a description bycodeName. -
isAlgorithmSupported(AlgorithmDescription<?>): Checks and caches algorithm availability (based onRequirement.check()).
Note: The registry performs built-in algorithm registration during static initialization, after which
AlgorithmRegisterEventis fired. If you want to register a custom algorithm, listen to this event.
The following events can be subscribed to via SuperResolutionAPI.EVENT_BUS:
-
AlgorithmRegisterEvent: Fired after the algorithm registration process completes. Register custom algorithms here. -
AlgorithmDispatchEvent: Fired before algorithm execution. Provides:getAlgorithm()getDispatchResource()
-
AlgorithmDispatchFinishEvent: Fired after algorithm execution. Provides:getAlgorithm()-
getOutput()(output FBO)
-
AlgorithmResizeEvent: Fired when the screen resolution is updated and an algorithm instance exists. Provides:screenWidth / screenHeightrenderWidth / renderHeightgetAlgorithm()
-
LevelRenderStartEvent: Fired when world rendering begins. -
LevelRenderEndEvent: Fired when world rendering ends. -
ConfigChangedEvent: Fired when the configuration changes (avoid relying on this where possible).
Note
The exact trigger points of LevelRenderStart / LevelRenderEnd may be affected by capture mode.
Requirement is used to declare algorithm runtime prerequisites and supports fluent builder-style construction:
- OpenGL requirements:
glVersion(major, minor)glMajorVersion(...)glMinorVersion(...)requiredGlExtension("...")
- Vulkan requirements:
requireVulkan(true)vulkanVersion(major, minor, patch)requireVulkanDeviceExtension("...")
- Platform and environment:
addSupportedOS(...)developmentEnvironment(true / false)
- Custom conditions:
isTrue(Supplier<Boolean>)isFalse(Supplier<Boolean>)
Validation entry points:
-
check()returns aRequirement.Result. -
result.support()directly indicates whether all conditions are met. -
getMissingGlExtensions() / getMissingVkExtensions()can be used to report missing capabilities.
Note
AlgorithmRegistry.isAlgorithmSupported(...) has caching semantics; consider cache invalidation if runtime capabilities change.
Represents a single external resource (e.g. gugugaga.dll):
-
check(DirectoryEnsurer): Checks whether the resource already exists in the target directory. -
get(...): Downloads or copies the resource based on its source (local or remote).
Resource source ResourceSource:
-
Type.Local: Copy from a local path. -
Type.Remote: Download via HTTP.
Error codes ErrorCode:
-
NetworkErrorβ Network error -
FileNotFoundβ Resource not found -
PermissionDeniedβ Insufficient permissions -
Cancelledβ Cancelled by user -
UnknownErrorβ Unknown error
-
checkAll(directory): Checks for missing resources and returns the missing list. -
getAll(...): Batch-fetches resources (supportsasyncmulti-threading). -
cancelAll(): Cancels all ongoing downloads. -
resetCancelState() / isCancelled(): Cancel state management.
-
ResourcesProgressListenerβ Download progress callback -
ResourcesFinishListenerβ Download completion callback -
ResourcesErrorListenerβ Download error callback