## Profiles
profile.POTATO = !VOLUMETRIC_LIGHTING CLOUD_TYPE:1 !SHADOW_MAPPING !SHADOW_COLOR !SHADOW_FILTER !SSAO !ROUGH_REFLECTIONS !PREVIOUS_FRAME !SSR !BLOOM !SHARPEN_FILTER ANTI_ALIASING:1
profile.LOW = profile.POTATO SHADOW_MAPPING SSR RAYTRACER_STEPS:20 RAYTRACER_BISTEPS:2 BLOOM shadowMapResolution:512 UNDERWATER_CAUSTICS:0
profile.MEDIUM = profile.LOW VOLUMETRIC_LIGHTING CLOUD_TYPE:2 SHADOW_COLOR SHADOW_FILTER SSAO PREVIOUS_FRAME ANTI_ALIASING:2 shadowMapResolution:1024 UNDERWATER_CAUSTICS:1
profile.HIGH = profile.MEDIUM ROUGH_REFLECTIONS RAYTRACER_STEPS:24 shadowMapResolution:2048
profile.ULTRA = profile.HIGH RAYTRACER_STEPS:28 SHARPEN_FILTER shadowMapResolution:4096 UNDERWATER_CAUSTICS:2

## Main shader settings screen
screen = \
    [DEBUG] <profile> \
    <empty> <empty> \
    [POST] [LIGHTING] \
    [ATMOSPHERICS] [WORLD] \
    [PBR] [CONFIGURATION]

    ## Debug Screen
    screen.DEBUG = COLOR_MODE NOISE_SPEED

    ## Post Screen
    screen.POST = \
        OUTLINES OUTLINE_BRIGHTNESS \
        OUTLINE_PIXEL_SIZE RETRO_FILTER \
        <empty> <empty> \
        ANTI_ALIASING SHARPEN_FILTER \
        [CAMERA] [TONEMAP]

        ## Camera Screen
        screen.CAMERA = \
            DOF DOF_STRENGTH \
            CHROMATIC_ABERRATION ABERRATION_PIXEL_SIZE \
            BLOOM BLOOM_STRENGTH \
            <empty> <empty> \
            LENS_FLARE LENS_FLARE_STRENGTH \
            VIGNETTE VIGNETTE_STRENGTH \
            MOTION_BLUR MOTION_BLUR_STRENGTH

        ## Tonemap Screen
        screen.TONEMAP = \
            CONTRAST SATURATION \
            WHITE_POINT SHOULDER_STRENGTH \
            <empty> <empty> \
            AUTO_EXPOSURE AUTO_EXPOSURE_SPEED \
            EXPOSURE MINIMUM_EXPOSURE \
            <empty> <empty> \
            TINT_R TINT_G \
            TINT_B

    ## Lighting Screen
    screen.LIGHTING = \
        SHADOW_MAPPING SHADOW_COLOR \
        BLOCK_ENTITY_SHADOWS ENTITY_SHADOWS \
        SHADOW_FILTER shadowMapResolution \
        shadowDistance sunPathRotation \
        <empty> <empty> [RAY_TRACING] \
        UNDERWATER_CAUSTICS SSAO \
        AMBIENT_LIGHTING

        ## Ray Tracing Screen
        screen.RAY_TRACING = \
            SSGI SSR \
            RAYTRACER_STEPS RAYTRACER_BISTEPS \
            <empty> <empty> \
            ROUGH_REFLECTIONS PREVIOUS_FRAME

    ## Atmospherics Screen
    screen.ATMOSPHERICS = \
        SUN_MOON_TYPE SUN_MOON_INTENSITY \
        <empty> <empty> \
        VOLUMETRIC_LIGHTING VOLUMETRIC_LIGHTING_STRENGTH \
        BORDER_FOG GROUND_FOG_STRENGTH \
        <empty> <empty> \
        [CLOUD_SETTINGS] SKYBOX_BRIGHTNESS

        ## Cloud Screen
        screen.CLOUD_SETTINGS = \
            CLOUD_TYPE DOUBLE_LAYERED_CLOUDS \
            DYNAMIC_CLOUDS FADE_SPEED \
            SECOND_CLOUD_HEIGHT <empty> \
            <empty> <empty> \
            VOLUMETRIC_CLOUD_STEPS VOLUMETRIC_CLOUD_DEPTH \
            SKYBOX_CLOUD_STEPS SKYBOX_CLOUD_DEPTH

    # World Screen
    screen.WORLD = \
        TERRAIN_ANIMATION WATER_ANIMATION \
        WEATHER_ANIMATION TIMELAPSE_MODE \
        <empty> <empty> \
        WIND_SPEED CURRENT_SPEED \
        WIND_FREQUENCY CURRENT_FREQUENCY \
        <empty> <empty> \
        WORLD_CURVATURE WORLD_CURVATURE_SIZE

    # PBR Screen
    screen.PBR = \
        PBR_MODE SPECULAR_HIGHLIGHTS \
        ENVIRONMENT_PBR SUBSURFACE_SCATTERING \
        EMISSIVE_INTENSITY NORMAL_STRENGTH \
        <empty> <empty> \
        [POM_SETTINGS] [IPBR_SETTINGS] \
        DIRECTIONAL_LIGHTMAPS DIRECTIONAL_LIGHTMAP_STRENGTH \
        SLOPE_NORMALS

        # POM Settings Screen
        screen.POM_SETTINGS = \
            PARALLAX_OCCLUSION PARALLAX_DEPTH \
            PARALLAX_STEPS <empty> \
            <empty> <empty> \
            PARALLAX_SHADOW PARALLAX_SHADOW_STEPS

        # iPBR Settings Screen
        screen.IPBR_SETTINGS = \
            [WATER_SETTINGS] [LAVA_SETTINGS] \
            [SCULK_SETTINGS] <empty> \
            <empty> <empty> \
            NORMAL_GENERATION NORMAL_GENERATION_RESOLUTION

            # Water Settings Screen
            screen.WATER_SETTINGS = \
                WATER_NOISE WATER_BRIGHTNESS \
                <empty> <empty> \
                WATER_NORMAL WATER_BLUR_SIZE \
                WATER_DEPTH_SIZE WATER_TILE_SIZE \
                <empty> <empty> \
                WATER_STYLIZE_ABSORPTION WATER_FOAM \
                WATER_FLAT

            # Lava Settings Screen
            screen.LAVA_SETTINGS = \
                LAVA_BRIGHTNESS LAVA_NOISE \
                LAVA_TILE_SIZE
            
            # Sculk Settings Screen
            screen.SCULK_SETTINGS = \
                SCULK_BRIGHTNESS SCULK_NOISE \
                SCULK_TILE_SIZE

    # Configuration Screen
    screen.CONFIGURATION = \
        [OVERWORLD_SETTINGS] [NETHER_SETTINGS] \
        [END_SETTINGS] <empty> \
        <empty> <empty> \
        [BLOCK_LIGHT_COLOR]

        # Overworld Settings Screen
        screen.OVERWORLD_SETTINGS = \
            [DAY_SETTINGS] [NIGHT_SETTINGS] \
            [TWILIGHT_SETTINGS] [FOG_SETTINGS0]

            # Day Settings Screen
            screen.DAY_SETTINGS = \
                LIGHT0_DR LIGHT0_DG \
                LIGHT0_DB LIGHT0_DI \
                <empty> <empty> \
                SKY0_DR SKY0_DG \
                SKY0_DB SKY0_DI

            # Night Settings Screen
            screen.NIGHT_SETTINGS = \
                LIGHT0_NR LIGHT0_NG \
                LIGHT0_NB LIGHT0_NI \
                <empty> <empty> \
                SKY0_NR SKY0_NG \
                SKY0_NB SKY0_NI

            # Twilight Settings Screen
            screen.TWILIGHT_SETTINGS = \
                LIGHT0_TR LIGHT0_TG \
                LIGHT0_TB LIGHT0_TI \
                <empty> <empty> \
                SKY0_TR SKY0_TG \
                SKY0_TB SKY0_TI

            # Fog Settings Screen
            screen.FOG_SETTINGS0 = \
                FOG0_VERTICAL_DENSITY_D FOG0_VERTICAL_DENSITY_N \
                FOG0_VERTICAL_DENSITY_T <empty> \
                <empty> <empty> \
                FOG0_TOTAL_DENSITY

        # Nether Settings Screen
        screen.NETHER_SETTINGS = \
            FOGn1_VERTICAL_DENSITY FOGn1_TOTAL_DENSITY \
            <empty> <empty> \
            WORLDn1_VANILLA_FOGCOLI

        # End Settings Screen
        screen.END_SETTINGS = \
            LIGHT1_CR LIGHT1_CG \
            LIGHT1_CB LIGHT1_CI \
            <empty> <empty> \
            SKY1_CR SKY1_CG \
            SKY1_CB SKY1_CI \
            <empty> <empty> \
            FOG1_VERTICAL_DENSITY FOG1_TOTAL_DENSITY

        # Overworld block light color Screen
        screen.BLOCK_LIGHT_COLOR = \
            BLOCKLIGHT_R BLOCKLIGHT_G \
            BLOCKLIGHT_B BLOCKLIGHT_I

