void DispatchUpdate()
 {
     computeShader.SetFloats("_ViewProj", GetViewProjectionArray());
     computeShader.SetTexture(updateKernel_, "_CameraDepthTexture", GBufferUtils.GetDepthTexture());
     computeShader.SetTexture(updateKernel_, "_CameraGBufferTexture2", GBufferUtils.GetGBufferTexture(2));
     computeShader.SetBuffer(updateKernel_, "_Particles", particlesBuffer_);
     computeShader.SetBuffer(updateKernel_, "_DeadList", particlePoolBuffer_);
     computeShader.Dispatch(updateKernel_, maxParticleNum / 8, 1, 1);
 }
Exemplo n.º 2
0
    void OnDisable()
    {
        Instance = null;

        if (depthTexture_ != null)
        {
            depthTexture_.Release();
            depthTexture_ = null;
        }

        for (int i = 0; i < 4; ++i)
        {
            if (gbufferTextures_[i] != null)
            {
                gbufferTextures_[i].Release();
                gbufferTextures_[i] = null;
            }
        }
    }
Exemplo n.º 3
0
        void DispatchUpdate()
        {
            computeShader.SetFloats("_ViewProj", GetViewProjectionArray());

            var cam = Camera.main;

            computeShader.SetMatrix("_view", cam.worldToCameraMatrix);
            computeShader.SetMatrix("_proj", GL.GetGPUProjectionMatrix(cam.projectionMatrix, false));
            //computeShader.SetMatrix("_proj", GL.GetGPUProjectionMatrix(cam.projectionMatrix, true));


            computeShader.SetTexture(updateKernel, "_CameraDepthTex", GBufferUtils.GetDepthTexture());
            computeShader.SetTexture(updateKernel, "_CameraGBufferTex2", GBufferUtils.GetGBufferTexture(2));
            computeShader.SetFloat("_screenWidth", cam.pixelWidth);
            computeShader.SetFloat("_screenHeight", cam.pixelHeight);
            computeShader.SetFloat("_timeSpeed", timeSpeed);
            //TODO : normal
            computeShader.SetBuffer(updateKernel, "_particles", particleBuffer);
            computeShader.SetBuffer(updateKernel, "_deadList", particlePoolBuffer);
            computeShader.Dispatch(updateKernel, maxParticleNum / 8, 1, 1);
        }
 void Update()
 {
     GetComponent <Renderer>().material.mainTexture = GBufferUtils.GetGBufferTexture(2);
 }
Exemplo n.º 5
0
 void OnEnable()
 {
     Assert.IsTrue(Instance == null, "Multiple GBUfferUtils are set as active at the same time.");
     Instance = this;
     UpdateRenderTextures();
 }