Standard (Tessellation).shader 137 KB

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