## Sliders
sliders = \
    NOISE_SPEED \
    OUTLINE_BRIGHTNESS OUTLINE_PIXEL_SIZE \
    DOF_STRENGTH ABERRATION_PIXEL_SIZE BLOOM_STRENGTH LENS_FLARE_STRENGTH VIGNETTE_STRENGTH MOTION_BLUR_STRENGTH \
    CONTRAST SATURATION WHITE_POINT SHOULDER_STRENGTH AUTO_EXPOSURE_SPEED EXPOSURE MINIMUM_EXPOSURE TINT_R TINT_G TINT_B \
    shadowMapResolution shadowDistance sunPathRotation AMBIENT_LIGHTING \
    RAYTRACER_STEPS RAYTRACER_BISTEPS \
    SUN_MOON_INTENSITY VOLUMETRIC_LIGHTING_STRENGTH GROUND_FOG_STRENGTH SKYBOX_BRIGHTNESS \
    FADE_SPEED SECOND_CLOUD_HEIGHT VOLUMETRIC_CLOUD_STEPS VOLUMETRIC_CLOUD_DEPTH SKYBOX_CLOUD_STEPS SKYBOX_CLOUD_DEPTH \
    WIND_SPEED CURRENT_SPEED WIND_FREQUENCY CURRENT_FREQUENCY WORLD_CURVATURE_SIZE \
    NORMAL_GENERATION_RESOLUTION EMISSIVE_INTENSITY NORMAL_STRENGTH DIRECTIONAL_LIGHTMAP_STRENGTH \
    PARALLAX_DEPTH PARALLAX_STEPS PARALLAX_SHADOW_STEPS \
    WATER_BRIGHTNESS WATER_BLUR_SIZE WATER_DEPTH_SIZE WATER_TILE_SIZE \
    LAVA_BRIGHTNESS LAVA_TILE_SIZE \
    SCULK_BRIGHTNESS SCULK_TILE_SIZE \
    LIGHT0_DR LIGHT0_DG LIGHT0_DB LIGHT0_DI SKY0_DR SKY0_DG SKY0_DB SKY0_DI \
    LIGHT0_NR LIGHT0_NG LIGHT0_NB LIGHT0_NI SKY0_NR SKY0_NG SKY0_NB SKY0_NI \
    LIGHT0_TR LIGHT0_TG LIGHT0_TB LIGHT0_TI SKY0_TR SKY0_TG SKY0_TB SKY0_TI \
    FOG0_VERTICAL_DENSITY_D FOG0_VERTICAL_DENSITY_N FOG0_VERTICAL_DENSITY_T FOG0_TOTAL_DENSITY \
    FOGn1_VERTICAL_DENSITY FOGn1_TOTAL_DENSITY WORLDn1_VANILLA_FOGCOLI \
    LIGHT1_CR LIGHT1_CG LIGHT1_CB LIGHT1_CI SKY1_CR SKY1_CG SKY1_CB SKY1_CI FOG1_VERTICAL_DENSITY FOG1_TOTAL_DENSITY \
    BLOCKLIGHT_R BLOCKLIGHT_G BLOCKLIGHT_B BLOCKLIGHT_I

