Search in sources :

Example 1 with GlShader

use of me.jellysquid.mods.sodium.client.gl.shader.GlShader in project Iris by IrisShaders.

the class IrisChunkProgramOverrides method createFragmentShader.

private GlShader createFragmentShader(RenderDevice device, IrisTerrainPass pass, SodiumTerrainPipeline pipeline) {
    Optional<String> irisFragmentShader;
    if (pass == IrisTerrainPass.SHADOW) {
        irisFragmentShader = pipeline.getShadowFragmentShaderSource();
    } else if (pass == IrisTerrainPass.GBUFFER_SOLID) {
        irisFragmentShader = pipeline.getTerrainFragmentShaderSource();
    } else if (pass == IrisTerrainPass.GBUFFER_TRANSLUCENT) {
        irisFragmentShader = pipeline.getTranslucentFragmentShaderSource();
    } else {
        throw new IllegalArgumentException("Unknown pass type " + pass);
    }
    String source = irisFragmentShader.orElse(null);
    if (source == null) {
        return null;
    }
    return new GlShader(device, ShaderType.FRAGMENT, new ResourceLocation("iris", "sodium-terrain.fsh"), source, EMPTY_CONSTANTS);
}
Also used : GlShader(me.jellysquid.mods.sodium.client.gl.shader.GlShader) ResourceLocation(net.minecraft.resources.ResourceLocation)

Example 2 with GlShader

use of me.jellysquid.mods.sodium.client.gl.shader.GlShader in project Iris by IrisShaders.

the class IrisChunkProgramOverrides method createGeometryShader.

private GlShader createGeometryShader(RenderDevice device, IrisTerrainPass pass, SodiumTerrainPipeline pipeline) {
    Optional<String> irisGeometryShader;
    if (pass == IrisTerrainPass.SHADOW) {
        irisGeometryShader = pipeline.getShadowGeometryShaderSource();
    } else if (pass == IrisTerrainPass.GBUFFER_SOLID) {
        irisGeometryShader = pipeline.getTerrainGeometryShaderSource();
    } else if (pass == IrisTerrainPass.GBUFFER_TRANSLUCENT) {
        irisGeometryShader = pipeline.getTranslucentGeometryShaderSource();
    } else {
        throw new IllegalArgumentException("Unknown pass type " + pass);
    }
    String source = irisGeometryShader.orElse(null);
    if (source == null) {
        return null;
    }
    return new GlShader(device, IrisShaderTypes.GEOMETRY, new ResourceLocation("iris", "sodium-terrain.gsh"), source, EMPTY_CONSTANTS);
}
Also used : GlShader(me.jellysquid.mods.sodium.client.gl.shader.GlShader) ResourceLocation(net.minecraft.resources.ResourceLocation)

Example 3 with GlShader

use of me.jellysquid.mods.sodium.client.gl.shader.GlShader in project Iris by IrisShaders.

the class IrisChunkProgramOverrides method createVertexShader.

private GlShader createVertexShader(RenderDevice device, IrisTerrainPass pass, SodiumTerrainPipeline pipeline) {
    Optional<String> irisVertexShader;
    if (pass == IrisTerrainPass.SHADOW) {
        irisVertexShader = pipeline.getShadowVertexShaderSource();
    } else if (pass == IrisTerrainPass.GBUFFER_SOLID) {
        irisVertexShader = pipeline.getTerrainVertexShaderSource();
    } else if (pass == IrisTerrainPass.GBUFFER_TRANSLUCENT) {
        irisVertexShader = pipeline.getTranslucentVertexShaderSource();
    } else {
        throw new IllegalArgumentException("Unknown pass type " + pass);
    }
    String source = irisVertexShader.orElse(null);
    if (source == null) {
        return null;
    }
    return new GlShader(device, ShaderType.VERTEX, new ResourceLocation("iris", "sodium-terrain.vsh"), source, EMPTY_CONSTANTS);
}
Also used : GlShader(me.jellysquid.mods.sodium.client.gl.shader.GlShader) ResourceLocation(net.minecraft.resources.ResourceLocation)

