public override void Interp(Texture from, Texture to, float t) { if (from == null || to == null) { base.Interp(from, to, t); return; } var format = TextureFormatUtilities.GetUncompressedRenderTextureFormat(to); var rt = RuntimeUtilities.GetLerpTarget(to.width, to.height, format); var material = RuntimeUtilities.lerpMaterial; material.SetTexture("_From", from); material.SetTexture("_To", to); material.SetFloat("_Interp", t); Graphics.SetRenderTarget(rt); material.SetPass(0); Graphics.DrawMeshNow(RuntimeUtilities.fullscreenTriangle, Matrix4x4.identity); value = rt; }
internal Texture Lerp(Texture from, Texture to, float t) { Assert.IsNotNull(from); Assert.IsNotNull(to); bool is3d = to is Texture3D || (to is RenderTexture && ((RenderTexture)to).volumeDepth > 1); RenderTexture rt = null; if (is3d) { int size = to.width; rt = Get(RenderTextureFormat.ARGBHalf, size, size, size, true); var compute = m_Resources.computeShaders.texture3dLerp; int kernel = compute.FindKernel("KTexture3DLerp"); m_Command.SetComputeVectorParam(compute, "_Params", new Vector4(t, size, 0f, 0f)); m_Command.SetComputeTextureParam(compute, kernel, "_Output", rt); m_Command.SetComputeTextureParam(compute, kernel, "_From", from); m_Command.SetComputeTextureParam(compute, kernel, "_To", to); int groupSize = Mathf.CeilToInt(size / 8f); m_Command.DispatchCompute(compute, kernel, groupSize, groupSize, groupSize); } else { var format = TextureFormatUtilities.GetUncompressedRenderTextureFormat(to); rt = Get(format, to.width, to.height); var sheet = m_PropertySheets.Get(m_Resources.shaders.texture2dLerp); sheet.properties.SetTexture(Uniforms._To, to); sheet.properties.SetFloat(Uniforms._Interp, t); m_Command.BlitFullscreenTriangle(from, rt, sheet, 0); } return(rt); }