浏览代码

TextureCache: rolled back format conversion code, fixed test scene to match code changes

/main
vlad-andreev 8 年前
当前提交
03f141d0
共有 12 个文件被更改,包括 729 次插入1032 次删除
  1. 82
      Assets/ScriptableRenderLoop/common/TextureCache.cs
  2. 2
      Assets/ScriptableRenderLoop/common/TextureSettings.cs
  3. 9
      Assets/ScriptableRenderLoop/fptl/FptlLighting.cs
  4. 3
      Assets/ScriptableRenderLoop/fptl/renderloopfptl.asset
  5. 2
      Assets/TestScenes/FPTL/FPTL.unity
  6. 4
      Assets/TestScenes/FPTL/FPTL/LightingData.asset
  7. 2
      Assets/TestScenes/FPTL/FPTL/LightingData.asset.meta
  8. 1001
      Assets/TestScenes/FPTL/FPTL/ReflectionProbe-0.exr
  9. 34
      Assets/TestScenes/FPTL/FPTL/ReflectionProbe-0.exr.meta
  10. 17
      Assets/TestScenes/FPTL/Materials/Custom_NewSurfaceShader.mat
  11. 601
      Assets/Textures/cubeTest.png
  12. 4
      Assets/Textures/cubeTest.png.meta

82
Assets/ScriptableRenderLoop/common/TextureCache.cs


{
bool mismatch = (cache.width != texture.width) || (cache.height != texture.height);
if (!mismatch)
if (texture is Texture2D)
if (texture is Texture2D)
{
mismatch = cache.format != (texture as Texture2D).format;
}
mismatch |= (cache.format != (texture as Texture2D).format);
if (!mismatch)
if (mismatch)
Graphics.CopyTexture(texture, 0, cache, sliceIndex);
Debug.LogErrorFormat(texture, "Texture size or format of \"{0}\" doesn't match renderloop settings (should be {1}x{2} {3})",
texture.name, cache.width, cache.height, cache.format);
return;
else
{
// TODO: move to C++
Texture2D src = texture as Texture2D;
if (src == null)
{
Debug.LogError("TransferToSlice() requires size conversion, but the input texture is not a Texture2D.");
return;
}
Color[] data = cache.GetPixels(sliceIndex);
float sx = 1.0f / (float)cache.width;
float sy = 1.0f / (float)cache.height;
for (int i = 0; i < data.Length; i++)
{
int x = i % cache.width;
int y = i / cache.width;
data[i] = src.GetPixelBilinear(sx * (float)x, sy * (float)y);
}
cache.SetPixels(data, sliceIndex);
cache.Apply();
}
Graphics.CopyTexture(texture, 0, cache, sliceIndex);
}
public override Texture GetTexCache()

{
bool mismatch = (cache.width != texture.width) || (cache.height != texture.height);
if (!mismatch)
if (texture is Cubemap)
if (texture is Cubemap)
{
mismatch = cache.format != (texture as Cubemap).format;
}
mismatch |= (cache.format != (texture as Cubemap).format);
if (!mismatch)
if (mismatch)
for (int f = 0; f < 6; f++)
Graphics.CopyTexture(texture, f, cache, 6 * sliceIndex + f);
Debug.LogErrorFormat(texture, "Texture size or format of \"{0}\" doesn't match renderloop settings (should be {1}x{2} {3})",
texture.name, cache.width, cache.height, cache.format);
return;
else
{
// TODO: move to C++
Cubemap src = texture as Cubemap;
if (src == null)
{
Debug.LogError("TransferToSlice() requires size conversion, but the input texture is not a Texture2D.");
return;
}
for (int f = 0; f < 6; f++)
{
Color[] rpixels = cache.GetPixels((CubemapFace)f, sliceIndex);
float sx = 1.0f / (float)cache.width;
float sy = 1.0f / (float)cache.height;
for (int i = 0; i < rpixels.Length; i++)
{
int x = i % cache.width;
int y = i / cache.width;
rpixels[i] = src.GetPixelBilinear((CubemapFace)f, sx * (float)x, sy * (float)y);
}
cache.SetPixels(rpixels, (CubemapFace)f, sliceIndex);
}
cache.Apply();
}
for (int f = 0; f < 6; f++)
Graphics.CopyTexture(texture, f, cache, 6 * sliceIndex + f);
}
public override Texture GetTexCache()

2
Assets/ScriptableRenderLoop/common/TextureSettings.cs


