Skip to content

Commit

Permalink
Update materials and AtlasNormalShader for ColorDNA
Browse files Browse the repository at this point in the history
  • Loading branch information
davidosullivan committed Nov 10, 2018
1 parent f58f759 commit c3b5493
Show file tree
Hide file tree
Showing 18 changed files with 200 additions and 84 deletions.
Binary file not shown.
Expand Up @@ -19,7 +19,7 @@ MonoBehaviour:
materialPropertyName: _MainTex
sourceTextureName:
- channelType: 1
textureFormat: 0
textureFormat: 2
materialPropertyName: _BumpMap
sourceTextureName:
- channelType: 0
Expand Down
Expand Up @@ -19,7 +19,7 @@ MonoBehaviour:
materialPropertyName: _MainTex
sourceTextureName:
- channelType: 1
textureFormat: 0
textureFormat: 2
materialPropertyName: _BumpMap
sourceTextureName:
clothProperties: {fileID: 0}
Expand Down
Expand Up @@ -19,7 +19,7 @@ MonoBehaviour:
materialPropertyName: _MainTex
sourceTextureName:
- channelType: 1
textureFormat: 0
textureFormat: 2
materialPropertyName: _BumpMap
sourceTextureName:
- channelType: 0
Expand Down
Expand Up @@ -25,7 +25,7 @@ Shader "UMA/Hair Fade Cutout"

