|
|
|
|
|
|
public class TexturePadding |
|
|
|
{ |
|
|
|
static readonly int _RectOffset = Shader.PropertyToID("_RectOffset"); |
|
|
|
static readonly int _Source = Shader.PropertyToID("_Source"); |
|
|
|
static readonly int _InOutTexture = Shader.PropertyToID("_InOutTexture"); |
|
|
|
|
|
|
|
ComputeShader m_CS; |
|
|
|
int m_KMainTopRight; |
|
|
|
|
|
|
m_KMainTop = m_CS.FindKernel("KMainTop"); |
|
|
|
m_KMainRight = m_CS.FindKernel("KMainRight"); |
|
|
|
} |
|
|
|
public void Pad(CommandBuffer cmd, RenderTexture source, RectInt from, RectInt to) |
|
|
|
public void Pad(CommandBuffer cmd, RenderTexture inOutTexture, RectInt from, RectInt to) |
|
|
|
cmd.SetComputeTextureParam(m_CS, m_KMainRight, _Source, source); |
|
|
|
cmd.SetComputeTextureParam(m_CS, m_KMainRight, _InOutTexture, inOutTexture); |
|
|
|
cmd.SetComputeTextureParam(m_CS, m_KMainTop, _Source, source); |
|
|
|
cmd.SetComputeTextureParam(m_CS, m_KMainTop, _InOutTexture, inOutTexture); |
|
|
|
cmd.SetComputeTextureParam(m_CS, m_KMainTopRight, _Source, source); |
|
|
|
cmd.SetComputeTextureParam(m_CS, m_KMainTopRight, _InOutTexture, inOutTexture); |
|
|
|
cmd.DispatchCompute(m_CS, m_KMainTopRight, to.width - from.width, to.height - from.height, 1); |
|
|
|
} |
|
|
|
} |