Mesh Cross Fade.shader 127 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537
  1. // Made with Amplify Shader Editor v1.9.7.1
  2. // Available at the Unity Asset Store - http://u3d.as/y3X
  3. Shader "Toby Fredson/Custom/Mesh Cross Fade"
  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. _AlbedoMap("Albedo Map", 2D) = "white" {}
  10. _AlbedoColor("Albedo Color", Color) = (1,1,1,0)
  11. [Normal]_NormalMap("Normal Map", 2D) = "bump" {}
  12. _MaskMap("Mask Map", 2D) = "white" {}
  13. [HideInInspector] _texcoord( "", 2D ) = "white" {}
  14. //_TransmissionShadow( "Transmission Shadow", Range( 0, 1 ) ) = 0.5
  15. //_TransStrength( "Trans Strength", Range( 0, 50 ) ) = 1
  16. //_TransNormal( "Trans Normal Distortion", Range( 0, 1 ) ) = 0.5
  17. //_TransScattering( "Trans Scattering", Range( 1, 50 ) ) = 2
  18. //_TransDirect( "Trans Direct", Range( 0, 1 ) ) = 0.9
  19. //_TransAmbient( "Trans Ambient", Range( 0, 1 ) ) = 0.1
  20. //_TransShadow( "Trans Shadow", Range( 0, 1 ) ) = 0.5
  21. //_TessPhongStrength( "Tess Phong Strength", Range( 0, 1 ) ) = 0.5
  22. //_TessValue( "Tess Max Tessellation", Range( 1, 32 ) ) = 16
  23. //_TessMin( "Tess Min Distance", Float ) = 10
  24. //_TessMax( "Tess Max Distance", Float ) = 25
  25. //_TessEdgeLength ( "Tess Edge length", Range( 2, 50 ) ) = 16
  26. //_TessMaxDisp( "Tess Max Displacement", Float ) = 25
  27. [HideInInspector][ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1
  28. [HideInInspector][ToggleOff] _EnvironmentReflections("Environment Reflections", Float) = 1
  29. [HideInInspector][ToggleOff] _ReceiveShadows("Receive Shadows", Float) = 1.0
  30. [HideInInspector] _QueueOffset("_QueueOffset", Float) = 0
  31. [HideInInspector] _QueueControl("_QueueControl", Float) = -1
  32. [HideInInspector][NoScaleOffset] unity_Lightmaps("unity_Lightmaps", 2DArray) = "" {}
  33. [HideInInspector][NoScaleOffset] unity_LightmapsInd("unity_LightmapsInd", 2DArray) = "" {}
  34. [HideInInspector][NoScaleOffset] unity_ShadowMasks("unity_ShadowMasks", 2DArray) = "" {}
  35. //[HideInInspector][ToggleUI] _AddPrecomputedVelocity("Add Precomputed Velocity", Float) = 1
  36. }
  37. SubShader
  38. {
  39. LOD 0
  40. Tags { "RenderPipeline"="UniversalPipeline" "RenderType"="Opaque" "Queue"="Geometry" "UniversalMaterialType"="Lit" }
  41. Cull Back
  42. ZWrite On
  43. ZTest LEqual
  44. Offset 0 , 0
  45. AlphaToMask Off
  46. HLSLINCLUDE
  47. #pragma target 4.5
  48. #pragma prefer_hlslcc gles
  49. // ensure rendering platforms toggle list is visible
  50. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
  51. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Filtering.hlsl"
  52. #ifndef ASE_TESS_FUNCS
  53. #define ASE_TESS_FUNCS
  54. float4 FixedTess( float tessValue )
  55. {
  56. return tessValue;
  57. }
  58. float CalcDistanceTessFactor (float4 vertex, float minDist, float maxDist, float tess, float4x4 o2w, float3 cameraPos )
  59. {
  60. float3 wpos = mul(o2w,vertex).xyz;
  61. float dist = distance (wpos, cameraPos);
  62. float f = clamp(1.0 - (dist - minDist) / (maxDist - minDist), 0.01, 1.0) * tess;
  63. return f;
  64. }
  65. float4 CalcTriEdgeTessFactors (float3 triVertexFactors)
  66. {
  67. float4 tess;
  68. tess.x = 0.5 * (triVertexFactors.y + triVertexFactors.z);
  69. tess.y = 0.5 * (triVertexFactors.x + triVertexFactors.z);
  70. tess.z = 0.5 * (triVertexFactors.x + triVertexFactors.y);
  71. tess.w = (triVertexFactors.x + triVertexFactors.y + triVertexFactors.z) / 3.0f;
  72. return tess;
  73. }
  74. float CalcEdgeTessFactor (float3 wpos0, float3 wpos1, float edgeLen, float3 cameraPos, float4 scParams )
  75. {
  76. float dist = distance (0.5 * (wpos0+wpos1), cameraPos);
  77. float len = distance(wpos0, wpos1);
  78. float f = max(len * scParams.y / (edgeLen * dist), 1.0);
  79. return f;
  80. }
  81. float DistanceFromPlane (float3 pos, float4 plane)
  82. {
  83. float d = dot (float4(pos,1.0f), plane);
  84. return d;
  85. }
  86. bool WorldViewFrustumCull (float3 wpos0, float3 wpos1, float3 wpos2, float cullEps, float4 planes[6] )
  87. {
  88. float4 planeTest;
  89. planeTest.x = (( DistanceFromPlane(wpos0, planes[0]) > -cullEps) ? 1.0f : 0.0f ) +
  90. (( DistanceFromPlane(wpos1, planes[0]) > -cullEps) ? 1.0f : 0.0f ) +
  91. (( DistanceFromPlane(wpos2, planes[0]) > -cullEps) ? 1.0f : 0.0f );
  92. planeTest.y = (( DistanceFromPlane(wpos0, planes[1]) > -cullEps) ? 1.0f : 0.0f ) +
  93. (( DistanceFromPlane(wpos1, planes[1]) > -cullEps) ? 1.0f : 0.0f ) +
  94. (( DistanceFromPlane(wpos2, planes[1]) > -cullEps) ? 1.0f : 0.0f );
  95. planeTest.z = (( DistanceFromPlane(wpos0, planes[2]) > -cullEps) ? 1.0f : 0.0f ) +
  96. (( DistanceFromPlane(wpos1, planes[2]) > -cullEps) ? 1.0f : 0.0f ) +
  97. (( DistanceFromPlane(wpos2, planes[2]) > -cullEps) ? 1.0f : 0.0f );
  98. planeTest.w = (( DistanceFromPlane(wpos0, planes[3]) > -cullEps) ? 1.0f : 0.0f ) +
  99. (( DistanceFromPlane(wpos1, planes[3]) > -cullEps) ? 1.0f : 0.0f ) +
  100. (( DistanceFromPlane(wpos2, planes[3]) > -cullEps) ? 1.0f : 0.0f );
  101. return !all (planeTest);
  102. }
  103. float4 DistanceBasedTess( float4 v0, float4 v1, float4 v2, float tess, float minDist, float maxDist, float4x4 o2w, float3 cameraPos )
  104. {
  105. float3 f;
  106. f.x = CalcDistanceTessFactor (v0,minDist,maxDist,tess,o2w,cameraPos);
  107. f.y = CalcDistanceTessFactor (v1,minDist,maxDist,tess,o2w,cameraPos);
  108. f.z = CalcDistanceTessFactor (v2,minDist,maxDist,tess,o2w,cameraPos);
  109. return CalcTriEdgeTessFactors (f);
  110. }
  111. float4 EdgeLengthBasedTess( float4 v0, float4 v1, float4 v2, float edgeLength, float4x4 o2w, float3 cameraPos, float4 scParams )
  112. {
  113. float3 pos0 = mul(o2w,v0).xyz;
  114. float3 pos1 = mul(o2w,v1).xyz;
  115. float3 pos2 = mul(o2w,v2).xyz;
  116. float4 tess;
  117. tess.x = CalcEdgeTessFactor (pos1, pos2, edgeLength, cameraPos, scParams);
  118. tess.y = CalcEdgeTessFactor (pos2, pos0, edgeLength, cameraPos, scParams);
  119. tess.z = CalcEdgeTessFactor (pos0, pos1, edgeLength, cameraPos, scParams);
  120. tess.w = (tess.x + tess.y + tess.z) / 3.0f;
  121. return tess;
  122. }
  123. float4 EdgeLengthBasedTessCull( float4 v0, float4 v1, float4 v2, float edgeLength, float maxDisplacement, float4x4 o2w, float3 cameraPos, float4 scParams, float4 planes[6] )
  124. {
  125. float3 pos0 = mul(o2w,v0).xyz;
  126. float3 pos1 = mul(o2w,v1).xyz;
  127. float3 pos2 = mul(o2w,v2).xyz;
  128. float4 tess;
  129. if (WorldViewFrustumCull(pos0, pos1, pos2, maxDisplacement, planes))
  130. {
  131. tess = 0.0f;
  132. }
  133. else
  134. {
  135. tess.x = CalcEdgeTessFactor (pos1, pos2, edgeLength, cameraPos, scParams);
  136. tess.y = CalcEdgeTessFactor (pos2, pos0, edgeLength, cameraPos, scParams);
  137. tess.z = CalcEdgeTessFactor (pos0, pos1, edgeLength, cameraPos, scParams);
  138. tess.w = (tess.x + tess.y + tess.z) / 3.0f;
  139. }
  140. return tess;
  141. }
  142. #endif //ASE_TESS_FUNCS
  143. ENDHLSL
  144. Pass
  145. {
  146. Name "Forward"
  147. Tags { "LightMode"="UniversalForward" }
  148. Blend One Zero, One Zero
  149. ZWrite On
  150. ZTest LEqual
  151. Offset 0 , 0
  152. ColorMask RGBA
  153. HLSLPROGRAM
  154. #pragma multi_compile_local_fragment _ALPHATEST_ON
  155. #define _NORMAL_DROPOFF_TS 1
  156. #pragma shader_feature_local _RECEIVE_SHADOWS_OFF
  157. #pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
  158. #pragma multi_compile_instancing
  159. #pragma instancing_options renderinglayer
  160. #pragma multi_compile _ LOD_FADE_CROSSFADE
  161. #pragma multi_compile_fog
  162. #define ASE_FOG 1
  163. #define _NORMALMAP 1
  164. #define ASE_VERSION 19701
  165. #define ASE_SRP_VERSION 170003
  166. #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
  167. #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
  168. #pragma multi_compile _ EVALUATE_SH_MIXED EVALUATE_SH_VERTEX
  169. #pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
  170. #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
  171. #pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION
  172. #pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
  173. #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
  174. #pragma multi_compile _ _LIGHT_LAYERS
  175. #pragma multi_compile_fragment _ _LIGHT_COOKIES
  176. #pragma multi_compile _ _FORWARD_PLUS
  177. #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
  178. #pragma multi_compile _ SHADOWS_SHADOWMASK
  179. #pragma multi_compile _ DIRLIGHTMAP_COMBINED
  180. #pragma multi_compile _ LIGHTMAP_ON
  181. #pragma multi_compile _ DYNAMICLIGHTMAP_ON
  182. #pragma multi_compile _ USE_LEGACY_LIGHTMAPS
  183. #pragma multi_compile_fragment _ DEBUG_DISPLAY
  184. #pragma vertex vert
  185. #pragma fragment frag
  186. #if defined(_SPECULAR_SETUP) && defined(_ASE_LIGHTING_SIMPLE)
  187. #define _SPECULAR_COLOR 1
  188. #endif
  189. #define SHADERPASS SHADERPASS_FORWARD
  190. #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
  191. #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"
  192. #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl"
  193. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  194. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
  195. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  196. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  197. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl"
  198. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
  199. #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
  200. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl"
  201. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl"
  202. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl"
  203. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  204. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DBuffer.hlsl"
  205. #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
  206. #if defined(LOD_FADE_CROSSFADE)
  207. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl"
  208. #endif
  209. #if defined(UNITY_INSTANCING_ENABLED) && defined(_TERRAIN_INSTANCED_PERPIXEL_NORMAL)
  210. #define ENABLE_TERRAIN_PERPIXEL_NORMAL
  211. #endif
  212. #if defined(ASE_EARLY_Z_DEPTH_OPTIMIZE) && (SHADER_TARGET >= 45)
  213. #define ASE_SV_DEPTH SV_DepthLessEqual
  214. #define ASE_SV_POSITION_QUALIFIERS linear noperspective centroid
  215. #else
  216. #define ASE_SV_DEPTH SV_Depth
  217. #define ASE_SV_POSITION_QUALIFIERS
  218. #endif
  219. struct Attributes
  220. {
  221. float4 positionOS : POSITION;
  222. float3 normalOS : NORMAL;
  223. float4 tangentOS : TANGENT;
  224. float4 texcoord : TEXCOORD0;
  225. float4 texcoord1 : TEXCOORD1;
  226. float4 texcoord2 : TEXCOORD2;
  227. UNITY_VERTEX_INPUT_INSTANCE_ID
  228. };
  229. struct PackedVaryings
  230. {
  231. ASE_SV_POSITION_QUALIFIERS float4 positionCS : SV_POSITION;
  232. float4 clipPosV : TEXCOORD0;
  233. float4 lightmapUVOrVertexSH : TEXCOORD1;
  234. half4 fogFactorAndVertexLight : TEXCOORD2;
  235. float4 tSpace0 : TEXCOORD3;
  236. float4 tSpace1 : TEXCOORD4;
  237. float4 tSpace2 : TEXCOORD5;
  238. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  239. float4 shadowCoord : TEXCOORD6;
  240. #endif
  241. #if defined(DYNAMICLIGHTMAP_ON)
  242. float2 dynamicLightmapUV : TEXCOORD7;
  243. #endif
  244. #if defined(USE_APV_PROBE_OCCLUSION)
  245. float4 probeOcclusion : TEXCOORD8;
  246. #endif
  247. float4 ase_texcoord9 : TEXCOORD9;
  248. UNITY_VERTEX_INPUT_INSTANCE_ID
  249. UNITY_VERTEX_OUTPUT_STEREO
  250. };
  251. CBUFFER_START(UnityPerMaterial)
  252. float4 _AlbedoColor;
  253. float4 _AlbedoMap_ST;
  254. float4 _NormalMap_ST;
  255. float4 _MaskMap_ST;
  256. #ifdef ASE_TRANSMISSION
  257. float _TransmissionShadow;
  258. #endif
  259. #ifdef ASE_TRANSLUCENCY
  260. float _TransStrength;
  261. float _TransNormal;
  262. float _TransScattering;
  263. float _TransDirect;
  264. float _TransAmbient;
  265. float _TransShadow;
  266. #endif
  267. #ifdef ASE_TESSELLATION
  268. float _TessPhongStrength;
  269. float _TessValue;
  270. float _TessMin;
  271. float _TessMax;
  272. float _TessEdgeLength;
  273. float _TessMaxDisp;
  274. #endif
  275. CBUFFER_END
  276. #ifdef SCENEPICKINGPASS
  277. float4 _SelectionID;
  278. #endif
  279. #ifdef SCENESELECTIONPASS
  280. int _ObjectId;
  281. int _PassValue;
  282. #endif
  283. sampler2D _AlbedoMap;
  284. sampler2D _NormalMap;
  285. sampler2D _MaskMap;
  286. PackedVaryings VertexFunction( Attributes input )
  287. {
  288. PackedVaryings output = (PackedVaryings)0;
  289. UNITY_SETUP_INSTANCE_ID(input);
  290. UNITY_TRANSFER_INSTANCE_ID(input, output);
  291. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
  292. output.ase_texcoord9.xy = input.texcoord.xy;
  293. //setting value to unused interpolator channels and avoid initialization warnings
  294. output.ase_texcoord9.zw = 0;
  295. #ifdef ASE_ABSOLUTE_VERTEX_POS
  296. float3 defaultVertexValue = input.positionOS.xyz;
  297. #else
  298. float3 defaultVertexValue = float3(0, 0, 0);
  299. #endif
  300. float3 vertexValue = defaultVertexValue;
  301. #ifdef ASE_ABSOLUTE_VERTEX_POS
  302. input.positionOS.xyz = vertexValue;
  303. #else
  304. input.positionOS.xyz += vertexValue;
  305. #endif
  306. input.normalOS = input.normalOS;
  307. input.tangentOS = input.tangentOS;
  308. VertexPositionInputs vertexInput = GetVertexPositionInputs( input.positionOS.xyz );
  309. VertexNormalInputs normalInput = GetVertexNormalInputs( input.normalOS, input.tangentOS );
  310. output.tSpace0 = float4( normalInput.normalWS, vertexInput.positionWS.x );
  311. output.tSpace1 = float4( normalInput.tangentWS, vertexInput.positionWS.y );
  312. output.tSpace2 = float4( normalInput.bitangentWS, vertexInput.positionWS.z );
  313. #if defined(LIGHTMAP_ON)
  314. OUTPUT_LIGHTMAP_UV( input.texcoord1, unity_LightmapST, output.lightmapUVOrVertexSH.xy );
  315. #endif
  316. #if defined(DYNAMICLIGHTMAP_ON)
  317. output.dynamicLightmapUV.xy = input.texcoord2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
  318. #endif
  319. OUTPUT_SH4( vertexInput.positionWS, normalInput.normalWS.xyz, GetWorldSpaceNormalizeViewDir( vertexInput.positionWS ), output.lightmapUVOrVertexSH.xyz, output.probeOcclusion );
  320. #if defined(ENABLE_TERRAIN_PERPIXEL_NORMAL)
  321. output.lightmapUVOrVertexSH.zw = input.texcoord.xy;
  322. output.lightmapUVOrVertexSH.xy = input.texcoord.xy * unity_LightmapST.xy + unity_LightmapST.zw;
  323. #endif
  324. half3 vertexLight = VertexLighting( vertexInput.positionWS, normalInput.normalWS );
  325. #ifdef ASE_FOG
  326. half fogFactor = ComputeFogFactor( vertexInput.positionCS.z );
  327. #else
  328. half fogFactor = 0;
  329. #endif
  330. output.fogFactorAndVertexLight = half4(fogFactor, vertexLight);
  331. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  332. output.shadowCoord = GetShadowCoord( vertexInput );
  333. #endif
  334. output.positionCS = vertexInput.positionCS;
  335. output.clipPosV = vertexInput.positionCS;
  336. return output;
  337. }
  338. #if defined(ASE_TESSELLATION)
  339. struct VertexControl
  340. {
  341. float4 vertex : INTERNALTESSPOS;
  342. float3 normalOS : NORMAL;
  343. float4 tangentOS : TANGENT;
  344. float4 texcoord : TEXCOORD0;
  345. float4 texcoord1 : TEXCOORD1;
  346. float4 texcoord2 : TEXCOORD2;
  347. UNITY_VERTEX_INPUT_INSTANCE_ID
  348. };
  349. struct TessellationFactors
  350. {
  351. float edge[3] : SV_TessFactor;
  352. float inside : SV_InsideTessFactor;
  353. };
  354. VertexControl vert ( Attributes input )
  355. {
  356. VertexControl output;
  357. UNITY_SETUP_INSTANCE_ID(input);
  358. UNITY_TRANSFER_INSTANCE_ID(input, output);
  359. output.vertex = input.positionOS;
  360. output.normalOS = input.normalOS;
  361. output.tangentOS = input.tangentOS;
  362. output.texcoord = input.texcoord;
  363. output.texcoord1 = input.texcoord1;
  364. output.texcoord2 = input.texcoord2;
  365. return output;
  366. }
  367. TessellationFactors TessellationFunction (InputPatch<VertexControl,3> input)
  368. {
  369. TessellationFactors output;
  370. float4 tf = 1;
  371. float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
  372. float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
  373. #if defined(ASE_FIXED_TESSELLATION)
  374. tf = FixedTess( tessValue );
  375. #elif defined(ASE_DISTANCE_TESSELLATION)
  376. tf = DistanceBasedTess(input[0].vertex, input[1].vertex, input[2].vertex, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
  377. #elif defined(ASE_LENGTH_TESSELLATION)
  378. tf = EdgeLengthBasedTess(input[0].vertex, input[1].vertex, input[2].vertex, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
  379. #elif defined(ASE_LENGTH_CULL_TESSELLATION)
  380. tf = EdgeLengthBasedTessCull(input[0].vertex, input[1].vertex, input[2].vertex, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
  381. #endif
  382. output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w;
  383. return output;
  384. }
  385. [domain("tri")]
  386. [partitioning("fractional_odd")]
  387. [outputtopology("triangle_cw")]
  388. [patchconstantfunc("TessellationFunction")]
  389. [outputcontrolpoints(3)]
  390. VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
  391. {
  392. return patch[id];
  393. }
  394. [domain("tri")]
  395. PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
  396. {
  397. Attributes output = (Attributes) 0;
  398. output.positionOS = patch[0].vertex * bary.x + patch[1].vertex * bary.y + patch[2].vertex * bary.z;
  399. output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
  400. output.tangentOS = patch[0].tangentOS * bary.x + patch[1].tangentOS * bary.y + patch[2].tangentOS * bary.z;
  401. output.texcoord = patch[0].texcoord * bary.x + patch[1].texcoord * bary.y + patch[2].texcoord * bary.z;
  402. output.texcoord1 = patch[0].texcoord1 * bary.x + patch[1].texcoord1 * bary.y + patch[2].texcoord1 * bary.z;
  403. output.texcoord2 = patch[0].texcoord2 * bary.x + patch[1].texcoord2 * bary.y + patch[2].texcoord2 * bary.z;
  404. #if defined(ASE_PHONG_TESSELLATION)
  405. float3 pp[3];
  406. for (int i = 0; i < 3; ++i)
  407. pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].vertex.xyz, patch[i].normalOS));
  408. float phongStrength = _TessPhongStrength;
  409. output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz;
  410. #endif
  411. UNITY_TRANSFER_INSTANCE_ID(patch[0], output);
  412. return VertexFunction(output);
  413. }
  414. #else
  415. PackedVaryings vert ( Attributes input )
  416. {
  417. return VertexFunction( input );
  418. }
  419. #endif
  420. half4 frag ( PackedVaryings input
  421. #ifdef ASE_DEPTH_WRITE_ON
  422. ,out float outputDepth : ASE_SV_DEPTH
  423. #endif
  424. #ifdef _WRITE_RENDERING_LAYERS
  425. , out float4 outRenderingLayers : SV_Target1
  426. #endif
  427. ) : SV_Target
  428. {
  429. UNITY_SETUP_INSTANCE_ID(input);
  430. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
  431. #if defined(LOD_FADE_CROSSFADE)
  432. LODFadeCrossFade( input.positionCS );
  433. #endif
  434. #if defined(ENABLE_TERRAIN_PERPIXEL_NORMAL)
  435. float2 sampleCoords = (input.lightmapUVOrVertexSH.zw / _TerrainHeightmapRecipSize.zw + 0.5f) * _TerrainHeightmapRecipSize.xy;
  436. float3 WorldNormal = TransformObjectToWorldNormal(normalize(SAMPLE_TEXTURE2D(_TerrainNormalmapTexture, sampler_TerrainNormalmapTexture, sampleCoords).rgb * 2 - 1));
  437. float3 WorldTangent = -cross(GetObjectToWorldMatrix()._13_23_33, WorldNormal);
  438. float3 WorldBiTangent = cross(WorldNormal, -WorldTangent);
  439. #else
  440. float3 WorldNormal = normalize( input.tSpace0.xyz );
  441. float3 WorldTangent = input.tSpace1.xyz;
  442. float3 WorldBiTangent = input.tSpace2.xyz;
  443. #endif
  444. float3 WorldPosition = float3(input.tSpace0.w,input.tSpace1.w,input.tSpace2.w);
  445. float3 WorldViewDirection = _WorldSpaceCameraPos.xyz - WorldPosition;
  446. float4 ShadowCoords = float4( 0, 0, 0, 0 );
  447. float4 ClipPos = input.clipPosV;
  448. float4 ScreenPos = ComputeScreenPos( input.clipPosV );
  449. float2 NormalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS);
  450. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  451. ShadowCoords = input.shadowCoord;
  452. #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
  453. ShadowCoords = TransformWorldToShadowCoord( WorldPosition );
  454. #endif
  455. WorldViewDirection = SafeNormalize( WorldViewDirection );
  456. float2 uv_AlbedoMap = input.ase_texcoord9.xy * _AlbedoMap_ST.xy + _AlbedoMap_ST.zw;
  457. float2 uv_NormalMap = input.ase_texcoord9.xy * _NormalMap_ST.xy + _NormalMap_ST.zw;
  458. float2 uv_MaskMap = input.ase_texcoord9.xy * _MaskMap_ST.xy + _MaskMap_ST.zw;
  459. float3 BaseColor = ( _AlbedoColor * tex2D( _AlbedoMap, uv_AlbedoMap ) ).rgb;
  460. float3 Normal = UnpackNormalScale( tex2D( _NormalMap, uv_NormalMap ), 1.0f );
  461. float3 Emission = 0;
  462. float3 Specular = 0.5;
  463. float Metallic = 0;
  464. float Smoothness = tex2D( _MaskMap, uv_MaskMap ).a;
  465. float Occlusion = 1;
  466. float Alpha = 1;
  467. float AlphaClipThreshold = 0.5;
  468. float AlphaClipThresholdShadow = 0.5;
  469. float3 BakedGI = 0;
  470. float3 RefractionColor = 1;
  471. float RefractionIndex = 1;
  472. float3 Transmission = 1;
  473. float3 Translucency = 1;
  474. #ifdef ASE_DEPTH_WRITE_ON
  475. float DepthValue = input.positionCS.z;
  476. #endif
  477. #ifdef _CLEARCOAT
  478. float CoatMask = 0;
  479. float CoatSmoothness = 0;
  480. #endif
  481. #ifdef _ALPHATEST_ON
  482. clip(Alpha - AlphaClipThreshold);
  483. #endif
  484. InputData inputData = (InputData)0;
  485. inputData.positionWS = WorldPosition;
  486. inputData.positionCS = input.positionCS;
  487. inputData.viewDirectionWS = WorldViewDirection;
  488. #ifdef _NORMALMAP
  489. #if _NORMAL_DROPOFF_TS
  490. inputData.normalWS = TransformTangentToWorld(Normal, half3x3(WorldTangent, WorldBiTangent, WorldNormal));
  491. #elif _NORMAL_DROPOFF_OS
  492. inputData.normalWS = TransformObjectToWorldNormal(Normal);
  493. #elif _NORMAL_DROPOFF_WS
  494. inputData.normalWS = Normal;
  495. #endif
  496. inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS);
  497. #else
  498. inputData.normalWS = WorldNormal;
  499. #endif
  500. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  501. inputData.shadowCoord = ShadowCoords;
  502. #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
  503. inputData.shadowCoord = TransformWorldToShadowCoord(inputData.positionWS);
  504. #else
  505. inputData.shadowCoord = float4(0, 0, 0, 0);
  506. #endif
  507. #ifdef ASE_FOG
  508. inputData.fogCoord = input.fogFactorAndVertexLight.x;
  509. #endif
  510. inputData.vertexLighting = input.fogFactorAndVertexLight.yzw;
  511. #if defined(ENABLE_TERRAIN_PERPIXEL_NORMAL)
  512. float3 SH = SampleSH(inputData.normalWS.xyz);
  513. #else
  514. float3 SH = input.lightmapUVOrVertexSH.xyz;
  515. #endif
  516. #if defined(DYNAMICLIGHTMAP_ON)
  517. inputData.bakedGI = SAMPLE_GI(input.lightmapUVOrVertexSH.xy, input.dynamicLightmapUV.xy, SH, inputData.normalWS);
  518. inputData.shadowMask = SAMPLE_SHADOWMASK(input.lightmapUVOrVertexSH.xy);
  519. #elif !defined(LIGHTMAP_ON) && (defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2))
  520. inputData.bakedGI = SAMPLE_GI( SH, GetAbsolutePositionWS(inputData.positionWS),
  521. inputData.normalWS,
  522. inputData.viewDirectionWS,
  523. input.positionCS.xy,
  524. input.probeOcclusion,
  525. inputData.shadowMask );
  526. #else
  527. inputData.bakedGI = SAMPLE_GI(input.lightmapUVOrVertexSH.xy, SH, inputData.normalWS);
  528. inputData.shadowMask = SAMPLE_SHADOWMASK(input.lightmapUVOrVertexSH.xy);
  529. #endif
  530. #ifdef ASE_BAKEDGI
  531. inputData.bakedGI = BakedGI;
  532. #endif
  533. inputData.normalizedScreenSpaceUV = NormalizedScreenSpaceUV;
  534. #if defined(DEBUG_DISPLAY)
  535. #if defined(DYNAMICLIGHTMAP_ON)
  536. inputData.dynamicLightmapUV = input.dynamicLightmapUV.xy;
  537. #endif
  538. #if defined(LIGHTMAP_ON)
  539. inputData.staticLightmapUV = input.lightmapUVOrVertexSH.xy;
  540. #else
  541. inputData.vertexSH = SH;
  542. #endif
  543. #if defined(USE_APV_PROBE_OCCLUSION)
  544. inputData.probeOcclusion = input.probeOcclusion;
  545. #endif
  546. #endif
  547. SurfaceData surfaceData;
  548. surfaceData.albedo = BaseColor;
  549. surfaceData.metallic = saturate(Metallic);
  550. surfaceData.specular = Specular;
  551. surfaceData.smoothness = saturate(Smoothness),
  552. surfaceData.occlusion = Occlusion,
  553. surfaceData.emission = Emission,
  554. surfaceData.alpha = saturate(Alpha);
  555. surfaceData.normalTS = Normal;
  556. surfaceData.clearCoatMask = 0;
  557. surfaceData.clearCoatSmoothness = 1;
  558. #ifdef _CLEARCOAT
  559. surfaceData.clearCoatMask = saturate(CoatMask);
  560. surfaceData.clearCoatSmoothness = saturate(CoatSmoothness);
  561. #endif
  562. #ifdef _DBUFFER
  563. ApplyDecalToSurfaceData(input.positionCS, surfaceData, inputData);
  564. #endif
  565. #ifdef _ASE_LIGHTING_SIMPLE
  566. half4 color = UniversalFragmentBlinnPhong( inputData, surfaceData);
  567. #else
  568. half4 color = UniversalFragmentPBR( inputData, surfaceData);
  569. #endif
  570. #ifdef ASE_TRANSMISSION
  571. {
  572. float shadow = _TransmissionShadow;
  573. #define SUM_LIGHT_TRANSMISSION(Light)\
  574. float3 atten = Light.color * Light.distanceAttenuation;\
  575. atten = lerp( atten, atten * Light.shadowAttenuation, shadow );\
  576. half3 transmission = max( 0, -dot( inputData.normalWS, Light.direction ) ) * atten * Transmission;\
  577. color.rgb += BaseColor * transmission;
  578. SUM_LIGHT_TRANSMISSION( GetMainLight( inputData.shadowCoord ) );
  579. #if defined(_ADDITIONAL_LIGHTS)
  580. uint meshRenderingLayers = GetMeshRenderingLayer();
  581. uint pixelLightCount = GetAdditionalLightsCount();
  582. #if USE_FORWARD_PLUS
  583. [loop] for (uint lightIndex = 0; lightIndex < min(URP_FP_DIRECTIONAL_LIGHTS_COUNT, MAX_VISIBLE_LIGHTS); lightIndex++)
  584. {
  585. FORWARD_PLUS_SUBTRACTIVE_LIGHT_CHECK
  586. Light light = GetAdditionalLight(lightIndex, inputData.positionWS, inputData.shadowMask);
  587. #ifdef _LIGHT_LAYERS
  588. if (IsMatchingLightLayer(light.layerMask, meshRenderingLayers))
  589. #endif
  590. {
  591. SUM_LIGHT_TRANSMISSION( light );
  592. }
  593. }
  594. #endif
  595. LIGHT_LOOP_BEGIN( pixelLightCount )
  596. Light light = GetAdditionalLight(lightIndex, inputData.positionWS, inputData.shadowMask);
  597. #ifdef _LIGHT_LAYERS
  598. if (IsMatchingLightLayer(light.layerMask, meshRenderingLayers))
  599. #endif
  600. {
  601. SUM_LIGHT_TRANSMISSION( light );
  602. }
  603. LIGHT_LOOP_END
  604. #endif
  605. }
  606. #endif
  607. #ifdef ASE_TRANSLUCENCY
  608. {
  609. float shadow = _TransShadow;
  610. float normal = _TransNormal;
  611. float scattering = _TransScattering;
  612. float direct = _TransDirect;
  613. float ambient = _TransAmbient;
  614. float strength = _TransStrength;
  615. #define SUM_LIGHT_TRANSLUCENCY(Light)\
  616. float3 atten = Light.color * Light.distanceAttenuation;\
  617. atten = lerp( atten, atten * Light.shadowAttenuation, shadow );\
  618. half3 lightDir = Light.direction + inputData.normalWS * normal;\
  619. half VdotL = pow( saturate( dot( inputData.viewDirectionWS, -lightDir ) ), scattering );\
  620. half3 translucency = atten * ( VdotL * direct + inputData.bakedGI * ambient ) * Translucency;\
  621. color.rgb += BaseColor * translucency * strength;
  622. SUM_LIGHT_TRANSLUCENCY( GetMainLight( inputData.shadowCoord ) );
  623. #if defined(_ADDITIONAL_LIGHTS)
  624. uint meshRenderingLayers = GetMeshRenderingLayer();
  625. uint pixelLightCount = GetAdditionalLightsCount();
  626. #if USE_FORWARD_PLUS
  627. [loop] for (uint lightIndex = 0; lightIndex < min(URP_FP_DIRECTIONAL_LIGHTS_COUNT, MAX_VISIBLE_LIGHTS); lightIndex++)
  628. {
  629. FORWARD_PLUS_SUBTRACTIVE_LIGHT_CHECK
  630. Light light = GetAdditionalLight(lightIndex, inputData.positionWS, inputData.shadowMask);
  631. #ifdef _LIGHT_LAYERS
  632. if (IsMatchingLightLayer(light.layerMask, meshRenderingLayers))
  633. #endif
  634. {
  635. SUM_LIGHT_TRANSLUCENCY( light );
  636. }
  637. }
  638. #endif
  639. LIGHT_LOOP_BEGIN( pixelLightCount )
  640. Light light = GetAdditionalLight(lightIndex, inputData.positionWS, inputData.shadowMask);
  641. #ifdef _LIGHT_LAYERS
  642. if (IsMatchingLightLayer(light.layerMask, meshRenderingLayers))
  643. #endif
  644. {
  645. SUM_LIGHT_TRANSLUCENCY( light );
  646. }
  647. LIGHT_LOOP_END
  648. #endif
  649. }
  650. #endif
  651. #ifdef ASE_REFRACTION
  652. float4 projScreenPos = ScreenPos / ScreenPos.w;
  653. float3 refractionOffset = ( RefractionIndex - 1.0 ) * mul( UNITY_MATRIX_V, float4( WorldNormal,0 ) ).xyz * ( 1.0 - dot( WorldNormal, WorldViewDirection ) );
  654. projScreenPos.xy += refractionOffset.xy;
  655. float3 refraction = SHADERGRAPH_SAMPLE_SCENE_COLOR( projScreenPos.xy ) * RefractionColor;
  656. color.rgb = lerp( refraction, color.rgb, color.a );
  657. color.a = 1;
  658. #endif
  659. #ifdef ASE_FINAL_COLOR_ALPHA_MULTIPLY
  660. color.rgb *= color.a;
  661. #endif
  662. #ifdef ASE_FOG
  663. #ifdef TERRAIN_SPLAT_ADDPASS
  664. color.rgb = MixFogColor(color.rgb, half3( 0, 0, 0 ), input.fogFactorAndVertexLight.x );
  665. #else
  666. color.rgb = MixFog(color.rgb, input.fogFactorAndVertexLight.x);
  667. #endif
  668. #endif
  669. #ifdef ASE_DEPTH_WRITE_ON
  670. outputDepth = DepthValue;
  671. #endif
  672. #ifdef _WRITE_RENDERING_LAYERS
  673. uint renderingLayers = GetMeshRenderingLayer();
  674. outRenderingLayers = float4( EncodeMeshRenderingLayer( renderingLayers ), 0, 0, 0 );
  675. #endif
  676. return color;
  677. }
  678. ENDHLSL
  679. }
  680. Pass
  681. {
  682. Name "ShadowCaster"
  683. Tags { "LightMode"="ShadowCaster" }
  684. ZWrite On
  685. ZTest LEqual
  686. AlphaToMask Off
  687. ColorMask 0
  688. HLSLPROGRAM
  689. #pragma multi_compile_local_fragment _ALPHATEST_ON
  690. #define _NORMAL_DROPOFF_TS 1
  691. #pragma multi_compile_instancing
  692. #pragma multi_compile _ LOD_FADE_CROSSFADE
  693. #define ASE_FOG 1
  694. #define _NORMALMAP 1
  695. #define ASE_VERSION 19701
  696. #define ASE_SRP_VERSION 170003
  697. #pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW
  698. #pragma vertex vert
  699. #pragma fragment frag
  700. #if defined(_SPECULAR_SETUP) && defined(_ASE_LIGHTING_SIMPLE)
  701. #define _SPECULAR_COLOR 1
  702. #endif
  703. #define SHADERPASS SHADERPASS_SHADOWCASTER
  704. #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
  705. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  706. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
  707. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  708. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  709. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl"
  710. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
  711. #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
  712. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl"
  713. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl"
  714. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  715. #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
  716. #if defined(LOD_FADE_CROSSFADE)
  717. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl"
  718. #endif
  719. #if defined(ASE_EARLY_Z_DEPTH_OPTIMIZE) && (SHADER_TARGET >= 45)
  720. #define ASE_SV_DEPTH SV_DepthLessEqual
  721. #define ASE_SV_POSITION_QUALIFIERS linear noperspective centroid
  722. #else
  723. #define ASE_SV_DEPTH SV_Depth
  724. #define ASE_SV_POSITION_QUALIFIERS
  725. #endif
  726. struct Attributes
  727. {
  728. float4 positionOS : POSITION;
  729. float3 normalOS : NORMAL;
  730. UNITY_VERTEX_INPUT_INSTANCE_ID
  731. };
  732. struct PackedVaryings
  733. {
  734. ASE_SV_POSITION_QUALIFIERS float4 positionCS : SV_POSITION;
  735. float4 clipPosV : TEXCOORD0;
  736. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  737. float3 positionWS : TEXCOORD1;
  738. #endif
  739. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  740. float4 shadowCoord : TEXCOORD2;
  741. #endif
  742. UNITY_VERTEX_INPUT_INSTANCE_ID
  743. UNITY_VERTEX_OUTPUT_STEREO
  744. };
  745. CBUFFER_START(UnityPerMaterial)
  746. float4 _AlbedoColor;
  747. float4 _AlbedoMap_ST;
  748. float4 _NormalMap_ST;
  749. float4 _MaskMap_ST;
  750. #ifdef ASE_TRANSMISSION
  751. float _TransmissionShadow;
  752. #endif
  753. #ifdef ASE_TRANSLUCENCY
  754. float _TransStrength;
  755. float _TransNormal;
  756. float _TransScattering;
  757. float _TransDirect;
  758. float _TransAmbient;
  759. float _TransShadow;
  760. #endif
  761. #ifdef ASE_TESSELLATION
  762. float _TessPhongStrength;
  763. float _TessValue;
  764. float _TessMin;
  765. float _TessMax;
  766. float _TessEdgeLength;
  767. float _TessMaxDisp;
  768. #endif
  769. CBUFFER_END
  770. #ifdef SCENEPICKINGPASS
  771. float4 _SelectionID;
  772. #endif
  773. #ifdef SCENESELECTIONPASS
  774. int _ObjectId;
  775. int _PassValue;
  776. #endif
  777. float3 _LightDirection;
  778. float3 _LightPosition;
  779. PackedVaryings VertexFunction( Attributes input )
  780. {
  781. PackedVaryings output;
  782. UNITY_SETUP_INSTANCE_ID(input);
  783. UNITY_TRANSFER_INSTANCE_ID(input, output);
  784. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( output );
  785. #ifdef ASE_ABSOLUTE_VERTEX_POS
  786. float3 defaultVertexValue = input.positionOS.xyz;
  787. #else
  788. float3 defaultVertexValue = float3(0, 0, 0);
  789. #endif
  790. float3 vertexValue = defaultVertexValue;
  791. #ifdef ASE_ABSOLUTE_VERTEX_POS
  792. input.positionOS.xyz = vertexValue;
  793. #else
  794. input.positionOS.xyz += vertexValue;
  795. #endif
  796. input.normalOS = input.normalOS;
  797. float3 positionWS = TransformObjectToWorld( input.positionOS.xyz );
  798. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  799. output.positionWS = positionWS;
  800. #endif
  801. float3 normalWS = TransformObjectToWorldDir(input.normalOS);
  802. #if _CASTING_PUNCTUAL_LIGHT_SHADOW
  803. float3 lightDirectionWS = normalize(_LightPosition - positionWS);
  804. #else
  805. float3 lightDirectionWS = _LightDirection;
  806. #endif
  807. float4 positionCS = TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS, lightDirectionWS));
  808. //code for UNITY_REVERSED_Z is moved into Shadows.hlsl from 6000.0.22 and or higher
  809. positionCS = ApplyShadowClamping(positionCS);
  810. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  811. VertexPositionInputs vertexInput = (VertexPositionInputs)0;
  812. vertexInput.positionWS = positionWS;
  813. vertexInput.positionCS = positionCS;
  814. output.shadowCoord = GetShadowCoord( vertexInput );
  815. #endif
  816. output.positionCS = positionCS;
  817. output.clipPosV = positionCS;
  818. return output;
  819. }
  820. #if defined(ASE_TESSELLATION)
  821. struct VertexControl
  822. {
  823. float4 vertex : INTERNALTESSPOS;
  824. float3 normalOS : NORMAL;
  825. UNITY_VERTEX_INPUT_INSTANCE_ID
  826. };
  827. struct TessellationFactors
  828. {
  829. float edge[3] : SV_TessFactor;
  830. float inside : SV_InsideTessFactor;
  831. };
  832. VertexControl vert ( Attributes input )
  833. {
  834. VertexControl output;
  835. UNITY_SETUP_INSTANCE_ID(input);
  836. UNITY_TRANSFER_INSTANCE_ID(input, output);
  837. output.vertex = input.positionOS;
  838. output.normalOS = input.normalOS;
  839. return output;
  840. }
  841. TessellationFactors TessellationFunction (InputPatch<VertexControl,3> input)
  842. {
  843. TessellationFactors output;
  844. float4 tf = 1;
  845. float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
  846. float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
  847. #if defined(ASE_FIXED_TESSELLATION)
  848. tf = FixedTess( tessValue );
  849. #elif defined(ASE_DISTANCE_TESSELLATION)
  850. tf = DistanceBasedTess(input[0].vertex, input[1].vertex, input[2].vertex, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
  851. #elif defined(ASE_LENGTH_TESSELLATION)
  852. tf = EdgeLengthBasedTess(input[0].vertex, input[1].vertex, input[2].vertex, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
  853. #elif defined(ASE_LENGTH_CULL_TESSELLATION)
  854. tf = EdgeLengthBasedTessCull(input[0].vertex, input[1].vertex, input[2].vertex, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
  855. #endif
  856. output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w;
  857. return output;
  858. }
  859. [domain("tri")]
  860. [partitioning("fractional_odd")]
  861. [outputtopology("triangle_cw")]
  862. [patchconstantfunc("TessellationFunction")]
  863. [outputcontrolpoints(3)]
  864. VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
  865. {
  866. return patch[id];
  867. }
  868. [domain("tri")]
  869. PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
  870. {
  871. Attributes output = (Attributes) 0;
  872. output.positionOS = patch[0].vertex * bary.x + patch[1].vertex * bary.y + patch[2].vertex * bary.z;
  873. output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
  874. #if defined(ASE_PHONG_TESSELLATION)
  875. float3 pp[3];
  876. for (int i = 0; i < 3; ++i)
  877. pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].vertex.xyz, patch[i].normalOS));
  878. float phongStrength = _TessPhongStrength;
  879. output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz;
  880. #endif
  881. UNITY_TRANSFER_INSTANCE_ID(patch[0], output);
  882. return VertexFunction(output);
  883. }
  884. #else
  885. PackedVaryings vert ( Attributes input )
  886. {
  887. return VertexFunction( input );
  888. }
  889. #endif
  890. half4 frag( PackedVaryings input
  891. #ifdef ASE_DEPTH_WRITE_ON
  892. ,out float outputDepth : ASE_SV_DEPTH
  893. #endif
  894. ) : SV_TARGET
  895. {
  896. UNITY_SETUP_INSTANCE_ID( input );
  897. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( input );
  898. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  899. float3 WorldPosition = input.positionWS;
  900. #endif
  901. float4 ShadowCoords = float4( 0, 0, 0, 0 );
  902. float4 ClipPos = input.clipPosV;
  903. float4 ScreenPos = ComputeScreenPos( input.clipPosV );
  904. #if defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  905. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  906. ShadowCoords = input.shadowCoord;
  907. #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
  908. ShadowCoords = TransformWorldToShadowCoord( WorldPosition );
  909. #endif
  910. #endif
  911. float Alpha = 1;
  912. float AlphaClipThreshold = 0.5;
  913. float AlphaClipThresholdShadow = 0.5;
  914. #ifdef ASE_DEPTH_WRITE_ON
  915. float DepthValue = input.positionCS.z;
  916. #endif
  917. #ifdef _ALPHATEST_ON
  918. #ifdef _ALPHATEST_SHADOW_ON
  919. clip(Alpha - AlphaClipThresholdShadow);
  920. #else
  921. clip(Alpha - AlphaClipThreshold);
  922. #endif
  923. #endif
  924. #if defined(LOD_FADE_CROSSFADE)
  925. LODFadeCrossFade( input.positionCS );
  926. #endif
  927. #ifdef ASE_DEPTH_WRITE_ON
  928. outputDepth = DepthValue;
  929. #endif
  930. return 0;
  931. }
  932. ENDHLSL
  933. }
  934. Pass
  935. {
  936. Name "DepthOnly"
  937. Tags { "LightMode"="DepthOnly" }
  938. ZWrite On
  939. ColorMask 0
  940. AlphaToMask Off
  941. HLSLPROGRAM
  942. #pragma multi_compile_local_fragment _ALPHATEST_ON
  943. #define _NORMAL_DROPOFF_TS 1
  944. #pragma multi_compile_instancing
  945. #pragma multi_compile _ LOD_FADE_CROSSFADE
  946. #define ASE_FOG 1
  947. #define _NORMALMAP 1
  948. #define ASE_VERSION 19701
  949. #define ASE_SRP_VERSION 170003
  950. #pragma vertex vert
  951. #pragma fragment frag
  952. #if defined(_SPECULAR_SETUP) && defined(_ASE_LIGHTING_SIMPLE)
  953. #define _SPECULAR_COLOR 1
  954. #endif
  955. #define SHADERPASS SHADERPASS_DEPTHONLY
  956. #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
  957. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  958. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
  959. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  960. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  961. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl"
  962. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
  963. #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
  964. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl"
  965. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  966. #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
  967. #if defined(LOD_FADE_CROSSFADE)
  968. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl"
  969. #endif
  970. #if defined(ASE_EARLY_Z_DEPTH_OPTIMIZE) && (SHADER_TARGET >= 45)
  971. #define ASE_SV_DEPTH SV_DepthLessEqual
  972. #define ASE_SV_POSITION_QUALIFIERS linear noperspective centroid
  973. #else
  974. #define ASE_SV_DEPTH SV_Depth
  975. #define ASE_SV_POSITION_QUALIFIERS
  976. #endif
  977. struct Attributes
  978. {
  979. float4 positionOS : POSITION;
  980. float3 normalOS : NORMAL;
  981. UNITY_VERTEX_INPUT_INSTANCE_ID
  982. };
  983. struct PackedVaryings
  984. {
  985. ASE_SV_POSITION_QUALIFIERS float4 positionCS : SV_POSITION;
  986. float4 clipPosV : TEXCOORD0;
  987. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  988. float3 positionWS : TEXCOORD1;
  989. #endif
  990. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  991. float4 shadowCoord : TEXCOORD2;
  992. #endif
  993. UNITY_VERTEX_INPUT_INSTANCE_ID
  994. UNITY_VERTEX_OUTPUT_STEREO
  995. };
  996. CBUFFER_START(UnityPerMaterial)
  997. float4 _AlbedoColor;
  998. float4 _AlbedoMap_ST;
  999. float4 _NormalMap_ST;
  1000. float4 _MaskMap_ST;
  1001. #ifdef ASE_TRANSMISSION
  1002. float _TransmissionShadow;
  1003. #endif
  1004. #ifdef ASE_TRANSLUCENCY
  1005. float _TransStrength;
  1006. float _TransNormal;
  1007. float _TransScattering;
  1008. float _TransDirect;
  1009. float _TransAmbient;
  1010. float _TransShadow;
  1011. #endif
  1012. #ifdef ASE_TESSELLATION
  1013. float _TessPhongStrength;
  1014. float _TessValue;
  1015. float _TessMin;
  1016. float _TessMax;
  1017. float _TessEdgeLength;
  1018. float _TessMaxDisp;
  1019. #endif
  1020. CBUFFER_END
  1021. #ifdef SCENEPICKINGPASS
  1022. float4 _SelectionID;
  1023. #endif
  1024. #ifdef SCENESELECTIONPASS
  1025. int _ObjectId;
  1026. int _PassValue;
  1027. #endif
  1028. PackedVaryings VertexFunction( Attributes input )
  1029. {
  1030. PackedVaryings output = (PackedVaryings)0;
  1031. UNITY_SETUP_INSTANCE_ID(input);
  1032. UNITY_TRANSFER_INSTANCE_ID(input, output);
  1033. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
  1034. #ifdef ASE_ABSOLUTE_VERTEX_POS
  1035. float3 defaultVertexValue = input.positionOS.xyz;
  1036. #else
  1037. float3 defaultVertexValue = float3(0, 0, 0);
  1038. #endif
  1039. float3 vertexValue = defaultVertexValue;
  1040. #ifdef ASE_ABSOLUTE_VERTEX_POS
  1041. input.positionOS.xyz = vertexValue;
  1042. #else
  1043. input.positionOS.xyz += vertexValue;
  1044. #endif
  1045. input.normalOS = input.normalOS;
  1046. VertexPositionInputs vertexInput = GetVertexPositionInputs( input.positionOS.xyz );
  1047. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1048. output.positionWS = vertexInput.positionWS;
  1049. #endif
  1050. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1051. output.shadowCoord = GetShadowCoord( vertexInput );
  1052. #endif
  1053. output.positionCS = vertexInput.positionCS;
  1054. output.clipPosV = vertexInput.positionCS;
  1055. return output;
  1056. }
  1057. #if defined(ASE_TESSELLATION)
  1058. struct VertexControl
  1059. {
  1060. float4 vertex : INTERNALTESSPOS;
  1061. float3 normalOS : NORMAL;
  1062. UNITY_VERTEX_INPUT_INSTANCE_ID
  1063. };
  1064. struct TessellationFactors
  1065. {
  1066. float edge[3] : SV_TessFactor;
  1067. float inside : SV_InsideTessFactor;
  1068. };
  1069. VertexControl vert ( Attributes input )
  1070. {
  1071. VertexControl output;
  1072. UNITY_SETUP_INSTANCE_ID(input);
  1073. UNITY_TRANSFER_INSTANCE_ID(input, output);
  1074. output.vertex = input.positionOS;
  1075. output.normalOS = input.normalOS;
  1076. return output;
  1077. }
  1078. TessellationFactors TessellationFunction (InputPatch<VertexControl,3> input)
  1079. {
  1080. TessellationFactors output;
  1081. float4 tf = 1;
  1082. float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
  1083. float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
  1084. #if defined(ASE_FIXED_TESSELLATION)
  1085. tf = FixedTess( tessValue );
  1086. #elif defined(ASE_DISTANCE_TESSELLATION)
  1087. tf = DistanceBasedTess(input[0].vertex, input[1].vertex, input[2].vertex, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
  1088. #elif defined(ASE_LENGTH_TESSELLATION)
  1089. tf = EdgeLengthBasedTess(input[0].vertex, input[1].vertex, input[2].vertex, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
  1090. #elif defined(ASE_LENGTH_CULL_TESSELLATION)
  1091. tf = EdgeLengthBasedTessCull(input[0].vertex, input[1].vertex, input[2].vertex, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
  1092. #endif
  1093. output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w;
  1094. return output;
  1095. }
  1096. [domain("tri")]
  1097. [partitioning("fractional_odd")]
  1098. [outputtopology("triangle_cw")]
  1099. [patchconstantfunc("TessellationFunction")]
  1100. [outputcontrolpoints(3)]
  1101. VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
  1102. {
  1103. return patch[id];
  1104. }
  1105. [domain("tri")]
  1106. PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
  1107. {
  1108. Attributes output = (Attributes) 0;
  1109. output.positionOS = patch[0].vertex * bary.x + patch[1].vertex * bary.y + patch[2].vertex * bary.z;
  1110. output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
  1111. #if defined(ASE_PHONG_TESSELLATION)
  1112. float3 pp[3];
  1113. for (int i = 0; i < 3; ++i)
  1114. pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].vertex.xyz, patch[i].normalOS));
  1115. float phongStrength = _TessPhongStrength;
  1116. output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz;
  1117. #endif
  1118. UNITY_TRANSFER_INSTANCE_ID(patch[0], output);
  1119. return VertexFunction(output);
  1120. }
  1121. #else
  1122. PackedVaryings vert ( Attributes input )
  1123. {
  1124. return VertexFunction( input );
  1125. }
  1126. #endif
  1127. half4 frag( PackedVaryings input
  1128. #ifdef ASE_DEPTH_WRITE_ON
  1129. ,out float outputDepth : ASE_SV_DEPTH
  1130. #endif
  1131. ) : SV_TARGET
  1132. {
  1133. UNITY_SETUP_INSTANCE_ID(input);
  1134. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( input );
  1135. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1136. float3 WorldPosition = input.positionWS;
  1137. #endif
  1138. float4 ShadowCoords = float4( 0, 0, 0, 0 );
  1139. float4 ClipPos = input.clipPosV;
  1140. float4 ScreenPos = ComputeScreenPos( input.clipPosV );
  1141. #if defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1142. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  1143. ShadowCoords = input.shadowCoord;
  1144. #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
  1145. ShadowCoords = TransformWorldToShadowCoord( WorldPosition );
  1146. #endif
  1147. #endif
  1148. float Alpha = 1;
  1149. float AlphaClipThreshold = 0.5;
  1150. #ifdef ASE_DEPTH_WRITE_ON
  1151. float DepthValue = input.positionCS.z;
  1152. #endif
  1153. #ifdef _ALPHATEST_ON
  1154. clip(Alpha - AlphaClipThreshold);
  1155. #endif
  1156. #if defined(LOD_FADE_CROSSFADE)
  1157. LODFadeCrossFade( input.positionCS );
  1158. #endif
  1159. #ifdef ASE_DEPTH_WRITE_ON
  1160. outputDepth = DepthValue;
  1161. #endif
  1162. return 0;
  1163. }
  1164. ENDHLSL
  1165. }
  1166. Pass
  1167. {
  1168. Name "Meta"
  1169. Tags { "LightMode"="Meta" }
  1170. Cull Off
  1171. HLSLPROGRAM
  1172. #pragma multi_compile_local_fragment _ALPHATEST_ON
  1173. #define _NORMAL_DROPOFF_TS 1
  1174. #define ASE_FOG 1
  1175. #define _NORMALMAP 1
  1176. #define ASE_VERSION 19701
  1177. #define ASE_SRP_VERSION 170003
  1178. #pragma shader_feature EDITOR_VISUALIZATION
  1179. #pragma vertex vert
  1180. #pragma fragment frag
  1181. #if defined(_SPECULAR_SETUP) && defined(_ASE_LIGHTING_SIMPLE)
  1182. #define _SPECULAR_COLOR 1
  1183. #endif
  1184. #define SHADERPASS SHADERPASS_META
  1185. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  1186. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
  1187. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  1188. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  1189. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl"
  1190. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
  1191. #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
  1192. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl"
  1193. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl"
  1194. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  1195. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/MetaInput.hlsl"
  1196. #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
  1197. struct Attributes
  1198. {
  1199. float4 positionOS : POSITION;
  1200. float3 normalOS : NORMAL;
  1201. float4 texcoord0 : TEXCOORD0;
  1202. float4 texcoord1 : TEXCOORD1;
  1203. float4 texcoord2 : TEXCOORD2;
  1204. UNITY_VERTEX_INPUT_INSTANCE_ID
  1205. };
  1206. struct PackedVaryings
  1207. {
  1208. float4 positionCS : SV_POSITION;
  1209. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1210. float3 positionWS : TEXCOORD0;
  1211. #endif
  1212. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1213. float4 shadowCoord : TEXCOORD1;
  1214. #endif
  1215. #ifdef EDITOR_VISUALIZATION
  1216. float4 VizUV : TEXCOORD2;
  1217. float4 LightCoord : TEXCOORD3;
  1218. #endif
  1219. float4 ase_texcoord4 : TEXCOORD4;
  1220. UNITY_VERTEX_INPUT_INSTANCE_ID
  1221. UNITY_VERTEX_OUTPUT_STEREO
  1222. };
  1223. CBUFFER_START(UnityPerMaterial)
  1224. float4 _AlbedoColor;
  1225. float4 _AlbedoMap_ST;
  1226. float4 _NormalMap_ST;
  1227. float4 _MaskMap_ST;
  1228. #ifdef ASE_TRANSMISSION
  1229. float _TransmissionShadow;
  1230. #endif
  1231. #ifdef ASE_TRANSLUCENCY
  1232. float _TransStrength;
  1233. float _TransNormal;
  1234. float _TransScattering;
  1235. float _TransDirect;
  1236. float _TransAmbient;
  1237. float _TransShadow;
  1238. #endif
  1239. #ifdef ASE_TESSELLATION
  1240. float _TessPhongStrength;
  1241. float _TessValue;
  1242. float _TessMin;
  1243. float _TessMax;
  1244. float _TessEdgeLength;
  1245. float _TessMaxDisp;
  1246. #endif
  1247. CBUFFER_END
  1248. #ifdef SCENEPICKINGPASS
  1249. float4 _SelectionID;
  1250. #endif
  1251. #ifdef SCENESELECTIONPASS
  1252. int _ObjectId;
  1253. int _PassValue;
  1254. #endif
  1255. sampler2D _AlbedoMap;
  1256. PackedVaryings VertexFunction( Attributes input )
  1257. {
  1258. PackedVaryings output = (PackedVaryings)0;
  1259. UNITY_SETUP_INSTANCE_ID(input);
  1260. UNITY_TRANSFER_INSTANCE_ID(input, output);
  1261. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
  1262. output.ase_texcoord4.xy = input.texcoord0.xy;
  1263. //setting value to unused interpolator channels and avoid initialization warnings
  1264. output.ase_texcoord4.zw = 0;
  1265. #ifdef ASE_ABSOLUTE_VERTEX_POS
  1266. float3 defaultVertexValue = input.positionOS.xyz;
  1267. #else
  1268. float3 defaultVertexValue = float3(0, 0, 0);
  1269. #endif
  1270. float3 vertexValue = defaultVertexValue;
  1271. #ifdef ASE_ABSOLUTE_VERTEX_POS
  1272. input.positionOS.xyz = vertexValue;
  1273. #else
  1274. input.positionOS.xyz += vertexValue;
  1275. #endif
  1276. input.normalOS = input.normalOS;
  1277. float3 positionWS = TransformObjectToWorld( input.positionOS.xyz );
  1278. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1279. output.positionWS = positionWS;
  1280. #endif
  1281. output.positionCS = MetaVertexPosition( input.positionOS, input.texcoord1.xy, input.texcoord1.xy, unity_LightmapST, unity_DynamicLightmapST );
  1282. #ifdef EDITOR_VISUALIZATION
  1283. float2 VizUV = 0;
  1284. float4 LightCoord = 0;
  1285. UnityEditorVizData(input.positionOS.xyz, input.texcoord0.xy, input.texcoord1.xy, input.texcoord2.xy, VizUV, LightCoord);
  1286. output.VizUV = float4(VizUV, 0, 0);
  1287. output.LightCoord = LightCoord;
  1288. #endif
  1289. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1290. VertexPositionInputs vertexInput = (VertexPositionInputs)0;
  1291. vertexInput.positionWS = positionWS;
  1292. vertexInput.positionCS = output.positionCS;
  1293. output.shadowCoord = GetShadowCoord( vertexInput );
  1294. #endif
  1295. return output;
  1296. }
  1297. #if defined(ASE_TESSELLATION)
  1298. struct VertexControl
  1299. {
  1300. float4 vertex : INTERNALTESSPOS;
  1301. float3 normalOS : NORMAL;
  1302. float4 texcoord0 : TEXCOORD0;
  1303. float4 texcoord1 : TEXCOORD1;
  1304. float4 texcoord2 : TEXCOORD2;
  1305. UNITY_VERTEX_INPUT_INSTANCE_ID
  1306. };
  1307. struct TessellationFactors
  1308. {
  1309. float edge[3] : SV_TessFactor;
  1310. float inside : SV_InsideTessFactor;
  1311. };
  1312. VertexControl vert ( Attributes input )
  1313. {
  1314. VertexControl output;
  1315. UNITY_SETUP_INSTANCE_ID(input);
  1316. UNITY_TRANSFER_INSTANCE_ID(input, output);
  1317. output.vertex = input.positionOS;
  1318. output.normalOS = input.normalOS;
  1319. output.texcoord0 = input.texcoord0;
  1320. output.texcoord1 = input.texcoord1;
  1321. output.texcoord2 = input.texcoord2;
  1322. return output;
  1323. }
  1324. TessellationFactors TessellationFunction (InputPatch<VertexControl,3> input)
  1325. {
  1326. TessellationFactors output;
  1327. float4 tf = 1;
  1328. float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
  1329. float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
  1330. #if defined(ASE_FIXED_TESSELLATION)
  1331. tf = FixedTess( tessValue );
  1332. #elif defined(ASE_DISTANCE_TESSELLATION)
  1333. tf = DistanceBasedTess(input[0].vertex, input[1].vertex, input[2].vertex, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
  1334. #elif defined(ASE_LENGTH_TESSELLATION)
  1335. tf = EdgeLengthBasedTess(input[0].vertex, input[1].vertex, input[2].vertex, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
  1336. #elif defined(ASE_LENGTH_CULL_TESSELLATION)
  1337. tf = EdgeLengthBasedTessCull(input[0].vertex, input[1].vertex, input[2].vertex, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
  1338. #endif
  1339. output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w;
  1340. return output;
  1341. }
  1342. [domain("tri")]
  1343. [partitioning("fractional_odd")]
  1344. [outputtopology("triangle_cw")]
  1345. [patchconstantfunc("TessellationFunction")]
  1346. [outputcontrolpoints(3)]
  1347. VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
  1348. {
  1349. return patch[id];
  1350. }
  1351. [domain("tri")]
  1352. PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
  1353. {
  1354. Attributes output = (Attributes) 0;
  1355. output.positionOS = patch[0].vertex * bary.x + patch[1].vertex * bary.y + patch[2].vertex * bary.z;
  1356. output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
  1357. output.texcoord0 = patch[0].texcoord0 * bary.x + patch[1].texcoord0 * bary.y + patch[2].texcoord0 * bary.z;
  1358. output.texcoord1 = patch[0].texcoord1 * bary.x + patch[1].texcoord1 * bary.y + patch[2].texcoord1 * bary.z;
  1359. output.texcoord2 = patch[0].texcoord2 * bary.x + patch[1].texcoord2 * bary.y + patch[2].texcoord2 * bary.z;
  1360. #if defined(ASE_PHONG_TESSELLATION)
  1361. float3 pp[3];
  1362. for (int i = 0; i < 3; ++i)
  1363. pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].vertex.xyz, patch[i].normalOS));
  1364. float phongStrength = _TessPhongStrength;
  1365. output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz;
  1366. #endif
  1367. UNITY_TRANSFER_INSTANCE_ID(patch[0], output);
  1368. return VertexFunction(output);
  1369. }
  1370. #else
  1371. PackedVaryings vert ( Attributes input )
  1372. {
  1373. return VertexFunction( input );
  1374. }
  1375. #endif
  1376. half4 frag(PackedVaryings input ) : SV_TARGET
  1377. {
  1378. UNITY_SETUP_INSTANCE_ID(input);
  1379. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( input );
  1380. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1381. float3 WorldPosition = input.positionWS;
  1382. #endif
  1383. float4 ShadowCoords = float4( 0, 0, 0, 0 );
  1384. #if defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1385. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  1386. ShadowCoords = input.shadowCoord;
  1387. #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
  1388. ShadowCoords = TransformWorldToShadowCoord( WorldPosition );
  1389. #endif
  1390. #endif
  1391. float2 uv_AlbedoMap = input.ase_texcoord4.xy * _AlbedoMap_ST.xy + _AlbedoMap_ST.zw;
  1392. float3 BaseColor = ( _AlbedoColor * tex2D( _AlbedoMap, uv_AlbedoMap ) ).rgb;
  1393. float3 Emission = 0;
  1394. float Alpha = 1;
  1395. float AlphaClipThreshold = 0.5;
  1396. #ifdef _ALPHATEST_ON
  1397. clip(Alpha - AlphaClipThreshold);
  1398. #endif
  1399. MetaInput metaInput = (MetaInput)0;
  1400. metaInput.Albedo = BaseColor;
  1401. metaInput.Emission = Emission;
  1402. #ifdef EDITOR_VISUALIZATION
  1403. metaInput.VizUV = input.VizUV.xy;
  1404. metaInput.LightCoord = input.LightCoord;
  1405. #endif
  1406. return UnityMetaFragment(metaInput);
  1407. }
  1408. ENDHLSL
  1409. }
  1410. Pass
  1411. {
  1412. Name "Universal2D"
  1413. Tags { "LightMode"="Universal2D" }
  1414. Blend One Zero, One Zero
  1415. ZWrite On
  1416. ZTest LEqual
  1417. Offset 0 , 0
  1418. ColorMask RGBA
  1419. HLSLPROGRAM
  1420. #pragma multi_compile_local_fragment _ALPHATEST_ON
  1421. #define _NORMAL_DROPOFF_TS 1
  1422. #define ASE_FOG 1
  1423. #define _NORMALMAP 1
  1424. #define ASE_VERSION 19701
  1425. #define ASE_SRP_VERSION 170003
  1426. #pragma vertex vert
  1427. #pragma fragment frag
  1428. #if defined(_SPECULAR_SETUP) && defined(_ASE_LIGHTING_SIMPLE)
  1429. #define _SPECULAR_COLOR 1
  1430. #endif
  1431. #define SHADERPASS SHADERPASS_2D
  1432. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  1433. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
  1434. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  1435. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  1436. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl"
  1437. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
  1438. #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
  1439. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl"
  1440. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl"
  1441. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  1442. #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
  1443. struct Attributes
  1444. {
  1445. float4 positionOS : POSITION;
  1446. float3 normalOS : NORMAL;
  1447. float4 ase_texcoord : TEXCOORD0;
  1448. UNITY_VERTEX_INPUT_INSTANCE_ID
  1449. };
  1450. struct PackedVaryings
  1451. {
  1452. float4 positionCS : SV_POSITION;
  1453. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1454. float3 positionWS : TEXCOORD0;
  1455. #endif
  1456. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1457. float4 shadowCoord : TEXCOORD1;
  1458. #endif
  1459. float4 ase_texcoord2 : TEXCOORD2;
  1460. UNITY_VERTEX_INPUT_INSTANCE_ID
  1461. UNITY_VERTEX_OUTPUT_STEREO
  1462. };
  1463. CBUFFER_START(UnityPerMaterial)
  1464. float4 _AlbedoColor;
  1465. float4 _AlbedoMap_ST;
  1466. float4 _NormalMap_ST;
  1467. float4 _MaskMap_ST;
  1468. #ifdef ASE_TRANSMISSION
  1469. float _TransmissionShadow;
  1470. #endif
  1471. #ifdef ASE_TRANSLUCENCY
  1472. float _TransStrength;
  1473. float _TransNormal;
  1474. float _TransScattering;
  1475. float _TransDirect;
  1476. float _TransAmbient;
  1477. float _TransShadow;
  1478. #endif
  1479. #ifdef ASE_TESSELLATION
  1480. float _TessPhongStrength;
  1481. float _TessValue;
  1482. float _TessMin;
  1483. float _TessMax;
  1484. float _TessEdgeLength;
  1485. float _TessMaxDisp;
  1486. #endif
  1487. CBUFFER_END
  1488. #ifdef SCENEPICKINGPASS
  1489. float4 _SelectionID;
  1490. #endif
  1491. #ifdef SCENESELECTIONPASS
  1492. int _ObjectId;
  1493. int _PassValue;
  1494. #endif
  1495. sampler2D _AlbedoMap;
  1496. PackedVaryings VertexFunction( Attributes input )
  1497. {
  1498. PackedVaryings output = (PackedVaryings)0;
  1499. UNITY_SETUP_INSTANCE_ID( input );
  1500. UNITY_TRANSFER_INSTANCE_ID( input, output );
  1501. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( output );
  1502. output.ase_texcoord2.xy = input.ase_texcoord.xy;
  1503. //setting value to unused interpolator channels and avoid initialization warnings
  1504. output.ase_texcoord2.zw = 0;
  1505. #ifdef ASE_ABSOLUTE_VERTEX_POS
  1506. float3 defaultVertexValue = input.positionOS.xyz;
  1507. #else
  1508. float3 defaultVertexValue = float3(0, 0, 0);
  1509. #endif
  1510. float3 vertexValue = defaultVertexValue;
  1511. #ifdef ASE_ABSOLUTE_VERTEX_POS
  1512. input.positionOS.xyz = vertexValue;
  1513. #else
  1514. input.positionOS.xyz += vertexValue;
  1515. #endif
  1516. input.normalOS = input.normalOS;
  1517. VertexPositionInputs vertexInput = GetVertexPositionInputs( input.positionOS.xyz );
  1518. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1519. output.positionWS = vertexInput.positionWS;
  1520. #endif
  1521. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1522. output.shadowCoord = GetShadowCoord( vertexInput );
  1523. #endif
  1524. output.positionCS = vertexInput.positionCS;
  1525. return output;
  1526. }
  1527. #if defined(ASE_TESSELLATION)
  1528. struct VertexControl
  1529. {
  1530. float4 vertex : INTERNALTESSPOS;
  1531. float3 normalOS : NORMAL;
  1532. float4 ase_texcoord : TEXCOORD0;
  1533. UNITY_VERTEX_INPUT_INSTANCE_ID
  1534. };
  1535. struct TessellationFactors
  1536. {
  1537. float edge[3] : SV_TessFactor;
  1538. float inside : SV_InsideTessFactor;
  1539. };
  1540. VertexControl vert ( Attributes input )
  1541. {
  1542. VertexControl output;
  1543. UNITY_SETUP_INSTANCE_ID(input);
  1544. UNITY_TRANSFER_INSTANCE_ID(input, output);
  1545. output.vertex = input.positionOS;
  1546. output.normalOS = input.normalOS;
  1547. output.ase_texcoord = input.ase_texcoord;
  1548. return output;
  1549. }
  1550. TessellationFactors TessellationFunction (InputPatch<VertexControl,3> input)
  1551. {
  1552. TessellationFactors output;
  1553. float4 tf = 1;
  1554. float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
  1555. float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
  1556. #if defined(ASE_FIXED_TESSELLATION)
  1557. tf = FixedTess( tessValue );
  1558. #elif defined(ASE_DISTANCE_TESSELLATION)
  1559. tf = DistanceBasedTess(input[0].vertex, input[1].vertex, input[2].vertex, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
  1560. #elif defined(ASE_LENGTH_TESSELLATION)
  1561. tf = EdgeLengthBasedTess(input[0].vertex, input[1].vertex, input[2].vertex, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
  1562. #elif defined(ASE_LENGTH_CULL_TESSELLATION)
  1563. tf = EdgeLengthBasedTessCull(input[0].vertex, input[1].vertex, input[2].vertex, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
  1564. #endif
  1565. output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w;
  1566. return output;
  1567. }
  1568. [domain("tri")]
  1569. [partitioning("fractional_odd")]
  1570. [outputtopology("triangle_cw")]
  1571. [patchconstantfunc("TessellationFunction")]
  1572. [outputcontrolpoints(3)]
  1573. VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
  1574. {
  1575. return patch[id];
  1576. }
  1577. [domain("tri")]
  1578. PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
  1579. {
  1580. Attributes output = (Attributes) 0;
  1581. output.positionOS = patch[0].vertex * bary.x + patch[1].vertex * bary.y + patch[2].vertex * bary.z;
  1582. output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
  1583. output.ase_texcoord = patch[0].ase_texcoord * bary.x + patch[1].ase_texcoord * bary.y + patch[2].ase_texcoord * bary.z;
  1584. #if defined(ASE_PHONG_TESSELLATION)
  1585. float3 pp[3];
  1586. for (int i = 0; i < 3; ++i)
  1587. pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].vertex.xyz, patch[i].normalOS));
  1588. float phongStrength = _TessPhongStrength;
  1589. output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz;
  1590. #endif
  1591. UNITY_TRANSFER_INSTANCE_ID(patch[0], output);
  1592. return VertexFunction(output);
  1593. }
  1594. #else
  1595. PackedVaryings vert ( Attributes input )
  1596. {
  1597. return VertexFunction( input );
  1598. }
  1599. #endif
  1600. half4 frag(PackedVaryings input ) : SV_TARGET
  1601. {
  1602. UNITY_SETUP_INSTANCE_ID( input );
  1603. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( input );
  1604. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1605. float3 WorldPosition = input.positionWS;
  1606. #endif
  1607. float4 ShadowCoords = float4( 0, 0, 0, 0 );
  1608. #if defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1609. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  1610. ShadowCoords = input.shadowCoord;
  1611. #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
  1612. ShadowCoords = TransformWorldToShadowCoord( WorldPosition );
  1613. #endif
  1614. #endif
  1615. float2 uv_AlbedoMap = input.ase_texcoord2.xy * _AlbedoMap_ST.xy + _AlbedoMap_ST.zw;
  1616. float3 BaseColor = ( _AlbedoColor * tex2D( _AlbedoMap, uv_AlbedoMap ) ).rgb;
  1617. float Alpha = 1;
  1618. float AlphaClipThreshold = 0.5;
  1619. half4 color = half4(BaseColor, Alpha );
  1620. #ifdef _ALPHATEST_ON
  1621. clip(Alpha - AlphaClipThreshold);
  1622. #endif
  1623. return color;
  1624. }
  1625. ENDHLSL
  1626. }
  1627. Pass
  1628. {
  1629. Name "DepthNormals"
  1630. Tags { "LightMode"="DepthNormals" }
  1631. ZWrite On
  1632. Blend One Zero
  1633. ZTest LEqual
  1634. ZWrite On
  1635. HLSLPROGRAM
  1636. #pragma multi_compile_local_fragment _ALPHATEST_ON
  1637. #define _NORMAL_DROPOFF_TS 1
  1638. #pragma multi_compile_instancing
  1639. #pragma multi_compile _ LOD_FADE_CROSSFADE
  1640. #define ASE_FOG 1
  1641. #define _NORMALMAP 1
  1642. #define ASE_VERSION 19701
  1643. #define ASE_SRP_VERSION 170003
  1644. #pragma vertex vert
  1645. #pragma fragment frag
  1646. #if defined(_SPECULAR_SETUP) && defined(_ASE_LIGHTING_SIMPLE)
  1647. #define _SPECULAR_COLOR 1
  1648. #endif
  1649. #define SHADERPASS SHADERPASS_DEPTHNORMALSONLY
  1650. //#define SHADERPASS SHADERPASS_DEPTHNORMALS
  1651. #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
  1652. #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"
  1653. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  1654. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
  1655. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  1656. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  1657. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl"
  1658. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
  1659. #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
  1660. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl"
  1661. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl"
  1662. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  1663. #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
  1664. #if defined(LOD_FADE_CROSSFADE)
  1665. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl"
  1666. #endif
  1667. #if defined(ASE_EARLY_Z_DEPTH_OPTIMIZE) && (SHADER_TARGET >= 45)
  1668. #define ASE_SV_DEPTH SV_DepthLessEqual
  1669. #define ASE_SV_POSITION_QUALIFIERS linear noperspective centroid
  1670. #else
  1671. #define ASE_SV_DEPTH SV_Depth
  1672. #define ASE_SV_POSITION_QUALIFIERS
  1673. #endif
  1674. struct Attributes
  1675. {
  1676. float4 positionOS : POSITION;
  1677. float3 normalOS : NORMAL;
  1678. float4 tangentOS : TANGENT;
  1679. float4 ase_texcoord : TEXCOORD0;
  1680. UNITY_VERTEX_INPUT_INSTANCE_ID
  1681. };
  1682. struct PackedVaryings
  1683. {
  1684. ASE_SV_POSITION_QUALIFIERS float4 positionCS : SV_POSITION;
  1685. float4 clipPosV : TEXCOORD0;
  1686. float3 worldNormal : TEXCOORD1;
  1687. float4 worldTangent : TEXCOORD2;
  1688. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1689. float3 positionWS : TEXCOORD3;
  1690. #endif
  1691. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1692. float4 shadowCoord : TEXCOORD4;
  1693. #endif
  1694. float4 ase_texcoord5 : TEXCOORD5;
  1695. UNITY_VERTEX_INPUT_INSTANCE_ID
  1696. UNITY_VERTEX_OUTPUT_STEREO
  1697. };
  1698. CBUFFER_START(UnityPerMaterial)
  1699. float4 _AlbedoColor;
  1700. float4 _AlbedoMap_ST;
  1701. float4 _NormalMap_ST;
  1702. float4 _MaskMap_ST;
  1703. #ifdef ASE_TRANSMISSION
  1704. float _TransmissionShadow;
  1705. #endif
  1706. #ifdef ASE_TRANSLUCENCY
  1707. float _TransStrength;
  1708. float _TransNormal;
  1709. float _TransScattering;
  1710. float _TransDirect;
  1711. float _TransAmbient;
  1712. float _TransShadow;
  1713. #endif
  1714. #ifdef ASE_TESSELLATION
  1715. float _TessPhongStrength;
  1716. float _TessValue;
  1717. float _TessMin;
  1718. float _TessMax;
  1719. float _TessEdgeLength;
  1720. float _TessMaxDisp;
  1721. #endif
  1722. CBUFFER_END
  1723. #ifdef SCENEPICKINGPASS
  1724. float4 _SelectionID;
  1725. #endif
  1726. #ifdef SCENESELECTIONPASS
  1727. int _ObjectId;
  1728. int _PassValue;
  1729. #endif
  1730. sampler2D _NormalMap;
  1731. PackedVaryings VertexFunction( Attributes input )
  1732. {
  1733. PackedVaryings output = (PackedVaryings)0;
  1734. UNITY_SETUP_INSTANCE_ID(input);
  1735. UNITY_TRANSFER_INSTANCE_ID(input, output);
  1736. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
  1737. output.ase_texcoord5.xy = input.ase_texcoord.xy;
  1738. //setting value to unused interpolator channels and avoid initialization warnings
  1739. output.ase_texcoord5.zw = 0;
  1740. #ifdef ASE_ABSOLUTE_VERTEX_POS
  1741. float3 defaultVertexValue = input.positionOS.xyz;
  1742. #else
  1743. float3 defaultVertexValue = float3(0, 0, 0);
  1744. #endif
  1745. float3 vertexValue = defaultVertexValue;
  1746. #ifdef ASE_ABSOLUTE_VERTEX_POS
  1747. input.positionOS.xyz = vertexValue;
  1748. #else
  1749. input.positionOS.xyz += vertexValue;
  1750. #endif
  1751. input.normalOS = input.normalOS;
  1752. input.tangentOS = input.tangentOS;
  1753. VertexPositionInputs vertexInput = GetVertexPositionInputs( input.positionOS.xyz );
  1754. float3 normalWS = TransformObjectToWorldNormal( input.normalOS );
  1755. float4 tangentWS = float4( TransformObjectToWorldDir( input.tangentOS.xyz ), input.tangentOS.w );
  1756. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1757. output.positionWS = vertexInput.positionWS;
  1758. #endif
  1759. output.worldNormal = normalWS;
  1760. output.worldTangent = tangentWS;
  1761. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1762. output.shadowCoord = GetShadowCoord( vertexInput );
  1763. #endif
  1764. output.positionCS = vertexInput.positionCS;
  1765. output.clipPosV = vertexInput.positionCS;
  1766. return output;
  1767. }
  1768. #if defined(ASE_TESSELLATION)
  1769. struct VertexControl
  1770. {
  1771. float4 vertex : INTERNALTESSPOS;
  1772. float3 normalOS : NORMAL;
  1773. float4 tangentOS : TANGENT;
  1774. float4 ase_texcoord : TEXCOORD0;
  1775. UNITY_VERTEX_INPUT_INSTANCE_ID
  1776. };
  1777. struct TessellationFactors
  1778. {
  1779. float edge[3] : SV_TessFactor;
  1780. float inside : SV_InsideTessFactor;
  1781. };
  1782. VertexControl vert ( Attributes input )
  1783. {
  1784. VertexControl output;
  1785. UNITY_SETUP_INSTANCE_ID(input);
  1786. UNITY_TRANSFER_INSTANCE_ID(input, output);
  1787. output.vertex = input.positionOS;
  1788. output.normalOS = input.normalOS;
  1789. output.tangentOS = input.tangentOS;
  1790. output.ase_texcoord = input.ase_texcoord;
  1791. return output;
  1792. }
  1793. TessellationFactors TessellationFunction (InputPatch<VertexControl,3> input)
  1794. {
  1795. TessellationFactors output;
  1796. float4 tf = 1;
  1797. float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
  1798. float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
  1799. #if defined(ASE_FIXED_TESSELLATION)
  1800. tf = FixedTess( tessValue );
  1801. #elif defined(ASE_DISTANCE_TESSELLATION)
  1802. tf = DistanceBasedTess(input[0].vertex, input[1].vertex, input[2].vertex, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
  1803. #elif defined(ASE_LENGTH_TESSELLATION)
  1804. tf = EdgeLengthBasedTess(input[0].vertex, input[1].vertex, input[2].vertex, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
  1805. #elif defined(ASE_LENGTH_CULL_TESSELLATION)
  1806. tf = EdgeLengthBasedTessCull(input[0].vertex, input[1].vertex, input[2].vertex, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
  1807. #endif
  1808. output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w;
  1809. return output;
  1810. }
  1811. [domain("tri")]
  1812. [partitioning("fractional_odd")]
  1813. [outputtopology("triangle_cw")]
  1814. [patchconstantfunc("TessellationFunction")]
  1815. [outputcontrolpoints(3)]
  1816. VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
  1817. {
  1818. return patch[id];
  1819. }
  1820. [domain("tri")]
  1821. PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
  1822. {
  1823. Attributes output = (Attributes) 0;
  1824. output.positionOS = patch[0].vertex * bary.x + patch[1].vertex * bary.y + patch[2].vertex * bary.z;
  1825. output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
  1826. output.tangentOS = patch[0].tangentOS * bary.x + patch[1].tangentOS * bary.y + patch[2].tangentOS * bary.z;
  1827. output.ase_texcoord = patch[0].ase_texcoord * bary.x + patch[1].ase_texcoord * bary.y + patch[2].ase_texcoord * bary.z;
  1828. #if defined(ASE_PHONG_TESSELLATION)
  1829. float3 pp[3];
  1830. for (int i = 0; i < 3; ++i)
  1831. pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].vertex.xyz, patch[i].normalOS));
  1832. float phongStrength = _TessPhongStrength;
  1833. output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz;
  1834. #endif
  1835. UNITY_TRANSFER_INSTANCE_ID(patch[0], output);
  1836. return VertexFunction(output);
  1837. }
  1838. #else
  1839. PackedVaryings vert ( Attributes input )
  1840. {
  1841. return VertexFunction( input );
  1842. }
  1843. #endif
  1844. void frag( PackedVaryings input
  1845. , out half4 outNormalWS : SV_Target0
  1846. #ifdef ASE_DEPTH_WRITE_ON
  1847. ,out float outputDepth : ASE_SV_DEPTH
  1848. #endif
  1849. #ifdef _WRITE_RENDERING_LAYERS
  1850. , out float4 outRenderingLayers : SV_Target1
  1851. #endif
  1852. )
  1853. {
  1854. UNITY_SETUP_INSTANCE_ID(input);
  1855. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( input );
  1856. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1857. float3 WorldPosition = input.positionWS;
  1858. #endif
  1859. float4 ShadowCoords = float4( 0, 0, 0, 0 );
  1860. float3 WorldNormal = input.worldNormal;
  1861. float4 WorldTangent = input.worldTangent;
  1862. float4 ClipPos = input.clipPosV;
  1863. float4 ScreenPos = ComputeScreenPos( input.clipPosV );
  1864. #if defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1865. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  1866. ShadowCoords = input.shadowCoord;
  1867. #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
  1868. ShadowCoords = TransformWorldToShadowCoord( WorldPosition );
  1869. #endif
  1870. #endif
  1871. float2 uv_NormalMap = input.ase_texcoord5.xy * _NormalMap_ST.xy + _NormalMap_ST.zw;
  1872. float3 Normal = UnpackNormalScale( tex2D( _NormalMap, uv_NormalMap ), 1.0f );
  1873. float Alpha = 1;
  1874. float AlphaClipThreshold = 0.5;
  1875. #ifdef ASE_DEPTH_WRITE_ON
  1876. float DepthValue = input.positionCS.z;
  1877. #endif
  1878. #ifdef _ALPHATEST_ON
  1879. clip(Alpha - AlphaClipThreshold);
  1880. #endif
  1881. #if defined(LOD_FADE_CROSSFADE)
  1882. LODFadeCrossFade( input.positionCS );
  1883. #endif
  1884. #ifdef ASE_DEPTH_WRITE_ON
  1885. outputDepth = DepthValue;
  1886. #endif
  1887. #if defined(_GBUFFER_NORMALS_OCT)
  1888. float2 octNormalWS = PackNormalOctQuadEncode(WorldNormal);
  1889. float2 remappedOctNormalWS = saturate(octNormalWS * 0.5 + 0.5);
  1890. half3 packedNormalWS = PackFloat2To888(remappedOctNormalWS);
  1891. outNormalWS = half4(packedNormalWS, 0.0);
  1892. #else
  1893. #if defined(_NORMALMAP)
  1894. #if _NORMAL_DROPOFF_TS
  1895. float crossSign = (WorldTangent.w > 0.0 ? 1.0 : -1.0) * GetOddNegativeScale();
  1896. float3 bitangent = crossSign * cross(WorldNormal.xyz, WorldTangent.xyz);
  1897. float3 normalWS = TransformTangentToWorld(Normal, half3x3(WorldTangent.xyz, bitangent, WorldNormal.xyz));
  1898. #elif _NORMAL_DROPOFF_OS
  1899. float3 normalWS = TransformObjectToWorldNormal(Normal);
  1900. #elif _NORMAL_DROPOFF_WS
  1901. float3 normalWS = Normal;
  1902. #endif
  1903. #else
  1904. float3 normalWS = WorldNormal;
  1905. #endif
  1906. outNormalWS = half4(NormalizeNormalPerPixel(normalWS), 0.0);
  1907. #endif
  1908. #ifdef _WRITE_RENDERING_LAYERS
  1909. uint renderingLayers = GetMeshRenderingLayer();
  1910. outRenderingLayers = float4( EncodeMeshRenderingLayer( renderingLayers ), 0, 0, 0 );
  1911. #endif
  1912. }
  1913. ENDHLSL
  1914. }
  1915. Pass
  1916. {
  1917. Name "GBuffer"
  1918. Tags { "LightMode"="UniversalGBuffer" }
  1919. Blend One Zero, One Zero
  1920. ZWrite On
  1921. ZTest LEqual
  1922. Offset 0 , 0
  1923. ColorMask RGBA
  1924. HLSLPROGRAM
  1925. #pragma multi_compile_local_fragment _ALPHATEST_ON
  1926. #define _NORMAL_DROPOFF_TS 1
  1927. #pragma shader_feature_local _RECEIVE_SHADOWS_OFF
  1928. #pragma multi_compile_instancing
  1929. #pragma instancing_options renderinglayer
  1930. #pragma multi_compile _ LOD_FADE_CROSSFADE
  1931. #pragma multi_compile_fog
  1932. #define ASE_FOG 1
  1933. #define _NORMALMAP 1
  1934. #define ASE_VERSION 19701
  1935. #define ASE_SRP_VERSION 170003
  1936. #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
  1937. #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
  1938. #pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION
  1939. #pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
  1940. #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
  1941. #pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
  1942. #pragma multi_compile_fragment _ _RENDER_PASS_ENABLED
  1943. #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
  1944. #pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE
  1945. #pragma multi_compile _ SHADOWS_SHADOWMASK
  1946. #pragma multi_compile _ DIRLIGHTMAP_COMBINED
  1947. #pragma multi_compile _ USE_LEGACY_LIGHTMAPS
  1948. #pragma multi_compile _ LIGHTMAP_ON
  1949. #pragma multi_compile _ DYNAMICLIGHTMAP_ON
  1950. #pragma multi_compile_fragment _ DEBUG_DISPLAY
  1951. #pragma vertex vert
  1952. #pragma fragment frag
  1953. #if defined(_SPECULAR_SETUP) && defined(_ASE_LIGHTING_SIMPLE)
  1954. #define _SPECULAR_COLOR 1
  1955. #endif
  1956. #define SHADERPASS SHADERPASS_GBUFFER
  1957. #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
  1958. #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"
  1959. #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl"
  1960. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  1961. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
  1962. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  1963. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  1964. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl"
  1965. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
  1966. #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
  1967. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl"
  1968. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl"
  1969. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl"
  1970. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  1971. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DBuffer.hlsl"
  1972. #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
  1973. #if defined(LOD_FADE_CROSSFADE)
  1974. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl"
  1975. #endif
  1976. #if defined(UNITY_INSTANCING_ENABLED) && defined(_TERRAIN_INSTANCED_PERPIXEL_NORMAL)
  1977. #define ENABLE_TERRAIN_PERPIXEL_NORMAL
  1978. #endif
  1979. #if defined(ASE_EARLY_Z_DEPTH_OPTIMIZE) && (SHADER_TARGET >= 45)
  1980. #define ASE_SV_DEPTH SV_DepthLessEqual
  1981. #define ASE_SV_POSITION_QUALIFIERS linear noperspective centroid
  1982. #else
  1983. #define ASE_SV_DEPTH SV_Depth
  1984. #define ASE_SV_POSITION_QUALIFIERS
  1985. #endif
  1986. struct Attributes
  1987. {
  1988. float4 positionOS : POSITION;
  1989. float3 normalOS : NORMAL;
  1990. float4 tangentOS : TANGENT;
  1991. float4 texcoord : TEXCOORD0;
  1992. float4 texcoord1 : TEXCOORD1;
  1993. float4 texcoord2 : TEXCOORD2;
  1994. UNITY_VERTEX_INPUT_INSTANCE_ID
  1995. };
  1996. struct PackedVaryings
  1997. {
  1998. ASE_SV_POSITION_QUALIFIERS float4 positionCS : SV_POSITION;
  1999. float4 clipPosV : TEXCOORD0;
  2000. float4 lightmapUVOrVertexSH : TEXCOORD1;
  2001. half4 fogFactorAndVertexLight : TEXCOORD2;
  2002. float4 tSpace0 : TEXCOORD3;
  2003. float4 tSpace1 : TEXCOORD4;
  2004. float4 tSpace2 : TEXCOORD5;
  2005. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  2006. float4 shadowCoord : TEXCOORD6;
  2007. #endif
  2008. #if defined(DYNAMICLIGHTMAP_ON)
  2009. float2 dynamicLightmapUV : TEXCOORD7;
  2010. #endif
  2011. #if defined(USE_APV_PROBE_OCCLUSION)
  2012. float4 probeOcclusion : TEXCOORD8;
  2013. #endif
  2014. float4 ase_texcoord9 : TEXCOORD9;
  2015. UNITY_VERTEX_INPUT_INSTANCE_ID
  2016. UNITY_VERTEX_OUTPUT_STEREO
  2017. };
  2018. CBUFFER_START(UnityPerMaterial)
  2019. float4 _AlbedoColor;
  2020. float4 _AlbedoMap_ST;
  2021. float4 _NormalMap_ST;
  2022. float4 _MaskMap_ST;
  2023. #ifdef ASE_TRANSMISSION
  2024. float _TransmissionShadow;
  2025. #endif
  2026. #ifdef ASE_TRANSLUCENCY
  2027. float _TransStrength;
  2028. float _TransNormal;
  2029. float _TransScattering;
  2030. float _TransDirect;
  2031. float _TransAmbient;
  2032. float _TransShadow;
  2033. #endif
  2034. #ifdef ASE_TESSELLATION
  2035. float _TessPhongStrength;
  2036. float _TessValue;
  2037. float _TessMin;
  2038. float _TessMax;
  2039. float _TessEdgeLength;
  2040. float _TessMaxDisp;
  2041. #endif
  2042. CBUFFER_END
  2043. #ifdef SCENEPICKINGPASS
  2044. float4 _SelectionID;
  2045. #endif
  2046. #ifdef SCENESELECTIONPASS
  2047. int _ObjectId;
  2048. int _PassValue;
  2049. #endif
  2050. sampler2D _AlbedoMap;
  2051. sampler2D _NormalMap;
  2052. sampler2D _MaskMap;
  2053. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/UnityGBuffer.hlsl"
  2054. PackedVaryings VertexFunction( Attributes input )
  2055. {
  2056. PackedVaryings output = (PackedVaryings)0;
  2057. UNITY_SETUP_INSTANCE_ID(input);
  2058. UNITY_TRANSFER_INSTANCE_ID(input, output);
  2059. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
  2060. output.ase_texcoord9.xy = input.texcoord.xy;
  2061. //setting value to unused interpolator channels and avoid initialization warnings
  2062. output.ase_texcoord9.zw = 0;
  2063. #ifdef ASE_ABSOLUTE_VERTEX_POS
  2064. float3 defaultVertexValue = input.positionOS.xyz;
  2065. #else
  2066. float3 defaultVertexValue = float3(0, 0, 0);
  2067. #endif
  2068. float3 vertexValue = defaultVertexValue;
  2069. #ifdef ASE_ABSOLUTE_VERTEX_POS
  2070. input.positionOS.xyz = vertexValue;
  2071. #else
  2072. input.positionOS.xyz += vertexValue;
  2073. #endif
  2074. input.normalOS = input.normalOS;
  2075. input.tangentOS = input.tangentOS;
  2076. VertexPositionInputs vertexInput = GetVertexPositionInputs( input.positionOS.xyz );
  2077. VertexNormalInputs normalInput = GetVertexNormalInputs( input.normalOS, input.tangentOS );
  2078. output.tSpace0 = float4( normalInput.normalWS, vertexInput.positionWS.x);
  2079. output.tSpace1 = float4( normalInput.tangentWS, vertexInput.positionWS.y);
  2080. output.tSpace2 = float4( normalInput.bitangentWS, vertexInput.positionWS.z);
  2081. #if defined(LIGHTMAP_ON)
  2082. OUTPUT_LIGHTMAP_UV(input.texcoord1, unity_LightmapST, output.lightmapUVOrVertexSH.xy);
  2083. #endif
  2084. #if defined(DYNAMICLIGHTMAP_ON)
  2085. output.dynamicLightmapUV.xy = input.texcoord2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
  2086. #endif
  2087. OUTPUT_SH4( vertexInput.positionWS, normalInput.normalWS.xyz, GetWorldSpaceNormalizeViewDir( vertexInput.positionWS ), output.lightmapUVOrVertexSH.xyz, output.probeOcclusion );
  2088. #if defined(ENABLE_TERRAIN_PERPIXEL_NORMAL)
  2089. output.lightmapUVOrVertexSH.zw = input.texcoord.xy;
  2090. output.lightmapUVOrVertexSH.xy = input.texcoord.xy * unity_LightmapST.xy + unity_LightmapST.zw;
  2091. #endif
  2092. half3 vertexLight = VertexLighting( vertexInput.positionWS, normalInput.normalWS );
  2093. output.fogFactorAndVertexLight = half4(0, vertexLight);
  2094. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  2095. output.shadowCoord = GetShadowCoord( vertexInput );
  2096. #endif
  2097. output.positionCS = vertexInput.positionCS;
  2098. output.clipPosV = vertexInput.positionCS;
  2099. return output;
  2100. }
  2101. #if defined(ASE_TESSELLATION)
  2102. struct VertexControl
  2103. {
  2104. float4 vertex : INTERNALTESSPOS;
  2105. float3 normalOS : NORMAL;
  2106. float4 tangentOS : TANGENT;
  2107. float4 texcoord : TEXCOORD0;
  2108. float4 texcoord1 : TEXCOORD1;
  2109. float4 texcoord2 : TEXCOORD2;
  2110. UNITY_VERTEX_INPUT_INSTANCE_ID
  2111. };
  2112. struct TessellationFactors
  2113. {
  2114. float edge[3] : SV_TessFactor;
  2115. float inside : SV_InsideTessFactor;
  2116. };
  2117. VertexControl vert ( Attributes input )
  2118. {
  2119. VertexControl output;
  2120. UNITY_SETUP_INSTANCE_ID(input);
  2121. UNITY_TRANSFER_INSTANCE_ID(input, output);
  2122. output.vertex = input.positionOS;
  2123. output.normalOS = input.normalOS;
  2124. output.tangentOS = input.tangentOS;
  2125. output.texcoord = input.texcoord;
  2126. output.texcoord1 = input.texcoord1;
  2127. output.texcoord2 = input.texcoord2;
  2128. return output;
  2129. }
  2130. TessellationFactors TessellationFunction (InputPatch<VertexControl,3> input)
  2131. {
  2132. TessellationFactors output;
  2133. float4 tf = 1;
  2134. float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
  2135. float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
  2136. #if defined(ASE_FIXED_TESSELLATION)
  2137. tf = FixedTess( tessValue );
  2138. #elif defined(ASE_DISTANCE_TESSELLATION)
  2139. tf = DistanceBasedTess(input[0].vertex, input[1].vertex, input[2].vertex, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
  2140. #elif defined(ASE_LENGTH_TESSELLATION)
  2141. tf = EdgeLengthBasedTess(input[0].vertex, input[1].vertex, input[2].vertex, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
  2142. #elif defined(ASE_LENGTH_CULL_TESSELLATION)
  2143. tf = EdgeLengthBasedTessCull(input[0].vertex, input[1].vertex, input[2].vertex, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
  2144. #endif
  2145. output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w;
  2146. return output;
  2147. }
  2148. [domain("tri")]
  2149. [partitioning("fractional_odd")]
  2150. [outputtopology("triangle_cw")]
  2151. [patchconstantfunc("TessellationFunction")]
  2152. [outputcontrolpoints(3)]
  2153. VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
  2154. {
  2155. return patch[id];
  2156. }
  2157. [domain("tri")]
  2158. PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
  2159. {
  2160. Attributes output = (Attributes) 0;
  2161. output.positionOS = patch[0].vertex * bary.x + patch[1].vertex * bary.y + patch[2].vertex * bary.z;
  2162. output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
  2163. output.tangentOS = patch[0].tangentOS * bary.x + patch[1].tangentOS * bary.y + patch[2].tangentOS * bary.z;
  2164. output.texcoord = patch[0].texcoord * bary.x + patch[1].texcoord * bary.y + patch[2].texcoord * bary.z;
  2165. output.texcoord1 = patch[0].texcoord1 * bary.x + patch[1].texcoord1 * bary.y + patch[2].texcoord1 * bary.z;
  2166. output.texcoord2 = patch[0].texcoord2 * bary.x + patch[1].texcoord2 * bary.y + patch[2].texcoord2 * bary.z;
  2167. #if defined(ASE_PHONG_TESSELLATION)
  2168. float3 pp[3];
  2169. for (int i = 0; i < 3; ++i)
  2170. pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].vertex.xyz, patch[i].normalOS));
  2171. float phongStrength = _TessPhongStrength;
  2172. output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz;
  2173. #endif
  2174. UNITY_TRANSFER_INSTANCE_ID(patch[0], output);
  2175. return VertexFunction(output);
  2176. }
  2177. #else
  2178. PackedVaryings vert ( Attributes input )
  2179. {
  2180. return VertexFunction( input );
  2181. }
  2182. #endif
  2183. FragmentOutput frag ( PackedVaryings input
  2184. #ifdef ASE_DEPTH_WRITE_ON
  2185. ,out float outputDepth : ASE_SV_DEPTH
  2186. #endif
  2187. )
  2188. {
  2189. UNITY_SETUP_INSTANCE_ID(input);
  2190. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
  2191. #if defined(LOD_FADE_CROSSFADE)
  2192. LODFadeCrossFade( input.positionCS );
  2193. #endif
  2194. #if defined(ENABLE_TERRAIN_PERPIXEL_NORMAL)
  2195. float2 sampleCoords = (input.lightmapUVOrVertexSH.zw / _TerrainHeightmapRecipSize.zw + 0.5f) * _TerrainHeightmapRecipSize.xy;
  2196. float3 WorldNormal = TransformObjectToWorldNormal(normalize(SAMPLE_TEXTURE2D(_TerrainNormalmapTexture, sampler_TerrainNormalmapTexture, sampleCoords).rgb * 2 - 1));
  2197. float3 WorldTangent = -cross(GetObjectToWorldMatrix()._13_23_33, WorldNormal);
  2198. float3 WorldBiTangent = cross(WorldNormal, -WorldTangent);
  2199. #else
  2200. float3 WorldNormal = normalize( input.tSpace0.xyz );
  2201. float3 WorldTangent = input.tSpace1.xyz;
  2202. float3 WorldBiTangent = input.tSpace2.xyz;
  2203. #endif
  2204. float3 WorldPosition = float3(input.tSpace0.w,input.tSpace1.w,input.tSpace2.w);
  2205. float3 WorldViewDirection = _WorldSpaceCameraPos.xyz - WorldPosition;
  2206. float4 ShadowCoords = float4( 0, 0, 0, 0 );
  2207. float4 ClipPos = input.clipPosV;
  2208. float4 ScreenPos = ComputeScreenPos( input.clipPosV );
  2209. float2 NormalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS);
  2210. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  2211. ShadowCoords = input.shadowCoord;
  2212. #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
  2213. ShadowCoords = TransformWorldToShadowCoord( WorldPosition );
  2214. #else
  2215. ShadowCoords = float4(0, 0, 0, 0);
  2216. #endif
  2217. WorldViewDirection = SafeNormalize( WorldViewDirection );
  2218. float2 uv_AlbedoMap = input.ase_texcoord9.xy * _AlbedoMap_ST.xy + _AlbedoMap_ST.zw;
  2219. float2 uv_NormalMap = input.ase_texcoord9.xy * _NormalMap_ST.xy + _NormalMap_ST.zw;
  2220. float2 uv_MaskMap = input.ase_texcoord9.xy * _MaskMap_ST.xy + _MaskMap_ST.zw;
  2221. float3 BaseColor = ( _AlbedoColor * tex2D( _AlbedoMap, uv_AlbedoMap ) ).rgb;
  2222. float3 Normal = UnpackNormalScale( tex2D( _NormalMap, uv_NormalMap ), 1.0f );
  2223. float3 Emission = 0;
  2224. float3 Specular = 0.5;
  2225. float Metallic = 0;
  2226. float Smoothness = tex2D( _MaskMap, uv_MaskMap ).a;
  2227. float Occlusion = 1;
  2228. float Alpha = 1;
  2229. float AlphaClipThreshold = 0.5;
  2230. float AlphaClipThresholdShadow = 0.5;
  2231. float3 BakedGI = 0;
  2232. float3 RefractionColor = 1;
  2233. float RefractionIndex = 1;
  2234. float3 Transmission = 1;
  2235. float3 Translucency = 1;
  2236. #ifdef ASE_DEPTH_WRITE_ON
  2237. float DepthValue = input.positionCS.z;
  2238. #endif
  2239. #ifdef _ALPHATEST_ON
  2240. clip(Alpha - AlphaClipThreshold);
  2241. #endif
  2242. InputData inputData = (InputData)0;
  2243. inputData.positionWS = WorldPosition;
  2244. inputData.positionCS = input.positionCS;
  2245. inputData.shadowCoord = ShadowCoords;
  2246. #ifdef _NORMALMAP
  2247. #if _NORMAL_DROPOFF_TS
  2248. inputData.normalWS = TransformTangentToWorld(Normal, half3x3( WorldTangent, WorldBiTangent, WorldNormal ));
  2249. #elif _NORMAL_DROPOFF_OS
  2250. inputData.normalWS = TransformObjectToWorldNormal(Normal);
  2251. #elif _NORMAL_DROPOFF_WS
  2252. inputData.normalWS = Normal;
  2253. #endif
  2254. #else
  2255. inputData.normalWS = WorldNormal;
  2256. #endif
  2257. inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS);
  2258. inputData.viewDirectionWS = SafeNormalize( WorldViewDirection );
  2259. inputData.vertexLighting = input.fogFactorAndVertexLight.yzw;
  2260. #if defined(ENABLE_TERRAIN_PERPIXEL_NORMAL)
  2261. float3 SH = SampleSH(inputData.normalWS.xyz);
  2262. #else
  2263. float3 SH = input.lightmapUVOrVertexSH.xyz;
  2264. #endif
  2265. #if defined(DYNAMICLIGHTMAP_ON)
  2266. inputData.bakedGI = SAMPLE_GI(input.lightmapUVOrVertexSH.xy, input.dynamicLightmapUV.xy, SH, inputData.normalWS);
  2267. inputData.shadowMask = SAMPLE_SHADOWMASK(input.lightmapUVOrVertexSH.xy);
  2268. #elif !defined(LIGHTMAP_ON) && (defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2))
  2269. inputData.bakedGI = SAMPLE_GI( SH, GetAbsolutePositionWS(inputData.positionWS),
  2270. inputData.normalWS,
  2271. inputData.viewDirectionWS,
  2272. input.positionCS.xy,
  2273. input.probeOcclusion,
  2274. inputData.shadowMask );
  2275. #else
  2276. inputData.bakedGI = SAMPLE_GI(input.lightmapUVOrVertexSH.xy, SH, inputData.normalWS);
  2277. inputData.shadowMask = SAMPLE_SHADOWMASK(input.lightmapUVOrVertexSH.xy);
  2278. #endif
  2279. #ifdef ASE_BAKEDGI
  2280. inputData.bakedGI = BakedGI;
  2281. #endif
  2282. inputData.normalizedScreenSpaceUV = NormalizedScreenSpaceUV;
  2283. #if defined(DEBUG_DISPLAY)
  2284. #if defined(DYNAMICLIGHTMAP_ON)
  2285. inputData.dynamicLightmapUV = input.dynamicLightmapUV.xy;
  2286. #endif
  2287. #if defined(LIGHTMAP_ON)
  2288. inputData.staticLightmapUV = input.lightmapUVOrVertexSH.xy;
  2289. #else
  2290. inputData.vertexSH = SH;
  2291. #endif
  2292. #if defined(USE_APV_PROBE_OCCLUSION)
  2293. inputData.probeOcclusion = input.probeOcclusion;
  2294. #endif
  2295. #endif
  2296. #ifdef _DBUFFER
  2297. ApplyDecal(input.positionCS,
  2298. BaseColor,
  2299. Specular,
  2300. inputData.normalWS,
  2301. Metallic,
  2302. Occlusion,
  2303. Smoothness);
  2304. #endif
  2305. BRDFData brdfData;
  2306. InitializeBRDFData
  2307. (BaseColor, Metallic, Specular, Smoothness, Alpha, brdfData);
  2308. Light mainLight = GetMainLight(inputData.shadowCoord, inputData.positionWS, inputData.shadowMask);
  2309. half4 color;
  2310. MixRealtimeAndBakedGI(mainLight, inputData.normalWS, inputData.bakedGI, inputData.shadowMask);
  2311. color.rgb = GlobalIllumination(brdfData, inputData.bakedGI, Occlusion, inputData.positionWS, inputData.normalWS, inputData.viewDirectionWS);
  2312. color.a = Alpha;
  2313. #ifdef ASE_FINAL_COLOR_ALPHA_MULTIPLY
  2314. color.rgb *= color.a;
  2315. #endif
  2316. #ifdef ASE_DEPTH_WRITE_ON
  2317. outputDepth = DepthValue;
  2318. #endif
  2319. return BRDFDataToGbuffer(brdfData, inputData, Smoothness, Emission + color.rgb, Occlusion);
  2320. }
  2321. ENDHLSL
  2322. }
  2323. Pass
  2324. {
  2325. Name "SceneSelectionPass"
  2326. Tags { "LightMode"="SceneSelectionPass" }
  2327. Cull Off
  2328. AlphaToMask Off
  2329. HLSLPROGRAM
  2330. #pragma multi_compile_local_fragment _ALPHATEST_ON
  2331. #define _NORMAL_DROPOFF_TS 1
  2332. #define ASE_FOG 1
  2333. #define _NORMALMAP 1
  2334. #define ASE_VERSION 19701
  2335. #define ASE_SRP_VERSION 170003
  2336. #pragma vertex vert
  2337. #pragma fragment frag
  2338. #if defined(_SPECULAR_SETUP) && defined(_ASE_LIGHTING_SIMPLE)
  2339. #define _SPECULAR_COLOR 1
  2340. #endif
  2341. #define SCENESELECTIONPASS 1
  2342. #define ATTRIBUTES_NEED_NORMAL
  2343. #define ATTRIBUTES_NEED_TANGENT
  2344. #define SHADERPASS SHADERPASS_DEPTHONLY
  2345. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  2346. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
  2347. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  2348. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  2349. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl"
  2350. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
  2351. #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
  2352. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl"
  2353. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl"
  2354. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  2355. #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
  2356. #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
  2357. struct Attributes
  2358. {
  2359. float4 positionOS : POSITION;
  2360. float3 normalOS : NORMAL;
  2361. UNITY_VERTEX_INPUT_INSTANCE_ID
  2362. };
  2363. struct PackedVaryings
  2364. {
  2365. float4 positionCS : SV_POSITION;
  2366. UNITY_VERTEX_INPUT_INSTANCE_ID
  2367. UNITY_VERTEX_OUTPUT_STEREO
  2368. };
  2369. CBUFFER_START(UnityPerMaterial)
  2370. float4 _AlbedoColor;
  2371. float4 _AlbedoMap_ST;
  2372. float4 _NormalMap_ST;
  2373. float4 _MaskMap_ST;
  2374. #ifdef ASE_TRANSMISSION
  2375. float _TransmissionShadow;
  2376. #endif
  2377. #ifdef ASE_TRANSLUCENCY
  2378. float _TransStrength;
  2379. float _TransNormal;
  2380. float _TransScattering;
  2381. float _TransDirect;
  2382. float _TransAmbient;
  2383. float _TransShadow;
  2384. #endif
  2385. #ifdef ASE_TESSELLATION
  2386. float _TessPhongStrength;
  2387. float _TessValue;
  2388. float _TessMin;
  2389. float _TessMax;
  2390. float _TessEdgeLength;
  2391. float _TessMaxDisp;
  2392. #endif
  2393. CBUFFER_END
  2394. #ifdef SCENEPICKINGPASS
  2395. float4 _SelectionID;
  2396. #endif
  2397. #ifdef SCENESELECTIONPASS
  2398. int _ObjectId;
  2399. int _PassValue;
  2400. #endif
  2401. struct SurfaceDescription
  2402. {
  2403. float Alpha;
  2404. float AlphaClipThreshold;
  2405. };
  2406. PackedVaryings VertexFunction(Attributes input )
  2407. {
  2408. PackedVaryings output;
  2409. ZERO_INITIALIZE(PackedVaryings, output);
  2410. UNITY_SETUP_INSTANCE_ID(input);
  2411. UNITY_TRANSFER_INSTANCE_ID(input, output);
  2412. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
  2413. #ifdef ASE_ABSOLUTE_VERTEX_POS
  2414. float3 defaultVertexValue = input.positionOS.xyz;
  2415. #else
  2416. float3 defaultVertexValue = float3(0, 0, 0);
  2417. #endif
  2418. float3 vertexValue = defaultVertexValue;
  2419. #ifdef ASE_ABSOLUTE_VERTEX_POS
  2420. input.positionOS.xyz = vertexValue;
  2421. #else
  2422. input.positionOS.xyz += vertexValue;
  2423. #endif
  2424. input.normalOS = input.normalOS;
  2425. float3 positionWS = TransformObjectToWorld( input.positionOS.xyz );
  2426. output.positionCS = TransformWorldToHClip(positionWS);
  2427. return output;
  2428. }
  2429. #if defined(ASE_TESSELLATION)
  2430. struct VertexControl
  2431. {
  2432. float4 vertex : INTERNALTESSPOS;
  2433. float3 normalOS : NORMAL;
  2434. UNITY_VERTEX_INPUT_INSTANCE_ID
  2435. };
  2436. struct TessellationFactors
  2437. {
  2438. float edge[3] : SV_TessFactor;
  2439. float inside : SV_InsideTessFactor;
  2440. };
  2441. VertexControl vert ( Attributes input )
  2442. {
  2443. VertexControl output;
  2444. UNITY_SETUP_INSTANCE_ID(input);
  2445. UNITY_TRANSFER_INSTANCE_ID(input, output);
  2446. output.vertex = input.positionOS;
  2447. output.normalOS = input.normalOS;
  2448. return output;
  2449. }
  2450. TessellationFactors TessellationFunction (InputPatch<VertexControl,3> input)
  2451. {
  2452. TessellationFactors output;
  2453. float4 tf = 1;
  2454. float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
  2455. float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
  2456. #if defined(ASE_FIXED_TESSELLATION)
  2457. tf = FixedTess( tessValue );
  2458. #elif defined(ASE_DISTANCE_TESSELLATION)
  2459. tf = DistanceBasedTess(input[0].vertex, input[1].vertex, input[2].vertex, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
  2460. #elif defined(ASE_LENGTH_TESSELLATION)
  2461. tf = EdgeLengthBasedTess(input[0].vertex, input[1].vertex, input[2].vertex, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
  2462. #elif defined(ASE_LENGTH_CULL_TESSELLATION)
  2463. tf = EdgeLengthBasedTessCull(input[0].vertex, input[1].vertex, input[2].vertex, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
  2464. #endif
  2465. output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w;
  2466. return output;
  2467. }
  2468. [domain("tri")]
  2469. [partitioning("fractional_odd")]
  2470. [outputtopology("triangle_cw")]
  2471. [patchconstantfunc("TessellationFunction")]
  2472. [outputcontrolpoints(3)]
  2473. VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
  2474. {
  2475. return patch[id];
  2476. }
  2477. [domain("tri")]
  2478. PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
  2479. {
  2480. Attributes output = (Attributes) 0;
  2481. output.positionOS = patch[0].vertex * bary.x + patch[1].vertex * bary.y + patch[2].vertex * bary.z;
  2482. output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
  2483. #if defined(ASE_PHONG_TESSELLATION)
  2484. float3 pp[3];
  2485. for (int i = 0; i < 3; ++i)
  2486. pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].vertex.xyz, patch[i].normalOS));
  2487. float phongStrength = _TessPhongStrength;
  2488. output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz;
  2489. #endif
  2490. UNITY_TRANSFER_INSTANCE_ID(patch[0], output);
  2491. return VertexFunction(output);
  2492. }
  2493. #else
  2494. PackedVaryings vert ( Attributes input )
  2495. {
  2496. return VertexFunction( input );
  2497. }
  2498. #endif
  2499. half4 frag(PackedVaryings input ) : SV_TARGET
  2500. {
  2501. SurfaceDescription surfaceDescription = (SurfaceDescription)0;
  2502. surfaceDescription.Alpha = 1;
  2503. surfaceDescription.AlphaClipThreshold = 0.5;
  2504. #if _ALPHATEST_ON
  2505. float alphaClipThreshold = 0.01f;
  2506. #if ALPHA_CLIP_THRESHOLD
  2507. alphaClipThreshold = surfaceDescription.AlphaClipThreshold;
  2508. #endif
  2509. clip(surfaceDescription.Alpha - alphaClipThreshold);
  2510. #endif
  2511. half4 outColor = 0;
  2512. #ifdef SCENESELECTIONPASS
  2513. outColor = half4(_ObjectId, _PassValue, 1.0, 1.0);
  2514. #elif defined(SCENEPICKINGPASS)
  2515. outColor = _SelectionID;
  2516. #endif
  2517. return outColor;
  2518. }
  2519. ENDHLSL
  2520. }
  2521. Pass
  2522. {
  2523. Name "ScenePickingPass"
  2524. Tags { "LightMode"="Picking" }
  2525. AlphaToMask Off
  2526. HLSLPROGRAM
  2527. #pragma multi_compile_local_fragment _ALPHATEST_ON
  2528. #define _NORMAL_DROPOFF_TS 1
  2529. #define ASE_FOG 1
  2530. #define _NORMALMAP 1
  2531. #define ASE_VERSION 19701
  2532. #define ASE_SRP_VERSION 170003
  2533. #pragma vertex vert
  2534. #pragma fragment frag
  2535. #if defined(_SPECULAR_SETUP) && defined(_ASE_LIGHTING_SIMPLE)
  2536. #define _SPECULAR_COLOR 1
  2537. #endif
  2538. #define SCENEPICKINGPASS 1
  2539. #define ATTRIBUTES_NEED_NORMAL
  2540. #define ATTRIBUTES_NEED_TANGENT
  2541. #define SHADERPASS SHADERPASS_DEPTHONLY
  2542. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  2543. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
  2544. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  2545. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  2546. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl"
  2547. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
  2548. #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
  2549. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl"
  2550. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl"
  2551. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  2552. #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
  2553. #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
  2554. struct Attributes
  2555. {
  2556. float4 positionOS : POSITION;
  2557. float3 normalOS : NORMAL;
  2558. UNITY_VERTEX_INPUT_INSTANCE_ID
  2559. };
  2560. struct PackedVaryings
  2561. {
  2562. float4 positionCS : SV_POSITION;
  2563. UNITY_VERTEX_INPUT_INSTANCE_ID
  2564. UNITY_VERTEX_OUTPUT_STEREO
  2565. };
  2566. CBUFFER_START(UnityPerMaterial)
  2567. float4 _AlbedoColor;
  2568. float4 _AlbedoMap_ST;
  2569. float4 _NormalMap_ST;
  2570. float4 _MaskMap_ST;
  2571. #ifdef ASE_TRANSMISSION
  2572. float _TransmissionShadow;
  2573. #endif
  2574. #ifdef ASE_TRANSLUCENCY
  2575. float _TransStrength;
  2576. float _TransNormal;
  2577. float _TransScattering;
  2578. float _TransDirect;
  2579. float _TransAmbient;
  2580. float _TransShadow;
  2581. #endif
  2582. #ifdef ASE_TESSELLATION
  2583. float _TessPhongStrength;
  2584. float _TessValue;
  2585. float _TessMin;
  2586. float _TessMax;
  2587. float _TessEdgeLength;
  2588. float _TessMaxDisp;
  2589. #endif
  2590. CBUFFER_END
  2591. #ifdef SCENEPICKINGPASS
  2592. float4 _SelectionID;
  2593. #endif
  2594. #ifdef SCENESELECTIONPASS
  2595. int _ObjectId;
  2596. int _PassValue;
  2597. #endif
  2598. struct SurfaceDescription
  2599. {
  2600. float Alpha;
  2601. float AlphaClipThreshold;
  2602. };
  2603. PackedVaryings VertexFunction(Attributes input )
  2604. {
  2605. PackedVaryings output;
  2606. ZERO_INITIALIZE(PackedVaryings, output);
  2607. UNITY_SETUP_INSTANCE_ID(input);
  2608. UNITY_TRANSFER_INSTANCE_ID(input, output);
  2609. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
  2610. #ifdef ASE_ABSOLUTE_VERTEX_POS
  2611. float3 defaultVertexValue = input.positionOS.xyz;
  2612. #else
  2613. float3 defaultVertexValue = float3(0, 0, 0);
  2614. #endif
  2615. float3 vertexValue = defaultVertexValue;
  2616. #ifdef ASE_ABSOLUTE_VERTEX_POS
  2617. input.positionOS.xyz = vertexValue;
  2618. #else
  2619. input.positionOS.xyz += vertexValue;
  2620. #endif
  2621. input.normalOS = input.normalOS;
  2622. float3 positionWS = TransformObjectToWorld( input.positionOS.xyz );
  2623. output.positionCS = TransformWorldToHClip(positionWS);
  2624. return output;
  2625. }
  2626. #if defined(ASE_TESSELLATION)
  2627. struct VertexControl
  2628. {
  2629. float4 vertex : INTERNALTESSPOS;
  2630. float3 normalOS : NORMAL;
  2631. UNITY_VERTEX_INPUT_INSTANCE_ID
  2632. };
  2633. struct TessellationFactors
  2634. {
  2635. float edge[3] : SV_TessFactor;
  2636. float inside : SV_InsideTessFactor;
  2637. };
  2638. VertexControl vert ( Attributes input )
  2639. {
  2640. VertexControl output;
  2641. UNITY_SETUP_INSTANCE_ID(input);
  2642. UNITY_TRANSFER_INSTANCE_ID(input, output);
  2643. output.vertex = input.positionOS;
  2644. output.normalOS = input.normalOS;
  2645. return output;
  2646. }
  2647. TessellationFactors TessellationFunction (InputPatch<VertexControl,3> input)
  2648. {
  2649. TessellationFactors output;
  2650. float4 tf = 1;
  2651. float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
  2652. float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
  2653. #if defined(ASE_FIXED_TESSELLATION)
  2654. tf = FixedTess( tessValue );
  2655. #elif defined(ASE_DISTANCE_TESSELLATION)
  2656. tf = DistanceBasedTess(input[0].vertex, input[1].vertex, input[2].vertex, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
  2657. #elif defined(ASE_LENGTH_TESSELLATION)
  2658. tf = EdgeLengthBasedTess(input[0].vertex, input[1].vertex, input[2].vertex, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
  2659. #elif defined(ASE_LENGTH_CULL_TESSELLATION)
  2660. tf = EdgeLengthBasedTessCull(input[0].vertex, input[1].vertex, input[2].vertex, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
  2661. #endif
  2662. output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w;
  2663. return output;
  2664. }
  2665. [domain("tri")]
  2666. [partitioning("fractional_odd")]
  2667. [outputtopology("triangle_cw")]
  2668. [patchconstantfunc("TessellationFunction")]
  2669. [outputcontrolpoints(3)]
  2670. VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
  2671. {
  2672. return patch[id];
  2673. }
  2674. [domain("tri")]
  2675. PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
  2676. {
  2677. Attributes output = (Attributes) 0;
  2678. output.positionOS = patch[0].vertex * bary.x + patch[1].vertex * bary.y + patch[2].vertex * bary.z;
  2679. output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
  2680. #if defined(ASE_PHONG_TESSELLATION)
  2681. float3 pp[3];
  2682. for (int i = 0; i < 3; ++i)
  2683. pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].vertex.xyz, patch[i].normalOS));
  2684. float phongStrength = _TessPhongStrength;
  2685. output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz;
  2686. #endif
  2687. UNITY_TRANSFER_INSTANCE_ID(patch[0], output);
  2688. return VertexFunction(output);
  2689. }
  2690. #else
  2691. PackedVaryings vert ( Attributes input )
  2692. {
  2693. return VertexFunction( input );
  2694. }
  2695. #endif
  2696. half4 frag(PackedVaryings input ) : SV_TARGET
  2697. {
  2698. SurfaceDescription surfaceDescription = (SurfaceDescription)0;
  2699. surfaceDescription.Alpha = 1;
  2700. surfaceDescription.AlphaClipThreshold = 0.5;
  2701. #if _ALPHATEST_ON
  2702. float alphaClipThreshold = 0.01f;
  2703. #if ALPHA_CLIP_THRESHOLD
  2704. alphaClipThreshold = surfaceDescription.AlphaClipThreshold;
  2705. #endif
  2706. clip(surfaceDescription.Alpha - alphaClipThreshold);
  2707. #endif
  2708. half4 outColor = 0;
  2709. #ifdef SCENESELECTIONPASS
  2710. outColor = half4(_ObjectId, _PassValue, 1.0, 1.0);
  2711. #elif defined(SCENEPICKINGPASS)
  2712. outColor = _SelectionID;
  2713. #endif
  2714. return outColor;
  2715. }
  2716. ENDHLSL
  2717. }
  2718. Pass
  2719. {
  2720. Name "MotionVectors"
  2721. Tags { "LightMode"="MotionVectors" }
  2722. ColorMask RG
  2723. HLSLPROGRAM
  2724. #pragma multi_compile_local_fragment _ALPHATEST_ON
  2725. #define _NORMAL_DROPOFF_TS 1
  2726. #pragma multi_compile_instancing
  2727. #pragma multi_compile _ LOD_FADE_CROSSFADE
  2728. #define ASE_FOG 1
  2729. #define _NORMALMAP 1
  2730. #define ASE_VERSION 19701
  2731. #define ASE_SRP_VERSION 170003
  2732. #pragma vertex vert
  2733. #pragma fragment frag
  2734. #if defined(_SPECULAR_SETUP) && defined(_ASE_LIGHTING_SIMPLE)
  2735. #define _SPECULAR_COLOR 1
  2736. #endif
  2737. #define SHADERPASS SHADERPASS_MOTION_VECTORS
  2738. #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
  2739. #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"
  2740. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  2741. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
  2742. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  2743. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  2744. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl"
  2745. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
  2746. #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
  2747. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl"
  2748. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl"
  2749. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  2750. #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
  2751. #if defined(LOD_FADE_CROSSFADE)
  2752. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl"
  2753. #endif
  2754. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/MotionVectorsCommon.hlsl"
  2755. struct Attributes
  2756. {
  2757. float4 positionOS : POSITION;
  2758. float3 positionOld : TEXCOORD4;
  2759. #if _ADD_PRECOMPUTED_VELOCITY
  2760. float3 alembicMotionVector : TEXCOORD5;
  2761. #endif
  2762. UNITY_VERTEX_INPUT_INSTANCE_ID
  2763. };
  2764. struct PackedVaryings
  2765. {
  2766. float4 positionCS : SV_POSITION;
  2767. float4 positionCSNoJitter : TEXCOORD0;
  2768. float4 previousPositionCSNoJitter : TEXCOORD1;
  2769. UNITY_VERTEX_INPUT_INSTANCE_ID
  2770. UNITY_VERTEX_OUTPUT_STEREO
  2771. };
  2772. CBUFFER_START(UnityPerMaterial)
  2773. float4 _AlbedoColor;
  2774. float4 _AlbedoMap_ST;
  2775. float4 _NormalMap_ST;
  2776. float4 _MaskMap_ST;
  2777. #ifdef ASE_TRANSMISSION
  2778. float _TransmissionShadow;
  2779. #endif
  2780. #ifdef ASE_TRANSLUCENCY
  2781. float _TransStrength;
  2782. float _TransNormal;
  2783. float _TransScattering;
  2784. float _TransDirect;
  2785. float _TransAmbient;
  2786. float _TransShadow;
  2787. #endif
  2788. #ifdef ASE_TESSELLATION
  2789. float _TessPhongStrength;
  2790. float _TessValue;
  2791. float _TessMin;
  2792. float _TessMax;
  2793. float _TessEdgeLength;
  2794. float _TessMaxDisp;
  2795. #endif
  2796. CBUFFER_END
  2797. #ifdef SCENEPICKINGPASS
  2798. float4 _SelectionID;
  2799. #endif
  2800. #ifdef SCENESELECTIONPASS
  2801. int _ObjectId;
  2802. int _PassValue;
  2803. #endif
  2804. PackedVaryings VertexFunction( Attributes input )
  2805. {
  2806. PackedVaryings output = (PackedVaryings)0;
  2807. UNITY_SETUP_INSTANCE_ID(input);
  2808. UNITY_TRANSFER_INSTANCE_ID(input, output);
  2809. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
  2810. #ifdef ASE_ABSOLUTE_VERTEX_POS
  2811. float3 defaultVertexValue = input.positionOS.xyz;
  2812. #else
  2813. float3 defaultVertexValue = float3(0, 0, 0);
  2814. #endif
  2815. float3 vertexValue = defaultVertexValue;
  2816. #ifdef ASE_ABSOLUTE_VERTEX_POS
  2817. input.positionOS.xyz = vertexValue;
  2818. #else
  2819. input.positionOS.xyz += vertexValue;
  2820. #endif
  2821. VertexPositionInputs vertexInput = GetVertexPositionInputs( input.positionOS.xyz );
  2822. #if defined(APLICATION_SPACE_WARP_MOTION)
  2823. // We do not need jittered position in ASW
  2824. output.positionCSNoJitter = mul(_NonJitteredViewProjMatrix, mul(UNITY_MATRIX_M, input.positionOS));;
  2825. output.positionCS = output.positionCSNoJitter;
  2826. #else
  2827. // Jittered. Match the frame.
  2828. output.positionCS = vertexInput.positionCS;
  2829. output.positionCSNoJitter = mul( _NonJitteredViewProjMatrix, mul( UNITY_MATRIX_M, input.positionOS));
  2830. #endif
  2831. float4 prevPos = ( unity_MotionVectorsParams.x == 1 ) ? float4( input.positionOld, 1 ) : input.positionOS;
  2832. #if _ADD_PRECOMPUTED_VELOCITY
  2833. prevPos = prevPos - float4(input.alembicMotionVector, 0);
  2834. #endif
  2835. output.previousPositionCSNoJitter = mul( _PrevViewProjMatrix, mul( UNITY_PREV_MATRIX_M, prevPos ) );
  2836. // removed in ObjectMotionVectors.hlsl found in unity 6000.0.23 and higher
  2837. //ApplyMotionVectorZBias( output.positionCS );
  2838. return output;
  2839. }
  2840. PackedVaryings vert ( Attributes input )
  2841. {
  2842. return VertexFunction( input );
  2843. }
  2844. half4 frag( PackedVaryings input ) : SV_Target
  2845. {
  2846. UNITY_SETUP_INSTANCE_ID(input);
  2847. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( input );
  2848. float Alpha = 1;
  2849. float AlphaClipThreshold = 0.5;
  2850. #ifdef _ALPHATEST_ON
  2851. clip(Alpha - AlphaClipThreshold);
  2852. #endif
  2853. #if defined(LOD_FADE_CROSSFADE)
  2854. LODFadeCrossFade( input.positionCS );
  2855. #endif
  2856. #if defined(APLICATION_SPACE_WARP_MOTION)
  2857. return float4( CalcAswNdcMotionVectorFromCsPositions( input.positionCSNoJitter, input.previousPositionCSNoJitter ), 1 );
  2858. #else
  2859. return float4( CalcNdcMotionVectorFromCsPositions( input.positionCSNoJitter, input.previousPositionCSNoJitter ), 0, 0 );
  2860. #endif
  2861. }
  2862. ENDHLSL
  2863. }
  2864. }
  2865. CustomEditor "UnityEditor.ShaderGraphLitGUI"
  2866. FallBack "Hidden/Shader Graph/FallbackError"
  2867. Fallback Off
  2868. }
  2869. /*ASEBEGIN
  2870. Version=19701
  2871. Node;AmplifyShaderEditor.ColorNode;18;-445.4847,-402.4033;Inherit;False;Property;_AlbedoColor;Albedo Color;1;0;Create;True;0;0;0;False;0;False;1,1,1,0;1,1,1,0;True;True;0;6;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4;FLOAT3;5
  2872. Node;AmplifyShaderEditor.SamplerNode;1;-486.1925,-201.8055;Inherit;True;Property;_AlbedoMap;Albedo Map;0;0;Create;True;0;0;0;False;0;False;-1;None;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;6;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4;FLOAT3;5
  2873. Node;AmplifyShaderEditor.SimpleMultiplyOpNode;15;-107.1206,-175.716;Inherit;False;2;2;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;1;COLOR;0
  2874. Node;AmplifyShaderEditor.SamplerNode;2;-486.8851,-2.902534;Inherit;True;Property;_NormalMap;Normal Map;2;1;[Normal];Create;True;0;0;0;False;0;False;-1;None;None;True;0;True;bump;Auto;True;Object;-1;Auto;Texture2D;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;6;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4;FLOAT3;5
  2875. Node;AmplifyShaderEditor.SamplerNode;3;-482.6043,197.1131;Inherit;True;Property;_MaskMap;Mask Map;3;0;Create;True;0;0;0;False;0;False;-1;None;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;6;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4;FLOAT3;5
  2876. Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;20;0,0;Float;False;False;-1;2;UnityEditor.ShaderGraphLitGUI;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;;False;True;0;False;;False;False;False;False;False;False;False;False;False;True;False;0;False;;255;False;;255;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;False;True;1;False;;True;3;False;;True;True;0;False;;0;False;;True;4;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;UniversalMaterialType=Lit;True;5;True;12;all;0;False;True;1;1;False;;0;False;;0;1;False;;0;False;;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;;False;True;True;True;True;True;0;False;;False;False;False;False;False;False;False;True;False;0;False;;255;False;;255;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;False;True;1;False;;True;3;False;;True;True;0;False;;0;False;;True;0;False;False;0;;0;0;Standard;0;False;0
  2877. Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;21;0,0;Float;False;True;-1;2;UnityEditor.ShaderGraphLitGUI;0;12;Toby Fredson/Custom/Mesh Cross Fade;94348b07e5e8bab40bd6c8a1e3df54cd;True;Forward;0;1;Forward;21;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;;False;True;0;False;;False;False;False;False;False;False;False;False;False;True;False;0;False;;255;False;;255;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;False;True;1;False;;True;3;False;;True;True;0;False;;0;False;;True;4;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;UniversalMaterialType=Lit;True;5;True;12;all;0;False;True;1;1;False;;0;False;;1;1;False;;0;False;;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;True;True;True;True;0;False;;False;False;False;False;False;False;False;True;False;0;False;;255;False;;255;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;False;True;1;False;;True;3;False;;True;True;0;False;;0;False;;True;1;LightMode=UniversalForward;False;False;0;;0;0;Standard;45;Lighting Model;0;0;Workflow;1;0;Surface;0;0; Refraction Model;0;0; Blend;0;0;Two Sided;1;0;Alpha Clipping;1;0; Use Shadow Threshold;0;0;Fragment Normal Space,InvertActionOnDeselection;0;0;Forward Only;0;0;Transmission;0;0; Transmission Shadow;0.5,False,;0;Translucency;0;0; Translucency Strength;1,False,;0; Normal Distortion;0.5,False,;0; Scattering;2,False,;0; Direct;0.9,False,;0; Ambient;0.1,False,;0; Shadow;0.5,False,;0;Cast Shadows;1;0;Receive Shadows;1;0;Receive SSAO;1;0;Motion Vectors;1;0; Add Precomputed Velocity;0;0;GPU Instancing;1;0;LOD CrossFade;1;0;Built-in Fog;1;0;_FinalColorxAlpha;0;0;Meta Pass;1;0;Override Baked GI;0;0;Extra Pre Pass;0;0;Tessellation;0;0; Phong;0;0; Strength;0.5,False,;0; Type;0;0; Tess;16,False,;0; Min;10,False,;0; Max;25,False,;0; Edge Length;16,False,;0; Max Displacement;25,False,;0;Write Depth;0;0; Early Z;0;0;Vertex Position,InvertActionOnDeselection;1;0;Debug Display;0;0;Clear Coat;0;0;0;11;False;True;True;True;True;True;True;True;True;True;True;False;;False;0
  2878. Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;22;0,0;Float;False;False;-1;2;UnityEditor.ShaderGraphLitGUI;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;;False;True;0;False;;False;False;False;False;False;False;False;False;False;True;False;0;False;;255;False;;255;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;False;True;1;False;;True;3;False;;True;True;0;False;;0;False;;True;4;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;UniversalMaterialType=Lit;True;5;True;12;all;0;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;;False;False;False;True;False;False;False;False;0;False;;False;False;False;False;False;False;False;False;False;True;1;False;;True;3;False;;False;True;1;LightMode=ShadowCaster;False;False;0;;0;0;Standard;0;False;0
  2879. Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;23;0,0;Float;False;False;-1;2;UnityEditor.ShaderGraphLitGUI;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;;False;True;0;False;;False;False;False;False;False;False;False;False;False;True;False;0;False;;255;False;;255;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;False;True;1;False;;True;3;False;;True;True;0;False;;0;False;;True;4;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;UniversalMaterialType=Lit;True;5;True;12;all;0;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;;False;False;False;True;False;False;False;False;0;False;;False;False;False;False;False;False;False;False;False;True;1;False;;False;False;True;1;LightMode=DepthOnly;False;False;0;;0;0;Standard;0;False;0
  2880. Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;24;0,0;Float;False;False;-1;2;UnityEditor.ShaderGraphLitGUI;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;;False;True;0;False;;False;False;False;False;False;False;False;False;False;True;False;0;False;;255;False;;255;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;False;True;1;False;;True;3;False;;True;True;0;False;;0;False;;True;4;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;UniversalMaterialType=Lit;True;5;True;12;all;0;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;2;False;;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;1;LightMode=Meta;False;False;0;;0;0;Standard;0;False;0
  2881. Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;25;0,0;Float;False;False;-1;2;UnityEditor.ShaderGraphLitGUI;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;;False;True;0;False;;False;False;False;False;False;False;False;False;False;True;False;0;False;;255;False;;255;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;False;True;1;False;;True;3;False;;True;True;0;False;;0;False;;True;4;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;UniversalMaterialType=Lit;True;5;True;12;all;0;False;True;1;1;False;;0;False;;1;1;False;;0;False;;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;True;True;True;True;0;False;;False;False;False;False;False;False;False;False;False;True;1;False;;True;3;False;;True;True;0;False;;0;False;;True;1;LightMode=Universal2D;False;False;0;;0;0;Standard;0;False;0
  2882. Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;26;0,0;Float;False;False;-1;2;UnityEditor.ShaderGraphLitGUI;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;;False;True;0;False;;False;False;False;False;False;False;False;False;False;True;False;0;False;;255;False;;255;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;False;True;1;False;;True;3;False;;True;True;0;False;;0;False;;True;4;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;UniversalMaterialType=Lit;True;5;True;12;all;0;False;True;1;1;False;;0;False;;0;1;False;;0;False;;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;;True;3;False;;False;True;1;LightMode=DepthNormals;False;False;0;;0;0;Standard;0;False;0
  2883. Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;27;0,0;Float;False;False;-1;2;UnityEditor.ShaderGraphLitGUI;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;;False;True;0;False;;False;False;False;False;False;False;False;False;False;True;False;0;False;;255;False;;255;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;False;True;1;False;;True;3;False;;True;True;0;False;;0;False;;True;4;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;UniversalMaterialType=Lit;True;5;True;12;all;0;False;True;1;1;False;;0;False;;1;1;False;;0;False;;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;True;True;True;True;0;False;;False;False;False;False;False;False;False;True;False;0;False;;255;False;;255;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;False;True;1;False;;True;3;False;;True;True;0;False;;0;False;;True;1;LightMode=UniversalGBuffer;False;False;0;;0;0;Standard;0;False;0
  2884. Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;28;0,0;Float;False;False;-1;2;UnityEditor.ShaderGraphLitGUI;0;1;New Amplify Shader;94348b07e5e8bab40bd6c8a1e3df54cd;True;SceneSelectionPass;0;8;SceneSelectionPass;0;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;;False;True;0;False;;False;False;False;False;False;False;False;False;False;True;False;0;False;;255;False;;255;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;False;True;1;False;;True;3;False;;True;True;0;False;;0;False;;True;4;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;UniversalMaterialType=Lit;True;5;True;12;all;0;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;;False;True;2;False;;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;1;LightMode=SceneSelectionPass;False;False;0;;0;0;Standard;0;False;0
  2885. Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;29;0,0;Float;False;False;-1;2;UnityEditor.ShaderGraphLitGUI;0;1;New Amplify Shader;94348b07e5e8bab40bd6c8a1e3df54cd;True;ScenePickingPass;0;9;ScenePickingPass;0;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;;False;True;0;False;;False;False;False;False;False;False;False;False;False;True;False;0;False;;255;False;;255;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;False;True;1;False;;True;3;False;;True;True;0;False;;0;False;;True;4;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;UniversalMaterialType=Lit;True;5;True;12;all;0;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;1;LightMode=Picking;False;False;0;;0;0;Standard;0;False;0
  2886. Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;30;0,100;Float;False;False;-1;2;UnityEditor.ShaderGraphLitGUI;0;1;New Amplify Shader;94348b07e5e8bab40bd6c8a1e3df54cd;True;MotionVectors;0;10;MotionVectors;0;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;;False;True;0;False;;False;False;False;False;False;False;False;False;False;True;False;0;False;;255;False;;255;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;False;True;1;False;;True;3;False;;True;True;0;False;;0;False;;True;4;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;UniversalMaterialType=Lit;True;5;True;12;all;0;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;True;True;False;False;0;False;;False;False;False;False;False;False;False;False;False;False;False;False;True;1;LightMode=MotionVectors;False;False;0;;0;0;Standard;0;False;0
  2887. WireConnection;15;0;18;0
  2888. WireConnection;15;1;1;0
  2889. WireConnection;21;0;15;0
  2890. WireConnection;21;1;2;0
  2891. WireConnection;21;4;3;4
  2892. ASEEND*/
  2893. //CHKSM=ADF6C3146474BC8B93C236698BBA47E21B62EE86