public void Build(HDRenderPipelineAsset asset)
        {
            m_SupportVolumetrics = asset.currentPlatformRenderPipelineSettings.supportVolumetrics;

            if (!m_SupportVolumetrics)
            {
                return;
            }

            preset = asset.currentPlatformRenderPipelineSettings.increaseResolutionOfVolumetrics
                ? VolumetricLightingPreset.High
                : VolumetricLightingPreset.Medium;

            m_VolumeVoxelizationCS = asset.renderPipelineResources.shaders.volumeVoxelizationCS;
            m_VolumetricLightingCS = asset.renderPipelineResources.shaders.volumetricLightingCS;

            m_PackedCoeffs   = new Vector4[7];
            m_PhaseZH        = new ZonalHarmonicsL2();
            m_PhaseZH.coeffs = new float[3];

            m_xySeq       = new Vector2[7];
            m_xySeqOffset = new Vector4();

            CreateBuffers();
        }
        public void InitializeVolumetricLighting()
        {
            m_SupportVolumetrics = asset.currentPlatformRenderPipelineSettings.supportVolumetrics;

            if (!m_SupportVolumetrics)
            {
                return;
            }

            preset = asset.currentPlatformRenderPipelineSettings.increaseResolutionOfVolumetrics
                ? VolumetricLightingPreset.High
                : VolumetricLightingPreset.Medium;

            m_VolumeVoxelizationCS = asset.renderPipelineResources.shaders.volumeVoxelizationCS;
            m_VolumetricLightingCS = asset.renderPipelineResources.shaders.volumetricLightingCS;

            m_PackedCoeffs   = new Vector4[7];
            m_PhaseZH        = new ZonalHarmonicsL2();
            m_PhaseZH.coeffs = new float[3];

            m_xySeq       = new Vector2[7];
            m_xySeqOffset = new Vector4();

            m_PixelCoordToViewDirWS = new Matrix4x4[TextureXR.kMaxSlices];

            CreateVolumetricLightingBuffers();
        }
Ejemplo n.º 3
0
        static int ComputeVBufferSliceCount(VolumetricLightingPreset preset)
        {
            var result = 0;

            switch (preset)
            {
            case VolumetricLightingPreset.Medium:
                result = 64;
                break;

            case VolumetricLightingPreset.High:
                result = 128;
                break;

            case VolumetricLightingPreset.Off:
                result = 0;
                break;

            default:
                Debug.Assert(false, "Encountered an unexpected VolumetricLightingPreset.");
                result = 0;
                break;
            }

            return(result);
        }
        static int ComputeVBufferSliceCount(VolumetricLightingPreset preset, bool accountForXR = false)
        {
            var result = 0;

            switch (preset)
            {
            case VolumetricLightingPreset.Medium:
                result = 64;
                break;

            case VolumetricLightingPreset.High:
                result = 128;
                break;

            case VolumetricLightingPreset.Off:
                result = 0;
                break;

            default:
                Debug.Assert(false, "Encountered an unexpected VolumetricLightingPreset.");
                result = 0;
                break;
            }

            if (accountForXR)
            {
                // With XR single-pass, the VBuffer size is increased and split into compartments for each eye
                if (TextureXR.useTexArray)
                {
                    result = result * TextureXR.slices;
                }
            }

            return(result);
        }
        static Vector3Int ComputeVBufferResolution(VolumetricLightingPreset preset, int screenWidth, int screenHeight)
        {
            int t = ComputeVBufferTileSize(preset);

            int w = HDUtils.DivRoundUp(screenWidth, t);
            int h = HDUtils.DivRoundUp(screenHeight, t);
            int d = ComputeVBufferSliceCount(preset);

            return(new Vector3Int(w, h, d));
        }
Ejemplo n.º 6
0
        static Vector3Int ComputeVBufferResolution(VolumetricLightingPreset preset,
                                                   int screenWidth, int screenHeight)
        {
            int t = ComputeVBufferTileSize(preset);

            // ceil(ScreenSize / TileSize).
            int w = (screenWidth + (t - 1)) / t;
            int h = (screenHeight + (t - 1)) / t;
            int d = ComputeVBufferSliceCount(preset);

            return(new Vector3Int(w, h, d));
        }
        // Since a single voxel corresponds to a tile (e.g. 8x8) of pixels,
        // the VBuffer can potentially extend past the boundaries of the viewport.
        // The function returns the fraction of the {width, height} of the VBuffer visible on screen.
        // Note: for performance reasons, the scale is unused (implicitly 1). The error is typically under 1%.
        static Vector2 ComputeVBufferResolutionAndScale(VolumetricLightingPreset preset,
                                                        int screenWidth, int screenHeight,
                                                        ref int w, ref int h, ref int d)
        {
            int t = ComputeVBufferTileSize(preset);

            // Ceil(ScreenSize / TileSize).
            w = (screenWidth + t - 1) / t;
            h = (screenHeight + t - 1) / t;
            d = ComputeVBufferSliceCount(preset);

            return(new Vector2((float)screenWidth / (float)(w * t), (float)screenHeight / (float)(h * t)));
        }
        public void Build(HDRenderPipelineAsset asset)
        {
            m_supportVolumetrics = asset.renderPipelineSettings.supportVolumetrics;

            if (!m_supportVolumetrics)
            {
                return;
            }

            preset = asset.renderPipelineSettings.increaseResolutionOfVolumetrics ? VolumetricLightingPreset.High :
                     VolumetricLightingPreset.Medium;

            m_VolumeVoxelizationCS = asset.renderPipelineResources.volumeVoxelizationCS;
            m_VolumetricLightingCS = asset.renderPipelineResources.volumetricLightingCS;

            CreateBuffers();
        }
        static int ComputeVBufferSliceCount(VolumetricLightingPreset preset)
        {
            switch (preset)
            {
            case VolumetricLightingPreset.Medium:
                return(64);

            case VolumetricLightingPreset.High:
                return(128);

            case VolumetricLightingPreset.Off:
                return(0);

            default:
                Debug.Assert(false, "Encountered an unexpected VolumetricLightingPreset.");
                return(0);
            }
        }
        static int ComputeVBufferTileSize(VolumetricLightingPreset preset)
        {
            switch (preset)
            {
            case VolumetricLightingPreset.Normal:
                return(8);

            case VolumetricLightingPreset.Ultra:
                return(4);

            case VolumetricLightingPreset.Off:
                return(0);

            default:
                Debug.Assert(false, "Encountered an unexpected VolumetricLightingPreset.");
                return(0);
            }
        }