Example #1
0
        private void OnDisable()
        {
            NotifyBlurredTexOnUpdate(null);

            if (blur != null)
            {
                blur.Dispose();
                blur = null;
            }
            if (bDepthTex != null)
            {
                bDepthTex.DestroySelf();
                bDepthTex = null;
            }
            if (maskTex0 != null)
            {
                maskTex0.Dispose();
                maskTex0 = null;
            }
            if (maskTex1 != null)
            {
                maskTex1.Dispose();
                maskTex1 = null;
            }
            if (ramm != null)
            {
                ramm.Dispose();
                ramm = null;
            }
            if (pip != null)
            {
                pip.Dispose();
                pip = null;
            }
        }
Example #2
0
        private void OnEnable()
        {
            if (link.targetCam == null)
            {
                link.targetCam = GetComponent <Camera>();
            }

            manualCam = new ManuallyRenderCamera(link.targetCam);
            commander = new CameraEventRetention(manualCam.Camera);

            cmd      = new CommandBuffer();
            cap      = new DepthCapture();
            depthTex = new ResizableRenderTexture(new FormatRT()
            {
                textureFormat = RenderTextureFormat.Depth,
                depth         = 24
            });
            depthColorTex = new ResizableRenderTexture(new FormatRT()
            {
                textureFormat = RenderTextureFormat.ARGBHalf,
                readWrite     = RenderTextureReadWrite.Linear,
                depth         = 0,
            });

            pip = new PIPTexture();

            currCamData = default;
            validator.Reset();
            validator.SetCheckers(() => currCamData.Equals(link.targetCam));
            validator.Validation += () => {
                currCamData = link.targetCam;

                cmd.Clear();

                var size = link.targetCam.Size();
                depthTex.Size      = size;
                depthColorTex.Size = size;

                cmd.Clear();
                cap.StepThreashold = tuner.stepThreashold;
                cap.Capture(cmd, depthColorTex, tuner.depthOutputMode);
                commander.Set(tuner.captureEvent, cmd);

                pip.CurrTuner = tuner.pip;
                pip.TargetCam = link.targetCam;
            };
            manualCam.AfterCopyFrom += v => {
                manualCam.Camera.depthTextureMode = DepthTextureMode.Depth;
                manualCam.Camera.cullingMask      = tuner.CullingMask();
            };

            validator.Validate();

            depthTex.AfterCreateTexture      += v => validator.Invalidate();
            depthColorTex.AfterCreateTexture += v => {
                using (new RenderTextureActivator(depthColorTex))
                    GL.Clear(true, true, Color.white);
                validator.Invalidate();
            };
        }
Example #3
0
 private void OnDisable()
 {
     SetTargetTexture(null);
     if (targetTex != null)
     {
         targetTex.Dispose();
         targetTex = null;
     }
 }
Example #4
0
    protected virtual void OnEnable()
    {
        _attachedCamera = GetComponent <Camera> ();
        _attachedCamera.depthTextureMode = DepthTextureMode.Depth;

        manualCam = new ManuallyRenderCamera(_attachedCamera);
#if TEMPORAL
        _imageTex0 = new TemporalResizableRenderTexture(new nobnak.Gist.Resizable.FormatRT()
        {
            depth         = 0,
            textureFormat = textureFormatAdvected,
            readWrite     = RenderTextureReadWrite.Linear
        });
        _imageTex1 = new TemporalResizableRenderTexture(new nobnak.Gist.Resizable.FormatRT()
        {
            depth         = 0,
            textureFormat = textureFormatAdvected,
            readWrite     = RenderTextureReadWrite.Linear
        });
        _sourceTex = new TemporalResizableRenderTexture(new nobnak.Gist.Resizable.FormatRT()
        {
            depth         = 24,
            textureFormat = textureFormatSource,
            readWrite     = RenderTextureReadWrite.Linear,
            antiAliasing  = QualitySettings.antiAliasing
        });
#else
        _imageTex0 = new ResizableRenderTexture(new nobnak.Gist.Resizable.FormatRT()
        {
            depth         = 0,
            textureFormat = textureFormatAdvected,
            readWrite     = RenderTextureReadWrite.Linear,
            filterMode    = FilterMode.Point
        });
        _imageTex1 = new ResizableRenderTexture(new nobnak.Gist.Resizable.FormatRT()
        {
            depth         = 0,
            textureFormat = textureFormatAdvected,
            readWrite     = RenderTextureReadWrite.Linear,
            filterMode    = FilterMode.Point
        });
        _sourceTex = new ResizableRenderTexture(new nobnak.Gist.Resizable.FormatRT()
        {
            depth         = 24,
            textureFormat = textureFormatSource,
            readWrite     = RenderTextureReadWrite.Linear,
            antiAliasing  = QualitySettings.antiAliasing
        });
#endif

        Prepare();
    }
