<commit_before>import FragmentSimpleShader from './FragmentSimpleShader';
import VertexWorldShaderSource from './VertexWorldShader';
import VertexWorldShadowShaderSource from './VertexWorldShadowShader';
import {FragmentSimpleShaderSource} from './FragmentSimpleShader';

export class WireframeShaderSource {
  // In the context within these member methods,
  // this is the instance of the corresponding shader class.

  VSDefine_WireframeShaderSource(in_, out_, f) {
    var shaderText = '';
    shaderText += `${in_} vec3 aVertex_barycentricCoord;\n`;
    shaderText += `${out_} vec3 barycentricCoord;\n`;

    return shaderText;
  }

  VSTransform_WireframeShaderSource(existCamera_f, f) {
    var shaderText = '';

    shaderText += '  barycentricCoord = aVertex_barycentricCoord;\n';

    return shaderText;
  }

  FSDefine_WireframeShaderSource(in_, f, lights, material, extraData) {
    let shaderText = '';

    shaderText += `${in_} vec3 barycentricCoord;\n`;

    shaderText += 'uniform bool isWireframe;\n';
    //shaderText += 'uniform bool isWireframeOnShade;\n';
    shaderText += 'uniform float wireframeWidth;\n';

    return shaderText;
  }

  FSMethodDefine_WireframeShaderSource(in_, f, lights, material, extraData) {
    let shaderText = '';

    shaderText += `
    float edge_ratio(vec3 bary3, float wireframeWidthInner, float wireframeWidthRelativeScale) {     
        vec3 d = fwidth(bary3);
        vec3 x = bary3+vec3(1.0 - wireframeWidthInner)*d;
        vec3 a3 = smoothstep(vec3(0.0), d, x);
        float factor = min(min(a3.x, a3.y), a3.z);
        
        return clamp((1.0 - factor), 0.0, 1.0);
    }
    `;

    return shaderText;
  }

  FSShade_WireframeShaderSource(f, gl, lights, material, extraData) {
    let shaderText = '';

    shaderText += 'bool isWireframeInner = false;\n';

    return shaderText;
  }

  FSPostEffect_WireframeShaderSource(f, gl, lights, material, extraData) {
    let shaderText = '';

    shaderText += 'float wireframeWidthInner = wireframeWidth;\n';
    shaderText += 'float threshold = 0.001;\n';
    shaderText += 'vec4 wireframeResult = rt0;\n';
    shaderText += 'if ( isWireframeInner || isWireframe ) {\n';
    shaderText += '  vec4 wireframeColor = vec4(0.2, 0.75, 0.0, 1.0);\n';
    shaderText += '  float edgeRatio = edge_ratio(barycentricCoord, wireframeWidthInner, wireframeWidthRelativeScale);\n';
    shaderText += '  float edgeRatioModified = mix(step(0.001, edgeRatio), clamp(edgeRatio*4.0, 0.0, 1.0), wireframeWidthInner / wireframeWidthRelativeScale/4.0);\n';
    // if r0.a is 0.0, it is wireframe not on shaded
    shaderText += '  wireframeResult.rgb = wireframeColor.rgb * edgeRatioModified + rt0.rgb * (1.0 - edgeRatioModified);\n';
    shaderText += '  wireframeResult.a = max(rt0.a, wireframeColor.a * mix(edgeRatioModified, pow(edgeRatioModified, 100.0), wireframeWidthInner / wireframeWidthRelativeScale/1.0));\n';
    shaderText += '}\n';

    shaderText += 'if ( isWireframe ) {\n';<commit_msg>Add wireframeWidthRelativeScale to wireframeShader<commit_after>import FragmentSimpleShader from './FragmentSimpleShader';
import VertexWorldShaderSource from './VertexWorldShader';
import VertexWorldShadowShaderSource from './VertexWorldShadowShader';
import {FragmentSimpleShaderSource} from './FragmentSimpleShader';

export class WireframeShaderSource {
  // In the context within these member methods,
  // this is the instance of the corresponding shader class.

  VSDefine_WireframeShaderSource(in_, out_, f) {
    var shaderText = '';
    shaderText += `${in_} vec3 aVertex_barycentricCoord;\n`;
    shaderText += `${out_} vec3 barycentricCoord;\n`;

    return shaderText;
  }

  VSTransform_WireframeShaderSource(existCamera_f, f) {
    var shaderText = '';

    shaderText += '  barycentricCoord = aVertex_barycentricCoord;\n';

    return shaderText;
  }

  FSDefine_WireframeShaderSource(in_, f, lights, material, extraData) {
    let shaderText = '';

    shaderText += `${in_} vec3 barycentricCoord;\n`;

    shaderText += 'uniform bool isWireframe;\n';
    //shaderText += 'uniform bool isWireframeOnShade;\n';
    shaderText += 'uniform float wireframeWidth;\n';

    return shaderText;
  }

  FSMethodDefine_WireframeShaderSource(in_, f, lights, material, extraData) {
    let shaderText = '';

    shaderText += `
    float edge_ratio(vec3 bary3, float wireframeWidthInner, float wireframeWidthRelativeScale) {     
        vec3 d = fwidth(bary3);
        vec3 x = bary3+vec3(1.0 - wireframeWidthInner)*d;
        vec3 a3 = smoothstep(vec3(0.0), d, x);
        float factor = min(min(a3.x, a3.y), a3.z);
        
        return clamp((1.0 - factor), 0.0, 1.0);
    }
    `;

    return shaderText;
  }

  FSShade_WireframeShaderSource(f, gl, lights, material, extraData) {
    let shaderText = '';

    shaderText += 'bool isWireframeInner = false;\n';
    shaderText += 'float wireframeWidthRelativeScale = 1.0;\n';
    
    return shaderText;
  }

  FSPostEffect_WireframeShaderSource(f, gl, lights, material, extraData) {
    let shaderText = '';

    shaderText += 'float wireframeWidthInner = wireframeWidth;\n';
    shaderText += 'float threshold = 0.001;\n';
    shaderText += 'vec4 wireframeResult = rt0;\n';
    shaderText += 'if ( isWireframeInner || isWireframe ) {\n';
    shaderText += '  vec4 wireframeColor = vec4(0.2, 0.75, 0.0, 1.0);\n';
    shaderText += '  float edgeRatio = edge_ratio(barycentricCoord, wireframeWidthInner, wireframeWidthRelativeScale);\n';
    shaderText += '  float edgeRatioModified = mix(step(0.001, edgeRatio), clamp(edgeRatio*4.0, 0.0, 1.0), wireframeWidthInner / wireframeWidthRelativeScale/4.0);\n';
    // if r0.a is 0.0, it is wireframe not on shaded
    shaderText += '  wireframeResult.rgb = wireframeColor.rgb * edgeRatioModified + rt0.rgb * (1.0 - edgeRatioModified);\n';
    shaderText += '  wireframeResult.a = max(rt0.a, wireframeColor.a * mix(edgeRatioModified, pow(edgeRatioModified, 100.0), wireframeWidthInner / wireframeWidthRelativeScale/1.0));\n';
    shaderText += '}\n';

    shaderText += 'if ( isWireframe ) {\n';
{'fraction_non_alphanumeric': 0.1272786992938085, 'fraction_numerical': 0.02266382000328461, 'mean_word_length': 3.864217252396166, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5620627', 'n_tokens_mistral': 2100, 'n_tokens_neox': 1945, 'n_words': 436}