public bool AddTexture(CommandBuffer cmd, ref Vector4 scaleBias, Texture texture) { IntPtr key = texture.GetNativeTexturePtr(); if (!m_AllocationCache.TryGetValue(key, out scaleBias)) { int width = texture.width; int height = texture.height; if (m_AtlasAllocator.Allocate(ref scaleBias, width, height)) { scaleBias.Scale(new Vector4(1.0f / m_Width, 1.0f / m_Height, 1.0f / m_Width, 1.0f / m_Height)); for (int mipLevel = 0; mipLevel < (texture as Texture2D).mipmapCount; mipLevel++) { cmd.SetRenderTarget(m_AtlasTexture, mipLevel); HDUtils.BlitQuad(cmd, texture, new Vector4(1, 1, 0, 0), scaleBias, mipLevel, false); } m_AllocationCache.Add(key, scaleBias); return(true); } else { return(false); } } return(true); }
public void RenderDebugOverlay(HDCamera hdCamera, CommandBuffer cmd, DebugDisplaySettings debugDisplaySettings, ref float x, ref float y, float overlaySize, float width) { if (debugDisplaySettings.decalsDebugSettings.m_DisplayAtlas) { using (new ProfilingSample(cmd, "Display Decal Atlas", CustomSamplerId.DisplayDebugDecalsAtlas.GetSampler())) { HDUtils.BlitQuad(cmd, Atlas.AtlasTexture, new Vector4(1, 1, 0, 0), new Vector4(width / hdCamera.actualWidth, overlaySize / hdCamera.actualHeight, x / hdCamera.actualWidth, y / hdCamera.actualHeight), (int)debugDisplaySettings.decalsDebugSettings.m_MipLevel, true); HDUtils.NextOverlayCoord(ref x, ref y, overlaySize, overlaySize, hdCamera.actualWidth); } } }
public void RenderDebugOverlay(HDCamera hdCamera, CommandBuffer cmd, DebugDisplaySettings debugDisplaySettings, ref float x, ref float y, float overlaySize, float width) { if (debugDisplaySettings.data.decalsDebugSettings.displayAtlas) { using (new ProfilingSample(cmd, "Display Decal Atlas", CustomSamplerId.DisplayDebugDecalsAtlas.GetSampler())) { cmd.SetViewport(new Rect(x, y, overlaySize, overlaySize)); HDUtils.BlitQuad(cmd, Atlas.AtlasTexture, new Vector4(1, 1, 0, 0), new Vector4(1, 1, 0, 0), (int)debugDisplaySettings.data.decalsDebugSettings.mipLevel, true); HDUtils.NextOverlayCoord(ref x, ref y, overlaySize, overlaySize, hdCamera); } } }