Example #1
0
        void OnEnable()
        {
            manualCam = new ManuallyRenderCamera(refCam);
            output    = new LODRenderTexture();

            var formatOutput = output.Format;

            formatOutput.depth         = 24;
            formatOutput.textureFormat = RenderTextureFormat.ARGBFloat;
            output.Format = formatOutput;

            manualCam.AfterCopyFrom += (Camera obj) => {
                obj.cullingMask = tuner.MaskValue;

                if (tuner.overrideClearFlags)
                {
                    obj.clearFlags      = tuner.clearFlags;
                    obj.backgroundColor = tuner.backgroundColor;
                }
            };
            output.AfterCreateTexture += (LODRenderTexture obj) => {
                obj.Texture.filterMode = FilterMode.Bilinear;
                obj.Texture.wrapMode   = TextureWrapMode.Clamp;
                OnUpdateVelocityTex.Invoke(obj.Texture);
            };
        }
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();
            };
        }
        void Start()
        {
            _attachedCamera = GetComponent <Camera> ();
            _attachedCamera.depthTextureMode = DepthTextureMode.Depth;

            manualCam  = new ManuallyRenderCamera(_attachedCamera);
            _imageTex0 = new LODRenderTexture();
            _imageTex1 = new LODRenderTexture();
            _sourceTex = new LODRenderTexture();

            var format0 = _imageTex0.Format;

            format0.depth         = 0;
            format0.textureFormat = textureFormatAdvected;
            format0.readWrite     = RenderTextureReadWrite.Linear;
            _imageTex0.Format     = format0;
            _imageTex1.Format     = format0;

            var formatSource = _sourceTex.Format;

            formatSource.depth         = 24;
            formatSource.textureFormat = textureFormatSource;
            formatSource.readWrite     = RenderTextureReadWrite.Linear;
            formatSource.antiAliasing  = QualitySettings.antiAliasing;

            _imageTex0.AfterCreateTexture += UpdateAfterCreateTexture;
            _imageTex1.AfterCreateTexture += UpdateAfterCreateTexture;

            Prepare();
        }
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();
    }
    public TriadVoxelizer(ComputeShaderLinker csLinker, Shader voxelizer, AbstractVoxelBounds voxelBounds, int prefferedResolution)
    {
        this.csLinker  = csLinker;
        this.voxelizer = voxelizer;

        this.shaderConstants = ShaderConstants.Instance;

        this.cameraDirection = new VoxelCameraDirection();
        this.renderCam       = new ManuallyRenderCamera((cam) => cameraDirection.FitCameraToVoxelBounds(cam, voxelBounds));

        this.colorTextures = new VoxelTexture[DIRECTIONS.Length];
        for (var i = 0; i < colorTextures.Length; i++)
        {
            colorTextures [i] = GenerateVoxelTexture(prefferedResolution);
        }
        this.resultTex = GenerateVoxelTexture(prefferedResolution);
    }
Example #6
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;
     }
 }