Bilinear interpolation for quad vertex data via geometry shader #12
No files matched your search
-4
@@ -57,10 +57,6 @@ public abstract class ShaderChunkRenderer implements ChunkRenderer {
|
||||
loadedShaders.add(ShaderLoader.loadShader(ShaderType.VERTEX,
|
||||
"sodium:" + path + ".vsh", constants));
|
||||
|
||||
if (options.pass().primitiveType().getDefines().contains("USE_GEOMETRY_SHADER")) {
|
||||
loadedShaders.add(ShaderLoader.loadShader(ShaderType.GEOM,"sodium:" + path + ".gsh", constants));
|
||||
}
|
||||
|
||||
loadedShaders.add(ShaderLoader.loadShader(ShaderType.FRAGMENT,
|
||||
"sodium:" + path + ".fsh", constants));
|
||||
|
||||
|
||||
+6
-8
@@ -7,10 +7,15 @@ import org.lwjgl.system.MemoryUtil;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
|
||||
public final class QuadPrimitiveType implements ChunkPrimitiveType {
|
||||
/**
|
||||
* Generates index buffers that decompose quads into two triangles (suitable for core profile rendering).
|
||||
*/
|
||||
public static final QuadPrimitiveType TRIANGULATED = new QuadPrimitiveType(true);
|
||||
/**
|
||||
* Generates index buffers suited for working with quad(-like) primitives directly.
|
||||
*/
|
||||
public static final QuadPrimitiveType DIRECT = new QuadPrimitiveType(false);
|
||||
|
||||
private final boolean triangulating;
|
||||
@@ -28,13 +33,6 @@ public final class QuadPrimitiveType implements ChunkPrimitiveType {
|
||||
return triangulating ? 6 : 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getDefines() {
|
||||
// TODO this technically prevents the primitive type from being used without the geometry shader
|
||||
// This shouldn't be an issue on most modern platforms as GL_QUADS is not supported in core profile.
|
||||
return !triangulating ? List.of("USE_GEOMETRY_SHADER") : List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVerticesPerPrimitive() {
|
||||
return VERTICES_PER_PRIMITIVE;
|
||||
|
||||
@@ -2,18 +2,9 @@
|
||||
|
||||
#import <sodium:include/fog.glsl>
|
||||
|
||||
#ifdef USE_GEOMETRY_SHADER
|
||||
in GS_OUT
|
||||
#else
|
||||
in VS_OUT
|
||||
#endif
|
||||
{
|
||||
#ifdef USE_GEOMETRY_SHADER
|
||||
vec2 v_QuadEdge;
|
||||
flat vec4 v_Color[4];
|
||||
#else
|
||||
vec4 v_Color;
|
||||
#endif
|
||||
vec2 v_TexCoord;
|
||||
|
||||
float v_MaterialMipBias;
|
||||
@@ -50,14 +41,7 @@ void main() {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_GEOMETRY_SHADER
|
||||
vec4 c1 = mix(fs_in.v_Color[0], fs_in.v_Color[1], fs_in.v_QuadEdge.x);
|
||||
vec4 c2 = mix(fs_in.v_Color[2], fs_in.v_Color[3], fs_in.v_QuadEdge.x);
|
||||
|
||||
vec4 m_color = mix(c1, c2, fs_in.v_QuadEdge.y);
|
||||
#else
|
||||
vec4 m_color = fs_in.v_Color;
|
||||
#endif
|
||||
|
||||
#ifdef USE_VANILLA_COLOR_FORMAT
|
||||
// Apply per-vertex color. AO shade is applied ahead of time on the CPU.
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
#version 330 core
|
||||
|
||||
layout (lines_adjacency) in;
|
||||
layout (triangle_strip, max_vertices = 4) out;
|
||||
|
||||
in VS_OUT
|
||||
{
|
||||
vec4 v_Color;// The interpolated vertex color
|
||||
vec2 v_TexCoord;// The interpolated block texture coordinates
|
||||
|
||||
float v_MaterialMipBias;
|
||||
#ifdef USE_FRAGMENT_DISCARD
|
||||
float v_MaterialAlphaCutoff;
|
||||
#endif
|
||||
|
||||
#ifdef USE_FOG
|
||||
float v_FragDistance;// The fragment's distance from the camera
|
||||
#endif
|
||||
} gs_in[4];
|
||||
|
||||
out GS_OUT
|
||||
{
|
||||
vec2 v_QuadEdge;
|
||||
flat vec4 v_Color[4];
|
||||
vec2 v_TexCoord;
|
||||
|
||||
float v_MaterialMipBias;
|
||||
#ifdef USE_FRAGMENT_DISCARD
|
||||
float v_MaterialAlphaCutoff;
|
||||
#endif
|
||||
|
||||
#ifdef USE_FOG
|
||||
float v_FragDistance;// The fragment's distance from the camera
|
||||
#endif
|
||||
} gs_out;
|
||||
|
||||
void setVertex(in int i, in vec2 edge) {
|
||||
gl_Position = gl_in[i].gl_Position;
|
||||
|
||||
gs_out.v_QuadEdge = edge;
|
||||
|
||||
gs_out.v_TexCoord = gs_in[i].v_TexCoord;
|
||||
|
||||
gs_out.v_MaterialMipBias = gs_in[i].v_MaterialMipBias;
|
||||
|
||||
#ifdef USE_FRAGMENT_DISCARD
|
||||
gs_out.v_MaterialAlphaCutoff = gs_in[i].v_MaterialAlphaCutoff;
|
||||
#endif
|
||||
|
||||
#ifdef USE_FOG
|
||||
gs_out.v_FragDistance = gs_in[i].v_FragDistance;
|
||||
#endif
|
||||
}
|
||||
|
||||
void main() {
|
||||
// Set the colors once for the entire primitive
|
||||
gs_out.v_Color[0] = gs_in[0].v_Color;
|
||||
gs_out.v_Color[1] = gs_in[3].v_Color;
|
||||
gs_out.v_Color[2] = gs_in[1].v_Color;
|
||||
gs_out.v_Color[3] = gs_in[2].v_Color;
|
||||
|
||||
// Define the triangle strip as: ABDC
|
||||
setVertex(0, vec2(0.0, 0.0));
|
||||
EmitVertex();
|
||||
setVertex(1, vec2(0.0, 1.0));
|
||||
EmitVertex();
|
||||
setVertex(3, vec2(1.0, 0.0));
|
||||
EmitVertex();
|
||||
setVertex(2, vec2(1.0, 1.0));
|
||||
EmitVertex();
|
||||
|
||||
EndPrimitive();
|
||||
}
|
||||
+1
-7
@@ -14,12 +14,6 @@ import org.lwjgl.opengl.GL11;
|
||||
import java.util.Map;
|
||||
|
||||
public class ArchaicRenderPassConfigurationBuilder {
|
||||
/**
|
||||
* The use of {@link QuadPrimitiveType#DIRECT} instead of {@link QuadPrimitiveType#TRIANGULATED} may have a performance impact.
|
||||
* <p>
|
||||
* This is part of the "Enhanced Interpolation" and should be behind a config toggle.
|
||||
*/
|
||||
private static final QuadPrimitiveType PRIMITIVE_TYPE = QuadPrimitiveType.DIRECT;
|
||||
|
||||
public static final TerrainRenderPass SOLID_PASS, CUTOUT_MIPPED_PASS, TRANSLUCENT_PASS;
|
||||
public static final Material SOLID_MATERIAL, CUTOUT_MIPPED_MATERIAL, TRANSLUCENT_MATERIAL;
|
||||
@@ -45,7 +39,7 @@ public class ArchaicRenderPassConfigurationBuilder {
|
||||
}
|
||||
|
||||
private static TerrainRenderPass.TerrainRenderPassBuilder builderForRenderType(int pass, boolean disableBlend) {
|
||||
return TerrainRenderPass.builder().pipelineState(new ArchaicPipelineState(pass, disableBlend)).vertexType(ChunkMeshFormats.VANILLA_LIKE).primitiveType(PRIMITIVE_TYPE);
|
||||
return TerrainRenderPass.builder().pipelineState(new ArchaicPipelineState(pass, disableBlend)).vertexType(ChunkMeshFormats.VANILLA_LIKE).primitiveType(QuadPrimitiveType.TRIANGULATED);
|
||||
}
|
||||
|
||||
static {
|
||||
|
||||
-1
@@ -64,7 +64,6 @@ public final class StandardOptions {
|
||||
public static final ResourceLocation CPU_FRAMES_AHEAD = ResourceLocationUtil.make(Celeritas.MODID, "cpu_render_ahead_limit");
|
||||
public static final ResourceLocation TRANSLUCENT_FACE_SORTING = ResourceLocationUtil.make(Celeritas.MODID, "translucent_face_sorting");
|
||||
public static final ResourceLocation USE_QUAD_NORMALS_FOR_LIGHTING = ResourceLocationUtil.make(Celeritas.MODID, "use_quad_normals_for_lighting");
|
||||
public static final ResourceLocation USE_ENHANCED_INTERPOLATION = ResourceLocationUtil.make(Celeritas.MODID, "use_enhanced_interpolation");
|
||||
public static final ResourceLocation RENDER_PASS_OPTIMIZATION = ResourceLocationUtil.make(Celeritas.MODID, "render_pass_optimization");
|
||||
public static final ResourceLocation RENDER_PASS_CONSOLIDATION = ResourceLocationUtil.make(Celeritas.MODID, "render_pass_consolidation");
|
||||
public static final ResourceLocation USE_FASTER_CLOUDS = ResourceLocationUtil.make(Celeritas.MODID, "use_faster_clouds");
|
||||
|
||||
@@ -358,15 +358,6 @@ public class SodiumGameOptionPages {
|
||||
.setEnabled(!ForgeConfig.CLIENT.experimentalForgeLightPipelineEnabled.get())
|
||||
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||
.build())
|
||||
.add(OptionImpl.createBuilder(boolean.class, sodiumOpts)
|
||||
.setId(StandardOptions.Option.USE_ENHANCED_INTERPOLATION)
|
||||
.setControl(TickBoxControl::new)
|
||||
.setImpact(OptionImpact.HIGH)
|
||||
.setBinding((opts, value) -> opts.quality.useEnhancedInterpolation = value, opts -> opts.quality.useEnhancedInterpolation)
|
||||
.setName(ComponentUtil.translatable("celeritas.options.use_enhanced_interpolation.name"))
|
||||
.setTooltip(ComponentUtil.translatable("celeritas.options.use_enhanced_interpolation.tooltip"))
|
||||
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||
.build())
|
||||
.build());
|
||||
|
||||
return new OptionPage(ComponentUtil.translatable("sodium.options.pages.quality"), ImmutableList.copyOf(groups));
|
||||
|
||||
@@ -80,8 +80,6 @@ public class SodiumGameOptions {
|
||||
|
||||
@SerializedName("use_quad_normals_for_shading_v2")
|
||||
public boolean useQuadNormalsForShading = true;
|
||||
|
||||
public boolean useEnhancedInterpolation = false;
|
||||
}
|
||||
|
||||
public static class NotificationSettings {
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ public class ModernRenderPassConfigurationBuilder {
|
||||
}
|
||||
|
||||
private static TerrainRenderPass.TerrainRenderPassBuilder builderForRenderType(RenderType chunkRenderType, ChunkVertexType vertexType) {
|
||||
return TerrainRenderPass.builder().pipelineState(new ModernRenderTypePipelineState(chunkRenderType)).vertexType(vertexType).primitiveType(Celeritas.options().quality.useEnhancedInterpolation ? QuadPrimitiveType.DIRECT : QuadPrimitiveType.TRIANGULATED);
|
||||
return TerrainRenderPass.builder().pipelineState(new ModernRenderTypePipelineState(chunkRenderType)).vertexType(vertexType).primitiveType(QuadPrimitiveType.TRIANGULATED);
|
||||
}
|
||||
|
||||
public static RenderPassConfiguration<RenderType> build(ChunkVertexType vertexType) {
|
||||
|
||||
@@ -14,7 +14,5 @@
|
||||
"embeddium.options.use_faster_clouds.name": "Use Faster Clouds",
|
||||
"embeddium.options.use_faster_clouds.tooltip": "When enabled, Celeritas replaces vanilla cloud rendering with a less glitchy and potentially faster implementation. Disable this if mods' cloud customizations aren't visible.",
|
||||
"celeritas.options.async_graph_search.name": "Async Occlusion Culling",
|
||||
"celeritas.options.async_graph_search.tooltip": "Performs occlusion/frustum culling asynchronously, up to one frame behind the current camera position. This can improve frametimes, particularly at higher render distances, but at the cost of chunks popping into view if the camera is turned too aggressively.",
|
||||
"celeritas.options.use_enhanced_interpolation.name": "Use Enhanced Interpolation",
|
||||
"celeritas.options.use_enhanced_interpolation.tooltip": "Uses custom shader-based bilinear interpolation to render block faces rather than the GPU's default interpolation. This can noticeably improve the quality of ambient occlusion shadows, but currently has a sizeable impact on performance, and may have compatibility issues with some drivers."
|
||||
"celeritas.options.async_graph_search.tooltip": "Performs occlusion/frustum culling asynchronously, up to one frame behind the current camera position. This can improve frametimes, particularly at higher render distances, but at the cost of chunks popping into view if the camera is turned too aggressively."
|
||||
}
|
||||
Reference in new issue
Block a user