Exemplo n.º 1
0
        public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor)
        {
            cameraTextureDescriptor.depthBufferBits = 0;
            cameraTextureDescriptor.width           = m_Resolution;
            cameraTextureDescriptor.height          = m_Resolution;
            cameraTextureDescriptor.colorFormat     = RenderTextureFormat.Default;

// Does not help for single pass instanced...
// cameraTextureDescriptor.vrUsage = VRTextureUsage.None;
// https://docs.unity3d.com/ScriptReference/Rendering.AttachmentDescriptor.ConfigureTarget.html

            cmd.GetTemporaryRT(m_GrassDisplacementFX.id, cameraTextureDescriptor, FilterMode.Bilinear);
            ConfigureTarget(m_GrassDisplacementFX.Identifier());
            ConfigureClear(ClearFlag.Color, m_ClearColor);

            //  Set up all constants
            stepSize        = m_Size / (float)m_Resolution;
            oneOverStepSize = 1.0f / stepSize;
            var halfSize = m_Size * 0.5f;

            projectionMatrix = Matrix4x4.Ortho(-halfSize, halfSize, -halfSize, halfSize, 0.1f, 80.0f);
            projectionMatrix = GL.GetGPUProjectionMatrix(projectionMatrix, false);
            worldToCameraMatrix.SetRow(0, new Vector4(1, 0, 0, 0)); //last is x pos
            worldToCameraMatrix.SetRow(1, new Vector4(0, 0, 1, 0)); //last is z pos
            worldToCameraMatrix.SetRow(2, new Vector4(0, 1, 0, 0)); //last is y pos
            worldToCameraMatrix.SetRow(3, new Vector4(0, 0, 0, 1));
        }
Exemplo n.º 2
0
 public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor)
 {
     cameraTextureDescriptor.depthBufferBits = 0;
     cameraTextureDescriptor.width           = cameraTextureDescriptor.width / 2;
     cameraTextureDescriptor.height          = cameraTextureDescriptor.height / 2;
     cameraTextureDescriptor.colorFormat     = RenderTextureFormat.Default;
     cmd.GetTemporaryRT(m_WaterFX.id, cameraTextureDescriptor, FilterMode.Bilinear);
     ConfigureTarget(m_WaterFX.Identifier());
     ConfigureClear(ClearFlag.Color, m_ClearColor);
 }
Exemplo n.º 3
0
        /// <inheritdoc/>
        public override void Execute(ScriptableRenderContext context, ref UnityEngine.Rendering.Universal.RenderingData renderingData)
        {
            CommandBuffer cmd = CommandBufferPool.Get(m_ProfilerTag);

            RenderTextureDescriptor opaqueDesc = renderingData.cameraData.cameraTargetDescriptor;

            opaqueDesc.depthBufferBits = 0;

            // Can't read and write to same color target, create a temp render target to blit.
            if (destination == UnityEngine.Rendering.Universal.RenderTargetHandle.CameraTarget)
            {
                cmd.GetTemporaryRT(m_TemporaryColorTexture.id, opaqueDesc, filterMode);

                RenderTargetIdentifier mainID;

                if (setMainTexTo != null)
                {
                    mainID = new RenderTargetIdentifier(setMainTexTo);

                    Blit(cmd, mainID, m_TemporaryColorTexture.Identifier(), blitMaterial, blitShaderPassIndex);
                }
                else
                {
                    Blit(cmd, source, m_TemporaryColorTexture.Identifier(), blitMaterial, blitShaderPassIndex);
                }


                Blit(cmd, m_TemporaryColorTexture.Identifier(), source);
            }
            else
            {
                Blit(cmd, source, destination.Identifier(), blitMaterial, blitShaderPassIndex);
            }

            context.ExecuteCommandBuffer(cmd);

            CommandBufferPool.Release(cmd);
        }