<commit_before>attribute vec4 vertex;
attribute vec3 color;
attribute vec2 texCoordinate;
uniform mat4 modelView;
uniform mat4 projection;
varying vec2 v_texCoord;
varying vec3 fColor;
varying vec4 eyePosition;
varying float radius;

void main()
{
  radius = abs(texCoordinate.x);
  fColor = color;
  v_texCoord = texCoordinate / radius;
  gl_Position = modelView * vertex;
  eyePosition = gl_Position;
  gl_Position.xy += texCoordinate;
  gl_Position = projection * gl_Position;
}
<commit_msg>Fix rendering artifact for partially-clipped spheres.<commit_after>attribute vec4 vertex;
attribute vec3 color;
attribute vec2 texCoordinate;
uniform mat4 modelView;
uniform mat4 projection;
varying vec2 v_texCoord;
varying vec3 fColor;
varying vec4 eyePosition;
varying float radius;

void main()
{
  radius = abs(texCoordinate.x);
  fColor = color;
  v_texCoord = texCoordinate / radius;
  gl_Position = modelView * vertex;
  eyePosition = gl_Position;

  // Test if the closest point on the sphere would be clipped.
  vec4 clipTestNear = eyePosition;
  clipTestNear.z += radius;
  clipTestNear = projection * clipTestNear;
  if (clipTestNear.z > -clipTestNear.w) {
    // If not, calculate clip coordinate
    gl_Position.xy += texCoordinate;
    gl_Position = projection * gl_Position;
  }
  else {
    // If so, invalidate the clip coordinate to ensure that it will be clipped.
    gl_Position.w = 0.0;
  }
}

{'fraction_non_alphanumeric': 0.07883522727272728, 'fraction_numerical': 0.013494318181818182, 'mean_word_length': 4.357414448669202, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, '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': '7130151', 'n_tokens_mistral': 461, 'n_tokens_neox': 442, 'n_words': 140}