Example #5
0
        private void OnEnable()
        {
            sender       = GetComponent <SpoutSender>();
            targetCamera = GetComponent <Camera>();

            targetTex = new ResizableRenderTexture();

            validator.Reset();
            validator.Validation += () => {
                Debug.LogFormat("Update Spout : {0}", data);
                SetTargetTexture(null);
                guidata = new GUIData(data);

                var frt = new FormatRT()
                {
                    textureFormat = format,
                    depth         = 24,
                    useMipMap     = false,
                    antiAliasing  = QualitySettings.antiAliasing,
                    readWrite     = RenderTextureReadWrite.Default,
                    filterMode    = FilterMode.Bilinear,
                    wrapMode      = TextureWrapMode.Clamp,
                    anisoLevel    = 0
                };

                if (sender != null)
                {
                    sender.enabled = data.spout;
                }

                if (data.spout)
                {
                    targetTex.Format = frt;
                    targetTex.Size   = data.Size;
                    SetTargetTexture(targetTex);
                }
                else
                {
                    targetTex.Release();
                }

                events.ActiveOnEnabled.Invoke(data.spout);
                events.ActiveOnDisabled.Invoke(!data.spout);
            };
            Load();

            validator.Validate();
        }
Example #6
0
        private void OnEnable()
        {
            if (link.targetCam == null)
            {
                link.targetCam = GetComponent <Camera>();
            }

            blur     = new Blur();
            ramm     = new BinaryAccumulator();
            maskTex0 = new ResizableRenderTexture(new FormatRT()
            {
                textureFormat = RenderTextureFormat.ARGBHalf,
                depth         = 0,
            });
            maskTex1 = new ResizableRenderTexture(maskTex0.Format);

            pip = new PIPTexture();

            currCamData = default;
            validator.Reset();
            validator.SetCheckers(() => currCamData.Equals(link.targetCam));
            validator.Validation += () => {
                currCamData = link.targetCam;

                var size = link.targetCam.Size();
                maskTex0.Size = size;
                maskTex1.Size = size;

                pip.CurrTuner = tuner.pip;
                pip.TargetCam = link.targetCam;
            };

            System.Action <RenderTexture> fClear = tex => {
                using (new RenderTextureActivator(tex)) {
                    GL.Clear(true, true, Color.white);
                }
            };

            maskTex0.AfterCreateTexture += fClear;
            maskTex1.AfterCreateTexture += fClear;

            validator.Validate();
        }
Example #7
0
 protected virtual void OnDisable()
 {
     //NotifyTextureOnChange(null);
     manualCam.Dispose();
     if (_imageTex0 != null)
     {
         _imageTex0.Dispose();
         _imageTex0 = null;
     }
     if (_imageTex1 != null)
     {
         _imageTex1.Dispose();
         _imageTex1 = null;
     }
     if (_sourceTex != null)
     {
         _sourceTex.Dispose();
         _sourceTex = null;
     }
 }
Example #8
0
 private void OnDisable()
 {
     if (commander != null)
     {
         commander.Reset();
         commander = null;
     }
     if (manualCam != null)
     {
         manualCam.Dispose();
         manualCam = null;
     }
     if (cap != null)
     {
         cap.Dispose();
         cap = null;
     }
     if (cmd != null)
     {
         cmd.Dispose();
         cmd = null;
     }
     if (depthTex != null)
     {
         depthTex.Dispose();
         depthTex = null;
     }
     if (depthColorTex != null)
     {
         depthColorTex.Dispose();
         depthColorTex = null;
     }
     if (pip != null)
     {
         pip.Dispose();
         pip = null;
     }
 }