浏览代码

[BC6H] Fix missing last mips

/main
Frédéric Vauchelles 7 年前
当前提交
7acb1559
共有 1 个文件被更改,包括 7 次插入6 次删除
  1. 13
      ScriptableRenderPipeline/Core/BC6H.cs

13
ScriptableRenderPipeline/Core/BC6H.cs


public void EncodeFastCubemap(CommandBuffer cmb, RenderTargetIdentifier source, int sourceSize, RenderTargetIdentifier target, int fromMip, int toMip)
{
var maxMip = Mathf.Max(0, (int)(Mathf.Log(sourceSize) / Mathf.Log(2)) - 2);
fromMip = (int)Mathf.Clamp(fromMip, 0, maxMip);
toMip = (int)Mathf.Min(maxMip, Mathf.Max(toMip, fromMip));
var actualFromMip = (int)Mathf.Clamp(fromMip, 0, maxMip);
var actualToMip = (int)Mathf.Min(maxMip, Mathf.Max(toMip, actualFromMip));
// Convert TextureCube source to Texture2DArray
var d = new RenderTextureDescriptor

cmb.SetComputeTextureParam(m_Shader, m_KEncodeFastCubemapMip, _Source, source);
for (var mip = fromMip; mip <= toMip; ++mip)
for (var mip = actualFromMip; mip <= actualToMip; ++mip)
{
var size = (sourceSize >> mip) >> 2;
d.width = size;

for (var mip = fromMip; mip <= toMip; ++mip)
for (var mip = actualFromMip; mip <= actualToMip; ++mip)
{
var size = (sourceSize >> mip) >> 2;
cmb.SetComputeTextureParam(m_Shader, m_KEncodeFastCubemapMip, _Target, __Tmp_RT[mip]);

for (var mip = fromMip; mip <= toMip; ++mip)
{
var rtMip = Mathf.Clamp(mip, actualFromMip, actualToMip);
cmb.CopyTexture(__Tmp_RT[mip], faceId, 0, target, faceId, mip);
cmb.CopyTexture(__Tmp_RT[rtMip], faceId, 0, target, faceId, mip);
for (var mip = fromMip; mip <= toMip; ++mip)
for (var mip = actualFromMip; mip <= actualToMip; ++mip)
cmb.ReleaseTemporaryRT(__Tmp_RT[mip]);
}
}

正在加载...
取消
保存