Standard (Tessellation).shader 135 KB

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