130 lines
4.3 KiB
Plaintext
130 lines
4.3 KiB
Plaintext
Shader "MY/PBR/PlayerV2"
|
|
{
|
|
Properties
|
|
{
|
|
_Color("Color", Color) = (1,1,1,1)
|
|
_MainTex("Albedo (RGB)", 2D) = "white" {}
|
|
_Glossiness("Smoothness", Range(0,1)) = 0.5
|
|
|
|
_SpecTex("Specular (R 高光 G 自发光 B Detail)", 2D) = "black" {}
|
|
_SpecColor("高光颜色", Color) = (0,0,0,1)
|
|
_SpecPower("高光强度", Range(0,2)) = 1
|
|
_RimColor("边光颜色", Color) = (0,0,0,1)
|
|
_RimPower("边光强度", Range(0,2)) = 1
|
|
_RimRange("边光范围", Range(1,10)) = 1.8
|
|
_EmissionColor("自发光颜色", Color) = (0,0,0)
|
|
_EmissionPower("自发光强度", Range(0,5)) = 1
|
|
[HDR]_DetailColor("细节颜色", Color) = (0,0,0)
|
|
}
|
|
|
|
SubShader
|
|
{
|
|
Tags { "RenderType" = "Opaque" }
|
|
LOD 200
|
|
|
|
CGPROGRAM
|
|
// Physically based Standard lighting model, and enable shadows on all light types
|
|
#pragma surface surf StandardSpecular fullforwardshadows finalcolor:mycolor exclude_path:deferred exclude_path:prepass nometa nolightmap nofog
|
|
|
|
// Use shader model 3.0 target, to get nicer looking lighting
|
|
#pragma target 3.0
|
|
|
|
|
|
sampler2D _MainTex;
|
|
|
|
struct Input
|
|
{
|
|
float2 uv_MainTex;
|
|
float3 viewDir;
|
|
float3 worldNormal;
|
|
};
|
|
|
|
half _Glossiness;
|
|
fixed4 _Color;
|
|
sampler2D _SpecTex;
|
|
//fixed3 _SpecColor;
|
|
half _SpecPower;
|
|
fixed3 _RimColor;
|
|
half _RimPower;
|
|
half _RimRange;
|
|
fixed3 _EmissionColor;
|
|
half _EmissionPower;
|
|
fixed3 _DetailColor;
|
|
// 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)
|
|
|
|
//struct SurfaceOutputStandardSpecular
|
|
//{
|
|
// fixed3 Albedo; // diffuse color
|
|
// fixed3 Specular; // specular color
|
|
// float3 Normal; // tangent space normal, if written
|
|
// half3 Emission;
|
|
// half Smoothness; // 0=rough, 1=smooth
|
|
// half Occlusion; // occlusion (default 1)
|
|
// fixed Alpha; // alpha for transparencies
|
|
//};
|
|
|
|
//struct SurfaceOutputStandard
|
|
//{
|
|
// fixed3 Albedo; // base (diffuse or specular) color
|
|
// float3 Normal; // tangent space normal, if written
|
|
// half3 Emission;
|
|
// half Metallic; // 0=non-metal, 1=metal
|
|
// // Smoothness is the user facing name, it should be perceptual smoothness but user should not have to deal with it.
|
|
// // Everywhere in the code you meet smoothness it is perceptual smoothness
|
|
// half Smoothness; // 0=rough, 1=smooth
|
|
// half Occlusion; // occlusion (default 1)
|
|
// fixed Alpha; // alpha for transparencies
|
|
//};
|
|
|
|
/* half3 LerpWhiteTo(half3 b, half t)
|
|
{
|
|
half oneMinusT = 1 - t;
|
|
return half3(oneMinusT, oneMinusT, oneMinusT) + b * t;
|
|
}*/
|
|
//void vert(inout appdata_full v, out Input o)
|
|
//{
|
|
// UNITY_INITIALIZE_OUTPUT(Input, o);
|
|
//}
|
|
|
|
void surf(Input IN, inout SurfaceOutputStandardSpecular o)
|
|
{
|
|
// Albedo comes from a texture tinted by color
|
|
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
|
|
fixed4 specGloss = tex2D(_SpecTex, IN.uv_MainTex);
|
|
fixed3 detailAlbedo = _DetailColor;//tex2D(_DetailAlbedoMap, IN.uv_MainTex);
|
|
|
|
o.Albedo = c.rgb;
|
|
half mask = specGloss.b;
|
|
//#if _DETAIL_MULX2
|
|
// o.Albedo *= LerpWhiteTo(detailAlbedo * unity_ColorSpaceDouble.rgb, mask);
|
|
//#elif _DETAIL_MUL
|
|
//o.Albedo *= LerpWhiteTo(detailAlbedo, mask);
|
|
//#elif _DETAIL_ADD
|
|
o.Albedo += detailAlbedo * mask;
|
|
//#elif _DETAIL_LERP
|
|
// o.Albedo = lerp(albedo, detailAlbedo, mask);
|
|
//#endif
|
|
//o.Albedo = c.rgb;
|
|
// Specular and smoothness come from slider variables
|
|
o.Specular = _SpecColor * specGloss.r * _SpecPower;
|
|
o.Smoothness = _Glossiness;
|
|
//o.Emission = specGloss.g * _EmissionPower * _EmissionColor;
|
|
o.Alpha = 1;//c.a;
|
|
}
|
|
|
|
void mycolor(Input IN, SurfaceOutputStandardSpecular o, inout fixed4 color)
|
|
{
|
|
fixed3 rim = _RimColor * _RimPower * saturate(1 - saturate(dot(IN.worldNormal, IN.viewDir)) * _RimRange);
|
|
color.rgb += rim;
|
|
}
|
|
|
|
ENDCG
|
|
}
|
|
FallBack "Diffuse"
|
|
}
|