浏览代码

Restored basic BC6H compression

/Add-support-for-light-specular-color-tint
Frédéric Vauchelles 7 年前
当前提交
a1b6f2fd
共有 2 个文件被更改,包括 2 次插入34 次删除
  1. 11
      ScriptableRenderPipeline/Core/Resources/BC6H.compute
  2. 25
      Tests/TextureCompressionTests/Editor/BC6HTests.cs

11
ScriptableRenderPipeline/Core/Resources/BC6H.compute


#include "../ShaderLibrary/BC6H.hlsl"
Texture2D<float4> _Source;
RWTexture2D<float4> _Target;
RWTexture2D<uint4> _Target;
#pragma kernel KEncodeFast
[numthreads(4, 4, 1)]

EncodeMode11(block, blockMSLE, texels);
_Target[dispatchThreadId] = float4(0, 0, 0, 0);
}
#pragma kernel KCopy
[numthreads(1, 1, 1)]
void KCopy(uint2 groupId : SV_GroupID, uint2 groupThreadId : SV_GroupThreadID, uint2 dispatchThreadId : SV_DispatchThreadID)
{
_Target[dispatchThreadId] = _Source.Load(uint3(dispatchThreadId, 0));
_Target[dispatchThreadId] = block;
}

25
Tests/TextureCompressionTests/Editor/BC6HTests.cs


target.Release();
}
// Test texture copy
[Test]
public void TextureCopy()
{
var shader = AssetDatabase.LoadAssetAtPath<ComputeShader>("Assets/ScriptableRenderPipeline/ScriptableRenderPipeline/Core/Resources/BC6H.compute");
var sourceTexture = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/ScriptableRenderPipeline/Tests/TextureCompressionTests/Editor/Resources/graffiti_shelter_1k.hdr");
var k = shader.FindKernel("KCopy");
var target = new RenderTexture(sourceTexture.width, sourceTexture.height, 0, RenderTextureFormat.ARGBFloat, RenderTextureReadWrite.Linear);
target.Release();
target.enableRandomWrite = true;
target.Create();
var targetT2D = new Texture2D(sourceTexture.width, sourceTexture.height, TextureFormat.RGBAFloat, false, true);
shader.SetTexture(k, "_Source", sourceTexture);
shader.SetTexture(k, "_Target", target);
shader.Dispatch(k, targetT2D.width, targetT2D.height, 1);
Graphics.CopyTexture(target, targetT2D);
var targetFile = "Assets/ScriptableRenderPipeline/Tests/TextureCompressionTests/Editor/Resources/graffiti_shelter_1k_bc6h.hdr";
var bytes = targetT2D.GetRawTextureData();
File.WriteAllBytes(targetFile, bytes);
target.Release();
}
}
正在加载...
取消
保存