## Set shader settings
    vignette = false
    separateAo = true
    oldLighting = false
    underwaterOverlay = false

    rain.depth = false
    shadow.culling = true
    frustum.culling = true
    beacon.beam.depth = true

    ## Iris Exclusives
        sky = false
        stars = false

        occlusion.culling = true
        ## Makes sure particles are rendered after deferred
        particles.ordering = after
        ## NOTE: Despite having separateEntityDraws, gbuffers_entities_translucent and gbuffers_block_translucent is unused
        ## IMS made gbuffers_entities_translucent and gbuffers_block_translucent as a scam :C
        separateEntityDraws = true

    ## Mod Exclusives
        dhClouds = off
        dhShadow.enabled = false

    #if SUN_MOON_TYPE != 2
        sun = false
        moon = false
    #endif

    #ifndef BLOCK_ENTITY_SHADOWS
        shadowBlockEntities = false
    #endif

    ## TO DO: need to separate the 2 options
    #ifndef ENTITY_SHADOWS
        shadowEntities = false

        ## Iris Exclusives
            shadowPlayer = true
    #endif

## Blending settings
## These are set to maximize performance
    blend.gbuffers_basic = off
    blend.gbuffers_clouds = off
    blend.gbuffers_line = off
    blend.gbuffers_skybasic = off
    blend.gbuffers_terrain = off
    blend.shadow = off

    blend.gbuffers_armor_glint = ONE ONE ZERO ZERO
    blend.gbuffers_skytextured = ONE ONE ZERO ZERO
    blend.gbuffers_lightning = ONE ONE ZERO ZERO
    blend.gbuffers_spidereyes = ONE ONE ZERO ZERO

    ## Iris Exclusives
        blend.shadow_block = off
        blend.shadow_cutout = off
        blend.shadow_entities = off
        blend.shadow_lightning = off
        blend.shadow_solid = off
        blend.shadow_water = off

    ## Mod Exclusives (Note to self, the DH program parameters are utterly useless)
        blend.dh_generic = off
        blend.dh_terrain = off

        blend.physics_ocean_shadow = off

