示例#1
0
        private void Start()
        {
            // Setup pipe
            m_postProcessingPipe = new AARPostProcessingObjectBlending();
            m_postProcessingPipe.SetParams(
                ObjectBlendType.AAR_BLENDTYPE_HOLOLENS,
                1,
                m_hololensCamera.pixelWidth * 4,
                m_hololensCamera.pixelHeight * 4);
            m_postProcessingPipe.Configure(m_hololensCamera);


            // Object Mask
            if (ObjectBlendMask.value == 0)
            {
                ObjectBlendMask = LayerMask.GetMask("AARBlendable");
            }

            if (SpatialEnvironmentMask.value == 0)
            {
                SpatialEnvironmentMask = LayerMask.GetMask(
                    "AARVirtualEnvironments",
                    "Spatial Awareness",
                    "AARProjectorOnly");
            }

            // Set Default Camera mask
            m_hololensCamera.cullingMask = ~SpatialEnvironmentMask.value;

            EnableCustomShaderPipeline();
        }
示例#2
0
        private void Start()
        {
            meshFilter   = gameObject.AddComponent <MeshFilter>();
            meshRenderer = gameObject.AddComponent <MeshRenderer>();
            Shader unlitShader = Shader.Find("Unlit/Texture");

            meshMat                = new Material(unlitShader);
            debugPlaneM            = new Mesh();
            meshFilter.hideFlags   = HideFlags.HideInInspector;
            meshRenderer.hideFlags = HideFlags.HideInInspector;
            meshMat.hideFlags      = HideFlags.HideInInspector;

            m_mainCamera = GetComponent <Camera>();
            if (m_mainCamera == null)
            {
                m_mainCamera = gameObject.AddComponent <Camera>();
            }
            //m_mainCamera.hideFlags = HideFlags.HideInInspector;  // | HideFlags.HideInHierarchy

            m_mainCamera.rect            = new Rect(0, 0, 1, 1);
            m_mainCamera.enabled         = false; //important to disable this camera as we will be calling Render() directly.
            m_mainCamera.aspect          = m_texWidth / m_texHeight;
            m_mainCamera.targetDisplay   = -1;
            m_mainCamera.stereoTargetEye = StereoTargetEyeMask.None;

            TargetRGBTexture = new RenderTexture(
                m_texWidth,
                m_texHeight,
                0,
                RenderTextureFormat.ARGBFloat,
                RenderTextureReadWrite.Default);
            TargetRGBTexture.filterMode       = FilterMode.Trilinear;
            TargetRGBTexture.autoGenerateMips = true;
            TargetRGBTexture.depth            = 24;
            TargetRGBTexture.Create();

            // Create copy for rendering
            m_copyCamera.CopyFrom(m_mainCamera);
            m_copyCamera.projectionMatrix = m_mainCamera.projectionMatrix;
            m_copyCamera.enabled          = false;

            // Setup pipe
            m_postProcessingPipe = new AARPostProcessingObjectBlending();
            m_postProcessingPipe.SetParams(
                ObjectBlendType.AAR_BLENDTYPE_PROJECTOR,
                0,
                m_texWidth,
                m_texHeight);
            m_postProcessingPipe.Configure(m_mainCamera);

            m_isInitialized = true;
        }