TextureArray_Triplanar.shader 116 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931
  1. // Made with Amplify Shader Editor
  2. // Available at the Unity Asset Store - http://u3d.as/y3X
  3. Shader "MTE/URP/TextureArray_Triplanar"
  4. {
  5. Properties
  6. {
  7. [HideInInspector] _AlphaCutoff("Alpha Cutoff ", Range(0, 1)) = 0.5
  8. [HideInInspector] _EmissionColor("Emission Color", Color) = (1,1,1,1)
  9. _Control0("Control0", 2D) = "white" {}
  10. _Control1("Control1", 2D) = "white" {}
  11. _Control2("Control2", 2D) = "white" {}
  12. _SplatArray("SplatArray", 2DArray) = "white" {}
  13. _NormalArray("NormalArray", 2DArray) = "white" {}
  14. _UVScaleOffset("UVScaleOffset", Vector) = (1,1,0,0)
  15. _Smoothness("Smoothness", Range( 0 , 1)) = 0
  16. _SpecColor("SpecColor", Color) = (0,0,0,0)
  17. //_TransmissionShadow( "Transmission Shadow", Range( 0, 1 ) ) = 0.5
  18. //_TransStrength( "Trans Strength", Range( 0, 50 ) ) = 1
  19. //_TransNormal( "Trans Normal Distortion", Range( 0, 1 ) ) = 0.5
  20. //_TransScattering( "Trans Scattering", Range( 1, 50 ) ) = 2
  21. //_TransDirect( "Trans Direct", Range( 0, 1 ) ) = 0.9
  22. //_TransAmbient( "Trans Ambient", Range( 0, 1 ) ) = 0.1
  23. //_TransShadow( "Trans Shadow", Range( 0, 1 ) ) = 0.5
  24. //_TessPhongStrength( "Tess Phong Strength", Range( 0, 1 ) ) = 0.5
  25. //_TessValue( "Tess Max Tessellation", Range( 1, 32 ) ) = 16
  26. //_TessMin( "Tess Min Distance", Float ) = 10
  27. //_TessMax( "Tess Max Distance", Float ) = 25
  28. //_TessEdgeLength ( "Tess Edge length", Range( 2, 50 ) ) = 16
  29. //_TessMaxDisp( "Tess Max Displacement", Float ) = 25
  30. }
  31. SubShader
  32. {
  33. LOD 0
  34. Tags { "RenderPipeline"="UniversalPipeline" "RenderType"="Opaque" "Queue"="Geometry" }
  35. Cull Back
  36. AlphaToMask Off
  37. HLSLINCLUDE
  38. #pragma target 3.0
  39. #pragma prefer_hlslcc gles
  40. #pragma exclude_renderers d3d11_9x
  41. #ifndef ASE_TESS_FUNCS
  42. #define ASE_TESS_FUNCS
  43. float4 FixedTess( float tessValue )
  44. {
  45. return tessValue;
  46. }
  47. float CalcDistanceTessFactor (float4 vertex, float minDist, float maxDist, float tess, float4x4 o2w, float3 cameraPos )
  48. {
  49. float3 wpos = mul(o2w,vertex).xyz;
  50. float dist = distance (wpos, cameraPos);
  51. float f = clamp(1.0 - (dist - minDist) / (maxDist - minDist), 0.01, 1.0) * tess;
  52. return f;
  53. }
  54. float4 CalcTriEdgeTessFactors (float3 triVertexFactors)
  55. {
  56. float4 tess;
  57. tess.x = 0.5 * (triVertexFactors.y + triVertexFactors.z);
  58. tess.y = 0.5 * (triVertexFactors.x + triVertexFactors.z);
  59. tess.z = 0.5 * (triVertexFactors.x + triVertexFactors.y);
  60. tess.w = (triVertexFactors.x + triVertexFactors.y + triVertexFactors.z) / 3.0f;
  61. return tess;
  62. }
  63. float CalcEdgeTessFactor (float3 wpos0, float3 wpos1, float edgeLen, float3 cameraPos, float4 scParams )
  64. {
  65. float dist = distance (0.5 * (wpos0+wpos1), cameraPos);
  66. float len = distance(wpos0, wpos1);
  67. float f = max(len * scParams.y / (edgeLen * dist), 1.0);
  68. return f;
  69. }
  70. float DistanceFromPlane (float3 pos, float4 plane)
  71. {
  72. float d = dot (float4(pos,1.0f), plane);
  73. return d;
  74. }
  75. bool WorldViewFrustumCull (float3 wpos0, float3 wpos1, float3 wpos2, float cullEps, float4 planes[6] )
  76. {
  77. float4 planeTest;
  78. planeTest.x = (( DistanceFromPlane(wpos0, planes[0]) > -cullEps) ? 1.0f : 0.0f ) +
  79. (( DistanceFromPlane(wpos1, planes[0]) > -cullEps) ? 1.0f : 0.0f ) +
  80. (( DistanceFromPlane(wpos2, planes[0]) > -cullEps) ? 1.0f : 0.0f );
  81. planeTest.y = (( DistanceFromPlane(wpos0, planes[1]) > -cullEps) ? 1.0f : 0.0f ) +
  82. (( DistanceFromPlane(wpos1, planes[1]) > -cullEps) ? 1.0f : 0.0f ) +
  83. (( DistanceFromPlane(wpos2, planes[1]) > -cullEps) ? 1.0f : 0.0f );
  84. planeTest.z = (( DistanceFromPlane(wpos0, planes[2]) > -cullEps) ? 1.0f : 0.0f ) +
  85. (( DistanceFromPlane(wpos1, planes[2]) > -cullEps) ? 1.0f : 0.0f ) +
  86. (( DistanceFromPlane(wpos2, planes[2]) > -cullEps) ? 1.0f : 0.0f );
  87. planeTest.w = (( DistanceFromPlane(wpos0, planes[3]) > -cullEps) ? 1.0f : 0.0f ) +
  88. (( DistanceFromPlane(wpos1, planes[3]) > -cullEps) ? 1.0f : 0.0f ) +
  89. (( DistanceFromPlane(wpos2, planes[3]) > -cullEps) ? 1.0f : 0.0f );
  90. return !all (planeTest);
  91. }
  92. float4 DistanceBasedTess( float4 v0, float4 v1, float4 v2, float tess, float minDist, float maxDist, float4x4 o2w, float3 cameraPos )
  93. {
  94. float3 f;
  95. f.x = CalcDistanceTessFactor (v0,minDist,maxDist,tess,o2w,cameraPos);
  96. f.y = CalcDistanceTessFactor (v1,minDist,maxDist,tess,o2w,cameraPos);
  97. f.z = CalcDistanceTessFactor (v2,minDist,maxDist,tess,o2w,cameraPos);
  98. return CalcTriEdgeTessFactors (f);
  99. }
  100. float4 EdgeLengthBasedTess( float4 v0, float4 v1, float4 v2, float edgeLength, float4x4 o2w, float3 cameraPos, float4 scParams )
  101. {
  102. float3 pos0 = mul(o2w,v0).xyz;
  103. float3 pos1 = mul(o2w,v1).xyz;
  104. float3 pos2 = mul(o2w,v2).xyz;
  105. float4 tess;
  106. tess.x = CalcEdgeTessFactor (pos1, pos2, edgeLength, cameraPos, scParams);
  107. tess.y = CalcEdgeTessFactor (pos2, pos0, edgeLength, cameraPos, scParams);
  108. tess.z = CalcEdgeTessFactor (pos0, pos1, edgeLength, cameraPos, scParams);
  109. tess.w = (tess.x + tess.y + tess.z) / 3.0f;
  110. return tess;
  111. }
  112. float4 EdgeLengthBasedTessCull( float4 v0, float4 v1, float4 v2, float edgeLength, float maxDisplacement, float4x4 o2w, float3 cameraPos, float4 scParams, float4 planes[6] )
  113. {
  114. float3 pos0 = mul(o2w,v0).xyz;
  115. float3 pos1 = mul(o2w,v1).xyz;
  116. float3 pos2 = mul(o2w,v2).xyz;
  117. float4 tess;
  118. if (WorldViewFrustumCull(pos0, pos1, pos2, maxDisplacement, planes))
  119. {
  120. tess = 0.0f;
  121. }
  122. else
  123. {
  124. tess.x = CalcEdgeTessFactor (pos1, pos2, edgeLength, cameraPos, scParams);
  125. tess.y = CalcEdgeTessFactor (pos2, pos0, edgeLength, cameraPos, scParams);
  126. tess.z = CalcEdgeTessFactor (pos0, pos1, edgeLength, cameraPos, scParams);
  127. tess.w = (tess.x + tess.y + tess.z) / 3.0f;
  128. }
  129. return tess;
  130. }
  131. #endif //ASE_TESS_FUNCS
  132. ENDHLSL
  133. Pass
  134. {
  135. Name "Forward"
  136. Tags { "LightMode"="UniversalForward" }
  137. Blend One Zero, One Zero
  138. ZWrite On
  139. ZTest LEqual
  140. Offset 0 , 0
  141. ColorMask RGBA
  142. HLSLPROGRAM
  143. #define _SPECULAR_SETUP 1
  144. #define _NORMAL_DROPOFF_TS 1
  145. #pragma multi_compile_instancing
  146. #pragma multi_compile _ LOD_FADE_CROSSFADE
  147. #pragma multi_compile_fog
  148. #define ASE_FOG 1
  149. #define _NORMALMAP 1
  150. #define ASE_SRP_VERSION 100500
  151. #define ASE_USING_SAMPLING_MACROS 1
  152. #pragma multi_compile _ _SCREEN_SPACE_OCCLUSION
  153. #pragma multi_compile _ _MAIN_LIGHT_SHADOWS
  154. #pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
  155. #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS _ADDITIONAL_OFF
  156. #pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
  157. #pragma multi_compile _ _SHADOWS_SOFT
  158. #pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE
  159. #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
  160. #pragma multi_compile _ SHADOWS_SHADOWMASK
  161. #pragma multi_compile _ DIRLIGHTMAP_COMBINED
  162. #pragma multi_compile _ LIGHTMAP_ON
  163. #pragma vertex vert
  164. #pragma fragment frag
  165. #define SHADERPASS_FORWARD
  166. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  167. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  168. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  169. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/UnityInstancing.hlsl"
  170. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  171. #if ASE_SRP_VERSION <= 70108
  172. #define REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR
  173. #endif
  174. #if defined(UNITY_INSTANCING_ENABLED) && defined(_TERRAIN_INSTANCED_PERPIXEL_NORMAL)
  175. #define ENABLE_TERRAIN_PERPIXEL_NORMAL
  176. #endif
  177. #define ASE_NEEDS_FRAG_WORLD_NORMAL
  178. #define ASE_NEEDS_FRAG_WORLD_POSITION
  179. #define ASE_NEEDS_FRAG_WORLD_TANGENT
  180. #define ASE_NEEDS_FRAG_WORLD_BITANGENT
  181. #include "../MTECommonPBR.hlsl"
  182. struct VertexInput
  183. {
  184. float4 vertex : POSITION;
  185. float3 ase_normal : NORMAL;
  186. float4 ase_tangent : TANGENT;
  187. float4 texcoord1 : TEXCOORD1;
  188. float4 texcoord : TEXCOORD0;
  189. UNITY_VERTEX_INPUT_INSTANCE_ID
  190. };
  191. struct VertexOutput
  192. {
  193. float4 clipPos : SV_POSITION;
  194. float4 lightmapUVOrVertexSH : TEXCOORD0;
  195. half4 fogFactorAndVertexLight : TEXCOORD1;
  196. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  197. float4 shadowCoord : TEXCOORD2;
  198. #endif
  199. float4 tSpace0 : TEXCOORD3;
  200. float4 tSpace1 : TEXCOORD4;
  201. float4 tSpace2 : TEXCOORD5;
  202. #if defined(ASE_NEEDS_FRAG_SCREEN_POSITION)
  203. float4 screenPos : TEXCOORD6;
  204. #endif
  205. float4 ase_texcoord7 : TEXCOORD7;
  206. UNITY_VERTEX_INPUT_INSTANCE_ID
  207. UNITY_VERTEX_OUTPUT_STEREO
  208. };
  209. CBUFFER_START(UnityPerMaterial)
  210. float4 _UVScaleOffset;
  211. float4 _Control0_ST;
  212. float4 _Control1_ST;
  213. float4 _Control2_ST;
  214. float4 _SpecColor;
  215. float _Smoothness;
  216. #ifdef _TRANSMISSION_ASE
  217. float _TransmissionShadow;
  218. #endif
  219. #ifdef _TRANSLUCENCY_ASE
  220. float _TransStrength;
  221. float _TransNormal;
  222. float _TransScattering;
  223. float _TransDirect;
  224. float _TransAmbient;
  225. float _TransShadow;
  226. #endif
  227. #ifdef TESSELLATION_ON
  228. float _TessPhongStrength;
  229. float _TessValue;
  230. float _TessMin;
  231. float _TessMax;
  232. float _TessEdgeLength;
  233. float _TessMaxDisp;
  234. #endif
  235. CBUFFER_END
  236. TEXTURE2D_ARRAY(_SplatArray);
  237. SAMPLER(sampler_SplatArray);
  238. TEXTURE2D_ARRAY(_NormalArray);
  239. SAMPLER(sampler_NormalArray);
  240. TEXTURE2D(_Control0);
  241. SAMPLER(sampler_Control0);
  242. TEXTURE2D(_Control1);
  243. SAMPLER(sampler_Control1);
  244. TEXTURE2D(_Control2);
  245. SAMPLER(sampler_Control2);
  246. void TriplanarBlendLayers( float3 WorldNormal, float3 WorldPos, TEXTURE2D_ARRAY(AlbedoArray), SamplerState AlbedoArraySampler, TEXTURE2D_ARRAY(NormalArray), SamplerState NormalArraySampler, float4 UVScaleOffset, float4 Weights, float4 Indices, out float4 OutAlbedo, out float3 OutWorldNormal )
  247. {
  248. //Dependency: MTECommonPBR.hlsl
  249. // calculate triplanar blend
  250. half3 triblend = saturate(pow(WorldNormal, 4));
  251. triblend /= max(dot(triblend, half3(1,1,1)), 0.0001);
  252. // calculate triplanar uvs
  253. // applying texture scale and offset values
  254. float2 uvX = WorldPos.zy * UVScaleOffset.xy + UVScaleOffset.zw;
  255. float2 uvY = WorldPos.xz * UVScaleOffset.xy + UVScaleOffset.zw;
  256. float2 uvZ = WorldPos.xy * UVScaleOffset.xy + UVScaleOffset.zw;
  257. // offset UVs to prevent obvious mirroring
  258. //uvY += 0.33;
  259. //uvZ += 0.67;
  260. // minor optimization of sign(). prevents return value of 0
  261. half3 axisSign = WorldNormal < 0 ? -1 : 1;
  262. // flip UVs horizontally to correct for back side projection
  263. uvX.x *= axisSign.x;
  264. uvY.x *= axisSign.y;
  265. uvZ.x *= -axisSign.z;
  266. // albedo textures
  267. OutAlbedo = 0;
  268. OutWorldNormal = 0;
  269. for(int i = 0; i < 4; i++)
  270. {
  271. int index = Indices[i];
  272. float weight = Weights[i];
  273. float4 colX = SAMPLE_TEXTURE2D_ARRAY(AlbedoArray, AlbedoArraySampler, uvX, index);
  274. float4 colY = SAMPLE_TEXTURE2D_ARRAY(AlbedoArray, AlbedoArraySampler, uvY, index);
  275. float4 colZ = SAMPLE_TEXTURE2D_ARRAY(AlbedoArray, AlbedoArraySampler, uvZ, index);
  276. float4 albedo = colX * triblend.x + colY * triblend.y + colZ * triblend.z;
  277. OutAlbedo += albedo * weight;
  278. // tangent space normal maps
  279. half3 tnormalX = UnpackNormal(SAMPLE_TEXTURE2D_ARRAY(NormalArray, NormalArraySampler, uvX, index));
  280. half3 tnormalY = UnpackNormal(SAMPLE_TEXTURE2D_ARRAY(NormalArray, NormalArraySampler, uvY, index));
  281. half3 tnormalZ = UnpackNormal(SAMPLE_TEXTURE2D_ARRAY(NormalArray, NormalArraySampler, uvZ, index));
  282. // flip normal maps' x axis to account for flipped UVs
  283. tnormalX.x *= axisSign.x;
  284. tnormalY.x *= axisSign.y;
  285. tnormalZ.x *= -axisSign.z;
  286. half3 absVertNormal = abs(WorldNormal);
  287. // swizzle world normals to match tangent space and apply reoriented normal mapping blend
  288. tnormalX = blend_rnm(half3(WorldNormal.zy, absVertNormal.x), tnormalX);
  289. tnormalY = blend_rnm(half3(WorldNormal.xz, absVertNormal.y), tnormalY);
  290. tnormalZ = blend_rnm(half3(WorldNormal.xy, absVertNormal.z), tnormalZ);
  291. // apply world space sign to tangent space Z
  292. tnormalX.z *= axisSign.x;
  293. tnormalY.z *= axisSign.y;
  294. tnormalZ.z *= axisSign.z;
  295. // sizzle tangent normals to match world normal and blend together
  296. float3 normal = normalize(
  297. tnormalX.zyx * triblend.x +
  298. tnormalY.xzy * triblend.y +
  299. tnormalZ.xyz * triblend.z
  300. );
  301. OutWorldNormal += normal * weight;
  302. }
  303. }
  304. VertexOutput VertexFunction( VertexInput v )
  305. {
  306. VertexOutput o = (VertexOutput)0;
  307. UNITY_SETUP_INSTANCE_ID(v);
  308. UNITY_TRANSFER_INSTANCE_ID(v, o);
  309. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
  310. o.ase_texcoord7.xy = v.texcoord.xy;
  311. //setting value to unused interpolator channels and avoid initialization warnings
  312. o.ase_texcoord7.zw = 0;
  313. #ifdef ASE_ABSOLUTE_VERTEX_POS
  314. float3 defaultVertexValue = v.vertex.xyz;
  315. #else
  316. float3 defaultVertexValue = float3(0, 0, 0);
  317. #endif
  318. float3 vertexValue = defaultVertexValue;
  319. #ifdef ASE_ABSOLUTE_VERTEX_POS
  320. v.vertex.xyz = vertexValue;
  321. #else
  322. v.vertex.xyz += vertexValue;
  323. #endif
  324. v.ase_normal = v.ase_normal;
  325. float3 positionWS = TransformObjectToWorld( v.vertex.xyz );
  326. float3 positionVS = TransformWorldToView( positionWS );
  327. float4 positionCS = TransformWorldToHClip( positionWS );
  328. VertexNormalInputs normalInput = GetVertexNormalInputs( v.ase_normal, v.ase_tangent );
  329. o.tSpace0 = float4( normalInput.normalWS, positionWS.x);
  330. o.tSpace1 = float4( normalInput.tangentWS, positionWS.y);
  331. o.tSpace2 = float4( normalInput.bitangentWS, positionWS.z);
  332. OUTPUT_LIGHTMAP_UV( v.texcoord1, unity_LightmapST, o.lightmapUVOrVertexSH.xy );
  333. OUTPUT_SH( normalInput.normalWS.xyz, o.lightmapUVOrVertexSH.xyz );
  334. #if defined(ENABLE_TERRAIN_PERPIXEL_NORMAL)
  335. o.lightmapUVOrVertexSH.zw = v.texcoord;
  336. o.lightmapUVOrVertexSH.xy = v.texcoord * unity_LightmapST.xy + unity_LightmapST.zw;
  337. #endif
  338. half3 vertexLight = VertexLighting( positionWS, normalInput.normalWS );
  339. #ifdef ASE_FOG
  340. half fogFactor = ComputeFogFactor( positionCS.z );
  341. #else
  342. half fogFactor = 0;
  343. #endif
  344. o.fogFactorAndVertexLight = half4(fogFactor, vertexLight);
  345. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  346. VertexPositionInputs vertexInput = (VertexPositionInputs)0;
  347. vertexInput.positionWS = positionWS;
  348. vertexInput.positionCS = positionCS;
  349. o.shadowCoord = GetShadowCoord( vertexInput );
  350. #endif
  351. o.clipPos = positionCS;
  352. #if defined(ASE_NEEDS_FRAG_SCREEN_POSITION)
  353. o.screenPos = ComputeScreenPos(positionCS);
  354. #endif
  355. return o;
  356. }
  357. #if defined(TESSELLATION_ON)
  358. struct VertexControl
  359. {
  360. float4 vertex : INTERNALTESSPOS;
  361. float3 ase_normal : NORMAL;
  362. float4 ase_tangent : TANGENT;
  363. float4 texcoord : TEXCOORD0;
  364. float4 texcoord1 : TEXCOORD1;
  365. UNITY_VERTEX_INPUT_INSTANCE_ID
  366. };
  367. struct TessellationFactors
  368. {
  369. float edge[3] : SV_TessFactor;
  370. float inside : SV_InsideTessFactor;
  371. };
  372. VertexControl vert ( VertexInput v )
  373. {
  374. VertexControl o;
  375. UNITY_SETUP_INSTANCE_ID(v);
  376. UNITY_TRANSFER_INSTANCE_ID(v, o);
  377. o.vertex = v.vertex;
  378. o.ase_normal = v.ase_normal;
  379. o.ase_tangent = v.ase_tangent;
  380. o.texcoord = v.texcoord;
  381. o.texcoord1 = v.texcoord1;
  382. return o;
  383. }
  384. TessellationFactors TessellationFunction (InputPatch<VertexControl,3> v)
  385. {
  386. TessellationFactors o;
  387. float4 tf = 1;
  388. float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
  389. float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
  390. #if defined(ASE_FIXED_TESSELLATION)
  391. tf = FixedTess( tessValue );
  392. #elif defined(ASE_DISTANCE_TESSELLATION)
  393. tf = DistanceBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
  394. #elif defined(ASE_LENGTH_TESSELLATION)
  395. tf = EdgeLengthBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
  396. #elif defined(ASE_LENGTH_CULL_TESSELLATION)
  397. tf = EdgeLengthBasedTessCull(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
  398. #endif
  399. o.edge[0] = tf.x; o.edge[1] = tf.y; o.edge[2] = tf.z; o.inside = tf.w;
  400. return o;
  401. }
  402. [domain("tri")]
  403. [partitioning("fractional_odd")]
  404. [outputtopology("triangle_cw")]
  405. [patchconstantfunc("TessellationFunction")]
  406. [outputcontrolpoints(3)]
  407. VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
  408. {
  409. return patch[id];
  410. }
  411. [domain("tri")]
  412. VertexOutput DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
  413. {
  414. VertexInput o = (VertexInput) 0;
  415. o.vertex = patch[0].vertex * bary.x + patch[1].vertex * bary.y + patch[2].vertex * bary.z;
  416. o.ase_normal = patch[0].ase_normal * bary.x + patch[1].ase_normal * bary.y + patch[2].ase_normal * bary.z;
  417. o.ase_tangent = patch[0].ase_tangent * bary.x + patch[1].ase_tangent * bary.y + patch[2].ase_tangent * bary.z;
  418. o.texcoord = patch[0].texcoord * bary.x + patch[1].texcoord * bary.y + patch[2].texcoord * bary.z;
  419. o.texcoord1 = patch[0].texcoord1 * bary.x + patch[1].texcoord1 * bary.y + patch[2].texcoord1 * bary.z;
  420. #if defined(ASE_PHONG_TESSELLATION)
  421. float3 pp[3];
  422. for (int i = 0; i < 3; ++i)
  423. pp[i] = o.vertex.xyz - patch[i].ase_normal * (dot(o.vertex.xyz, patch[i].ase_normal) - dot(patch[i].vertex.xyz, patch[i].ase_normal));
  424. float phongStrength = _TessPhongStrength;
  425. o.vertex.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.vertex.xyz;
  426. #endif
  427. UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
  428. return VertexFunction(o);
  429. }
  430. #else
  431. VertexOutput vert ( VertexInput v )
  432. {
  433. return VertexFunction( v );
  434. }
  435. #endif
  436. #if defined(ASE_EARLY_Z_DEPTH_OPTIMIZE)
  437. #define ASE_SV_DEPTH SV_DepthLessEqual
  438. #else
  439. #define ASE_SV_DEPTH SV_Depth
  440. #endif
  441. half4 frag ( VertexOutput IN
  442. #ifdef ASE_DEPTH_WRITE_ON
  443. ,out float outputDepth : ASE_SV_DEPTH
  444. #endif
  445. ) : SV_Target
  446. {
  447. UNITY_SETUP_INSTANCE_ID(IN);
  448. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(IN);
  449. #ifdef LOD_FADE_CROSSFADE
  450. LODDitheringTransition( IN.clipPos.xyz, unity_LODFade.x );
  451. #endif
  452. #if defined(ENABLE_TERRAIN_PERPIXEL_NORMAL)
  453. float2 sampleCoords = (IN.lightmapUVOrVertexSH.zw / _TerrainHeightmapRecipSize.zw + 0.5f) * _TerrainHeightmapRecipSize.xy;
  454. float3 WorldNormal = TransformObjectToWorldNormal(normalize(SAMPLE_TEXTURE2D(_TerrainNormalmapTexture, sampler_TerrainNormalmapTexture, sampleCoords).rgb * 2 - 1));
  455. float3 WorldTangent = -cross(GetObjectToWorldMatrix()._13_23_33, WorldNormal);
  456. float3 WorldBiTangent = cross(WorldNormal, -WorldTangent);
  457. #else
  458. float3 WorldNormal = normalize( IN.tSpace0.xyz );
  459. float3 WorldTangent = IN.tSpace1.xyz;
  460. float3 WorldBiTangent = IN.tSpace2.xyz;
  461. #endif
  462. float3 WorldPosition = float3(IN.tSpace0.w,IN.tSpace1.w,IN.tSpace2.w);
  463. float3 WorldViewDirection = _WorldSpaceCameraPos.xyz - WorldPosition;
  464. float4 ShadowCoords = float4( 0, 0, 0, 0 );
  465. #if defined(ASE_NEEDS_FRAG_SCREEN_POSITION)
  466. float4 ScreenPos = IN.screenPos;
  467. #endif
  468. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  469. ShadowCoords = IN.shadowCoord;
  470. #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
  471. ShadowCoords = TransformWorldToShadowCoord( WorldPosition );
  472. #endif
  473. WorldViewDirection = SafeNormalize( WorldViewDirection );
  474. float4 localBreakRGBA115 = ( float4( 0,0,0,0 ) );
  475. float localTriplanarBlendLayers307 = ( 0.0 );
  476. float3 WorldNormal307 = WorldNormal;
  477. float3 WorldPos307 = WorldPosition;
  478. TEXTURE2D_ARRAY(AlbedoArray307) = _SplatArray;
  479. SamplerState AlbedoArraySampler307 = sampler_SplatArray;
  480. TEXTURE2D_ARRAY(NormalArray307) = _NormalArray;
  481. SamplerState NormalArraySampler307 = sampler_NormalArray;
  482. float4 UVScaleOffset307 = _UVScaleOffset;
  483. float localGetMax4WeightLayers169 = ( 0.0 );
  484. float2 uv_Control0 = IN.ase_texcoord7.xy * _Control0_ST.xy + _Control0_ST.zw;
  485. float4 Control0169 = SAMPLE_TEXTURE2D( _Control0, sampler_Control0, uv_Control0 );
  486. float2 uv_Control1 = IN.ase_texcoord7.xy * _Control1_ST.xy + _Control1_ST.zw;
  487. float4 Control1169 = SAMPLE_TEXTURE2D( _Control1, sampler_Control1, uv_Control1 );
  488. float2 uv_Control2 = IN.ase_texcoord7.xy * _Control2_ST.xy + _Control2_ST.zw;
  489. float4 Control2169 = SAMPLE_TEXTURE2D( _Control2, sampler_Control2, uv_Control2 );
  490. float4 Weights169 = float4( 1,0,0,0 );
  491. float4 Indices169 = float4( 1,0,0,0 );
  492. {
  493. Max4WeightLayer(Control0169, Control1169, Control2169, Weights169, Indices169);
  494. }
  495. float4 Weights307 = Weights169;
  496. float4 Indices307 = Indices169;
  497. float4 OutAlbedo307 = float4( 0,0,0,0 );
  498. float3 OutWorldNormal307 = float3( 0,0,0 );
  499. TriplanarBlendLayers( WorldNormal307 , WorldPos307 , AlbedoArray307 , AlbedoArraySampler307 , NormalArray307 , NormalArraySampler307 , UVScaleOffset307 , Weights307 , Indices307 , OutAlbedo307 , OutWorldNormal307 );
  500. float4 RGBA115 = OutAlbedo307;
  501. float3 RGB115 = float3( 0,0,0 );
  502. float A115 = 0;
  503. {
  504. RGB115 = RGBA115.rgb;
  505. A115 = RGBA115.a;
  506. }
  507. float3x3 ase_worldToTangent = float3x3(WorldTangent,WorldBiTangent,WorldNormal);
  508. float3 worldToTangentDir337 = mul( ase_worldToTangent, OutWorldNormal307);
  509. float3 Albedo = RGB115;
  510. float3 Normal = worldToTangentDir337;
  511. float3 Emission = 0;
  512. float3 Specular = _SpecColor.rgb;
  513. float Metallic = 0;
  514. float Smoothness = _Smoothness;
  515. float Occlusion = 1;
  516. float Alpha = 1;
  517. float AlphaClipThreshold = 0.5;
  518. float AlphaClipThresholdShadow = 0.5;
  519. float3 BakedGI = 0;
  520. float3 RefractionColor = 1;
  521. float RefractionIndex = 1;
  522. float3 Transmission = 1;
  523. float3 Translucency = 1;
  524. #ifdef ASE_DEPTH_WRITE_ON
  525. float DepthValue = 0;
  526. #endif
  527. #ifdef _ALPHATEST_ON
  528. clip(Alpha - AlphaClipThreshold);
  529. #endif
  530. InputData inputData;
  531. inputData.positionWS = WorldPosition;
  532. inputData.viewDirectionWS = WorldViewDirection;
  533. inputData.shadowCoord = ShadowCoords;
  534. #ifdef _NORMALMAP
  535. #if _NORMAL_DROPOFF_TS
  536. inputData.normalWS = TransformTangentToWorld(Normal, half3x3( WorldTangent, WorldBiTangent, WorldNormal ));
  537. #elif _NORMAL_DROPOFF_OS
  538. inputData.normalWS = TransformObjectToWorldNormal(Normal);
  539. #elif _NORMAL_DROPOFF_WS
  540. inputData.normalWS = Normal;
  541. #endif
  542. inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS);
  543. #else
  544. inputData.normalWS = WorldNormal;
  545. #endif
  546. #ifdef ASE_FOG
  547. inputData.fogCoord = IN.fogFactorAndVertexLight.x;
  548. #endif
  549. inputData.vertexLighting = IN.fogFactorAndVertexLight.yzw;
  550. #if defined(ENABLE_TERRAIN_PERPIXEL_NORMAL)
  551. float3 SH = SampleSH(inputData.normalWS.xyz);
  552. #else
  553. float3 SH = IN.lightmapUVOrVertexSH.xyz;
  554. #endif
  555. inputData.bakedGI = SAMPLE_GI( IN.lightmapUVOrVertexSH.xy, SH, inputData.normalWS );
  556. #ifdef _ASE_BAKEDGI
  557. inputData.bakedGI = BakedGI;
  558. #endif
  559. inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(IN.clipPos);
  560. inputData.shadowMask = SAMPLE_SHADOWMASK(IN.lightmapUVOrVertexSH.xy);
  561. half4 color = UniversalFragmentPBR(
  562. inputData,
  563. Albedo,
  564. Metallic,
  565. Specular,
  566. Smoothness,
  567. Occlusion,
  568. Emission,
  569. Alpha);
  570. #ifdef _TRANSMISSION_ASE
  571. {
  572. float shadow = _TransmissionShadow;
  573. Light mainLight = GetMainLight( inputData.shadowCoord );
  574. float3 mainAtten = mainLight.color * mainLight.distanceAttenuation;
  575. mainAtten = lerp( mainAtten, mainAtten * mainLight.shadowAttenuation, shadow );
  576. half3 mainTransmission = max(0 , -dot(inputData.normalWS, mainLight.direction)) * mainAtten * Transmission;
  577. color.rgb += Albedo * mainTransmission;
  578. #ifdef _ADDITIONAL_LIGHTS
  579. int transPixelLightCount = GetAdditionalLightsCount();
  580. for (int i = 0; i < transPixelLightCount; ++i)
  581. {
  582. Light light = GetAdditionalLight(i, inputData.positionWS);
  583. float3 atten = light.color * light.distanceAttenuation;
  584. atten = lerp( atten, atten * light.shadowAttenuation, shadow );
  585. half3 transmission = max(0 , -dot(inputData.normalWS, light.direction)) * atten * Transmission;
  586. color.rgb += Albedo * transmission;
  587. }
  588. #endif
  589. }
  590. #endif
  591. #ifdef _TRANSLUCENCY_ASE
  592. {
  593. float shadow = _TransShadow;
  594. float normal = _TransNormal;
  595. float scattering = _TransScattering;
  596. float direct = _TransDirect;
  597. float ambient = _TransAmbient;
  598. float strength = _TransStrength;
  599. Light mainLight = GetMainLight( inputData.shadowCoord );
  600. float3 mainAtten = mainLight.color * mainLight.distanceAttenuation;
  601. mainAtten = lerp( mainAtten, mainAtten * mainLight.shadowAttenuation, shadow );
  602. half3 mainLightDir = mainLight.direction + inputData.normalWS * normal;
  603. half mainVdotL = pow( saturate( dot( inputData.viewDirectionWS, -mainLightDir ) ), scattering );
  604. half3 mainTranslucency = mainAtten * ( mainVdotL * direct + inputData.bakedGI * ambient ) * Translucency;
  605. color.rgb += Albedo * mainTranslucency * strength;
  606. #ifdef _ADDITIONAL_LIGHTS
  607. int transPixelLightCount = GetAdditionalLightsCount();
  608. for (int i = 0; i < transPixelLightCount; ++i)
  609. {
  610. Light light = GetAdditionalLight(i, inputData.positionWS);
  611. float3 atten = light.color * light.distanceAttenuation;
  612. atten = lerp( atten, atten * light.shadowAttenuation, shadow );
  613. half3 lightDir = light.direction + inputData.normalWS * normal;
  614. half VdotL = pow( saturate( dot( inputData.viewDirectionWS, -lightDir ) ), scattering );
  615. half3 translucency = atten * ( VdotL * direct + inputData.bakedGI * ambient ) * Translucency;
  616. color.rgb += Albedo * translucency * strength;
  617. }
  618. #endif
  619. }
  620. #endif
  621. #ifdef _REFRACTION_ASE
  622. float4 projScreenPos = ScreenPos / ScreenPos.w;
  623. float3 refractionOffset = ( RefractionIndex - 1.0 ) * mul( UNITY_MATRIX_V, float4( WorldNormal,0 ) ).xyz * ( 1.0 - dot( WorldNormal, WorldViewDirection ) );
  624. projScreenPos.xy += refractionOffset.xy;
  625. float3 refraction = SHADERGRAPH_SAMPLE_SCENE_COLOR( projScreenPos.xy ) * RefractionColor;
  626. color.rgb = lerp( refraction, color.rgb, color.a );
  627. color.a = 1;
  628. #endif
  629. #ifdef ASE_FINAL_COLOR_ALPHA_MULTIPLY
  630. color.rgb *= color.a;
  631. #endif
  632. #ifdef ASE_FOG
  633. #ifdef TERRAIN_SPLAT_ADDPASS
  634. color.rgb = MixFogColor(color.rgb, half3( 0, 0, 0 ), IN.fogFactorAndVertexLight.x );
  635. #else
  636. color.rgb = MixFog(color.rgb, IN.fogFactorAndVertexLight.x);
  637. #endif
  638. #endif
  639. #ifdef ASE_DEPTH_WRITE_ON
  640. outputDepth = DepthValue;
  641. #endif
  642. return color;
  643. }
  644. ENDHLSL
  645. }
  646. Pass
  647. {
  648. Name "ShadowCaster"
  649. Tags { "LightMode"="ShadowCaster" }
  650. ZWrite On
  651. ZTest LEqual
  652. AlphaToMask Off
  653. ColorMask 0
  654. HLSLPROGRAM
  655. #define _SPECULAR_SETUP 1
  656. #define _NORMAL_DROPOFF_TS 1
  657. #pragma multi_compile_instancing
  658. #pragma multi_compile _ LOD_FADE_CROSSFADE
  659. #pragma multi_compile_fog
  660. #define ASE_FOG 1
  661. #define _NORMALMAP 1
  662. #define ASE_SRP_VERSION 100500
  663. #define ASE_USING_SAMPLING_MACROS 1
  664. #pragma vertex vert
  665. #pragma fragment frag
  666. #if ASE_SRP_VERSION >= 110000
  667. #pragma multi_compile _ _CASTING_PUNCTUAL_LIGHT_SHADOW
  668. #endif
  669. #define SHADERPASS_SHADOWCASTER
  670. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  671. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  672. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  673. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  674. #include "../MTECommonPBR.hlsl"
  675. struct VertexInput
  676. {
  677. float4 vertex : POSITION;
  678. float3 ase_normal : NORMAL;
  679. UNITY_VERTEX_INPUT_INSTANCE_ID
  680. };
  681. struct VertexOutput
  682. {
  683. float4 clipPos : SV_POSITION;
  684. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  685. float3 worldPos : TEXCOORD0;
  686. #endif
  687. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  688. float4 shadowCoord : TEXCOORD1;
  689. #endif
  690. UNITY_VERTEX_INPUT_INSTANCE_ID
  691. UNITY_VERTEX_OUTPUT_STEREO
  692. };
  693. CBUFFER_START(UnityPerMaterial)
  694. float4 _UVScaleOffset;
  695. float4 _Control0_ST;
  696. float4 _Control1_ST;
  697. float4 _Control2_ST;
  698. float4 _SpecColor;
  699. float _Smoothness;
  700. #ifdef _TRANSMISSION_ASE
  701. float _TransmissionShadow;
  702. #endif
  703. #ifdef _TRANSLUCENCY_ASE
  704. float _TransStrength;
  705. float _TransNormal;
  706. float _TransScattering;
  707. float _TransDirect;
  708. float _TransAmbient;
  709. float _TransShadow;
  710. #endif
  711. #ifdef TESSELLATION_ON
  712. float _TessPhongStrength;
  713. float _TessValue;
  714. float _TessMin;
  715. float _TessMax;
  716. float _TessEdgeLength;
  717. float _TessMaxDisp;
  718. #endif
  719. CBUFFER_END
  720. float3 _LightDirection;
  721. #if ASE_SRP_VERSION >= 110000
  722. float3 _LightPosition;
  723. #endif
  724. VertexOutput VertexFunction( VertexInput v )
  725. {
  726. VertexOutput o;
  727. UNITY_SETUP_INSTANCE_ID(v);
  728. UNITY_TRANSFER_INSTANCE_ID(v, o);
  729. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( o );
  730. #ifdef ASE_ABSOLUTE_VERTEX_POS
  731. float3 defaultVertexValue = v.vertex.xyz;
  732. #else
  733. float3 defaultVertexValue = float3(0, 0, 0);
  734. #endif
  735. float3 vertexValue = defaultVertexValue;
  736. #ifdef ASE_ABSOLUTE_VERTEX_POS
  737. v.vertex.xyz = vertexValue;
  738. #else
  739. v.vertex.xyz += vertexValue;
  740. #endif
  741. v.ase_normal = v.ase_normal;
  742. float3 positionWS = TransformObjectToWorld( v.vertex.xyz );
  743. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  744. o.worldPos = positionWS;
  745. #endif
  746. float3 normalWS = TransformObjectToWorldDir(v.ase_normal);
  747. #if ASE_SRP_VERSION >= 110000
  748. #if _CASTING_PUNCTUAL_LIGHT_SHADOW
  749. float3 lightDirectionWS = normalize(_LightPosition - positionWS);
  750. #else
  751. float3 lightDirectionWS = _LightDirection;
  752. #endif
  753. float4 clipPos = TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS, lightDirectionWS));
  754. #if UNITY_REVERSED_Z
  755. clipPos.z = min(clipPos.z, UNITY_NEAR_CLIP_VALUE);
  756. #else
  757. clipPos.z = max(clipPos.z, UNITY_NEAR_CLIP_VALUE);
  758. #endif
  759. #else
  760. float4 clipPos = TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS, _LightDirection));
  761. #if UNITY_REVERSED_Z
  762. clipPos.z = min(clipPos.z, clipPos.w * UNITY_NEAR_CLIP_VALUE);
  763. #else
  764. clipPos.z = max(clipPos.z, clipPos.w * UNITY_NEAR_CLIP_VALUE);
  765. #endif
  766. #endif
  767. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  768. VertexPositionInputs vertexInput = (VertexPositionInputs)0;
  769. vertexInput.positionWS = positionWS;
  770. vertexInput.positionCS = clipPos;
  771. o.shadowCoord = GetShadowCoord( vertexInput );
  772. #endif
  773. o.clipPos = clipPos;
  774. return o;
  775. }
  776. #if defined(TESSELLATION_ON)
  777. struct VertexControl
  778. {
  779. float4 vertex : INTERNALTESSPOS;
  780. float3 ase_normal : NORMAL;
  781. UNITY_VERTEX_INPUT_INSTANCE_ID
  782. };
  783. struct TessellationFactors
  784. {
  785. float edge[3] : SV_TessFactor;
  786. float inside : SV_InsideTessFactor;
  787. };
  788. VertexControl vert ( VertexInput v )
  789. {
  790. VertexControl o;
  791. UNITY_SETUP_INSTANCE_ID(v);
  792. UNITY_TRANSFER_INSTANCE_ID(v, o);
  793. o.vertex = v.vertex;
  794. o.ase_normal = v.ase_normal;
  795. return o;
  796. }
  797. TessellationFactors TessellationFunction (InputPatch<VertexControl,3> v)
  798. {
  799. TessellationFactors o;
  800. float4 tf = 1;
  801. float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
  802. float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
  803. #if defined(ASE_FIXED_TESSELLATION)
  804. tf = FixedTess( tessValue );
  805. #elif defined(ASE_DISTANCE_TESSELLATION)
  806. tf = DistanceBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
  807. #elif defined(ASE_LENGTH_TESSELLATION)
  808. tf = EdgeLengthBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
  809. #elif defined(ASE_LENGTH_CULL_TESSELLATION)
  810. tf = EdgeLengthBasedTessCull(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
  811. #endif
  812. o.edge[0] = tf.x; o.edge[1] = tf.y; o.edge[2] = tf.z; o.inside = tf.w;
  813. return o;
  814. }
  815. [domain("tri")]
  816. [partitioning("fractional_odd")]
  817. [outputtopology("triangle_cw")]
  818. [patchconstantfunc("TessellationFunction")]
  819. [outputcontrolpoints(3)]
  820. VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
  821. {
  822. return patch[id];
  823. }
  824. [domain("tri")]
  825. VertexOutput DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
  826. {
  827. VertexInput o = (VertexInput) 0;
  828. o.vertex = patch[0].vertex * bary.x + patch[1].vertex * bary.y + patch[2].vertex * bary.z;
  829. o.ase_normal = patch[0].ase_normal * bary.x + patch[1].ase_normal * bary.y + patch[2].ase_normal * bary.z;
  830. #if defined(ASE_PHONG_TESSELLATION)
  831. float3 pp[3];
  832. for (int i = 0; i < 3; ++i)
  833. pp[i] = o.vertex.xyz - patch[i].ase_normal * (dot(o.vertex.xyz, patch[i].ase_normal) - dot(patch[i].vertex.xyz, patch[i].ase_normal));
  834. float phongStrength = _TessPhongStrength;
  835. o.vertex.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.vertex.xyz;
  836. #endif
  837. UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
  838. return VertexFunction(o);
  839. }
  840. #else
  841. VertexOutput vert ( VertexInput v )
  842. {
  843. return VertexFunction( v );
  844. }
  845. #endif
  846. #if defined(ASE_EARLY_Z_DEPTH_OPTIMIZE)
  847. #define ASE_SV_DEPTH SV_DepthLessEqual
  848. #else
  849. #define ASE_SV_DEPTH SV_Depth
  850. #endif
  851. half4 frag( VertexOutput IN
  852. #ifdef ASE_DEPTH_WRITE_ON
  853. ,out float outputDepth : ASE_SV_DEPTH
  854. #endif
  855. ) : SV_TARGET
  856. {
  857. UNITY_SETUP_INSTANCE_ID( IN );
  858. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( IN );
  859. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  860. float3 WorldPosition = IN.worldPos;
  861. #endif
  862. float4 ShadowCoords = float4( 0, 0, 0, 0 );
  863. #if defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  864. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  865. ShadowCoords = IN.shadowCoord;
  866. #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
  867. ShadowCoords = TransformWorldToShadowCoord( WorldPosition );
  868. #endif
  869. #endif
  870. float Alpha = 1;
  871. float AlphaClipThreshold = 0.5;
  872. float AlphaClipThresholdShadow = 0.5;
  873. #ifdef ASE_DEPTH_WRITE_ON
  874. float DepthValue = 0;
  875. #endif
  876. #ifdef _ALPHATEST_ON
  877. #ifdef _ALPHATEST_SHADOW_ON
  878. clip(Alpha - AlphaClipThresholdShadow);
  879. #else
  880. clip(Alpha - AlphaClipThreshold);
  881. #endif
  882. #endif
  883. #ifdef LOD_FADE_CROSSFADE
  884. LODDitheringTransition( IN.clipPos.xyz, unity_LODFade.x );
  885. #endif
  886. #ifdef ASE_DEPTH_WRITE_ON
  887. outputDepth = DepthValue;
  888. #endif
  889. return 0;
  890. }
  891. ENDHLSL
  892. }
  893. Pass
  894. {
  895. Name "DepthOnly"
  896. Tags { "LightMode"="DepthOnly" }
  897. ZWrite On
  898. ColorMask 0
  899. AlphaToMask Off
  900. HLSLPROGRAM
  901. #define _SPECULAR_SETUP 1
  902. #define _NORMAL_DROPOFF_TS 1
  903. #pragma multi_compile_instancing
  904. #pragma multi_compile _ LOD_FADE_CROSSFADE
  905. #pragma multi_compile_fog
  906. #define ASE_FOG 1
  907. #define _NORMALMAP 1
  908. #define ASE_SRP_VERSION 100500
  909. #define ASE_USING_SAMPLING_MACROS 1
  910. #pragma vertex vert
  911. #pragma fragment frag
  912. #define SHADERPASS_DEPTHONLY
  913. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  914. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  915. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  916. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  917. #include "../MTECommonPBR.hlsl"
  918. struct VertexInput
  919. {
  920. float4 vertex : POSITION;
  921. float3 ase_normal : NORMAL;
  922. UNITY_VERTEX_INPUT_INSTANCE_ID
  923. };
  924. struct VertexOutput
  925. {
  926. float4 clipPos : SV_POSITION;
  927. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  928. float3 worldPos : TEXCOORD0;
  929. #endif
  930. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  931. float4 shadowCoord : TEXCOORD1;
  932. #endif
  933. UNITY_VERTEX_INPUT_INSTANCE_ID
  934. UNITY_VERTEX_OUTPUT_STEREO
  935. };
  936. CBUFFER_START(UnityPerMaterial)
  937. float4 _UVScaleOffset;
  938. float4 _Control0_ST;
  939. float4 _Control1_ST;
  940. float4 _Control2_ST;
  941. float4 _SpecColor;
  942. float _Smoothness;
  943. #ifdef _TRANSMISSION_ASE
  944. float _TransmissionShadow;
  945. #endif
  946. #ifdef _TRANSLUCENCY_ASE
  947. float _TransStrength;
  948. float _TransNormal;
  949. float _TransScattering;
  950. float _TransDirect;
  951. float _TransAmbient;
  952. float _TransShadow;
  953. #endif
  954. #ifdef TESSELLATION_ON
  955. float _TessPhongStrength;
  956. float _TessValue;
  957. float _TessMin;
  958. float _TessMax;
  959. float _TessEdgeLength;
  960. float _TessMaxDisp;
  961. #endif
  962. CBUFFER_END
  963. VertexOutput VertexFunction( VertexInput v )
  964. {
  965. VertexOutput o = (VertexOutput)0;
  966. UNITY_SETUP_INSTANCE_ID(v);
  967. UNITY_TRANSFER_INSTANCE_ID(v, o);
  968. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
  969. #ifdef ASE_ABSOLUTE_VERTEX_POS
  970. float3 defaultVertexValue = v.vertex.xyz;
  971. #else
  972. float3 defaultVertexValue = float3(0, 0, 0);
  973. #endif
  974. float3 vertexValue = defaultVertexValue;
  975. #ifdef ASE_ABSOLUTE_VERTEX_POS
  976. v.vertex.xyz = vertexValue;
  977. #else
  978. v.vertex.xyz += vertexValue;
  979. #endif
  980. v.ase_normal = v.ase_normal;
  981. float3 positionWS = TransformObjectToWorld( v.vertex.xyz );
  982. float4 positionCS = TransformWorldToHClip( positionWS );
  983. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  984. o.worldPos = positionWS;
  985. #endif
  986. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  987. VertexPositionInputs vertexInput = (VertexPositionInputs)0;
  988. vertexInput.positionWS = positionWS;
  989. vertexInput.positionCS = positionCS;
  990. o.shadowCoord = GetShadowCoord( vertexInput );
  991. #endif
  992. o.clipPos = positionCS;
  993. return o;
  994. }
  995. #if defined(TESSELLATION_ON)
  996. struct VertexControl
  997. {
  998. float4 vertex : INTERNALTESSPOS;
  999. float3 ase_normal : NORMAL;
  1000. UNITY_VERTEX_INPUT_INSTANCE_ID
  1001. };
  1002. struct TessellationFactors
  1003. {
  1004. float edge[3] : SV_TessFactor;
  1005. float inside : SV_InsideTessFactor;
  1006. };
  1007. VertexControl vert ( VertexInput v )
  1008. {
  1009. VertexControl o;
  1010. UNITY_SETUP_INSTANCE_ID(v);
  1011. UNITY_TRANSFER_INSTANCE_ID(v, o);
  1012. o.vertex = v.vertex;
  1013. o.ase_normal = v.ase_normal;
  1014. return o;
  1015. }
  1016. TessellationFactors TessellationFunction (InputPatch<VertexControl,3> v)
  1017. {
  1018. TessellationFactors o;
  1019. float4 tf = 1;
  1020. float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
  1021. float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
  1022. #if defined(ASE_FIXED_TESSELLATION)
  1023. tf = FixedTess( tessValue );
  1024. #elif defined(ASE_DISTANCE_TESSELLATION)
  1025. tf = DistanceBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
  1026. #elif defined(ASE_LENGTH_TESSELLATION)
  1027. tf = EdgeLengthBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
  1028. #elif defined(ASE_LENGTH_CULL_TESSELLATION)
  1029. tf = EdgeLengthBasedTessCull(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
  1030. #endif
  1031. o.edge[0] = tf.x; o.edge[1] = tf.y; o.edge[2] = tf.z; o.inside = tf.w;
  1032. return o;
  1033. }
  1034. [domain("tri")]
  1035. [partitioning("fractional_odd")]
  1036. [outputtopology("triangle_cw")]
  1037. [patchconstantfunc("TessellationFunction")]
  1038. [outputcontrolpoints(3)]
  1039. VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
  1040. {
  1041. return patch[id];
  1042. }
  1043. [domain("tri")]
  1044. VertexOutput DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
  1045. {
  1046. VertexInput o = (VertexInput) 0;
  1047. o.vertex = patch[0].vertex * bary.x + patch[1].vertex * bary.y + patch[2].vertex * bary.z;
  1048. o.ase_normal = patch[0].ase_normal * bary.x + patch[1].ase_normal * bary.y + patch[2].ase_normal * bary.z;
  1049. #if defined(ASE_PHONG_TESSELLATION)
  1050. float3 pp[3];
  1051. for (int i = 0; i < 3; ++i)
  1052. pp[i] = o.vertex.xyz - patch[i].ase_normal * (dot(o.vertex.xyz, patch[i].ase_normal) - dot(patch[i].vertex.xyz, patch[i].ase_normal));
  1053. float phongStrength = _TessPhongStrength;
  1054. o.vertex.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.vertex.xyz;
  1055. #endif
  1056. UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
  1057. return VertexFunction(o);
  1058. }
  1059. #else
  1060. VertexOutput vert ( VertexInput v )
  1061. {
  1062. return VertexFunction( v );
  1063. }
  1064. #endif
  1065. #if defined(ASE_EARLY_Z_DEPTH_OPTIMIZE)
  1066. #define ASE_SV_DEPTH SV_DepthLessEqual
  1067. #else
  1068. #define ASE_SV_DEPTH SV_Depth
  1069. #endif
  1070. half4 frag( VertexOutput IN
  1071. #ifdef ASE_DEPTH_WRITE_ON
  1072. ,out float outputDepth : ASE_SV_DEPTH
  1073. #endif
  1074. ) : SV_TARGET
  1075. {
  1076. UNITY_SETUP_INSTANCE_ID(IN);
  1077. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( IN );
  1078. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1079. float3 WorldPosition = IN.worldPos;
  1080. #endif
  1081. float4 ShadowCoords = float4( 0, 0, 0, 0 );
  1082. #if defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1083. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  1084. ShadowCoords = IN.shadowCoord;
  1085. #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
  1086. ShadowCoords = TransformWorldToShadowCoord( WorldPosition );
  1087. #endif
  1088. #endif
  1089. float Alpha = 1;
  1090. float AlphaClipThreshold = 0.5;
  1091. #ifdef ASE_DEPTH_WRITE_ON
  1092. float DepthValue = 0;
  1093. #endif
  1094. #ifdef _ALPHATEST_ON
  1095. clip(Alpha - AlphaClipThreshold);
  1096. #endif
  1097. #ifdef LOD_FADE_CROSSFADE
  1098. LODDitheringTransition( IN.clipPos.xyz, unity_LODFade.x );
  1099. #endif
  1100. #ifdef ASE_DEPTH_WRITE_ON
  1101. outputDepth = DepthValue;
  1102. #endif
  1103. return 0;
  1104. }
  1105. ENDHLSL
  1106. }
  1107. Pass
  1108. {
  1109. Name "Meta"
  1110. Tags { "LightMode"="Meta" }
  1111. Cull Off
  1112. HLSLPROGRAM
  1113. #define _SPECULAR_SETUP 1
  1114. #define _NORMAL_DROPOFF_TS 1
  1115. #pragma multi_compile_instancing
  1116. #pragma multi_compile _ LOD_FADE_CROSSFADE
  1117. #pragma multi_compile_fog
  1118. #define ASE_FOG 1
  1119. #define _NORMALMAP 1
  1120. #define ASE_SRP_VERSION 100500
  1121. #define ASE_USING_SAMPLING_MACROS 1
  1122. #pragma vertex vert
  1123. #pragma fragment frag
  1124. #define SHADERPASS_META
  1125. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  1126. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/MetaInput.hlsl"
  1127. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  1128. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  1129. #define ASE_NEEDS_VERT_NORMAL
  1130. #define ASE_NEEDS_FRAG_WORLD_POSITION
  1131. #include "../MTECommonPBR.hlsl"
  1132. #pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
  1133. struct VertexInput
  1134. {
  1135. float4 vertex : POSITION;
  1136. float3 ase_normal : NORMAL;
  1137. float4 texcoord1 : TEXCOORD1;
  1138. float4 texcoord2 : TEXCOORD2;
  1139. float4 ase_texcoord : TEXCOORD0;
  1140. UNITY_VERTEX_INPUT_INSTANCE_ID
  1141. };
  1142. struct VertexOutput
  1143. {
  1144. float4 clipPos : SV_POSITION;
  1145. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1146. float3 worldPos : TEXCOORD0;
  1147. #endif
  1148. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1149. float4 shadowCoord : TEXCOORD1;
  1150. #endif
  1151. float4 ase_texcoord2 : TEXCOORD2;
  1152. float4 ase_texcoord3 : TEXCOORD3;
  1153. UNITY_VERTEX_INPUT_INSTANCE_ID
  1154. UNITY_VERTEX_OUTPUT_STEREO
  1155. };
  1156. CBUFFER_START(UnityPerMaterial)
  1157. float4 _UVScaleOffset;
  1158. float4 _Control0_ST;
  1159. float4 _Control1_ST;
  1160. float4 _Control2_ST;
  1161. float4 _SpecColor;
  1162. float _Smoothness;
  1163. #ifdef _TRANSMISSION_ASE
  1164. float _TransmissionShadow;
  1165. #endif
  1166. #ifdef _TRANSLUCENCY_ASE
  1167. float _TransStrength;
  1168. float _TransNormal;
  1169. float _TransScattering;
  1170. float _TransDirect;
  1171. float _TransAmbient;
  1172. float _TransShadow;
  1173. #endif
  1174. #ifdef TESSELLATION_ON
  1175. float _TessPhongStrength;
  1176. float _TessValue;
  1177. float _TessMin;
  1178. float _TessMax;
  1179. float _TessEdgeLength;
  1180. float _TessMaxDisp;
  1181. #endif
  1182. CBUFFER_END
  1183. TEXTURE2D_ARRAY(_SplatArray);
  1184. SAMPLER(sampler_SplatArray);
  1185. TEXTURE2D_ARRAY(_NormalArray);
  1186. SAMPLER(sampler_NormalArray);
  1187. TEXTURE2D(_Control0);
  1188. SAMPLER(sampler_Control0);
  1189. TEXTURE2D(_Control1);
  1190. SAMPLER(sampler_Control1);
  1191. TEXTURE2D(_Control2);
  1192. SAMPLER(sampler_Control2);
  1193. void TriplanarBlendLayers( float3 WorldNormal, float3 WorldPos, TEXTURE2D_ARRAY(AlbedoArray), SamplerState AlbedoArraySampler, TEXTURE2D_ARRAY(NormalArray), SamplerState NormalArraySampler, float4 UVScaleOffset, float4 Weights, float4 Indices, out float4 OutAlbedo, out float3 OutWorldNormal )
  1194. {
  1195. //Dependency: MTECommonPBR.hlsl
  1196. // calculate triplanar blend
  1197. half3 triblend = saturate(pow(WorldNormal, 4));
  1198. triblend /= max(dot(triblend, half3(1,1,1)), 0.0001);
  1199. // calculate triplanar uvs
  1200. // applying texture scale and offset values
  1201. float2 uvX = WorldPos.zy * UVScaleOffset.xy + UVScaleOffset.zw;
  1202. float2 uvY = WorldPos.xz * UVScaleOffset.xy + UVScaleOffset.zw;
  1203. float2 uvZ = WorldPos.xy * UVScaleOffset.xy + UVScaleOffset.zw;
  1204. // offset UVs to prevent obvious mirroring
  1205. //uvY += 0.33;
  1206. //uvZ += 0.67;
  1207. // minor optimization of sign(). prevents return value of 0
  1208. half3 axisSign = WorldNormal < 0 ? -1 : 1;
  1209. // flip UVs horizontally to correct for back side projection
  1210. uvX.x *= axisSign.x;
  1211. uvY.x *= axisSign.y;
  1212. uvZ.x *= -axisSign.z;
  1213. // albedo textures
  1214. OutAlbedo = 0;
  1215. OutWorldNormal = 0;
  1216. for(int i = 0; i < 4; i++)
  1217. {
  1218. int index = Indices[i];
  1219. float weight = Weights[i];
  1220. float4 colX = SAMPLE_TEXTURE2D_ARRAY(AlbedoArray, AlbedoArraySampler, uvX, index);
  1221. float4 colY = SAMPLE_TEXTURE2D_ARRAY(AlbedoArray, AlbedoArraySampler, uvY, index);
  1222. float4 colZ = SAMPLE_TEXTURE2D_ARRAY(AlbedoArray, AlbedoArraySampler, uvZ, index);
  1223. float4 albedo = colX * triblend.x + colY * triblend.y + colZ * triblend.z;
  1224. OutAlbedo += albedo * weight;
  1225. // tangent space normal maps
  1226. half3 tnormalX = UnpackNormal(SAMPLE_TEXTURE2D_ARRAY(NormalArray, NormalArraySampler, uvX, index));
  1227. half3 tnormalY = UnpackNormal(SAMPLE_TEXTURE2D_ARRAY(NormalArray, NormalArraySampler, uvY, index));
  1228. half3 tnormalZ = UnpackNormal(SAMPLE_TEXTURE2D_ARRAY(NormalArray, NormalArraySampler, uvZ, index));
  1229. // flip normal maps' x axis to account for flipped UVs
  1230. tnormalX.x *= axisSign.x;
  1231. tnormalY.x *= axisSign.y;
  1232. tnormalZ.x *= -axisSign.z;
  1233. half3 absVertNormal = abs(WorldNormal);
  1234. // swizzle world normals to match tangent space and apply reoriented normal mapping blend
  1235. tnormalX = blend_rnm(half3(WorldNormal.zy, absVertNormal.x), tnormalX);
  1236. tnormalY = blend_rnm(half3(WorldNormal.xz, absVertNormal.y), tnormalY);
  1237. tnormalZ = blend_rnm(half3(WorldNormal.xy, absVertNormal.z), tnormalZ);
  1238. // apply world space sign to tangent space Z
  1239. tnormalX.z *= axisSign.x;
  1240. tnormalY.z *= axisSign.y;
  1241. tnormalZ.z *= axisSign.z;
  1242. // sizzle tangent normals to match world normal and blend together
  1243. float3 normal = normalize(
  1244. tnormalX.zyx * triblend.x +
  1245. tnormalY.xzy * triblend.y +
  1246. tnormalZ.xyz * triblend.z
  1247. );
  1248. OutWorldNormal += normal * weight;
  1249. }
  1250. }
  1251. VertexOutput VertexFunction( VertexInput v )
  1252. {
  1253. VertexOutput o = (VertexOutput)0;
  1254. UNITY_SETUP_INSTANCE_ID(v);
  1255. UNITY_TRANSFER_INSTANCE_ID(v, o);
  1256. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
  1257. float3 ase_worldNormal = TransformObjectToWorldNormal(v.ase_normal);
  1258. o.ase_texcoord2.xyz = ase_worldNormal;
  1259. o.ase_texcoord3.xy = v.ase_texcoord.xy;
  1260. //setting value to unused interpolator channels and avoid initialization warnings
  1261. o.ase_texcoord2.w = 0;
  1262. o.ase_texcoord3.zw = 0;
  1263. #ifdef ASE_ABSOLUTE_VERTEX_POS
  1264. float3 defaultVertexValue = v.vertex.xyz;
  1265. #else
  1266. float3 defaultVertexValue = float3(0, 0, 0);
  1267. #endif
  1268. float3 vertexValue = defaultVertexValue;
  1269. #ifdef ASE_ABSOLUTE_VERTEX_POS
  1270. v.vertex.xyz = vertexValue;
  1271. #else
  1272. v.vertex.xyz += vertexValue;
  1273. #endif
  1274. v.ase_normal = v.ase_normal;
  1275. float3 positionWS = TransformObjectToWorld( v.vertex.xyz );
  1276. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1277. o.worldPos = positionWS;
  1278. #endif
  1279. o.clipPos = MetaVertexPosition( v.vertex, v.texcoord1.xy, v.texcoord1.xy, unity_LightmapST, unity_DynamicLightmapST );
  1280. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1281. VertexPositionInputs vertexInput = (VertexPositionInputs)0;
  1282. vertexInput.positionWS = positionWS;
  1283. vertexInput.positionCS = o.clipPos;
  1284. o.shadowCoord = GetShadowCoord( vertexInput );
  1285. #endif
  1286. return o;
  1287. }
  1288. #if defined(TESSELLATION_ON)
  1289. struct VertexControl
  1290. {
  1291. float4 vertex : INTERNALTESSPOS;
  1292. float3 ase_normal : NORMAL;
  1293. float4 texcoord1 : TEXCOORD1;
  1294. float4 texcoord2 : TEXCOORD2;
  1295. float4 ase_texcoord : TEXCOORD0;
  1296. UNITY_VERTEX_INPUT_INSTANCE_ID
  1297. };
  1298. struct TessellationFactors
  1299. {
  1300. float edge[3] : SV_TessFactor;
  1301. float inside : SV_InsideTessFactor;
  1302. };
  1303. VertexControl vert ( VertexInput v )
  1304. {
  1305. VertexControl o;
  1306. UNITY_SETUP_INSTANCE_ID(v);
  1307. UNITY_TRANSFER_INSTANCE_ID(v, o);
  1308. o.vertex = v.vertex;
  1309. o.ase_normal = v.ase_normal;
  1310. o.texcoord1 = v.texcoord1;
  1311. o.texcoord2 = v.texcoord2;
  1312. o.ase_texcoord = v.ase_texcoord;
  1313. return o;
  1314. }
  1315. TessellationFactors TessellationFunction (InputPatch<VertexControl,3> v)
  1316. {
  1317. TessellationFactors o;
  1318. float4 tf = 1;
  1319. float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
  1320. float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
  1321. #if defined(ASE_FIXED_TESSELLATION)
  1322. tf = FixedTess( tessValue );
  1323. #elif defined(ASE_DISTANCE_TESSELLATION)
  1324. tf = DistanceBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
  1325. #elif defined(ASE_LENGTH_TESSELLATION)
  1326. tf = EdgeLengthBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
  1327. #elif defined(ASE_LENGTH_CULL_TESSELLATION)
  1328. tf = EdgeLengthBasedTessCull(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
  1329. #endif
  1330. o.edge[0] = tf.x; o.edge[1] = tf.y; o.edge[2] = tf.z; o.inside = tf.w;
  1331. return o;
  1332. }
  1333. [domain("tri")]
  1334. [partitioning("fractional_odd")]
  1335. [outputtopology("triangle_cw")]
  1336. [patchconstantfunc("TessellationFunction")]
  1337. [outputcontrolpoints(3)]
  1338. VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
  1339. {
  1340. return patch[id];
  1341. }
  1342. [domain("tri")]
  1343. VertexOutput DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
  1344. {
  1345. VertexInput o = (VertexInput) 0;
  1346. o.vertex = patch[0].vertex * bary.x + patch[1].vertex * bary.y + patch[2].vertex * bary.z;
  1347. o.ase_normal = patch[0].ase_normal * bary.x + patch[1].ase_normal * bary.y + patch[2].ase_normal * bary.z;
  1348. o.texcoord1 = patch[0].texcoord1 * bary.x + patch[1].texcoord1 * bary.y + patch[2].texcoord1 * bary.z;
  1349. o.texcoord2 = patch[0].texcoord2 * bary.x + patch[1].texcoord2 * bary.y + patch[2].texcoord2 * bary.z;
  1350. o.ase_texcoord = patch[0].ase_texcoord * bary.x + patch[1].ase_texcoord * bary.y + patch[2].ase_texcoord * bary.z;
  1351. #if defined(ASE_PHONG_TESSELLATION)
  1352. float3 pp[3];
  1353. for (int i = 0; i < 3; ++i)
  1354. pp[i] = o.vertex.xyz - patch[i].ase_normal * (dot(o.vertex.xyz, patch[i].ase_normal) - dot(patch[i].vertex.xyz, patch[i].ase_normal));
  1355. float phongStrength = _TessPhongStrength;
  1356. o.vertex.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.vertex.xyz;
  1357. #endif
  1358. UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
  1359. return VertexFunction(o);
  1360. }
  1361. #else
  1362. VertexOutput vert ( VertexInput v )
  1363. {
  1364. return VertexFunction( v );
  1365. }
  1366. #endif
  1367. half4 frag(VertexOutput IN ) : SV_TARGET
  1368. {
  1369. UNITY_SETUP_INSTANCE_ID(IN);
  1370. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( IN );
  1371. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1372. float3 WorldPosition = IN.worldPos;
  1373. #endif
  1374. float4 ShadowCoords = float4( 0, 0, 0, 0 );
  1375. #if defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1376. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  1377. ShadowCoords = IN.shadowCoord;
  1378. #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
  1379. ShadowCoords = TransformWorldToShadowCoord( WorldPosition );
  1380. #endif
  1381. #endif
  1382. float4 localBreakRGBA115 = ( float4( 0,0,0,0 ) );
  1383. float localTriplanarBlendLayers307 = ( 0.0 );
  1384. float3 ase_worldNormal = IN.ase_texcoord2.xyz;
  1385. float3 WorldNormal307 = ase_worldNormal;
  1386. float3 WorldPos307 = WorldPosition;
  1387. TEXTURE2D_ARRAY(AlbedoArray307) = _SplatArray;
  1388. SamplerState AlbedoArraySampler307 = sampler_SplatArray;
  1389. TEXTURE2D_ARRAY(NormalArray307) = _NormalArray;
  1390. SamplerState NormalArraySampler307 = sampler_NormalArray;
  1391. float4 UVScaleOffset307 = _UVScaleOffset;
  1392. float localGetMax4WeightLayers169 = ( 0.0 );
  1393. float2 uv_Control0 = IN.ase_texcoord3.xy * _Control0_ST.xy + _Control0_ST.zw;
  1394. float4 Control0169 = SAMPLE_TEXTURE2D( _Control0, sampler_Control0, uv_Control0 );
  1395. float2 uv_Control1 = IN.ase_texcoord3.xy * _Control1_ST.xy + _Control1_ST.zw;
  1396. float4 Control1169 = SAMPLE_TEXTURE2D( _Control1, sampler_Control1, uv_Control1 );
  1397. float2 uv_Control2 = IN.ase_texcoord3.xy * _Control2_ST.xy + _Control2_ST.zw;
  1398. float4 Control2169 = SAMPLE_TEXTURE2D( _Control2, sampler_Control2, uv_Control2 );
  1399. float4 Weights169 = float4( 1,0,0,0 );
  1400. float4 Indices169 = float4( 1,0,0,0 );
  1401. {
  1402. Max4WeightLayer(Control0169, Control1169, Control2169, Weights169, Indices169);
  1403. }
  1404. float4 Weights307 = Weights169;
  1405. float4 Indices307 = Indices169;
  1406. float4 OutAlbedo307 = float4( 0,0,0,0 );
  1407. float3 OutWorldNormal307 = float3( 0,0,0 );
  1408. TriplanarBlendLayers( WorldNormal307 , WorldPos307 , AlbedoArray307 , AlbedoArraySampler307 , NormalArray307 , NormalArraySampler307 , UVScaleOffset307 , Weights307 , Indices307 , OutAlbedo307 , OutWorldNormal307 );
  1409. float4 RGBA115 = OutAlbedo307;
  1410. float3 RGB115 = float3( 0,0,0 );
  1411. float A115 = 0;
  1412. {
  1413. RGB115 = RGBA115.rgb;
  1414. A115 = RGBA115.a;
  1415. }
  1416. float3 Albedo = RGB115;
  1417. float3 Emission = 0;
  1418. float Alpha = 1;
  1419. float AlphaClipThreshold = 0.5;
  1420. #ifdef _ALPHATEST_ON
  1421. clip(Alpha - AlphaClipThreshold);
  1422. #endif
  1423. MetaInput metaInput = (MetaInput)0;
  1424. metaInput.Albedo = Albedo;
  1425. metaInput.Emission = Emission;
  1426. return MetaFragment(metaInput);
  1427. }
  1428. ENDHLSL
  1429. }
  1430. Pass
  1431. {
  1432. Name "Universal2D"
  1433. Tags { "LightMode"="Universal2D" }
  1434. Blend One Zero, One Zero
  1435. ZWrite On
  1436. ZTest LEqual
  1437. Offset 0 , 0
  1438. ColorMask RGBA
  1439. HLSLPROGRAM
  1440. #define _SPECULAR_SETUP 1
  1441. #define _NORMAL_DROPOFF_TS 1
  1442. #pragma multi_compile_instancing
  1443. #pragma multi_compile _ LOD_FADE_CROSSFADE
  1444. #pragma multi_compile_fog
  1445. #define ASE_FOG 1
  1446. #define _NORMALMAP 1
  1447. #define ASE_SRP_VERSION 100500
  1448. #define ASE_USING_SAMPLING_MACROS 1
  1449. #pragma vertex vert
  1450. #pragma fragment frag
  1451. #define SHADERPASS_2D
  1452. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  1453. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  1454. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  1455. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/UnityInstancing.hlsl"
  1456. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  1457. #define ASE_NEEDS_VERT_NORMAL
  1458. #define ASE_NEEDS_FRAG_WORLD_POSITION
  1459. #include "../MTECommonPBR.hlsl"
  1460. #pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
  1461. struct VertexInput
  1462. {
  1463. float4 vertex : POSITION;
  1464. float3 ase_normal : NORMAL;
  1465. float4 ase_texcoord : TEXCOORD0;
  1466. UNITY_VERTEX_INPUT_INSTANCE_ID
  1467. };
  1468. struct VertexOutput
  1469. {
  1470. float4 clipPos : SV_POSITION;
  1471. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1472. float3 worldPos : TEXCOORD0;
  1473. #endif
  1474. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1475. float4 shadowCoord : TEXCOORD1;
  1476. #endif
  1477. float4 ase_texcoord2 : TEXCOORD2;
  1478. float4 ase_texcoord3 : TEXCOORD3;
  1479. UNITY_VERTEX_INPUT_INSTANCE_ID
  1480. UNITY_VERTEX_OUTPUT_STEREO
  1481. };
  1482. CBUFFER_START(UnityPerMaterial)
  1483. float4 _UVScaleOffset;
  1484. float4 _Control0_ST;
  1485. float4 _Control1_ST;
  1486. float4 _Control2_ST;
  1487. float4 _SpecColor;
  1488. float _Smoothness;
  1489. #ifdef _TRANSMISSION_ASE
  1490. float _TransmissionShadow;
  1491. #endif
  1492. #ifdef _TRANSLUCENCY_ASE
  1493. float _TransStrength;
  1494. float _TransNormal;
  1495. float _TransScattering;
  1496. float _TransDirect;
  1497. float _TransAmbient;
  1498. float _TransShadow;
  1499. #endif
  1500. #ifdef TESSELLATION_ON
  1501. float _TessPhongStrength;
  1502. float _TessValue;
  1503. float _TessMin;
  1504. float _TessMax;
  1505. float _TessEdgeLength;
  1506. float _TessMaxDisp;
  1507. #endif
  1508. CBUFFER_END
  1509. TEXTURE2D_ARRAY(_SplatArray);
  1510. SAMPLER(sampler_SplatArray);
  1511. TEXTURE2D_ARRAY(_NormalArray);
  1512. SAMPLER(sampler_NormalArray);
  1513. TEXTURE2D(_Control0);
  1514. SAMPLER(sampler_Control0);
  1515. TEXTURE2D(_Control1);
  1516. SAMPLER(sampler_Control1);
  1517. TEXTURE2D(_Control2);
  1518. SAMPLER(sampler_Control2);
  1519. void TriplanarBlendLayers( float3 WorldNormal, float3 WorldPos, TEXTURE2D_ARRAY(AlbedoArray), SamplerState AlbedoArraySampler, TEXTURE2D_ARRAY(NormalArray), SamplerState NormalArraySampler, float4 UVScaleOffset, float4 Weights, float4 Indices, out float4 OutAlbedo, out float3 OutWorldNormal )
  1520. {
  1521. //Dependency: MTECommonPBR.hlsl
  1522. // calculate triplanar blend
  1523. half3 triblend = saturate(pow(WorldNormal, 4));
  1524. triblend /= max(dot(triblend, half3(1,1,1)), 0.0001);
  1525. // calculate triplanar uvs
  1526. // applying texture scale and offset values
  1527. float2 uvX = WorldPos.zy * UVScaleOffset.xy + UVScaleOffset.zw;
  1528. float2 uvY = WorldPos.xz * UVScaleOffset.xy + UVScaleOffset.zw;
  1529. float2 uvZ = WorldPos.xy * UVScaleOffset.xy + UVScaleOffset.zw;
  1530. // offset UVs to prevent obvious mirroring
  1531. //uvY += 0.33;
  1532. //uvZ += 0.67;
  1533. // minor optimization of sign(). prevents return value of 0
  1534. half3 axisSign = WorldNormal < 0 ? -1 : 1;
  1535. // flip UVs horizontally to correct for back side projection
  1536. uvX.x *= axisSign.x;
  1537. uvY.x *= axisSign.y;
  1538. uvZ.x *= -axisSign.z;
  1539. // albedo textures
  1540. OutAlbedo = 0;
  1541. OutWorldNormal = 0;
  1542. for(int i = 0; i < 4; i++)
  1543. {
  1544. int index = Indices[i];
  1545. float weight = Weights[i];
  1546. float4 colX = SAMPLE_TEXTURE2D_ARRAY(AlbedoArray, AlbedoArraySampler, uvX, index);
  1547. float4 colY = SAMPLE_TEXTURE2D_ARRAY(AlbedoArray, AlbedoArraySampler, uvY, index);
  1548. float4 colZ = SAMPLE_TEXTURE2D_ARRAY(AlbedoArray, AlbedoArraySampler, uvZ, index);
  1549. float4 albedo = colX * triblend.x + colY * triblend.y + colZ * triblend.z;
  1550. OutAlbedo += albedo * weight;
  1551. // tangent space normal maps
  1552. half3 tnormalX = UnpackNormal(SAMPLE_TEXTURE2D_ARRAY(NormalArray, NormalArraySampler, uvX, index));
  1553. half3 tnormalY = UnpackNormal(SAMPLE_TEXTURE2D_ARRAY(NormalArray, NormalArraySampler, uvY, index));
  1554. half3 tnormalZ = UnpackNormal(SAMPLE_TEXTURE2D_ARRAY(NormalArray, NormalArraySampler, uvZ, index));
  1555. // flip normal maps' x axis to account for flipped UVs
  1556. tnormalX.x *= axisSign.x;
  1557. tnormalY.x *= axisSign.y;
  1558. tnormalZ.x *= -axisSign.z;
  1559. half3 absVertNormal = abs(WorldNormal);
  1560. // swizzle world normals to match tangent space and apply reoriented normal mapping blend
  1561. tnormalX = blend_rnm(half3(WorldNormal.zy, absVertNormal.x), tnormalX);
  1562. tnormalY = blend_rnm(half3(WorldNormal.xz, absVertNormal.y), tnormalY);
  1563. tnormalZ = blend_rnm(half3(WorldNormal.xy, absVertNormal.z), tnormalZ);
  1564. // apply world space sign to tangent space Z
  1565. tnormalX.z *= axisSign.x;
  1566. tnormalY.z *= axisSign.y;
  1567. tnormalZ.z *= axisSign.z;
  1568. // sizzle tangent normals to match world normal and blend together
  1569. float3 normal = normalize(
  1570. tnormalX.zyx * triblend.x +
  1571. tnormalY.xzy * triblend.y +
  1572. tnormalZ.xyz * triblend.z
  1573. );
  1574. OutWorldNormal += normal * weight;
  1575. }
  1576. }
  1577. VertexOutput VertexFunction( VertexInput v )
  1578. {
  1579. VertexOutput o = (VertexOutput)0;
  1580. UNITY_SETUP_INSTANCE_ID( v );
  1581. UNITY_TRANSFER_INSTANCE_ID( v, o );
  1582. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( o );
  1583. float3 ase_worldNormal = TransformObjectToWorldNormal(v.ase_normal);
  1584. o.ase_texcoord2.xyz = ase_worldNormal;
  1585. o.ase_texcoord3.xy = v.ase_texcoord.xy;
  1586. //setting value to unused interpolator channels and avoid initialization warnings
  1587. o.ase_texcoord2.w = 0;
  1588. o.ase_texcoord3.zw = 0;
  1589. #ifdef ASE_ABSOLUTE_VERTEX_POS
  1590. float3 defaultVertexValue = v.vertex.xyz;
  1591. #else
  1592. float3 defaultVertexValue = float3(0, 0, 0);
  1593. #endif
  1594. float3 vertexValue = defaultVertexValue;
  1595. #ifdef ASE_ABSOLUTE_VERTEX_POS
  1596. v.vertex.xyz = vertexValue;
  1597. #else
  1598. v.vertex.xyz += vertexValue;
  1599. #endif
  1600. v.ase_normal = v.ase_normal;
  1601. float3 positionWS = TransformObjectToWorld( v.vertex.xyz );
  1602. float4 positionCS = TransformWorldToHClip( positionWS );
  1603. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1604. o.worldPos = positionWS;
  1605. #endif
  1606. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1607. VertexPositionInputs vertexInput = (VertexPositionInputs)0;
  1608. vertexInput.positionWS = positionWS;
  1609. vertexInput.positionCS = positionCS;
  1610. o.shadowCoord = GetShadowCoord( vertexInput );
  1611. #endif
  1612. o.clipPos = positionCS;
  1613. return o;
  1614. }
  1615. #if defined(TESSELLATION_ON)
  1616. struct VertexControl
  1617. {
  1618. float4 vertex : INTERNALTESSPOS;
  1619. float3 ase_normal : NORMAL;
  1620. float4 ase_texcoord : TEXCOORD0;
  1621. UNITY_VERTEX_INPUT_INSTANCE_ID
  1622. };
  1623. struct TessellationFactors
  1624. {
  1625. float edge[3] : SV_TessFactor;
  1626. float inside : SV_InsideTessFactor;
  1627. };
  1628. VertexControl vert ( VertexInput v )
  1629. {
  1630. VertexControl o;
  1631. UNITY_SETUP_INSTANCE_ID(v);
  1632. UNITY_TRANSFER_INSTANCE_ID(v, o);
  1633. o.vertex = v.vertex;
  1634. o.ase_normal = v.ase_normal;
  1635. o.ase_texcoord = v.ase_texcoord;
  1636. return o;
  1637. }
  1638. TessellationFactors TessellationFunction (InputPatch<VertexControl,3> v)
  1639. {
  1640. TessellationFactors o;
  1641. float4 tf = 1;
  1642. float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
  1643. float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
  1644. #if defined(ASE_FIXED_TESSELLATION)
  1645. tf = FixedTess( tessValue );
  1646. #elif defined(ASE_DISTANCE_TESSELLATION)
  1647. tf = DistanceBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
  1648. #elif defined(ASE_LENGTH_TESSELLATION)
  1649. tf = EdgeLengthBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
  1650. #elif defined(ASE_LENGTH_CULL_TESSELLATION)
  1651. tf = EdgeLengthBasedTessCull(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
  1652. #endif
  1653. o.edge[0] = tf.x; o.edge[1] = tf.y; o.edge[2] = tf.z; o.inside = tf.w;
  1654. return o;
  1655. }
  1656. [domain("tri")]
  1657. [partitioning("fractional_odd")]
  1658. [outputtopology("triangle_cw")]
  1659. [patchconstantfunc("TessellationFunction")]
  1660. [outputcontrolpoints(3)]
  1661. VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
  1662. {
  1663. return patch[id];
  1664. }
  1665. [domain("tri")]
  1666. VertexOutput DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
  1667. {
  1668. VertexInput o = (VertexInput) 0;
  1669. o.vertex = patch[0].vertex * bary.x + patch[1].vertex * bary.y + patch[2].vertex * bary.z;
  1670. o.ase_normal = patch[0].ase_normal * bary.x + patch[1].ase_normal * bary.y + patch[2].ase_normal * bary.z;
  1671. o.ase_texcoord = patch[0].ase_texcoord * bary.x + patch[1].ase_texcoord * bary.y + patch[2].ase_texcoord * bary.z;
  1672. #if defined(ASE_PHONG_TESSELLATION)
  1673. float3 pp[3];
  1674. for (int i = 0; i < 3; ++i)
  1675. pp[i] = o.vertex.xyz - patch[i].ase_normal * (dot(o.vertex.xyz, patch[i].ase_normal) - dot(patch[i].vertex.xyz, patch[i].ase_normal));
  1676. float phongStrength = _TessPhongStrength;
  1677. o.vertex.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.vertex.xyz;
  1678. #endif
  1679. UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
  1680. return VertexFunction(o);
  1681. }
  1682. #else
  1683. VertexOutput vert ( VertexInput v )
  1684. {
  1685. return VertexFunction( v );
  1686. }
  1687. #endif
  1688. half4 frag(VertexOutput IN ) : SV_TARGET
  1689. {
  1690. UNITY_SETUP_INSTANCE_ID( IN );
  1691. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( IN );
  1692. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1693. float3 WorldPosition = IN.worldPos;
  1694. #endif
  1695. float4 ShadowCoords = float4( 0, 0, 0, 0 );
  1696. #if defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1697. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  1698. ShadowCoords = IN.shadowCoord;
  1699. #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
  1700. ShadowCoords = TransformWorldToShadowCoord( WorldPosition );
  1701. #endif
  1702. #endif
  1703. float4 localBreakRGBA115 = ( float4( 0,0,0,0 ) );
  1704. float localTriplanarBlendLayers307 = ( 0.0 );
  1705. float3 ase_worldNormal = IN.ase_texcoord2.xyz;
  1706. float3 WorldNormal307 = ase_worldNormal;
  1707. float3 WorldPos307 = WorldPosition;
  1708. TEXTURE2D_ARRAY(AlbedoArray307) = _SplatArray;
  1709. SamplerState AlbedoArraySampler307 = sampler_SplatArray;
  1710. TEXTURE2D_ARRAY(NormalArray307) = _NormalArray;
  1711. SamplerState NormalArraySampler307 = sampler_NormalArray;
  1712. float4 UVScaleOffset307 = _UVScaleOffset;
  1713. float localGetMax4WeightLayers169 = ( 0.0 );
  1714. float2 uv_Control0 = IN.ase_texcoord3.xy * _Control0_ST.xy + _Control0_ST.zw;
  1715. float4 Control0169 = SAMPLE_TEXTURE2D( _Control0, sampler_Control0, uv_Control0 );
  1716. float2 uv_Control1 = IN.ase_texcoord3.xy * _Control1_ST.xy + _Control1_ST.zw;
  1717. float4 Control1169 = SAMPLE_TEXTURE2D( _Control1, sampler_Control1, uv_Control1 );
  1718. float2 uv_Control2 = IN.ase_texcoord3.xy * _Control2_ST.xy + _Control2_ST.zw;
  1719. float4 Control2169 = SAMPLE_TEXTURE2D( _Control2, sampler_Control2, uv_Control2 );
  1720. float4 Weights169 = float4( 1,0,0,0 );
  1721. float4 Indices169 = float4( 1,0,0,0 );
  1722. {
  1723. Max4WeightLayer(Control0169, Control1169, Control2169, Weights169, Indices169);
  1724. }
  1725. float4 Weights307 = Weights169;
  1726. float4 Indices307 = Indices169;
  1727. float4 OutAlbedo307 = float4( 0,0,0,0 );
  1728. float3 OutWorldNormal307 = float3( 0,0,0 );
  1729. TriplanarBlendLayers( WorldNormal307 , WorldPos307 , AlbedoArray307 , AlbedoArraySampler307 , NormalArray307 , NormalArraySampler307 , UVScaleOffset307 , Weights307 , Indices307 , OutAlbedo307 , OutWorldNormal307 );
  1730. float4 RGBA115 = OutAlbedo307;
  1731. float3 RGB115 = float3( 0,0,0 );
  1732. float A115 = 0;
  1733. {
  1734. RGB115 = RGBA115.rgb;
  1735. A115 = RGBA115.a;
  1736. }
  1737. float3 Albedo = RGB115;
  1738. float Alpha = 1;
  1739. float AlphaClipThreshold = 0.5;
  1740. half4 color = half4( Albedo, Alpha );
  1741. #ifdef _ALPHATEST_ON
  1742. clip(Alpha - AlphaClipThreshold);
  1743. #endif
  1744. return color;
  1745. }
  1746. ENDHLSL
  1747. }
  1748. Pass
  1749. {
  1750. Name "DepthNormals"
  1751. Tags { "LightMode"="DepthNormals" }
  1752. ZWrite On
  1753. Blend One Zero
  1754. ZTest LEqual
  1755. ZWrite On
  1756. HLSLPROGRAM
  1757. #define _SPECULAR_SETUP 1
  1758. #define _NORMAL_DROPOFF_TS 1
  1759. #pragma multi_compile_instancing
  1760. #pragma multi_compile _ LOD_FADE_CROSSFADE
  1761. #pragma multi_compile_fog
  1762. #define ASE_FOG 1
  1763. #define _NORMALMAP 1
  1764. #define ASE_SRP_VERSION 100500
  1765. #define ASE_USING_SAMPLING_MACROS 1
  1766. #pragma vertex vert
  1767. #pragma fragment frag
  1768. #define SHADERPASS_DEPTHNORMALSONLY
  1769. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  1770. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  1771. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  1772. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  1773. #include "../MTECommonPBR.hlsl"
  1774. struct VertexInput
  1775. {
  1776. float4 vertex : POSITION;
  1777. float3 ase_normal : NORMAL;
  1778. UNITY_VERTEX_INPUT_INSTANCE_ID
  1779. };
  1780. struct VertexOutput
  1781. {
  1782. float4 clipPos : SV_POSITION;
  1783. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1784. float3 worldPos : TEXCOORD0;
  1785. #endif
  1786. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1787. float4 shadowCoord : TEXCOORD1;
  1788. #endif
  1789. float3 worldNormal : TEXCOORD2;
  1790. UNITY_VERTEX_INPUT_INSTANCE_ID
  1791. UNITY_VERTEX_OUTPUT_STEREO
  1792. };
  1793. CBUFFER_START(UnityPerMaterial)
  1794. float4 _UVScaleOffset;
  1795. float4 _Control0_ST;
  1796. float4 _Control1_ST;
  1797. float4 _Control2_ST;
  1798. float4 _SpecColor;
  1799. float _Smoothness;
  1800. #ifdef _TRANSMISSION_ASE
  1801. float _TransmissionShadow;
  1802. #endif
  1803. #ifdef _TRANSLUCENCY_ASE
  1804. float _TransStrength;
  1805. float _TransNormal;
  1806. float _TransScattering;
  1807. float _TransDirect;
  1808. float _TransAmbient;
  1809. float _TransShadow;
  1810. #endif
  1811. #ifdef TESSELLATION_ON
  1812. float _TessPhongStrength;
  1813. float _TessValue;
  1814. float _TessMin;
  1815. float _TessMax;
  1816. float _TessEdgeLength;
  1817. float _TessMaxDisp;
  1818. #endif
  1819. CBUFFER_END
  1820. VertexOutput VertexFunction( VertexInput v )
  1821. {
  1822. VertexOutput o = (VertexOutput)0;
  1823. UNITY_SETUP_INSTANCE_ID(v);
  1824. UNITY_TRANSFER_INSTANCE_ID(v, o);
  1825. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
  1826. #ifdef ASE_ABSOLUTE_VERTEX_POS
  1827. float3 defaultVertexValue = v.vertex.xyz;
  1828. #else
  1829. float3 defaultVertexValue = float3(0, 0, 0);
  1830. #endif
  1831. float3 vertexValue = defaultVertexValue;
  1832. #ifdef ASE_ABSOLUTE_VERTEX_POS
  1833. v.vertex.xyz = vertexValue;
  1834. #else
  1835. v.vertex.xyz += vertexValue;
  1836. #endif
  1837. v.ase_normal = v.ase_normal;
  1838. float3 positionWS = TransformObjectToWorld( v.vertex.xyz );
  1839. float3 normalWS = TransformObjectToWorldNormal( v.ase_normal );
  1840. float4 positionCS = TransformWorldToHClip( positionWS );
  1841. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1842. o.worldPos = positionWS;
  1843. #endif
  1844. o.worldNormal = normalWS;
  1845. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1846. VertexPositionInputs vertexInput = (VertexPositionInputs)0;
  1847. vertexInput.positionWS = positionWS;
  1848. vertexInput.positionCS = positionCS;
  1849. o.shadowCoord = GetShadowCoord( vertexInput );
  1850. #endif
  1851. o.clipPos = positionCS;
  1852. return o;
  1853. }
  1854. #if defined(TESSELLATION_ON)
  1855. struct VertexControl
  1856. {
  1857. float4 vertex : INTERNALTESSPOS;
  1858. float3 ase_normal : NORMAL;
  1859. UNITY_VERTEX_INPUT_INSTANCE_ID
  1860. };
  1861. struct TessellationFactors
  1862. {
  1863. float edge[3] : SV_TessFactor;
  1864. float inside : SV_InsideTessFactor;
  1865. };
  1866. VertexControl vert ( VertexInput v )
  1867. {
  1868. VertexControl o;
  1869. UNITY_SETUP_INSTANCE_ID(v);
  1870. UNITY_TRANSFER_INSTANCE_ID(v, o);
  1871. o.vertex = v.vertex;
  1872. o.ase_normal = v.ase_normal;
  1873. return o;
  1874. }
  1875. TessellationFactors TessellationFunction (InputPatch<VertexControl,3> v)
  1876. {
  1877. TessellationFactors o;
  1878. float4 tf = 1;
  1879. float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
  1880. float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
  1881. #if defined(ASE_FIXED_TESSELLATION)
  1882. tf = FixedTess( tessValue );
  1883. #elif defined(ASE_DISTANCE_TESSELLATION)
  1884. tf = DistanceBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
  1885. #elif defined(ASE_LENGTH_TESSELLATION)
  1886. tf = EdgeLengthBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
  1887. #elif defined(ASE_LENGTH_CULL_TESSELLATION)
  1888. tf = EdgeLengthBasedTessCull(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
  1889. #endif
  1890. o.edge[0] = tf.x; o.edge[1] = tf.y; o.edge[2] = tf.z; o.inside = tf.w;
  1891. return o;
  1892. }
  1893. [domain("tri")]
  1894. [partitioning("fractional_odd")]
  1895. [outputtopology("triangle_cw")]
  1896. [patchconstantfunc("TessellationFunction")]
  1897. [outputcontrolpoints(3)]
  1898. VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
  1899. {
  1900. return patch[id];
  1901. }
  1902. [domain("tri")]
  1903. VertexOutput DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
  1904. {
  1905. VertexInput o = (VertexInput) 0;
  1906. o.vertex = patch[0].vertex * bary.x + patch[1].vertex * bary.y + patch[2].vertex * bary.z;
  1907. o.ase_normal = patch[0].ase_normal * bary.x + patch[1].ase_normal * bary.y + patch[2].ase_normal * bary.z;
  1908. #if defined(ASE_PHONG_TESSELLATION)
  1909. float3 pp[3];
  1910. for (int i = 0; i < 3; ++i)
  1911. pp[i] = o.vertex.xyz - patch[i].ase_normal * (dot(o.vertex.xyz, patch[i].ase_normal) - dot(patch[i].vertex.xyz, patch[i].ase_normal));
  1912. float phongStrength = _TessPhongStrength;
  1913. o.vertex.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.vertex.xyz;
  1914. #endif
  1915. UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
  1916. return VertexFunction(o);
  1917. }
  1918. #else
  1919. VertexOutput vert ( VertexInput v )
  1920. {
  1921. return VertexFunction( v );
  1922. }
  1923. #endif
  1924. #if defined(ASE_EARLY_Z_DEPTH_OPTIMIZE)
  1925. #define ASE_SV_DEPTH SV_DepthLessEqual
  1926. #else
  1927. #define ASE_SV_DEPTH SV_Depth
  1928. #endif
  1929. half4 frag( VertexOutput IN
  1930. #ifdef ASE_DEPTH_WRITE_ON
  1931. ,out float outputDepth : ASE_SV_DEPTH
  1932. #endif
  1933. ) : SV_TARGET
  1934. {
  1935. UNITY_SETUP_INSTANCE_ID(IN);
  1936. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( IN );
  1937. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1938. float3 WorldPosition = IN.worldPos;
  1939. #endif
  1940. float4 ShadowCoords = float4( 0, 0, 0, 0 );
  1941. #if defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1942. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  1943. ShadowCoords = IN.shadowCoord;
  1944. #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
  1945. ShadowCoords = TransformWorldToShadowCoord( WorldPosition );
  1946. #endif
  1947. #endif
  1948. float Alpha = 1;
  1949. float AlphaClipThreshold = 0.5;
  1950. #ifdef ASE_DEPTH_WRITE_ON
  1951. float DepthValue = 0;
  1952. #endif
  1953. #ifdef _ALPHATEST_ON
  1954. clip(Alpha - AlphaClipThreshold);
  1955. #endif
  1956. #ifdef LOD_FADE_CROSSFADE
  1957. LODDitheringTransition( IN.clipPos.xyz, unity_LODFade.x );
  1958. #endif
  1959. #ifdef ASE_DEPTH_WRITE_ON
  1960. outputDepth = DepthValue;
  1961. #endif
  1962. return float4(PackNormalOctRectEncode(TransformWorldToViewDir(IN.worldNormal, true)), 0.0, 0.0);
  1963. }
  1964. ENDHLSL
  1965. }
  1966. Pass
  1967. {
  1968. Name "GBuffer"
  1969. Tags { "LightMode"="UniversalGBuffer" }
  1970. Blend One Zero, One Zero
  1971. ZWrite On
  1972. ZTest LEqual
  1973. Offset 0 , 0
  1974. ColorMask RGBA
  1975. HLSLPROGRAM
  1976. #define _SPECULAR_SETUP 1
  1977. #define _NORMAL_DROPOFF_TS 1
  1978. #pragma multi_compile_instancing
  1979. #pragma multi_compile _ LOD_FADE_CROSSFADE
  1980. #pragma multi_compile_fog
  1981. #define ASE_FOG 1
  1982. #define _NORMALMAP 1
  1983. #define ASE_SRP_VERSION 100500
  1984. #define ASE_USING_SAMPLING_MACROS 1
  1985. #pragma multi_compile _ _MAIN_LIGHT_SHADOWS
  1986. #pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
  1987. #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
  1988. #pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
  1989. #pragma multi_compile _ _SHADOWS_SOFT
  1990. #pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE
  1991. #pragma multi_compile _ _GBUFFER_NORMALS_OCT
  1992. #pragma multi_compile _ DIRLIGHTMAP_COMBINED
  1993. #pragma multi_compile _ LIGHTMAP_ON
  1994. #pragma vertex vert
  1995. #pragma fragment frag
  1996. #define SHADERPASS SHADERPASS_GBUFFER
  1997. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  1998. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  1999. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  2000. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/UnityInstancing.hlsl"
  2001. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  2002. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/UnityGBuffer.hlsl"
  2003. #if ASE_SRP_VERSION <= 70108
  2004. #define REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR
  2005. #endif
  2006. #if defined(UNITY_INSTANCING_ENABLED) && defined(_TERRAIN_INSTANCED_PERPIXEL_NORMAL)
  2007. #define ENABLE_TERRAIN_PERPIXEL_NORMAL
  2008. #endif
  2009. #define ASE_NEEDS_FRAG_WORLD_NORMAL
  2010. #define ASE_NEEDS_FRAG_WORLD_POSITION
  2011. #define ASE_NEEDS_FRAG_WORLD_TANGENT
  2012. #define ASE_NEEDS_FRAG_WORLD_BITANGENT
  2013. #include "../MTECommonPBR.hlsl"
  2014. struct VertexInput
  2015. {
  2016. float4 vertex : POSITION;
  2017. float3 ase_normal : NORMAL;
  2018. float4 ase_tangent : TANGENT;
  2019. float4 texcoord1 : TEXCOORD1;
  2020. float4 texcoord : TEXCOORD0;
  2021. UNITY_VERTEX_INPUT_INSTANCE_ID
  2022. };
  2023. struct VertexOutput
  2024. {
  2025. float4 clipPos : SV_POSITION;
  2026. float4 lightmapUVOrVertexSH : TEXCOORD0;
  2027. half4 fogFactorAndVertexLight : TEXCOORD1;
  2028. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  2029. float4 shadowCoord : TEXCOORD2;
  2030. #endif
  2031. float4 tSpace0 : TEXCOORD3;
  2032. float4 tSpace1 : TEXCOORD4;
  2033. float4 tSpace2 : TEXCOORD5;
  2034. #if defined(ASE_NEEDS_FRAG_SCREEN_POSITION)
  2035. float4 screenPos : TEXCOORD6;
  2036. #endif
  2037. float4 ase_texcoord7 : TEXCOORD7;
  2038. UNITY_VERTEX_INPUT_INSTANCE_ID
  2039. UNITY_VERTEX_OUTPUT_STEREO
  2040. };
  2041. CBUFFER_START(UnityPerMaterial)
  2042. float4 _UVScaleOffset;
  2043. float4 _Control0_ST;
  2044. float4 _Control1_ST;
  2045. float4 _Control2_ST;
  2046. float4 _SpecColor;
  2047. float _Smoothness;
  2048. #ifdef _TRANSMISSION_ASE
  2049. float _TransmissionShadow;
  2050. #endif
  2051. #ifdef _TRANSLUCENCY_ASE
  2052. float _TransStrength;
  2053. float _TransNormal;
  2054. float _TransScattering;
  2055. float _TransDirect;
  2056. float _TransAmbient;
  2057. float _TransShadow;
  2058. #endif
  2059. #ifdef TESSELLATION_ON
  2060. float _TessPhongStrength;
  2061. float _TessValue;
  2062. float _TessMin;
  2063. float _TessMax;
  2064. float _TessEdgeLength;
  2065. float _TessMaxDisp;
  2066. #endif
  2067. CBUFFER_END
  2068. TEXTURE2D_ARRAY(_SplatArray);
  2069. SAMPLER(sampler_SplatArray);
  2070. TEXTURE2D_ARRAY(_NormalArray);
  2071. SAMPLER(sampler_NormalArray);
  2072. TEXTURE2D(_Control0);
  2073. SAMPLER(sampler_Control0);
  2074. TEXTURE2D(_Control1);
  2075. SAMPLER(sampler_Control1);
  2076. TEXTURE2D(_Control2);
  2077. SAMPLER(sampler_Control2);
  2078. void TriplanarBlendLayers( float3 WorldNormal, float3 WorldPos, TEXTURE2D_ARRAY(AlbedoArray), SamplerState AlbedoArraySampler, TEXTURE2D_ARRAY(NormalArray), SamplerState NormalArraySampler, float4 UVScaleOffset, float4 Weights, float4 Indices, out float4 OutAlbedo, out float3 OutWorldNormal )
  2079. {
  2080. //Dependency: MTECommonPBR.hlsl
  2081. // calculate triplanar blend
  2082. half3 triblend = saturate(pow(WorldNormal, 4));
  2083. triblend /= max(dot(triblend, half3(1,1,1)), 0.0001);
  2084. // calculate triplanar uvs
  2085. // applying texture scale and offset values
  2086. float2 uvX = WorldPos.zy * UVScaleOffset.xy + UVScaleOffset.zw;
  2087. float2 uvY = WorldPos.xz * UVScaleOffset.xy + UVScaleOffset.zw;
  2088. float2 uvZ = WorldPos.xy * UVScaleOffset.xy + UVScaleOffset.zw;
  2089. // offset UVs to prevent obvious mirroring
  2090. //uvY += 0.33;
  2091. //uvZ += 0.67;
  2092. // minor optimization of sign(). prevents return value of 0
  2093. half3 axisSign = WorldNormal < 0 ? -1 : 1;
  2094. // flip UVs horizontally to correct for back side projection
  2095. uvX.x *= axisSign.x;
  2096. uvY.x *= axisSign.y;
  2097. uvZ.x *= -axisSign.z;
  2098. // albedo textures
  2099. OutAlbedo = 0;
  2100. OutWorldNormal = 0;
  2101. for(int i = 0; i < 4; i++)
  2102. {
  2103. int index = Indices[i];
  2104. float weight = Weights[i];
  2105. float4 colX = SAMPLE_TEXTURE2D_ARRAY(AlbedoArray, AlbedoArraySampler, uvX, index);
  2106. float4 colY = SAMPLE_TEXTURE2D_ARRAY(AlbedoArray, AlbedoArraySampler, uvY, index);
  2107. float4 colZ = SAMPLE_TEXTURE2D_ARRAY(AlbedoArray, AlbedoArraySampler, uvZ, index);
  2108. float4 albedo = colX * triblend.x + colY * triblend.y + colZ * triblend.z;
  2109. OutAlbedo += albedo * weight;
  2110. // tangent space normal maps
  2111. half3 tnormalX = UnpackNormal(SAMPLE_TEXTURE2D_ARRAY(NormalArray, NormalArraySampler, uvX, index));
  2112. half3 tnormalY = UnpackNormal(SAMPLE_TEXTURE2D_ARRAY(NormalArray, NormalArraySampler, uvY, index));
  2113. half3 tnormalZ = UnpackNormal(SAMPLE_TEXTURE2D_ARRAY(NormalArray, NormalArraySampler, uvZ, index));
  2114. // flip normal maps' x axis to account for flipped UVs
  2115. tnormalX.x *= axisSign.x;
  2116. tnormalY.x *= axisSign.y;
  2117. tnormalZ.x *= -axisSign.z;
  2118. half3 absVertNormal = abs(WorldNormal);
  2119. // swizzle world normals to match tangent space and apply reoriented normal mapping blend
  2120. tnormalX = blend_rnm(half3(WorldNormal.zy, absVertNormal.x), tnormalX);
  2121. tnormalY = blend_rnm(half3(WorldNormal.xz, absVertNormal.y), tnormalY);
  2122. tnormalZ = blend_rnm(half3(WorldNormal.xy, absVertNormal.z), tnormalZ);
  2123. // apply world space sign to tangent space Z
  2124. tnormalX.z *= axisSign.x;
  2125. tnormalY.z *= axisSign.y;
  2126. tnormalZ.z *= axisSign.z;
  2127. // sizzle tangent normals to match world normal and blend together
  2128. float3 normal = normalize(
  2129. tnormalX.zyx * triblend.x +
  2130. tnormalY.xzy * triblend.y +
  2131. tnormalZ.xyz * triblend.z
  2132. );
  2133. OutWorldNormal += normal * weight;
  2134. }
  2135. }
  2136. VertexOutput VertexFunction( VertexInput v )
  2137. {
  2138. VertexOutput o = (VertexOutput)0;
  2139. UNITY_SETUP_INSTANCE_ID(v);
  2140. UNITY_TRANSFER_INSTANCE_ID(v, o);
  2141. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
  2142. o.ase_texcoord7.xy = v.texcoord.xy;
  2143. //setting value to unused interpolator channels and avoid initialization warnings
  2144. o.ase_texcoord7.zw = 0;
  2145. #ifdef ASE_ABSOLUTE_VERTEX_POS
  2146. float3 defaultVertexValue = v.vertex.xyz;
  2147. #else
  2148. float3 defaultVertexValue = float3(0, 0, 0);
  2149. #endif
  2150. float3 vertexValue = defaultVertexValue;
  2151. #ifdef ASE_ABSOLUTE_VERTEX_POS
  2152. v.vertex.xyz = vertexValue;
  2153. #else
  2154. v.vertex.xyz += vertexValue;
  2155. #endif
  2156. v.ase_normal = v.ase_normal;
  2157. float3 positionWS = TransformObjectToWorld( v.vertex.xyz );
  2158. float3 positionVS = TransformWorldToView( positionWS );
  2159. float4 positionCS = TransformWorldToHClip( positionWS );
  2160. VertexNormalInputs normalInput = GetVertexNormalInputs( v.ase_normal, v.ase_tangent );
  2161. o.tSpace0 = float4( normalInput.normalWS, positionWS.x);
  2162. o.tSpace1 = float4( normalInput.tangentWS, positionWS.y);
  2163. o.tSpace2 = float4( normalInput.bitangentWS, positionWS.z);
  2164. OUTPUT_LIGHTMAP_UV( v.texcoord1, unity_LightmapST, o.lightmapUVOrVertexSH.xy );
  2165. OUTPUT_SH( normalInput.normalWS.xyz, o.lightmapUVOrVertexSH.xyz );
  2166. #if defined(ENABLE_TERRAIN_PERPIXEL_NORMAL)
  2167. o.lightmapUVOrVertexSH.zw = v.texcoord;
  2168. o.lightmapUVOrVertexSH.xy = v.texcoord * unity_LightmapST.xy + unity_LightmapST.zw;
  2169. #endif
  2170. half3 vertexLight = VertexLighting( positionWS, normalInput.normalWS );
  2171. #ifdef ASE_FOG
  2172. half fogFactor = ComputeFogFactor( positionCS.z );
  2173. #else
  2174. half fogFactor = 0;
  2175. #endif
  2176. o.fogFactorAndVertexLight = half4(fogFactor, vertexLight);
  2177. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  2178. VertexPositionInputs vertexInput = (VertexPositionInputs)0;
  2179. vertexInput.positionWS = positionWS;
  2180. vertexInput.positionCS = positionCS;
  2181. o.shadowCoord = GetShadowCoord( vertexInput );
  2182. #endif
  2183. o.clipPos = positionCS;
  2184. #if defined(ASE_NEEDS_FRAG_SCREEN_POSITION)
  2185. o.screenPos = ComputeScreenPos(positionCS);
  2186. #endif
  2187. return o;
  2188. }
  2189. #if defined(TESSELLATION_ON)
  2190. struct VertexControl
  2191. {
  2192. float4 vertex : INTERNALTESSPOS;
  2193. float3 ase_normal : NORMAL;
  2194. float4 ase_tangent : TANGENT;
  2195. float4 texcoord : TEXCOORD0;
  2196. float4 texcoord1 : TEXCOORD1;
  2197. UNITY_VERTEX_INPUT_INSTANCE_ID
  2198. };
  2199. struct TessellationFactors
  2200. {
  2201. float edge[3] : SV_TessFactor;
  2202. float inside : SV_InsideTessFactor;
  2203. };
  2204. VertexControl vert ( VertexInput v )
  2205. {
  2206. VertexControl o;
  2207. UNITY_SETUP_INSTANCE_ID(v);
  2208. UNITY_TRANSFER_INSTANCE_ID(v, o);
  2209. o.vertex = v.vertex;
  2210. o.ase_normal = v.ase_normal;
  2211. o.ase_tangent = v.ase_tangent;
  2212. o.texcoord = v.texcoord;
  2213. o.texcoord1 = v.texcoord1;
  2214. return o;
  2215. }
  2216. TessellationFactors TessellationFunction (InputPatch<VertexControl,3> v)
  2217. {
  2218. TessellationFactors o;
  2219. float4 tf = 1;
  2220. float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
  2221. float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
  2222. #if defined(ASE_FIXED_TESSELLATION)
  2223. tf = FixedTess( tessValue );
  2224. #elif defined(ASE_DISTANCE_TESSELLATION)
  2225. tf = DistanceBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
  2226. #elif defined(ASE_LENGTH_TESSELLATION)
  2227. tf = EdgeLengthBasedTess(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
  2228. #elif defined(ASE_LENGTH_CULL_TESSELLATION)
  2229. tf = EdgeLengthBasedTessCull(v[0].vertex, v[1].vertex, v[2].vertex, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
  2230. #endif
  2231. o.edge[0] = tf.x; o.edge[1] = tf.y; o.edge[2] = tf.z; o.inside = tf.w;
  2232. return o;
  2233. }
  2234. [domain("tri")]
  2235. [partitioning("fractional_odd")]
  2236. [outputtopology("triangle_cw")]
  2237. [patchconstantfunc("TessellationFunction")]
  2238. [outputcontrolpoints(3)]
  2239. VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
  2240. {
  2241. return patch[id];
  2242. }
  2243. [domain("tri")]
  2244. VertexOutput DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
  2245. {
  2246. VertexInput o = (VertexInput) 0;
  2247. o.vertex = patch[0].vertex * bary.x + patch[1].vertex * bary.y + patch[2].vertex * bary.z;
  2248. o.ase_normal = patch[0].ase_normal * bary.x + patch[1].ase_normal * bary.y + patch[2].ase_normal * bary.z;
  2249. o.ase_tangent = patch[0].ase_tangent * bary.x + patch[1].ase_tangent * bary.y + patch[2].ase_tangent * bary.z;
  2250. o.texcoord = patch[0].texcoord * bary.x + patch[1].texcoord * bary.y + patch[2].texcoord * bary.z;
  2251. o.texcoord1 = patch[0].texcoord1 * bary.x + patch[1].texcoord1 * bary.y + patch[2].texcoord1 * bary.z;
  2252. #if defined(ASE_PHONG_TESSELLATION)
  2253. float3 pp[3];
  2254. for (int i = 0; i < 3; ++i)
  2255. pp[i] = o.vertex.xyz - patch[i].ase_normal * (dot(o.vertex.xyz, patch[i].ase_normal) - dot(patch[i].vertex.xyz, patch[i].ase_normal));
  2256. float phongStrength = _TessPhongStrength;
  2257. o.vertex.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * o.vertex.xyz;
  2258. #endif
  2259. UNITY_TRANSFER_INSTANCE_ID(patch[0], o);
  2260. return VertexFunction(o);
  2261. }
  2262. #else
  2263. VertexOutput vert ( VertexInput v )
  2264. {
  2265. return VertexFunction( v );
  2266. }
  2267. #endif
  2268. #if defined(ASE_EARLY_Z_DEPTH_OPTIMIZE)
  2269. #define ASE_SV_DEPTH SV_DepthLessEqual
  2270. #else
  2271. #define ASE_SV_DEPTH SV_Depth
  2272. #endif
  2273. FragmentOutput frag ( VertexOutput IN
  2274. #ifdef ASE_DEPTH_WRITE_ON
  2275. ,out float outputDepth : ASE_SV_DEPTH
  2276. #endif
  2277. )
  2278. {
  2279. UNITY_SETUP_INSTANCE_ID(IN);
  2280. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(IN);
  2281. #ifdef LOD_FADE_CROSSFADE
  2282. LODDitheringTransition( IN.clipPos.xyz, unity_LODFade.x );
  2283. #endif
  2284. #if defined(ENABLE_TERRAIN_PERPIXEL_NORMAL)
  2285. float2 sampleCoords = (IN.lightmapUVOrVertexSH.zw / _TerrainHeightmapRecipSize.zw + 0.5f) * _TerrainHeightmapRecipSize.xy;
  2286. float3 WorldNormal = TransformObjectToWorldNormal(normalize(SAMPLE_TEXTURE2D(_TerrainNormalmapTexture, sampler_TerrainNormalmapTexture, sampleCoords).rgb * 2 - 1));
  2287. float3 WorldTangent = -cross(GetObjectToWorldMatrix()._13_23_33, WorldNormal);
  2288. float3 WorldBiTangent = cross(WorldNormal, -WorldTangent);
  2289. #else
  2290. float3 WorldNormal = normalize( IN.tSpace0.xyz );
  2291. float3 WorldTangent = IN.tSpace1.xyz;
  2292. float3 WorldBiTangent = IN.tSpace2.xyz;
  2293. #endif
  2294. float3 WorldPosition = float3(IN.tSpace0.w,IN.tSpace1.w,IN.tSpace2.w);
  2295. float3 WorldViewDirection = _WorldSpaceCameraPos.xyz - WorldPosition;
  2296. float4 ShadowCoords = float4( 0, 0, 0, 0 );
  2297. #if defined(ASE_NEEDS_FRAG_SCREEN_POSITION)
  2298. float4 ScreenPos = IN.screenPos;
  2299. #endif
  2300. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  2301. ShadowCoords = IN.shadowCoord;
  2302. #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
  2303. ShadowCoords = TransformWorldToShadowCoord( WorldPosition );
  2304. #endif
  2305. WorldViewDirection = SafeNormalize( WorldViewDirection );
  2306. float4 localBreakRGBA115 = ( float4( 0,0,0,0 ) );
  2307. float localTriplanarBlendLayers307 = ( 0.0 );
  2308. float3 WorldNormal307 = WorldNormal;
  2309. float3 WorldPos307 = WorldPosition;
  2310. TEXTURE2D_ARRAY(AlbedoArray307) = _SplatArray;
  2311. SamplerState AlbedoArraySampler307 = sampler_SplatArray;
  2312. TEXTURE2D_ARRAY(NormalArray307) = _NormalArray;
  2313. SamplerState NormalArraySampler307 = sampler_NormalArray;
  2314. float4 UVScaleOffset307 = _UVScaleOffset;
  2315. float localGetMax4WeightLayers169 = ( 0.0 );
  2316. float2 uv_Control0 = IN.ase_texcoord7.xy * _Control0_ST.xy + _Control0_ST.zw;
  2317. float4 Control0169 = SAMPLE_TEXTURE2D( _Control0, sampler_Control0, uv_Control0 );
  2318. float2 uv_Control1 = IN.ase_texcoord7.xy * _Control1_ST.xy + _Control1_ST.zw;
  2319. float4 Control1169 = SAMPLE_TEXTURE2D( _Control1, sampler_Control1, uv_Control1 );
  2320. float2 uv_Control2 = IN.ase_texcoord7.xy * _Control2_ST.xy + _Control2_ST.zw;
  2321. float4 Control2169 = SAMPLE_TEXTURE2D( _Control2, sampler_Control2, uv_Control2 );
  2322. float4 Weights169 = float4( 1,0,0,0 );
  2323. float4 Indices169 = float4( 1,0,0,0 );
  2324. {
  2325. Max4WeightLayer(Control0169, Control1169, Control2169, Weights169, Indices169);
  2326. }
  2327. float4 Weights307 = Weights169;
  2328. float4 Indices307 = Indices169;
  2329. float4 OutAlbedo307 = float4( 0,0,0,0 );
  2330. float3 OutWorldNormal307 = float3( 0,0,0 );
  2331. TriplanarBlendLayers( WorldNormal307 , WorldPos307 , AlbedoArray307 , AlbedoArraySampler307 , NormalArray307 , NormalArraySampler307 , UVScaleOffset307 , Weights307 , Indices307 , OutAlbedo307 , OutWorldNormal307 );
  2332. float4 RGBA115 = OutAlbedo307;
  2333. float3 RGB115 = float3( 0,0,0 );
  2334. float A115 = 0;
  2335. {
  2336. RGB115 = RGBA115.rgb;
  2337. A115 = RGBA115.a;
  2338. }
  2339. float3x3 ase_worldToTangent = float3x3(WorldTangent,WorldBiTangent,WorldNormal);
  2340. float3 worldToTangentDir337 = mul( ase_worldToTangent, OutWorldNormal307);
  2341. float3 Albedo = RGB115;
  2342. float3 Normal = worldToTangentDir337;
  2343. float3 Emission = 0;
  2344. float3 Specular = _SpecColor.rgb;
  2345. float Metallic = 0;
  2346. float Smoothness = _Smoothness;
  2347. float Occlusion = 1;
  2348. float Alpha = 1;
  2349. float AlphaClipThreshold = 0.5;
  2350. float AlphaClipThresholdShadow = 0.5;
  2351. float3 BakedGI = 0;
  2352. float3 RefractionColor = 1;
  2353. float RefractionIndex = 1;
  2354. float3 Transmission = 1;
  2355. float3 Translucency = 1;
  2356. #ifdef ASE_DEPTH_WRITE_ON
  2357. float DepthValue = 0;
  2358. #endif
  2359. #ifdef _ALPHATEST_ON
  2360. clip(Alpha - AlphaClipThreshold);
  2361. #endif
  2362. InputData inputData;
  2363. inputData.positionWS = WorldPosition;
  2364. inputData.viewDirectionWS = WorldViewDirection;
  2365. inputData.shadowCoord = ShadowCoords;
  2366. #ifdef _NORMALMAP
  2367. #if _NORMAL_DROPOFF_TS
  2368. inputData.normalWS = TransformTangentToWorld(Normal, half3x3( WorldTangent, WorldBiTangent, WorldNormal ));
  2369. #elif _NORMAL_DROPOFF_OS
  2370. inputData.normalWS = TransformObjectToWorldNormal(Normal);
  2371. #elif _NORMAL_DROPOFF_WS
  2372. inputData.normalWS = Normal;
  2373. #endif
  2374. inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS);
  2375. #else
  2376. inputData.normalWS = WorldNormal;
  2377. #endif
  2378. #ifdef ASE_FOG
  2379. inputData.fogCoord = IN.fogFactorAndVertexLight.x;
  2380. #endif
  2381. inputData.vertexLighting = IN.fogFactorAndVertexLight.yzw;
  2382. #if defined(ENABLE_TERRAIN_PERPIXEL_NORMAL)
  2383. float3 SH = SampleSH(inputData.normalWS.xyz);
  2384. #else
  2385. float3 SH = IN.lightmapUVOrVertexSH.xyz;
  2386. #endif
  2387. inputData.bakedGI = SAMPLE_GI( IN.lightmapUVOrVertexSH.xy, SH, inputData.normalWS );
  2388. #ifdef _ASE_BAKEDGI
  2389. inputData.bakedGI = BakedGI;
  2390. #endif
  2391. BRDFData brdfData;
  2392. InitializeBRDFData( Albedo, Metallic, Specular, Smoothness, Alpha, brdfData);
  2393. half4 color;
  2394. color.rgb = GlobalIllumination( brdfData, inputData.bakedGI, Occlusion, inputData.normalWS, inputData.viewDirectionWS);
  2395. color.a = Alpha;
  2396. #ifdef _TRANSMISSION_ASE
  2397. {
  2398. float shadow = _TransmissionShadow;
  2399. Light mainLight = GetMainLight( inputData.shadowCoord );
  2400. float3 mainAtten = mainLight.color * mainLight.distanceAttenuation;
  2401. mainAtten = lerp( mainAtten, mainAtten * mainLight.shadowAttenuation, shadow );
  2402. half3 mainTransmission = max(0 , -dot(inputData.normalWS, mainLight.direction)) * mainAtten * Transmission;
  2403. color.rgb += Albedo * mainTransmission;
  2404. #ifdef _ADDITIONAL_LIGHTS
  2405. int transPixelLightCount = GetAdditionalLightsCount();
  2406. for (int i = 0; i < transPixelLightCount; ++i)
  2407. {
  2408. Light light = GetAdditionalLight(i, inputData.positionWS);
  2409. float3 atten = light.color * light.distanceAttenuation;
  2410. atten = lerp( atten, atten * light.shadowAttenuation, shadow );
  2411. half3 transmission = max(0 , -dot(inputData.normalWS, light.direction)) * atten * Transmission;
  2412. color.rgb += Albedo * transmission;
  2413. }
  2414. #endif
  2415. }
  2416. #endif
  2417. #ifdef _TRANSLUCENCY_ASE
  2418. {
  2419. float shadow = _TransShadow;
  2420. float normal = _TransNormal;
  2421. float scattering = _TransScattering;
  2422. float direct = _TransDirect;
  2423. float ambient = _TransAmbient;
  2424. float strength = _TransStrength;
  2425. Light mainLight = GetMainLight( inputData.shadowCoord );
  2426. float3 mainAtten = mainLight.color * mainLight.distanceAttenuation;
  2427. mainAtten = lerp( mainAtten, mainAtten * mainLight.shadowAttenuation, shadow );
  2428. half3 mainLightDir = mainLight.direction + inputData.normalWS * normal;
  2429. half mainVdotL = pow( saturate( dot( inputData.viewDirectionWS, -mainLightDir ) ), scattering );
  2430. half3 mainTranslucency = mainAtten * ( mainVdotL * direct + inputData.bakedGI * ambient ) * Translucency;
  2431. color.rgb += Albedo * mainTranslucency * strength;
  2432. #ifdef _ADDITIONAL_LIGHTS
  2433. int transPixelLightCount = GetAdditionalLightsCount();
  2434. for (int i = 0; i < transPixelLightCount; ++i)
  2435. {
  2436. Light light = GetAdditionalLight(i, inputData.positionWS);
  2437. float3 atten = light.color * light.distanceAttenuation;
  2438. atten = lerp( atten, atten * light.shadowAttenuation, shadow );
  2439. half3 lightDir = light.direction + inputData.normalWS * normal;
  2440. half VdotL = pow( saturate( dot( inputData.viewDirectionWS, -lightDir ) ), scattering );
  2441. half3 translucency = atten * ( VdotL * direct + inputData.bakedGI * ambient ) * Translucency;
  2442. color.rgb += Albedo * translucency * strength;
  2443. }
  2444. #endif
  2445. }
  2446. #endif
  2447. #ifdef _REFRACTION_ASE
  2448. float4 projScreenPos = ScreenPos / ScreenPos.w;
  2449. float3 refractionOffset = ( RefractionIndex - 1.0 ) * mul( UNITY_MATRIX_V, float4( WorldNormal, 0 ) ).xyz * ( 1.0 - dot( WorldNormal, WorldViewDirection ) );
  2450. projScreenPos.xy += refractionOffset.xy;
  2451. float3 refraction = SHADERGRAPH_SAMPLE_SCENE_COLOR( projScreenPos.xy ) * RefractionColor;
  2452. color.rgb = lerp( refraction, color.rgb, color.a );
  2453. color.a = 1;
  2454. #endif
  2455. #ifdef ASE_FINAL_COLOR_ALPHA_MULTIPLY
  2456. color.rgb *= color.a;
  2457. #endif
  2458. #ifdef ASE_FOG
  2459. #ifdef TERRAIN_SPLAT_ADDPASS
  2460. color.rgb = MixFogColor(color.rgb, half3( 0, 0, 0 ), IN.fogFactorAndVertexLight.x );
  2461. #else
  2462. color.rgb = MixFog(color.rgb, IN.fogFactorAndVertexLight.x);
  2463. #endif
  2464. #endif
  2465. #ifdef ASE_DEPTH_WRITE_ON
  2466. outputDepth = DepthValue;
  2467. #endif
  2468. return BRDFDataToGbuffer(brdfData, inputData, Smoothness, Emission + color.rgb);
  2469. }
  2470. ENDHLSL
  2471. }
  2472. }
  2473. CustomEditor "ASEMaterialInspector"
  2474. Fallback "Hidden/InternalErrorShader"
  2475. }
  2476. /*ASEBEGIN
  2477. Version=18927
  2478. 640;93;1329;899;-1383.962;885.8386;1;True;False
  2479. Node;AmplifyShaderEditor.CommentaryNode;180;-686.8809,-709.781;Inherit;False;1213.657;671.5775;;14;106;103;168;104;105;166;6;86;167;169;112;111;113;110;Fetch max 4 weighted layers;1,1,1,1;0;0
  2480. Node;AmplifyShaderEditor.TexturePropertyNode;168;-631.5784,-270.9434;Float;True;Property;_Control2;Control2;2;0;Create;True;0;0;0;False;0;False;None;b65270a08b78d544b9a083f29cd6ef0d;False;white;Auto;Texture2D;-1;0;2;SAMPLER2D;0;SAMPLERSTATE;1
  2481. Node;AmplifyShaderEditor.TexturePropertyNode;103;-634.5789,-659.781;Float;True;Property;_Control0;Control0;0;0;Create;True;0;0;0;False;0;False;None;6c994aeec150fba4c9cae3c391c29d76;False;white;Auto;Texture2D;-1;0;2;SAMPLER2D;0;SAMPLERSTATE;1
  2482. Node;AmplifyShaderEditor.TexturePropertyNode;106;-636.8809,-475.3198;Float;True;Property;_Control1;Control1;1;0;Create;True;0;0;0;False;0;False;None;82d54f2d5e16173409ed7b4cdc1f02dd;False;white;Auto;Texture2D;-1;0;2;SAMPLER2D;0;SAMPLERSTATE;1
  2483. Node;AmplifyShaderEditor.TextureCoordinatesNode;166;-380.3777,-205.4063;Inherit;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  2484. Node;AmplifyShaderEditor.TextureCoordinatesNode;104;-380.3783,-592.244;Inherit;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  2485. Node;AmplifyShaderEditor.CommentaryNode;325;565.7554,-1104.434;Inherit;False;1234.211;895.2533;;11;314;108;337;115;307;322;313;185;321;182;193;Triplanar sample and blend layers;1,1,1,1;0;0
  2486. Node;AmplifyShaderEditor.TextureCoordinatesNode;105;-385.6803,-409.7827;Inherit;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  2487. Node;AmplifyShaderEditor.SamplerNode;86;-126.2071,-472.5799;Inherit;True;Property;_ControlEx;ControlEx;0;0;Create;True;0;0;0;False;0;False;-1;None;None;True;0;False;black;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
  2488. Node;AmplifyShaderEditor.TexturePropertyNode;182;591.1433,-842.9471;Inherit;True;Property;_SplatArray;SplatArray;3;0;Create;True;0;0;0;False;0;False;None;292b309e13a6d7d44ac70f86619d7c80;False;white;LockedToTexture2DArray;Texture2DArray;-1;0;2;SAMPLER2DARRAY;0;SAMPLERSTATE;1
  2489. Node;AmplifyShaderEditor.SamplerNode;6;-133.011,-657.2652;Inherit;True;Property;_TextureSample4;Texture Sample 4;1;0;Create;True;0;0;0;False;0;False;-1;None;None;True;0;False;black;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
  2490. Node;AmplifyShaderEditor.SamplerNode;167;-120.9045,-268.2035;Inherit;True;Property;_TextureSample0;Texture Sample 0;0;0;Create;True;0;0;0;False;0;False;-1;None;None;True;0;False;black;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
  2491. Node;AmplifyShaderEditor.TexturePropertyNode;193;599.1224,-655.8825;Inherit;True;Property;_NormalArray;NormalArray;4;0;Create;True;0;0;0;False;0;False;None;69fbb55c066467242be2b47974c2fa82;False;white;LockedToTexture2DArray;Texture2DArray;-1;0;2;SAMPLER2DARRAY;0;SAMPLERSTATE;1
  2492. Node;AmplifyShaderEditor.Vector4Node;185;882.7981,-413.6318;Inherit;False;Property;_UVScaleOffset;UVScaleOffset;5;0;Create;True;0;0;0;False;0;False;1,1,0,0;1,1,0,0;0;5;FLOAT4;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  2493. Node;AmplifyShaderEditor.CustomExpressionNode;169;272.7763,-526.5311;Inherit;False;Max4WeightLayer(Control0, Control1, Control2, Weights, Indices)@;7;Create;5;True;Control0;FLOAT4;1,0,0,0;In;;Inherit;False;True;Control1;FLOAT4;0,0,0,0;In;;Inherit;False;True;Control2;FLOAT4;0,0,0,0;In;;Inherit;False;True;Weights;FLOAT4;1,0,0,0;Out;;Half;False;True;Indices;FLOAT4;1,0,0,0;Out;;Half;False;GetMax4WeightLayers;False;False;0;;False;6;0;FLOAT;0;False;1;FLOAT4;1,0,0,0;False;2;FLOAT4;0,0,0,0;False;3;FLOAT4;0,0,0,0;False;4;FLOAT4;1,0,0,0;False;5;FLOAT4;1,0,0,0;False;3;FLOAT;0;FLOAT4;5;FLOAT4;6
  2494. Node;AmplifyShaderEditor.SamplerStateNode;322;880.9268,-533.2679;Inherit;False;0;0;0;1;-1;None;1;0;SAMPLER2DARRAY;;False;1;SAMPLERSTATE;0
  2495. Node;AmplifyShaderEditor.WorldNormalVector;314;870.6539,-1054.434;Inherit;False;False;1;0;FLOAT3;0,0,1;False;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3
  2496. Node;AmplifyShaderEditor.SamplerStateNode;321;882.7079,-672.3923;Inherit;False;0;0;0;1;-1;None;1;0;SAMPLER2DARRAY;;False;1;SAMPLERSTATE;0
  2497. Node;AmplifyShaderEditor.WorldPosInputsNode;313;875.192,-906.3575;Inherit;False;0;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3
  2498. Node;AmplifyShaderEditor.CustomExpressionNode;307;1144.691,-694.5832;Inherit;False;//Dependency: MTECommonPBR.hlsl$$// calculate triplanar blend$half3 triblend = saturate(pow(WorldNormal, 4))@$triblend /= max(dot(triblend, half3(1,1,1)), 0.0001)@$$// calculate triplanar uvs$// applying texture scale and offset values$float2 uvX = WorldPos.zy * UVScaleOffset.xy + UVScaleOffset.zw@$float2 uvY = WorldPos.xz * UVScaleOffset.xy + UVScaleOffset.zw@$float2 uvZ = WorldPos.xy * UVScaleOffset.xy + UVScaleOffset.zw@$$// offset UVs to prevent obvious mirroring$//uvY += 0.33@$//uvZ += 0.67@$$// minor optimization of sign(). prevents return value of 0$half3 axisSign = WorldNormal < 0 ? -1 : 1@$$// flip UVs horizontally to correct for back side projection$uvX.x *= axisSign.x@$uvY.x *= axisSign.y@$uvZ.x *= -axisSign.z@$$// albedo textures$OutAlbedo = 0@$OutWorldNormal = 0@$for(int i = 0@ i < 4@ i++)${$ int index = Indices[i]@$ float weight = Weights[i]@$$ float4 colX = SAMPLE_TEXTURE2D_ARRAY(AlbedoArray, AlbedoArraySampler, uvX, index)@$ float4 colY = SAMPLE_TEXTURE2D_ARRAY(AlbedoArray, AlbedoArraySampler, uvY, index)@$ float4 colZ = SAMPLE_TEXTURE2D_ARRAY(AlbedoArray, AlbedoArraySampler, uvZ, index)@$ float4 albedo = colX * triblend.x + colY * triblend.y + colZ * triblend.z@$ OutAlbedo += albedo * weight@$$ // tangent space normal maps$ half3 tnormalX = UnpackNormal(SAMPLE_TEXTURE2D_ARRAY(NormalArray, NormalArraySampler, uvX, index))@$ half3 tnormalY = UnpackNormal(SAMPLE_TEXTURE2D_ARRAY(NormalArray, NormalArraySampler, uvY, index))@$ half3 tnormalZ = UnpackNormal(SAMPLE_TEXTURE2D_ARRAY(NormalArray, NormalArraySampler, uvZ, index))@$$ // flip normal maps' x axis to account for flipped UVs$ tnormalX.x *= axisSign.x@$ tnormalY.x *= axisSign.y@$ tnormalZ.x *= -axisSign.z@$$ half3 absVertNormal = abs(WorldNormal)@$$ // swizzle world normals to match tangent space and apply reoriented normal mapping blend$ tnormalX = blend_rnm(half3(WorldNormal.zy, absVertNormal.x), tnormalX)@$ tnormalY = blend_rnm(half3(WorldNormal.xz, absVertNormal.y), tnormalY)@$ tnormalZ = blend_rnm(half3(WorldNormal.xy, absVertNormal.z), tnormalZ)@$$ // apply world space sign to tangent space Z$ tnormalX.z *= axisSign.x@$ tnormalY.z *= axisSign.y@$ tnormalZ.z *= axisSign.z@$$ // sizzle tangent normals to match world normal and blend together$ float3 normal = normalize($ tnormalX.zyx * triblend.x +$ tnormalY.xzy * triblend.y +$ tnormalZ.xyz * triblend.z$ )@$$ OutWorldNormal += normal * weight@$}$;7;Create;11;True;WorldNormal;FLOAT3;0,0,0;In;;Inherit;False;True;WorldPos;FLOAT3;0,0,0;In;;Inherit;False;True;AlbedoArray;SAMPLER2DARRAY;;In;;Inherit;False;True;AlbedoArraySampler;SAMPLERSTATE;;In;;Inherit;False;True;NormalArray;SAMPLER2DARRAY;;In;;Inherit;False;True;NormalArraySampler;SAMPLERSTATE;;In;;Inherit;False;True;UVScaleOffset;FLOAT4;1,1,0,0;In;;Inherit;False;True;Weights;FLOAT4;0,0,0,0;In;;Inherit;False;True;Indices;FLOAT4;0,0,0,0;In;;Inherit;False;True;OutAlbedo;FLOAT4;0,0,0,0;Out;;Inherit;False;True;OutWorldNormal;FLOAT3;0,0,0;Out;;Inherit;False;TriplanarBlendLayers;False;False;0;;False;12;0;FLOAT;0;False;1;FLOAT3;0,0,0;False;2;FLOAT3;0,0,0;False;3;SAMPLER2DARRAY;;False;4;SAMPLERSTATE;;False;5;SAMPLER2DARRAY;;False;6;SAMPLERSTATE;;False;7;FLOAT4;1,1,0,0;False;8;FLOAT4;0,0,0,0;False;9;FLOAT4;0,0,0,0;False;10;FLOAT4;0,0,0,0;False;11;FLOAT3;0,0,0;False;3;FLOAT;0;FLOAT4;11;FLOAT3;12
  2499. Node;AmplifyShaderEditor.TransformDirectionNode;337;1568.077,-556.4105;Inherit;False;World;Tangent;False;Fast;False;1;0;FLOAT3;0,0,0;False;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3
  2500. Node;AmplifyShaderEditor.CustomExpressionNode;115;1560.73,-693.1279;Inherit;False;RGB = RGBA.rgb@$A = RGBA.a@;7;Create;3;True;RGBA;FLOAT4;0,0,0,0;In;;Inherit;False;True;RGB;FLOAT3;0,0,0;Out;;Inherit;False;True;A;FLOAT;0;Out;;Inherit;False;BreakRGBA;False;False;0;;False;4;0;FLOAT4;0,0,0,0;False;1;FLOAT4;0,0,0,0;False;2;FLOAT3;0,0,0;False;3;FLOAT;0;False;3;FLOAT4;0;FLOAT3;3;FLOAT;4
  2501. Node;AmplifyShaderEditor.ColorNode;341;1851.962,-492.8386;Inherit;False;Property;_SpecColor;SpecColor;7;0;Create;True;0;0;0;False;0;False;0,0,0,0;0,0,0,0;True;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
  2502. Node;AmplifyShaderEditor.RangedFloatNode;220;1831.993,-302.7517;Inherit;False;Property;_Smoothness;Smoothness;6;0;Create;True;0;0;0;False;0;False;0;0;0;1;0;1;FLOAT;0
  2503. Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;111;240.7755,-183.3562;Float;False;False;-1;2;UnityEditor.ShaderGraph.PBRMasterGUI;0;1;New Amplify Shader;94348b07e5e8bab40bd6c8a1e3df54cd;True;DepthOnly;0;3;DepthOnly;0;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;-1;False;True;0;False;-1;False;False;False;False;False;False;False;False;False;True;False;255;False;-1;255;False;-1;255;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;False;False;False;False;True;3;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;0;True;17;d3d9;d3d11;glcore;gles;gles3;metal;vulkan;xbox360;xboxone;xboxseries;ps4;playstation;psp2;n3ds;wiiu;switch;nomrt;0;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;-1;False;False;False;True;False;False;False;False;0;False;-1;False;False;False;False;False;False;False;False;False;True;1;False;-1;False;False;True;1;LightMode=DepthOnly;False;False;0;Hidden/InternalErrorShader;0;0;Standard;0;False;0
  2504. Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;339;2128.728,-606.5547;Float;False;False;-1;2;UnityEditor.ShaderGraph.PBRMasterGUI;0;1;New Amplify Shader;94348b07e5e8bab40bd6c8a1e3df54cd;True;GBuffer;0;7;GBuffer;0;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;-1;False;True;0;False;-1;False;False;False;False;False;False;False;False;False;True;False;255;False;-1;255;False;-1;255;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;False;False;False;False;True;3;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;0;True;17;d3d9;d3d11;glcore;gles;gles3;metal;vulkan;xbox360;xboxone;xboxseries;ps4;playstation;psp2;n3ds;wiiu;switch;nomrt;0;False;True;1;1;False;-1;0;False;-1;1;1;False;-1;0;False;-1;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;True;True;True;True;0;False;-1;False;False;False;False;False;False;False;True;False;255;False;-1;255;False;-1;255;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;False;True;1;False;-1;True;3;False;-1;True;True;0;False;-1;0;False;-1;True;1;LightMode=UniversalGBuffer;False;False;0;Hidden/InternalErrorShader;0;0;Standard;0;False;0
  2505. Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;113;240.7755,-183.3562;Float;False;False;-1;2;UnityEditor.ShaderGraph.PBRMasterGUI;0;1;New Amplify Shader;94348b07e5e8bab40bd6c8a1e3df54cd;True;Universal2D;0;5;Universal2D;0;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;-1;False;True;0;False;-1;False;False;False;False;False;False;False;False;False;True;False;255;False;-1;255;False;-1;255;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;False;False;False;False;True;3;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;0;True;17;d3d9;d3d11;glcore;gles;gles3;metal;vulkan;xbox360;xboxone;xboxseries;ps4;playstation;psp2;n3ds;wiiu;switch;nomrt;0;False;True;1;1;False;-1;0;False;-1;1;1;False;-1;0;False;-1;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;True;True;True;True;0;False;-1;False;False;False;False;False;False;False;False;False;True;1;False;-1;True;3;False;-1;True;True;0;False;-1;0;False;-1;True;1;LightMode=Universal2D;False;False;0;Hidden/InternalErrorShader;0;0;Standard;0;False;0
  2506. Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;110;240.7755,-183.3562;Float;False;False;-1;2;UnityEditor.ShaderGraph.PBRMasterGUI;0;1;New Amplify Shader;94348b07e5e8bab40bd6c8a1e3df54cd;True;ShadowCaster;0;2;ShadowCaster;0;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;-1;False;True;0;False;-1;False;False;False;False;False;False;False;False;False;True;False;255;False;-1;255;False;-1;255;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;False;False;False;False;True;3;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;0;True;17;d3d9;d3d11;glcore;gles;gles3;metal;vulkan;xbox360;xboxone;xboxseries;ps4;playstation;psp2;n3ds;wiiu;switch;nomrt;0;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;-1;False;False;False;True;False;False;False;False;0;False;-1;False;False;False;False;False;False;False;False;False;True;1;False;-1;True;3;False;-1;False;True;1;LightMode=ShadowCaster;False;False;0;Hidden/InternalErrorShader;0;0;Standard;0;False;0
  2507. Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;109;2128.728,-666.5547;Float;False;True;-1;2;ASEMaterialInspector;0;2;MTE/URP/TextureArray_Triplanar;94348b07e5e8bab40bd6c8a1e3df54cd;True;Forward;0;1;Forward;18;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;-1;False;True;0;False;-1;False;False;False;False;False;False;False;False;False;True;False;255;False;-1;255;False;-1;255;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;False;False;False;False;True;3;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;2;True;17;d3d9;d3d11;glcore;gles;gles3;metal;vulkan;xbox360;xboxone;xboxseries;ps4;playstation;psp2;n3ds;wiiu;switch;nomrt;0;False;True;1;1;False;-1;0;False;-1;1;1;False;-1;0;False;-1;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;True;True;True;True;0;False;-1;False;False;False;False;False;False;False;True;False;255;False;-1;255;False;-1;255;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;False;True;1;False;-1;True;3;False;-1;True;True;0;False;-1;0;False;-1;True;1;LightMode=UniversalForward;False;False;2;Include;;False;;Native;Include;../MTECommonPBR.hlsl;False;fa510ed2a5a3b2d4a9ef902d0fbdd6e2;Custom;Hidden/InternalErrorShader;0;0;Standard;38;Workflow;0;Surface;0; Refraction Model;0; Blend;0;Two Sided;1;Fragment Normal Space,InvertActionOnDeselection;0;Transmission;0; Transmission Shadow;0.5,False,-1;Translucency;0; Translucency Strength;1,False,-1; Normal Distortion;0.5,False,-1; Scattering;2,False,-1; Direct;0.9,False,-1; Ambient;0.1,False,-1; Shadow;0.5,False,-1;Cast Shadows;1; Use Shadow Threshold;0;Receive Shadows;1;GPU Instancing;1;LOD CrossFade;1;Built-in Fog;1;_FinalColorxAlpha;0;Meta Pass;1;Override Baked GI;0;Extra Pre Pass;0;DOTS Instancing;0;Tessellation;0; Phong;0; Strength;0.5,False,-1; Type;0; Tess;16,False,-1; Min;10,False,-1; Max;25,False,-1; Edge Length;16,False,-1; Max Displacement;25,False,-1;Write Depth;0; Early Z;0;Vertex Position,InvertActionOnDeselection;1;0;8;False;True;True;True;True;True;True;True;False;;True;0
  2508. Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;112;240.7755,-183.3562;Float;False;False;-1;2;UnityEditor.ShaderGraph.PBRMasterGUI;0;1;New Amplify Shader;94348b07e5e8bab40bd6c8a1e3df54cd;True;Meta;0;4;Meta;0;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;-1;False;True;0;False;-1;False;False;False;False;False;False;False;False;False;True;False;255;False;-1;255;False;-1;255;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;False;False;False;False;True;3;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;0;True;17;d3d9;d3d11;glcore;gles;gles3;metal;vulkan;xbox360;xboxone;xboxseries;ps4;playstation;psp2;n3ds;wiiu;switch;nomrt;0;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;2;False;-1;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;1;LightMode=Meta;False;False;0;Hidden/InternalErrorShader;0;0;Standard;0;False;0
  2509. Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;108;798.0896,-294.2241;Float;False;False;-1;2;UnityEditor.ShaderGraph.PBRMasterGUI;0;1;New Amplify Shader;94348b07e5e8bab40bd6c8a1e3df54cd;True;ExtraPrePass;0;0;ExtraPrePass;5;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;-1;False;True;0;False;-1;False;False;False;False;False;False;False;False;False;True;False;255;False;-1;255;False;-1;255;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;False;False;False;False;True;3;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;0;True;17;d3d9;d3d11;glcore;gles;gles3;metal;vulkan;xbox360;xboxone;xboxseries;ps4;playstation;psp2;n3ds;wiiu;switch;nomrt;0;False;True;1;1;False;-1;0;False;-1;0;1;False;-1;0;False;-1;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;-1;False;True;True;True;True;True;0;False;-1;False;False;False;False;False;False;False;True;False;255;False;-1;255;False;-1;255;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;False;True;1;False;-1;True;3;False;-1;True;True;0;False;-1;0;False;-1;True;0;False;False;0;Hidden/InternalErrorShader;0;0;Standard;0;False;0
  2510. Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;338;2128.728,-606.5547;Float;False;False;-1;2;UnityEditor.ShaderGraph.PBRMasterGUI;0;1;New Amplify Shader;94348b07e5e8bab40bd6c8a1e3df54cd;True;DepthNormals;0;6;DepthNormals;0;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;-1;False;True;0;False;-1;False;False;False;False;False;False;False;False;False;True;False;255;False;-1;255;False;-1;255;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;False;False;False;False;True;3;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;0;True;17;d3d9;d3d11;glcore;gles;gles3;metal;vulkan;xbox360;xboxone;xboxseries;ps4;playstation;psp2;n3ds;wiiu;switch;nomrt;0;False;True;1;1;False;-1;0;False;-1;0;1;False;-1;0;False;-1;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;1;False;-1;True;3;False;-1;False;True;1;LightMode=DepthNormals;False;False;0;Hidden/InternalErrorShader;0;0;Standard;0;False;0
  2511. WireConnection;166;2;168;0
  2512. WireConnection;104;2;103;0
  2513. WireConnection;105;2;106;0
  2514. WireConnection;86;0;106;0
  2515. WireConnection;86;1;105;0
  2516. WireConnection;6;0;103;0
  2517. WireConnection;6;1;104;0
  2518. WireConnection;167;0;168;0
  2519. WireConnection;167;1;166;0
  2520. WireConnection;169;1;6;0
  2521. WireConnection;169;2;86;0
  2522. WireConnection;169;3;167;0
  2523. WireConnection;322;0;193;0
  2524. WireConnection;321;0;182;0
  2525. WireConnection;307;1;314;0
  2526. WireConnection;307;2;313;0
  2527. WireConnection;307;3;182;0
  2528. WireConnection;307;4;321;0
  2529. WireConnection;307;5;193;0
  2530. WireConnection;307;6;322;0
  2531. WireConnection;307;7;185;0
  2532. WireConnection;307;8;169;5
  2533. WireConnection;307;9;169;6
  2534. WireConnection;337;0;307;12
  2535. WireConnection;115;1;307;11
  2536. WireConnection;109;0;115;3
  2537. WireConnection;109;1;337;0
  2538. WireConnection;109;9;341;0
  2539. WireConnection;109;4;220;0
  2540. ASEEND*/
  2541. //CHKSM=A7552927BAEE6D44995395B2CE9FF99793A85703