c1_unity/Assets/arts/shaders/models/whatifstyle.shader
2023-04-03 11:04:31 +08:00

160 lines
6.0 KiB
Plaintext

Shader "whatifstyle"
{
Properties
{
_ASEOutlineColor("Outline Color", Color) = (0.139,0.06359903,0.06359903,0.5843138)
_ASEOutlineWidth("Outline Width", Float) = 0.006
[NoScaleOffset]_Albedo("Albedo", 2D) = "white" {}
[HDR]_Color("Color", Color) = (1,1,1,0)
_FresnelDir("FresnelDir", Vector) = (0,0,0,0)
_AOScale("AOScale", Vector) = (0.1,0.1,0.1,4)
_AOPosition("AOPosition", Vector) = (1,0,0,0)
_Broderlight("Broderlight", Color) = (0.5,0.5,0.5,1)
_Specular("Specular", Float) = 2
_Emission("Emission", Float) = 0
[HideInInspector] _texcoord("", 2D) = "white" {}
[HideInInspector] __dirty("", Int) = 1
}
SubShader
{
Tags{ }
Cull Front
CGPROGRAM
#pragma target 3.0
#pragma surface outlineSurf Outline keepalpha noshadow noambient novertexlights nolightmap nodynlightmap nodirlightmap nometa noforwardadd vertex:outlineVertexDataFunc
struct Input {
half filler;
};
half4 _ASEOutlineColor;
half _ASEOutlineWidth;
void outlineVertexDataFunc(inout appdata_full v, out Input o)
{
UNITY_INITIALIZE_OUTPUT(Input, o);
v.vertex.xyz += (v.normal * _ASEOutlineWidth);
}
inline half4 LightingOutline(SurfaceOutput s, half3 lightDir, half atten) { return half4 (0,0,0, s.Alpha); }
void outlineSurf(Input i, inout SurfaceOutput o)
{
o.Emission = _ASEOutlineColor.rgb;
o.Alpha = 1;
}
ENDCG
Tags{ "RenderType" = "Opaque" "Queue" = "Geometry+0" "DisableBatching" = "True" "IsEmissive" = "true" }
Cull Back
CGPROGRAM
#include "UnityPBSLighting.cginc"
#include "UnityShaderVariables.cginc"
#include "UnityCG.cginc"
#pragma target 3.0
#pragma surface surf StandardCustomLighting keepalpha addshadow fullforwardshadows exclude_path:deferred novertexlights nolightmap nodirlightmap
struct Input
{
float2 uv_texcoord;
float3 worldPos;
float3 viewDir;
half3 worldNormal;
};
struct SurfaceOutputCustomLightingCustom
{
half3 Albedo;
half3 Normal;
half3 Emission;
half Metallic;
half Smoothness;
half Occlusion;
half Alpha;
Input SurfInput;
UnityGIInput GIData;
};
uniform sampler2D _Albedo;
SamplerState sampler_Albedo;
uniform half _Emission;
uniform half4 _AOScale;
uniform half3 _AOPosition;
uniform half4 _Broderlight;
uniform half3 _FresnelDir;
uniform half _Specular;
uniform half4 _Color;
inline half4 LightingStandardCustomLighting(inout SurfaceOutputCustomLightingCustom s, half3 viewDir, UnityGI gi)
{
UnityGIInput data = s.GIData;
Input i = s.SurfInput;
half4 c = 0;
#ifdef UNITY_PASS_FORWARDBASE
float ase_lightAtten = data.atten;
if (_LightColor0.a == 0)
ase_lightAtten = 0;
#else
float3 ase_lightAttenRGB = gi.light.color / ((_LightColor0.rgb) + 0.000001);
float ase_lightAtten = max(max(ase_lightAttenRGB.r, ase_lightAttenRGB.g), ase_lightAttenRGB.b);
#endif
#if defined(HANDLE_SHADOWS_BLENDING_IN_GI)
half bakedAtten = UnitySampleBakedOcclusion(data.lightmapUV.xy, data.worldPos);
float zDist = dot(_WorldSpaceCameraPos - data.worldPos, UNITY_MATRIX_V[2].xyz);
float fadeDist = UnityComputeShadowFadeDistance(data.worldPos, zDist);
ase_lightAtten = UnityMixRealtimeAndBakedShadows(data.atten, bakedAtten, UnityComputeShadowFade(fadeDist));
#endif
float2 uv_Albedo23 = i.uv_texcoord;
half4 tex2DNode23 = tex2D(_Albedo, uv_Albedo23);
half4 albedo137 = tex2DNode23;
float3 ase_vertex3Pos = mul(unity_WorldToObject, float4(i.worldPos , 1));
half3 appendResult133 = (half3(_AOScale.x , _AOScale.y , _AOScale.z));
half4 matrixToPos119 = float4(float4x4(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)[3][0],float4x4(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)[3][1],float4x4(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)[3][2],float4x4(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)[3][3]);
half3 normalizeResult116 = normalize((i.viewDir + _FresnelDir));
half3 ase_worldNormal = i.worldNormal;
half fresnelNdotV111 = dot(ase_worldNormal, normalizeResult116);
half fresnelNode111 = (0.0 + 1.0 * pow(1.0 - fresnelNdotV111, 4.0));
half smoothstepResult112 = smoothstep(0.5 , 0.7 , fresnelNode111);
half3 ase_normWorldNormal = normalize(ase_worldNormal);
float3 ase_worldPos = i.worldPos;
#if defined(LIGHTMAP_ON) && UNITY_VERSION < 560 //aseld
half3 ase_worldlightDir = 0;
#else //aseld
half3 ase_worldlightDir = normalize(UnityWorldSpaceLightDir(ase_worldPos));
#endif //aseld
half3 normalizeResult36 = normalize((i.viewDir + ase_worldlightDir));
half dotResult37 = dot(ase_normWorldNormal , normalizeResult36);
half clampResult156 = clamp(dotResult37 , 0.0 , 1.0);
half smoothstepResult134 = smoothstep(0.96 , 0.97 , clampResult156);
half smoothstepResult157 = smoothstep(0.6 , 1.0 , tex2DNode23.a);
half Spe139 = (clampResult156 + (smoothstepResult134 * smoothstepResult157 * _Specular));
#if defined(LIGHTMAP_ON) && ( UNITY_VERSION < 560 || ( defined(LIGHTMAP_SHADOW_MIXING) && !defined(SHADOWS_SHADOWMASK) && defined(SHADOWS_SCREEN) ) )//aselc
half4 ase_lightColor = 0;
#else //aselc
half4 ase_lightColor = _LightColor0;
#endif //aselc
c.rgb = ((albedo137 + (albedo137 * (((pow(distance(half4((ase_vertex3Pos * appendResult133) , 0.0) , (matrixToPos119 + half4(_AOPosition , 0.0))) , _AOScale.w) * _Broderlight) * smoothstepResult112) + Spe139))) * ase_lightAtten * half4(ase_lightColor.rgb , 0.0) * _Color).rgb;
c.a = 1;
return c;
}
inline void LightingStandardCustomLighting_GI(inout SurfaceOutputCustomLightingCustom s, UnityGIInput data, inout UnityGI gi)
{
s.GIData = data;
}
void surf(Input i , inout SurfaceOutputCustomLightingCustom o)
{
o.SurfInput = i;
float2 uv_Albedo23 = i.uv_texcoord;
half4 tex2DNode23 = tex2D(_Albedo, uv_Albedo23);
half4 albedo137 = tex2DNode23;
half smoothstepResult159 = smoothstep(0.9 , 1.0 , (1.0 - tex2DNode23.a));
half4 EmissionColor162 = (albedo137 * smoothstepResult159 * pow(_Emission , 2.0));
o.Emission = EmissionColor162.rgb;
}
ENDCG
}
Fallback off
}