## Per-buffer blending settings
## These are set to maximize performance
    blend.gbuffers_block.colortex1 = off
    blend.gbuffers_block.colortex2 = off
    blend.gbuffers_block.colortex3 = off

    blend.gbuffers_entities.colortex1 = off
    blend.gbuffers_entities.colortex2 = off
    blend.gbuffers_entities.colortex3 = off

    blend.gbuffers_hand.colortex1 = off
    blend.gbuffers_hand.colortex2 = off
    blend.gbuffers_hand.colortex3 = off

    blend.gbuffers_water.colortex1 = off
    blend.gbuffers_water.colortex2 = off
    blend.gbuffers_water.colortex3 = off

    blend.gbuffers_textured.colortex3 = off

    ## Iris Exclusives
        blend.gbuffers_lightning.colortex3 = off

        blend.gbuffers_particles.colortex3 = off

    ## Mod Exclusives
        blend.dh_water.colortex1 = off
        blend.dh_water.colortex2 = off
        blend.dh_water.colortex3 = off

        blend.physics_ocean.colortex1 = off
        blend.physics_ocean.colortex2 = off
        blend.physics_ocean.colortex3 = off

## Disable alpha testing completely
    alphaTest.gbuffers_armor_glint = off
    alphaTest.gbuffers_basic = off
    alphaTest.gbuffers_beaconbeam = off
    alphaTest.gbuffers_block = off
    alphaTest.gbuffers_clouds = off
    alphaTest.gbuffers_damagedblock = off
    alphaTest.gbuffers_entities = off
    alphaTest.gbuffers_hand = off
    alphaTest.gbuffers_line = off
    alphaTest.gbuffers_skybasic = off
    alphaTest.gbuffers_skytextured = off
    alphaTest.gbuffers_spidereyes = off
    alphaTest.gbuffers_terrain = off
    alphaTest.gbuffers_textured = off
    alphaTest.gbuffers_water = off
    alphaTest.gbuffers_weather = off
    alphaTest.shadow = off

    ## Iris Exclusives
        alphaTest.gbuffers_lightning = off
        alphaTest.gbuffers_particles = off

        alphaTest.shadow_block = off
        alphaTest.shadow_cutout = off
        alphaTest.shadow_entities = off
        alphaTest.shadow_lightning = off
        alphaTest.shadow_solid = off
        alphaTest.shadow_water = off

    ## Mod Exclusives (Note to self, the DH program parameters are utterly useless)
        alphaTest.dh_generic = off
        alphaTest.dh_terrain = off
        alphaTest.dh_water = off

        alphaTest.physics_ocean = off
        alphaTest.physics_ocean_shadow = off

