private void initImageBasedMaterial(LeapImageBasedMaterial imageBasedMaterial)
    {
        Material material = imageBasedMaterial.GetComponent <Renderer> ().material;

        switch (_currentFormat)
        {
        case Image.FormatType.INFRARED:
            material.EnableKeyword(IR_SHADER_VARIANT_NAME);
            material.DisableKeyword(RGB_SHADER_VARIANT_NAME);
            break;

        case (Image.FormatType) 4:
            material.EnableKeyword(RGB_SHADER_VARIANT_NAME);
            material.DisableKeyword(IR_SHADER_VARIANT_NAME);
            break;

        default:
            Debug.LogWarning("Unexpected format type " + _currentFormat);
            break;
        }

        if (SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.Depth))
        {
            material.EnableKeyword(DEPTH_TEXTURE_VARIANT_NAME);
        }
        else
        {
            material.DisableKeyword(DEPTH_TEXTURE_VARIANT_NAME);
        }

        imageBasedMaterial.GetComponent <Renderer> ().material.SetFloat("_LeapGammaCorrectionExponent", 1.0f / gammaCorrection);
    }
Esempio n. 2
0
    private void updateImageBasedMaterial(LeapImageBasedMaterial imageBasedMaterial, ref Image image)
    {
        imageBasedMaterial.GetComponent <Renderer>().material.SetTexture("_LeapTexture", _mainTexture);

        Vector4 projection = new Vector4();

        projection.x = GetComponent <Camera>().projectionMatrix[0, 2];
        projection.z = GetComponent <Camera>().projectionMatrix[0, 0];
        projection.w = GetComponent <Camera>().projectionMatrix[1, 1];
        imageBasedMaterial.GetComponent <Renderer>().material.SetVector("_LeapProjection", projection);

        if (_distortion == null)
        {
            initDistortion(image);
            loadDistortion(image);
            _forceDistortionRecalc = false;
        }

        if (_forceDistortionRecalc || (_requestDistortionRecalc && _controller.Frame().Hands.Count != 0))
        {
            loadDistortion(image);
            _requestDistortionRecalc = false;
            _forceDistortionRecalc   = false;
        }

        imageBasedMaterial.GetComponent <Renderer>().material.SetTexture("_LeapDistortion", _distortion);
    }
Esempio n. 3
0
    private void initImageBasedMaterial(LeapImageBasedMaterial imageBasedMaterial)
    {
        Material material = imageBasedMaterial.GetComponent <Renderer>().material;

        foreach (string keyword in material.shaderKeywords)
        {
            material.DisableKeyword(keyword);
        }

        switch (_currentFormat)
        {
        case Image.FormatType.INFRARED:
            material.EnableKeyword("LEAP_FORMAT_IR");
            break;

        case (Image.FormatType) 4:
            material.EnableKeyword("LEAP_FORMAT_RGB");
            break;

        default:
            Debug.LogWarning("Unexpected format type " + _currentFormat);
            break;
        }

        imageBasedMaterial.GetComponent <Renderer>().material.SetFloat("_LeapGammaCorrectionExponent", 1.0f / gammaCorrection);
    }
  private void initImageBasedMaterial (LeapImageBasedMaterial imageBasedMaterial)
  {
    Material material = imageBasedMaterial.GetComponent<Renderer> ().material;

    switch (_currentFormat) {
    case Image.FormatType.INFRARED:
      material.EnableKeyword (IR_SHADER_VARIANT_NAME);
      material.DisableKeyword (RGB_SHADER_VARIANT_NAME);
      break;
    case (Image.FormatType)4:
      material.EnableKeyword (RGB_SHADER_VARIANT_NAME);
      material.DisableKeyword (IR_SHADER_VARIANT_NAME);
      break;
    default:
      Debug.LogWarning ("Unexpected format type " + _currentFormat);
      break;
    }

    if (SystemInfo.SupportsRenderTextureFormat (RenderTextureFormat.Depth)) {
      material.EnableKeyword (DEPTH_TEXTURE_VARIANT_NAME);
    } else {
      material.DisableKeyword (DEPTH_TEXTURE_VARIANT_NAME);
    }

    imageBasedMaterial.GetComponent<Renderer> ().material.SetFloat ("_LeapGammaCorrectionExponent", 1.0f / gammaCorrection);
  }
