<commit_before>module microtome.three_d {

  /**
    * Properly encoding 32 bit float in rgba from here:
    * http://www.gamedev.net/topic/486847-encoding-16-and-32-bit-floating-point-value-into-rgba-byte-texture/
    */
  export class CoreMaterialsFactory {
    private static _basicVertex = `
void main(void) {
   // compute position
   gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}`;

    private static _depthShaderFrag = `
vec4 pack( const in float depth ) {
    const float toFixed = 255.0/256.0;
    vec4 result = vec4(0);
    result.r = fract(depth*toFixed*1.0);
    result.g = fract(depth*toFixed*255.0);
    result.b = fract(depth*toFixed*255.0*255.0);
    result.a = fract(depth*toFixed*255.0*255.0*255.0);
    return result;
}

void main() {
  gl_FragColor = pack(gl_FragCoord.z);
}`;

    private static _copyShaderFrag = `
// Texture containing depth info of scene
// packed into rgba
// Must be same size as current viewport
uniform sampler2D src;

// View dimensions
uniform int viewWidth;
uniform int viewHeight;

void main(void) {
  vec2 lookup = gl_FragCoord.xy / vec2(viewWidth, viewHeight );
  float smpl = texture2D(src, lookup);
  gl_FragColor = vec4(smpl);
}  `;

    private static _erodeOrDialateShaderFrag = `
// Texture containing depth info of scene
// packed into rgba
// Must be same size as current viewport
uniform sampler2D src;

// View dimensions
uniform int viewWidth;
uniform int viewHeight;

// Radius of sampling area
uniform int pixelRadius;
// If == 1, dialate, else erode
uniform int dialate;

void main(void) {
  float pr2 = pixelRadius * pixelRadius;
  vec2 lookup = gl_FragCoord.xy / vec2(viewWidth, viewHeight );
  float smpl = texture2D(src, lookup);
  for(int i = -pixelRadius; i <= pixelRadius; i++ ){
    for(int j = -pixelRadius; j <= pixelRadius; j++ ){
      if( i*i + j*j <= pr2 ){
        vec2 offset = vec2(i / viewWidth, j / viewHeight);
        if(dialate == 1){
          smpl = max(smpl, texture2D(src, lookup + offset));
        }else{
          smpl = min(smpl, texture2D(src, lookup + offset));
        }
      }
    }<commit_msg>Added comments on future cleanup<commit_after>module microtome.three_d {

  /**
    * Properly encoding 32 bit float in rgba from here:
    * http://www.gamedev.net/topic/486847-encoding-16-and-32-bit-floating-point-value-into-rgba-byte-texture/
    */
  export class CoreMaterialsFactory {
    private static _basicVertex = `
void main(void) {
   // compute position
   gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}`;

    private static _depthShaderFrag = `
vec4 pack( const in float depth ) {
    const float toFixed = 255.0/256.0;
    vec4 result = vec4(0);
    result.r = fract(depth*toFixed*1.0);
    result.g = fract(depth*toFixed*255.0);
    result.b = fract(depth*toFixed*255.0*255.0);
    result.a = fract(depth*toFixed*255.0*255.0*255.0);
    return result;
}

void main() {
  gl_FragColor = pack(gl_FragCoord.z);
}`;

    private static _copyShaderFrag = `
// Texture containing depth info of scene
// packed into rgba
// Must be same size as current viewport
uniform sampler2D src;

// View dimensions
uniform int viewWidth;
uniform int viewHeight;

void main(void) {
  vec2 lookup = gl_FragCoord.xy / vec2(viewWidth, viewHeight );
  float smpl = texture2D(src, lookup);
  gl_FragColor = vec4(smpl);
}  `;

    private static _erodeOrDialateShaderFrag = `
// Image to be dialated/eroded
uniform sampler2D src;

// View dimensions
uniform int viewWidth;
uniform int viewHeight;

// Radius of sampling area
uniform int pixelRadius;
// If == 1, dialate, else erode
uniform int dialate;

void main(void) {
  float pr2 = pixelRadius * pixelRadius;
  vec2 lookup = gl_FragCoord.xy / vec2(viewWidth, viewHeight );
  float smpl = texture2D(src, lookup);
  // TODO these offsets should be pre-generated and set as array uniform
  // to shader
  for(int i = -pixelRadius; i <= pixelRadius; i++ ){
    for(int j = -pixelRadius; j <= pixelRadius; j++ ){
      if( i*i + j*j <= pr2 ){
        vec2 offset = vec2(i / viewWidth, j / viewHeight);
        if(dialate == 1){
          smpl = max(smpl, texture2D(src, lookup + offset));
        }else{
          smpl = min(smpl, texture2D(src, lookup + offset));
        }
      }
    }
{'fraction_non_alphanumeric': 0.12099976640971735, 'fraction_numerical': 0.03270263957019388, 'mean_word_length': 3.1898238747553815, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7288910', 'n_tokens_mistral': 1516, 'n_tokens_neox': 1438, 'n_words': 395}