## gbuffers_beaconbeam and gbuffers_weather are excluded from this list
## Both programs will render as intended

## Custom textures
    texture.noise = textures/noise.png

    ## TO DO: Implement a custom cloud map for maximum optimization
    #if CLOUD_TYPE != 0
        texture.composite.colortex0 = textures/clouds.png
        texture.deferred.colortex0 = textures/clouds.png
    #endif

## Position uniforms
    uniform.vec3.camPosDelta = vec3(cameraPosition.x - previousCameraPosition.x, cameraPosition.y - previousCameraPosition.y, cameraPosition.z - previousCameraPosition.z)

## Mod Exclusives uniforms
    #ifdef DISTANT_HORIZONS
        uniform.float.borderFar = if(isEyeInWater == 0, dhRenderDistance, far)
    #else
        uniform.float.borderFar = far
    #endif

## Custom time uniforms
    ## Apparently using the macro conditional "else if" does not work here so I improvised
    #if TIMELAPSE_MODE == 2
        uniform.float.vertexFrameTime = smooth(worldTime / 24, 30)
        uniform.float.fragmentFrameTime = vertexFrameTime
    #endif

    #if TIMELAPSE_MODE == 1
        uniform.float.vertexFrameTime = frameTimeCounter
        uniform.float.fragmentFrameTime = smooth(worldTime / 24, 30)
    #endif

    #if TIMELAPSE_MODE == 0
        uniform.float.vertexFrameTime = frameTimeCounter
        uniform.float.fragmentFrameTime = frameTimeCounter
    #endif

