HDRP shadows working properly in editor, but not in build

I’m currently having an issue where in the editor, the lighting from my directional light works just fine. However, when I build the game, it’s like the scene has a giant shadow casted over it. Here’s an image of what I’m talking about (top picture is in the editor, bottom is in the build)

If I disable shadow mapping in the build on the directional light, the lighting seems to be accurate and comparable to the first editor screenshot (but with no shadows of course)

I’m not sure if this is useful at all, but here’s the code I use at the start of my scene to initialize all of the props/post processing/lighting

public void UpdateProps()
        {
            //if (currentSceneSettings == null)
            //    return;

            currentShakeInstance?.Stop(0, true);
            currentShakeInstance = cameraShaker.Shake(shakePreset);
            postProcessVolume.sharedProfile.TryGet(out whiteBalance);
            postProcessVolume.sharedProfile.TryGet(out colorAdjustments);
            postProcessVolume.sharedProfile.TryGet(out hdriSky);
            postProcessVolume.sharedProfile.TryGet(out fog);
            postProcessVolume.sharedProfile.TryGet(out blur);
            postProcessVolume.sharedProfile.TryGet(out depthOfField);
            postProcessVolume.sharedProfile.TryGet(out visualEnvironment);
            retroVolume.sharedProfile.TryGet(out vignette);

            //Debug.LogWarning("White Balance " + whiteBalance != null);
            //Debug.LogWarning("Color adjustments " + colorAdjustments != null);
            //Debug.LogWarning("HDRI Sky " + hdriSky != null);
            //Debug.LogWarning("Fog " + fog != null);
            //Debug.LogWarning("Blur " + blur != null);
            //Debug.LogWarning("Depth of Field " + depthOfField != null);
            //Debug.LogWarning("Visual Environment " + visualEnvironment != null);
            //Debug.LogWarning("Vignette " + vignette != null);

            foreach (Material material in windMaterials1)
            {
                material.SetFloat("WindSpeedFloat1", currentSceneSettings.windSpeed);
                material.SetFloat("_WindStrength", currentSceneSettings.windStrength);
            }

            foreach (Material material in windMaterials2)
            {
                material.SetFloat("_Frequency", currentSceneSettings.windSpeed);
                material.SetFloat("_Amplitude", currentSceneSettings.windStrength);
            }

            foreach (VisualEffect vfx in leavesAndWindVFX)
            {
                vfx.enabled = currentSceneSettings.leafParticles;
            }

            foreach (VisualEffect vfx in fireflyVFX)
            {
                vfx.enabled = currentSceneSettings.fireflyParticles;
            }

            foreach (Light light in eiffelTowerLights)
            {
                light.enabled = currentSceneSettings.eiffelTowerLights;
            }

            rainVFX.enabled = currentSceneSettings.rainParticles;
            rainVFX.SetFloat("Spawn Rate", currentSceneSettings.rainSpawnRate);
            rainVFX.SetFloat("Brightness", currentSceneSettings.rainBrightness);

            if (lightningCoroutine != null)
                StopCoroutine(lightningCoroutine);
            lightningFlashTween?.Stop();
            lightningRenderer.forceRenderingOff = true;
            lightningRenderer.enabled = false;
            thunderSound.Stop();

            if (currentSceneSettings.lightning)
            {
                lightningCoroutine = StartCoroutine(LightningCoroutine());
            }

            puddles.transform.localPosition = new Vector3(puddles.transform.localPosition.x, Mathf.Lerp(2.38f, 2.52f, currentSceneSettings.puddleHeight), puddles.transform.localPosition.z);

            wallPieceMaterial.SetTexture("_Cubemap", currentSceneSettings.skybox);
            wallPieceMaterial.SetFloat("_IntensityDripLine", currentSceneSettings.wallWetness);
            wallPieceMaterial.SetFloat("_TrailDropSpeed", currentSceneSettings.wallWetnessSpeed);


            directionalLight.colorTemperature = currentSceneSettings.directionalLightTemperature;
            directionalLight.GetComponent<HDAdditionalLightData>().SetIntensity(currentSceneSettings.directionalLightIntensity, LightUnit.Lux);

            Debug.Log("Direction light intensity: " + directionalLight.GetComponent<HDAdditionalLightData>().intensity);

            whiteBalance.temperature.value = currentSceneSettings.postProcessTemperature;
            colorAdjustments.saturation.value = currentSceneSettings.postProcessSaturation;
            hdriSky.hdriSky.value = currentSceneSettings.skybox;
            hdriSky.scrollSpeed.value = currentSceneSettings.scrollSpeed;
            hdriSky.rotation.value = currentSceneSettings.rotation;
            hdriSky.skyIntensityMode.value = SkyIntensityMode.Multiplier;
            hdriSky.multiplier.value = currentSceneSettings.intensityMultiplier;
            fog.enabled.value = currentSceneSettings.fog;
            fog.baseHeight.value = currentSceneSettings.fogBaseHeight;
            fog.maxFogDistance.value = currentSceneSettings.fogMaxDistance;
            fog.maximumHeight.value = currentSceneSettings.fogMaxHeight;
            fog.meanFreePath.value = currentSceneSettings.fogAttenuationDistance;

            Debug.Log("HDRISky: " + hdriSky.hdriSky.value.name);
            Debug.Log("HDRISky Intensity Mode: " + hdriSky.skyIntensityMode.value);
            Debug.Log("HDRISky multiplier: " + hdriSky.multiplier.value);


            Debug.LogError("DIRECTION LIGHT ROTATION: " + directionalLight.transform.localEulerAngles);
            probe.RequestRenderNextUpdate();
            initialized = true;
            //Debug.LogError("Finished updating props");
        }

I’ve tried making sure the rotation of the directional light is correct in the build, using deferred rendering instead of forward, changing the light layer of the light, changing all the light parameters, and increasing the max distance for shadows in the shadow post process component. Only changing the max distance for shadows has had any effect, though it’s still quite broken. I’m kind of stuck now, so any help is greatly appreciated!

Just solved it. For anyone struggling with this in the future, I had a terrain layer with a hole in it above the tracks in the scene, but the hole was still casting shadows. I turned off shadow casting in the terrain settings and everything is fine now.