Skip to content

Commit

Permalink
Make explicit the implicit
Browse files Browse the repository at this point in the history
- Add @apiNotes explaining that flywheel/ is prepended to each shader
  ResourceLocation's path
- Document all InstanceType fields
  • Loading branch information
Jozufozu committed Jan 7, 2025
1 parent a89756a commit b379be5
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

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();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

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();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

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();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@

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();
}

0 comments on commit b379be5

Please sign in to comment.