Make explicit the implicit

- Add @apiNotes explaining that flywheel/ is prepended to each shader
  ResourceLocation's path
- Document all InstanceType fields
This commit is contained in:
Jozufozu 2025-01-06 22:03:43 -08:00
parent a89756a709
commit b379be57ae
5 changed files with 64 additions and 0 deletions

View file

@ -15,11 +15,48 @@ public interface InstanceType<I extends Instance> {
*/
I create(InstanceHandle handle);
/**
* The native memory layout of this instance type.
*
* <p>This layout determines what fields are made available to the instance type's shaders
* as well as determining how the fields are arranged in memory.
*
* @return The layout of this instance type.
*/
Layout layout();
/**
* The writer of this instance type.
*
* <p>The writer of an InstanceType is responsible for translating java instance objects
* into contiguous native memory. The instance writer must write to the given pointer
* according to the layout of this instance type.
*
* <p>It is undefined behavior to write outside the half closed range
* {@code [ptr, ptr + layout().byteSize())}.
*
* @return The writer for this instance type.
*/
InstanceWriter<I> writer();
/**
* <p>The vertex shader of an InstanceType is responsible for transforming vertices from mesh
* space to world space in whatever way the instance type requires.
*
* @return The vertex shader for this instance type.
* @apiNote {@code flywheel/} is implicitly prepended to the {@link ResourceLocation}'s path.
*/
ResourceLocation vertexShader();
/**
* The cull shader of this instance type.
*
* <p>The cull shader of an InstanceType is responsible for transforming bounding spheres from mesh
* space to world space, such that a mesh contained by the input bounding sphere and transformed
* by the vertex shader would be contained by the output bounding sphere.
*
* @return The cull shader for this instance type.
* @apiNote {@code flywheel/} is implicitly prepended to the {@link ResourceLocation}'s path.
*/
ResourceLocation cullShader();
}

View file

@ -2,6 +2,12 @@ package dev.engine_room.flywheel.api.material;
import net.minecraft.resources.ResourceLocation;
/**
* A shader that decides what colors should be discarded in the fragment shader.
*/
public interface CutoutShader {
/**
* @apiNote {@code flywheel/} is implicitly prepended to the {@link ResourceLocation}'s path.
*/
ResourceLocation source();
}

View file

@ -2,6 +2,12 @@ package dev.engine_room.flywheel.api.material;
import net.minecraft.resources.ResourceLocation;
/**
* A shader that controls the fog effect on a material.
*/
public interface FogShader {
/**
* @apiNote {@code flywheel/} is implicitly prepended to the {@link ResourceLocation}'s path.
*/
ResourceLocation source();
}

View file

@ -2,6 +2,12 @@ package dev.engine_room.flywheel.api.material;
import net.minecraft.resources.ResourceLocation;
/**
* A shader that controls the GPU-based light on a material.
*/
public interface LightShader {
/**
* @apiNote {@code flywheel/} is implicitly prepended to the {@link ResourceLocation}'s path.
*/
ResourceLocation source();
}

View file

@ -2,8 +2,17 @@ package dev.engine_room.flywheel.api.material;
import net.minecraft.resources.ResourceLocation;
/**
* A vertex and fragment shader pair that can be attached to a material.
*/
public interface MaterialShaders {
/**
* @apiNote {@code flywheel/} is implicitly prepended to the {@link ResourceLocation}'s path.
*/
ResourceLocation vertexSource();
/**
* @apiNote {@code flywheel/} is implicitly prepended to the {@link ResourceLocation}'s path.
*/
ResourceLocation fragmentSource();
}