-
-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate tilemap editor icons properly (#1219)
* Replace AssetPreview with RuntimePreviewGenerator, update RuntimePreviewGenerator * Implement trojans * implement computer explosion * ObjectIcon shader
- Loading branch information
1 parent
798ef26
commit fb80904
Showing
5 changed files
with
734 additions
and
441 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
Assets/Content/Resources/Simple Toon/Shaders/ObjectIcon.shader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
Shader "Unlit/ObjectIcon" | ||
{ | ||
Properties | ||
{ | ||
_MainTex ("Base (RGB)", 2D) = "white" {} | ||
_EmissionMap ("Emission Map", 2D) = "black" {} | ||
[HDR]_EmissionColor ("Emission Color", Color) = (0,0,0,0) | ||
|
||
} | ||
|
||
SubShader | ||
{ | ||
Pass | ||
{ | ||
Tags{ "RenderType" = "Opaque" "Queue" = "Opaque" } | ||
CGPROGRAM | ||
#pragma vertex vert | ||
#pragma fragment frag | ||
#pragma target 2.0 | ||
#pragma multi_compile_fog | ||
|
||
#include "UnityCG.cginc" | ||
|
||
struct appdata_t { | ||
float4 vertex : POSITION; | ||
float2 texcoord : TEXCOORD0; | ||
float3 normal : NORMAL; | ||
}; | ||
|
||
struct v2f { | ||
float4 vertex : SV_POSITION; | ||
float2 texcoord : TEXCOORD0; | ||
half3 worldNormal : TEXCOORD1; | ||
float4 worldPos : TEXCOORD2; | ||
float3 viewDir : TEXCOORD3; | ||
}; | ||
|
||
sampler2D _MainTex; | ||
float4 _MainTex_ST; | ||
sampler2D _EmissionMap; | ||
float4 _EmissionColor; | ||
|
||
v2f vert (appdata_t v) | ||
{ | ||
v2f o; | ||
o.vertex = UnityObjectToClipPos(v.vertex); | ||
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex); | ||
o.worldNormal = UnityObjectToWorldNormal(v.normal); | ||
o.worldPos = mul(unity_ObjectToWorld, v.vertex); | ||
o.viewDir = WorldSpaceViewDir(v.vertex); | ||
return o; | ||
} | ||
|
||
fixed4 frag (v2f i) : SV_Target | ||
{ | ||
float3 viewDir = normalize(i.viewDir); | ||
fixed4 texColor = tex2D(_MainTex, i.texcoord); | ||
fixed4 emission = tex2D(_EmissionMap, i.texcoord) * _EmissionColor; | ||
|
||
float3 lightVector = (float3(-0.258, 0.22, 0.966)); | ||
|
||
float NdotL = dot(i.worldNormal, lightVector); | ||
float light = (smoothstep(0, 0.75, NdotL) * 0.525 + 0.475); | ||
float4 shadow = float4(0,0,0.04f,0) * (1 - light); | ||
|
||
|
||
// float4 rimDot = (1 - dot(viewDir, i.worldNormal)); | ||
// rimDot = (rimDot * rimDot * rimDot) * 0.15; | ||
|
||
fixed3 color = texColor.rgb * light + shadow + emission; | ||
fixed4 outcolor; | ||
outcolor.rgb = color.rgb; | ||
outcolor.a = texColor.a; | ||
return outcolor; | ||
} | ||
ENDCG | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
Assets/Content/Resources/Simple Toon/Shaders/ObjectIcon.shader.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.