|
|
|
|
|
|
|
|
|
|
// Configuration parameters for Multiple Importance Sampling.
|
|
|
|
const bool m_useMIS = false; |
|
|
|
const int MIS_TEXTURE_HEIGHT = 256; |
|
|
|
const int MIS_TEXTURE_WIDTH = MIS_TEXTURE_HEIGHT * 2; |
|
|
|
const int m_TextureHeightMIS = 256; |
|
|
|
const int m_TextureWidthMIS = m_TextureHeightMIS * 2; |
|
|
|
|
|
|
|
SkyParameters m_SkyParameters = null; |
|
|
|
|
|
|
|
|
|
|
if (m_useMIS) |
|
|
|
{ |
|
|
|
// + 1 because we store the value of the integral of the cubemap at the end of the texture.
|
|
|
|
m_SkyboxMarginalRowCdfRT = new RenderTexture(MIS_TEXTURE_HEIGHT + 1, 1, 1, RenderTextureFormat.RFloat); |
|
|
|
m_SkyboxMarginalRowCdfRT = new RenderTexture(m_TextureHeightMIS + 1, 1, 1, RenderTextureFormat.RFloat); |
|
|
|
m_SkyboxMarginalRowCdfRT.dimension = TextureDimension.Tex2D; |
|
|
|
m_SkyboxMarginalRowCdfRT.useMipMap = false; |
|
|
|
m_SkyboxMarginalRowCdfRT.autoGenerateMips = false; |
|
|
|
|
|
|
|
|
|
|
// TODO: switch the format to R16 (once it's available) to save some bandwidth.
|
|
|
|
m_SkyboxConditionalCdfRT = new RenderTexture(MIS_TEXTURE_WIDTH, MIS_TEXTURE_HEIGHT, 1, RenderTextureFormat.RFloat); |
|
|
|
m_SkyboxConditionalCdfRT = new RenderTexture(m_TextureWidthMIS, m_TextureHeightMIS, 1, RenderTextureFormat.RFloat); |
|
|
|
m_SkyboxConditionalCdfRT.dimension = TextureDimension.Tex2D; |
|
|
|
m_SkyboxConditionalCdfRT.useMipMap = false; |
|
|
|
m_SkyboxConditionalCdfRT.autoGenerateMips = false; |
|
|
|
|
|
|
m_BuildProbabilityTablesCS.SetTexture(m_MarginalRowDensitiesKernel, "marginalRowDensities", m_SkyboxMarginalRowCdfRT); |
|
|
|
|
|
|
|
var cmd = new CommandBuffer() { name = "" }; |
|
|
|
cmd.DispatchCompute(m_BuildProbabilityTablesCS, m_ConditionalDensitiesKernel, MIS_TEXTURE_HEIGHT, 1, 1); |
|
|
|
cmd.DispatchCompute(m_BuildProbabilityTablesCS, m_ConditionalDensitiesKernel, m_TextureHeightMIS, 1, 1); |
|
|
|
cmd.DispatchCompute(m_BuildProbabilityTablesCS, m_MarginalRowDensitiesKernel, 1, 1, 1); |
|
|
|
renderLoop.ExecuteCommandBuffer(cmd); |
|
|
|
cmd.Dispose(); |
|
|
|