## Custom day cycle uniforms
    #if TIMELAPSE_MODE != 0
        variable.float.newSunAngle = smooth(sunAngle, 30) * pi * 2
    #else
        variable.float.newSunAngle = sunAngle * pi * 2
    #endif

    uniform.float.celestialSinX = sin(newSunAngle)

    variable.float.absCelestialSinX = abs(celestialSinX)

    ## Rotation translation

    ## variable.vec3.rotationXT = vec3(1, 0, 0)
    ## variable.vec3.rotationYB = vec3(0, 1, 0)
    ## variable.vec3.rotationZN = vec3(0, 0, 1)

    ## Transposed rotation of shadowModelView matrix with rotation

    ## uniform.vec3.newShadowModelViewXT = vec3(shaddowModelView.0.0, shaddowModelView.0.1, shaddowModelView.0.2)
    ## uniform.vec3.newShadowModelViewXT = vec3(shaddowModelView.0.0 * rotationXT.x + shaddowModelView.1.0 * rotationYB.x + shaddowModelView.2.0 * rotationZN.x, shaddowModelView.0.0 * rotationXT.y + shaddowModelView.1.0 * rotationYB.y + shaddowModelView.2.0 * rotationZN.y, shaddowModelView.0.0 * rotationXT.z + shaddowModelView.1.0 * rotationYB.z + shaddowModelView.2.0 * rotationZN.z)

    ## uniform.vec3.newShadowModelViewYB = vec3(shaddowModelView.1.0, shaddowModelView.1.1, shaddowModelView.1.2)
    ## uniform.vec3.newShadowModelViewYB = vec3(shaddowModelView.0.1 * rotationXT.x + shaddowModelView.1.1 * rotationYB.x + shaddowModelView.2.1 * rotationZN.x, shaddowModelView.0.1 * rotationXT.y + shaddowModelView.1.1 * rotationYB.y + shaddowModelView.2.1 * rotationZN.y, shaddowModelView.0.1 * rotationXT.z + shaddowModelView.1.1 * rotationYB.z + shaddowModelView.2.1 * rotationZN.z)

    ## uniform.vec3.newShadowModelViewZN = vec3(shaddowModelView.2.0, shaddowModelView.2.1, shaddowModelView.2.2)
    ## uniform.vec3.newShadowModelViewZN = vec3(shaddowModelView.0.2 * rotationXT.x + shaddowModelView.1.2 * rotationYB.x + shaddowModelView.2.2 * rotationZN.x, shaddowModelView.0.2 * rotationXT.y + shaddowModelView.1.2 * rotationYB.y + shaddowModelView.2.2 * rotationZN.y, shaddowModelView.0.2 * rotationXT.z + shaddowModelView.1.2 * rotationYB.z + shaddowModelView.2.2 * rotationZN.z)

    ## Translation of shadowModelView matrix
    ## uniform.vec3.newShadowModelViewOffset = vec3(shaddowModelView.3.0, shaddowModelView.3.1, shaddowModelView.3.2)

    ## New shadow fade calculation
    uniform.float.shdFade = min(absCelestialSinX * pi * 2, 1)

    ## uniform.float.dayCycle = clamp(1 + celestialSinX, 0, 2)

    uniform.float.dayCycle = 1 + celestialSinX
    uniform.float.dayCycleAdjust = clamp(dayCycle - 0.5, 0, 1)

    uniform.float.twilightPhase = absCelestialSinX * absCelestialSinX * (3 - 2 * absCelestialSinX)

## Environment detection
    uniform.float.isPrecipitationRain = smooth(if(in(biome_precipitation, 1) && cameraPosition.y < 96, 1, 0), 15) * wetness

## Lightning flash calculation
    uniform.float.lightningFlash = lightningBoltPosition.w

## Frame Jitter Uniform
    uniform.int.frameMod = frameCounter % 8

    ## 0.125 * 1.61803399
    uniform.float.frameFract = frameMod * 0.20225425

## Other
    uniform.float.pixelWidth = 1 / viewWidth
    uniform.float.pixelHeight = 1 / viewHeight

    uniform.float.eyeSkylight = smooth(eyeBrightness.y / 240, 15)

    uniform.float.effectFactor = max(blindness, darknessFactor * 0.125 + darknessLightFactor)
    uniform.float.volumetricCloudFar = far * 8.0 * (1.0 - rainStrength * 0.5)

    ## uniform.float.maxResolution = max(viewWidth, viewHeight)
    ## uniform.float.minResolution = min(viewWidth, viewHeight)