setValues()

in packages/miew/src/gfx/shaders/UberMaterial.js [245:338]


  setValues(values) {
    if (typeof values === 'undefined') {
      return;
    }

    // set direct values
    super.setValues(values);

    const defines = {};
    const extensions = {};

    if (this.fog) {
      defines.USE_FOG = 1;
    }
    if (this.instancedPos) {
      defines.INSTANCED_POS = 1;
    }
    if (this.instancedMatrix) {
      defines.INSTANCED_MATRIX = 1;
    }
    if (this.attrColor) {
      defines.ATTR_COLOR = 1;
    }
    if (this.attrColor2) {
      defines.ATTR_COLOR2 = 1;
    }
    if (this.attrAlphaColor) {
      defines.ATTR_ALPHA_COLOR = 1;
    }
    if (this.overrideColor) {
      defines.OVERRIDE_COLOR = 1;
    }
    if (this.sphereSprite) {
      defines.SPHERE_SPRITE = 1;
      extensions.fragDepth = true;
    }
    if (this.cylinderSprite) {
      defines.CYLINDER_SPRITE = 1;
      extensions.fragDepth = true;
    }
    if (this.zClip) {
      defines.ZCLIP = 1;
    }
    if (this.clipPlane) {
      defines.CLIP_PLANE = 1;
    }
    if (this.fakeOpacity) {
      defines.FAKE_OPACITY = 1;
    }
    if (this.lights) {
      defines.USE_LIGHTS = 1;
    }
    if (this.colorFromPos) {
      defines.COLOR_FROM_POS = 1;
    }
    if (this.shadowmap) {
      defines.SHADOWMAP = 1;
      if (this.shadowmapType === 'pcf') {
        defines.SHADOWMAP_PCF_SHARP = 1;
      } else if (this.shadowmapType === 'random') {
        defines.SHADOWMAP_PCF_RAND = 1;
      } else {
        defines.SHADOWMAP_BASIC = 1;
      }
    }
    if (this.colorFromDepth) {
      defines.COLOR_FROM_DEPTH = 1;
    }
    if (this.orthoCam) {
      defines.ORTHOGRAPHIC_CAMERA = 1;
    }
    if (this.prepassTransparancy) {
      defines.PREPASS_TRANSP = 1;
    }
    if (this.dashedLine) {
      defines.DASHED_LINE = 1;
    }
    if (this.thickLine) {
      defines.THICK_LINE = 1;
    }
    if (this.fogTransparent) {
      defines.FOG_TRANSPARENT = 1;
    }
    if (this.normalsToGBuffer) {
      extensions.drawBuffers = true;
      defines.NORMALS_TO_G_BUFFER = 1;
    }
    if (this.toonShading) {
      defines.TOON_SHADING = 1;
    }
    // set dependent values
    this.defines = defines;
    this.extensions = extensions;
  }