<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — Outline shader for buildings]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=926&amp;type=atom" />
	<updated>2018-11-01T10:26:42Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=926</id>
		<entry>
			<title type="html"><![CDATA[Re: Outline shader for buildings]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=4140#p4140" />
			<content type="html"><![CDATA[<p>Thanks, this works perfect!</p>]]></content>
			<author>
				<name><![CDATA[Tim Reniers]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=829</uri>
			</author>
			<updated>2018-11-01T10:26:42Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=4140#p4140</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Outline shader for buildings]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=4136#p4136" />
			<content type="html"><![CDATA[<p>Something like that:<br /><a href="https://ibb.co/haJfdL"><span class="postimg"><img src="https://thumb.ibb.co/haJfdL/img1.png" alt="https://thumb.ibb.co/haJfdL/img1.png" /></span></a></p><div class="codebox"><pre><code>using UnityEngine;

public class FixBuildingUV : MonoBehaviour
{
    private void Start()
    {
        OnlineMapsBuildings.instance.OnBuildingCreated += OnBuildingCreated;
    }

    private void OnBuildingCreated(OnlineMapsBuildingBase building)
    {
        Renderer r = building.GetComponent&lt;Renderer&gt;();
        foreach (Material sharedMaterial in r.sharedMaterials) sharedMaterial.mainTextureScale = Vector2.one;

        MeshFilter meshFilter = building.GetComponent&lt;MeshFilter&gt;();
        Mesh mesh = meshFilter.sharedMesh;

        Vector2[] uv = mesh.uv;
        int[] ts = mesh.GetTriangles(0);

        for (int i = 0; i &lt; ts.Length; i += 6)
        {
            uv[ts[i + 2]] = Vector2.zero;
            uv[ts[i + 4]] = Vector2.right;
            uv[ts[i]] = Vector2.up;
            uv[ts[i + 1]] = Vector2.one;
        }

        mesh.uv = uv;
    }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2018-10-31T16:57:42Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=4136#p4136</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Outline shader for buildings]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=4134#p4134" />
			<content type="html"><![CDATA[<p>Here I the texture is use.</p>]]></content>
			<author>
				<name><![CDATA[Tim Reniers]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=829</uri>
			</author>
			<updated>2018-10-31T12:29:00Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=4134#p4134</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Outline shader for buildings]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=4133#p4133" />
			<content type="html"><![CDATA[<p>Thankyou for your answer.</p><p>Some free outline shaders do indeed work. But the result of those shaders is not what I&#039;m looking for because those shaders do not draw all the edges of an object at all time. What I try to achieve with my shader is that it gives the edges of an object/building a color and that it makes the rest of the object transparent, something comparable to a wireframe but then only draw the edges.</p><p>I&#039;m currently doing it by putting a texture onto the cube and changing its color of the texture if I want to. You can find my shader in the attachments. If you put this shader onto a material with the texture I will provide and use this material as roof and wall materials, you can see what it does (make sure the tile size of x and y of the texture inside the material is 1).</p><p>Thanks!</p>]]></content>
			<author>
				<name><![CDATA[Tim Reniers]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=829</uri>
			</author>
			<updated>2018-10-31T12:27:54Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=4133#p4133</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Outline shader for buildings]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=4124#p4124" />
			<content type="html"><![CDATA[<p>Hello.</p><p>I just tested some free outline shaders from the Asset Store and it works fine.<br />Most likely your shader is based on UV. I&#039;m right?<br />For a cube, each side has UV (0; 0) - (1; 1).<br />For a building, UV.x is stretched to the full length of the building.<br />So, for your shader you need to reassign UV for each point of the mesh.<br />This is most conveniently to make after the mesh of the building has been created (OnlineMapsBuildings.OnBuildingCreated)<br /><a href="http://infinity-code.com/doxygen/online-maps/classOnlineMapsBuildings.html#ab7bf6d7e6752f31dc2c93f72246c0d9e.">http://infinity-code.com/doxygen/online … 2246c0d9e.</a></p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2018-10-30T16:47:44Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=4124#p4124</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Outline shader for buildings]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=4121#p4121" />
			<content type="html"><![CDATA[<p>Hi,</p><p>I&#039;m trying to make an outline effect on the buildings with a shader. It works perfectly fine on a cube but when I add the roof and wall materials (with the same shader as used on the cube) on the buildings script it does not seem to work. I don&#039;t really know how the buildings are created and how the materials are added to the buildings but it seems that a building and a cube have a comparable mesh so I don&#039;t know why it&#039;s not working.</p><p>Is there anyone that has done this before or knows how the materials/meshes/textures work with adding them to the buildings?</p><p>(Cube is on the left, one of the generated buildings is on the right. As you can see not all the edges are filled with the material like with the cube.)</p><p>Thanks!</p>]]></content>
			<author>
				<name><![CDATA[Tim Reniers]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=829</uri>
			</author>
			<updated>2018-10-30T13:53:04Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=4121#p4121</id>
		</entry>
</feed>
