public override void Render(Matrix matrix, ColorTransform colorTransform, int renderingIndex, int renderingCount, bool visible) { if (!visible || m_empty) return; Factory factory = (Factory)m_context.factory; factory.ConvertColorTransform( ref m_colorMult, ref m_colorAdd, colorTransform); if (m_colorMult.a <= 0) return; m_color = m_colors32[0] * m_colorMult + m_colorAdd; m_updated = m_matrix.SetWithComparing(matrix); int z = renderingCount - renderingIndex; if (m_z != z) { m_updated = true; m_z = z; } if (m_updated) { factory.ConvertMatrix( ref m_matrixForRender, matrix, 1, z, m_context.height); } factory.Render(this, m_vertices.Length / 4, m_context.settings.font.material, m_colorAdd); }
public override void Render(Matrix matrix, ColorTransform colorTransform, int renderingIndex, int renderingCount, bool visible) { #if UNITY_EDITOR m_visible = visible; #endif if (!visible || m_empty) return; Factory factory = (Factory)m_context.factory; factory.ConvertMatrix(ref m_matrix, matrix, 1, renderingCount - renderingIndex, m_context.height); Factory.MultiplyMatrix(ref m_renderMatrix, factory.gameObject.transform.localToWorldMatrix, m_matrix); factory.ConvertColorTransform( ref m_colorMult, ref m_colorAdd, colorTransform); var color = m_color * m_colorMult + m_colorAdd; for (int i = 0; i < m_colors32.Length; ++i) m_colors32[i] = color; m_mesh.Clear(true); m_mesh.vertices = m_vertices; m_mesh.uv = m_uv; m_mesh.triangles = m_triangles; m_mesh.colors32 = m_colors32; Graphics.DrawMesh(m_mesh, m_renderMatrix, m_context.settings.font.material, 0); }
public TextMeshRenderer(LWF lwf, UnityRenderer.TextContext context) : base(lwf, context) { m_matrix = new Matrix(0, 0, 0, 0, 0, 0); m_matrixForRender = new Matrix4x4(); m_colorMult = new UnityEngine.Color(); m_colorAdd = new UnityEngine.Color(); m_color = new Color32(); m_z = -1; m_updated = false; m_buffer = null; m_bufferIndex = -1; }
public override void Render(Matrix matrix, ColorTransform colorTransform, int renderingIndex, int renderingCount, bool visible) { // Ignore null texture if (m_context == null) return; Factory factory = m_context.factory; CombinedMeshBuffer buffer = factory.buffer; int bufferIndex = buffer.index++; if (!factory.updated) return; if (!visible) goto invisible; factory.ConvertColorTransform( ref m_colorMult, ref m_colorAdd, colorTransform); if (m_colorMult.a <= 0) goto invisible; if (factory.premultipliedAlpha) { m_colorMult.r *= m_colorMult.a; m_colorMult.g *= m_colorMult.a; m_colorMult.b *= m_colorMult.a; } Color32 color32 = m_colorMult; factory.ConvertMatrix(ref m_matrix, matrix, 1, renderingCount - renderingIndex, m_context.height); int index = bufferIndex * 4; Color32 bc = buffer.colors32[index]; if (bc.r != color32.r || bc.g != color32.g || bc.b != color32.b || bc.a != color32.a) { for (int i = 0; i < 4; ++i) buffer.colors32[index + i] = color32; } if (factory.useAdditionalColor) { Vector3 bac = buffer.additionalColors[index]; if (bac.x != m_colorAdd.r || bac.y != m_colorAdd.g || bac.z != m_colorAdd.b) { for (int i = 0; i < 4; ++i) buffer.additionalColors[index + i] = new Vector3(m_colorAdd.r, m_colorAdd.g, m_colorAdd.b); } } if (!buffer.clean && m_available && buffer.objects[bufferIndex] == m_context.objectId) { index = bufferIndex * 4; for (int i = 0; i < 4; ++i) { buffer.vertices[index + i] = m_matrix.MultiplyPoint3x4(m_context.vertices[i]); } return; } buffer.objects[bufferIndex] = m_context.objectId; index = bufferIndex * 4; for (int i = 0; i < 4; ++i) { buffer.vertices[index + i] = m_matrix.MultiplyPoint3x4(m_context.vertices[i]); buffer.uv[index + i] = m_context.uv[i]; } int offset = bufferIndex * 4; index = bufferIndex * 6; for (int i = 0; i < 6; ++i) buffer.triangles[index + i] = m_context.triangles[i] + offset; buffer.changed = true; m_available = true; return; invisible: factory.ConvertMatrix(ref m_matrix, matrix, 1, renderingCount - renderingIndex, m_context.height); Vector3 v = m_matrix.MultiplyPoint3x4(m_context.vertices[0]); index = bufferIndex * 4; for (int i = 0; i < 4; ++i) { buffer.vertices[index + i] = v; buffer.colors32[index + i] = s_clearColor; } m_available = false; }
public void ConvertMatrix(ref Matrix4x4 m, Matrix lm, float scale = 1, float z = 0, float height = 0) { ConvertMatrix(ref m, lm, scale, z, zOffset, zRate, height); }
public static void ConvertMatrix(ref Matrix4x4 m, Matrix lm, float scale, float z, float zO, float zR, float height) { m.m00 = lm.scaleX * scale; m.m01 = -lm.skew0 * scale; m.m02 = 0; m.m03 = (lm.skew0 * scale * height) + lm.translateX; m.m10 = -lm.skew1 * scale; m.m11 = lm.scaleY * scale; m.m12 = 0; m.m13 = (-lm.scaleY * scale * height) + (-lm.translateY); m.m20 = 0; m.m21 = 0; m.m22 = 1; m.m23 = zO + z * zR; m.m30 = 0; m.m31 = 0; m.m32 = 0; m.m33 = 1; }
public override void Render(Matrix matrix, ColorTransform colorTransform, int renderingIndex, int renderingCount, bool visible) { // Ignore null texture #if UNITY_EDITOR m_visible = visible; #endif if (m_context == null || !visible) return; Factory factory = m_context.factory; factory.ConvertColorTransform( ref m_colorMult, ref m_colorAdd, colorTransform); if (m_colorMult.a <= 0) return; if (m_context.premultipliedAlpha) { m_colorMult.r *= m_colorMult.a; m_colorMult.g *= m_colorMult.a; m_colorMult.b *= m_colorMult.a; } factory.ConvertMatrix(ref m_matrix, matrix, 1, renderingCount - renderingIndex, m_context.height); Factory.MultiplyMatrix(ref m_renderMatrix, factory.gameObject.transform.localToWorldMatrix, m_matrix); m_property.Clear(); m_property.AddColor("_Color", m_colorMult); if (factory.useAdditionalColor) m_property.AddColor("_AdditionalColor", m_colorAdd); if (factory.blendMode == (int)Format.Constant.BLEND_MODE_ADD) { if (m_additiveMaterial == null) { m_additiveMaterial = new Material(m_context.material); m_additiveMaterial.shader = ResourceCache.SharedInstance().GetAdditiveShader( m_context.material.shader); } Graphics.DrawMesh(m_context.mesh, m_renderMatrix, m_additiveMaterial, factory.gameObject.layer, factory.camera, 0, m_property); } else { Graphics.DrawMesh(m_context.mesh, m_renderMatrix, m_context.material, factory.gameObject.layer, factory.camera, 0, m_property); } }
public override void Render(Matrix matrix, ColorTransform colorTransform, int renderingIndex, int renderingCount, bool visible) { #if UNITY_EDITOR m_visible = visible; #endif if (m_context == null || !visible) return; float scale = 1; if (m_context.systemFontRenderer != null) scale /= m_lwf.scaleByStage; Factory factory = m_context.factory; factory.ConvertMatrix(ref m_matrix, matrix, scale, m_shouldBeOnTop ? m_zOffset : renderingCount - renderingIndex); Factory.MultiplyMatrix(ref m_renderMatrix, m_context.parent.transform.localToWorldMatrix, m_matrix); factory.ConvertColorTransform( ref m_colorMult, ref m_colorAdd, colorTransform); m_context.Render(m_renderMatrix, m_colorMult, m_colorAdd, m_context.parent.layer, factory.camera); }
public override void Render(Matrix matrix, ColorTransform colorTransform, int renderingIndex, int renderingCount, bool visible) { // Ignore null texture #if UNITY_EDITOR m_visible = visible; #endif if (m_context == null || !visible) return; Factory factory = m_context.factory; factory.ConvertColorTransform( ref m_colorMult, ref m_colorAdd, colorTransform); if (m_colorMult.a <= 0) return; if (m_context.premultipliedAlpha) { m_colorMult.r *= m_colorMult.a; m_colorMult.g *= m_colorMult.a; m_colorMult.b *= m_colorMult.a; } factory.ConvertMatrix(ref m_matrix, matrix, 1, renderingCount - renderingIndex, m_context.height); Factory.MultiplyMatrix(ref m_renderMatrix, factory.gameObject.transform.localToWorldMatrix, m_matrix); m_property.Clear(); m_property.SetColor(m_colorId, m_colorMult); if (factory.useAdditionalColor) m_property.SetColor(m_additionalColorId, m_colorAdd); if (m_blendMode != factory.blendMode) { m_blendMode = factory.blendMode; if (m_material != null) { Material.Destroy(m_material); m_material = null; } m_material = ResourceCache.CreateBlendMaterial( m_context.material, m_context.premultipliedAlpha, m_blendMode); } Material material = m_material == null ? m_context.material : m_material; Graphics.DrawMesh(m_context.mesh, m_renderMatrix, material, factory.gameObject.layer, factory.renderCamera, 0, m_property); }
public override void Render(Matrix matrix, ColorTransform colorTransform, int renderingIndex, int renderingCount, bool visible) { // Ignore null texture if (m_context == null) return; if (!visible) return; Factory factory = m_context.factory; factory.ConvertColorTransform( ref m_colorMult, ref m_colorAdd, colorTransform); if (m_colorMult.a <= 0) return; if (m_context.premultipliedAlpha) { m_colorMult.r *= m_colorMult.a; m_colorMult.g *= m_colorMult.a; m_colorMult.b *= m_colorMult.a; } m_updated = m_matrix.SetWithComparing(matrix); int z = renderingCount - renderingIndex; if (m_z != z) { m_updated = true; m_z = z; } if (m_updated) { factory.ConvertMatrix( ref m_matrixForRender, matrix, 1, z, m_context.height); } if (m_blendMode != factory.blendMode) { m_blendMode = factory.blendMode; if (m_material != null) { Material.Destroy(m_material); m_material = null; } m_material = ResourceCache.CreateBlendMaterial( m_context.material, m_context.premultipliedAlpha, m_blendMode); } Material material = m_material == null ? m_context.material : m_material; factory.Render(this, 1, material, m_colorAdd); }
public BitmapRenderer(LWF lwf, BitmapContext context) : base(lwf) { m_context = context; m_matrix = new Matrix(0, 0, 0, 0, 0, 0); m_matrixForRender = new Matrix4x4(); m_colorMult = new UnityEngine.Color(); m_colorAdd = new UnityEngine.Color(); m_blendMode = (int)Format.Constant.BLEND_MODE_NORMAL; m_z = -1; m_updated = false; m_buffer = null; m_bufferIndex = -1; }