bool UpdatePlanarTexture(CommandBuffer cmd, Texture texture, ref Vector4 scaleOffset)
        {
            bool success = false;

            using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.ConvolvePlanarReflectionProbe)))
            {
                // For now baking is done directly but will be time sliced in the future. Just preparing the code here.
                m_ProbeBakingState[scaleOffset] = ProbeFilteringState.Convolving;

                Vector4 sourceScaleOffset;
                Texture convolvedTexture = ConvolveProbeTexture(cmd, texture, out sourceScaleOffset);
                if (convolvedTexture == null)
                {
                    return(false);
                }

                if (m_PerformBC6HCompression)
                {
                    throw new NotImplementedException("BC6H Support not implemented for PlanarReflectionProbeCache");
                }
                else
                {
                    if (m_TextureAtlas.IsCached(out scaleOffset, texture))
                    {
                        success = m_TextureAtlas.UpdateTexture(cmd, texture, convolvedTexture, ref scaleOffset, sourceScaleOffset);
                    }
                    else
                    {
                        // Reserve space for the rendertarget and then blit the result of the convolution at this
                        // location, we don't use the UpdateTexture because it will keep the reference to the
                        // temporary target used to convolve the result of the probe rendering.
                        if (!m_TextureAtlas.AllocateTextureWithoutBlit(texture, texture.width, texture.height, ref scaleOffset))
                        {
                            return(false);
                        }
                        m_TextureAtlas.BlitTexture(cmd, scaleOffset, convolvedTexture, sourceScaleOffset);
                        success = true;
                    }
                }

                m_ProbeBakingState[scaleOffset] = ProbeFilteringState.Ready;
            }

            return(success);
        }
예제 #2
0
        bool UpdatePlanarTexture(CommandBuffer cmd, Texture texture, ref IBLFilterBSDF.PlanarTextureFilteringParameters planarTextureFilteringParameters, ref Vector4 scaleOffset)
        {
            bool success = false;

            using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.ConvolvePlanarReflectionProbe)))
            {
                m_ProbeBakingState[scaleOffset] = ProbeFilteringState.Convolving;

                Vector4 sourceScaleOffset;
                Texture convolvedTexture = ConvolveProbeTexture(cmd, texture, ref planarTextureFilteringParameters, out sourceScaleOffset);
                if (convolvedTexture == null)
                {
                    return(false);
                }

                if (m_TextureAtlas.IsCached(out scaleOffset, texture))
                {
                    success = m_TextureAtlas.UpdateTexture(cmd, texture, convolvedTexture, ref scaleOffset, sourceScaleOffset);
                }
                else
                {
                    // Reserve space for the rendertarget and then blit the result of the convolution at this
                    // location, we don't use the UpdateTexture because it will keep the reference to the
                    // temporary target used to convolve the result of the probe rendering.
                    if (!m_TextureAtlas.AllocateTextureWithoutBlit(texture, texture.width, texture.height, ref scaleOffset))
                    {
                        return(false);
                    }
                    m_TextureAtlas.BlitTexture(cmd, scaleOffset, convolvedTexture, sourceScaleOffset);
                    success = true;
                }

                m_ProbeBakingState[scaleOffset] = ProbeFilteringState.Ready;
            }

            return(success);
        }