add ckg
plantilla base para movimiento básico
This commit is contained in:
@@ -0,0 +1,165 @@
|
||||
// Upgrade NOTE: upgraded instancing buffer 'Props' to new syntax.
|
||||
|
||||
Shader "Custom/EyeBallsHD" {
|
||||
|
||||
Properties {
|
||||
_InternalColor ("Internal Color", Color) = (1,1,1,1)
|
||||
_EmissionColor ("Emission Color", Color) = (1,1,1,1)
|
||||
_EyeColor ("Iris Color", Color) = (0,0,1,0)
|
||||
_ScleraColor ("Scolera Color", Color) = (1,1,1,0)
|
||||
[Space]
|
||||
_MainTex ("Albedo (RGB)", 2D) = "white" {}
|
||||
_BumpMap ("Normals", 2D) = "bump" {}
|
||||
_NormalScale ("NormalScale", Range(0,1)) = 1
|
||||
_Mask ("(R) Subsurface (G) Spec (B) Iris Mask (A) Height", 2D) = "white" {}
|
||||
[Space]
|
||||
_SSS ("SSS Intensity", Range(0,1)) = 1
|
||||
_Glossiness ("Gloss", Range(0,1)) = 0.5
|
||||
_Reflection ("Reflection", Range(0,1)) = 0.0
|
||||
_Parallax ("Parallax", Range(0,0.3)) = 0
|
||||
_Fresnel ("Fresnel Value", Float) = 0.028
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags { "RenderType"="Opaque" }
|
||||
LOD 200
|
||||
Cull Back
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma surface surf SimpleSpecular vertex:vert addshadow
|
||||
|
||||
#pragma target 4.0
|
||||
|
||||
#include "UnityPBSLighting.cginc"
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _BumpMap;
|
||||
sampler2D _Mask;
|
||||
|
||||
struct Input {
|
||||
float2 uv_MainTex : TEXCOORD0;
|
||||
float3 eye : TEXCOORD1;
|
||||
float3 normal : TEXCOORD2;
|
||||
float3 light : COLOR;
|
||||
float3 viewDir;
|
||||
};
|
||||
|
||||
struct SurfaceOutputSSS {
|
||||
float3 Albedo;
|
||||
float3 Emission;
|
||||
float3 Normal;
|
||||
float Smoothness;
|
||||
float Specular;
|
||||
float Thickness;
|
||||
float Alpha;
|
||||
};
|
||||
|
||||
half _Glossiness;
|
||||
half _Reflection;
|
||||
fixed4 _Color, _EmissionColor, _InternalColor, _EyeColor, _ScleraColor;
|
||||
half _SSS;
|
||||
half _Parallax;
|
||||
float _Fresnel;
|
||||
float _NormalScale;
|
||||
|
||||
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
|
||||
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
|
||||
// #pragma instancing_options assumeuniformscaling
|
||||
UNITY_INSTANCING_BUFFER_START(Props)
|
||||
UNITY_INSTANCING_BUFFER_END(Props)
|
||||
|
||||
half4 LightingSimpleSpecular (SurfaceOutputSSS s, half3 lightDir, half3 viewDir, half atten) {
|
||||
|
||||
half diff = saturate(dot (s.Normal, lightDir));
|
||||
|
||||
half3 h = normalize (normalize(lightDir) + normalize(viewDir));
|
||||
float nh = saturate(dot (s.Normal, h));
|
||||
float spec = pow (nh, s.Specular * 128.0) * _Glossiness;
|
||||
|
||||
//reflection
|
||||
float4 refColor = 1.0;
|
||||
float3 refDir = reflect(-viewDir, s.Normal);
|
||||
float4 reflection = UNITY_SAMPLE_TEXCUBE(unity_SpecCube0, refDir);
|
||||
refColor.rgb = DecodeHDR(reflection, unity_SpecCube0_HDR);
|
||||
refColor.a = 1.0;
|
||||
//sss
|
||||
//differnce of eye to incoming light
|
||||
float eDotL = saturate(dot(viewDir, lightDir));
|
||||
//thickness estimate
|
||||
fixed3 albedo = s.Albedo;
|
||||
albedo -= (1-_InternalColor) * s.Thickness * eDotL * (diff * atten) * _SSS;
|
||||
//spec
|
||||
half4 c;
|
||||
c.rgb = (albedo * _LightColor0.rgb * diff + _LightColor0.rgb * spec) * atten;
|
||||
c.a = 1;
|
||||
return c + (refColor * s.Smoothness * _Reflection);
|
||||
}
|
||||
|
||||
float2 CalculateUVOffset(float3 lightDir, float3 viewDir, float3 normal, float2 uv) {
|
||||
|
||||
float limit = (-length(viewDir.xy) / viewDir.z) * _Parallax;
|
||||
float2 uvDir = normalize(viewDir.xy);
|
||||
float2 maxUVOffset = uvDir * limit;
|
||||
|
||||
//choose the amount of steps we need based on angle to surface.
|
||||
int maxSteps = lerp(40, 5, dot(viewDir, normal));
|
||||
float rayStep = 1.0 / (float)maxSteps;
|
||||
|
||||
// dx and dy effectively calculate the UV size of a pixel in the texture.
|
||||
// x derivative of mask uv
|
||||
float2 dx = ddx(uv);
|
||||
// y derivative of mask uv
|
||||
float2 dy = ddy(uv);
|
||||
|
||||
float rayHeight = 1.0;
|
||||
float2 uvOffset = 0;
|
||||
float currentHeight = 1;
|
||||
float2 stepLength = rayStep * maxUVOffset;
|
||||
|
||||
int step = 0;
|
||||
//search for the occluding uv coord in the heightmap
|
||||
while (step < maxSteps && currentHeight <= rayHeight)
|
||||
{
|
||||
step++;
|
||||
currentHeight = tex2Dgrad(_Mask, uv + uvOffset, dx, dy).a;
|
||||
rayHeight -= rayStep;
|
||||
uvOffset += stepLength;
|
||||
}
|
||||
return uvOffset;
|
||||
}
|
||||
|
||||
void vert (inout appdata_full v, out Input o) {
|
||||
UNITY_INITIALIZE_OUTPUT(Input,o);
|
||||
float3x3 t2w;
|
||||
float3 P = mul(unity_ObjectToWorld, v.vertex).xyz;
|
||||
float3 N = UnityObjectToWorldNormal(v.normal);
|
||||
float3 E = -UnityWorldSpaceViewDir(P);
|
||||
float3 L = UnityWorldSpaceLightDir(P);
|
||||
float3 binormal = cross(v.normal, v.tangent.xyz) * v.tangent.w;
|
||||
t2w[0] = UnityObjectToWorldNormal(v.tangent);
|
||||
t2w[1] = UnityObjectToWorldNormal(binormal);
|
||||
t2w[2] = UnityObjectToWorldNormal(v.normal);
|
||||
float3x3 w2t = transpose(t2w);
|
||||
o.eye = mul(E, w2t);
|
||||
o.normal = mul(N, w2t);
|
||||
o.light = mul(L, w2t);
|
||||
}
|
||||
|
||||
void surf (Input IN, inout SurfaceOutputSSS o) {
|
||||
fixed4 mask = tex2D(_Mask, IN.uv_MainTex);
|
||||
float2 offset = CalculateUVOffset(IN.light, IN.eye, IN.normal, IN.uv_MainTex);
|
||||
fixed4 c = tex2D (_MainTex, IN.uv_MainTex+offset);
|
||||
o.Normal = UnpackScaleNormal (tex2D (_BumpMap, IN.uv_MainTex), _NormalScale);
|
||||
half f = dot(normalize(IN.viewDir), o.Normal);
|
||||
o.Albedo = ((c.rgb * _EyeColor) * mask.b) + ((c.rgb * _ScleraColor) * (1-mask.b));
|
||||
o.Specular = mask.b;
|
||||
o.Smoothness = (_Fresnel-f*_Fresnel);
|
||||
o.Thickness = mask.r;
|
||||
o.Emission = (2 * c.rgb * _EmissionColor * mask.b);
|
||||
o.Alpha = 1;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
FallBack "Standard"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b8ffc11356b25423badb5ee91cd5fab6
|
||||
timeCreated: 1499268500
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,51 @@
|
||||
// Upgrade NOTE: upgraded instancing buffer 'Props' to new syntax.
|
||||
|
||||
Shader "Custom/EyeLash" {
|
||||
Properties {
|
||||
_Color ("Color", Color) = (1,1,1,1)
|
||||
_MainTex ("Albedo (RGB)", 2D) = "white" {}
|
||||
_Glossiness ("Smoothness", Range(0,1)) = 0.5
|
||||
_Metallic ("Metallic", Range(0,1)) = 0.0
|
||||
}
|
||||
SubShader {
|
||||
Tags { "RenderType"="Opaque" }
|
||||
LOD 200
|
||||
Cull Off
|
||||
|
||||
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 _MainTex;
|
||||
|
||||
struct Input {
|
||||
float2 uv_MainTex;
|
||||
};
|
||||
|
||||
half _Glossiness;
|
||||
half _Metallic;
|
||||
fixed4 _Color;
|
||||
|
||||
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
|
||||
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
|
||||
// #pragma instancing_options assumeuniformscaling
|
||||
UNITY_INSTANCING_BUFFER_START(Props)
|
||||
// put more per-instance properties here
|
||||
UNITY_INSTANCING_BUFFER_END(Props)
|
||||
|
||||
void surf (Input IN, inout SurfaceOutputStandard o) {
|
||||
// Albedo comes from a texture tinted by color
|
||||
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
|
||||
o.Albedo = c.rgb;
|
||||
// Metallic and smoothness come from slider variables
|
||||
o.Metallic = _Metallic;
|
||||
o.Smoothness = _Glossiness;
|
||||
o.Alpha = c.a;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3433191ca6e0b3540b6277505b8abde3
|
||||
timeCreated: 1502201250
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,94 @@
|
||||
Shader "Custom/SculptedHair" {
|
||||
Properties {
|
||||
_Color ("Main Color", Color) = (1,1,1,1)
|
||||
_HighlightColor ("Highlight Color", Color) = (1,1,1,1)
|
||||
_HighlightColor2 ("Highlight Color", Color) = (1,1,1,1)
|
||||
_MainTex ("Diffuse (RGB) Alpha (A)", 2D) = "white" {}
|
||||
_MetallicSmooth ("Metallic (RGB) _Smooth (A)", 2D) = "white" {}
|
||||
_BumpMap ("Normal (Normal)", 2D) = "bump" {}
|
||||
_AnisoTex ("Anisotropic Direction (Normal)", 2D) = "bump" {}
|
||||
_AnisoOffset ("Anisotropic Highlight Offset", Range(-1,1)) = -0.2
|
||||
_AnisoOffset2 ("Anisotropic Highlight Offset", Range(-1,1)) = -0.2
|
||||
_Gloss ("Gloss", Range(0,1)) = 0.2
|
||||
_Gloss2 ("Gloss2", Range(0,1)) = 0.2
|
||||
_Specularity ("Specularity", Range(0,1)) = 0.2
|
||||
_Specularity2 ("Specularity2", Range(0,1)) = 0.2
|
||||
_Reflection ("Reflection", Range(0,1)) = 0.2
|
||||
_value ("value", Float) = 0.0
|
||||
}
|
||||
|
||||
SubShader{
|
||||
Tags { "RenderType" = "Opaque" }
|
||||
|
||||
CGPROGRAM
|
||||
#pragma surface surf Aniso fullforwardshadows addshadow
|
||||
#pragma target 3.0
|
||||
|
||||
struct Input
|
||||
{
|
||||
float2 uv_MainTex;
|
||||
float2 uv_AnisoTex;
|
||||
};
|
||||
|
||||
struct SurfaceOutputAniso {
|
||||
fixed3 Albedo;
|
||||
fixed3 Ramp;
|
||||
fixed3 Emission;
|
||||
fixed3 Normal;
|
||||
fixed4 AnisoDir;
|
||||
fixed Alpha;
|
||||
fixed Smoothness;
|
||||
};
|
||||
|
||||
fixed4 _Color;
|
||||
fixed4 _HighlightColor;
|
||||
fixed4 _HighlightColor2;
|
||||
fixed _AnisoOffset;
|
||||
fixed _AnisoOffset2;
|
||||
float _value;
|
||||
fixed _Gloss, _Gloss2, _Specularity, _Specularity2, _Reflection;
|
||||
|
||||
sampler2D _MainTex, _SpecularTex, _BumpMap, _AnisoTex, _MetallicSmooth;
|
||||
|
||||
inline fixed4 LightingAniso (SurfaceOutputAniso s, fixed3 lightDir, fixed3 viewDir, fixed atten)
|
||||
{
|
||||
fixed3 h = normalize(normalize(lightDir) + normalize(viewDir));
|
||||
float NdotL = saturate(dot(s.Normal, lightDir));
|
||||
|
||||
fixed HdotA = dot(normalize(s.Normal + s.AnisoDir.rgb), h);
|
||||
float aniso = max(0, sin(radians((HdotA + _AnisoOffset + (s.Smoothness*0.1)) * 180 )));
|
||||
float aniso2 = max(0, sin(radians((HdotA + _AnisoOffset2 + (s.Smoothness*0.1)) * 180 )));
|
||||
|
||||
float spec = saturate(dot(s.Normal, h));
|
||||
float spec2 = spec;
|
||||
|
||||
spec = saturate(pow(lerp(spec, aniso, s.AnisoDir.a), _Gloss * 128) * _Specularity);
|
||||
spec2 = saturate(pow(lerp(spec2, aniso2, s.AnisoDir.a), _Gloss2 * 128) * _Specularity2);
|
||||
|
||||
|
||||
float4 refColor = 1.0;
|
||||
float3 refDir = reflect(-viewDir, s.Normal);
|
||||
float4 reflection = UNITY_SAMPLE_TEXCUBE(unity_SpecCube0, refDir);
|
||||
refColor.rgb = DecodeHDR(reflection, unity_SpecCube0_HDR);
|
||||
refColor.a = 1.0;
|
||||
|
||||
fixed4 c;
|
||||
c.rgb = ((s.Albedo * _LightColor0.rgb * NdotL) + (lerp(_HighlightColor.rgb, refColor.rgb, _Reflection) * spec * NdotL)) * (atten * 2);
|
||||
c.rgb += lerp(_HighlightColor2.rgb, refColor.rgb, _Reflection) * spec2 * NdotL;
|
||||
c.a = 1;
|
||||
return c;
|
||||
}
|
||||
|
||||
void surf (Input IN, inout SurfaceOutputAniso o)
|
||||
{
|
||||
fixed4 albedo = tex2D(_MainTex, IN.uv_MainTex) * _Color;
|
||||
o.Smoothness = tex2D(_MetallicSmooth, IN.uv_MainTex).a;
|
||||
o.Albedo = albedo.rgb;
|
||||
o.Alpha = albedo.a;
|
||||
o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_MainTex));
|
||||
o.AnisoDir = fixed4(tex2D(_AnisoTex, IN.uv_AnisoTex).rgb, 1);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: acd706f1b4a1246c0bc59b2626e1f1f2
|
||||
timeCreated: 1499342934
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,112 @@
|
||||
// Upgrade NOTE: upgraded instancing buffer 'Props' to new syntax.
|
||||
|
||||
Shader "Custom/ToonSkin" {
|
||||
|
||||
Properties{
|
||||
_Color("Color", Color) = (1,1,1,1)
|
||||
_InternalColor("Internal Color", Color) = (1,1,1,1)
|
||||
_SpecularColor("Specular Color", Color) = (1,1,1,1)
|
||||
[Space]
|
||||
_MainTex("Albedo (RGB) SSS (A)", 2D) = "white" {}
|
||||
_SpecGloss("Specular (RGB) Glossiness (A)", 2D) = "white" {}
|
||||
_BumpMap("Bumpmap", 2D) = "bump" {}
|
||||
_DetailBumpMap("Detail Bumpmap", 2D) = "bump" {}
|
||||
[Space]
|
||||
_SSS("SSS Intensity", Range(0,1)) = 1
|
||||
_Glossiness("Smoothness", Range(0,1)) = 0.5
|
||||
_Specular("Specular", Range(0,2)) = 0.0
|
||||
}
|
||||
|
||||
SubShader{
|
||||
Tags{ "RenderType" = "Opaque" }
|
||||
LOD 200
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#include "UnityPBSLighting.cginc"
|
||||
|
||||
#pragma surface surf SimpleSSS fullforwardshadows
|
||||
#pragma target 3.0
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _SpecGloss;
|
||||
sampler2D _BumpMap;
|
||||
sampler2D _DetailBumpMap;
|
||||
|
||||
struct Input {
|
||||
float2 uv_MainTex;
|
||||
float2 uv_BumpMap;
|
||||
float2 uv_DetailBumpMap;
|
||||
};
|
||||
|
||||
half _Glossiness;
|
||||
half _Specular;
|
||||
fixed4 _Color, _InternalColor, _SpecularColor;
|
||||
half _SSS;
|
||||
|
||||
|
||||
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
|
||||
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
|
||||
// #pragma instancing_options assumeuniformscaling
|
||||
UNITY_INSTANCING_BUFFER_START(Props)
|
||||
|
||||
UNITY_INSTANCING_BUFFER_END(Props)
|
||||
|
||||
float3 SubsurfaceShadingSimple(float3 diffColor, float3 normal, float3 viewDir, float3 thickness, float3 lightDir, float3 lightColor)
|
||||
{
|
||||
half3 vLTLight = lightDir + normal * 1;
|
||||
half fLTDot = pow(saturate(dot(viewDir, -vLTLight)), 3.5) * 1.5;
|
||||
half3 fLT = 1 * (fLTDot + 1.2) * (thickness);
|
||||
return diffColor * ((lightColor * fLT) * 0.4);
|
||||
}
|
||||
|
||||
|
||||
half4 LightingSimpleSSS(SurfaceOutputStandardSpecular s, half3 viewDir, UnityGI gi)
|
||||
{
|
||||
s.Normal = normalize(s.Normal);
|
||||
|
||||
// energy conservation
|
||||
half oneMinusReflectivity;
|
||||
s.Albedo = EnergyConservationBetweenDiffuseAndSpecular(s.Albedo, s.Specular, /*out*/ oneMinusReflectivity);
|
||||
|
||||
// shader relies on pre-multiply alpha-blend (_SrcBlend = One, _DstBlend = OneMinusSrcAlpha)
|
||||
// this is necessary to handle transparency in physically correct way - only diffuse component gets affected by alpha
|
||||
half outputAlpha;
|
||||
s.Albedo = PreMultiplyAlpha(s.Albedo, 1.0f, oneMinusReflectivity, /*out*/ outputAlpha);
|
||||
|
||||
half4 c = UNITY_BRDF_PBS(s.Albedo, s.Specular, oneMinusReflectivity, s.Smoothness, s.Normal, viewDir, gi.light, gi.indirect);
|
||||
|
||||
c.rgb += SubsurfaceShadingSimple(_InternalColor, s.Normal, viewDir, s.Alpha*_SSS, gi.light.dir, gi.light.color);
|
||||
|
||||
c.a = outputAlpha;
|
||||
return c;
|
||||
}
|
||||
|
||||
inline void LightingSimpleSSS_GI(
|
||||
SurfaceOutputStandardSpecular s,
|
||||
UnityGIInput data,
|
||||
inout UnityGI gi)
|
||||
{
|
||||
#if defined(UNITY_PASS_DEFERRED) && UNITY_ENABLE_REFLECTION_BUFFERS
|
||||
gi = UnityGlobalIllumination(data, s.Occlusion, s.Normal);
|
||||
#else
|
||||
Unity_GlossyEnvironmentData g = UnityGlossyEnvironmentSetup(s.Smoothness, data.worldViewDir, s.Normal, s.Specular);
|
||||
gi = UnityGlobalIllumination(data, s.Occlusion, s.Normal, g);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void surf(Input IN, inout SurfaceOutputStandardSpecular o) {
|
||||
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
|
||||
fixed4 s = tex2D(_SpecGloss, IN.uv_MainTex);
|
||||
o.Albedo = c.rgb;
|
||||
o.Normal = BlendNormals(UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)), UnpackNormal(tex2D(_DetailBumpMap, IN.uv_DetailBumpMap)));
|
||||
o.Specular = _Specular * s.rgb * _SpecularColor.rgb;
|
||||
o.Smoothness = _Glossiness * s.a;
|
||||
o.Alpha = c.a;
|
||||
//o.Emission = SubsurfaceShadingSimple(_InternalColor, o.Normal, IN.viewDir, c.a*_SSS, IN.lightDir, _LightColor0);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
FallBack "Standard"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e346c3fa450443dbaa9506ddb3a521d
|
||||
timeCreated: 1498559922
|
||||
licenseType: Store
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user