Texture2D CreateDataTexture(int num_max_instances) { int width = BatchRendererUtil.data_texture_width; int height = BatchRendererUtil.ceildiv(num_max_instances, width); Texture2D r = null; if (SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGBFloat)) { r = new Texture2D(width, height, TextureFormat.RGBAFloat, false); } else if (SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGBHalf)) { Debug.Log("BatchRenderer: float texture is not available. use half texture instead"); r = new Texture2D(width, height, TextureFormat.RGBAHalf, false); } else { Debug.Log("BatchRenderer: both float and half texture are not available. give up."); return(null); } r.filterMode = FilterMode.Point; return(r); }
public virtual void Flush() { if (m_expanded_mesh == null || m_instance_count == 0) { m_instance_count = 0; return; } Vector3 scale = m_trans.localScale; m_expanded_mesh.bounds = new Bounds(m_trans.position, new Vector3(m_bounds_size.x * scale.x, m_bounds_size.y * scale.y, m_bounds_size.y * scale.y)); m_instance_count = Mathf.Min(m_instance_count, m_max_instances); m_batch_count = BatchRendererUtil.ceildiv(m_instance_count, m_instances_par_batch); for (int i = 0; i < m_actual_materials.Count; ++i) { var a = m_actual_materials[i]; while (a.Count < m_batch_count) { Material m = CloneMaterial(m_materials[i], a.Count); a.Add(m); } } UpdateGPUResources(); IssueDrawCall(); m_instance_count = m_batch_count = 0; }