浏览代码

hotswapping/reimporting of cookie textures

/main
vlad-andreev 8 年前
当前提交
f41bce43
共有 2 个文件被更改,包括 37 次插入11 次删除
  1. 42
      Assets/ScriptableRenderLoop/common/TextureCache.cs
  2. 6
      Assets/ScriptableRenderLoop/fptl/FptlLighting.cs

42
Assets/ScriptableRenderLoop/common/TextureCache.cs


using UnityEngine;
using UnityEditor;
//using System;
using System.Collections.Generic;

public override void TransferToSlice(int sliceIndex, Texture texture)
{
for (int m=0; m<m_numMipLevels; m++)
Graphics.CopyTexture(texture, 0, m, cache, sliceIndex, m);
for (int m = 0; m < m_numMipLevels; m++)
Graphics.CopyTexture(texture, 0, m, cache, sliceIndex, m);
}
public override Texture GetTexCache()

m_numMipLevels = GetNumMips(width, height);
cache = new Texture2DArray(width, height, numTextures, format, isMipMapped);
cache.wrapMode = TextureWrapMode.Clamp;
cache.hideFlags = HideFlags.HideAndDontSave;
cache.wrapMode = TextureWrapMode.Clamp;
return res;
}

m_numMipLevels = GetNumMips(width, width);
cache = new CubemapArray(width, numCubeMaps, format, isMipMapped);
cache.wrapMode = TextureWrapMode.Clamp;
cache.hideFlags = HideFlags.HideAndDontSave;
cache.wrapMode = TextureWrapMode.Clamp;
return res;
}

{
protected int m_numMipLevels;
public static int ms_GlobalTextureCacheVersion = 0;
public int m_TextureCacheVersion = 0;
internal class AssetReloader : AssetPostprocessor
{
void OnPostprocessTexture(Texture texture)
{
ms_GlobalTextureCacheVersion++;
}
}
private struct SSliceEntry
{

private int m_numTextures;
private int [] m_SortedIdxArray;
private SSliceEntry [] m_SliceArray;
private AssetReloader m_assetReloader;
Dictionary<uint, int> m_locatorInSliceArray;
Dictionary<uint, int> m_locatorInSliceArray;
private static uint g_MaxFrameCount = unchecked( (uint) (-1) );
private static uint g_InvalidTexID = (uint) 0;

int sliceIndex = -1;
// search for existing copy
if(m_locatorInSliceArray.ContainsKey(TexID))
if(m_locatorInSliceArray.ContainsKey(TexID))
sliceIndex = m_locatorInSliceArray[TexID];
bFoundAvailOrExistingSlice = true;
if (m_TextureCacheVersion != ms_GlobalTextureCacheVersion)
{
m_locatorInSliceArray.Remove(TexID);
m_TextureCacheVersion++;
Debug.Assert(m_TextureCacheVersion <= ms_GlobalTextureCacheVersion);
}
else
{
sliceIndex = m_locatorInSliceArray[TexID];
bFoundAvailOrExistingSlice = true;
}
//assert(m_SliceArray[sliceIndex].TexID==TexID);
}

{
m_numTextures=0;
m_numMipLevels=0;
}
}
public virtual void TransferToSlice(int sliceIndex, Texture texture)
{

6
Assets/ScriptableRenderLoop/fptl/FptlLighting.cs


using UnityEngine;
using UnityEngine;
using UnityEngine.Rendering;
using System;
using System.Collections;

m_cookieTexArray.NewFrame();
m_cubeCookieTexArray.NewFrame();
m_cubeReflTexArray.NewFrame();
m_DeferredMaterial.SetTexture("_spotCookieTextures", m_cookieTexArray.GetTexCache());
m_DeferredMaterial.SetTexture("_pointCookieTextures", m_cubeCookieTexArray.GetTexCache());
m_DeferredReflectionMaterial.SetTexture("_reflCubeTextures", m_cubeReflTexArray.GetTexCache());
}
}
}
正在加载...
取消
保存