### Fabric Event Listener Setup Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Events.md This example shows how to set up a listener for Fabric-specific events, using FabricFreeNativeResourcesEvent. It implements the ClientModInitializer interface for client-side initialization. ```java import foundry.veil.fabric.event.FabricFreeNativeResourcesEvent; import net.fabricmc.api.ClientModInitializer; public class ModFabric implements ClientModInitializer { @Override public void onInitializeClient() { FabricFreeNativeResourcesEvent.EVENT.register(() -> { // listener here }); } } ``` -------------------------------- ### Full VertexArray Example with Custom Buffers and Attributes Source: https://github.com/foundrymc/veil/blob/1.21/wiki/VertexArray.md Demonstrates creating a VertexArray, managing multiple OpenGL buffers, uploading vertex and index data, defining custom vertex formats, and applying vanilla formats. This example covers advanced usage including custom buffer indices and attribute mapping. ```java VertexArray vertexArray = VertexArray.create(); // Arbitrary OpenGl buffers can be created int defaultVbo = vertexArray.getOrCreateBuffer(VertexArray.VERTEX_BUFFER); int extraVbo = vertexArray.getOrCreateBuffer(2); int vanillaVbo = vertexArray.getOrCreateBuffer(3); try (MemoryStack stack = MemoryStack.stackPush()) { ByteBuffer vertexData = stack.malloc(Float.BYTES * 5 * 4); // Put data in the buffer vertexData.asFloatBuffer().put(new float[]{ 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F, 0.0F, 1.0F, 0.0F, 1.0F, 0.0F, 0.0F, 0.0F, 1.0F }); // Upload the data into the buffer VertexArray.upload(defaultVbo, vertexData, VertexArray.DrawUsage.STATIC); // Upload some extra data to another buffer ByteBuffer extraData = stack.malloc(Integer.BYTES * 4); extraData.asIntBuffer().put(new int[]{0xFFFFFFFF, 0xFFFF0000, 0xFF00FF00, 0xFF0000FF}); VertexArray.upload(extraVbo, extraData, VertexArray.DrawUsage.STATIC); // Manually upload indices vertexArray.uploadIndexBuffer(stack.bytes( (byte) 0, (byte) 1, (byte) 2, (byte) 2, (byte) 3, (byte) 0 )); vertexArray.setIndexCount(6, VertexArray.IndexType.BYTE); vertexArray.setDrawMode(VertexFormat.Mode.TRIANGLES); // 1.2.0+ equivalent vertexArray.uploadIndexBuffer(stack.bytes( (byte) 0, (byte) 1, (byte) 2, (byte) 2, (byte) 3, (byte) 0 ), VertexArray.IndexType.BYTE); } // Set up vertex format VertexArrayBuilder builder = vertexArray.editFormat(); // 5 floats per vertex builder.defineVertexBuffer(0, defaultVbo, 0, Float.BYTES * 5, 0); // 1 integer per vertex builder.defineVertexBuffer(1, extraVbo, 0, Integer.BYTES, 0); // Position builder.setVertexAttribute(0, 0, 3, VertexArrayBuilder.DataType.FLOAT, false, 0); // UV builder.setVertexAttribute(1, 0, 2, VertexArrayBuilder.DataType.FLOAT, false, Float.BYTES * 3); // Color builder.setVertexAttribute(2, 1, 4, VertexArrayBuilder.DataType.UNSIGNED_BYTE, false, 0); // Defines the vertex data to be pulled from the specified buffer and how the vanilla attributes should be applied builder.applyFrom(3, vanillaVbo, 2, DefaultVertexFormat.PARTICLE); vertexArray.bind(); vertexArray.draw(); // You can also use a render type to draw vertexArray.drawWithRenderType(RenderType.solid()); // Frees the vertex array and all owned verted buffers vertexArray.free(); ``` -------------------------------- ### Resource Pack Structure Example Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Quasar.md This markdown illustrates the required folder structure for a resource pack intended for particle definitions. ```markdown resourcepacks \-particles |-pack.mcmeta \-assets \-modid \-quasar |-emitters |-modules |-render |-update |-init |-force |---collision \-particle_data \-emitter \-particle \-shape ``` -------------------------------- ### pack.mcmeta Example Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Quasar.md A basic pack.mcmeta file for a resource pack. Ensure the pack_format matches your Minecraft version. ```json { "pack": { "pack_format": 15, "description": "Resource pack for testing Quasar" } } ``` -------------------------------- ### Render Template Example Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Flare.md Demonstrates how to render a Veil effect template directly. Requires the template resource location, effect host, matrix stack, and partial tick. ```java public static void renderEffect(...) { ResourceLocation template = ...; EffectHost host = ...; MatrixStack matrixStack = ...; float partialTick = ...; try { FlareEffectManager.getTemplate(template).render(host, matrixStack, partialTick); } catch (Exception ignored) { } } ``` -------------------------------- ### Example Vertex Shader Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Shader.md A basic vertex shader that passes position and UV coordinates. Requires standard model-view and projection matrices. ```glsl layout(location = 0) in vec3 Position; layout(location = 1) in vec2 UV0; uniform mat4 ModelViewMat; uniform mat4 ProjMat; out vec2 texCoord0; void main() { gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0); texCoord0 = UV0; } ``` -------------------------------- ### GLSL Sampler Reference Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Framebuffer.md Example of how to reference a custom-named texture sampler in GLSL shaders, showing that both the default and custom names can be used. ```glsl // Both of these reference the same texture uniform sampler2D DiffuseSampler0; uniform sampler2D AlbedoSampler; ``` -------------------------------- ### Render Module Example Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Flare.md Demonstrates how to render a specific sub-module of a Veil module. Requires a module resource location, sub-module name, effect host, matrix stack, and partial tick. ```java public static void renderEffect(...) { ResourceLocation module = ...; String subModule = ...; EffectHost host = ...; MatrixStack matrixStack = ...; float partialTick = ...; try { FlareEffectManager.getModule(module).getSubModule(subModule).render(host, matrixStack, partialTick); } catch (Exception ignored) { } } ``` -------------------------------- ### Theme Property Examples Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Colors.md Illustrates how theme properties are declared and stored within the Color Theme system. Use getAndCastProperty to retrieve properties when the type is known. ```java Optional,Boolean Optional,Number Optional,String Optional,Consumer ``` ```java ConsumerThemeProperty consumerProp = (ConsumerThemeProperty) theme.getAndCastProperty("consumerProp"); ``` -------------------------------- ### Example Skeleton Class Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Necromancer.md Defines a custom Skeleton class by adding and structuring bones. Ensure buildRoots() is called after adding bones. ```java public class ExampleSkeleton extends Skeleton { protected final Bone Head, Body, LeftLeg, RightLeg; public ExampleSkeleton(ExampleEntity parent) { super(); this.Body = new Bone("Body"); this.Body.setInitialTransform(0F, 16F, 0F, new Quaternionf().rotationZYX(0F, 0F, 0F)); this.addBone(Body); this.Head = new Bone("Head"); this.Head.setInitialTransform(0F, 8F, 0F, new Quaternionf().rotationZYX(0F, 0F, 0F)); this.addBone(Head); this.LeftLeg = new Bone("LeftLeg"); this.LeftLeg.setInitialTransform(-8F, -8F, 0F, new Quaternionf().rotationZYX(1.5F, 0F, 0F)); this.addBone(LeftLeg); this.RightLeg = new Bone("RightLeg"); this.RightLeg.setInitialTransform(8F, 8F, 0F, new Quaternionf().rotationZYX(1.5F, 0F, 0F)); this.addBone(RightLeg); this.Body.addChild(Head); this.Body.addChild(RightLeg); this.Body.addChild(LeftLeg); this.buildRoots(); } } ``` -------------------------------- ### Veil Shader Include Example Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Shader.md Demonstrates how to include GLSL code from other files using the `#include` directive. This allows for code reuse across multiple shader programs and includes. Ensure there are no circular references between includes. ```glsl #include domain:includeid out vec4 fragColor; void main() { fragColor = vec4(1, 0, 1, 1); } ``` -------------------------------- ### Veil Double Include Example Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Shader.md Illustrates a scenario with two include files, where `bar.glsl` includes `foo.glsl`. This showcases how to build modular shader code by referencing other include files. The `#include` directive is used for this purpose. ```glsl #include veil:foo vec3 bar(vec4 color) { return foo(color) / 2.0; } ``` -------------------------------- ### Veil Foo Include Example Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Shader.md A simple GLSL include file that defines a function `foo`. This function takes a `vec4` color and returns its RGB components as a `vec3`. It is intended to be included by other shader files. ```glsl vec3 foo(vec4 color) { return color.rgb; } ``` -------------------------------- ### Java Code to Get and Use a Veil Render Type Source: https://github.com/foundrymc/veil/blob/1.21/wiki/CustomRenderType.md This Java code demonstrates how to retrieve a data-driven render type using `VeilRenderType.get` and then use it to obtain a `VertexConsumer` for rendering. Ensure `VeilRenderType#get` calls are within the render loop for dynamic updates. ```java import com.mojang.blaze3d.vertex.VertexConsumer; import foundry.veil.Veil; import foundry.veil.api.client.render.rendertype.VeilRenderType; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.resources.ResourceLocation; public class TestRenderer { private static final ResourceLocation RENDER_TYPE = ResourceLocation.fromNamespaceAndPath("examplemod", "test_rendertype"); public static void render(MultiBufferSource bufferSource) { RenderType renderType = VeilRenderType.get(RENDER_TYPE, "test_texture.png"); if (renderType == null) { // There was an error loading the render type return; } VertexConsumer builder = bufferSource.getBuffer(renderType); // do rendering code as usual } } ``` -------------------------------- ### Forge Event Listener Setup Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Events.md This snippet demonstrates how to register a listener for Forge-specific events, specifically ForgeFreeNativeResourcesEvent. It requires registering the class with the Forge event bus. ```java import foundry.veil.forge.event.ForgeFreeNativeResourcesEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @Mod("modid") public class ModForge { public ModForge() { MinecraftForge.EVENT_BUS.register(this); } @SubscribeEvent public void onEvent(ForgeFreeNativeResourcesEvent event) { // listener here } } ``` -------------------------------- ### Configure Shader Textures in JSON Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Shader.md Configure texture inputs for a shader program in a JSON file. This example binds a custom texture named 'CustomTexture' to the shader. ```json { "vertex": "example", "fragment": "example", "textures": { "CustomTexture": "veil:textures/gui/item_shadow.png" } } ``` -------------------------------- ### Example Animator Class Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Necromancer.md Custom Animator class that applies animations and directly manipulates bone transformations. Animations should be statically created and shared. ```java public class ExampleAnimator extends Animator { final AnimationEntry walk; public ExampleAnimator(ExampleEntity entity, ExampleSkeleton skeleton) { this.walk = this.addAnimation(WalkAnimation.INSTANCE, 0); } public void animate(ExampleEntity entity) { super.animate(entity); // walk WalkAnimation walkState = entity.walkAnimation; this.walk.setTime(walkState.position()); this.walk.setMixFactor(walkState.speed()); // idle skeleton.Body.y += Mth.sin(entity.tickCount * 0.05F) * 2; } static class WalkAnimation extends Animation { static final INSTANCE = new WalkAnimation(); public void apply(ExampleEntity entity, ExampleSkeleton skeleton, float blendFactor, float time) { skeleton.LeftLeg .rotateDeg(45 * Mth.sin(time) * blendFactor, Direction.Axis.Z); skeleton.RightLeg.rotateDeg(45 * -Mth.cos(time) * blendFactor, Direction.Axis.Z); } } } ``` -------------------------------- ### Set Custom Shader Uniforms Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Shader.md Example of setting custom shader uniforms in Java. Always check for nullability as uniforms may not exist. This code requires Veil and Mojang's Blaze3D libraries. ```java import com.mojang.blaze3d.vertex.PoseStack; import foundry.veil.Veil; import foundry.veil.api.client.render.VeilRenderSystem; import foundry.veil.api.client.render.shader.program.ShaderProgram; import foundry.veil.api.client.render.shader.uniform.ShaderUniformAccess; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.resources.ResourceLocation; import org.joml.Matrix4f; public class RenderClass { private static final ResourceLocation CUSTOM_SHADER = ResourceLocation.fromNamespaceAndPath(Veil.MODID, "test_shader"); public static void render(PoseStack stack, MultiBufferSource source, float partialTicks) { ShaderProgram shader = VeilRenderSystem.setShader(CUSTOM_SHADER); if (shader == null) { return; } ShaderUniformAccess customValue = shader.getUniform("CustomValue"); // Always check if the uniform for nullability // because it will be null if it doesn't exist if (customValue != null) { customValue.setFloat(32.2F); } ShaderUniformAccess customProjection = shader.getUniform("CustomProjection"); if (customProjection != null) { Matrix4f projection = new Matrix4f().ortho(0, 10, 10, 0, 0.3F, 100.0F, false); customProjection.setMatrix(projection); } shader.bind(); // rendering code here ShaderProgram.unbind(); } } ``` -------------------------------- ### Example Fragment Shader with Bindless Texture Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Shader.md A fragment shader that samples a texture using bindless texture access. Requires a uniform buffer for texture samplers and a texture index. ```glsl in vec2 texCoord0; layout(std140) uniform CustomTextures { sampler2D textures[128]; }; uniform uint TextureIndex; out vec4 Color; void main() { Color = texture(textures[TextureIndex], texCoord0); } ``` -------------------------------- ### Example Data-Driven Render Type JSON Source: https://github.com/foundrymc/veil/blob/1.21/wiki/CustomRenderType.md This JSON defines a custom render type with a texture, a Veil shader, depth testing, culling, and lightmap. It specifies the vertex format, rendering mode, and buffer size. ```json { "format": "POSITION_COLOR_TEX_LIGHTMAP", "mode": "QUADS", "bufferSize": "TRANSIENT", "sort": false, "affectsCrumbling": true, "outline": false, "layers": [ { "type": "minecraft:texture", "texture": "%1$s", "blur": true, "mipmap": false }, { "type": "veil:shader", "name": "veil:test_shader" }, { "type": "minecraft:depth_test", "mode": "always" }, { "type": "minecraft:cull" }, { "type": "minecraft:lightmap" }, { "type": "minecraft:write_mask", "color": true, "depth": false } ] } ``` -------------------------------- ### Define Shader Pre-Definitions in Java Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Shader.md Define pre-processor macros for shaders using Java code. This adds `#define EXAMPLE_DEFINITION` to shaders that depend on it, automatically recompiling them if the definition changes. ```java import foundry.veil.api.client.render.VeilRenderSystem; import foundry.veil.api.client.render.VeilRenderer; import foundry.veil.api.client.render.shader.ShaderPreDefinitions; import net.minecraft.resources.ResourceLocation; public class Foo { private static final ResourceLocation SHADER_ID = ResourceLocation.fromNamespaceAndPath("veil", "example"); // Some event fired before rendering public static void onPreRender() { VeilRenderer renderer = VeilRenderSystem.renderer(); ShaderPreDefinitions definitions = renderer.getShaderDefinitions(); // This adds #define EXAMPLE_DEFINITION to all shaders that depend on it definitions.set("example_definition"); } } ``` -------------------------------- ### Initialize and Upload Vertex Data Source: https://github.com/foundrymc/veil/blob/1.21/wiki/VertexArray.md Initializes a BufferBuilder, builds mesh data, uploads it to a VertexArray, and demonstrates basic rendering and cleanup. Ensure to bind the VertexArray before drawing and free it when no longer needed. ```java // This initializes the data BufferBuilder builder = RenderSystem.renderThreadTesselator().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); // Build mesh builder.addVertex(0, 0, 0).setColor(-1); builder.addVertex(0, 1, 0).setColor(-1); builder.addVertex(1, 1, 0).setColor(-1); builder.addVertex(1, 0, 0).setColor(-1); VertexArray vertexArray = VertexArray.create(); vertexArray.upload(builder.buildOrThrow(), VertexArray.DrawUsage.STATIC); // This goes inside a render loop { // Make sure to bind vertexArray.bind(); // Draw data vertexArray.drawWithRenderType(RenderType.debugQuads()); } // When not being used anymore, make sure to free it vertexArray.free(); ``` -------------------------------- ### Line Configuration Source: https://github.com/foundrymc/veil/blob/1.21/wiki/CustomRenderType.md Sets the width of lines when rendering. If not specified, the window scale is used. ```APIDOC ## Line ### Description Sets the width of lines when rendering. If `width` is not specified, the window scale is used instead. ### Method Not Applicable (Configuration Object) ### Endpoint Not Applicable (Configuration Object) ### Parameters #### Request Body - **width** (number) - Optional - The width of the lines. ### Request Example ```json { "type": "minecraft:line", "width": 4 } ``` ### Response #### Success Response (200) N/A (Configuration Object) #### Response Example N/A ``` -------------------------------- ### Create Path with Keyframes Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Animations.md Constructs a Path object with a list of Keyframes, specifying loop behavior and Bézier interpolation. Use this to define an animation timeline. ```java Path arcPath=new Path(List.of( new Keyframe(new Vec3(0.5,0.5,-0.5),Vec3.ZERO,Vec3.ZERO,20,Easings.Easing.linear), new Keyframe(new Vec3(0.5,0.5,-0.5),Vec3.ZERO,Vec3.ZERO,5,Easings.Easing.easeInQuad), new Keyframe(new Vec3(0.5,1.15,-0.5),Vec3.ZERO,Vec3.ZERO,10,Easings.Easing.easeInBounce), new Keyframe(new Vec3(0.5,1.2,-0.25),Vec3.ZERO,Vec3.ZERO,5,Easings.Easing.easeInBounce), new Keyframe(new Vec3(0.5,1.2,0.25),Vec3.ZERO,Vec3.ZERO,5,Easings.Easing.easeInBounce), new Keyframe(new Vec3(0.5,1.2,0.75),Vec3.ZERO,Vec3.ZERO,10,Easings.Easing.easeInBounce), // Loop, then Bézier ),false,true) ``` -------------------------------- ### Seamless Cubemap Configuration Source: https://github.com/foundrymc/veil/blob/1.21/wiki/CustomRenderType.md Globally enables OpenGL Seamless Cubemap Sampling. ```APIDOC ## Seamless Cubemap ### Description Globally enables OpenGL [Seamless Cubemap Sampling](https://wikis.khronos.org/opengl/Cubemap_Texture#Seamless_cubemap). This is not required when using a Veil Shader. Instead, this can be set as a [sampling parameter](Shader#texture-filters) per cubemap texture. ### Method Not Applicable (Configuration Object) ### Endpoint Not Applicable (Configuration Object) ### Parameters #### Request Body - **enabled** (boolean) - Optional - Whether to enable seamless cubemap sampling. Defaults to true. ### Request Example ```json { "type": "veil:seamless_cubemap", "enabled": true } ``` ### Response #### Success Response (200) N/A (Configuration Object) #### Response Example N/A ``` -------------------------------- ### Spawn Particle at Position (Java) Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Quasar.md Java method to spawn a particle system at a specific position. Includes error handling. ```java public static void spawnParticle(Vec3 position, ResourceLocation id){ try { ParticleSystemManager manager = VeilRenderSystem.renderer().getParticleManager(); ParticleEmitter emitter = manager.createEmitter(id); emitter.setPosition(position); manager.addParticleSystem(emitter); } catch (Exception ignored) { } } ``` -------------------------------- ### Line Width Configuration Source: https://github.com/foundrymc/veil/blob/1.21/wiki/CustomRenderType.md Sets the width of lines when rendering. If `width` is not specified, the window scale is used. ```json { "type": "minecraft:line", "width": 42 } ``` -------------------------------- ### Custom Sampler Names for Multiple Color Buffers Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Framebuffer.md Demonstrates assigning custom names to color buffer textures, allowing them to be referenced by these names as samplers in shaders. ```json { "depth": true, "color_buffers": [ { "name": "AlbedoSampler", "format": "RGBA8" }, { "name": "NormalSampler", "format": "RGB16F" }, { "name": "MaterialSampler", "format": "R16F" }, { "name": "EmissiveSampler", "format": "RGBA8" }, { "name": "VanillaLightSampler", "format": "RG8" } ] } ``` -------------------------------- ### Multisample Drawing Enable Configuration Source: https://github.com/foundrymc/veil/blob/1.21/wiki/CustomRenderType.md Enables OpenGL Multisample Drawing for anti-aliasing. This requires drawing into a framebuffer with a multi-sampled render buffer attachment. ```json { "type": "veil:multisample", "enabled": true } ``` -------------------------------- ### Import Veil Shader Buffer Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Shader.md Use this directive to include fields from a registered shader buffer. Specify an interface name for organized access to fields. ```glsl #veil:buffer veil:camera ``` ```glsl #veil:buffer veil:camera FooBar ``` -------------------------------- ### Multisample Configuration Source: https://github.com/foundrymc/veil/blob/1.21/wiki/CustomRenderType.md Enables or disables OpenGL Multisample Drawing for anti-aliasing. ```APIDOC ## Multisample ### Description Enables OpenGL [Multisample Drawing](https://learnopengl.com/Advanced-OpenGL/Anti-Aliasing). This only works if drawing into a framebuffer with a multi-sampled render buffer attachment (samples > 0). ### Method Not Applicable (Configuration Object) ### Endpoint Not Applicable (Configuration Object) ### Parameters #### Request Body - **enabled** (boolean) - Optional - Whether to enable multisample drawing. Defaults to true. ### Request Example ```json { "type": "veil:multisample", "enabled": true } ``` ### Response #### Success Response (200) N/A (Configuration Object) #### Response Example N/A ``` -------------------------------- ### Output Configuration Source: https://github.com/foundrymc/veil/blob/1.21/wiki/CustomRenderType.md Defines the target framebuffer for rendering the output of a render type. ```APIDOC ## Output ### Description The framebuffer to draw the result of this render into. The `framebuffer` field is the name of any transparency or created veil framebuffer. ### Method Not Applicable (Configuration Object) ### Endpoint Not Applicable (Configuration Object) ### Parameters #### Request Body - **framebuffer** (string) - Required - The name of the target framebuffer. ### Request Example ```json { "type": "minecraft:output", "framebuffer": "veil:main" } ``` ### Response #### Success Response (200) N/A (Configuration Object) #### Response Example N/A ``` -------------------------------- ### Depth Clamp Enable Configuration Source: https://github.com/foundrymc/veil/blob/1.21/wiki/CustomRenderType.md Enables OpenGL Depth Clamp, which prevents fragments from being clipped if they are outside the viewing frustum but within the depth range. ```json { "type": "veil:depth_clamp", "enabled": true } ``` -------------------------------- ### Depth Test Configuration Source: https://github.com/foundrymc/veil/blob/1.21/wiki/CustomRenderType.md Specifies the depth testing mode to determine fragment rendering order. The default mode is 'lequal'. ```json { "type": "minecraft:depth_test", "mode": "formatting_string" } ``` -------------------------------- ### Depth Clamp Configuration Source: https://github.com/foundrymc/veil/blob/1.21/wiki/CustomRenderType.md Enables or disables OpenGL Depth Clamp. ```APIDOC ## Depth Clamp ### Description Enables OpenGL [Depth Clamp](https://paroj.github.io/gltut/Positioning/Tut05%20Depth%20Clamping.html). ### Method Not Applicable (Configuration Object) ### Endpoint Not Applicable (Configuration Object) ### Parameters #### Request Body - **enabled** (boolean) - Optional - Whether to enable depth clamping. Defaults to true. ### Request Example ```json { "type": "veil:depth_clamp", "enabled": true } ``` ### Response #### Success Response (200) N/A (Configuration Object) #### Response Example N/A ``` -------------------------------- ### Initialize Common Event Listener Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Events.md This platform-independent code initializes a listener for the FreeNativeResourcesEvent using the Veil platform method. Ensure VeilEventPlatform is accessible. ```java import foundry.veil.event.FreeNativeResourcesEvent; import foundry.veil.platform.services.VeilEventPlatform; // This class is platform independent, so it uses the veil platform method public class ModCommon { public static void initCommon() { VeilEventPlatform.INSTANCE.onFreeNativeResources(() -> { // listener here }); } } ``` -------------------------------- ### Overlay Configuration Source: https://github.com/foundrymc/veil/blob/1.21/wiki/CustomRenderType.md Enables or disables the use of the overlay texture. ```APIDOC ## Overlay ### Description Enables/disables the overlay texture. By default, this layer enables the overlay. ### Method Not Applicable (Configuration Object) ### Endpoint Not Applicable (Configuration Object) ### Parameters #### Request Body - **enabled** (boolean) - Optional - Whether to enable the overlay. Defaults to true. ### Request Example ```json { "type": "minecraft:overlay", "enabled": true } ``` ### Response #### Success Response (200) N/A (Configuration Object) #### Response Example N/A ``` -------------------------------- ### Color Logic Configuration Source: https://github.com/foundrymc/veil/blob/1.21/wiki/CustomRenderType.md Enables OpenGL color logic with a specified operation, used for effects like inverted text selection. ```APIDOC ## Color Logic ### Description Enables OpenGL color logic with the specified operation. In Vanilla MC this is used for making the text selection in GUIs an inverted color (or_reverse). ### Method Not Applicable (Configuration Object) ### Endpoint Not Applicable (Configuration Object) ### Parameters #### Request Body - **operation** (string) - Required - The color logic operation. Valid operations: `and`, `and_inverted`, `and_reverse`, `clear`, `copy`, `copy_inverted`, `equiv`, `invert`, `nand`, `noop`, `nor`, `or`, `or_inverted`, `or_reverse`, `set`, `xor`. ### Request Example ```json { "type": "minecraft:color_logic", "operation": "xor" } ``` ### Response #### Success Response (200) N/A (Configuration Object) #### Response Example N/A ``` -------------------------------- ### Bind Texture Using Mojang's RenderSystem Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Shader.md Bind a texture using Mojang's RenderSystem, commonly used for UI elements or block atlases. The first argument is the texture unit. ```java import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.world.inventory.InventoryMenu; public class Foo { public void render() { RenderSystem.setShaderTexture(0, InventoryMenu.BLOCK_ATLAS); } } ``` -------------------------------- ### Depth Buffer Configuration (Attachment Definition) Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Framebuffer.md Provides detailed configuration for a depth buffer attachment, including its type, format, levels, filtering, and custom name. ```json { "depth": { "type": "texture", "format": "DEPTH_COMPONENT", "levels": 0, "linear": false, "name": "AwesomeDepthBuffer" } } ``` -------------------------------- ### Spawn Particle Attached to Entity (Java) Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Quasar.md Java method to spawn a particle system attached to an entity. Includes error handling to prevent crashes. ```java public static void spawnParticle(Entity entity, ResourceLocation id){ try { ParticleSystemManager manager = VeilRenderSystem.renderer().getParticleManager(); ParticleEmitter emitter = manager.createEmitter(id); emitter.setAttachedEntity(entity); manager.addParticleSystem(emitter); } catch (Exception ignored) { } } ``` -------------------------------- ### Patch Size Configuration Source: https://github.com/foundrymc/veil/blob/1.21/wiki/CustomRenderType.md Sets the per-vertex patch size when using tessellation shaders. ```json { "type": "veil:patches", "patchVertices": 4 } ``` -------------------------------- ### Model Definition Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Flare.md Defines a model with a shell reference, position, rotation, scale offsets, and materials. Properties like positionOffset are also available as model properties. ```json5 { //Required //Reference to a shell "path": "veil:cube", //Required //Position offset //Also added as a model property called "model::position" "positionOffset": [0, 0, 0], //Required //XYZ Rotation Offset in Degrees //Also added as a model property called "model::rotation" "rotationOffset": [0, 0, 0], //Required //Scale offset //Also added as a model property called "model::scale" "scaleOffset": [1, 1, 1], //Required //Single material OR array of materials "materials": { //... } } ``` -------------------------------- ### Lightmap Configuration Source: https://github.com/foundrymc/veil/blob/1.21/wiki/CustomRenderType.md Enables or disables the use of the lightmap texture. ```APIDOC ## Lightmap ### Description Enables/disables the lightmap texture. By default, this layer enables the lightmap. ### Method Not Applicable (Configuration Object) ### Endpoint Not Applicable (Configuration Object) ### Parameters #### Request Body - **enabled** (boolean) - Optional - Whether to enable the lightmap. Defaults to true. ### Request Example ```json { "type": "minecraft:lightmap", "enabled": true } ``` ### Response #### Success Response (200) N/A (Configuration Object) #### Response Example N/A ``` -------------------------------- ### Veil Blit Stage Configuration Source: https://github.com/foundrymc/veil/blob/1.21/wiki/PostProcessing.md Configures a blit stage, which draws a quad with a specified shader. Use this for basic rendering tasks within a post-pipeline. Ensure the 'out' parameter is set to 'veil:post' for the final stage. ```json { "type": "veil:blit", // Required "shader": "modid:shaderid", // Optional // The input scene is stored in veil:post "in": "modid:framebufferid", // Required // The framebuffer to draw into. It is generally good practice to draw into veil:post on the last stage "out": "modid:framebufferid", // Optional // Whether to clear the out buffer before drawing "clear": true } ``` -------------------------------- ### Color Logic Operation Configuration Source: https://github.com/foundrymc/veil/blob/1.21/wiki/CustomRenderType.md Enables OpenGL color logic with a specified operation. This is used in Vanilla MC for inverted text selection in GUIs. ```json { "type": "minecraft:color_logic", "operation": "formatting_string" } ``` -------------------------------- ### Layering Configuration Source: https://github.com/foundrymc/veil/blob/1.21/wiki/CustomRenderType.md Specifies the layering mode to prevent Z-fighting by adding offsets. ```APIDOC ## Layering ### Description Specifies the layering mode. This works by adding a small offset in view or polygon space to prevent Z-fighting in meshes. ### Method Not Applicable (Configuration Object) ### Endpoint Not Applicable (Configuration Object) ### Parameters #### Request Body - **mode** (string) - Optional - The layering mode. Valid modes: `none`, `polygon_offset` (default), `view_offset`. ### Request Example ```json { "type": "minecraft:layering", "mode": "polygon_offset" } ``` ### Response #### Success Response (200) N/A (Configuration Object) #### Response Example N/A ``` -------------------------------- ### Module Definition Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Flare.md Defines a module, which is the final form of effects, consisting of multiple sub-modules. Modules are files placed in 'flare/module/'. ```json5 { //Required "subModules": { //Sub module consisting of a single template "plume": "veil:plume", //Sub module consisting of one or more templates "splash": [ "veil:splash", "veil:plume" ] } } ``` -------------------------------- ### Depth-Test Configuration Source: https://github.com/foundrymc/veil/blob/1.21/wiki/CustomRenderType.md Configures the depth testing mode to determine how fragments are rendered over others. Supports various comparison functions. ```APIDOC ## Depth-Test ### Description The kind of depth testing to use. This determines how fragments are chosen to render over others. ### Method Not Applicable (Configuration Object) ### Endpoint Not Applicable (Configuration Object) ### Parameters #### Request Body - **mode** (string) - Required - The depth test mode. Valid modes: `never`, `less`, `equal`, `lequal` (default), `greater`, `notequal`, `gequal`, `always`. ### Request Example ```json { "type": "minecraft:depth_test", "mode": "lequal" } ``` ### Response #### Success Response (200) N/A (Configuration Object) #### Response Example N/A ``` -------------------------------- ### Texturing Configuration Source: https://github.com/foundrymc/veil/blob/1.21/wiki/CustomRenderType.md Sets the `TextureMatrix` in the shader to a scrolling UV coordinate for the vanilla enchantment glint effect. ```json { "type": "minecraft:texturing", "scale": 1 } ``` -------------------------------- ### Layering Mode Configuration Source: https://github.com/foundrymc/veil/blob/1.21/wiki/CustomRenderType.md Specifies the layering mode to prevent Z-fighting by adding a small offset. The default mode is 'polygon_offset'. ```json { "type": "minecraft:layering", "mode": "polygon_offset" } ``` -------------------------------- ### Simple Module Definition in JSON Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Quasar.md This is the simplest way to define a module for a particle. It specifies the module to be used, in this case, 'die_on_collision'. ```json { "module": "die_on_collision" } ``` -------------------------------- ### Patches Configuration Source: https://github.com/foundrymc/veil/blob/1.21/wiki/CustomRenderType.md Sets the per-vertex patch size when using tessellation shaders. ```APIDOC ## Patches ### Description Sets the per-vertex patch size when using tessellation shaders. ### Method Not Applicable (Configuration Object) ### Endpoint Not Applicable (Configuration Object) ### Parameters #### Request Body - **patchVertices** (number) - Required - The number of vertices per patch. ### Request Example ```json { "type": "veil:patches", "patchVertices": 3 } ``` ### Response #### Success Response (200) N/A (Configuration Object) #### Response Example N/A ``` -------------------------------- ### Vertex Shader with Dynamic Buffer Output Source: https://github.com/foundrymc/veil/blob/1.21/wiki/DynamicBuffer.md This GLSL vertex shader demonstrates how to conditionally output data to Veil's dynamic buffers using preprocessor directives and specific tags. Ensure the relevant buffer flags are defined before compilation. ```glsl #include veil:fog layout(location = 0) in vec3 Position; layout(location = 1) in vec2 UV0; layout(location = 2) in vec4 Color; layout(location = 3) in ivec2 UV2; #ifdef VEIL_NORMAL layout(location = 4) in vec3 Normal; #endif uniform sampler2D Sampler2; uniform mat4 ModelViewMat; uniform mat4 ProjMat; #ifdef VEIL_NORMAL uniform mat3 NormalMat; #endif out float vertexDistance; out vec2 texCoord0; out vec4 vertexColor; out vec4 lightmapColor; void main() { vec4 WorldPosition = ModelViewMat * vec4(Position, 1.0); gl_Position = ProjMat * WorldPosition; vertexDistance = length(WorldPosition.xyz); texCoord0 = UV0; #ifdef VEIL_LIGHT_UV // This comment here specifies what the shader should output to the light UV buffer // #veil:light_uv vec2 texCoord2 = vec2(UV2 / 256.0); #endif vertexColor = Color; lightmapColor = texelFetch(Sampler2, UV2 / 16, 0); #ifdef VEIL_NORMAL // #veil:normal vec3 normal = NormalMat * Normal; #endif } ``` -------------------------------- ### Vanilla Shader Layer Definition Source: https://github.com/foundrymc/veil/blob/1.21/wiki/CustomRenderType.md Specifies a vanilla Minecraft shader to be used. The `name` field should be the shader file name without the `minecraft` namespace. ```json { "type": "minecraft:shader", // Required "name": "formatting_string", } ``` -------------------------------- ### Depth Buffer Configuration (Boolean) Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Framebuffer.md A simple way to include a depth buffer in a framebuffer definition by setting the 'depth' property to true. ```json { "depth": true } ``` -------------------------------- ### Write Mask Configuration Source: https://github.com/foundrymc/veil/blob/1.21/wiki/CustomRenderType.md Sets flags to control drawing into the color and depth buffers. Both color and depth writing are enabled by default. ```json { "type": "minecraft:write_mask", "color": true, "depth": true } ``` -------------------------------- ### Seamless Cubemap Configuration Source: https://github.com/foundrymc/veil/blob/1.21/wiki/CustomRenderType.md Globally enables OpenGL Seamless Cubemap Sampling. This is not required when using a Veil Shader and can be set per cubemap texture as a sampling parameter. ```json { "type": "veil:seamless_cubemap", "enabled": true } ``` -------------------------------- ### Texturing Configuration Source: https://github.com/foundrymc/veil/blob/1.21/wiki/CustomRenderType.md Sets the `TextureMatrix` in the shader to a scrolling UV coordinate for the vanilla enchantment glint effect. ```APIDOC ## Texturing ### Description Sets the value of `TextureMatrix` in the shader to a scrolling UV coordinate for the vanilla enchantment glint effect. ### Method Not Applicable (Configuration Object) ### Endpoint Not Applicable (Configuration Object) ### Parameters #### Request Body - **scale** (number) - Required - The scaling factor for the UV coordinates. ### Request Example ```json { "type": "minecraft:texturing", "scale": 1 } ``` ### Response #### Success Response (200) N/A (Configuration Object) #### Response Example N/A ``` -------------------------------- ### Shader Feature Requirements Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Shader.md Specify required shader features to ensure GPU compatibility before compilation. This also enables necessary GLSL extensions. ```json5 { "required_features": [ "A list of enum constants found in ShaderFeature.java" ] } ``` ```json5 { "vertex": "veil:example", "fragment": "veil:example", "required_features": [ "BINDLESS_TEXTURE" ] } ``` -------------------------------- ### Define Fog Shader Program Source: https://github.com/foundrymc/veil/blob/1.21/wiki/PostProcessing.md This JSON defines the shader program for the fog effect, linking the vertex and fragment shaders. The vertex shader should typically be 'veil:blit_screen'. ```json5 { "vertex": "veil:blit_screen", // This should almost always be veil:blit_screen "fragment": "example:test_shader" } ``` -------------------------------- ### Access Built-in Uniform Blocks Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Shader.md Directives to import GLSL code for accessing built-in uniform blocks. Use the specified interface name to access fields. ```glsl #veil:buffer veil:camera VeilCamera ``` ```glsl #veil:buffer veil:gui_info VeilGuiInfo ``` -------------------------------- ### Veil Shader Modifier Directives Source: https://github.com/foundrymc/veil/blob/1.21/wiki/ShaderModification.md Illustrates the use of Veil's commands for injecting shader code. `[GET_ATTRIBUTE]` retrieves shader attributes, `[OUTPUT]` defines output variables, `[UNIFORM]` adds code to the uniforms block, and `[FUNCTION]` injects code into specific methods. ```text [GET_ATTRIBUTE 0] vec3 InPos; // test [GET_ATTRIBUTE 4] vec3 Nom; [OUTPUT] // Outputs are guaranteed to be unique out vec4 Test; out vec3 TestNormal; [UNIFORM] uniform sampler2D Sampler8; [FUNCTION main(0) HEAD] TestNormal = #Nom; Test = vec4(#InPos, 1.0); ``` -------------------------------- ### Veil Shader Modifier Syntax Source: https://github.com/foundrymc/veil/blob/1.21/wiki/ShaderModification.md Defines the basic structure and directives for a Veil shader modification file. Use `#version` to specify the minimum shader version and `#priority` to control loading order. `#include` imports other files, while `#replace` substitutes the entire target shader. ```text #version 330 // required #priority 1000 // default 1000 #include veil:camera // Test include // Replaces this with the defined shader // #replace veil:shader/test // Vertex Only [GET_ATTRIBUTE 0] vec3 InPos; // test [GET_ATTRIBUTE 4] vec3 Nom; [OUTPUT] // Outputs are guaranteed to be unique out vec4 Test; out vec3 TestNormal; [UNIFORM] uniform sampler2D Sampler8; [FUNCTION main(0) HEAD] TestNormal = #Nom; Test = vec4(#InPos, 1.0); ``` -------------------------------- ### Long-Form Framebuffer Definition Source: https://github.com/foundrymc/veil/blob/1.21/wiki/Framebuffer.md Use this format for custom framebuffer configurations with multiple color buffers and optional depth. Specify dimensions, auto-clear behavior, and detailed color buffer properties like type, format, levels, filtering, and custom sampler names. ```json { "width": "q.screen_width", "height": "q.screen_height", "autoClear": true, "color_buffers": [ { "type": "texture", "format": "RGBA8", "levels": 0, "linear": false, "name": "AwesomeColorBuffer" } ], "depth": ... } ``` -------------------------------- ### Veil Copy Stage Configuration Source: https://github.com/foundrymc/veil/blob/1.21/wiki/PostProcessing.md Configures a copy stage to transfer buffers between framebuffers without using a shader. Useful for duplicating or moving buffer contents. The 'color' and 'depth' parameters control which buffer types are copied. ```json { "type": "veil:copy", // Optional // The input scene is stored in veil:post "in": "modid:framebufferid", // Required // The framebuffer to draw into. It is generally good practice to draw into veil:post on the last stage "out": "modid:framebufferid", // Optional // Whether to copy color buffers "color": false, // Optional // Whether to copy depth buffers "depth": false, // Optional // Whether to use linear filtering if the out size does not equal the in size "linear": false } ```