clean project
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
//
|
||||
// OvrAvatar eye lens shader
|
||||
//
|
||||
// Generates glint on the eye lens of expressive avatars
|
||||
//
|
||||
|
||||
Shader "OvrAvatar/Avatar_EyeLens"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Cube("Cubemap Reflection", CUBE) = "black" {}
|
||||
_ReflectionIntensity("Reflection Intensity", Range(0.0,1.0)) = 0.2
|
||||
_GlintStrength("Glint Strength", Range(0, 10)) = 1.57
|
||||
_GlintSpead("Glint Spead", Range(32, 2048)) = 600
|
||||
_Alpha("Alpha", Range(0.0,1.0)) = 1.0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags { "LightMode" = "ForwardBase" "Queue" = "Transparent" "RenderType" = "Transparent" "IgnoreProjector" = "True" }
|
||||
Pass
|
||||
{
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma target 3.0
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityLightingCommon.cginc"
|
||||
#include "AutoLight.cginc"
|
||||
|
||||
samplerCUBE _Cube;
|
||||
half _ReflectionIntensity;
|
||||
half _GlintStrength;
|
||||
half _GlintSpead;
|
||||
half _Alpha;
|
||||
|
||||
struct VertexInput
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
};
|
||||
|
||||
struct VertexOutput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float4 posWorld : TEXCOORD1;
|
||||
float3 normalDir : TEXCOORD2;
|
||||
};
|
||||
|
||||
VertexOutput vert(VertexInput v)
|
||||
{
|
||||
VertexOutput o = (VertexOutput)0;
|
||||
o.normalDir = UnityObjectToWorldNormal(v.normal);
|
||||
o.posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag(VertexOutput i) : COLOR
|
||||
{
|
||||
i.normalDir = normalize(i.normalDir);
|
||||
half3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
|
||||
half NdotLV = max(0, dot(i.normalDir, normalize(_WorldSpaceLightPos0.xyz + viewDirection)));
|
||||
half3 spec = pow(NdotLV, _GlintSpead) * _GlintStrength;
|
||||
|
||||
// Sample the default reflection cubemap using the reflection vector
|
||||
half3 viewReflectDirection = reflect(-viewDirection, i.normalDir);
|
||||
half4 skyData = UNITY_SAMPLE_TEXCUBE(unity_SpecCube0, viewReflectDirection);
|
||||
// Decode cubemap data into actual color
|
||||
half3 reflectionColor = DecodeHDR(skyData, unity_SpecCube0_HDR);
|
||||
|
||||
half4 finalColor;
|
||||
finalColor.rgb = reflectionColor.rgb * _ReflectionIntensity;
|
||||
finalColor.rgb += spec;
|
||||
finalColor.a = (finalColor.r + finalColor.g + finalColor.b) / 3;
|
||||
|
||||
return finalColor;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8392f54e79937ed4bb1b692a143dc02b
|
||||
timeCreated: 1539383496
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,280 @@
|
||||
//
|
||||
// OvrAvatar Mobile combined mesh expressive shader
|
||||
// For use on expressive face meshes
|
||||
// Texture array approach for rendering a combined mesh avatar with blend shape expression
|
||||
// Coupled with OvrAvatarMaterialManager to populate the texture arrays
|
||||
//
|
||||
// Unity vertex-fragnment implementation
|
||||
// Simplified lighting model recommended for use on mobile supporting one directional light
|
||||
// Surface shader recommended on PC
|
||||
//
|
||||
// Uses transparent queue for fade effects
|
||||
//
|
||||
// Color and appearance of the facial regions controlled via G&B channels in roughness texture
|
||||
// Pupil size controlled by manipulating UV coordinates
|
||||
//
|
||||
// Shader keywords:
|
||||
// - SECONDARY_LIGHT_ON SECONDARY_LIGHT_OFF
|
||||
// Enable SECONDARY_LIGHT_ON for a second "light" comprised of _SecondaryLightDirection and
|
||||
// _SecondaryLightColor This will influence the rim effect providing a lit contour to the avatar
|
||||
//
|
||||
|
||||
|
||||
Shader "OvrAvatar/Avatar_Mobile_CombinedMeshExpressive"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[NoScaleOffset] _MainTex("Main Texture Array", 2DArray) = "white" {}
|
||||
[NoScaleOffset] _NormalMap("Normal Map Array", 2DArray) = "bump" {}
|
||||
[NoScaleOffset] _RoughnessMap("Roughness Map Array", 2DArray) = "black" {}
|
||||
|
||||
_Dimmer("Dimmer", Range(0.0,1.0)) = 1.0
|
||||
_Alpha("Alpha", Range(0.0,1.0)) = 1.0
|
||||
|
||||
// Index into the texture array needs an offset for precision
|
||||
_Slices("Texture Array Slices", int) = 4.97
|
||||
|
||||
_PupilSize("Pupil Size", Range(-1, 2)) = 0
|
||||
_LipSmoothness("Lip Smoothness", Range(0, 1)) = 0
|
||||
|
||||
_MaskColorIris("Iris Color", Color) = (0.0,0.0,0.0,1.0)
|
||||
_MaskColorLips("Lips Color", Color) = (0.0,0.0,0.0,1.0)
|
||||
_MaskColorBrows("Brows Color", Color) = (0.0,0.0,0.0,1.0)
|
||||
_MaskColorLashes("Lashes Color", Color) = (0.0,0.0,0.0,1.0)
|
||||
_MaskColorSclera("Sclera Color", Color) = (0.0,0.0,0.0,1.0)
|
||||
_MaskColorGums("Gums Color", Color) = (0.0,0.0,0.0,1.0)
|
||||
_MaskColorTeeth("Teeth Color", Color) = (0.0,0.0,0.0,1.0)
|
||||
|
||||
[HideInInspector] _SrcBlend("", Float) = 1
|
||||
[HideInInspector] _DstBlend("", Float) = 0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags { "LightMode" = "ForwardBase" "IgnoreProjector" = "True"}
|
||||
Pass
|
||||
{
|
||||
Blend [_SrcBlend] [_DstBlend]
|
||||
Cull Back
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 3.5
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma multi_compile SECONDARY_LIGHT_OFF SECONDARY_LIGHT_ON
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityLightingCommon.cginc"
|
||||
|
||||
UNITY_DECLARE_TEX2DARRAY(_MainTex);
|
||||
UNITY_DECLARE_TEX2DARRAY(_NormalMap);
|
||||
float4 _NormalMap_ST;
|
||||
UNITY_DECLARE_TEX2DARRAY(_RoughnessMap);
|
||||
|
||||
int _Slices;
|
||||
|
||||
half _Dimmer;
|
||||
half _Alpha;
|
||||
|
||||
half4 _BaseColor[5];
|
||||
half _DiffuseIntensity[5];
|
||||
half _RimIntensity[5];
|
||||
half _ReflectionIntensity[5];
|
||||
|
||||
half3 _SecondaryLightDirection;
|
||||
half4 _SecondaryLightColor;
|
||||
|
||||
half _PupilSize;
|
||||
half _LipSmoothness;
|
||||
|
||||
fixed4 _MaskColorIris;
|
||||
fixed4 _MaskColorSclera;
|
||||
fixed4 _MaskColorBrows;
|
||||
fixed4 _MaskColorLashes;
|
||||
fixed4 _MaskColorLashesEnd;
|
||||
fixed4 _MaskColorLips;
|
||||
fixed4 _MaskColorGums;
|
||||
fixed4 _MaskColorTeeth;
|
||||
|
||||
static const int ONE = 1;
|
||||
static const fixed ALPHA_CLIP_THRESHOLD = 0.7;
|
||||
static const int IRIS_BRIGHTNESS_MODIFIER = 2;
|
||||
static const fixed SCLERA_BRIGHTNESS_MODIFIER = 1.2;
|
||||
static const fixed LIP_SMOOTHNESS_MULTIPLIER = 0.5;
|
||||
static const fixed LIP_SMOOTHNESS_MIN_NDOTL = 0.3;
|
||||
static const fixed BROWS_LASHES_DIFFUSEINTENSITY = ONE - 0.25;
|
||||
static const int COLOR_MULTIPLIER = 255;
|
||||
static const half2 PUPIL_CENTER_UV = half2(0.127, 0.1175);
|
||||
static const half DILATION_ENVELOPE = 0.024;
|
||||
static const half2 EYE_REGION_UV = PUPIL_CENTER_UV + DILATION_ENVELOPE;
|
||||
|
||||
static const int MASK_SLICE_SIZE = 17;
|
||||
static const half MASK_SLICE_THRESHOLD = MASK_SLICE_SIZE * 0.5f;
|
||||
static const int MASK_INDEX_IRIS = 255;
|
||||
static const int MASK_INDEX_SCLERA = 238;
|
||||
static const int MASK_INDEX_LASHES = 221;
|
||||
static const int MASK_INDEX_LIPS = 204;
|
||||
static const int MASK_INDEX_GUMS = 187;
|
||||
static const int MASK_INDEX_TEETH = 170;
|
||||
static const int MASK_INDEX_BROWS = 153;
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex: POSITION;
|
||||
float3 normal: NORMAL;
|
||||
float4 tangent: TANGENT;
|
||||
float2 texcoord: TEXCOORD0;
|
||||
float4 vertexColor : COLOR0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float3 uv : TEXCOORD0;
|
||||
float4 posWorld: TEXCOORD1;
|
||||
float3 normalDir: TEXCOORD2;
|
||||
float3 tangentDir: TEXCOORD3;
|
||||
float3 bitangentDir: TEXCOORD4;
|
||||
};
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
|
||||
// Calculate tangents for normal mapping
|
||||
o.normalDir = normalize(UnityObjectToWorldNormal(v.normal));
|
||||
o.tangentDir = normalize(mul(unity_ObjectToWorld, half4(v.tangent.xyz, 0.0)).xyz);
|
||||
o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
|
||||
|
||||
o.posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.uv.xy = v.texcoord;
|
||||
o.uv.z = v.vertexColor.x * _Slices;
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f i) : COLOR
|
||||
{
|
||||
// Pupil size offsets uv coords
|
||||
if (all(i.uv.xy < EYE_REGION_UV))
|
||||
{
|
||||
i.uv.xy -= PUPIL_CENTER_UV;
|
||||
half pupil = saturate(length(i.uv.xy) / DILATION_ENVELOPE);
|
||||
i.uv.xy *= lerp(1.0, pupil, _PupilSize);
|
||||
i.uv.xy += PUPIL_CENTER_UV;
|
||||
}
|
||||
|
||||
// Diffuse texture sample
|
||||
float4 albedoColor = UNITY_SAMPLE_TEX2DARRAY(_MainTex, i.uv);
|
||||
|
||||
// Process normal map
|
||||
float3 transformedNormalUV = i.uv;
|
||||
transformedNormalUV.xy = float2(TRANSFORM_TEX(i.uv.xy, _NormalMap));
|
||||
float3 normalMap = UNITY_SAMPLE_TEX2DARRAY(_NormalMap, transformedNormalUV) * 2.0 - ONE;
|
||||
float3x3 tangentTransform = float3x3(i.tangentDir, i.bitangentDir, i.normalDir);
|
||||
float3 normalDirection = normalize(mul(normalMap.rgb, tangentTransform));
|
||||
|
||||
// Roughness contains metallic in r, smoothness in a, mask region in b and mask control in g
|
||||
half4 roughnessTex = UNITY_SAMPLE_TEX2DARRAY(_RoughnessMap, i.uv);
|
||||
|
||||
// Normal/Light/View calculations
|
||||
half3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
|
||||
half VdotN = saturate(dot(viewDirection, normalDirection));
|
||||
half NdotL = saturate(dot(normalDirection, normalize(_WorldSpaceLightPos0.xyz)));
|
||||
|
||||
// Sample the default reflection cubemap using the reflection vector
|
||||
float3 worldReflection = reflect(-viewDirection, normalDirection);
|
||||
half4 skyData = UNITY_SAMPLE_TEXCUBE(unity_SpecCube0, worldReflection);
|
||||
// Decode cubemap data into actual color
|
||||
half3 reflectionColor = DecodeHDR(skyData, unity_SpecCube0_HDR);
|
||||
|
||||
// Get index into texture array
|
||||
int componentIndex = floor(i.uv.z + 0.5);
|
||||
|
||||
// Base color from array
|
||||
float4 baseColor = _BaseColor[componentIndex];
|
||||
|
||||
// Color space conversions if we are in linear
|
||||
#ifndef UNITY_COLORSPACE_GAMMA
|
||||
_MaskColorIris.rgb = LinearToGammaSpace(_MaskColorIris.rgb);
|
||||
_MaskColorLips.rgb = LinearToGammaSpace(_MaskColorLips.rgb);
|
||||
_MaskColorBrows.rgb = LinearToGammaSpace(_MaskColorBrows.rgb);
|
||||
_MaskColorLashes.rgb = LinearToGammaSpace(_MaskColorLashes.rgb);
|
||||
_MaskColorLashesEnd.rgb = LinearToGammaSpace(_MaskColorLashesEnd.rgb);
|
||||
_MaskColorSclera.rgb = LinearToGammaSpace(_MaskColorSclera.rgb);
|
||||
_MaskColorGums.rgb = LinearToGammaSpace(_MaskColorGums.rgb);
|
||||
_MaskColorTeeth.rgb = LinearToGammaSpace(_MaskColorTeeth.rgb);
|
||||
#endif
|
||||
|
||||
// Calculate color masks
|
||||
half irisScalar = abs(roughnessTex.b * COLOR_MULTIPLIER - MASK_INDEX_IRIS) <= MASK_SLICE_THRESHOLD ? roughnessTex.g : 0.0f;
|
||||
half lipsScalar = abs(roughnessTex.b * COLOR_MULTIPLIER - MASK_INDEX_LIPS) <= MASK_SLICE_THRESHOLD ? roughnessTex.g : 0.0f;
|
||||
half browsScalar = abs(roughnessTex.b * COLOR_MULTIPLIER - MASK_INDEX_BROWS) <= MASK_SLICE_THRESHOLD ? roughnessTex.g : 0.0f;;
|
||||
half lashesScalar = abs(roughnessTex.b * COLOR_MULTIPLIER - MASK_INDEX_LASHES) <= MASK_SLICE_THRESHOLD ? roughnessTex.g : 0.0f;
|
||||
half scleraScalar = abs(roughnessTex.b * COLOR_MULTIPLIER - MASK_INDEX_SCLERA) <= MASK_SLICE_THRESHOLD ? roughnessTex.g : 0.0f;
|
||||
half teethScalar = abs(roughnessTex.b * COLOR_MULTIPLIER - MASK_INDEX_TEETH) <= MASK_SLICE_THRESHOLD ? roughnessTex.g : 0.0f;;
|
||||
half gumsScalar = abs(roughnessTex.b * COLOR_MULTIPLIER - MASK_INDEX_GUMS) <= MASK_SLICE_THRESHOLD ? roughnessTex.g : 0.0f;;
|
||||
|
||||
half3 maskIris = irisScalar * (_MaskColorIris * IRIS_BRIGHTNESS_MODIFIER - baseColor.rgb);
|
||||
half3 maskBrows = browsScalar * (_MaskColorBrows - baseColor.rgb);
|
||||
half3 maskLashes = lashesScalar * (_MaskColorLashes - baseColor.rgb);
|
||||
half3 maskSclera = scleraScalar * (_MaskColorSclera * SCLERA_BRIGHTNESS_MODIFIER - baseColor.rgb);
|
||||
half3 maskTeeth = teethScalar * (_MaskColorTeeth - baseColor.rgb);
|
||||
half3 maskGums = gumsScalar * (_MaskColorGums - baseColor.rgb);
|
||||
// Lip tint excluded from color mask as it lerps with texture color
|
||||
half3 colorMask = maskIris + maskBrows + maskLashes + maskSclera + maskTeeth + maskGums;
|
||||
|
||||
// Diffuse intensity from array
|
||||
half diffuseIntensity = _DiffuseIntensity[componentIndex];
|
||||
|
||||
// Lerp diffuseIntensity with roughness map
|
||||
diffuseIntensity = lerp(diffuseIntensity, ONE, roughnessTex.a);
|
||||
|
||||
// Brows and lashes modify DiffuseIntensity
|
||||
diffuseIntensity *= ONE - (saturate(browsScalar + lashesScalar) * BROWS_LASHES_DIFFUSEINTENSITY);
|
||||
|
||||
// Add in diffuseIntensity and main lighting to base color
|
||||
baseColor.rgb += diffuseIntensity * NdotL * _LightColor0;
|
||||
|
||||
// Add in color mask to base color if this is the head component (index == 0)
|
||||
baseColor.rgb += clamp(ONE - componentIndex, 0, ONE) * colorMask;
|
||||
|
||||
// Multiply texture with base color with special case for lips
|
||||
albedoColor.rgb = lerp(albedoColor.rgb * baseColor.rgb, _MaskColorLips.rgb, lipsScalar * _MaskColorLips.a);
|
||||
|
||||
// Smoothness multiplier on lip region
|
||||
albedoColor.rgb += lipsScalar * reflectionColor * (_LipSmoothness * LIP_SMOOTHNESS_MULTIPLIER) *
|
||||
lerp(LIP_SMOOTHNESS_MIN_NDOTL, ONE, NdotL);
|
||||
|
||||
// Reflection from cubemap
|
||||
albedoColor.rgb += reflectionColor * (roughnessTex.a * _ReflectionIntensity[componentIndex]) * NdotL;
|
||||
|
||||
// Rim term
|
||||
#ifdef SECONDARY_LIGHT_ON
|
||||
// Secondary light proxy (direction and color) passed into the rim term
|
||||
NdotL = saturate(dot(normalDirection, _SecondaryLightDirection));
|
||||
albedoColor.rgb += pow(ONE - VdotN, _RimIntensity[componentIndex]) * NdotL * _SecondaryLightColor;
|
||||
#else
|
||||
albedoColor.rgb += pow(ONE - VdotN, _RimIntensity[componentIndex]) * NdotL;
|
||||
#endif
|
||||
|
||||
// Global dimmer
|
||||
albedoColor.rgb *= _Dimmer;
|
||||
|
||||
#if !defined(UNITY_COLORSPACE_GAMMA)
|
||||
albedoColor.rgb = GammaToLinearSpace(albedoColor.rgb);
|
||||
#endif
|
||||
albedoColor.rgb = saturate(albedoColor.rgb);
|
||||
|
||||
// Set alpha, with special case for lashes
|
||||
albedoColor.a = saturate(albedoColor.a * lerp(ONE, _Alpha, ONE - lashesScalar) * _Alpha);
|
||||
|
||||
// Clip fragments in the lash region for clean lash transparency
|
||||
clip(albedoColor.a - lerp(0.0, ALPHA_CLIP_THRESHOLD, lashesScalar));
|
||||
|
||||
// Return clamped final color
|
||||
return albedoColor;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0600fe59b0c043344affd1d1368b9ef2
|
||||
timeCreated: 1539810396
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,272 @@
|
||||
//
|
||||
// OvrAvatar Mobile single component expressive face shader
|
||||
// For use on expressive face meshes
|
||||
//
|
||||
// Unity vertex-fragnment implementation
|
||||
// Simplified lighting model recommended for use on mobile supporting one directional light
|
||||
// Surface shader recommended on PC
|
||||
//
|
||||
// Uses transparent queue for fade effects
|
||||
//
|
||||
// Color and appearance of the facial regions controlled via G&B channels in roughness texture
|
||||
// Pupil size controlled by manipulating UV coordinates
|
||||
//
|
||||
// Shader keywords:
|
||||
// - SECONDARY_LIGHT_ON SECONDARY_LIGHT_OFF
|
||||
// Enable SECONDARY_LIGHT_ON for a second "light" comprised of _SecondaryLightDirection and
|
||||
// _SecondaryLightColor This will influence the rim effect providing additional contour to the
|
||||
// avatar
|
||||
//
|
||||
|
||||
Shader "OvrAvatar/Avatar_Mobile_SingleComponentExpressive"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[NoScaleOffset] _MainTex("Main Texture", 2D) = "white" {}
|
||||
[NoScaleOffset] _NormalMap("Normal Map", 2D) = "bump" {}
|
||||
[NoScaleOffset] _RoughnessMap("Roughness Map", 2D) = "black" {}
|
||||
|
||||
_BaseColor("Color Tint", Color) = (1.0,1.0,1.0,1.0)
|
||||
_Dimmer("Dimmer", Range(0.0,1.0)) = 1.0
|
||||
_Alpha("Alpha", Range(0.0,1.0)) = 1.0
|
||||
|
||||
_DiffuseIntensity("Diffuse Intensity", Range(0.0,1.0)) = 0.3
|
||||
_ReflectionIntensity("Reflection Intensity", Range(0.0,1.0)) = 0.0
|
||||
_RimIntensity("Rim Intensity", Range(0.0,10.0)) = 5.0
|
||||
|
||||
_PupilSize("Pupil Size", Range(-1, 2)) = 0
|
||||
_LipSmoothness("Lip Smoothness", Range(0, 1)) = 0
|
||||
|
||||
_MaskColorIris("Iris Color", Color) = (0.0,0.0,0.0,1.0)
|
||||
_MaskColorLips("Lips Color", Color) = (0.0,0.0,0.0,1.0)
|
||||
_MaskColorBrows("Brows Color", Color) = (0.0,0.0,0.0,1.0)
|
||||
_MaskColorLashes("Lashes Color", Color) = (0.0,0.0,0.0,1.0)
|
||||
_MaskColorSclera("Sclera Color", Color) = (0.0,0.0,0.0,1.0)
|
||||
_MaskColorGums("Gums Color", Color) = (0.0,0.0,0.0,1.0)
|
||||
_MaskColorTeeth("Teeth Color", Color) = (0.0,0.0,0.0,1.0)
|
||||
|
||||
[HideInInspector] _SrcBlend("", Float) = 1
|
||||
[HideInInspector] _DstBlend("", Float) = 0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags { "LightMode" = "ForwardBase" "IgnoreProjector" = "True"}
|
||||
Pass
|
||||
{
|
||||
Blend [_SrcBlend] [_DstBlend]
|
||||
Cull Back
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 3.0
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma multi_compile SECONDARY_LIGHT_OFF SECONDARY_LIGHT_ON
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityLightingCommon.cginc"
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _NormalMap;
|
||||
float4 _NormalMap_ST;
|
||||
sampler2D _RoughnessMap;
|
||||
|
||||
half4 _BaseColor;
|
||||
half _Dimmer;
|
||||
half _Alpha;
|
||||
|
||||
half _DiffuseIntensity;
|
||||
half _RimIntensity;
|
||||
half _ReflectionIntensity;
|
||||
|
||||
half3 _SecondaryLightDirection;
|
||||
half4 _SecondaryLightColor;
|
||||
|
||||
half _PupilSize;
|
||||
half _LipSmoothness;
|
||||
|
||||
fixed4 _MaskColorIris;
|
||||
fixed4 _MaskColorSclera;
|
||||
fixed4 _MaskColorBrows;
|
||||
fixed4 _MaskColorLashes;
|
||||
fixed4 _MaskColorLashesEnd;
|
||||
fixed4 _MaskColorLips;
|
||||
fixed4 _MaskColorGums;
|
||||
fixed4 _MaskColorTeeth;
|
||||
|
||||
static const int ONE = 1;
|
||||
static const fixed ALPHA_CLIP_THRESHOLD = 0.7;
|
||||
static const int IRIS_BRIGHTNESS_MODIFIER = 2;
|
||||
static const fixed SCLERA_BRIGHTNESS_MODIFIER = 1.2;
|
||||
static const fixed LIP_SMOOTHNESS_MULTIPLIER = 0.5;
|
||||
static const fixed LIP_SMOOTHNESS_MIN_NDOTL = 0.3;
|
||||
static const fixed BROWS_LASHES_DIFFUSEINTENSITY = ONE - 0.25;
|
||||
static const int COLOR_MULTIPLIER = 255;
|
||||
static const half2 PUPIL_CENTER_UV = half2(0.127, 0.1175);
|
||||
static const half DILATION_ENVELOPE = 0.024;
|
||||
static const half2 EYE_REGION_UV = PUPIL_CENTER_UV + DILATION_ENVELOPE;
|
||||
|
||||
static const int MASK_SLICE_SIZE = 17;
|
||||
static const half MASK_SLICE_THRESHOLD = MASK_SLICE_SIZE * 0.5f;
|
||||
static const int MASK_INDEX_IRIS = 255;
|
||||
static const int MASK_INDEX_SCLERA = 238;
|
||||
static const int MASK_INDEX_LASHES = 221;
|
||||
static const int MASK_INDEX_LIPS = 204;
|
||||
static const int MASK_INDEX_GUMS = 187;
|
||||
static const int MASK_INDEX_TEETH = 170;
|
||||
static const int MASK_INDEX_BROWS = 153;
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex: POSITION;
|
||||
float3 normal: NORMAL;
|
||||
float4 tangent: TANGENT;
|
||||
float4 uv: TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 posWorld: TEXCOORD1;
|
||||
float3 normalDir: TEXCOORD2;
|
||||
float3 tangentDir: TEXCOORD3;
|
||||
float3 bitangentDir: TEXCOORD4;
|
||||
};
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
|
||||
// Calculate tangents for normal mapping
|
||||
o.normalDir = normalize(UnityObjectToWorldNormal(v.normal));
|
||||
o.tangentDir = normalize(mul(unity_ObjectToWorld, half4(v.tangent.xyz, 0.0)).xyz);
|
||||
o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
|
||||
|
||||
o.posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.uv;
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f i) : COLOR
|
||||
{
|
||||
// Pupil size offsets uv coords
|
||||
if (all(i.uv < EYE_REGION_UV))
|
||||
{
|
||||
i.uv -= PUPIL_CENTER_UV;
|
||||
half pupil = saturate(length(i.uv) / DILATION_ENVELOPE);
|
||||
i.uv *= lerp(1.0, pupil, _PupilSize);
|
||||
i.uv += PUPIL_CENTER_UV;
|
||||
}
|
||||
|
||||
// Diffuse texture sample
|
||||
half4 albedoColor = tex2D(_MainTex, i.uv);
|
||||
|
||||
// Process normal map
|
||||
#if (UNITY_VERSION >= 20171)
|
||||
float3 normalMap = UnpackNormal(tex2D(_NormalMap, i.uv));
|
||||
#else
|
||||
float3 normalMap = tex2D(_NormalMap, i.uv) * 2.0 - ONE;
|
||||
#endif
|
||||
float3x3 tangentTransform = float3x3(i.tangentDir, i.bitangentDir, i.normalDir);
|
||||
float3 normalDirection = normalize(mul(normalMap.rgb, tangentTransform));
|
||||
|
||||
// Roughness contains metallic in r, smoothness in a, mask region in b and mask control in g
|
||||
half4 roughnessTex = tex2D(_RoughnessMap, i.uv);
|
||||
|
||||
// Normal/Light/View calculations
|
||||
half3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
|
||||
half VdotN = saturate(dot(viewDirection, normalDirection));
|
||||
half NdotL = saturate(dot(normalDirection, normalize(_WorldSpaceLightPos0.xyz)));
|
||||
|
||||
// Sample the default reflection cubemap using the reflection vector
|
||||
float3 worldReflection = reflect(-viewDirection, normalDirection);
|
||||
half4 skyData = UNITY_SAMPLE_TEXCUBE(unity_SpecCube0, worldReflection);
|
||||
// Decode cubemap data into actual color
|
||||
half3 reflectionColor = DecodeHDR(skyData, unity_SpecCube0_HDR);
|
||||
|
||||
// Color space conversions if we are in linear
|
||||
#ifndef UNITY_COLORSPACE_GAMMA
|
||||
_BaseColor.rgb = LinearToGammaSpace(_BaseColor.rgb);
|
||||
_MaskColorIris.rgb = LinearToGammaSpace(_MaskColorIris);
|
||||
_MaskColorLips.rgb = LinearToGammaSpace(_MaskColorLips.rgb);
|
||||
_MaskColorBrows.rgb = LinearToGammaSpace(_MaskColorBrows.rgb);
|
||||
_MaskColorLashes.rgb = LinearToGammaSpace(_MaskColorLashes.rgb);
|
||||
_MaskColorLashesEnd.rgb = LinearToGammaSpace(_MaskColorLashesEnd.rgb);
|
||||
_MaskColorSclera.rgb = LinearToGammaSpace(_MaskColorSclera.rgb);
|
||||
_MaskColorGums.rgb = LinearToGammaSpace(_MaskColorGums.rgb);
|
||||
_MaskColorTeeth.rgb = LinearToGammaSpace(_MaskColorTeeth.rgb);
|
||||
#endif
|
||||
|
||||
// Calculate color masks
|
||||
half irisScalar = abs(roughnessTex.b * COLOR_MULTIPLIER - MASK_INDEX_IRIS) <= MASK_SLICE_THRESHOLD ? roughnessTex.g : 0.0f;
|
||||
half lipsScalar = abs(roughnessTex.b * COLOR_MULTIPLIER - MASK_INDEX_LIPS) <= MASK_SLICE_THRESHOLD ? roughnessTex.g : 0.0f;
|
||||
half browsScalar = abs(roughnessTex.b * COLOR_MULTIPLIER - MASK_INDEX_BROWS) <= MASK_SLICE_THRESHOLD ? roughnessTex.g : 0.0f;;
|
||||
half lashesScalar = abs(roughnessTex.b * COLOR_MULTIPLIER - MASK_INDEX_LASHES) <= MASK_SLICE_THRESHOLD ? roughnessTex.g : 0.0f;
|
||||
half scleraScalar = abs(roughnessTex.b * COLOR_MULTIPLIER - MASK_INDEX_SCLERA) <= MASK_SLICE_THRESHOLD ? roughnessTex.g : 0.0f;
|
||||
half teethScalar = abs(roughnessTex.b * COLOR_MULTIPLIER - MASK_INDEX_TEETH) <= MASK_SLICE_THRESHOLD ? roughnessTex.g : 0.0f;;
|
||||
half gumsScalar = abs(roughnessTex.b * COLOR_MULTIPLIER - MASK_INDEX_GUMS) <= MASK_SLICE_THRESHOLD ? roughnessTex.g : 0.0f;;
|
||||
|
||||
half3 maskIris = irisScalar * (_MaskColorIris * IRIS_BRIGHTNESS_MODIFIER - _BaseColor.rgb);
|
||||
half3 maskBrows = browsScalar * (_MaskColorBrows - _BaseColor.rgb);
|
||||
half3 maskLashes = lashesScalar * (_MaskColorLashes - _BaseColor.rgb);
|
||||
half3 maskSclera = scleraScalar * (_MaskColorSclera * SCLERA_BRIGHTNESS_MODIFIER - _BaseColor.rgb);
|
||||
half3 maskTeeth = teethScalar * (_MaskColorTeeth - _BaseColor.rgb);
|
||||
half3 maskGums = gumsScalar * (_MaskColorGums - _BaseColor.rgb);
|
||||
// Lip tint excluded from color mask as it lerps with texture color
|
||||
half3 colorMask = maskIris + maskBrows + maskLashes + maskSclera + maskTeeth + maskGums;
|
||||
|
||||
// Lerp diffuseIntensity with roughness map
|
||||
_DiffuseIntensity = lerp(_DiffuseIntensity, ONE, roughnessTex.a);
|
||||
|
||||
// Brows and lashes modify DiffuseIntensity
|
||||
_DiffuseIntensity *= ONE - (saturate(browsScalar + lashesScalar) * BROWS_LASHES_DIFFUSEINTENSITY);
|
||||
|
||||
// Add in diffuseIntensity and main lighting to base color
|
||||
_BaseColor.rgb += _DiffuseIntensity * NdotL * _LightColor0;
|
||||
|
||||
// Add in color mask to base color
|
||||
_BaseColor.rgb += colorMask;
|
||||
|
||||
// Multiply texture with base color with special case for lips
|
||||
albedoColor.rgb = lerp(albedoColor.rgb * _BaseColor.rgb, _MaskColorLips.rgb, lipsScalar * _MaskColorLips.a);
|
||||
|
||||
// Smoothness multiplier on lip region
|
||||
albedoColor.rgb += lipsScalar * reflectionColor * (_LipSmoothness * LIP_SMOOTHNESS_MULTIPLIER) *
|
||||
lerp(LIP_SMOOTHNESS_MIN_NDOTL, ONE, NdotL);
|
||||
|
||||
// Reflection from cubemap
|
||||
albedoColor.rgb += reflectionColor * (roughnessTex.a * _ReflectionIntensity) * NdotL;
|
||||
|
||||
// Rim term
|
||||
#ifdef SECONDARY_LIGHT_ON
|
||||
// Secondary light proxy (direction and color) passed into the rim term
|
||||
NdotL = saturate(dot(normalDirection, _SecondaryLightDirection));
|
||||
albedoColor.rgb += pow(ONE - VdotN, _RimIntensity) * NdotL * _SecondaryLightColor;
|
||||
#else
|
||||
albedoColor.rgb += pow(ONE - VdotN, _RimIntensity) * NdotL;
|
||||
#endif
|
||||
|
||||
// Global dimmer
|
||||
albedoColor.rgb *= _Dimmer;
|
||||
|
||||
// Convert back to linear color space if we are in linear
|
||||
#if !defined(UNITY_COLORSPACE_GAMMA)
|
||||
albedoColor.rgb = GammaToLinearSpace(albedoColor.rgb);
|
||||
#endif
|
||||
albedoColor.rgb = saturate(albedoColor.rgb);
|
||||
|
||||
// Set alpha, with special case for lashes
|
||||
albedoColor.a = saturate(albedoColor.a * lerp(ONE, _Alpha, ONE - lashesScalar) * _Alpha);
|
||||
|
||||
// Clip fragments in the lash region for clean lash transparency
|
||||
clip(albedoColor.a - lerp(0.0, ALPHA_CLIP_THRESHOLD, lashesScalar));
|
||||
|
||||
// Return clamped final color
|
||||
return albedoColor;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
Fallback "Diffuse"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2fe0ac0c2373ab143a6f21314b785d7d
|
||||
timeCreated: 1544020283
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,216 @@
|
||||
//
|
||||
// OvrAvatar PC single component expressive face shader
|
||||
// For use on expressive face meshes
|
||||
//
|
||||
// Unity Surface Shader implementation
|
||||
// Mobile vertex/fragment shader is recommended for use on mobile platforms for performance.
|
||||
//
|
||||
// Uses transparent queue for fade effects
|
||||
//
|
||||
// Color and appearance of the facial regions controlled via G&B channels in roughness texture
|
||||
// Pupil size controlled by manipulating UV coordinates
|
||||
//
|
||||
|
||||
Shader "OvrAvatar/Avatar_PC_SingleComponentExpressive"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[NoScaleOffset] _MainTex("Color (RGB)", 2D) = "white" {}
|
||||
[NoScaleOffset] _NormalMap("Normal Map", 2D) = "bump" {}
|
||||
[NoScaleOffset] _RoughnessMap("Roughness Map", 2D) = "black" {}
|
||||
|
||||
_BaseColor("Color Tint", Color) = (1.0,1.0,1.0,1.0)
|
||||
_Dimmer("Dimmer", Range(0.0,1.0)) = 1.0
|
||||
_Alpha("Alpha", Range(0.0,1.0)) = 1.0
|
||||
|
||||
_DiffuseIntensity("Diffuse Intensity", Range(0.0,1.0)) = 0.3
|
||||
_SmoothnessMultiplier("Smoothness Multiplier", Range(0.0,1.0)) = 1.0
|
||||
_MetallicMultiplier("Metallic Multiplier", Range(0.0,1.0)) = 0.3
|
||||
_RimIntensity("Rim Intensity", Range(0.0,10.0)) = 5.0
|
||||
|
||||
_PupilSize("Pupil Size", Range(-1, 2)) = 0
|
||||
_LipSmoothness("Lip Smoothness", Range(0, 1)) = 0
|
||||
|
||||
_MaskColorIris("Iris Color", Color) = (0.0,0.0,0.0,1.0)
|
||||
_MaskColorLips("Lips Color", Color) = (0.0,0.0,0.0,1.0)
|
||||
_MaskColorBrows("Brows Color", Color) = (0.0,0.0,0.0,1.0)
|
||||
_MaskColorLashes("Lashes Color", Color) = (0.0,0.0,0.0,1.0)
|
||||
_MaskColorSclera("Sclera Color", Color) = (0.0,0.0,0.0,1.0)
|
||||
_MaskColorGums("Gums Color", Color) = (0.0,0.0,0.0,1.0)
|
||||
_MaskColorTeeth("Teeth Color", Color) = (0.0,0.0,0.0,1.0)
|
||||
|
||||
[HideInInspector] _SrcBlend("", Float) = 1
|
||||
[HideInInspector] _DstBlend("", Float) = 0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Blend [_SrcBlend] [_DstBlend]
|
||||
Cull Back
|
||||
CGPROGRAM
|
||||
#pragma surface surf Standard keepalpha fullforwardshadows
|
||||
#pragma target 3.0
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _NormalMap;
|
||||
sampler2D _RoughnessMap;
|
||||
|
||||
half4 _BaseColor;
|
||||
half _Dimmer;
|
||||
half _Alpha;
|
||||
|
||||
half _DiffuseIntensity;
|
||||
half _SmoothnessMultiplier;
|
||||
half _SmoothnessMultiplierLips;
|
||||
half _MetallicMultiplier;
|
||||
half _RimIntensity;
|
||||
|
||||
half _PupilSize;
|
||||
half _LipSmoothness;
|
||||
|
||||
fixed4 _MaskColorIris;
|
||||
fixed4 _MaskColorLips;
|
||||
fixed4 _MaskColorBrows;
|
||||
fixed4 _MaskColorLashes;
|
||||
fixed4 _MaskColorLashesEnd;
|
||||
fixed4 _MaskColorSclera;
|
||||
fixed4 _MaskColorGums;
|
||||
fixed4 _MaskColorTeeth;
|
||||
|
||||
static const int ONE = 1;
|
||||
static const fixed ALPHA_CLIP_THRESHOLD = 0.7;
|
||||
static const int IRIS_BRIGHTNESS_MODIFIER = 2;
|
||||
static const fixed SCLERA_BRIGHTNESS_MODIFIER = 1.2;
|
||||
static const fixed LIP_SMOOTHNESS_MULTIPLIER = 0.5;
|
||||
static const fixed LIP_SMOOTHNESS_MIN_NDOTL = 0.3;
|
||||
static const fixed BROWS_LASHES_DIFFUSEINTENSITY = ONE - 0.25;
|
||||
static const int COLOR_MULTIPLIER = 255;
|
||||
static const half2 PUPIL_CENTER_UV = half2(0.127, 0.1175);
|
||||
static const half DILATION_ENVELOPE = 0.024;
|
||||
static const half2 EYE_REGION_UV = PUPIL_CENTER_UV + DILATION_ENVELOPE;
|
||||
|
||||
static const int MASK_SLICE_SIZE = 17;
|
||||
static const half MASK_SLICE_THRESHOLD = MASK_SLICE_SIZE * 0.5f;
|
||||
static const int MASK_INDEX_IRIS = 255;
|
||||
static const int MASK_INDEX_SCLERA = 238;
|
||||
static const int MASK_INDEX_LASHES = 221;
|
||||
static const int MASK_INDEX_LIPS = 204;
|
||||
static const int MASK_INDEX_GUMS = 187;
|
||||
static const int MASK_INDEX_TEETH = 170;
|
||||
static const int MASK_INDEX_BROWS = 153;
|
||||
|
||||
struct Input
|
||||
{
|
||||
float2 uv_MainTex;
|
||||
float2 uv_NormalMap;
|
||||
float2 uv_RoughnessMap;
|
||||
float3 viewDir;
|
||||
float3 worldNormal; INTERNAL_DATA
|
||||
};
|
||||
|
||||
void surf(Input IN, inout SurfaceOutputStandard o)
|
||||
{
|
||||
// Pupil size offsets uv coords
|
||||
if (all(IN.uv_MainTex < EYE_REGION_UV))
|
||||
{
|
||||
IN.uv_MainTex -= PUPIL_CENTER_UV;
|
||||
half pupil = saturate(length(IN.uv_MainTex) / DILATION_ENVELOPE);
|
||||
IN.uv_MainTex *= lerp(ONE, pupil, _PupilSize);
|
||||
IN.uv_MainTex += PUPIL_CENTER_UV;
|
||||
}
|
||||
|
||||
// Diffuse texture sample
|
||||
half4 albedoColor = tex2D(_MainTex, IN.uv_MainTex);
|
||||
|
||||
// Unpack normal map
|
||||
#if (UNITY_VERSION >= 20171)
|
||||
o.Normal = UnpackNormal(tex2D(_NormalMap, IN.uv_MainTex));
|
||||
#else
|
||||
o.Normal = tex2D(_NormalMap, IN.uv_MainTex) * 2.0 - ONE;
|
||||
#endif
|
||||
// Roughness contains metallic in r, smoothness in a, mask region in b and mask control in g
|
||||
half4 roughnessTex = tex2D(_RoughnessMap, IN.uv_MainTex);
|
||||
|
||||
// Normal/Light/View calculations
|
||||
half NdotL = saturate(dot(WorldNormalVector(IN, o.Normal), _WorldSpaceLightPos0.xyz));
|
||||
half VdotN = saturate(dot(normalize(IN.viewDir), o.Normal));
|
||||
|
||||
// Color space conversions if we are in linear
|
||||
#ifndef UNITY_COLORSPACE_GAMMA
|
||||
_BaseColor.rgb = LinearToGammaSpace(_BaseColor.rgb);
|
||||
_MaskColorIris.rgb = LinearToGammaSpace(_MaskColorIris.rgb);
|
||||
_MaskColorLips.rgb = LinearToGammaSpace(_MaskColorLips.rgb);
|
||||
_MaskColorBrows.rgb = LinearToGammaSpace(_MaskColorBrows.rgb);
|
||||
_MaskColorLashes.rgb = LinearToGammaSpace(_MaskColorLashes.rgb);
|
||||
_MaskColorLashesEnd.rgb = LinearToGammaSpace(_MaskColorLashesEnd.rgb);
|
||||
_MaskColorSclera.rgb = LinearToGammaSpace(_MaskColorSclera.rgb);
|
||||
_MaskColorGums.rgb = LinearToGammaSpace(_MaskColorGums.rgb);
|
||||
_MaskColorTeeth.rgb = LinearToGammaSpace(_MaskColorTeeth.rgb);
|
||||
#endif
|
||||
|
||||
// Mask regions and colors
|
||||
half irisScalar = abs(roughnessTex.b * COLOR_MULTIPLIER - MASK_INDEX_IRIS) <= MASK_SLICE_THRESHOLD ? roughnessTex.g : 0.0f;
|
||||
half lipsScalar = abs(roughnessTex.b * COLOR_MULTIPLIER - MASK_INDEX_LIPS) <= MASK_SLICE_THRESHOLD ? roughnessTex.g : 0.0f;
|
||||
half browsScalar = abs(roughnessTex.b * COLOR_MULTIPLIER - MASK_INDEX_BROWS) <= MASK_SLICE_THRESHOLD ? roughnessTex.g : 0.0f;;
|
||||
half lashesScalar = abs(roughnessTex.b * COLOR_MULTIPLIER - MASK_INDEX_LASHES) <= MASK_SLICE_THRESHOLD ? roughnessTex.g : 0.0f;
|
||||
half scleraScalar = abs(roughnessTex.b * COLOR_MULTIPLIER - MASK_INDEX_SCLERA) <= MASK_SLICE_THRESHOLD ? roughnessTex.g : 0.0f;
|
||||
half teethScalar = abs(roughnessTex.b * COLOR_MULTIPLIER - MASK_INDEX_TEETH) <= MASK_SLICE_THRESHOLD ? roughnessTex.g : 0.0f;;
|
||||
half gumsScalar = abs(roughnessTex.b * COLOR_MULTIPLIER - MASK_INDEX_GUMS) <= MASK_SLICE_THRESHOLD ? roughnessTex.g : 0.0f;
|
||||
|
||||
half3 maskIris = irisScalar * (_MaskColorIris.rgb * IRIS_BRIGHTNESS_MODIFIER - _BaseColor.rgb);
|
||||
half3 maskBrows = browsScalar * (_MaskColorBrows.rgb - _BaseColor.rgb);
|
||||
half3 maskLashes = lashesScalar * (_MaskColorLashes.rgb - _BaseColor.rgb);
|
||||
half3 maskSclera = scleraScalar * (_MaskColorSclera.rgb * SCLERA_BRIGHTNESS_MODIFIER - _BaseColor.rgb);
|
||||
half3 maskTeeth = teethScalar * (_MaskColorTeeth.rgb - _BaseColor.rgb);
|
||||
half3 maskGums = gumsScalar * (_MaskColorGums.rgb - _BaseColor.rgb);
|
||||
// Lip tint excluded from color mask as it lerps with texture color
|
||||
half3 colorMask = maskIris + maskBrows + maskLashes + maskSclera + maskTeeth + maskGums;
|
||||
|
||||
// Set smoothness
|
||||
o.Smoothness = roughnessTex.a * _SmoothnessMultiplier;
|
||||
|
||||
// Force no smoothness on gums & teeth
|
||||
o.Smoothness *= ONE - saturate(teethScalar + gumsScalar);
|
||||
|
||||
// Use global smoothness or lip smoothness modifier
|
||||
o.Smoothness += (_LipSmoothness * LIP_SMOOTHNESS_MULTIPLIER) * lipsScalar;
|
||||
|
||||
// Set metallic with global modifier
|
||||
o.Metallic = roughnessTex.r * _MetallicMultiplier;
|
||||
|
||||
// Brows and lashes modify DiffuseIntensity
|
||||
_DiffuseIntensity *= ONE - (saturate(browsScalar + lashesScalar) * BROWS_LASHES_DIFFUSEINTENSITY);
|
||||
|
||||
// Modify base color with DiffuseIntensity * NdotL for lighting gradient
|
||||
_BaseColor.rgb += _DiffuseIntensity * NdotL;
|
||||
|
||||
// Add in color mask
|
||||
_BaseColor.rgb += colorMask;
|
||||
|
||||
// Multiply texture with base color with special case for lips
|
||||
o.Albedo.rgb = lerp(albedoColor.rgb * _BaseColor.rgb, _MaskColorLips.rgb, lipsScalar * _MaskColorLips.a);
|
||||
|
||||
// Rim term
|
||||
o.Albedo += pow(ONE - VdotN, _RimIntensity) * NdotL;
|
||||
|
||||
// Global dimmer
|
||||
o.Albedo *= _Dimmer;
|
||||
|
||||
// Convert back to linear color space if we are in linear
|
||||
#if !defined(UNITY_COLORSPACE_GAMMA)
|
||||
o.Albedo = GammaToLinearSpace(o.Albedo);
|
||||
#endif
|
||||
o.Albedo = saturate(o.Albedo);
|
||||
|
||||
// Set alpha, with special case for lashes
|
||||
o.Alpha = saturate(albedoColor.a * lerp(ONE, _Alpha, ONE - lashesScalar) * _Alpha);
|
||||
|
||||
// Clip fragments in the lash region for clean lash transparency
|
||||
clip(o.Alpha - lerp(0.0, ALPHA_CLIP_THRESHOLD, lashesScalar));
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
Fallback "Diffuse"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93b478e926e46654889c1c20f87f253f
|
||||
timeCreated: 1539382777
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user