clean project

This commit is contained in:
Helar Jaadla
2022-03-07 17:52:41 +02:00
parent a174b45bd2
commit cbeb10ec35
5100 changed files with 837159 additions and 0 deletions

View File

@@ -0,0 +1,318 @@
#ifndef AVATAR_UTIL_CG_INCLUDED
#define AVATAR_UTIL_CG_INCLUDED
#include "UnityCG.cginc"
#define SAMPLE_MODE_COLOR 0
#define SAMPLE_MODE_TEXTURE 1
#define SAMPLE_MODE_TEXTURE_SINGLE_CHANNEL 2
#define SAMPLE_MODE_PARALLAX 3
#define SAMPLE_MODE_RSRM 4
#define MASK_TYPE_NONE 0
#define MASK_TYPE_POSITIONAL 1
#define MASK_TYPE_REFLECTION 2
#define MASK_TYPE_FRESNEL 3
#define MASK_TYPE_PULSE 4
#define BLEND_MODE_ADD 0
#define BLEND_MODE_MULTIPLY 1
#ifdef LAYERS_1
#define LAYER_COUNT 1
#elif LAYERS_2
#define LAYER_COUNT 2
#elif LAYERS_3
#define LAYER_COUNT 3
#elif LAYERS_4
#define LAYER_COUNT 4
#elif LAYERS_5
#define LAYER_COUNT 5
#elif LAYERS_6
#define LAYER_COUNT 6
#elif LAYERS_7
#define LAYER_COUNT 7
#elif LAYERS_8
#define LAYER_COUNT 8
#endif
#define DECLARE_LAYER_UNIFORMS(index) \
int _LayerSampleMode##index; \
int _LayerBlendMode##index; \
int _LayerMaskType##index; \
fixed4 _LayerColor##index; \
sampler2D _LayerSurface##index; \
float4 _LayerSurface##index##_ST; \
float4 _LayerSampleParameters##index; \
float4 _LayerMaskParameters##index; \
float4 _LayerMaskAxis##index;
DECLARE_LAYER_UNIFORMS(0)
DECLARE_LAYER_UNIFORMS(1)
DECLARE_LAYER_UNIFORMS(2)
DECLARE_LAYER_UNIFORMS(3)
DECLARE_LAYER_UNIFORMS(4)
DECLARE_LAYER_UNIFORMS(5)
DECLARE_LAYER_UNIFORMS(6)
DECLARE_LAYER_UNIFORMS(7)
struct VertexOutput
{
float4 pos : SV_POSITION;
float2 texcoord : TEXCOORD0;
float3 worldPos : TEXCOORD1;
float3 worldNormal : TEXCOORD2;
float3 viewDir : TEXCOORD3;
float4 vertColor : COLOR;
#if NORMAL_MAP_ON || PARALLAX_ON
float3 worldTangent : TANGENT;
float3 worldBitangent : TEXCOORD5;
#endif
};
float _Alpha;
int _BaseMaskType;
float4 _BaseMaskParameters;
float4 _BaseMaskAxis;
fixed4 _DarkMultiplier;
fixed4 _BaseColor;
sampler2D _AlphaMask;
float4 _AlphaMask_ST;
sampler2D _AlphaMask2;
float4 _AlphaMask2_ST;
sampler2D _NormalMap;
float4 _NormalMap_ST;
sampler2D _ParallaxMap;
float4 _ParallaxMap_ST;
sampler2D _RoughnessMap;
float4 _RoughnessMap_ST;
float4x4 _ProjectorWorldToLocal;
VertexOutput vert(appdata_full v)
{
VertexOutput o;
UNITY_INITIALIZE_OUTPUT(VertexOutput, o);
o.texcoord = v.texcoord.xy;
o.worldPos = mul(unity_ObjectToWorld, v.vertex);
o.vertColor = v.color;
o.viewDir = normalize(_WorldSpaceCameraPos.xyz - o.worldPos);
o.worldNormal = normalize(mul(unity_ObjectToWorld, float4(v.normal, 0.0)).xyz);
#if NORMAL_MAP_ON || PARALLAX_ON
o.worldTangent = normalize(mul(unity_ObjectToWorld, float4(v.tangent.xyz, 0.0)).xyz);
o.worldBitangent = normalize(cross(o.worldNormal, o.worldTangent) * v.tangent.w);
#endif
o.pos = UnityObjectToClipPos(v.vertex);
return o;
}
#ifndef NORMAL_MAP_ON
#define COMPUTE_NORMAL IN.worldNormal
#else
#define COMPUTE_NORMAL normalize(mul(lerp(float3(0, 0, 1), surfaceNormal, normalMapStrength), tangentTransform))
#endif
float3 ComputeColor(
VertexOutput IN,
float2 uv,
#if PARALLAX_ON || NORMAL_MAP_ON
float3x3 tangentTransform,
#endif
#ifdef NORMAL_MAP_ON
float3 surfaceNormal,
#endif
sampler2D surface,
float4 surface_ST,
fixed4 color,
int sampleMode,
float4 sampleParameters
) {
if (sampleMode == SAMPLE_MODE_TEXTURE) {
float2 panning = _Time.g * sampleParameters.xy;
return tex2D(surface, (uv + panning) * surface_ST.xy + surface_ST.zw).rgb * color.rgb;
}
else if (sampleMode == SAMPLE_MODE_TEXTURE_SINGLE_CHANNEL) {
float4 channelMask = sampleParameters;
float4 channels = tex2D(surface, uv * surface_ST.xy + surface_ST.zw);
return dot(channels, channelMask) * color.rgb;
}
#ifdef PARALLAX_ON
else if (sampleMode == SAMPLE_MODE_PARALLAX) {
float parallaxMinHeight = sampleParameters.x;
float parallaxMaxHeight = sampleParameters.y;
float parallaxValue = tex2D(_ParallaxMap, TRANSFORM_TEX(uv, _ParallaxMap)).r;
float scaledHeight = lerp(parallaxMinHeight, parallaxMaxHeight, parallaxValue);
float2 parallaxUV = mul(tangentTransform, IN.viewDir).xy * scaledHeight;
return tex2D(surface, (uv * surface_ST.xy + surface_ST.zw) + parallaxUV).rgb * color.rgb;
}
#endif
else if (sampleMode == SAMPLE_MODE_RSRM) {
float roughnessMin = sampleParameters.x;
float roughnessMax = sampleParameters.y;
#ifdef ROUGHNESS_ON
float roughnessValue = tex2D(_RoughnessMap, TRANSFORM_TEX(uv, _RoughnessMap)).r;
float scaledRoughness = lerp(roughnessMin, roughnessMax, roughnessValue);
#else
float scaledRoughness = roughnessMin;
#endif
#ifdef NORMAL_MAP_ON
float normalMapStrength = sampleParameters.z;
#endif
float3 viewReflect = reflect(-IN.viewDir, COMPUTE_NORMAL);
float viewAngle = viewReflect.y * 0.5 + 0.5;
return tex2D(surface, float2(scaledRoughness, viewAngle)).rgb * color.rgb;
}
return color.rgb;
}
float ComputeMask(
VertexOutput IN,
#ifdef NORMAL_MAP_ON
float3x3 tangentTransform,
float3 surfaceNormal,
#endif
int maskType,
float4 layerParameters,
float3 maskAxis
) {
if (maskType == MASK_TYPE_POSITIONAL) {
float centerDistance = layerParameters.x;
float fadeAbove = layerParameters.y;
float fadeBelow = layerParameters.z;
float3 objPos = mul(unity_WorldToObject, float4(IN.worldPos, 1.0)).xyz;
float d = dot(objPos, maskAxis);
if (d > centerDistance) {
return saturate(1.0 - (d - centerDistance) / fadeAbove);
}
else {
return saturate(1.0 - (centerDistance - d) / fadeBelow);
}
}
else if (maskType == MASK_TYPE_REFLECTION) {
float fadeStart = layerParameters.x;
float fadeEnd = layerParameters.y;
#ifdef NORMAL_MAP_ON
float normalMapStrength = layerParameters.z;
#endif
float power = layerParameters.w;
float3 viewReflect = reflect(-IN.viewDir, COMPUTE_NORMAL);
float d = max(0.0, dot(viewReflect, maskAxis));
return saturate(1.0 - (d - fadeStart) / (fadeEnd - fadeStart));
}
else if (maskType == MASK_TYPE_FRESNEL) {
float power = layerParameters.x;
float fadeStart = layerParameters.y;
float fadeEnd = layerParameters.z;
#ifdef NORMAL_MAP_ON
float normalMapStrength = layerParameters.w;
#endif
float d = saturate(1.0 - max(0.0, dot(IN.viewDir, COMPUTE_NORMAL)));
float p = pow(d, power);
return saturate(lerp(fadeStart, fadeEnd, p));
}
else if (maskType == MASK_TYPE_PULSE) {
float distance = layerParameters.x;
float speed = layerParameters.y;
float power = layerParameters.z;
float3 objPos = mul(unity_WorldToObject, float4(IN.worldPos, 1.0)).xyz;
float d = dot(objPos, maskAxis);
float theta = 6.2831 * frac((d - _Time.g * speed) / distance);
return saturate(pow((sin(theta) * 0.5 + 0.5), power));
}
else {
return 1.0;
}
}
float3 ComputeBlend(float3 source, float3 blend, float mask, int blendMode) {
if (blendMode == BLEND_MODE_MULTIPLY) {
return source * (blend * mask);
}
else {
return source + (blend * mask);
}
}
float4 ComputeSurface(VertexOutput IN)
{
#if PROJECTOR_ON
float3 projectorPos = mul(_ProjectorWorldToLocal, float4(IN.worldPos, 1.0)).xyz;
if (abs(projectorPos.x) > 1.0 || abs(projectorPos.y) > 1.0 || abs(projectorPos.z) > 1.0)
{
discard;
}
float2 uv = projectorPos.xy * 0.5 + 0.5;
#else
float2 uv = IN.texcoord.xy;
#endif
fixed4 c = _BaseColor;
IN.worldNormal = normalize(IN.worldNormal);
#if PARALLAX_ON || NORMAL_MAP_ON
float3x3 tangentTransform = float3x3(IN.worldTangent, IN.worldBitangent, IN.worldNormal);
#endif
#ifdef NORMAL_MAP_ON
float3 surfaceNormal = UnpackNormal(tex2D(_NormalMap, TRANSFORM_TEX(uv, _NormalMap)));
#endif
#if PARALLAX_ON || NORMAL_MAP_ON
#ifndef NORMAL_MAP_ON
#define COLOR_INPUTS IN, uv, tangentTransform
#define MASK_INPUTS IN
#else
#define COLOR_INPUTS IN, uv, tangentTransform, surfaceNormal
#define MASK_INPUTS IN, tangentTransform, surfaceNormal
#endif
#else
#define COLOR_INPUTS IN, uv
#define MASK_INPUTS IN
#endif
#define LAYER_COLOR(index) ComputeColor(COLOR_INPUTS, _LayerSurface##index, _LayerSurface##index##_ST, _LayerColor##index, _LayerSampleMode##index, _LayerSampleParameters##index)
#define LAYER_MASK(index) ComputeMask(MASK_INPUTS, _LayerMaskType##index, _LayerMaskParameters##index, _LayerMaskAxis##index##.xyz)
#define LAYER_BLEND(index, c) ComputeBlend(c, LAYER_COLOR(index), LAYER_MASK(index), _LayerBlendMode##index)
c.rgb = LAYER_BLEND(0, c.rgb);
#if LAYER_COUNT > 1
c.rgb = LAYER_BLEND(1, c.rgb);
#endif
#if LAYER_COUNT > 2
c.rgb = LAYER_BLEND(2, c.rgb);
#endif
#if LAYER_COUNT > 3
c.rgb = LAYER_BLEND(3, c.rgb);
#endif
#if LAYER_COUNT > 4
c.rgb = LAYER_BLEND(4, c.rgb);
#endif
#if LAYER_COUNT > 5
c.rgb = LAYER_BLEND(5, c.rgb);
#endif
#if LAYER_COUNT > 6
c.rgb = LAYER_BLEND(6, c.rgb);
#endif
#if LAYER_COUNT > 7
c.rgb = LAYER_BLEND(7, c.rgb);
#endif
#ifdef VERTALPHA_ON
float scaledValue = IN.vertColor.a * 2.0;
float alpha0weight = max(0.0, 1.0 - scaledValue);
float alpha2weight = max(0.0, scaledValue - 1.0);
float alpha1weight = 1.0 - alpha0weight - alpha2weight;
c.a = _Alpha * c.a * (tex2D(_AlphaMask, TRANSFORM_TEX(uv, _AlphaMask)).r * alpha1weight + tex2D(_AlphaMask2, TRANSFORM_TEX(uv, _AlphaMask2)).r * alpha2weight + alpha0weight) * ComputeMask(MASK_INPUTS, _BaseMaskType, _BaseMaskParameters, _BaseMaskAxis);
#else
c.a = _Alpha * c.a * tex2D(_AlphaMask, TRANSFORM_TEX(uv, _AlphaMask)).r * IN.vertColor.a * ComputeMask(MASK_INPUTS, _BaseMaskType, _BaseMaskParameters, _BaseMaskAxis);
#endif
c.rgb = lerp(c.rgb, c.rgb * _DarkMultiplier, IN.vertColor.r);
return c;
}
#endif

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 80b6b34e742970d4bb0cdef9c74b04ae
timeCreated: 1525971186
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,64 @@
//
// OvrAvatar Simple Avatar Shader
// Uses the Avatar Material Model on the Standard Surface Shader
//
Shader "OvrAvatar/AvatarPBRV2Simple"
{
Properties
{
[NoScaleOffset] _MainTex("Color (RGB)", 2D) = "white" {}
[NoScaleOffset] _NormalMap("Normal Map", 2D) = "bump" {}
[NoScaleOffset] _RoughnessMap("Roughness Map", 2D) = "black" {}
}
SubShader
{
Blend One Zero
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;
struct Input
{
float2 uv_MainTex;
float2 uv_NormalMap;
float2 uv_RoughnessMap;
float3 viewDir;
float3 worldNormal; INTERNAL_DATA
};
void surf(Input IN, inout SurfaceOutputStandard o)
{
#if (UNITY_VERSION >= 20171)
o.Normal = UnpackNormal(tex2D(_NormalMap, IN.uv_MainTex));
#else
o.Normal = tex2D(_NormalMap, IN.uv_MainTex) * 2.0 - 1.0;
#endif
half4 roughnessTex = tex2D(_RoughnessMap, IN.uv_MainTex);
o.Albedo = tex2D(_MainTex, IN.uv_MainTex);
o.Smoothness = roughnessTex.a;
o.Metallic = roughnessTex.r;
#if !defined(UNITY_COLORSPACE_GAMMA)
o.Albedo = GammaToLinearSpace(o.Albedo);
#endif
o.Albedo = saturate(o.Albedo);
o.Alpha = 1.0;
}
ENDCG
}
Fallback "Diffuse"
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 28729c6ae5a33b04cb2f7956f3f3fc01
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,141 @@
Shader "OvrAvatar/AvatarSurfaceShader" {
Properties{
// Global parameters
_Alpha("Alpha", Range(0.0, 1.0)) = 1.0
_DarkMultiplier("Dark Multiplier", Color) = (0.6, 0.6, 0.6, 1.0)
_BaseColor("Base Color", Color) = (0.0, 0.0, 0.0, 0.0)
_BaseMaskType("Base Mask Type", Int) = 0
_BaseMaskParameters("Base Mask Parameters", Vector) = (0, 0, 0, 0)
_BaseMaskAxis("Base Mask Axis", Vector) = (0, 1, 0, 0)
_AlphaMask("Alpha Mask", 2D) = "white" {}
_NormalMap("Normal Map", 2D) = "" {}
_ParallaxMap("Parallax Map", 2D) = "" {}
_RoughnessMap("Roughness Map", 2D) = "" {}
// Layer 0 parameters
_LayerSampleMode0("Layer Sample Mode 0", Int) = 0
_LayerBlendMode0("Layer Blend Mode 0", Int) = 0
_LayerMaskType0("Layer Mask Type 0", Int) = 0
_LayerColor0("Layer Color 0", Color) = (1.0, 1.0, 1.0, 1.0)
_LayerSurface0("Layer Surface 0", 2D) = "" {}
_LayerSampleParameters0("Layer Sample Parameters 0", Vector) = (0, 0, 0, 0)
_LayerMaskParameters0("Layer Mask Parameters 0", Vector) = (0, 0, 0, 0)
_LayerMaskAxis0("Layer Mask Axis 0", Vector) = (0, 1, 0, 0)
// Layer 1 parameters
_LayerSampleMode1("Layer Sample Mode 1", Int) = 0
_LayerBlendMode1("Layer Blend Mode 1", Int) = 0
_LayerMaskType1("Layer Mask Type 1", Int) = 0
_LayerColor1("Layer Color 1", Color) = (1.0, 1.0, 1.0, 1.0)
_LayerSurface1("Layer Surface 1", 2D) = "" {}
_LayerSampleParameters1("Layer Sample Parameters 1", Vector) = (0, 0, 0, 0)
_LayerMaskParameters1("Layer Mask Parameters 1", Vector) = (0, 0, 0, 0)
_LayerMaskAxis1("Layer Mask Axis 1", Vector) = (0, 1, 0, 0)
// Layer 2 parameters
_LayerSampleMode2("Layer Sample Mode 2", Int) = 0
_LayerBlendMode2("Layer Blend Mode 2", Int) = 0
_LayerMaskType2("Layer Mask Type 2", Int) = 0
_LayerColor2("Layer Color 2", Color) = (1.0, 1.0, 1.0, 1.0)
_LayerSurface2("Layer Surface 2", 2D) = "" {}
_LayerSampleParameters2("Layer Sample Parameters 2", Vector) = (0, 0, 0, 0)
_LayerMaskParameters2("Layer Mask Parameters 2", Vector) = (0, 0, 0, 0)
_LayerMaskAxis2("Layer Mask Axis 2", Vector) = (0, 1, 0, 0)
// Layer 3 parameters
_LayerSampleMode3("Layer Sample Mode 3", Int) = 0
_LayerBlendMode3("Layer Blend Mode 3", Int) = 0
_LayerMaskType3("Layer Mask Type 3", Int) = 0
_LayerColor3("Layer Color 3", Color) = (1.0, 1.0, 1.0, 1.0)
_LayerSurface3("Layer Surface 3", 2D) = "" {}
_LayerSampleParameters3("Layer Sample Parameters 3", Vector) = (0, 0, 0, 0)
_LayerMaskParameters3("Layer Mask Parameters 3", Vector) = (0, 0, 0, 0)
_LayerMaskAxis3("Layer Mask Axis 3", Vector) = (0, 1, 0, 0)
// Layer 4 parameters
_LayerSampleMode4("Layer Sample Mode 4", Int) = 0
_LayerBlendMode4("Layer Blend Mode 4", Int) = 0
_LayerMaskType4("Layer Mask Type 4", Int) = 0
_LayerColor4("Layer Color 4", Color) = (1.0, 1.0, 1.0, 1.0)
_LayerSurface4("Layer Surface 4", 2D) = "" {}
_LayerSampleParameters4("Layer Sample Parameters 4", Vector) = (0, 0, 0, 0)
_LayerMaskParameters4("Layer Mask Parameters 4", Vector) = (0, 0, 0, 0)
_LayerMaskAxis4("Layer Mask Axis 4", Vector) = (0, 1, 0, 0)
// Layer 5 parameters
_LayerSampleMode5("Layer Sample Mode 5", Int) = 0
_LayerBlendMode5("Layer Blend Mode 5", Int) = 0
_LayerMaskType5("Layer Mask Type 5", Int) = 0
_LayerColor5("Layer Color 5", Color) = (1.0, 1.0, 1.0, 1.0)
_LayerSurface5("Layer Surface 5", 2D) = "" {}
_LayerSampleParameters5("Layer Sample Parameters 5", Vector) = (0, 0, 0, 0)
_LayerMaskParameters5("Layer Mask Parameters 5", Vector) = (0, 0, 0, 0)
_LayerMaskAxis5("Layer Mask Axis 5", Vector) = (0, 1, 0, 0)
// Layer 6 parameters
_LayerSampleMode6("Layer Sample Mode 6", Int) = 0
_LayerBlendMode6("Layer Blend Mode 6", Int) = 0
_LayerMaskType6("Layer Mask Type 6", Int) = 0
_LayerColor6("Layer Color 6", Color) = (1.0, 1.0, 1.0, 1.0)
_LayerSurface6("Layer Surface 6", 2D) = "" {}
_LayerSampleParameters6("Layer Sample Parameters 6", Vector) = (0, 0, 0, 0)
_LayerMaskParameters6("Layer Mask Parameters 6", Vector) = (0, 0, 0, 0)
_LayerMaskAxis6("Layer Mask Axis 6", Vector) = (0, 1, 0, 0)
// Layer 7 parameters
_LayerSampleMode7("Layer Sample Mode 7", Int) = 0
_LayerBlendMode7("Layer Blend Mode 7", Int) = 0
_LayerMaskType7("Layer Mask Type 7", Int) = 0
_LayerColor7("Layer Color 7", Color) = (1.0, 1.0, 1.0, 1.0)
_LayerSurface7("Layer Surface 7", 2D) = "" {}
_LayerSampleParameters7("Layer Sample Parameters 7", Vector) = (0, 0, 0, 0)
_LayerMaskParameters7("Layer Mask Parameters 7", Vector) = (0, 0, 0, 0)
_LayerMaskAxis7("Layer Mask Axis 7", Vector) = (0, 1, 0, 0)
}
SubShader
{
Tags
{
"Queue" = "Transparent"
"RenderType" = "Transparent"
}
Blend SrcAlpha OneMinusSrcAlpha
ZWrite Off
LOD 200
Pass
{
Name "FORWARD"
Tags
{
"LightMode" = "ForwardBase"
}
CGPROGRAM
#pragma only_renderers d3d11 gles3 gles
#pragma vertex vert
#pragma fragment frag
#pragma target 3.0
#pragma multi_compile PROJECTOR_OFF PROJECTOR_ON
#pragma multi_compile NORMAL_MAP_OFF NORMAL_MAP_ON
#pragma multi_compile PARALLAX_OFF PARALLAX_ON
#pragma multi_compile ROUGHNESS_OFF ROUGHNESS_ON
#pragma multi_compile VERTALPHA_OFF VERTALPHA_ON
#pragma multi_compile LAYERS_1 LAYERS_2 LAYERS_3 LAYERS_4 LAYERS_5 LAYERS_6 LAYERS_7 LAYERS_8
#include "Assets/Oculus/Avatar/Resources/Materials/AvatarMaterialStateShader.cginc"
float4 frag(VertexOutput IN) : COLOR
{
return ComputeSurface(IN);
}
ENDCG
}
}
FallBack "Diffuse"
CustomEditor "AvatarMaterialEditor"
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 73f67c4e7bf718b4385aa6b1f8a06591
timeCreated: 1525971190
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,79 @@
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "OvrAvatar/AvatarSurfaceShaderPBS" {
Properties{
// Global parameters
_Alpha("Alpha", Range(0.0, 1.0)) = 1.0
_Albedo("Albedo (RGB)", 2D) = "" {}
_Surface("Metallic (R) Occlusion (G) and Smoothness (A)", 2D) = "" {}
}
SubShader{
Tags {
"Queue" = "Transparent"
"RenderType" = "Transparent"
}
Pass {
ZWrite On
Cull Off
ColorMask 0
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 3.0
#include "UnityCG.cginc"
struct v2f {
float4 position : SV_POSITION;
};
v2f vert(appdata_full v) {
// Output
v2f output;
output.position = UnityObjectToClipPos(v.vertex);
return output;
}
float4 frag(v2f input) : COLOR {
return 0;
}
ENDCG
}
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard vertex:vert nolightmap alpha noforwardadd
float _Alpha;
sampler2D _Albedo;
float4 _Albedo_ST;
sampler2D _Surface;
float4 _Surface_ST;
struct Input {
float2 texcoord;
};
void vert(inout appdata_full v, out Input o) {
UNITY_INITIALIZE_OUTPUT(Input, o);
o.texcoord = v.texcoord.xy;
}
void surf (Input IN, inout SurfaceOutputStandard o) {
o.Albedo = tex2D(_Albedo, TRANSFORM_TEX(IN.texcoord, _Albedo)).rgb;
float4 surfaceParams = tex2D(_Surface, TRANSFORM_TEX(IN.texcoord, _Surface));
o.Metallic = surfaceParams.r;
o.Occlusion = surfaceParams.g;
o.Smoothness = surfaceParams.a;
o.Alpha = _Alpha;
}
#pragma only_renderers d3d11 gles3 gles
ENDCG
}
FallBack "Diffuse"
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 5e52aa58207bbf24d8eb8ec969e9ae88
timeCreated: 1525971190
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,39 @@
Shader "OvrAvatar/AvatarSurfaceShaderPBSV2" {
Properties {
_AlbedoMultiplier ("Albedo Multiplier", Color) = (1,1,1,1)
_Albedo ("Albedo (RGB)", 2D) = "white" {}
_Metallicness("Metallicness", 2D) = "grey" {}
_GlossinessScale ("Glossiness Scale", Range(0,1)) = 0.5
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard fullforwardshadows
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
sampler2D _Albedo;
sampler2D _Metallicness;
struct Input {
float2 uv_Albedo;
};
float _GlossinessScale;
float4 _AlbedoMultiplier;
void surf (Input IN, inout SurfaceOutputStandard o) {
fixed4 c = tex2D (_Albedo, IN.uv_Albedo) * _AlbedoMultiplier;
o.Albedo = c.rgb;
o.Metallic = tex2D (_Metallicness, IN.uv_Albedo).r;
o.Smoothness = _GlossinessScale;
o.Alpha = 1.0;
}
ENDCG
}
FallBack "Diffuse"
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 176faebcc612eb147900defeda2149cb
timeCreated: 1525971187
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,175 @@
Shader "OvrAvatar/AvatarSurfaceShaderSelfOccluding" {
Properties{
// Global parameters
_Alpha("Alpha", Range(0.0, 1.0)) = 1.0
_DarkMultiplier("Dark Multiplier", Color) = (0.6, 0.6, 0.6, 1.0)
_BaseColor("Base Color", Color) = (0.0, 0.0, 0.0, 0.0)
_BaseMaskType("Base Mask Type", Int) = 0
_BaseMaskParameters("Base Mask Parameters", Vector) = (0, 0, 0, 0)
_BaseMaskAxis("Base Mask Axis", Vector) = (0, 1, 0, 0)
_AlphaMask("Alpha Mask", 2D) = "white" {}
_NormalMap("Normal Map", 2D) = "" {}
_ParallaxMap("Parallax Map", 2D) = "" {}
_RoughnessMap("Roughness Map", 2D) = "" {}
// Layer 0 parameters
_LayerSampleMode0("Layer Sample Mode 0", Int) = 0
_LayerBlendMode0("Layer Blend Mode 0", Int) = 0
_LayerMaskType0("Layer Mask Type 0", Int) = 0
_LayerColor0("Layer Color 0", Color) = (1.0, 1.0, 1.0, 1.0)
_LayerSurface0("Layer Surface 0", 2D) = "" {}
_LayerSampleParameters0("Layer Sample Parameters 0", Vector) = (0, 0, 0, 0)
_LayerMaskParameters0("Layer Mask Parameters 0", Vector) = (0, 0, 0, 0)
_LayerMaskAxis0("Layer Mask Axis 0", Vector) = (0, 1, 0, 0)
// Layer 1 parameters
_LayerSampleMode1("Layer Sample Mode 1", Int) = 0
_LayerBlendMode1("Layer Blend Mode 1", Int) = 0
_LayerMaskType1("Layer Mask Type 1", Int) = 0
_LayerColor1("Layer Color 1", Color) = (1.0, 1.0, 1.0, 1.0)
_LayerSurface1("Layer Surface 1", 2D) = "" {}
_LayerSampleParameters1("Layer Sample Parameters 1", Vector) = (0, 0, 0, 0)
_LayerMaskParameters1("Layer Mask Parameters 1", Vector) = (0, 0, 0, 0)
_LayerMaskAxis1("Layer Mask Axis 1", Vector) = (0, 1, 0, 0)
// Layer 2 parameters
_LayerSampleMode2("Layer Sample Mode 2", Int) = 0
_LayerBlendMode2("Layer Blend Mode 2", Int) = 0
_LayerMaskType2("Layer Mask Type 2", Int) = 0
_LayerColor2("Layer Color 2", Color) = (1.0, 1.0, 1.0, 1.0)
_LayerSurface2("Layer Surface 2", 2D) = "" {}
_LayerSampleParameters2("Layer Sample Parameters 2", Vector) = (0, 0, 0, 0)
_LayerMaskParameters2("Layer Mask Parameters 2", Vector) = (0, 0, 0, 0)
_LayerMaskAxis2("Layer Mask Axis 2", Vector) = (0, 1, 0, 0)
// Layer 3 parameters
_LayerSampleMode3("Layer Sample Mode 3", Int) = 0
_LayerBlendMode3("Layer Blend Mode 3", Int) = 0
_LayerMaskType3("Layer Mask Type 3", Int) = 0
_LayerColor3("Layer Color 3", Color) = (1.0, 1.0, 1.0, 1.0)
_LayerSurface3("Layer Surface 3", 2D) = "" {}
_LayerSampleParameters3("Layer Sample Parameters 3", Vector) = (0, 0, 0, 0)
_LayerMaskParameters3("Layer Mask Parameters 3", Vector) = (0, 0, 0, 0)
_LayerMaskAxis3("Layer Mask Axis 3", Vector) = (0, 1, 0, 0)
// Layer 4 parameters
_LayerSampleMode4("Layer Sample Mode 4", Int) = 0
_LayerBlendMode4("Layer Blend Mode 4", Int) = 0
_LayerMaskType4("Layer Mask Type 4", Int) = 0
_LayerColor4("Layer Color 4", Color) = (1.0, 1.0, 1.0, 1.0)
_LayerSurface4("Layer Surface 4", 2D) = "" {}
_LayerSampleParameters4("Layer Sample Parameters 4", Vector) = (0, 0, 0, 0)
_LayerMaskParameters4("Layer Mask Parameters 4", Vector) = (0, 0, 0, 0)
_LayerMaskAxis4("Layer Mask Axis 4", Vector) = (0, 1, 0, 0)
// Layer 5 parameters
_LayerSampleMode5("Layer Sample Mode 5", Int) = 0
_LayerBlendMode5("Layer Blend Mode 5", Int) = 0
_LayerMaskType5("Layer Mask Type 5", Int) = 0
_LayerColor5("Layer Color 5", Color) = (1.0, 1.0, 1.0, 1.0)
_LayerSurface5("Layer Surface 5", 2D) = "" {}
_LayerSampleParameters5("Layer Sample Parameters 5", Vector) = (0, 0, 0, 0)
_LayerMaskParameters5("Layer Mask Parameters 5", Vector) = (0, 0, 0, 0)
_LayerMaskAxis5("Layer Mask Axis 5", Vector) = (0, 1, 0, 0)
// Layer 6 parameters
_LayerSampleMode6("Layer Sample Mode 6", Int) = 0
_LayerBlendMode6("Layer Blend Mode 6", Int) = 0
_LayerMaskType6("Layer Mask Type 6", Int) = 0
_LayerColor6("Layer Color 6", Color) = (1.0, 1.0, 1.0, 1.0)
_LayerSurface6("Layer Surface 6", 2D) = "" {}
_LayerSampleParameters6("Layer Sample Parameters 6", Vector) = (0, 0, 0, 0)
_LayerMaskParameters6("Layer Mask Parameters 6", Vector) = (0, 0, 0, 0)
_LayerMaskAxis6("Layer Mask Axis 6", Vector) = (0, 1, 0, 0)
// Layer 7 parameters
_LayerSampleMode7("Layer Sample Mode 7", Int) = 0
_LayerBlendMode7("Layer Blend Mode 7", Int) = 0
_LayerMaskType7("Layer Mask Type 7", Int) = 0
_LayerColor7("Layer Color 7", Color) = (1.0, 1.0, 1.0, 1.0)
_LayerSurface7("Layer Surface 7", 2D) = "" {}
_LayerSampleParameters7("Layer Sample Parameters 7", Vector) = (0, 0, 0, 0)
_LayerMaskParameters7("Layer Mask Parameters 7", Vector) = (0, 0, 0, 0)
_LayerMaskAxis7("Layer Mask Axis 7", Vector) = (0, 1, 0, 0)
}
SubShader
{
Tags
{
"Queue" = "Transparent"
"RenderType" = "Transparent"
}
Pass
{
ZWrite On
Cull Off
ColorMask 0
Offset 1, 1
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 3.0
#include "UnityCG.cginc"
struct v2f
{
float4 position : SV_POSITION;
};
v2f vert(appdata_full v)
{
// Output
v2f output;
output.position = UnityObjectToClipPos(v.vertex);
return output;
}
float4 frag(v2f input) : COLOR
{
return 0;
}
ENDCG
}
Blend SrcAlpha OneMinusSrcAlpha
ZWrite Off
LOD 200
Pass
{
Name "FORWARD"
Tags
{
"LightMode" = "ForwardBase"
}
CGPROGRAM
#pragma only_renderers d3d11 gles3 gles
#pragma vertex vert
#pragma fragment frag
#pragma target 3.0
#pragma multi_compile PROJECTOR_OFF PROJECTOR_ON
#pragma multi_compile NORMAL_MAP_OFF NORMAL_MAP_ON
#pragma multi_compile PARALLAX_OFF PARALLAX_ON
#pragma multi_compile ROUGHNESS_OFF ROUGHNESS_ON
#pragma multi_compile VERTALPHA_OFF VERTALPHA_ON
#pragma multi_compile LAYERS_1 LAYERS_2 LAYERS_3 LAYERS_4 LAYERS_5 LAYERS_6 LAYERS_7 LAYERS_8
#include "Assets/Oculus/Avatar/Resources/Materials/AvatarMaterialStateShader.cginc"
float4 frag(VertexOutput IN) : SV_Target
{
return ComputeSurface(IN);
}
ENDCG
}
}
FallBack "Diffuse"
CustomEditor "AvatarMaterialEditor"
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 69f342b79d37541489919a19cfd8a924
timeCreated: 1525971190
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 08113db6bc6c49046beb604cc64556ba
folderAsset: yes
timeCreated: 1540579933
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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"
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 8392f54e79937ed4bb1b692a143dc02b
timeCreated: 1539383496
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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
}
}
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 0600fe59b0c043344affd1d1368b9ef2
timeCreated: 1539810396
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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"
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 2fe0ac0c2373ab143a6f21314b785d7d
timeCreated: 1544020283
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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"
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 93b478e926e46654889c1c20f87f253f
timeCreated: 1539382777
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: ced8ef067736a0b468cde573cc63e3ec
folderAsset: yes
timeCreated: 1525971173
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,207 @@
//
// OvrAvatar Mobile combined mesh shader
// For use on non-expressive face meshes and other components
// Texture array approach for rendering a combined mesh avatar
// 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
//
// Simple mouth animation with speech done with vertex perturbation
//
// 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_CombinedMesh"
{
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
_Voice("Voice", Range(0.0,1.0)) = 0.0
[HideInInspector] _MouthPosition("Mouth position", Vector) = (0,0,0,1)
[HideInInspector] _MouthDirection("Mouth direction", Vector) = (0,0,0,1)
[HideInInspector] _MouthEffectDistance("Mouth Effect Distance", Float) = 0.03
[HideInInspector] _MouthEffectScale("Mouth Effect Scaler", Float) = 1
[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 _Voice;
half4 _MouthPosition;
half4 _MouthDirection;
half _MouthEffectDistance;
half _MouthEffectScale;
static const fixed MOUTH_ZSCALE = 0.5f;
static const fixed MOUTH_DROPOFF = 0.01f;
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;
// Mouth vertex animation with voice
float4 worldVert = mul(unity_ObjectToWorld, v.vertex);
float3 delta = _MouthPosition - worldVert;
delta.z *= MOUTH_ZSCALE;
half dist = length(delta);
half scaledMouthDropoff = _MouthEffectScale * MOUTH_DROPOFF;
half scaledMouthEffect = _MouthEffectScale * _MouthEffectDistance;
half displacement = _Voice * smoothstep(scaledMouthEffect + scaledMouthDropoff, scaledMouthEffect, dist);
worldVert.xyz -= _MouthDirection * displacement;
v.vertex = mul(unity_WorldToObject, worldVert);
// 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 = worldVert;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv.xy = v.texcoord;
o.uv.z = v.vertexColor.x * _Slices;
return o;
}
fixed4 frag(v2f i) : COLOR
{
// 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 - 1.0;
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, _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];
// Diffuse intensity from array
half diffuseIntensity = _DiffuseIntensity[componentIndex];
// Multiply in base color
albedoColor.rgb *= baseColor.rgb;
// Lerp diffuseIntensity with roughness map
diffuseIntensity = lerp(diffuseIntensity, 1.0, roughnessTex.a);
// Apply main light with a lerp between DiffuseIntensity and 1 based on the roughness
albedoColor.rgb += diffuseIntensity * NdotL * _LightColor0;
// 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(1.0 - VdotN, _RimIntensity[componentIndex]) * NdotL * _SecondaryLightColor;
#else
albedoColor.rgb += pow(1.0 - 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 *= _Alpha;
// Return clamped final color
return albedoColor;
}
ENDCG
}
}
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 37d2b8298f61cd2469465fc36108675d
timeCreated: 1526311739
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,135 @@
//
// OvrAvatar Mobile Single Component Loading shader
//
// Cut-down single component version of the avatar shader to be used during combined mesh loading
//
// See OvrAvatarMaterialManager implementation notes
//
Shader "OvrAvatar/Avatar_Mobile_Loader"
{
Properties
{
[NoScaleOffset] _NormalMap("Normal Map", 2D) = "bump" {}
_BaseColor("Color Tint", Color) = (1.0,1.0,1.0,1.0)
_Dimmer("Dimmer", Range(0.0,1.0)) = 1.0
_LoadingDimmer("Loading 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
_RimIntensity("Rim Intensity", Range(0.0,10.0)) = 5.0
}
SubShader
{
Tags { "LightMode" = "ForwardBase" "IgnoreProjector" = "True"}
Pass
{
Blend One Zero
Cull Back
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 3.0
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
#include "UnityLightingCommon.cginc"
sampler2D _NormalMap;
float4 _NormalMap_ST;
float4 _BaseColor;
float _Dimmer;
float _LoadingDimmer;
float _Alpha;
float _DiffuseIntensity;
float _RimIntensity;
static const fixed MOUTH_ZSCALE = 0.5f;
static const fixed MOUTH_DROPOFF = 0.01f;
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
{
// Process normal map
#if (UNITY_VERSION >= 20171)
float3 normalMap = UnpackNormal(tex2D(_NormalMap, i.uv));
#else
float3 normalMap = tex2D(_NormalMap, i.uv) * 2.0 - 1.0;
#endif
float3x3 tangentTransform = float3x3(i.tangentDir, i.bitangentDir, i.normalDir);
float3 normalDirection = normalize(mul(normalMap.rgb, tangentTransform));
// Normal/Light/View calculations
half3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
half VdotN = saturate(dot(viewDirection, normalDirection));
half NdotL = saturate(dot(normalDirection, _WorldSpaceLightPos0.xyz));
// Calculate color
float4 albedoColor;
#if !defined(UNITY_COLORSPACE_GAMMA)
_BaseColor.rgb = LinearToGammaSpace(_BaseColor.rgb);
#endif
// Final base color including DiffuseIntensity and NdotL for lighting gradient
_BaseColor.rgb += _DiffuseIntensity * NdotL * _LightColor0;
// No diffuse texture in the loader shader
albedoColor = _BaseColor;
// Rim term
albedoColor.rgb += pow(1.0 - VdotN, _RimIntensity) * NdotL;
// Global dimmer
albedoColor.rgb *= lerp(_Dimmer, _LoadingDimmer, step(_LoadingDimmer, _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
albedoColor.a *= _Alpha;
// Return clamped final color
return albedoColor;
}
ENDCG
}
}
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 822f5e641dc5dd54ca9555b727b3277f
timeCreated: 1526311739
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,200 @@
//
// OvrAvatar Mobile single component shader
// For use on non-expressive face meshes and other components
//
// 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
//
// Simple mouth animation with speech done with vertex perturbation
//
// 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_SingleComponent"
{
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
_RimIntensity("Rim Intensity", Range(0.0,10.0)) = 5.0
_ReflectionIntensity("Reflection Intensity", Range(0.0,1.0)) = 0.0
_Voice("Voice", Range(0.0,1.0)) = 0.0
[HideInInspector] _MouthPosition("Mouth position", Vector) = (0,0,0,1)
[HideInInspector] _MouthDirection("Mouth direction", Vector) = (0,0,0,1)
[HideInInspector] _MouthEffectDistance("Mouth Effect Distance", Float) = 0.03
[HideInInspector] _MouthEffectScale("Mouth Effect Scaler", Float) = 1
[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 _Voice;
half4 _MouthPosition;
half4 _MouthDirection;
half _MouthEffectDistance;
half _MouthEffectScale;
static const fixed MOUTH_ZSCALE = 0.5f;
static const fixed MOUTH_DROPOFF = 0.01f;
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;
// Mouth vertex animation with voice
float4 worldVert = mul(unity_ObjectToWorld, v.vertex);
float3 delta = _MouthPosition - worldVert;
delta.z *= MOUTH_ZSCALE;
half dist = length(delta);
half scaledMouthDropoff = _MouthEffectScale * MOUTH_DROPOFF;
half scaledMouthEffect = _MouthEffectScale * _MouthEffectDistance;
half displacement = _Voice * smoothstep(scaledMouthEffect + scaledMouthDropoff, scaledMouthEffect, dist);
worldVert.xyz -= _MouthDirection * displacement;
v.vertex = mul(unity_WorldToObject, worldVert);
// 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 = worldVert;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}
fixed4 frag(v2f i) : COLOR
{
// 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, _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);
#ifndef UNITY_COLORSPACE_GAMMA
_BaseColor.rgb = LinearToGammaSpace(_BaseColor.rgb);
#endif
// Multiply in base color
albedoColor.rgb *= _BaseColor.rgb;
// Lerp diffuseIntensity with roughness map
_DiffuseIntensity = lerp(_DiffuseIntensity, 1.0, roughnessTex.a);
// Apply main light with a lerp between DiffuseIntensity and 1 based on the roughness
albedoColor.rgb += _DiffuseIntensity * NdotL * _LightColor0;
// 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(1.0 - VdotN, _RimIntensity) * NdotL * _SecondaryLightColor;
#else
albedoColor.rgb += pow(1.0 - VdotN, _RimIntensity) * NdotL;
#endif
// Reflection from cubemap
albedoColor.rgb += reflectionColor * (roughnessTex.a * _ReflectionIntensity) * NdotL;
// 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
albedoColor.a *= _Alpha;
// Return clamped final color
return albedoColor;
}
ENDCG
}
}
Fallback "Diffuse"
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: c26fc51e445dcfd4db09305d861dc11c
timeCreated: 1526311739
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,114 @@
//
// OvrAvatar PC single component shader
// For use on non-expressive face meshes and other components
//
// Unity Surface Shader implementation
// Mobile vertex/fragment shader is recommended for use on mobile platforms for performance
//
// Uses transparent queue for fade effects
//
Shader "OvrAvatar/Avatar_PC_SingleComponent"
{
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)) = 1.0
_RimIntensity("Rim Intensity", Range(0.0,10.0)) = 5.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 _MetallicMultiplier;
half _RimIntensity;
struct Input
{
float2 uv_MainTex;
float2 uv_NormalMap;
float2 uv_RoughnessMap;
float3 viewDir;
float3 worldNormal; INTERNAL_DATA
};
void surf(Input IN, inout SurfaceOutputStandard o)
{
// 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 - 1.0;
#endif
// Roughness contains metallic in r, smoothness in a
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);
#endif
// Set smoothness and metallic
o.Smoothness = roughnessTex.a * _SmoothnessMultiplier;
o.Metallic = roughnessTex.r * _MetallicMultiplier;
// Final base color including DiffuseIntensity and NdotL for lighting gradient
_BaseColor.rgb += _DiffuseIntensity * NdotL;
// Multiply texture with base color
o.Albedo = albedoColor.rgb * _BaseColor;
// Rim term
o.Albedo += pow(1.0 - 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);
// Global alpha
o.Alpha = albedoColor.a * _Alpha;
}
ENDCG
}
Fallback "Diffuse"
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 36b8b481cf607814a8cec318f0148d63
timeCreated: 1525971189
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant: