diff --git a/Assets/IsoMat.mat b/Assets/IsoMat.mat new file mode 100755 index 0000000..b4474a2 --- /dev/null +++ b/Assets/IsoMat.mat @@ -0,0 +1,79 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: IsoMat + m_Shader: {fileID: 4800000, guid: 49548229fe6f1b545b094ac291857ea6, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: c86083660b07d414585b69e41afd3cb8, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _TextureScale: 0.1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _CenterPoint: {r: 0, g: 0, b: 0, a: 0} + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _TextureOffset: {r: 0, g: 0, b: 0, a: 0} diff --git a/Assets/IsoMat.mat b/Assets/IsoMat.mat new file mode 100755 index 0000000..b4474a2 --- /dev/null +++ b/Assets/IsoMat.mat @@ -0,0 +1,79 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: IsoMat + m_Shader: {fileID: 4800000, guid: 49548229fe6f1b545b094ac291857ea6, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: c86083660b07d414585b69e41afd3cb8, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _TextureScale: 0.1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _CenterPoint: {r: 0, g: 0, b: 0, a: 0} + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _TextureOffset: {r: 0, g: 0, b: 0, a: 0} diff --git a/Assets/IsoMat.mat.meta b/Assets/IsoMat.mat.meta new file mode 100755 index 0000000..85330fb --- /dev/null +++ b/Assets/IsoMat.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 45357dd64e40db1438d86976e32203aa +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/IsoMat.mat b/Assets/IsoMat.mat new file mode 100755 index 0000000..b4474a2 --- /dev/null +++ b/Assets/IsoMat.mat @@ -0,0 +1,79 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: IsoMat + m_Shader: {fileID: 4800000, guid: 49548229fe6f1b545b094ac291857ea6, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: c86083660b07d414585b69e41afd3cb8, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _TextureScale: 0.1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _CenterPoint: {r: 0, g: 0, b: 0, a: 0} + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _TextureOffset: {r: 0, g: 0, b: 0, a: 0} diff --git a/Assets/IsoMat.mat.meta b/Assets/IsoMat.mat.meta new file mode 100755 index 0000000..85330fb --- /dev/null +++ b/Assets/IsoMat.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 45357dd64e40db1438d86976e32203aa +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/IsoObject.cs b/Assets/IsoObject.cs index 0f593ce..3fa158d 100755 --- a/Assets/IsoObject.cs +++ b/Assets/IsoObject.cs @@ -2,10 +2,11 @@ using System.Collections.Generic; using UnityEngine; +[ExecuteInEditMode] public class IsoObject : MonoBehaviour { public Camera IsoCamera; - private Material isoMaterial; + public List IsoMeshes; // Use this for initialization void Start () { @@ -15,10 +16,13 @@ void Update () { } - + void LateUpdate() { Vector3 viewPos = IsoCamera.WorldToViewportPoint(gameObject.transform.position); - isoMaterial.SetVector("_CenterPoint", new Vector4(viewPos.x, viewPos.y)); + foreach (MeshRenderer mr in IsoMeshes) + { + mr.material.SetVector("_CenterPoint", new Vector4(viewPos.x, viewPos.y)); + } } } diff --git a/Assets/IsoMat.mat b/Assets/IsoMat.mat new file mode 100755 index 0000000..b4474a2 --- /dev/null +++ b/Assets/IsoMat.mat @@ -0,0 +1,79 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: IsoMat + m_Shader: {fileID: 4800000, guid: 49548229fe6f1b545b094ac291857ea6, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: c86083660b07d414585b69e41afd3cb8, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _TextureScale: 0.1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _CenterPoint: {r: 0, g: 0, b: 0, a: 0} + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _TextureOffset: {r: 0, g: 0, b: 0, a: 0} diff --git a/Assets/IsoMat.mat.meta b/Assets/IsoMat.mat.meta new file mode 100755 index 0000000..85330fb --- /dev/null +++ b/Assets/IsoMat.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 45357dd64e40db1438d86976e32203aa +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/IsoObject.cs b/Assets/IsoObject.cs index 0f593ce..3fa158d 100755 --- a/Assets/IsoObject.cs +++ b/Assets/IsoObject.cs @@ -2,10 +2,11 @@ using System.Collections.Generic; using UnityEngine; +[ExecuteInEditMode] public class IsoObject : MonoBehaviour { public Camera IsoCamera; - private Material isoMaterial; + public List IsoMeshes; // Use this for initialization void Start () { @@ -15,10 +16,13 @@ void Update () { } - + void LateUpdate() { Vector3 viewPos = IsoCamera.WorldToViewportPoint(gameObject.transform.position); - isoMaterial.SetVector("_CenterPoint", new Vector4(viewPos.x, viewPos.y)); + foreach (MeshRenderer mr in IsoMeshes) + { + mr.material.SetVector("_CenterPoint", new Vector4(viewPos.x, viewPos.y)); + } } } diff --git a/Assets/IsoShader.shader b/Assets/IsoShader.shader new file mode 100755 index 0000000..73db29a --- /dev/null +++ b/Assets/IsoShader.shader @@ -0,0 +1,70 @@ +Shader "Unlit/IsoShader" +{ + Properties + { + _MainTex ("Texture", 2D) = "white" {} + _CenterPoint ("Object Center", Vector) = (0,0,0,0) + _TextureOffset("Texture Offset", Vector) = (0,0,0,0) + _TextureScale("Texture Scale", Float) = 1 + } + SubShader + { + Tags { "RenderType"="Opaque" } + LOD 100 + + Pass + { + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + // make fog work + #pragma multi_compile_fog + + #include "UnityCG.cginc" + + struct appdata + { + float4 vertex : POSITION; + float2 uv : TEXCOORD0; + }; + + struct v2f + { + float2 uv : TEXCOORD0; + UNITY_FOG_COORDS(1) + float4 vertex : SV_POSITION; + float4 screenPos : TEXCOORD1; + }; + + sampler2D _MainTex; + float4 _MainTex_ST; + float4 _MainTex_TexelSize; + + float4 _CenterPoint; + float4 _TextureOffset; + float _TextureScale; + + v2f vert (appdata v) + { + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.uv = TRANSFORM_TEX(v.uv, _MainTex); + o.screenPos = ComputeScreenPos(o.vertex) + UNITY_TRANSFER_FOG(o,o.vertex); + return o; + } + + fixed4 frag (v2f i) : SV_Target + { + // sample the texture + fixed4 col = tex2D(_MainTex, (i.screenPos.xy - _CenterPoint.xy - _TextureOffset.xy * _MainTex_TexelSize.xy) / _TextureScale); + + // apply fog + //UNITY_APPLY_FOG(i.fogCoord, col); + + return col; + } + ENDCG + } + } +} diff --git a/Assets/IsoMat.mat b/Assets/IsoMat.mat new file mode 100755 index 0000000..b4474a2 --- /dev/null +++ b/Assets/IsoMat.mat @@ -0,0 +1,79 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: IsoMat + m_Shader: {fileID: 4800000, guid: 49548229fe6f1b545b094ac291857ea6, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: c86083660b07d414585b69e41afd3cb8, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _TextureScale: 0.1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _CenterPoint: {r: 0, g: 0, b: 0, a: 0} + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _TextureOffset: {r: 0, g: 0, b: 0, a: 0} diff --git a/Assets/IsoMat.mat.meta b/Assets/IsoMat.mat.meta new file mode 100755 index 0000000..85330fb --- /dev/null +++ b/Assets/IsoMat.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 45357dd64e40db1438d86976e32203aa +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/IsoObject.cs b/Assets/IsoObject.cs index 0f593ce..3fa158d 100755 --- a/Assets/IsoObject.cs +++ b/Assets/IsoObject.cs @@ -2,10 +2,11 @@ using System.Collections.Generic; using UnityEngine; +[ExecuteInEditMode] public class IsoObject : MonoBehaviour { public Camera IsoCamera; - private Material isoMaterial; + public List IsoMeshes; // Use this for initialization void Start () { @@ -15,10 +16,13 @@ void Update () { } - + void LateUpdate() { Vector3 viewPos = IsoCamera.WorldToViewportPoint(gameObject.transform.position); - isoMaterial.SetVector("_CenterPoint", new Vector4(viewPos.x, viewPos.y)); + foreach (MeshRenderer mr in IsoMeshes) + { + mr.material.SetVector("_CenterPoint", new Vector4(viewPos.x, viewPos.y)); + } } } diff --git a/Assets/IsoShader.shader b/Assets/IsoShader.shader new file mode 100755 index 0000000..73db29a --- /dev/null +++ b/Assets/IsoShader.shader @@ -0,0 +1,70 @@ +Shader "Unlit/IsoShader" +{ + Properties + { + _MainTex ("Texture", 2D) = "white" {} + _CenterPoint ("Object Center", Vector) = (0,0,0,0) + _TextureOffset("Texture Offset", Vector) = (0,0,0,0) + _TextureScale("Texture Scale", Float) = 1 + } + SubShader + { + Tags { "RenderType"="Opaque" } + LOD 100 + + Pass + { + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + // make fog work + #pragma multi_compile_fog + + #include "UnityCG.cginc" + + struct appdata + { + float4 vertex : POSITION; + float2 uv : TEXCOORD0; + }; + + struct v2f + { + float2 uv : TEXCOORD0; + UNITY_FOG_COORDS(1) + float4 vertex : SV_POSITION; + float4 screenPos : TEXCOORD1; + }; + + sampler2D _MainTex; + float4 _MainTex_ST; + float4 _MainTex_TexelSize; + + float4 _CenterPoint; + float4 _TextureOffset; + float _TextureScale; + + v2f vert (appdata v) + { + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.uv = TRANSFORM_TEX(v.uv, _MainTex); + o.screenPos = ComputeScreenPos(o.vertex) + UNITY_TRANSFER_FOG(o,o.vertex); + return o; + } + + fixed4 frag (v2f i) : SV_Target + { + // sample the texture + fixed4 col = tex2D(_MainTex, (i.screenPos.xy - _CenterPoint.xy - _TextureOffset.xy * _MainTex_TexelSize.xy) / _TextureScale); + + // apply fog + //UNITY_APPLY_FOG(i.fogCoord, col); + + return col; + } + ENDCG + } + } +} diff --git a/Assets/IsoShader.shader.meta b/Assets/IsoShader.shader.meta new file mode 100755 index 0000000..beb05fb --- /dev/null +++ b/Assets/IsoShader.shader.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 49548229fe6f1b545b094ac291857ea6 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/IsoMat.mat b/Assets/IsoMat.mat new file mode 100755 index 0000000..b4474a2 --- /dev/null +++ b/Assets/IsoMat.mat @@ -0,0 +1,79 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: IsoMat + m_Shader: {fileID: 4800000, guid: 49548229fe6f1b545b094ac291857ea6, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: c86083660b07d414585b69e41afd3cb8, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _TextureScale: 0.1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _CenterPoint: {r: 0, g: 0, b: 0, a: 0} + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _TextureOffset: {r: 0, g: 0, b: 0, a: 0} diff --git a/Assets/IsoMat.mat.meta b/Assets/IsoMat.mat.meta new file mode 100755 index 0000000..85330fb --- /dev/null +++ b/Assets/IsoMat.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 45357dd64e40db1438d86976e32203aa +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/IsoObject.cs b/Assets/IsoObject.cs index 0f593ce..3fa158d 100755 --- a/Assets/IsoObject.cs +++ b/Assets/IsoObject.cs @@ -2,10 +2,11 @@ using System.Collections.Generic; using UnityEngine; +[ExecuteInEditMode] public class IsoObject : MonoBehaviour { public Camera IsoCamera; - private Material isoMaterial; + public List IsoMeshes; // Use this for initialization void Start () { @@ -15,10 +16,13 @@ void Update () { } - + void LateUpdate() { Vector3 viewPos = IsoCamera.WorldToViewportPoint(gameObject.transform.position); - isoMaterial.SetVector("_CenterPoint", new Vector4(viewPos.x, viewPos.y)); + foreach (MeshRenderer mr in IsoMeshes) + { + mr.material.SetVector("_CenterPoint", new Vector4(viewPos.x, viewPos.y)); + } } } diff --git a/Assets/IsoShader.shader b/Assets/IsoShader.shader new file mode 100755 index 0000000..73db29a --- /dev/null +++ b/Assets/IsoShader.shader @@ -0,0 +1,70 @@ +Shader "Unlit/IsoShader" +{ + Properties + { + _MainTex ("Texture", 2D) = "white" {} + _CenterPoint ("Object Center", Vector) = (0,0,0,0) + _TextureOffset("Texture Offset", Vector) = (0,0,0,0) + _TextureScale("Texture Scale", Float) = 1 + } + SubShader + { + Tags { "RenderType"="Opaque" } + LOD 100 + + Pass + { + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + // make fog work + #pragma multi_compile_fog + + #include "UnityCG.cginc" + + struct appdata + { + float4 vertex : POSITION; + float2 uv : TEXCOORD0; + }; + + struct v2f + { + float2 uv : TEXCOORD0; + UNITY_FOG_COORDS(1) + float4 vertex : SV_POSITION; + float4 screenPos : TEXCOORD1; + }; + + sampler2D _MainTex; + float4 _MainTex_ST; + float4 _MainTex_TexelSize; + + float4 _CenterPoint; + float4 _TextureOffset; + float _TextureScale; + + v2f vert (appdata v) + { + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.uv = TRANSFORM_TEX(v.uv, _MainTex); + o.screenPos = ComputeScreenPos(o.vertex) + UNITY_TRANSFER_FOG(o,o.vertex); + return o; + } + + fixed4 frag (v2f i) : SV_Target + { + // sample the texture + fixed4 col = tex2D(_MainTex, (i.screenPos.xy - _CenterPoint.xy - _TextureOffset.xy * _MainTex_TexelSize.xy) / _TextureScale); + + // apply fog + //UNITY_APPLY_FOG(i.fogCoord, col); + + return col; + } + ENDCG + } + } +} diff --git a/Assets/IsoShader.shader.meta b/Assets/IsoShader.shader.meta new file mode 100755 index 0000000..beb05fb --- /dev/null +++ b/Assets/IsoShader.shader.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 49548229fe6f1b545b094ac291857ea6 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Textures.meta b/Assets/Textures.meta new file mode 100755 index 0000000..28b1066 --- /dev/null +++ b/Assets/Textures.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 87aec6870f24a624591d9e427bb44f47 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/IsoMat.mat b/Assets/IsoMat.mat new file mode 100755 index 0000000..b4474a2 --- /dev/null +++ b/Assets/IsoMat.mat @@ -0,0 +1,79 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: IsoMat + m_Shader: {fileID: 4800000, guid: 49548229fe6f1b545b094ac291857ea6, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: c86083660b07d414585b69e41afd3cb8, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _TextureScale: 0.1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _CenterPoint: {r: 0, g: 0, b: 0, a: 0} + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _TextureOffset: {r: 0, g: 0, b: 0, a: 0} diff --git a/Assets/IsoMat.mat.meta b/Assets/IsoMat.mat.meta new file mode 100755 index 0000000..85330fb --- /dev/null +++ b/Assets/IsoMat.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 45357dd64e40db1438d86976e32203aa +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/IsoObject.cs b/Assets/IsoObject.cs index 0f593ce..3fa158d 100755 --- a/Assets/IsoObject.cs +++ b/Assets/IsoObject.cs @@ -2,10 +2,11 @@ using System.Collections.Generic; using UnityEngine; +[ExecuteInEditMode] public class IsoObject : MonoBehaviour { public Camera IsoCamera; - private Material isoMaterial; + public List IsoMeshes; // Use this for initialization void Start () { @@ -15,10 +16,13 @@ void Update () { } - + void LateUpdate() { Vector3 viewPos = IsoCamera.WorldToViewportPoint(gameObject.transform.position); - isoMaterial.SetVector("_CenterPoint", new Vector4(viewPos.x, viewPos.y)); + foreach (MeshRenderer mr in IsoMeshes) + { + mr.material.SetVector("_CenterPoint", new Vector4(viewPos.x, viewPos.y)); + } } } diff --git a/Assets/IsoShader.shader b/Assets/IsoShader.shader new file mode 100755 index 0000000..73db29a --- /dev/null +++ b/Assets/IsoShader.shader @@ -0,0 +1,70 @@ +Shader "Unlit/IsoShader" +{ + Properties + { + _MainTex ("Texture", 2D) = "white" {} + _CenterPoint ("Object Center", Vector) = (0,0,0,0) + _TextureOffset("Texture Offset", Vector) = (0,0,0,0) + _TextureScale("Texture Scale", Float) = 1 + } + SubShader + { + Tags { "RenderType"="Opaque" } + LOD 100 + + Pass + { + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + // make fog work + #pragma multi_compile_fog + + #include "UnityCG.cginc" + + struct appdata + { + float4 vertex : POSITION; + float2 uv : TEXCOORD0; + }; + + struct v2f + { + float2 uv : TEXCOORD0; + UNITY_FOG_COORDS(1) + float4 vertex : SV_POSITION; + float4 screenPos : TEXCOORD1; + }; + + sampler2D _MainTex; + float4 _MainTex_ST; + float4 _MainTex_TexelSize; + + float4 _CenterPoint; + float4 _TextureOffset; + float _TextureScale; + + v2f vert (appdata v) + { + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.uv = TRANSFORM_TEX(v.uv, _MainTex); + o.screenPos = ComputeScreenPos(o.vertex) + UNITY_TRANSFER_FOG(o,o.vertex); + return o; + } + + fixed4 frag (v2f i) : SV_Target + { + // sample the texture + fixed4 col = tex2D(_MainTex, (i.screenPos.xy - _CenterPoint.xy - _TextureOffset.xy * _MainTex_TexelSize.xy) / _TextureScale); + + // apply fog + //UNITY_APPLY_FOG(i.fogCoord, col); + + return col; + } + ENDCG + } + } +} diff --git a/Assets/IsoShader.shader.meta b/Assets/IsoShader.shader.meta new file mode 100755 index 0000000..beb05fb --- /dev/null +++ b/Assets/IsoShader.shader.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 49548229fe6f1b545b094ac291857ea6 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Textures.meta b/Assets/Textures.meta new file mode 100755 index 0000000..28b1066 --- /dev/null +++ b/Assets/Textures.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 87aec6870f24a624591d9e427bb44f47 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Textures/House_FallingLeaves.png b/Assets/Textures/House_FallingLeaves.png new file mode 100644 index 0000000..7c42a99 --- /dev/null +++ b/Assets/Textures/House_FallingLeaves.png Binary files differ diff --git a/Assets/IsoMat.mat b/Assets/IsoMat.mat new file mode 100755 index 0000000..b4474a2 --- /dev/null +++ b/Assets/IsoMat.mat @@ -0,0 +1,79 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: IsoMat + m_Shader: {fileID: 4800000, guid: 49548229fe6f1b545b094ac291857ea6, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: c86083660b07d414585b69e41afd3cb8, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _TextureScale: 0.1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _CenterPoint: {r: 0, g: 0, b: 0, a: 0} + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _TextureOffset: {r: 0, g: 0, b: 0, a: 0} diff --git a/Assets/IsoMat.mat.meta b/Assets/IsoMat.mat.meta new file mode 100755 index 0000000..85330fb --- /dev/null +++ b/Assets/IsoMat.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 45357dd64e40db1438d86976e32203aa +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/IsoObject.cs b/Assets/IsoObject.cs index 0f593ce..3fa158d 100755 --- a/Assets/IsoObject.cs +++ b/Assets/IsoObject.cs @@ -2,10 +2,11 @@ using System.Collections.Generic; using UnityEngine; +[ExecuteInEditMode] public class IsoObject : MonoBehaviour { public Camera IsoCamera; - private Material isoMaterial; + public List IsoMeshes; // Use this for initialization void Start () { @@ -15,10 +16,13 @@ void Update () { } - + void LateUpdate() { Vector3 viewPos = IsoCamera.WorldToViewportPoint(gameObject.transform.position); - isoMaterial.SetVector("_CenterPoint", new Vector4(viewPos.x, viewPos.y)); + foreach (MeshRenderer mr in IsoMeshes) + { + mr.material.SetVector("_CenterPoint", new Vector4(viewPos.x, viewPos.y)); + } } } diff --git a/Assets/IsoShader.shader b/Assets/IsoShader.shader new file mode 100755 index 0000000..73db29a --- /dev/null +++ b/Assets/IsoShader.shader @@ -0,0 +1,70 @@ +Shader "Unlit/IsoShader" +{ + Properties + { + _MainTex ("Texture", 2D) = "white" {} + _CenterPoint ("Object Center", Vector) = (0,0,0,0) + _TextureOffset("Texture Offset", Vector) = (0,0,0,0) + _TextureScale("Texture Scale", Float) = 1 + } + SubShader + { + Tags { "RenderType"="Opaque" } + LOD 100 + + Pass + { + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + // make fog work + #pragma multi_compile_fog + + #include "UnityCG.cginc" + + struct appdata + { + float4 vertex : POSITION; + float2 uv : TEXCOORD0; + }; + + struct v2f + { + float2 uv : TEXCOORD0; + UNITY_FOG_COORDS(1) + float4 vertex : SV_POSITION; + float4 screenPos : TEXCOORD1; + }; + + sampler2D _MainTex; + float4 _MainTex_ST; + float4 _MainTex_TexelSize; + + float4 _CenterPoint; + float4 _TextureOffset; + float _TextureScale; + + v2f vert (appdata v) + { + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.uv = TRANSFORM_TEX(v.uv, _MainTex); + o.screenPos = ComputeScreenPos(o.vertex) + UNITY_TRANSFER_FOG(o,o.vertex); + return o; + } + + fixed4 frag (v2f i) : SV_Target + { + // sample the texture + fixed4 col = tex2D(_MainTex, (i.screenPos.xy - _CenterPoint.xy - _TextureOffset.xy * _MainTex_TexelSize.xy) / _TextureScale); + + // apply fog + //UNITY_APPLY_FOG(i.fogCoord, col); + + return col; + } + ENDCG + } + } +} diff --git a/Assets/IsoShader.shader.meta b/Assets/IsoShader.shader.meta new file mode 100755 index 0000000..beb05fb --- /dev/null +++ b/Assets/IsoShader.shader.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 49548229fe6f1b545b094ac291857ea6 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Textures.meta b/Assets/Textures.meta new file mode 100755 index 0000000..28b1066 --- /dev/null +++ b/Assets/Textures.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 87aec6870f24a624591d9e427bb44f47 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Textures/House_FallingLeaves.png b/Assets/Textures/House_FallingLeaves.png new file mode 100644 index 0000000..7c42a99 --- /dev/null +++ b/Assets/Textures/House_FallingLeaves.png Binary files differ diff --git a/Assets/Textures/House_FallingLeaves.png.meta b/Assets/Textures/House_FallingLeaves.png.meta new file mode 100755 index 0000000..b864809 --- /dev/null +++ b/Assets/Textures/House_FallingLeaves.png.meta @@ -0,0 +1,76 @@ +fileFormatVersion: 2 +guid: c86083660b07d414585b69e41afd3cb8 +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 4 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/IsoMat.mat b/Assets/IsoMat.mat new file mode 100755 index 0000000..b4474a2 --- /dev/null +++ b/Assets/IsoMat.mat @@ -0,0 +1,79 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: IsoMat + m_Shader: {fileID: 4800000, guid: 49548229fe6f1b545b094ac291857ea6, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: c86083660b07d414585b69e41afd3cb8, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _TextureScale: 0.1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _CenterPoint: {r: 0, g: 0, b: 0, a: 0} + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _TextureOffset: {r: 0, g: 0, b: 0, a: 0} diff --git a/Assets/IsoMat.mat.meta b/Assets/IsoMat.mat.meta new file mode 100755 index 0000000..85330fb --- /dev/null +++ b/Assets/IsoMat.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 45357dd64e40db1438d86976e32203aa +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/IsoObject.cs b/Assets/IsoObject.cs index 0f593ce..3fa158d 100755 --- a/Assets/IsoObject.cs +++ b/Assets/IsoObject.cs @@ -2,10 +2,11 @@ using System.Collections.Generic; using UnityEngine; +[ExecuteInEditMode] public class IsoObject : MonoBehaviour { public Camera IsoCamera; - private Material isoMaterial; + public List IsoMeshes; // Use this for initialization void Start () { @@ -15,10 +16,13 @@ void Update () { } - + void LateUpdate() { Vector3 viewPos = IsoCamera.WorldToViewportPoint(gameObject.transform.position); - isoMaterial.SetVector("_CenterPoint", new Vector4(viewPos.x, viewPos.y)); + foreach (MeshRenderer mr in IsoMeshes) + { + mr.material.SetVector("_CenterPoint", new Vector4(viewPos.x, viewPos.y)); + } } } diff --git a/Assets/IsoShader.shader b/Assets/IsoShader.shader new file mode 100755 index 0000000..73db29a --- /dev/null +++ b/Assets/IsoShader.shader @@ -0,0 +1,70 @@ +Shader "Unlit/IsoShader" +{ + Properties + { + _MainTex ("Texture", 2D) = "white" {} + _CenterPoint ("Object Center", Vector) = (0,0,0,0) + _TextureOffset("Texture Offset", Vector) = (0,0,0,0) + _TextureScale("Texture Scale", Float) = 1 + } + SubShader + { + Tags { "RenderType"="Opaque" } + LOD 100 + + Pass + { + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + // make fog work + #pragma multi_compile_fog + + #include "UnityCG.cginc" + + struct appdata + { + float4 vertex : POSITION; + float2 uv : TEXCOORD0; + }; + + struct v2f + { + float2 uv : TEXCOORD0; + UNITY_FOG_COORDS(1) + float4 vertex : SV_POSITION; + float4 screenPos : TEXCOORD1; + }; + + sampler2D _MainTex; + float4 _MainTex_ST; + float4 _MainTex_TexelSize; + + float4 _CenterPoint; + float4 _TextureOffset; + float _TextureScale; + + v2f vert (appdata v) + { + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.uv = TRANSFORM_TEX(v.uv, _MainTex); + o.screenPos = ComputeScreenPos(o.vertex) + UNITY_TRANSFER_FOG(o,o.vertex); + return o; + } + + fixed4 frag (v2f i) : SV_Target + { + // sample the texture + fixed4 col = tex2D(_MainTex, (i.screenPos.xy - _CenterPoint.xy - _TextureOffset.xy * _MainTex_TexelSize.xy) / _TextureScale); + + // apply fog + //UNITY_APPLY_FOG(i.fogCoord, col); + + return col; + } + ENDCG + } + } +} diff --git a/Assets/IsoShader.shader.meta b/Assets/IsoShader.shader.meta new file mode 100755 index 0000000..beb05fb --- /dev/null +++ b/Assets/IsoShader.shader.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 49548229fe6f1b545b094ac291857ea6 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Textures.meta b/Assets/Textures.meta new file mode 100755 index 0000000..28b1066 --- /dev/null +++ b/Assets/Textures.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 87aec6870f24a624591d9e427bb44f47 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Textures/House_FallingLeaves.png b/Assets/Textures/House_FallingLeaves.png new file mode 100644 index 0000000..7c42a99 --- /dev/null +++ b/Assets/Textures/House_FallingLeaves.png Binary files differ diff --git a/Assets/Textures/House_FallingLeaves.png.meta b/Assets/Textures/House_FallingLeaves.png.meta new file mode 100755 index 0000000..b864809 --- /dev/null +++ b/Assets/Textures/House_FallingLeaves.png.meta @@ -0,0 +1,76 @@ +fileFormatVersion: 2 +guid: c86083660b07d414585b69e41afd3cb8 +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 4 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/main.unity b/Assets/main.unity index 104fd8d..4d38d18 100755 --- a/Assets/main.unity +++ b/Assets/main.unity @@ -125,7 +125,7 @@ - component: {fileID: 516672266} - component: {fileID: 516672265} m_Layer: 0 - m_Name: Cube + m_Name: Mesh m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -145,7 +145,7 @@ m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 1639333834} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -191,10 +191,10 @@ m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 516672264} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} + m_LocalPosition: {x: -0.54, y: -0.23, z: 1.26} + m_LocalScale: {x: 0.7618044, y: 0.59613603, z: 1.8864031} m_Children: [] - m_Father: {fileID: 1707129768} + m_Father: {fileID: 1646089004} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &868025610 @@ -359,20 +359,20 @@ m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1211379094} - m_Enabled: 1 + m_Enabled: 0 --- !u!4 &1211379098 Transform: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1211379094} - m_LocalRotation: {x: 0.30070576, y: 0, z: 0, w: 0.953717} + m_LocalRotation: {x: 0.20791169, y: 0, z: 0, w: 0.9781476} m_LocalPosition: {x: 0, y: 7.41, z: -10.48} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 35, y: 0, z: 0} + m_LocalEulerAnglesHint: {x: 24, y: 0, z: 0} --- !u!1 &1493590970 GameObject: m_ObjectHideFlags: 0 @@ -414,6 +414,127 @@ m_Father: {fileID: 0} m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!21 &1639333834 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: IsoMat (Instance) + m_Shader: {fileID: 4800000, guid: 49548229fe6f1b545b094ac291857ea6, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: c86083660b07d414585b69e41afd3cb8, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _TextureScale: 0.1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _CenterPoint: {r: 0.5, g: 0.2493228, b: 0, a: 0} + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _TextureOffset: {r: -215, g: -628, b: 0, a: 0} +--- !u!1 &1646089003 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 1646089004} + - component: {fileID: 1646089005} + m_Layer: 0 + m_Name: IsoHouse + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1646089004 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1646089003} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 516672268} + m_Father: {fileID: 1707129768} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1646089005 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1646089003} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: bcdae60ce96b110429adb0dc2736286a, type: 3} + m_Name: + m_EditorClassIdentifier: + IsoCamera: {fileID: 1211379095} + IsoMeshes: + - {fileID: 516672265} --- !u!1 &1707129767 GameObject: m_ObjectHideFlags: 0 @@ -439,7 +560,7 @@ m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - - {fileID: 516672268} + - {fileID: 1646089004} m_Father: {fileID: 0} m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 45, z: 0}