Standard Decal.shader 158 KB

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