205 lines
11 KiB
Plaintext
205 lines
11 KiB
Plaintext
// Made with Amplify Shader Editor
|
|
// Available at the Unity Asset Store - http://u3d.as/y3X
|
|
Shader "PBR_material"
|
|
{
|
|
Properties
|
|
{
|
|
_Main_Tex("Main_Tex", 2D) = "white" {}
|
|
_Base_Col("Base_Col", Color) = (1,1,1,0)
|
|
_Normal_Tex("Normal_Tex", 2D) = "bump" {}
|
|
_Normal_Int("Normal_Int", Range( 0 , 2)) = 1.5
|
|
_Normal_Detail_Tex("Normal_Detail_Tex", 2D) = "bump" {}
|
|
_Normal_Detail_Int("Normal_Detail_Int", Range( 0 , 2)) = 1
|
|
_Smooth_Int("Smooth_Int", Range( 0 , 1)) = 0.5
|
|
_OutLineCol("OutLineCol", Color) = (1,1,1,0)
|
|
[Toggle(_OUTLINE_ONOFF_ON)] _OutLine_onoff("OutLine_on/off", Float) = 0
|
|
[HideInInspector] _texcoord( "", 2D ) = "white" {}
|
|
[HideInInspector] __dirty( "", Int ) = 1
|
|
}
|
|
|
|
SubShader
|
|
{
|
|
Tags{ "RenderType" = "Opaque" "Queue" = "Geometry+0" }
|
|
Cull Off
|
|
CGINCLUDE
|
|
#include "UnityPBSLighting.cginc"
|
|
#include "Lighting.cginc"
|
|
#pragma target 3.0
|
|
#pragma shader_feature_local _OUTLINE_ONOFF_ON
|
|
#ifdef UNITY_PASS_SHADOWCASTER
|
|
#undef INTERNAL_DATA
|
|
#undef WorldReflectionVector
|
|
#undef WorldNormalVector
|
|
#define INTERNAL_DATA half3 internalSurfaceTtoW0; half3 internalSurfaceTtoW1; half3 internalSurfaceTtoW2;
|
|
#define WorldReflectionVector(data,normal) reflect (data.worldRefl, half3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal)))
|
|
#define WorldNormalVector(data,normal) half3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal))
|
|
#endif
|
|
struct Input
|
|
{
|
|
float2 uv_texcoord;
|
|
float3 worldPos;
|
|
float3 worldNormal;
|
|
INTERNAL_DATA
|
|
};
|
|
|
|
uniform sampler2D _Normal_Tex;
|
|
uniform float4 _Normal_Tex_ST;
|
|
uniform float _Normal_Int;
|
|
uniform sampler2D _Normal_Detail_Tex;
|
|
uniform float4 _Normal_Detail_Tex_ST;
|
|
uniform float _Normal_Detail_Int;
|
|
uniform sampler2D _Main_Tex;
|
|
uniform float4 _Main_Tex_ST;
|
|
uniform float4 _Base_Col;
|
|
uniform float4 _OutLineCol;
|
|
uniform float _Smooth_Int;
|
|
|
|
void surf( Input i , inout SurfaceOutputStandard o )
|
|
{
|
|
float2 uv_Normal_Tex = i.uv_texcoord * _Normal_Tex_ST.xy + _Normal_Tex_ST.zw;
|
|
float2 uv_Normal_Detail_Tex = i.uv_texcoord * _Normal_Detail_Tex_ST.xy + _Normal_Detail_Tex_ST.zw;
|
|
o.Normal = ( ( UnpackNormal( tex2D( _Normal_Tex, uv_Normal_Tex ) ) * _Normal_Int ) + ( UnpackNormal( tex2D( _Normal_Detail_Tex, uv_Normal_Detail_Tex ) ) * _Normal_Detail_Int ) );
|
|
float2 uv_Main_Tex = i.uv_texcoord * _Main_Tex_ST.xy + _Main_Tex_ST.zw;
|
|
float4 temp_output_3_0 = ( tex2D( _Main_Tex, uv_Main_Tex ) * _Base_Col );
|
|
float3 ase_worldPos = i.worldPos;
|
|
float3 ase_worldViewDir = normalize( UnityWorldSpaceViewDir( ase_worldPos ) );
|
|
float3 ase_worldNormal = WorldNormalVector( i, float3( 0, 0, 1 ) );
|
|
float fresnelNdotV25 = dot( ase_worldNormal, ase_worldViewDir );
|
|
float fresnelNode25 = ( 0.0 + 1.0 * pow( 1.0 - fresnelNdotV25, 1.0 ) );
|
|
float4 lerpResult31 = lerp( temp_output_3_0 , ( fresnelNode25 * _OutLineCol ) , fresnelNode25);
|
|
#ifdef _OUTLINE_ONOFF_ON
|
|
float4 staticSwitch29 = lerpResult31;
|
|
#else
|
|
float4 staticSwitch29 = temp_output_3_0;
|
|
#endif
|
|
o.Albedo = staticSwitch29.rgb;
|
|
o.Smoothness = _Smooth_Int;
|
|
o.Alpha = 1;
|
|
}
|
|
|
|
ENDCG
|
|
CGPROGRAM
|
|
#pragma surface surf Standard keepalpha fullforwardshadows
|
|
|
|
ENDCG
|
|
Pass
|
|
{
|
|
Name "ShadowCaster"
|
|
Tags{ "LightMode" = "ShadowCaster" }
|
|
ZWrite On
|
|
CGPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#pragma target 3.0
|
|
#pragma multi_compile_shadowcaster
|
|
#pragma multi_compile UNITY_PASS_SHADOWCASTER
|
|
#pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
|
|
#include "HLSLSupport.cginc"
|
|
#if ( SHADER_API_D3D11 || SHADER_API_GLCORE || SHADER_API_GLES || SHADER_API_GLES3 || SHADER_API_METAL || SHADER_API_VULKAN )
|
|
#define CAN_SKIP_VPOS
|
|
#endif
|
|
#include "UnityCG.cginc"
|
|
#include "Lighting.cginc"
|
|
#include "UnityPBSLighting.cginc"
|
|
struct v2f
|
|
{
|
|
V2F_SHADOW_CASTER;
|
|
float2 customPack1 : TEXCOORD1;
|
|
float4 tSpace0 : TEXCOORD2;
|
|
float4 tSpace1 : TEXCOORD3;
|
|
float4 tSpace2 : TEXCOORD4;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
v2f vert( appdata_full v )
|
|
{
|
|
v2f o;
|
|
UNITY_SETUP_INSTANCE_ID( v );
|
|
UNITY_INITIALIZE_OUTPUT( v2f, o );
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( o );
|
|
UNITY_TRANSFER_INSTANCE_ID( v, o );
|
|
Input customInputData;
|
|
float3 worldPos = mul( unity_ObjectToWorld, v.vertex ).xyz;
|
|
half3 worldNormal = UnityObjectToWorldNormal( v.normal );
|
|
half3 worldTangent = UnityObjectToWorldDir( v.tangent.xyz );
|
|
half tangentSign = v.tangent.w * unity_WorldTransformParams.w;
|
|
half3 worldBinormal = cross( worldNormal, worldTangent ) * tangentSign;
|
|
o.tSpace0 = float4( worldTangent.x, worldBinormal.x, worldNormal.x, worldPos.x );
|
|
o.tSpace1 = float4( worldTangent.y, worldBinormal.y, worldNormal.y, worldPos.y );
|
|
o.tSpace2 = float4( worldTangent.z, worldBinormal.z, worldNormal.z, worldPos.z );
|
|
o.customPack1.xy = customInputData.uv_texcoord;
|
|
o.customPack1.xy = v.texcoord;
|
|
TRANSFER_SHADOW_CASTER_NORMALOFFSET( o )
|
|
return o;
|
|
}
|
|
half4 frag( v2f IN
|
|
#if !defined( CAN_SKIP_VPOS )
|
|
, UNITY_VPOS_TYPE vpos : VPOS
|
|
#endif
|
|
) : SV_Target
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID( IN );
|
|
Input surfIN;
|
|
UNITY_INITIALIZE_OUTPUT( Input, surfIN );
|
|
surfIN.uv_texcoord = IN.customPack1.xy;
|
|
float3 worldPos = float3( IN.tSpace0.w, IN.tSpace1.w, IN.tSpace2.w );
|
|
half3 worldViewDir = normalize( UnityWorldSpaceViewDir( worldPos ) );
|
|
surfIN.worldPos = worldPos;
|
|
surfIN.worldNormal = float3( IN.tSpace0.z, IN.tSpace1.z, IN.tSpace2.z );
|
|
surfIN.internalSurfaceTtoW0 = IN.tSpace0.xyz;
|
|
surfIN.internalSurfaceTtoW1 = IN.tSpace1.xyz;
|
|
surfIN.internalSurfaceTtoW2 = IN.tSpace2.xyz;
|
|
SurfaceOutputStandard o;
|
|
UNITY_INITIALIZE_OUTPUT( SurfaceOutputStandard, o )
|
|
surf( surfIN, o );
|
|
#if defined( CAN_SKIP_VPOS )
|
|
float2 vpos = IN.pos;
|
|
#endif
|
|
SHADOW_CASTER_FRAGMENT( IN )
|
|
}
|
|
ENDCG
|
|
}
|
|
}
|
|
Fallback "Diffuse"
|
|
CustomEditor "ASEMaterialInspector"
|
|
}
|
|
/*ASEBEGIN
|
|
Version=18935
|
|
1920;0;1920;1019;2317.362;742.3854;2.650575;True;True
|
|
Node;AmplifyShaderEditor.SamplerNode;1;-1067.973,400.8358;Inherit;True;Property;_Main_Tex;Main_Tex;0;0;Create;True;0;0;0;False;0;False;-1;None;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.ColorNode;27;-861.3221,12.16315;Inherit;False;Property;_OutLineCol;OutLineCol;7;0;Create;True;0;0;0;False;0;False;1,1,1,0;1,1,1,0;True;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.FresnelNode;25;-917.3441,-316.1306;Inherit;True;Standard;WorldNormal;ViewDir;False;False;5;0;FLOAT3;0,0,1;False;4;FLOAT3;0,0,0;False;1;FLOAT;0;False;2;FLOAT;1;False;3;FLOAT;1;False;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.ColorNode;2;-982.4724,676.4359;Inherit;False;Property;_Base_Col;Base_Col;1;0;Create;True;0;0;0;False;0;False;1,1,1,0;0,0,0,0;True;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.RangedFloatNode;21;-952.6912,1682.965;Inherit;False;Property;_Normal_Detail_Int;Normal_Detail_Int;5;0;Create;True;0;0;0;False;0;False;1;0;0;2;0;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;26;-548.4064,-107.9458;Inherit;True;2;2;0;FLOAT;0;False;1;COLOR;0,0,0,0;False;1;COLOR;0
|
|
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;3;-625.9726,555.136;Inherit;True;2;2;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;1;COLOR;0
|
|
Node;AmplifyShaderEditor.RangedFloatNode;6;-953.7222,1283.681;Inherit;False;Property;_Normal_Int;Normal_Int;3;0;Create;True;0;0;0;False;0;False;1.5;0;0;2;0;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.SamplerNode;4;-964.7491,1056.029;Inherit;True;Property;_Normal_Tex;Normal_Tex;2;0;Create;True;0;0;0;False;0;False;-1;None;None;True;0;True;bump;Auto;True;Object;-1;Auto;Texture2D;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.SamplerNode;22;-963.7181,1455.313;Inherit;True;Property;_Normal_Detail_Tex;Normal_Detail_Tex;4;0;Create;True;0;0;0;False;0;False;-1;None;None;True;0;True;bump;Auto;True;Object;-1;Auto;Texture2D;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
|
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;23;-450.0888,1503.586;Inherit;True;2;2;0;FLOAT3;0,0,0;False;1;FLOAT;0;False;1;FLOAT3;0
|
|
Node;AmplifyShaderEditor.LerpOp;31;113.1208,77.50623;Inherit;True;3;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;2;FLOAT;0;False;1;COLOR;0
|
|
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;5;-430.5966,1136.004;Inherit;True;2;2;0;FLOAT3;0,0,0;False;1;FLOAT;0;False;1;FLOAT3;0
|
|
Node;AmplifyShaderEditor.RangedFloatNode;7;-405.2965,1815.347;Inherit;False;Property;_Smooth_Int;Smooth_Int;6;0;Create;True;0;0;0;False;0;False;0.5;0;0;1;0;1;FLOAT;0
|
|
Node;AmplifyShaderEditor.StaticSwitch;29;340.8206,-401.4172;Inherit;True;Property;_OutLine_onoff;OutLine_on/off;8;0;Create;True;0;0;0;False;0;False;0;0;0;True;;Toggle;2;Key0;Key1;Create;True;True;All;9;1;COLOR;0,0,0,0;False;0;COLOR;0,0,0,0;False;2;COLOR;0,0,0,0;False;3;COLOR;0,0,0,0;False;4;COLOR;0,0,0,0;False;5;COLOR;0,0,0,0;False;6;COLOR;0,0,0,0;False;7;COLOR;0,0,0,0;False;8;COLOR;0,0,0,0;False;1;COLOR;0
|
|
Node;AmplifyShaderEditor.SimpleAddOpNode;24;-145.0889,1324.586;Inherit;True;2;2;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;1;FLOAT3;0
|
|
Node;AmplifyShaderEditor.StandardSurfaceOutputNode;14;782.4809,412.653;Float;False;True;-1;2;ASEMaterialInspector;0;0;Standard;PBR_material;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;Off;0;False;-1;0;False;-1;False;0;False;-1;0;False;-1;False;0;Opaque;0.5;True;True;0;False;Opaque;;Geometry;All;18;all;True;True;True;True;0;False;-1;False;0;False;-1;255;False;-1;255;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;False;2;15;10;25;False;0.5;True;0;0;False;-1;0;False;-1;0;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;0;0,0,0,0;VertexOffset;True;False;Cylindrical;False;True;Relative;0;;-1;-1;-1;-1;0;False;0;0;False;-1;-1;0;False;-1;0;0;0;False;0.1;False;-1;0;False;-1;False;16;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT3;0,0,0;False;3;FLOAT;0;False;4;FLOAT;0;False;5;FLOAT;0;False;6;FLOAT3;0,0,0;False;7;FLOAT3;0,0,0;False;8;FLOAT;0;False;9;FLOAT;0;False;10;FLOAT;0;False;13;FLOAT3;0,0,0;False;11;FLOAT3;0,0,0;False;12;FLOAT3;0,0,0;False;14;FLOAT4;0,0,0,0;False;15;FLOAT3;0,0,0;False;0
|
|
WireConnection;26;0;25;0
|
|
WireConnection;26;1;27;0
|
|
WireConnection;3;0;1;0
|
|
WireConnection;3;1;2;0
|
|
WireConnection;23;0;22;0
|
|
WireConnection;23;1;21;0
|
|
WireConnection;31;0;3;0
|
|
WireConnection;31;1;26;0
|
|
WireConnection;31;2;25;0
|
|
WireConnection;5;0;4;0
|
|
WireConnection;5;1;6;0
|
|
WireConnection;29;1;3;0
|
|
WireConnection;29;0;31;0
|
|
WireConnection;24;0;5;0
|
|
WireConnection;24;1;23;0
|
|
WireConnection;14;0;29;0
|
|
WireConnection;14;1;24;0
|
|
WireConnection;14;4;7;0
|
|
ASEEND*/
|
|
//CHKSM=02318CDB2D225AD7896B5B6E3F9285C92D360B04 |