Skip to content

Commit

Permalink
Progress on 1.21.2 port
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyrofab committed Dec 30, 2024
1 parent 7da1402 commit a5f2251
Show file tree
Hide file tree
Showing 23 changed files with 164 additions and 523 deletions.
24 changes: 23 additions & 1 deletion 1_21_2_model.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Minecraft Shader Loading
# Minecraft's new Shader system

## Shader Loading

`ShaderLoader` loads every file in the `shaders` directory
ending in `.json`, `.fsh`, `.vsh`, or `.glsl`
Expand Down Expand Up @@ -85,3 +87,23 @@ classDiagram
TextureSampler : +int width
TextureSampler : +int height
```

## Post-process effect rendering

Post effect rendering is now divided into two steps:
1. building a reusable frame graph
2. rendering the frame graph

### Building the frame graph

```mermaid
---
title: Frame Graph structure
---
classDiagram
Node <|-- ObjectNode
Node <|-- ResourceNode
ResourceNode "1" --* "*" FrameGraphBuilder
ObjectNode "1" --* "*" FrameGraphBuilder
FramePass "1" --* "*" FrameGraphBuilder
```
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ public interface ManagedFramebuffer {
*/
void clear();

void clear(boolean swallowErrors);

/**
* Gets a simple {@link RenderLayer} that is functionally identical to {@code baseLayer},
* but with a different {@link RenderPhase.Target} that binds this framebuffer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,23 +140,6 @@ public interface ManagedShaderEffect extends UniformFinder {
@API(status = EXPERIMENTAL, since = "1.4.0")
ManagedFramebuffer getTarget(String name);

/**
* Forwards to {@link #setupDynamicUniforms(int, Runnable)} with an index of 0
*
* @param dynamicSetBlock a block in which dynamic uniforms are set
*/
@API(status = EXPERIMENTAL, since = "1.0.0")
void setupDynamicUniforms(Runnable dynamicSetBlock);

/**
* Runs the given block while the shader at the given index is active
*
* @param index the shader index within the group
* @param dynamicSetBlock a block in which dynamic name uniforms are set
*/
@API(status = EXPERIMENTAL, since = "1.0.0")
void setupDynamicUniforms(int index, Runnable dynamicSetBlock);

/**
* Sets the value of a uniform declared in json
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@
@API(status = MAINTAINED)
public interface SamplerUniform {

/**
* Sets the value of a sampler uniform declared in json using the Opengl texture slot id (between 0 and 30).
* @param activeTexture the active texture id to be used by the sampler
* @see org.lwjgl.opengl.GL13#GL_TEXTURE0
*/
@API(status = MAINTAINED, since = "1.4.0")
void setDirect(int activeTexture);

/**
* Sets the value of a sampler uniform declared in json
*
Expand Down
239 changes: 0 additions & 239 deletions src/main/java/org/ladysnake/satin/api/util/ShaderPrograms.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public class CustomFormatFramebuffers {
* <p>Refer to {@link SimpleFramebuffer} for the list of parameters
*/
@API(status = API.Status.EXPERIMENTAL)
public static Framebuffer create(int width, int height, boolean useDepth, boolean getError, TextureFormat format) {
public static Framebuffer create(int width, int height, boolean useDepth, TextureFormat format) {
try {
FORMAT.set(format);
return new SimpleFramebuffer(width, height, useDepth, getError);
return new SimpleFramebuffer(width, height, useDepth);
} finally {
FORMAT.remove();
}
Expand Down
15 changes: 6 additions & 9 deletions src/main/java/org/ladysnake/satin/impl/FramebufferWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import net.minecraft.client.util.Window;
import org.ladysnake.satin.Satin;
import org.ladysnake.satin.api.managed.ManagedFramebuffer;
import org.ladysnake.satin.mixin.client.AccessiblePassesShaderEffect;

import javax.annotation.Nullable;

Expand All @@ -46,9 +47,10 @@ void findTarget(@Nullable PostEffectProcessor shaderEffect) {
if (shaderEffect == null) {
this.wrapped = null;
} else {
this.wrapped = shaderEffect.getSecondaryTarget(this.name);
// FIXME create the target instead and add it to a FramebufferSet
this.wrapped = null; ((AccessiblePassesShaderEffect) shaderEffect).getInternalTargets().get(this.name);
if (this.wrapped == null) {
Satin.LOGGER.warn("No target framebuffer found with name {} in shader {}", this.name, shaderEffect.getName());
Satin.LOGGER.warn("No target framebuffer found with name {} in shader", this.name);
}
}
}
Expand Down Expand Up @@ -86,19 +88,14 @@ public void draw() {
@Override
public void draw(int width, int height, boolean disableBlend) {
if (this.wrapped != null) {
this.wrapped.draw(width, height, disableBlend);
this.wrapped.draw(width, height);
}
}

@Override
public void clear() {
clear(MinecraftClient.IS_SYSTEM_MAC);
}

@Override
public void clear(boolean swallowErrors) {
if (this.wrapped != null) {
this.wrapped.clear(swallowErrors);
this.wrapped.clear();
}
}

Expand Down
Loading

0 comments on commit a5f2251

Please sign in to comment.