SubShader
{
Tags{ "RenderType" = "TransparentCutout" "Queue" = "Transparent" }
Tags{ "RenderType" = "TransparentCutout" "Queue" = "AlphaTest+0" }
Cull Back
CGINCLUDE
#include "UnityStandardUtils.cginc"
Expand Down Expand Up @@ -70,7 +70,7 @@ Shader "UMA/Hair Fade Cutout"

ENDCG

Tags{ "RenderType" = "Transparent" "Queue" = "Transparent+10" "IgnoreProjector" = "True" }
Tags{ "RenderType" = "Transparent" "Queue" = "Transparent+0" "IgnoreProjector" = "True" }
Cull Off
CGINCLUDE
#include "UnityStandardUtils.cginc"
Expand Down
Expand Up @@ -23,7 +23,7 @@ Shader "UMA/Hair Fade2 Cutout"

SubShader
{
Tags{ "RenderType" = "TransparentCutout" "Queue" = "Transparent" }
Tags{ "RenderType" = "TransparentCutout" "Queue" = "AlphaTest+0" }
Cull Back
CGINCLUDE
#include "UnityStandardUtils.cginc"
Expand Down Expand Up @@ -69,7 +69,7 @@ Shader "UMA/Hair Fade2 Cutout"

ENDCG

Tags{ "RenderType" = "Transparent" "Queue" = "Transparent+10" "IgnoreProjector" = "True" }
Tags{ "RenderType" = "Transparent" "Queue" = "Transparent+0" "IgnoreProjector" = "True" }
Cull Back
CGINCLUDE
#include "UnityStandardUtils.cginc"
Expand Down
Expand Up @@ -23,7 +23,7 @@ Shader "UMA/Hair Fade Cutout (Single Sided)"

SubShader
{
Tags{ "RenderType" = "TransparentCutout" "Queue" = "Transparent" }
Tags{ "RenderType" = "TransparentCutout" "Queue" = "AlphaTest+0" }
Cull Back
CGINCLUDE
#include "UnityStandardUtils.cginc"
Expand Down Expand Up @@ -69,7 +69,7 @@ Shader "UMA/Hair Fade Cutout (Single Sided)"

ENDCG

Tags{ "RenderType" = "Transparent" "Queue" = "Transparent+10" "IgnoreProjector" = "True" }
Tags{ "RenderType" = "Transparent" "Queue" = "Transparent+0" "IgnoreProjector" = "True" }
Cull Back
CGINCLUDE
#include "UnityStandardUtils.cginc"
Expand Down
Expand Up @@ -19,7 +19,7 @@ MonoBehaviour:
materialPropertyName: _MainTex
sourceTextureName:
- channelType: 1
textureFormat: 0
textureFormat: 2
materialPropertyName: _BumpMap
sourceTextureName:
- channelType: 0
Expand Down
Expand Up @@ -19,7 +19,7 @@ MonoBehaviour:
materialPropertyName: _MainTex
sourceTextureName:
- channelType: 1
textureFormat: 0
textureFormat: 2
materialPropertyName: _BumpMap
sourceTextureName:
- channelType: 0
Expand Down
Expand Up @@ -19,7 +19,7 @@ MonoBehaviour:
materialPropertyName: _MainTex
sourceTextureName:
- channelType: 1
textureFormat: 0
textureFormat: 2
materialPropertyName: _BumpMap
sourceTextureName:
- channelType: 0
Expand Down
Expand Up @@ -19,7 +19,7 @@ MonoBehaviour:
materialPropertyName: _MainTex
sourceTextureName:
- channelType: 1
textureFormat: 0
textureFormat: 2
materialPropertyName: _BumpMap
sourceTextureName:
- channelType: 0
Expand Down
Expand Up @@ -19,7 +19,7 @@ MonoBehaviour:
materialPropertyName: _MainTex
sourceTextureName:
- channelType: 1
textureFormat: 0
textureFormat: 2
materialPropertyName: _BumpMap
sourceTextureName:
- channelType: 0
Expand Down
Expand Up @@ -19,7 +19,7 @@ MonoBehaviour:
materialPropertyName: _MainTex
sourceTextureName:
- channelType: 1
textureFormat: 0
textureFormat: 2
materialPropertyName: _BumpMap
sourceTextureName:
- channelType: 0
Expand Down
Expand Up @@ -19,7 +19,7 @@ MonoBehaviour:
materialPropertyName: _MainTex
sourceTextureName:
- channelType: 1
textureFormat: 0
textureFormat: 2
materialPropertyName: _BumpMap
sourceTextureName:
- channelType: 0
Expand All @@ -28,6 +28,3 @@ MonoBehaviour:
sourceTextureName:
clothProperties: {fileID: 0}
RequireSeperateRenderer: 0
MipMapBias: 0
AnisoLevel: 1
MatFilterMode: 1
Expand Up @@ -19,7 +19,7 @@ MonoBehaviour:
materialPropertyName: _MainTex
sourceTextureName:
- channelType: 1
textureFormat: 0
textureFormat: 2
materialPropertyName: _BumpMap
sourceTextureName:
- channelType: 0
Expand Down
Expand Up @@ -13,87 +13,94 @@ Properties {
_ExtraTex ("mask", 2D) = "white" {}
}

SubShader {
SubShader
{
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}

GrabPass {}
Pass
{
{
Tags { "LightMode" = "Vertex" }
Fog { Mode Off }
Blend Zero SrcAlpha
Fog { Mode Off }
Blend off
Lighting Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
CGPROGRAM
#pragma vertex vert
#pragma fragment frag

#include "UnityCG.cginc"
#include "UnityCG.cginc"
#include "UnityStandardUtils.cginc"

float4 _Color;
float4 _AdditiveColor;
sampler2D _MainTex;
sampler2D _ExtraTex;
float4 _Color;
float4 _AdditiveColor;
sampler2D _MainTex;
sampler2D _ExtraTex;
sampler2D _GrabTexture;

struct v2f {
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
struct v2f {
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
float4 grabuv : TEXCOORD1;
};

float4 _MainTex_ST;
float4 _MainTex_ST;

v2f vert (appdata_base v)
{
v2f o;
o.pos = UnityObjectToClipPos (v.vertex);
o.uv = TRANSFORM_TEX (v.texcoord, _MainTex);
return o;
}
//http://blog.selfshadow.com/publications/blending-in-detail/

half4 frag (v2f i) : COLOR
{
half4 maskcol = tex2D (_ExtraTex, i.uv);
float value = 1 - maskcol.a;
return half4(value, value, value, value);
}
ENDCG
}
Pass
{
Tags { "LightMode" = "Vertex" }
Fog { Mode Off }
Blend One One
Lighting Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
float3 linearBlend(float3 n1, float3 n2, float t)
{
return normalize(lerp(n2, n1, t));
}

#include "UnityCG.cginc"
float3 pdBlend(float3 n1, float3 n2, float t)
{
float2 p1 = (n1.xy/n1.z);
float2 p2 = (n2.xy/n2.z);

float4 _Color;
float4 _AdditiveColor;
sampler2D _MainTex;
sampler2D _ExtraTex;
float2 pd = lerp(n2, n1, t);

struct v2f {
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
return normalize(float3(pd,1));
}

float4 _MainTex_ST;
v2f vert (appdata_base v)
{
v2f o;
o.pos = UnityObjectToClipPos (v.vertex);
o.uv = TRANSFORM_TEX (v.texcoord, _MainTex);
o.grabuv = ComputeGrabScreenPos(o.pos);
return o;
}

v2f vert (appdata_base v)
{
v2f o;
o.pos = UnityObjectToClipPos (v.vertex);
o.uv = TRANSFORM_TEX (v.texcoord, _MainTex);
return o;
}
half4 frag (v2f i) : COLOR
{
half3 n1 = UnpackNormal(tex2D(_MainTex, i.uv));
half3 n2 = UnpackNormal(tex2D(_GrabTexture, i.grabuv));

half4 frag (v2f i) : COLOR
{
half4 texcol = tex2D (_MainTex, i.uv) * _Color + _AdditiveColor;
half4 maskcol = tex2D (_ExtraTex, i.uv);
return texcol * maskcol.a;
}
half4 extra = tex2D(_ExtraTex, i.uv);

n1 = clamp(n1, -1, 1);
n2 = clamp(n2, -1, 1);

half t = min(extra.a, _Color.a);

//Add alpha check early out?

//float3 r = linearBlend(n1,n2);
half3 r = pdBlend(n1, n2, t);

//Bring normal back into packed range.
r = saturate(r * 0.5 + 0.5);

//G and A are the important ones.
//Setting green to red and blue just so it looks greyscale in the inspector.
//return half4(r.y,r.y,r.y,r.x);

#if defined(UNITY_NO_DXT5nm)
return half4(r.r, r.g, r.b, 0);
#else
return half4(1, r.y, 1, r.x);
#endif
}
ENDCG
}
}
Expand Down

0 comments on commit c3b5493

Please sign in to comment.