{
public uint spotCookieSize;
public uint pointCookieSize;
public uint reflectionCubemapSize;
static public TextureSettings Default
{

settings.spotCookieSize = 128;
settings.pointCookieSize = 512;
settings.reflectionCubemapSize = 64;
return settings;
}
}

9
Assets/ScriptableRenderLoop/fptl/FptlLighting.cs


void OnValidate()
{
if (!Mathf.IsPowerOfTwo((int)m_TextureSettings.pointCookieSize) ||
!Mathf.IsPowerOfTwo((int)m_TextureSettings.spotCookieSize))
{
// let the user type in peace..
return;
}
Rebuild();
}

m_cubeReflTexArray = new TextureCacheCubemap();
m_cookieTexArray.AllocTextureArray(8, (int)m_TextureSettings.spotCookieSize, (int)m_TextureSettings.spotCookieSize, TextureFormat.RGBA32, true);
m_cubeCookieTexArray.AllocTextureArray(4, (int)m_TextureSettings.pointCookieSize, TextureFormat.RGBA32, true);
m_cubeReflTexArray.AllocTextureArray(64, 128, TextureFormat.BC6H, true);
m_cubeReflTexArray.AllocTextureArray(64, (int)m_TextureSettings.reflectionCubemapSize, TextureFormat.BC6H, true);
m_DeferredMaterial.SetTexture("_spotCookieTextures", m_cookieTexArray.GetTexCache());
m_DeferredMaterial.SetTexture("_pointCookieTextures", m_cubeCookieTexArray.GetTexCache());

3
Assets/ScriptableRenderLoop/fptl/renderloopfptl.asset


directionalLightCascades: {x: 0.05, y: 0.2, z: 0.3}
m_TextureSettings:
spotCookieSize: 512
pointCookieSize: 512
pointCookieSize: 256
reflectionCubemapSize: 128
m_DeferredShader: {fileID: 4800000, guid: 1c102a89f3460254a8c413dbdcd63a2a, type: 3}
m_DeferredReflectionShader: {fileID: 4800000, guid: 3899e06d641c2cb4cbff794df0da536b,
type: 3}

2
Assets/TestScenes/FPTL/FPTL.unity


m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 1024
m_ReflectionCompression: 2
m_LightingDataAsset: {fileID: 112000001, guid: 7c15940932339a94eaebfe5f1346f44c,
m_LightingDataAsset: {fileID: 112000001, guid: 69881ce3df6a158419708b1cb7429d87,
type: 2}
m_RuntimeCPUUsage: 25
--- !u!196 &4

4
Assets/TestScenes/FPTL/FPTL/LightingData.asset
文件差异内容过多而无法显示
查看文件

2
Assets/TestScenes/FPTL/FPTL/LightingData.asset.meta


fileFormatVersion: 2
guid: 69881ce3df6a158419708b1cb7429d87
timeCreated: 1473166043
timeCreated: 1473174122
licenseType: Pro
NativeFormatImporter:
userData:

1001
Assets/TestScenes/FPTL/FPTL/ReflectionProbe-0.exr
文件差异内容过多而无法显示
查看文件

34
Assets/TestScenes/FPTL/FPTL/ReflectionProbe-0.exr.meta


externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
isReadable: 1
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 1

textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 100
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Standalone
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 100
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: iPhone
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 100
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: tvOS
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 100
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Windows Store Apps
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1

17
Assets/TestScenes/FPTL/Materials/Custom_NewSurfaceShader.mat


name: _EmissionMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Scale: {x: 32, y: 32}
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Texture: {fileID: 10305, guid: 0000000000000000f000000000000000, type: 0}
m_Scale: {x: 32, y: 32}
m_Offset: {x: 0, y: 0}
- first:
name: _MetallicGlossMap

m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _SpecGlossMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- first:
name: _BumpScale

second: 1
- first:
name: _Glossiness
second: 0.5
second: 0.258
- first:
name: _GlossyReflections
second: 1

- first:
name: _EmissionColor
second: {r: 0, g: 0, b: 0, a: 1}
- first:
name: _SpecColor
second: {r: 1, g: 1, b: 1, a: 1}

601
Assets/Textures/cubeTest.png

之前 之后
宽度: 512  |  高度: 512  |  大小: 50 KiB

4
Assets/Textures/cubeTest.png.meta


overridden: 0
- buildTarget: Standalone
maxTextureSize: 2048
textureFormat: -1
textureFormat: 4
overridden: 0
overridden: 1
- buildTarget: iPhone
maxTextureSize: 2048
textureFormat: -1

正在加载...
取消
保存