Esempio n. 5
0
    private void initImageBasedMaterial(LeapImageBasedMaterial imageBasedMaterial) {
        Material material = imageBasedMaterial.GetComponent<Renderer>().material;

        foreach (string keyword in material.shaderKeywords) {
            material.DisableKeyword(keyword);
        }

        switch(_currentFormat){
            case Image.FormatType.INFRARED:
                material.EnableKeyword("LEAP_FORMAT_IR");
                break;
            case (Image.FormatType)4:
                material.EnableKeyword("LEAP_FORMAT_RGB");
                break;
            default:
                Debug.LogWarning("Unexpected format type " + _currentFormat);
                break;
        }

        imageBasedMaterial.GetComponent<Renderer>().material.SetFloat("_LeapGammaCorrectionExponent", 1.0f / gammaCorrection);
    }
    private void updateImageBasedMaterial(LeapImageBasedMaterial imageBasedMaterial, ref Image image)
    {
        Camera   camera   = GetComponent <Camera> ();
        Material material = imageBasedMaterial.GetComponent <Renderer> ().material;

        material.SetTexture("_LeapTexture", _mainTexture);

        Vector4 projection = new Vector4();

        projection.x = camera.projectionMatrix [0, 2];
        projection.y = 0f;
        projection.z = camera.projectionMatrix [0, 0];
        projection.w = camera.projectionMatrix [1, 1];
        material.SetVector("_LeapProjection", projection);

        if (_distortion == null)
        {
            initDistortion(image);
            loadDistortion(image);
            _forceDistortionRecalc = false;
        }

        if (_forceDistortionRecalc || (_requestDistortionRecalc && _controller.Frame().Hands.Count != 0))
        {
            loadDistortion(image);
            _requestDistortionRecalc = false;
            _forceDistortionRecalc   = false;
        }

        material.SetTexture("_LeapDistortion", _distortion);

        // Set camera parameters
        material.SetFloat("_VirtualCameraV", camera.fieldOfView);
        material.SetFloat("_VirtualCameraH", Mathf.Rad2Deg * Mathf.Atan(Mathf.Tan(Mathf.Deg2Rad * camera.fieldOfView / 2f) * camera.aspect) * 2f);
        material.SetMatrix("_InverseView", camera.worldToCameraMatrix.inverse);
    }
  private void updateImageBasedMaterial (LeapImageBasedMaterial imageBasedMaterial, ref Image image)
  {
    Camera camera = GetComponent<Camera> ();
    Material material = imageBasedMaterial.GetComponent<Renderer> ().material;
    material.SetTexture ("_LeapTexture", _mainTexture);

    Vector4 projection = new Vector4 ();
    projection.x = camera.projectionMatrix [0, 2];
    projection.y = 0f;
    projection.z = camera.projectionMatrix [0, 0];
    projection.w = camera.projectionMatrix [1, 1];
    material.SetVector ("_LeapProjection", projection);

    if (_distortion == null) {
      initDistortion (image);
      loadDistortion (image);
      _forceDistortionRecalc = false;
    }

    if (_forceDistortionRecalc || (_requestDistortionRecalc && _controller.Frame ().Hands.Count != 0)) {
      loadDistortion (image);
      _requestDistortionRecalc = false;
      _forceDistortionRecalc = false;
    }

    material.SetTexture ("_LeapDistortion", _distortion);

    // Set camera parameters
    material.SetFloat ("_VirtualCameraV", camera.fieldOfView);
    material.SetFloat ("_VirtualCameraH", Mathf.Rad2Deg * Mathf.Atan (Mathf.Tan (Mathf.Deg2Rad * camera.fieldOfView / 2f) * camera.aspect) * 2f);
    material.SetMatrix ("_InverseView", camera.worldToCameraMatrix.inverse);
  }
Esempio n. 8
0
    private void updateImageBasedMaterial(LeapImageBasedMaterial imageBasedMaterial, ref Image image) {
        imageBasedMaterial.GetComponent<Renderer>().material.SetTexture("_LeapTexture", _mainTexture);

        Vector4 projection = new Vector4();
        projection.x = GetComponent<Camera>().projectionMatrix[0, 2];
        projection.z = GetComponent<Camera>().projectionMatrix[0, 0];
        projection.w = GetComponent<Camera>().projectionMatrix[1, 1];
        imageBasedMaterial.GetComponent<Renderer>().material.SetVector("_LeapProjection", projection);

        if (_distortion == null) {
            initDistortion(image);
            loadDistortion(image);
            _forceDistortionRecalc = false;
        }

        if (_forceDistortionRecalc || (_requestDistortionRecalc && _controller.Frame().Hands.Count != 0)) {
            loadDistortion(image);
            _requestDistortionRecalc = false;
            _forceDistortionRecalc = false;
        }

        imageBasedMaterial.GetComponent<Renderer>().material.SetTexture("_LeapDistortion", _distortion);
    }