1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
package util.render
import com.mojang.blaze3d.pipeline.BlendFunction
import com.mojang.blaze3d.pipeline.RenderPipeline
import com.mojang.blaze3d.platform.DepthTestFunction
import com.mojang.blaze3d.vertex.VertexFormat.Mode
import java.util.function.Function
import net.minecraft.client.renderer.RenderPipelines
import com.mojang.blaze3d.shaders.UniformType
import net.minecraft.client.renderer.RenderType
import net.minecraft.client.renderer.RenderStateShard
import com.mojang.blaze3d.vertex.DefaultVertexFormat
import net.minecraft.resources.ResourceLocation
import net.minecraft.Util
import moe.nea.firmament.Firmament
object CustomRenderPipelines {
val GUI_TEXTURED_NO_DEPTH_TRIS =
RenderPipeline.builder(RenderPipelines.GUI_TEXTURED_SNIPPET)
.withVertexFormat(DefaultVertexFormat.POSITION_TEX_COLOR, Mode.TRIANGLES)
.withLocation(Firmament.identifier("gui_textured_overlay_tris"))
.withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST)
.withCull(false)
.withDepthWrite(false)
.build()
val OMNIPRESENT_LINES = RenderPipeline
.builder(RenderPipelines.LINES_SNIPPET)
.withLocation(Firmament.identifier("lines"))
.withDepthWrite(false)
.withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST)
.build()
val COLORED_OMNIPRESENT_QUADS =
RenderPipeline.builder(RenderPipelines.MATRICES_PROJECTION_SNIPPET)// TODO: split this up to support better transparent ordering.
.withLocation(Firmament.identifier("colored_omnipresent_quads"))
.withVertexShader("core/position_color")
.withFragmentShader("core/position_color")
.withVertexFormat(DefaultVertexFormat.POSITION_COLOR, Mode.QUADS)
.withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST)
.withCull(false)
.withDepthWrite(false)
.withBlend(BlendFunction.TRANSLUCENT)
.build()
val CIRCLE_FILTER_TRANSLUCENT_GUI_TRIS =
RenderPipeline.builder(RenderPipelines.GUI_TEXTURED_SNIPPET)
.withVertexFormat(DefaultVertexFormat.POSITION_TEX_COLOR, Mode.TRIANGLES)
.withLocation(Firmament.identifier("gui_textured_overlay_tris_circle"))
.withUniform("CutoutRadius", UniformType.UNIFORM_BUFFER)
.withFragmentShader(Firmament.identifier("circle_discard_color"))
// .withBlend(BlendFunction.TRANSLUCENT)
.build()
val PARALLAX_CAPE_SHADER =
RenderPipeline.builder(RenderPipelines.ENTITY_SNIPPET)
.withLocation(Firmament.identifier("parallax_cape"))
.withFragmentShader(Firmament.identifier("cape/parallax"))
.withSampler("Sampler0")
.withSampler("Sampler1")
.withSampler("Sampler3")
.withUniform("Animation", UniformType.UNIFORM_BUFFER)
.build()
}
object CustomRenderLayers {
inline fun memoizeTextured(crossinline func: (ResourceLocation) -> RenderType.CompositeRenderType) = memoize(func)
inline fun <T, R> memoize(crossinline func: (T) -> R): Function<T, R> {
return Util.memoize { it: T -> func(it) }
}
val GUI_TEXTURED_NO_DEPTH_TRIS = memoizeTextured { texture ->
RenderType.create(
"firmament_gui_textured_overlay_tris",
RenderType.TRANSIENT_BUFFER_SIZE,
CustomRenderPipelines.GUI_TEXTURED_NO_DEPTH_TRIS,
RenderType.CompositeState.builder().setTextureState(
RenderStateShard.TextureStateShard(texture, false)
)
.createCompositeState(false)
)
}
val LINES = RenderType.create(
"firmament_lines",
RenderType.TRANSIENT_BUFFER_SIZE,
CustomRenderPipelines.OMNIPRESENT_LINES,
RenderType.CompositeState.builder() // TODO: accept linewidth here
.createCompositeState(false)
)
val COLORED_QUADS = RenderType.create(
"firmament_quads",
RenderType.TRANSIENT_BUFFER_SIZE,
false, true,
CustomRenderPipelines.COLORED_OMNIPRESENT_QUADS,
RenderType.CompositeState.builder()
.setLightmapState(RenderStateShard.NO_LIGHTMAP)
.createCompositeState(false)
)
val TRANSLUCENT_CIRCLE_GUI =
RenderType.create(
"firmament_circle_gui",
RenderType.TRANSIENT_BUFFER_SIZE,
CustomRenderPipelines.CIRCLE_FILTER_TRANSLUCENT_GUI_TRIS,
RenderType.CompositeState.builder()
.createCompositeState(false)
)
}
|