Example 4 with GlShader

use of me.jellysquid.mods.sodium.client.gl.shader.GlShader in project Iris by IrisShaders.

the class IrisChunkProgramOverrides method createShader.

@Nullable
private ChunkProgram createShader(RenderDevice device, IrisTerrainPass pass, SodiumTerrainPipeline pipeline) {
    GlShader vertShader = createVertexShader(device, pass, pipeline);
    GlShader geomShader = createGeometryShader(device, pass, pipeline);
    GlShader fragShader = createFragmentShader(device, pass, pipeline);
    if (vertShader == null || fragShader == null) {
        if (vertShader != null) {
            vertShader.delete();
        }
        if (geomShader != null) {
            geomShader.delete();
        }
        if (fragShader != null) {
            fragShader.delete();
        }
        // TODO: Partial shader programs?
        return null;
    }
    try {
        GlProgram.Builder builder = GlProgram.builder(new ResourceLocation("sodium", "chunk_shader_for_" + pass.getName()));
        if (geomShader != null) {
            builder.attachShader(geomShader);
        }
        return builder.attachShader(vertShader).attachShader(fragShader).bindAttribute("a_Pos", ChunkShaderBindingPoints.POSITION).bindAttribute("a_Color", ChunkShaderBindingPoints.COLOR).bindAttribute("a_TexCoord", ChunkShaderBindingPoints.TEX_COORD).bindAttribute("a_LightCoord", ChunkShaderBindingPoints.LIGHT_COORD).bindAttribute("mc_Entity", IrisChunkShaderBindingPoints.BLOCK_ID).bindAttribute("mc_midTexCoord", IrisChunkShaderBindingPoints.MID_TEX_COORD).bindAttribute("at_tangent", IrisChunkShaderBindingPoints.TANGENT).bindAttribute("a_Normal", IrisChunkShaderBindingPoints.NORMAL).bindAttribute("d_ModelOffset", ChunkShaderBindingPoints.MODEL_OFFSET).build((program, name) -> {
            ProgramUniforms uniforms = pipeline.initUniforms(name);
            ProgramSamplers samplers;
            ProgramImages images;
            if (pass == IrisTerrainPass.SHADOW) {
                samplers = pipeline.initShadowSamplers(name);
                images = pipeline.initShadowImages(name);
            } else {
                samplers = pipeline.initTerrainSamplers(name);
                images = pipeline.initTerrainImages(name);
            }
            return new IrisChunkProgram(device, program, name, uniforms, samplers, images);
        });
    } finally {
        vertShader.delete();
        if (geomShader != null) {
            geomShader.delete();
        }
        fragShader.delete();
    }
}
Also used : GlShader(me.jellysquid.mods.sodium.client.gl.shader.GlShader) ResourceLocation(net.minecraft.resources.ResourceLocation) ProgramSamplers(net.coderbot.iris.gl.program.ProgramSamplers) ProgramImages(net.coderbot.iris.gl.program.ProgramImages) GlProgram(me.jellysquid.mods.sodium.client.gl.shader.GlProgram) ProgramUniforms(net.coderbot.iris.gl.program.ProgramUniforms) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

GlShader (me.jellysquid.mods.sodium.client.gl.shader.GlShader)4 ResourceLocation (net.minecraft.resources.ResourceLocation)4 GlProgram (me.jellysquid.mods.sodium.client.gl.shader.GlProgram)1 ProgramImages (net.coderbot.iris.gl.program.ProgramImages)1 ProgramSamplers (net.coderbot.iris.gl.program.ProgramSamplers)1 ProgramUniforms (net.coderbot.iris.gl.program.ProgramUniforms)1 Nullable (org.jetbrains.annotations.Nullable)1