<commit_before>uniform vec3 u_radiiAndDynamicAtmosphereColor;

const float G = 0.9;
const float ATMOSPHERE_THICKNESS = 111e3;
const vec2 HEIGHT_SCALE = vec2(10e3, 3.2e3); // (Rayleigh, Mie) scales.
const vec3 BETA_RAYLEIGH = vec3(5.8e-6, 13.5e-6, 33.1e-6); // Better constants from Precomputed Atmospheric Scattering (https://hal.inria.fr/inria-00288758/document)
const vec3 BETA_MIE = vec3(21e-6);
const vec3 INTENSITY = vec3(100.0);

/**
 * This function computes the colors contributed by Rayliegh and Mie scattering at a given position, as well as
 * the opacity for the scattering.
 *
 * @param {vec3} positionWC The world position at which to calculate the scattering colors.
 * @param {vec3} lightDirection The direction of the light to calculate the scattering from.
 * @param {vec3} rayleighColor The variable the rayleigh color will be written to.
 * @param {vec3} mieColor The variable the mie color will be written to.
 * @param {float} opacity The variable the opacity will be written to.
 * @glslFunction
 */
void computeAtmosphericScattering(
    vec3 positionWC,
    vec3 lightDirection,
    out vec3 rayleighColor,
    out vec3 mieColor,
    out float opacity
) {

    // Initialize the default scattering amounts to 0.
    rayleighColor = vec3(0.0);
    mieColor = vec3(0.0);
    opacity = 0.0;

    // Extract the ray sampling parameteres that affect the visual quality.
    const float primaryRaySteps = 16.0;
    const float lightRaySteps = 4.0;

    // Setup the radii for the inner and outer ring of the atmosphere.
    float ellipsoidRadiiDifference = u_radiiAndDynamicAtmosphereColor.x - u_radiiAndDynamicAtmosphereColor.y;
    float atmosphereInnerRadius = (length(czm_viewerPositionWC) - czm_eyeHeight) - ellipsoidRadiiDifference;
    float atmosphereOuterRadius = atmosphereInnerRadius + ATMOSPHERE_THICKNESS;

    // Setup the primary ray: from the camera position to the vertex position.
    vec3 cameraToPositionWC = positionWC - czm_viewerPositionWC;
    vec3 cameraToPositionWCDirection = normalize(cameraToPositionWC);
    czm_ray primaryRay = czm_ray(czm_viewerPositionWC, cameraToPositionWCDirection);

    vec3 origin = vec3(0.0);

    // Calculate intersection from the camera to the outer ring of the atmosphere.
    czm_raySegment primaryRayAtmosphereIntersect = czm_raySphereIntersectionInterval(primaryRay, origin, atmosphereOuterRadius);

    // Return empty colors if intersects with globe geometry, if globe is translucent and camera is inside atmosphere.
    #if defined(GLOBE_TRANSLUCENT)
        czm_raySegment primaryRayEarthIntersect = czm_raySphereIntersectionInterval(primaryRay, origin, atmosphereInnerRadius + ellipsoidRadiiDifference);
        if (primaryRayEarthIntersect.start > 0.0 && primaryRayEarthIntersect.stop > 0.0) {
            return;
        }
    #endif

    // Return empty colors if no intersection with the atmosphere geometry.
    if (primaryRayAtmosphereIntersect == czm_emptyRaySegment) {
        return;<commit_msg>Adds distance adjustment to sky atmosphere<commit_after>uniform vec3 u_radiiAndDynamicAtmosphereColor;

const float G = 0.9;
const float ATMOSPHERE_THICKNESS = 111e3;
const vec2 HEIGHT_SCALE = vec2(10e3, 3.2e3); // (Rayleigh, Mie) scales.
const vec3 BETA_RAYLEIGH = vec3(5.8e-6, 13.5e-6, 33.1e-6); // Better constants from Precomputed Atmospheric Scattering (https://hal.inria.fr/inria-00288758/document)
const vec3 BETA_MIE = vec3(21e-6);
const vec3 INTENSITY = vec3(100.0);

/**
 * This function computes the colors contributed by Rayliegh and Mie scattering at a given position, as well as
 * the opacity for the scattering.
 *
 * @param {vec3} positionWC The world position at which to calculate the scattering colors.
 * @param {vec3} lightDirection The direction of the light to calculate the scattering from.
 * @param {vec3} rayleighColor The variable the rayleigh color will be written to.
 * @param {vec3} mieColor The variable the mie color will be written to.
 * @param {float} opacity The variable the opacity will be written to.
 * @glslFunction
 */
void computeAtmosphericScattering(
    vec3 positionWC,
    vec3 lightDirection,
    out vec3 rayleighColor,
    out vec3 mieColor,
    out float opacity
) {

    // Initialize the default scattering amounts to 0.
    rayleighColor = vec3(0.0);
    mieColor = vec3(0.0);
    opacity = 0.0;

    // Extract the ray sampling parameteres that affect the visual quality.
    const float primaryRaySteps = 16.0;
    const float lightRaySteps = 4.0;

    // Adjust the radius of the sky atmosphere, so at far away distances, low LOD tiles don't show gaps.
    float distMin = u_radiiAndDynamicAtmosphereColor.x / 4.0;
    float distMax = u_radiiAndDynamicAtmosphereColor.x;
    float distAdjust = 10e3 * clamp((czm_eyeHeight - distMin) / (distMax - distMin), 0.2, 1.2);

    // Setup the radii for the inner and outer ring of the atmosphere.
    float ellipsoidRadiiDifference = (u_radiiAndDynamicAtmosphereColor.x - u_radiiAndDynamicAtmosphereColor.y) + distAdjust;
    float atmosphereInnerRadius = (length(czm_viewerPositionWC) - czm_eyeHeight) - ellipsoidRadiiDifference;
    float atmosphereOuterRadius = atmosphereInnerRadius + ATMOSPHERE_THICKNESS;

    // Setup the primary ray: from the camera position to the vertex position.
    vec3 cameraToPositionWC = positionWC - czm_viewerPositionWC;
    vec3 cameraToPositionWCDirection = normalize(cameraToPositionWC);
    czm_ray primaryRay = czm_ray(czm_viewerPositionWC, cameraToPositionWCDirection);

    vec3 origin = vec3(0.0);

    // Calculate intersection from the camera to the outer ring of the atmosphere.
    czm_raySegment primaryRayAtmosphereIntersect = czm_raySphereIntersectionInterval(primaryRay, origin, atmosphereOuterRadius);

    // Return empty colors if intersects with globe geometry, if globe is translucent and camera is inside atmosphere.
    #if defined(GLOBE_TRANSLUCENT)
        czm_raySegment primaryRayEarthIntersect = czm_raySphereIntersectionInterval(primaryRay, origin, atmosphereInnerRadius + ellipsoidRadiiDifference);
        if (primaryRayEarthIntersect.start > 0.0 && primaryRayEarthIntersect.stop > 0.0) {
            return;
        }
    #endif

    // Return empty colors if no intersection with the atmosphere geometry.
    if (primaryRayAtmosphereIntersect == czm_emptyRaySegment) {
        return;
{'fraction_non_alphanumeric': 0.0713835486920895, 'fraction_numerical': 0.02631578947368421, 'mean_word_length': 4.102090032154341, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4134628', 'n_tokens_mistral': 1984, 'n_tokens_neox': 1867, 'n_words': 609}