Unlit.shader 103 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946
  1. Shader /*ase_name*/ "Hidden/Universal/Unlit" /*end*/
  2. {
  3. Properties
  4. {
  5. /*ase_props*/
  6. //_TessPhongStrength( "Tess Phong Strength", Range( 0, 1 ) ) = 0.5
  7. //_TessValue( "Tess Max Tessellation", Range( 1, 32 ) ) = 16
  8. //_TessMin( "Tess Min Distance", Float ) = 10
  9. //_TessMax( "Tess Max Distance", Float ) = 25
  10. //_TessEdgeLength ( "Tess Edge length", Range( 2, 50 ) ) = 16
  11. //_TessMaxDisp( "Tess Max Displacement", Float ) = 25
  12. [HideInInspector] _QueueOffset("_QueueOffset", Float) = 0
  13. [HideInInspector] _QueueControl("_QueueControl", Float) = -1
  14. [HideInInspector][NoScaleOffset] unity_Lightmaps("unity_Lightmaps", 2DArray) = "" {}
  15. [HideInInspector][NoScaleOffset] unity_LightmapsInd("unity_LightmapsInd", 2DArray) = "" {}
  16. [HideInInspector][NoScaleOffset] unity_ShadowMasks("unity_ShadowMasks", 2DArray) = "" {}
  17. [HideInInspector][ToggleOff] _ReceiveShadows("Receive Shadows", Float) = 1.0
  18. }
  19. SubShader
  20. {
  21. /*ase_subshader_options:Name=Additional Options
  22. Option:Surface:Opaque,Transparent:Opaque
  23. Opaque:SetPropertyOnSubShader:RenderType,Opaque
  24. Opaque:SetPropertyOnSubShader:RenderQueue,Geometry
  25. Opaque:SetPropertyOnPass:Forward:ZWrite,On
  26. Opaque:HideOption: Blend
  27. Opaque:RemoveDefine:_SURFACE_TYPE_TRANSPARENT 1
  28. Opaque:HidePort:Forward:Alpha
  29. Opaque:RefreshOption:Alpha Clipping
  30. Opaque:ExcludePass:Universal2D
  31. Opaque:ExcludePass:DepthNormalsOnly
  32. Transparent:SetPropertyOnSubShader:RenderType,Transparent
  33. Transparent:SetPropertyOnSubShader:RenderQueue,Transparent
  34. Transparent:SetPropertyOnPass:Forward:ZWrite,Off
  35. Transparent:ShowOption: Blend
  36. Transparent:SetDefine:_SURFACE_TYPE_TRANSPARENT 1
  37. Transparent:ShowPort:Forward:Alpha
  38. Transparent:ExcludePass:Universal2D
  39. Transparent:ExcludePass:DepthNormalsOnly
  40. Option: Blend:Alpha,Premultiply,Additive,Multiply:Alpha
  41. Alpha:SetPropertyOnPass:Forward:BlendRGB,SrcAlpha,OneMinusSrcAlpha
  42. Premultiply:SetPropertyOnPass:Forward:BlendRGB,One,OneMinusSrcAlpha
  43. Additive:SetPropertyOnPass:Forward:BlendRGB,One,One
  44. Multiply:SetPropertyOnPass:Forward:BlendRGB,DstColor,Zero
  45. Alpha,Premultiply,Additive:SetPropertyOnPass:Forward:BlendAlpha,One,OneMinusSrcAlpha
  46. Multiply:SetPropertyOnPass:Forward:BlendAlpha,One,Zero
  47. disable:SetPropertyOnPass:Forward:BlendRGB,One,Zero
  48. disable:SetPropertyOnPass:Forward:BlendAlpha,One,Zero
  49. Option:Two Sided:On,Cull Back,Cull Front:Cull Back
  50. On:SetPropertyOnSubShader:CullMode,Off
  51. Cull Back:SetPropertyOnSubShader:CullMode,Back
  52. Cull Front:SetPropertyOnSubShader:CullMode,Front
  53. Option:Alpha Clipping:false,true:true
  54. true:ShowPort:Forward:Alpha
  55. true:ShowPort:Forward:Alpha Clip Threshold
  56. true?Cast Shadows=true:ShowOption: Use Shadow Threshold
  57. true?Surface=Opaque:SetPropertyOnSubShader:RenderType,TransparentCutout
  58. true?Surface=Opaque:SetPropertyOnSubShader:RenderQueue,AlphaTest
  59. true:SetDefine:Forward:pragma multi_compile_fragment _ALPHATEST_ON
  60. true:SetDefine:Meta:pragma multi_compile_fragment _ALPHATEST_ON
  61. true:SetDefine:Universal2D:pragma multi_compile_fragment _ALPHATEST_ON
  62. true:SetDefine:ShadowCaster:pragma multi_compile _ALPHATEST_ON
  63. true:SetDefine:DepthOnly:pragma multi_compile _ALPHATEST_ON
  64. true:SetDefine:DepthNormals:pragma multi_compile _ALPHATEST_ON
  65. false:HidePort:Forward:Alpha Clip Threshold
  66. false:SetOption: Use Shadow Threshold,0
  67. false:HideOption: Use Shadow Threshold
  68. false:RefreshOption:Surface
  69. false:RemoveDefine:Forward:pragma multi_compile_fragment _ALPHATEST_ON
  70. false:RemoveDefine:Meta:pragma multi_compile_fragment _ALPHATEST_ON
  71. false:RemoveDefine:Universal2D:pragma multi_compile_fragment _ALPHATEST_ON
  72. false:RemoveDefine:ShadowCaster:pragma multi_compile _ALPHATEST_ON
  73. false:RemoveDefine:DepthOnly:pragma multi_compile _ALPHATEST_ON
  74. false:RemoveDefine:DepthNormals:pragma multi_compile _ALPHATEST_ON
  75. Option: Use Shadow Threshold:false,true:false
  76. true:ShowPort:Forward:Alpha Clip Threshold Shadow
  77. true:SetDefine:_ALPHATEST_SHADOW_ON 1
  78. false,disable:RemoveDefine:_ALPHATEST_SHADOW_ON 1
  79. false,disable:HidePort:Forward:Alpha Clip Threshold Shadow
  80. Option:Forward Only:false,true:false
  81. false,disable:SetPropertyOnPass:Forward:ChangeTagValue,LightMode,UniversalForward
  82. false,disable:SetPropertyOnPass:DepthNormals:ChangeTagValue,LightMode,DepthNormals
  83. true:SetPropertyOnPass:Forward:ChangeTagValue,LightMode,UniversalForwardOnly
  84. true:SetPropertyOnPass:DepthNormals:ChangeTagValue,LightMode,DepthNormalsOnly
  85. Option:Cast Shadows:false,true:true
  86. true:IncludePass:ShadowCaster
  87. false,disable:ExcludePass:ShadowCaster
  88. true?Alpha Clipping=true:ShowOption: Use Shadow Threshold
  89. false:HideOption: Use Shadow Threshold
  90. Option:Receive Shadows:false,true:true
  91. true:SetDefine:Forward:pragma shader_feature_local _RECEIVE_SHADOWS_OFF
  92. false:RemoveDefine:Forward:pragma shader_feature_local _RECEIVE_SHADOWS_OFF
  93. Option:GPU Instancing:false,true:true
  94. true:SetDefine:Forward:pragma multi_compile_instancing
  95. true:SetDefine:ShadowCaster:pragma multi_compile_instancing
  96. true:SetDefine:DepthOnly:pragma multi_compile_instancing
  97. true:SetDefine:DepthNormals:pragma multi_compile_instancing
  98. false:RemoveDefine:Forward:pragma multi_compile_instancing
  99. false:RemoveDefine:ShadowCaster:pragma multi_compile_instancing
  100. false:RemoveDefine:DepthOnly:pragma multi_compile_instancing
  101. false:RemoveDefine:DepthNormals:pragma multi_compile_instancing
  102. true:SetDefine:Forward:pragma instancing_options renderinglayer
  103. false:RemoveDefine:Forward:pragma instancing_options renderinglayer
  104. Option:LOD CrossFade:false,true:true
  105. true:SetDefine:Forward:pragma multi_compile_fragment _ LOD_FADE_CROSSFADE
  106. true:SetDefine:ShadowCaster:pragma multi_compile_fragment _ LOD_FADE_CROSSFADE
  107. true:SetDefine:DepthOnly:pragma multi_compile_fragment _ LOD_FADE_CROSSFADE
  108. true:SetDefine:DepthNormals:pragma multi_compile_fragment _ LOD_FADE_CROSSFADE
  109. false:RemoveDefine:Forward:pragma multi_compile_fragment _ LOD_FADE_CROSSFADE
  110. false:RemoveDefine:ShadowCaster:pragma multi_compile_fragment _ LOD_FADE_CROSSFADE
  111. false:RemoveDefine:DepthOnly:pragma multi_compile_fragment _ LOD_FADE_CROSSFADE
  112. false:RemoveDefine:DepthNormals:pragma multi_compile_fragment _ LOD_FADE_CROSSFADE
  113. Option:Built-in Fog:false,true:true
  114. true:SetDefine:Forward:pragma multi_compile_fog
  115. false:RemoveDefine:Forward:pragma multi_compile_fog
  116. true:SetDefine:ASE_FOG 1
  117. false:RemoveDefine:ASE_FOG 1
  118. Option:Meta Pass:false,true:false
  119. true:IncludePass:Meta
  120. true:ShowPort:Forward:Baked Albedo
  121. true:ShowPort:Forward:Baked Emission
  122. false,disable:ExcludePass:Meta
  123. false:HidePort:Forward:Baked Albedo
  124. false:HidePort:Forward:Baked Emission
  125. Option:Extra Pre Pass:false,true:false
  126. true:IncludePass:ExtraPrePass
  127. false,disable:ExcludePass:ExtraPrePass
  128. Option:Tessellation:false,true:false
  129. true:SetDefine:ASE_TESSELLATION 1
  130. true:SetDefine:pragma require tessellation tessHW
  131. true:SetDefine:pragma hull HullFunction
  132. true:SetDefine:pragma domain DomainFunction
  133. true:ShowOption: Phong
  134. true:ShowOption: Type
  135. false,disable:RemoveDefine:ASE_TESSELLATION 1
  136. false,disable:RemoveDefine:pragma require tessellation tessHW
  137. false,disable:RemoveDefine:pragma hull HullFunction
  138. false,disable:RemoveDefine:pragma domain DomainFunction
  139. false,disable:HideOption: Phong
  140. false,disable:HideOption: Type
  141. Option: Phong:false,true:false
  142. true:SetDefine:ASE_PHONG_TESSELLATION
  143. false,disable:RemoveDefine:ASE_PHONG_TESSELLATION
  144. true:ShowOption: Strength
  145. false,disable:HideOption: Strength
  146. Field: Strength:Float:0.5:0:1:_TessPhongStrength
  147. Change:SetMaterialProperty:_TessPhongStrength
  148. Change:SetShaderProperty:_TessPhongStrength,_TessPhongStrength( "Phong Tess Strength", Range( 0, 1 ) ) = 0.5
  149. Inline,disable:SetShaderProperty:_TessPhongStrength,//_TessPhongStrength( "Phong Tess Strength", Range( 0, 1 ) ) = 0.5
  150. Option: Type:Fixed,Distance Based,Edge Length,Edge Length Cull:Fixed
  151. Fixed:SetDefine:ASE_FIXED_TESSELLATION
  152. Fixed,Distance Based:ShowOption: Tess
  153. Distance Based:SetDefine:ASE_DISTANCE_TESSELLATION
  154. Distance Based:ShowOption: Min
  155. Distance Based:ShowOption: Max
  156. Edge Length:SetDefine:ASE_LENGTH_TESSELLATION
  157. Edge Length,Edge Length Cull:ShowOption: Edge Length
  158. Edge Length Cull:SetDefine:ASE_LENGTH_CULL_TESSELLATION
  159. Edge Length Cull:ShowOption: Max Displacement
  160. disable,Distance Based,Edge Length,Edge Length Cull:RemoveDefine:ASE_FIXED_TESSELLATION
  161. disable,Fixed,Edge Length,Edge Length Cull:RemoveDefine:ASE_DISTANCE_TESSELLATION
  162. disable,Fixed,Distance Based,Edge Length Cull:RemoveDefine:ASE_LENGTH_TESSELLATION
  163. disable,Fixed,Distance Based,Edge Length:RemoveDefine:ASE_LENGTH_CULL_TESSELLATION
  164. disable,Edge Length,Edge Length Cull:HideOption: Tess
  165. disable,Fixed,Edge Length,Edge Length Cull:HideOption: Min
  166. disable,Fixed,Edge Length,Edge Length Cull:HideOption: Max
  167. disable,Fixed,Distance Based:HideOption: Edge Length
  168. disable,Fixed,Distance Based,Edge Length:HideOption: Max Displacement
  169. Field: Tess:Float:16:1:32:_TessValue
  170. Change:SetMaterialProperty:_TessValue
  171. Change:SetShaderProperty:_TessValue,_TessValue( "Max Tessellation", Range( 1, 32 ) ) = 16
  172. Inline,disable:SetShaderProperty:_TessValue,//_TessValue( "Max Tessellation", Range( 1, 32 ) ) = 16
  173. Field: Min:Float:10:_TessMin
  174. Change:SetMaterialProperty:_TessMin
  175. Change:SetShaderProperty:_TessMin,_TessMin( "Tess Min Distance", Float ) = 10
  176. Inline,disable:SetShaderProperty:_TessMin,//_TessMin( "Tess Min Distance", Float ) = 10
  177. Field: Max:Float:25:_TessMax
  178. Change:SetMaterialProperty:_TessMax
  179. Change:SetShaderProperty:_TessMax,_TessMax( "Tess Max Distance", Float ) = 25
  180. Inline,disable:SetShaderProperty:_TessMax,//_TessMax( "Tess Max Distance", Float ) = 25
  181. Field: Edge Length:Float:16:2:50:_TessEdgeLength
  182. Change:SetMaterialProperty:_TessEdgeLength
  183. Change:SetShaderProperty:_TessEdgeLength,_TessEdgeLength ( "Edge length", Range( 2, 50 ) ) = 16
  184. Inline,disable:SetShaderProperty:_TessEdgeLength,//_TessEdgeLength ( "Edge length", Range( 2, 50 ) ) = 16
  185. Field: Max Displacement:Float:25:_TessMaxDisp
  186. Change:SetMaterialProperty:_TessMaxDisp
  187. Change:SetShaderProperty:_TessMaxDisp,_TessMaxDisp( "Max Displacement", Float ) = 25
  188. Inline,disable:SetShaderProperty:_TessMaxDisp,//_TessMaxDisp( "Max Displacement", Float ) = 25
  189. Option:Write Depth:false,true:false
  190. true:SetDefine:ASE_DEPTH_WRITE_ON
  191. true:ShowOption: Early Z
  192. true:ShowPort:Forward:Depth Value
  193. false,disable:RemoveDefine:ASE_DEPTH_WRITE_ON
  194. false,disable:HideOption: Early Z
  195. false,disable:HidePort:Forward:Depth Value
  196. Option: Early Z:false,true:false
  197. true:SetDefine:ASE_EARLY_Z_DEPTH_OPTIMIZE
  198. false,disable:RemoveDefine:ASE_EARLY_Z_DEPTH_OPTIMIZE
  199. Option:Vertex Position,InvertActionOnDeselection:Absolute,Relative:Relative
  200. Absolute:SetDefine:ASE_ABSOLUTE_VERTEX_POS 1
  201. Absolute:SetPortName:Forward:5,Vertex Position
  202. Relative:SetPortName:Forward:5,Vertex Offset
  203. Absolute:SetPortName:ExtraPrePass:3,Vertex Position
  204. Relative:SetPortName:ExtraPrePass:3,Vertex Offset
  205. */
  206. Tags
  207. {
  208. "RenderPipeline" = "UniversalPipeline"
  209. "RenderType"="Opaque"
  210. "Queue"="Geometry+0"
  211. "UniversalMaterialType"="Unlit"
  212. }
  213. Cull Back
  214. AlphaToMask Off
  215. /*ase_stencil*/
  216. HLSLINCLUDE
  217. #pragma target 4.5
  218. #pragma prefer_hlslcc gles
  219. #pragma exclude_renderers d3d9 // ensure rendering platforms toggle list is visible
  220. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
  221. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Filtering.hlsl"
  222. #ifndef ASE_TESS_FUNCS
  223. #define ASE_TESS_FUNCS
  224. float4 FixedTess( float tessValue )
  225. {
  226. return tessValue;
  227. }
  228. float CalcDistanceTessFactor (float4 vertex, float minDist, float maxDist, float tess, float4x4 o2w, float3 cameraPos )
  229. {
  230. float3 wpos = mul(o2w,vertex).xyz;
  231. float dist = distance (wpos, cameraPos);
  232. float f = clamp(1.0 - (dist - minDist) / (maxDist - minDist), 0.01, 1.0) * tess;
  233. return f;
  234. }
  235. float4 CalcTriEdgeTessFactors (float3 triVertexFactors)
  236. {
  237. float4 tess;
  238. tess.x = 0.5 * (triVertexFactors.y + triVertexFactors.z);
  239. tess.y = 0.5 * (triVertexFactors.x + triVertexFactors.z);
  240. tess.z = 0.5 * (triVertexFactors.x + triVertexFactors.y);
  241. tess.w = (triVertexFactors.x + triVertexFactors.y + triVertexFactors.z) / 3.0f;
  242. return tess;
  243. }
  244. float CalcEdgeTessFactor (float3 wpos0, float3 wpos1, float edgeLen, float3 cameraPos, float4 scParams )
  245. {
  246. float dist = distance (0.5 * (wpos0+wpos1), cameraPos);
  247. float len = distance(wpos0, wpos1);
  248. float f = max(len * scParams.y / (edgeLen * dist), 1.0);
  249. return f;
  250. }
  251. float DistanceFromPlane (float3 pos, float4 plane)
  252. {
  253. float d = dot (float4(pos,1.0f), plane);
  254. return d;
  255. }
  256. bool WorldViewFrustumCull (float3 wpos0, float3 wpos1, float3 wpos2, float cullEps, float4 planes[6] )
  257. {
  258. float4 planeTest;
  259. planeTest.x = (( DistanceFromPlane(wpos0, planes[0]) > -cullEps) ? 1.0f : 0.0f ) +
  260. (( DistanceFromPlane(wpos1, planes[0]) > -cullEps) ? 1.0f : 0.0f ) +
  261. (( DistanceFromPlane(wpos2, planes[0]) > -cullEps) ? 1.0f : 0.0f );
  262. planeTest.y = (( DistanceFromPlane(wpos0, planes[1]) > -cullEps) ? 1.0f : 0.0f ) +
  263. (( DistanceFromPlane(wpos1, planes[1]) > -cullEps) ? 1.0f : 0.0f ) +
  264. (( DistanceFromPlane(wpos2, planes[1]) > -cullEps) ? 1.0f : 0.0f );
  265. planeTest.z = (( DistanceFromPlane(wpos0, planes[2]) > -cullEps) ? 1.0f : 0.0f ) +
  266. (( DistanceFromPlane(wpos1, planes[2]) > -cullEps) ? 1.0f : 0.0f ) +
  267. (( DistanceFromPlane(wpos2, planes[2]) > -cullEps) ? 1.0f : 0.0f );
  268. planeTest.w = (( DistanceFromPlane(wpos0, planes[3]) > -cullEps) ? 1.0f : 0.0f ) +
  269. (( DistanceFromPlane(wpos1, planes[3]) > -cullEps) ? 1.0f : 0.0f ) +
  270. (( DistanceFromPlane(wpos2, planes[3]) > -cullEps) ? 1.0f : 0.0f );
  271. return !all (planeTest);
  272. }
  273. float4 DistanceBasedTess( float4 v0, float4 v1, float4 v2, float tess, float minDist, float maxDist, float4x4 o2w, float3 cameraPos )
  274. {
  275. float3 f;
  276. f.x = CalcDistanceTessFactor (v0,minDist,maxDist,tess,o2w,cameraPos);
  277. f.y = CalcDistanceTessFactor (v1,minDist,maxDist,tess,o2w,cameraPos);
  278. f.z = CalcDistanceTessFactor (v2,minDist,maxDist,tess,o2w,cameraPos);
  279. return CalcTriEdgeTessFactors (f);
  280. }
  281. float4 EdgeLengthBasedTess( float4 v0, float4 v1, float4 v2, float edgeLength, float4x4 o2w, float3 cameraPos, float4 scParams )
  282. {
  283. float3 pos0 = mul(o2w,v0).xyz;
  284. float3 pos1 = mul(o2w,v1).xyz;
  285. float3 pos2 = mul(o2w,v2).xyz;
  286. float4 tess;
  287. tess.x = CalcEdgeTessFactor (pos1, pos2, edgeLength, cameraPos, scParams);
  288. tess.y = CalcEdgeTessFactor (pos2, pos0, edgeLength, cameraPos, scParams);
  289. tess.z = CalcEdgeTessFactor (pos0, pos1, edgeLength, cameraPos, scParams);
  290. tess.w = (tess.x + tess.y + tess.z) / 3.0f;
  291. return tess;
  292. }
  293. float4 EdgeLengthBasedTessCull( float4 v0, float4 v1, float4 v2, float edgeLength, float maxDisplacement, float4x4 o2w, float3 cameraPos, float4 scParams, float4 planes[6] )
  294. {
  295. float3 pos0 = mul(o2w,v0).xyz;
  296. float3 pos1 = mul(o2w,v1).xyz;
  297. float3 pos2 = mul(o2w,v2).xyz;
  298. float4 tess;
  299. if (WorldViewFrustumCull(pos0, pos1, pos2, maxDisplacement, planes))
  300. {
  301. tess = 0.0f;
  302. }
  303. else
  304. {
  305. tess.x = CalcEdgeTessFactor (pos1, pos2, edgeLength, cameraPos, scParams);
  306. tess.y = CalcEdgeTessFactor (pos2, pos0, edgeLength, cameraPos, scParams);
  307. tess.z = CalcEdgeTessFactor (pos0, pos1, edgeLength, cameraPos, scParams);
  308. tess.w = (tess.x + tess.y + tess.z) / 3.0f;
  309. }
  310. return tess;
  311. }
  312. #endif //ASE_TESS_FUNCS
  313. ENDHLSL
  314. /*ase_pass*/
  315. Pass
  316. {
  317. Name "ExtraPrePass"
  318. Tags{ }
  319. Blend One Zero
  320. Cull Back
  321. ZWrite On
  322. ZTest LEqual
  323. Offset 0,0
  324. ColorMask RGBA
  325. /*ase_stencil*/
  326. HLSLPROGRAM
  327. /*ase_srp_cond_begin:<140007*/
  328. #pragma multi_compile _ DOTS_INSTANCING_ON
  329. /*ase_srp_cond_end*/
  330. #pragma vertex vert
  331. #pragma fragment frag
  332. /*ase_srp_cond_begin:>=140007*/
  333. #if ASE_SRP_VERSION >=140007
  334. #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
  335. #endif
  336. /*ase_srp_cond_end*/
  337. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  338. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  339. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  340. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/UnityInstancing.hlsl"
  341. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  342. #if defined(LOD_FADE_CROSSFADE)
  343. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl"
  344. #endif
  345. /*ase_pragma*/
  346. struct Attributes
  347. {
  348. float4 positionOS : POSITION;
  349. float3 normalOS : NORMAL;
  350. /*ase_vdata:p=p;n=n*/
  351. UNITY_VERTEX_INPUT_INSTANCE_ID
  352. };
  353. struct PackedVaryings
  354. {
  355. float4 positionCS : SV_POSITION;
  356. float4 clipPosV : TEXCOORD0;
  357. float3 positionWS : TEXCOORD1;
  358. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  359. float4 shadowCoord : TEXCOORD2;
  360. #endif
  361. #if defined(ASE_FOG) || defined(_ADDITIONAL_LIGHTS_VERTEX)
  362. half4 fogFactorAndVertexLight : TEXCOORD3;
  363. #endif
  364. /*ase_interp(4,):sp=sp;wp=tc1;sc=tc2*/
  365. UNITY_VERTEX_INPUT_INSTANCE_ID
  366. UNITY_VERTEX_OUTPUT_STEREO
  367. };
  368. CBUFFER_START(UnityPerMaterial)
  369. #ifdef ASE_TESSELLATION
  370. float _TessPhongStrength;
  371. float _TessValue;
  372. float _TessMin;
  373. float _TessMax;
  374. float _TessEdgeLength;
  375. float _TessMaxDisp;
  376. #endif
  377. CBUFFER_END
  378. /*ase_globals*/
  379. /*ase_funcs*/
  380. PackedVaryings VertexFunction( Attributes input /*ase_vert_input*/ )
  381. {
  382. PackedVaryings output = (PackedVaryings)0;
  383. UNITY_SETUP_INSTANCE_ID(input);
  384. UNITY_TRANSFER_INSTANCE_ID(input, output);
  385. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
  386. /*ase_vert_code:input=Attributes;output=PackedVaryings*/
  387. #ifdef ASE_ABSOLUTE_VERTEX_POS
  388. float3 defaultVertexValue = input.positionOS.xyz;
  389. #else
  390. float3 defaultVertexValue = float3(0, 0, 0);
  391. #endif
  392. float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;3;-1;_VertexP*/defaultVertexValue/*end*/;
  393. #ifdef ASE_ABSOLUTE_VERTEX_POS
  394. input.positionOS.xyz = vertexValue;
  395. #else
  396. input.positionOS.xyz += vertexValue;
  397. #endif
  398. input.normalOS = /*ase_vert_out:Vertex Normal;Float3;4;-1;_NormalP*/input.normalOS/*end*/;
  399. VertexPositionInputs vertexInput = GetVertexPositionInputs( input.positionOS.xyz );
  400. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  401. output.shadowCoord = GetShadowCoord( vertexInput );
  402. #endif
  403. #if defined(ASE_FOG) || defined(_ADDITIONAL_LIGHTS_VERTEX)
  404. output.fogFactorAndVertexLight = 0;
  405. #if defined(ASE_FOG) && !defined(_FOG_FRAGMENT)
  406. output.fogFactorAndVertexLight.x = ComputeFogFactor(vertexInput.positionCS.z);
  407. #endif
  408. #ifdef _ADDITIONAL_LIGHTS_VERTEX
  409. half3 vertexLight = VertexLighting( vertexInput.positionWS, normalInput.normalWS );
  410. output.fogFactorAndVertexLight.yzw = vertexLight;
  411. #endif
  412. #endif
  413. output.positionCS = vertexInput.positionCS;
  414. output.clipPosV = vertexInput.positionCS;
  415. output.positionWS = vertexInput.positionWS;
  416. return output;
  417. }
  418. #if defined(ASE_TESSELLATION)
  419. struct VertexControl
  420. {
  421. float4 positionOS : INTERNALTESSPOS;
  422. float3 normalOS : NORMAL;
  423. /*ase_vcontrol*/
  424. UNITY_VERTEX_INPUT_INSTANCE_ID
  425. };
  426. struct TessellationFactors
  427. {
  428. float edge[3] : SV_TessFactor;
  429. float inside : SV_InsideTessFactor;
  430. };
  431. VertexControl vert ( Attributes input )
  432. {
  433. VertexControl output;
  434. UNITY_SETUP_INSTANCE_ID(input);
  435. UNITY_TRANSFER_INSTANCE_ID(input, output);
  436. output.positionOS = input.positionOS;
  437. output.normalOS = input.normalOS;
  438. /*ase_control_code:input=Attributes;output=VertexControl*/
  439. return output;
  440. }
  441. TessellationFactors TessellationFunction (InputPatch<VertexControl,3> input)
  442. {
  443. TessellationFactors output;
  444. float4 tf = 1;
  445. float tessValue = /*ase_inline_begin*/_TessValue/*ase_inline_end*/; float tessMin = /*ase_inline_begin*/_TessMin/*ase_inline_end*/; float tessMax = /*ase_inline_begin*/_TessMax/*ase_inline_end*/;
  446. float edgeLength = /*ase_inline_begin*/_TessEdgeLength/*ase_inline_end*/; float tessMaxDisp = /*ase_inline_begin*/_TessMaxDisp/*ase_inline_end*/;
  447. #if defined(ASE_FIXED_TESSELLATION)
  448. tf = FixedTess( tessValue );
  449. #elif defined(ASE_DISTANCE_TESSELLATION)
  450. tf = DistanceBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
  451. #elif defined(ASE_LENGTH_TESSELLATION)
  452. tf = EdgeLengthBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
  453. #elif defined(ASE_LENGTH_CULL_TESSELLATION)
  454. tf = EdgeLengthBasedTessCull(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
  455. #endif
  456. output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w;
  457. return output;
  458. }
  459. [domain("tri")]
  460. [partitioning("fractional_odd")]
  461. [outputtopology("triangle_cw")]
  462. [patchconstantfunc("TessellationFunction")]
  463. [outputcontrolpoints(3)]
  464. VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
  465. {
  466. return patch[id];
  467. }
  468. [domain("tri")]
  469. PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
  470. {
  471. Attributes output = (Attributes) 0;
  472. output.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z;
  473. output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
  474. /*ase_domain_code:patch=VertexControl;output=Attributes;bary=SV_DomainLocation*/
  475. #if defined(ASE_PHONG_TESSELLATION)
  476. float3 pp[3];
  477. for (int i = 0; i < 3; ++i)
  478. pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS));
  479. float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/;
  480. output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz;
  481. #endif
  482. UNITY_TRANSFER_INSTANCE_ID(patch[0], output);
  483. return VertexFunction(output);
  484. }
  485. #else
  486. PackedVaryings vert ( Attributes input )
  487. {
  488. return VertexFunction( input );
  489. }
  490. #endif
  491. half4 frag ( PackedVaryings input /*ase_frag_input*/ ) : SV_Target
  492. {
  493. UNITY_SETUP_INSTANCE_ID( input );
  494. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( input );
  495. /*ase_local_var:wp*/float3 WorldPosition = input.positionWS;
  496. /*ase_local_var:wvd*/float3 WorldViewDirection = GetWorldSpaceNormalizeViewDir( WorldPosition );
  497. /*ase_local_var:sc*/float4 ShadowCoords = float4( 0, 0, 0, 0 );
  498. /*ase_local_var:sp*/float4 ClipPos = input.clipPosV;
  499. /*ase_local_var:spu*/float4 ScreenPos = ComputeScreenPos( input.clipPosV );
  500. #if defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  501. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  502. ShadowCoords = input.shadowCoord;
  503. #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
  504. ShadowCoords = TransformWorldToShadowCoord( WorldPosition );
  505. #endif
  506. #endif
  507. InputData inputData = (InputData)0;
  508. inputData.positionWS = WorldPosition;
  509. inputData.viewDirectionWS = WorldViewDirection;
  510. #ifdef ASE_FOG
  511. inputData.fogCoord = InitializeInputDataFog(float4(inputData.positionWS, 1.0), input.fogFactorAndVertexLight.x);
  512. #endif
  513. #ifdef _ADDITIONAL_LIGHTS_VERTEX
  514. inputData.vertexLighting = input.fogFactorAndVertexLight.yzw;
  515. #endif
  516. /*ase_frag_code:input=PackedVaryings*/
  517. float3 Color = /*ase_frag_out:Color;Float3;0;-1;_ColorP*/float3( 0, 0, 0 )/*end*/;
  518. float Alpha = /*ase_frag_out:Alpha;Float;1;-1;_AlphaP*/1/*end*/;
  519. float AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;2;-1;_AlphaClipP*/0.5/*end*/;
  520. #ifdef _ALPHATEST_ON
  521. clip( Alpha - AlphaClipThreshold );
  522. #endif
  523. #ifdef ASE_FOG
  524. #ifdef TERRAIN_SPLAT_ADDPASS
  525. Color.rgb = MixFogColor(Color.rgb, half3(0,0,0), inputData.fogCoord);
  526. #else
  527. Color.rgb = MixFog(Color.rgb, inputData.fogCoord);
  528. #endif
  529. #endif
  530. #if defined(LOD_FADE_CROSSFADE)
  531. LODFadeCrossFade( input.positionCS );
  532. #endif
  533. return half4( Color, Alpha );
  534. }
  535. ENDHLSL
  536. }
  537. /*ase_pass*/
  538. Pass
  539. {
  540. /*ase_main_pass*/
  541. Name "Forward"
  542. Tags
  543. {
  544. "LightMode" = "UniversalForwardOnly"
  545. }
  546. Blend One Zero
  547. ZWrite On
  548. ZTest LEqual
  549. Offset 0,0
  550. ColorMask RGBA
  551. /*ase_stencil*/
  552. HLSLPROGRAM
  553. /*ase_srp_cond_begin:<140007*/
  554. #pragma multi_compile _ DOTS_INSTANCING_ON
  555. /*ase_srp_cond_end*/
  556. #pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
  557. #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
  558. /*ase_srp_cond_begin:<140007*/
  559. #pragma multi_compile_fragment _ _WRITE_RENDERING_LAYERS
  560. /*ase_srp_cond_end*/
  561. #pragma multi_compile _ DIRLIGHTMAP_COMBINED
  562. #pragma multi_compile _ LIGHTMAP_ON
  563. #pragma multi_compile _ DYNAMICLIGHTMAP_ON
  564. #pragma multi_compile_fragment _ DEBUG_DISPLAY
  565. #pragma vertex vert
  566. #pragma fragment frag
  567. #define SHADERPASS SHADERPASS_UNLIT
  568. /*ase_srp_cond_begin:>=140007*/
  569. #if ASE_SRP_VERSION >=140007
  570. #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
  571. #endif
  572. /*ase_srp_cond_end*/
  573. /*ase_srp_cond_begin:>=140007*/
  574. #if ASE_SRP_VERSION >=140007
  575. #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"
  576. #endif
  577. /*ase_srp_cond_end*/
  578. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  579. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
  580. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  581. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  582. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl"
  583. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
  584. /*ase_srp_cond_begin:>=140010*/
  585. #if ASE_SRP_VERSION >=140010
  586. #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
  587. #endif
  588. /*ase_srp_cond_end*/
  589. /*ase_srp_cond_begin:<140010*/
  590. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl"
  591. /*ase_srp_cond_end*/
  592. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  593. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DBuffer.hlsl"
  594. #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
  595. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Debug/Debugging3D.hlsl"
  596. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceData.hlsl"
  597. #if defined(LOD_FADE_CROSSFADE)
  598. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl"
  599. #endif
  600. /*ase_pragma*/
  601. #if defined(ASE_EARLY_Z_DEPTH_OPTIMIZE) && (SHADER_TARGET >= 45)
  602. #define ASE_SV_DEPTH SV_DepthLessEqual
  603. #define ASE_SV_POSITION_QUALIFIERS linear noperspective centroid
  604. #else
  605. #define ASE_SV_DEPTH SV_Depth
  606. #define ASE_SV_POSITION_QUALIFIERS
  607. #endif
  608. struct Attributes
  609. {
  610. float4 positionOS : POSITION;
  611. float3 normalOS : NORMAL;
  612. float4 texcoord : TEXCOORD0;
  613. float4 texcoord1 : TEXCOORD1;
  614. float4 texcoord2 : TEXCOORD2;
  615. /*ase_vdata:p=p;n=n;uv0=tc0;uv1=tc1;uv2=tc2*/
  616. UNITY_VERTEX_INPUT_INSTANCE_ID
  617. };
  618. struct PackedVaryings
  619. {
  620. ASE_SV_POSITION_QUALIFIERS float4 positionCS : SV_POSITION;
  621. float4 clipPosV : TEXCOORD0;
  622. float3 positionWS : TEXCOORD1;
  623. #if defined(ASE_FOG) || defined(_ADDITIONAL_LIGHTS_VERTEX)
  624. half4 fogFactorAndVertexLight : TEXCOORD2;
  625. #endif
  626. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  627. float4 shadowCoord : TEXCOORD3;
  628. #endif
  629. #if defined(LIGHTMAP_ON)
  630. float4 lightmapUVOrVertexSH : TEXCOORD4;
  631. #endif
  632. #if defined(DYNAMICLIGHTMAP_ON)
  633. float2 dynamicLightmapUV : TEXCOORD5;
  634. #endif
  635. /*ase_interp(6,):sp=sp;wp=tc1;sc=tc3*/
  636. UNITY_VERTEX_INPUT_INSTANCE_ID
  637. UNITY_VERTEX_OUTPUT_STEREO
  638. };
  639. CBUFFER_START(UnityPerMaterial)
  640. #ifdef ASE_TESSELLATION
  641. float _TessPhongStrength;
  642. float _TessValue;
  643. float _TessMin;
  644. float _TessMax;
  645. float _TessEdgeLength;
  646. float _TessMaxDisp;
  647. #endif
  648. CBUFFER_END
  649. /*ase_globals*/
  650. /*ase_funcs*/
  651. PackedVaryings VertexFunction( Attributes input /*ase_vert_input*/ )
  652. {
  653. PackedVaryings output = (PackedVaryings)0;
  654. UNITY_SETUP_INSTANCE_ID(input);
  655. UNITY_TRANSFER_INSTANCE_ID(input, output);
  656. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
  657. /*ase_vert_code:input=Attributes;output=PackedVaryings*/
  658. #ifdef ASE_ABSOLUTE_VERTEX_POS
  659. float3 defaultVertexValue = input.positionOS.xyz;
  660. #else
  661. float3 defaultVertexValue = float3(0, 0, 0);
  662. #endif
  663. float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;5;-1;_Vertex*/defaultVertexValue/*end*/;
  664. #ifdef ASE_ABSOLUTE_VERTEX_POS
  665. input.positionOS.xyz = vertexValue;
  666. #else
  667. input.positionOS.xyz += vertexValue;
  668. #endif
  669. input.normalOS = /*ase_vert_out:Vertex Normal;Float3;6;-1;_Normal*/input.normalOS/*end*/;
  670. VertexPositionInputs vertexInput = GetVertexPositionInputs( input.positionOS.xyz );
  671. #if defined(LIGHTMAP_ON)
  672. OUTPUT_LIGHTMAP_UV(input.texcoord1, unity_LightmapST, output.lightmapUVOrVertexSH.xy);
  673. #endif
  674. #if defined(DYNAMICLIGHTMAP_ON)
  675. output.dynamicLightmapUV.xy = input.texcoord2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
  676. #endif
  677. #if defined(ASE_FOG) || defined(_ADDITIONAL_LIGHTS_VERTEX)
  678. output.fogFactorAndVertexLight = 0;
  679. #if defined(ASE_FOG) && !defined(_FOG_FRAGMENT)
  680. output.fogFactorAndVertexLight.x = ComputeFogFactor(vertexInput.positionCS.z);
  681. #endif
  682. #ifdef _ADDITIONAL_LIGHTS_VERTEX
  683. half3 vertexLight = VertexLighting( vertexInput.positionWS, normalInput.normalWS );
  684. output.fogFactorAndVertexLight.yzw = vertexLight;
  685. #endif
  686. #endif
  687. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  688. output.shadowCoord = GetShadowCoord( vertexInput );
  689. #endif
  690. output.positionCS = vertexInput.positionCS;
  691. output.clipPosV = vertexInput.positionCS;
  692. output.positionWS = vertexInput.positionWS;
  693. return output;
  694. }
  695. #if defined(ASE_TESSELLATION)
  696. struct VertexControl
  697. {
  698. float4 positionOS : INTERNALTESSPOS;
  699. float3 normalOS : NORMAL;
  700. /*ase_vcontrol*/
  701. UNITY_VERTEX_INPUT_INSTANCE_ID
  702. };
  703. struct TessellationFactors
  704. {
  705. float edge[3] : SV_TessFactor;
  706. float inside : SV_InsideTessFactor;
  707. };
  708. VertexControl vert ( Attributes input )
  709. {
  710. VertexControl output;
  711. UNITY_SETUP_INSTANCE_ID(input);
  712. UNITY_TRANSFER_INSTANCE_ID(input, output);
  713. output.positionOS = input.positionOS;
  714. output.normalOS = input.normalOS;
  715. /*ase_control_code:input=Attributes;output=VertexControl*/
  716. return output;
  717. }
  718. TessellationFactors TessellationFunction (InputPatch<VertexControl,3> input)
  719. {
  720. TessellationFactors output;
  721. float4 tf = 1;
  722. float tessValue = /*ase_inline_begin*/_TessValue/*ase_inline_end*/; float tessMin = /*ase_inline_begin*/_TessMin/*ase_inline_end*/; float tessMax = /*ase_inline_begin*/_TessMax/*ase_inline_end*/;
  723. float edgeLength = /*ase_inline_begin*/_TessEdgeLength/*ase_inline_end*/; float tessMaxDisp = /*ase_inline_begin*/_TessMaxDisp/*ase_inline_end*/;
  724. #if defined(ASE_FIXED_TESSELLATION)
  725. tf = FixedTess( tessValue );
  726. #elif defined(ASE_DISTANCE_TESSELLATION)
  727. tf = DistanceBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
  728. #elif defined(ASE_LENGTH_TESSELLATION)
  729. tf = EdgeLengthBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
  730. #elif defined(ASE_LENGTH_CULL_TESSELLATION)
  731. tf = EdgeLengthBasedTessCull(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
  732. #endif
  733. output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w;
  734. return output;
  735. }
  736. [domain("tri")]
  737. [partitioning("fractional_odd")]
  738. [outputtopology("triangle_cw")]
  739. [patchconstantfunc("TessellationFunction")]
  740. [outputcontrolpoints(3)]
  741. VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
  742. {
  743. return patch[id];
  744. }
  745. [domain("tri")]
  746. PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
  747. {
  748. Attributes output = (Attributes) 0;
  749. output.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z;
  750. output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
  751. /*ase_domain_code:patch=VertexControl;output=Attributes;bary=SV_DomainLocation*/
  752. #if defined(ASE_PHONG_TESSELLATION)
  753. float3 pp[3];
  754. for (int i = 0; i < 3; ++i)
  755. pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS));
  756. float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/;
  757. output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz;
  758. #endif
  759. UNITY_TRANSFER_INSTANCE_ID(patch[0], output);
  760. return VertexFunction(output);
  761. }
  762. #else
  763. PackedVaryings vert ( Attributes input )
  764. {
  765. return VertexFunction( input );
  766. }
  767. #endif
  768. half4 frag ( PackedVaryings input
  769. #ifdef ASE_DEPTH_WRITE_ON
  770. ,out float outputDepth : ASE_SV_DEPTH
  771. #endif
  772. #ifdef _WRITE_RENDERING_LAYERS
  773. , out float4 outRenderingLayers : SV_Target1
  774. #endif
  775. /*ase_frag_input*/ ) : SV_Target
  776. {
  777. UNITY_SETUP_INSTANCE_ID(input);
  778. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
  779. #if defined(LOD_FADE_CROSSFADE)
  780. LODFadeCrossFade( input.positionCS );
  781. #endif
  782. /*ase_local_var:wp*/float3 WorldPosition = input.positionWS;
  783. /*ase_local_var:wvd*/float3 WorldViewDirection = GetWorldSpaceNormalizeViewDir( WorldPosition );
  784. /*ase_local_var:sc*/float4 ShadowCoords = float4( 0, 0, 0, 0 );
  785. /*ase_local_var:sp*/float4 ClipPos = input.clipPosV;
  786. /*ase_local_var:spu*/float4 ScreenPos = ComputeScreenPos( input.clipPosV );
  787. float2 NormalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS);
  788. #if defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  789. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  790. ShadowCoords = input.shadowCoord;
  791. #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
  792. ShadowCoords = TransformWorldToShadowCoord( WorldPosition );
  793. #endif
  794. #endif
  795. /*ase_frag_code:input=PackedVaryings*/
  796. float3 BakedAlbedo = /*ase_frag_out:Baked Albedo;Float3;0;-1;_Albedo*/0/*end*/;
  797. float3 BakedEmission = /*ase_frag_out:Baked Emission;Float3;1;-1;_Emission*/0/*end*/;
  798. float3 Color = /*ase_frag_out:Color;Float3;2;-1;_Color*/float3(0.5, 0.5, 0.5)/*end*/;
  799. float Alpha = /*ase_frag_out:Alpha;Float;3;-1;_Alpha*/1/*end*/;
  800. float AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;4;-1;_AlphaClip*/0.5/*end*/;
  801. float AlphaClipThresholdShadow = /*ase_frag_out:Alpha Clip Threshold Shadow;Float;7;-1;_AlphaClipShadow*/0.5/*end*/;
  802. #ifdef ASE_DEPTH_WRITE_ON
  803. float DepthValue = /*ase_frag_out:Depth Value;Float;17;-1;_DepthValue*/input.positionCS.z/*end*/;
  804. #endif
  805. #ifdef _ALPHATEST_ON
  806. clip(Alpha - AlphaClipThreshold);
  807. #endif
  808. InputData inputData = (InputData)0;
  809. inputData.positionWS = WorldPosition;
  810. inputData.viewDirectionWS = WorldViewDirection;
  811. #ifdef ASE_FOG
  812. inputData.fogCoord = InitializeInputDataFog(float4(inputData.positionWS, 1.0), input.fogFactorAndVertexLight.x);
  813. #endif
  814. #ifdef _ADDITIONAL_LIGHTS_VERTEX
  815. inputData.vertexLighting = input.fogFactorAndVertexLight.yzw;
  816. #endif
  817. inputData.normalizedScreenSpaceUV = NormalizedScreenSpaceUV;
  818. #if defined(_DBUFFER)
  819. ApplyDecalToBaseColor(input.positionCS, Color);
  820. #endif
  821. #ifdef ASE_FOG
  822. #ifdef TERRAIN_SPLAT_ADDPASS
  823. Color.rgb = MixFogColor(Color.rgb, half3(0,0,0), inputData.fogCoord);
  824. #else
  825. Color.rgb = MixFog(Color.rgb, inputData.fogCoord);
  826. #endif
  827. #endif
  828. #ifdef ASE_DEPTH_WRITE_ON
  829. outputDepth = DepthValue;
  830. #endif
  831. #ifdef _WRITE_RENDERING_LAYERS
  832. uint renderingLayers = GetMeshRenderingLayer();
  833. outRenderingLayers = float4( EncodeMeshRenderingLayer( renderingLayers ), 0, 0, 0 );
  834. #endif
  835. return half4( Color, Alpha );
  836. }
  837. ENDHLSL
  838. }
  839. /*ase_pass*/
  840. Pass
  841. {
  842. /*ase_hide_pass*/
  843. Name "ShadowCaster"
  844. Tags
  845. {
  846. "LightMode" = "ShadowCaster"
  847. }
  848. ZWrite On
  849. ZTest LEqual
  850. AlphaToMask Off
  851. ColorMask 0
  852. HLSLPROGRAM
  853. /*ase_srp_cond_begin:<140007*/
  854. #pragma multi_compile _ DOTS_INSTANCING_ON
  855. /*ase_srp_cond_end*/
  856. #pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW
  857. #pragma vertex vert
  858. #pragma fragment frag
  859. #define SHADERPASS SHADERPASS_SHADOWCASTER
  860. /*ase_srp_cond_begin:>=140007*/
  861. #if ASE_SRP_VERSION >=140007
  862. #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
  863. #endif
  864. /*ase_srp_cond_end*/
  865. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  866. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  867. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  868. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  869. #if defined(LOD_FADE_CROSSFADE)
  870. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl"
  871. #endif
  872. /*ase_pragma*/
  873. #if defined(ASE_EARLY_Z_DEPTH_OPTIMIZE) && (SHADER_TARGET >= 45)
  874. #define ASE_SV_DEPTH SV_DepthLessEqual
  875. #define ASE_SV_POSITION_QUALIFIERS linear noperspective centroid
  876. #else
  877. #define ASE_SV_DEPTH SV_Depth
  878. #define ASE_SV_POSITION_QUALIFIERS
  879. #endif
  880. struct Attributes
  881. {
  882. float4 positionOS : POSITION;
  883. float3 normalOS : NORMAL;
  884. /*ase_vdata:p=p;n=n*/
  885. UNITY_VERTEX_INPUT_INSTANCE_ID
  886. };
  887. struct PackedVaryings
  888. {
  889. ASE_SV_POSITION_QUALIFIERS float4 positionCS : SV_POSITION;
  890. float4 clipPosV : TEXCOORD0;
  891. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  892. float3 positionWS : TEXCOORD1;
  893. #endif
  894. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  895. float4 shadowCoord : TEXCOORD2;
  896. #endif
  897. /*ase_interp(3,):sp=sp;wp=tc1;sc=tc2*/
  898. UNITY_VERTEX_INPUT_INSTANCE_ID
  899. UNITY_VERTEX_OUTPUT_STEREO
  900. };
  901. CBUFFER_START(UnityPerMaterial)
  902. #ifdef ASE_TESSELLATION
  903. float _TessPhongStrength;
  904. float _TessValue;
  905. float _TessMin;
  906. float _TessMax;
  907. float _TessEdgeLength;
  908. float _TessMaxDisp;
  909. #endif
  910. CBUFFER_END
  911. /*ase_globals*/
  912. /*ase_funcs*/
  913. float3 _LightDirection;
  914. float3 _LightPosition;
  915. PackedVaryings VertexFunction( Attributes input/*ase_vert_input*/ )
  916. {
  917. PackedVaryings output;
  918. UNITY_SETUP_INSTANCE_ID(input);
  919. UNITY_TRANSFER_INSTANCE_ID(input, output);
  920. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( output );
  921. /*ase_vert_code:input=Attributes;output=PackedVaryings*/
  922. #ifdef ASE_ABSOLUTE_VERTEX_POS
  923. float3 defaultVertexValue = input.positionOS.xyz;
  924. #else
  925. float3 defaultVertexValue = float3(0, 0, 0);
  926. #endif
  927. float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;2;-1;_Vertex*/defaultVertexValue/*end*/;
  928. #ifdef ASE_ABSOLUTE_VERTEX_POS
  929. input.positionOS.xyz = vertexValue;
  930. #else
  931. input.positionOS.xyz += vertexValue;
  932. #endif
  933. input.normalOS = /*ase_vert_out:Vertex Normal;Float3;3;-1;_Normal*/input.normalOS/*end*/;
  934. float3 positionWS = TransformObjectToWorld( input.positionOS.xyz );
  935. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  936. output.positionWS = positionWS;
  937. #endif
  938. float3 normalWS = TransformObjectToWorldDir(input.normalOS);
  939. #if _CASTING_PUNCTUAL_LIGHT_SHADOW
  940. float3 lightDirectionWS = normalize(_LightPosition - positionWS);
  941. #else
  942. float3 lightDirectionWS = _LightDirection;
  943. #endif
  944. float4 positionCS = TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS, lightDirectionWS));
  945. #if UNITY_REVERSED_Z
  946. positionCS.z = min(positionCS.z, UNITY_NEAR_CLIP_VALUE);
  947. #else
  948. positionCS.z = max(positionCS.z, UNITY_NEAR_CLIP_VALUE);
  949. #endif
  950. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  951. VertexPositionInputs vertexInput = (VertexPositionInputs)0;
  952. vertexInput.positionWS = positionWS;
  953. vertexInput.positionCS = positionCS;
  954. output.shadowCoord = GetShadowCoord( vertexInput );
  955. #endif
  956. output.positionCS = positionCS;
  957. output.clipPosV = positionCS;
  958. return output;
  959. }
  960. #if defined(ASE_TESSELLATION)
  961. struct VertexControl
  962. {
  963. float4 positionOS : INTERNALTESSPOS;
  964. float3 normalOS : NORMAL;
  965. /*ase_vcontrol*/
  966. UNITY_VERTEX_INPUT_INSTANCE_ID
  967. };
  968. struct TessellationFactors
  969. {
  970. float edge[3] : SV_TessFactor;
  971. float inside : SV_InsideTessFactor;
  972. };
  973. VertexControl vert ( Attributes input )
  974. {
  975. VertexControl output;
  976. UNITY_SETUP_INSTANCE_ID(input);
  977. UNITY_TRANSFER_INSTANCE_ID(input, output);
  978. output.positionOS = input.positionOS;
  979. output.normalOS = input.normalOS;
  980. /*ase_control_code:input=Attributes;output=VertexControl*/
  981. return output;
  982. }
  983. TessellationFactors TessellationFunction (InputPatch<VertexControl,3> input)
  984. {
  985. TessellationFactors output;
  986. float4 tf = 1;
  987. float tessValue = /*ase_inline_begin*/_TessValue/*ase_inline_end*/; float tessMin = /*ase_inline_begin*/_TessMin/*ase_inline_end*/; float tessMax = /*ase_inline_begin*/_TessMax/*ase_inline_end*/;
  988. float edgeLength = /*ase_inline_begin*/_TessEdgeLength/*ase_inline_end*/; float tessMaxDisp = /*ase_inline_begin*/_TessMaxDisp/*ase_inline_end*/;
  989. #if defined(ASE_FIXED_TESSELLATION)
  990. tf = FixedTess( tessValue );
  991. #elif defined(ASE_DISTANCE_TESSELLATION)
  992. tf = DistanceBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
  993. #elif defined(ASE_LENGTH_TESSELLATION)
  994. tf = EdgeLengthBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
  995. #elif defined(ASE_LENGTH_CULL_TESSELLATION)
  996. tf = EdgeLengthBasedTessCull(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
  997. #endif
  998. output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w;
  999. return output;
  1000. }
  1001. [domain("tri")]
  1002. [partitioning("fractional_odd")]
  1003. [outputtopology("triangle_cw")]
  1004. [patchconstantfunc("TessellationFunction")]
  1005. [outputcontrolpoints(3)]
  1006. VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
  1007. {
  1008. return patch[id];
  1009. }
  1010. [domain("tri")]
  1011. PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
  1012. {
  1013. Attributes output = (Attributes) 0;
  1014. output.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z;
  1015. output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
  1016. /*ase_domain_code:patch=VertexControl;output=Attributes;bary=SV_DomainLocation*/
  1017. #if defined(ASE_PHONG_TESSELLATION)
  1018. float3 pp[3];
  1019. for (int i = 0; i < 3; ++i)
  1020. pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS));
  1021. float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/;
  1022. output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz;
  1023. #endif
  1024. UNITY_TRANSFER_INSTANCE_ID(patch[0], output);
  1025. return VertexFunction(output);
  1026. }
  1027. #else
  1028. PackedVaryings vert ( Attributes input )
  1029. {
  1030. return VertexFunction( input );
  1031. }
  1032. #endif
  1033. half4 frag(PackedVaryings input
  1034. #ifdef ASE_DEPTH_WRITE_ON
  1035. ,out float outputDepth : ASE_SV_DEPTH
  1036. #endif
  1037. /*ase_frag_input*/ ) : SV_Target
  1038. {
  1039. UNITY_SETUP_INSTANCE_ID( input );
  1040. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( input );
  1041. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1042. /*ase_local_var:wp*/float3 WorldPosition = input.positionWS;
  1043. #endif
  1044. /*ase_local_var:sc*/float4 ShadowCoords = float4( 0, 0, 0, 0 );
  1045. /*ase_local_var:sp*/float4 ClipPos = input.clipPosV;
  1046. /*ase_local_var:spu*/float4 ScreenPos = ComputeScreenPos( input.clipPosV );
  1047. #if defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1048. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  1049. ShadowCoords = input.shadowCoord;
  1050. #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
  1051. ShadowCoords = TransformWorldToShadowCoord( WorldPosition );
  1052. #endif
  1053. #endif
  1054. /*ase_frag_code:input=PackedVaryings*/
  1055. float Alpha = /*ase_frag_out:Alpha;Float;0;-1;_Alpha*/1/*end*/;
  1056. float AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;1;-1;_AlphaClip*/0.5/*end*/;
  1057. float AlphaClipThresholdShadow = /*ase_frag_out:Alpha Clip Threshold Shadow;Float;4;-1;_AlphaClipShadow*/0.5/*end*/;
  1058. #ifdef ASE_DEPTH_WRITE_ON
  1059. float DepthValue = /*ase_frag_out:Depth Value;Float;17;-1;_DepthValue*/input.positionCS.z/*end*/;
  1060. #endif
  1061. #ifdef _ALPHATEST_ON
  1062. #ifdef _ALPHATEST_SHADOW_ON
  1063. clip(Alpha - AlphaClipThresholdShadow);
  1064. #else
  1065. clip(Alpha - AlphaClipThreshold);
  1066. #endif
  1067. #endif
  1068. #if defined(LOD_FADE_CROSSFADE)
  1069. LODFadeCrossFade( input.positionCS );
  1070. #endif
  1071. #ifdef ASE_DEPTH_WRITE_ON
  1072. outputDepth = DepthValue;
  1073. #endif
  1074. return 0;
  1075. }
  1076. ENDHLSL
  1077. }
  1078. /*ase_pass*/
  1079. Pass
  1080. {
  1081. /*ase_hide_pass*/
  1082. Name "DepthOnly"
  1083. Tags
  1084. {
  1085. "LightMode" = "DepthOnly"
  1086. }
  1087. ZWrite On
  1088. ColorMask R
  1089. AlphaToMask Off
  1090. HLSLPROGRAM
  1091. /*ase_srp_cond_begin:<140007*/
  1092. #pragma multi_compile _ DOTS_INSTANCING_ON
  1093. /*ase_srp_cond_end*/
  1094. #pragma vertex vert
  1095. #pragma fragment frag
  1096. /*ase_srp_cond_begin:>=140007*/
  1097. #if ASE_SRP_VERSION >=140007
  1098. #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
  1099. #endif
  1100. /*ase_srp_cond_end*/
  1101. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  1102. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  1103. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  1104. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  1105. #if defined(LOD_FADE_CROSSFADE)
  1106. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl"
  1107. #endif
  1108. /*ase_pragma*/
  1109. #if defined(ASE_EARLY_Z_DEPTH_OPTIMIZE) && (SHADER_TARGET >= 45)
  1110. #define ASE_SV_DEPTH SV_DepthLessEqual
  1111. #define ASE_SV_POSITION_QUALIFIERS linear noperspective centroid
  1112. #else
  1113. #define ASE_SV_DEPTH SV_Depth
  1114. #define ASE_SV_POSITION_QUALIFIERS
  1115. #endif
  1116. struct Attributes
  1117. {
  1118. float4 positionOS : POSITION;
  1119. float3 normalOS : NORMAL;
  1120. /*ase_vdata:p=p;n=n*/
  1121. UNITY_VERTEX_INPUT_INSTANCE_ID
  1122. };
  1123. struct PackedVaryings
  1124. {
  1125. ASE_SV_POSITION_QUALIFIERS float4 positionCS : SV_POSITION;
  1126. float4 clipPosV : TEXCOORD0;
  1127. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1128. float3 positionWS : TEXCOORD1;
  1129. #endif
  1130. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1131. float4 shadowCoord : TEXCOORD2;
  1132. #endif
  1133. /*ase_interp(3,):sp=sp;wp=tc1;sc=tc2*/
  1134. UNITY_VERTEX_INPUT_INSTANCE_ID
  1135. UNITY_VERTEX_OUTPUT_STEREO
  1136. };
  1137. CBUFFER_START(UnityPerMaterial)
  1138. #ifdef ASE_TESSELLATION
  1139. float _TessPhongStrength;
  1140. float _TessValue;
  1141. float _TessMin;
  1142. float _TessMax;
  1143. float _TessEdgeLength;
  1144. float _TessMaxDisp;
  1145. #endif
  1146. CBUFFER_END
  1147. /*ase_globals*/
  1148. /*ase_funcs*/
  1149. PackedVaryings VertexFunction( Attributes input /*ase_vert_input*/ )
  1150. {
  1151. PackedVaryings output = (PackedVaryings)0;
  1152. UNITY_SETUP_INSTANCE_ID(input);
  1153. UNITY_TRANSFER_INSTANCE_ID(input, output);
  1154. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
  1155. /*ase_vert_code:input=Attributes;output=PackedVaryings*/
  1156. #ifdef ASE_ABSOLUTE_VERTEX_POS
  1157. float3 defaultVertexValue = input.positionOS.xyz;
  1158. #else
  1159. float3 defaultVertexValue = float3(0, 0, 0);
  1160. #endif
  1161. float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;2;-1;_Vertex*/defaultVertexValue/*end*/;
  1162. #ifdef ASE_ABSOLUTE_VERTEX_POS
  1163. input.positionOS.xyz = vertexValue;
  1164. #else
  1165. input.positionOS.xyz += vertexValue;
  1166. #endif
  1167. input.normalOS = /*ase_vert_out:Vertex Normal;Float3;3;-1;_Normal*/input.normalOS/*end*/;
  1168. VertexPositionInputs vertexInput = GetVertexPositionInputs( input.positionOS.xyz );
  1169. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1170. output.positionWS = vertexInput.positionWS;
  1171. #endif
  1172. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1173. output.shadowCoord = GetShadowCoord( vertexInput );
  1174. #endif
  1175. output.positionCS = vertexInput.positionCS;
  1176. output.clipPosV = vertexInput.positionCS;
  1177. return output;
  1178. }
  1179. #if defined(ASE_TESSELLATION)
  1180. struct VertexControl
  1181. {
  1182. float4 positionOS : INTERNALTESSPOS;
  1183. float3 normalOS : NORMAL;
  1184. /*ase_vcontrol*/
  1185. UNITY_VERTEX_INPUT_INSTANCE_ID
  1186. };
  1187. struct TessellationFactors
  1188. {
  1189. float edge[3] : SV_TessFactor;
  1190. float inside : SV_InsideTessFactor;
  1191. };
  1192. VertexControl vert ( Attributes input )
  1193. {
  1194. VertexControl output;
  1195. UNITY_SETUP_INSTANCE_ID(input);
  1196. UNITY_TRANSFER_INSTANCE_ID(input, output);
  1197. output.positionOS = input.positionOS;
  1198. output.normalOS = input.normalOS;
  1199. /*ase_control_code:input=Attributes;output=VertexControl*/
  1200. return output;
  1201. }
  1202. TessellationFactors TessellationFunction (InputPatch<VertexControl,3> input)
  1203. {
  1204. TessellationFactors output;
  1205. float4 tf = 1;
  1206. float tessValue = /*ase_inline_begin*/_TessValue/*ase_inline_end*/; float tessMin = /*ase_inline_begin*/_TessMin/*ase_inline_end*/; float tessMax = /*ase_inline_begin*/_TessMax/*ase_inline_end*/;
  1207. float edgeLength = /*ase_inline_begin*/_TessEdgeLength/*ase_inline_end*/; float tessMaxDisp = /*ase_inline_begin*/_TessMaxDisp/*ase_inline_end*/;
  1208. #if defined(ASE_FIXED_TESSELLATION)
  1209. tf = FixedTess( tessValue );
  1210. #elif defined(ASE_DISTANCE_TESSELLATION)
  1211. tf = DistanceBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
  1212. #elif defined(ASE_LENGTH_TESSELLATION)
  1213. tf = EdgeLengthBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
  1214. #elif defined(ASE_LENGTH_CULL_TESSELLATION)
  1215. tf = EdgeLengthBasedTessCull(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
  1216. #endif
  1217. output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w;
  1218. return output;
  1219. }
  1220. [domain("tri")]
  1221. [partitioning("fractional_odd")]
  1222. [outputtopology("triangle_cw")]
  1223. [patchconstantfunc("TessellationFunction")]
  1224. [outputcontrolpoints(3)]
  1225. VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
  1226. {
  1227. return patch[id];
  1228. }
  1229. [domain("tri")]
  1230. PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
  1231. {
  1232. Attributes output = (Attributes) 0;
  1233. output.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z;
  1234. output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
  1235. /*ase_domain_code:patch=VertexControl;output=Attributes;bary=SV_DomainLocation*/
  1236. #if defined(ASE_PHONG_TESSELLATION)
  1237. float3 pp[3];
  1238. for (int i = 0; i < 3; ++i)
  1239. pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS));
  1240. float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/;
  1241. output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz;
  1242. #endif
  1243. UNITY_TRANSFER_INSTANCE_ID(patch[0], output);
  1244. return VertexFunction(output);
  1245. }
  1246. #else
  1247. PackedVaryings vert ( Attributes input )
  1248. {
  1249. return VertexFunction( input );
  1250. }
  1251. #endif
  1252. half4 frag(PackedVaryings input
  1253. #ifdef ASE_DEPTH_WRITE_ON
  1254. ,out float outputDepth : ASE_SV_DEPTH
  1255. #endif
  1256. /*ase_frag_input*/ ) : SV_Target
  1257. {
  1258. UNITY_SETUP_INSTANCE_ID(input);
  1259. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( input );
  1260. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1261. /*ase_local_var:wp*/float3 WorldPosition = input.positionWS;
  1262. #endif
  1263. /*ase_local_var:sc*/float4 ShadowCoords = float4( 0, 0, 0, 0 );
  1264. /*ase_local_var:sp*/float4 ClipPos = input.clipPosV;
  1265. /*ase_local_var:spu*/float4 ScreenPos = ComputeScreenPos( input.clipPosV );
  1266. #if defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1267. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  1268. ShadowCoords = input.shadowCoord;
  1269. #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
  1270. ShadowCoords = TransformWorldToShadowCoord( WorldPosition );
  1271. #endif
  1272. #endif
  1273. /*ase_frag_code:input=PackedVaryings*/
  1274. float Alpha = /*ase_frag_out:Alpha;Float;0;-1;_Alpha*/1/*end*/;
  1275. float AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;1;-1;_AlphaClip*/0.5/*end*/;
  1276. #ifdef ASE_DEPTH_WRITE_ON
  1277. float DepthValue = /*ase_frag_out:Depth Value;Float;17;-1;_DepthValue*/input.positionCS.z/*end*/;
  1278. #endif
  1279. #ifdef _ALPHATEST_ON
  1280. clip(Alpha - AlphaClipThreshold);
  1281. #endif
  1282. #if defined(LOD_FADE_CROSSFADE)
  1283. LODFadeCrossFade( input.positionCS );
  1284. #endif
  1285. #ifdef ASE_DEPTH_WRITE_ON
  1286. outputDepth = DepthValue;
  1287. #endif
  1288. return 0;
  1289. }
  1290. ENDHLSL
  1291. }
  1292. /*ase_pass*/
  1293. Pass
  1294. {
  1295. /*ase_hide_pass*/
  1296. Name "Meta"
  1297. Tags
  1298. {
  1299. "LightMode" = "Meta"
  1300. }
  1301. Cull Off
  1302. HLSLPROGRAM
  1303. #pragma vertex vert
  1304. #pragma fragment frag
  1305. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  1306. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  1307. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/MetaInput.hlsl"
  1308. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  1309. /*ase_pragma*/
  1310. struct Attributes
  1311. {
  1312. float4 positionOS : POSITION;
  1313. float3 normalOS : NORMAL;
  1314. float4 texcoord1 : TEXCOORD1;
  1315. float4 texcoord2 : TEXCOORD2;
  1316. /*ase_vdata:p=p;n=n;uv1=tc1;uv2=tc2*/
  1317. UNITY_VERTEX_INPUT_INSTANCE_ID
  1318. };
  1319. struct PackedVaryings
  1320. {
  1321. float4 positionCS : SV_POSITION;
  1322. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1323. float3 positionWS : TEXCOORD0;
  1324. #endif
  1325. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1326. float4 shadowCoord : TEXCOORD1;
  1327. #endif
  1328. /*ase_interp(2,):sp=sp;wp=tc0;sc=tc1*/
  1329. UNITY_VERTEX_INPUT_INSTANCE_ID
  1330. UNITY_VERTEX_OUTPUT_STEREO
  1331. };
  1332. CBUFFER_START(UnityPerMaterial)
  1333. #ifdef ASE_TRANSMISSION
  1334. float _TransmissionShadow;
  1335. #endif
  1336. #ifdef ASE_TRANSLUCENCY
  1337. float _TransStrength;
  1338. float _TransNormal;
  1339. float _TransScattering;
  1340. float _TransDirect;
  1341. float _TransAmbient;
  1342. float _TransShadow;
  1343. #endif
  1344. #ifdef ASE_TESSELLATION
  1345. float _TessPhongStrength;
  1346. float _TessValue;
  1347. float _TessMin;
  1348. float _TessMax;
  1349. float _TessEdgeLength;
  1350. float _TessMaxDisp;
  1351. #endif
  1352. CBUFFER_END
  1353. #ifdef SCENEPICKINGPASS
  1354. float4 _SelectionID;
  1355. #endif
  1356. #ifdef SCENESELECTIONPASS
  1357. int _ObjectId;
  1358. int _PassValue;
  1359. #endif
  1360. /*ase_globals*/
  1361. /*ase_funcs*/
  1362. PackedVaryings VertexFunction( Attributes input /*ase_vert_input*/ )
  1363. {
  1364. PackedVaryings output = (PackedVaryings)0;
  1365. UNITY_SETUP_INSTANCE_ID(input);
  1366. UNITY_TRANSFER_INSTANCE_ID(input, output);
  1367. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
  1368. /*ase_vert_code:input=Attributes;output=PackedVaryings*/
  1369. #ifdef ASE_ABSOLUTE_VERTEX_POS
  1370. float3 defaultVertexValue = input.positionOS.xyz;
  1371. #else
  1372. float3 defaultVertexValue = float3(0, 0, 0);
  1373. #endif
  1374. float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;4;-1;_Vertex*/defaultVertexValue/*end*/;
  1375. #ifdef ASE_ABSOLUTE_VERTEX_POS
  1376. input.positionOS.xyz = vertexValue;
  1377. #else
  1378. input.positionOS.xyz += vertexValue;
  1379. #endif
  1380. input.normalOS = /*ase_vert_out:Vertex Normal;Float3;5;-1;_Normal*/input.normalOS/*end*/;
  1381. float3 positionWS = TransformObjectToWorld( input.positionOS.xyz );
  1382. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1383. output.positionWS = positionWS;
  1384. #endif
  1385. output.positionCS = MetaVertexPosition( input.positionOS, input.texcoord1.xy, input.texcoord1.xy, unity_LightmapST, unity_DynamicLightmapST );
  1386. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1387. VertexPositionInputs vertexInput = (VertexPositionInputs)0;
  1388. vertexInput.positionWS = positionWS;
  1389. vertexInput.positionCS = output.positionCS;
  1390. output.shadowCoord = GetShadowCoord( vertexInput );
  1391. #endif
  1392. return output;
  1393. }
  1394. #if defined(ASE_TESSELLATION)
  1395. struct VertexControl
  1396. {
  1397. float4 positionOS : INTERNALTESSPOS;
  1398. float3 normalOS : NORMAL;
  1399. float4 texcoord1 : TEXCOORD1;
  1400. float4 texcoord2 : TEXCOORD2;
  1401. /*ase_vcontrol*/
  1402. UNITY_VERTEX_INPUT_INSTANCE_ID
  1403. };
  1404. struct TessellationFactors
  1405. {
  1406. float edge[3] : SV_TessFactor;
  1407. float inside : SV_InsideTessFactor;
  1408. };
  1409. VertexControl vert ( Attributes input )
  1410. {
  1411. VertexControl output;
  1412. UNITY_SETUP_INSTANCE_ID(input);
  1413. UNITY_TRANSFER_INSTANCE_ID(input, output);
  1414. output.positionOS = input.positionOS;
  1415. output.normalOS = input.normalOS;
  1416. output.texcoord1 = input.texcoord1;
  1417. output.texcoord2 = input.texcoord2;
  1418. /*ase_control_code:input=Attributes;output=VertexControl*/
  1419. return output;
  1420. }
  1421. TessellationFactors TessellationFunction (InputPatch<VertexControl,3> input)
  1422. {
  1423. TessellationFactors output;
  1424. float4 tf = 1;
  1425. float tessValue = /*ase_inline_begin*/_TessValue/*ase_inline_end*/; float tessMin = /*ase_inline_begin*/_TessMin/*ase_inline_end*/; float tessMax = /*ase_inline_begin*/_TessMax/*ase_inline_end*/;
  1426. float edgeLength = /*ase_inline_begin*/_TessEdgeLength/*ase_inline_end*/; float tessMaxDisp = /*ase_inline_begin*/_TessMaxDisp/*ase_inline_end*/;
  1427. #if defined(ASE_FIXED_TESSELLATION)
  1428. tf = FixedTess( tessValue );
  1429. #elif defined(ASE_DISTANCE_TESSELLATION)
  1430. tf = DistanceBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
  1431. #elif defined(ASE_LENGTH_TESSELLATION)
  1432. tf = EdgeLengthBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
  1433. #elif defined(ASE_LENGTH_CULL_TESSELLATION)
  1434. tf = EdgeLengthBasedTessCull(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
  1435. #endif
  1436. output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w;
  1437. return output;
  1438. }
  1439. [domain("tri")]
  1440. [partitioning("fractional_odd")]
  1441. [outputtopology("triangle_cw")]
  1442. [patchconstantfunc("TessellationFunction")]
  1443. [outputcontrolpoints(3)]
  1444. VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
  1445. {
  1446. return patch[id];
  1447. }
  1448. [domain("tri")]
  1449. PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
  1450. {
  1451. Attributes output = (Attributes) 0;
  1452. output.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z;
  1453. output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
  1454. output.texcoord1 = patch[0].texcoord1 * bary.x + patch[1].texcoord1 * bary.y + patch[2].texcoord1 * bary.z;
  1455. output.texcoord2 = patch[0].texcoord2 * bary.x + patch[1].texcoord2 * bary.y + patch[2].texcoord2 * bary.z;
  1456. /*ase_domain_code:patch=VertexControl;output=Attributes;bary=SV_DomainLocation*/
  1457. #if defined(ASE_PHONG_TESSELLATION)
  1458. float3 pp[3];
  1459. for (int i = 0; i < 3; ++i)
  1460. pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS));
  1461. float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/;
  1462. output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz;
  1463. #endif
  1464. UNITY_TRANSFER_INSTANCE_ID(patch[0], output);
  1465. return VertexFunction(output);
  1466. }
  1467. #else
  1468. PackedVaryings vert ( Attributes input )
  1469. {
  1470. return VertexFunction( input );
  1471. }
  1472. #endif
  1473. half4 frag(PackedVaryings input /*ase_frag_input*/ ) : SV_Target
  1474. {
  1475. UNITY_SETUP_INSTANCE_ID(input);
  1476. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( input );
  1477. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1478. /*ase_local_var:wp*/float3 WorldPosition = input.positionWS;
  1479. #endif
  1480. /*ase_local_var:sc*/float4 ShadowCoords = float4( 0, 0, 0, 0 );
  1481. #if defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1482. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  1483. ShadowCoords = input.shadowCoord;
  1484. #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
  1485. ShadowCoords = TransformWorldToShadowCoord( WorldPosition );
  1486. #endif
  1487. #endif
  1488. /*ase_frag_code:input=PackedVaryings*/
  1489. float3 BakedAlbedo = /*ase_frag_out:Baked Albedo;Float3;0;-1;_Albedo*/0/*end*/;
  1490. float3 BakedEmission = /*ase_frag_out:Baked Emission;Float3;1;-1;_Emission*/0/*end*/;
  1491. float Alpha = /*ase_frag_out:Alpha;Float;2;-1;_Alpha*/1/*end*/;
  1492. float AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;3;-1;_AlphaClip*/0.5/*end*/;
  1493. #ifdef _ALPHATEST_ON
  1494. clip(Alpha - AlphaClipThreshold);
  1495. #endif
  1496. MetaInput metaInput = (MetaInput)0;
  1497. metaInput.Albedo = BakedAlbedo;
  1498. metaInput.Emission = BakedEmission;
  1499. return MetaFragment(metaInput);
  1500. }
  1501. ENDHLSL
  1502. }
  1503. /*ase_pass*/
  1504. Pass // -- DEPRECATED --
  1505. {
  1506. /*ase_hide_pass:SyncP*/
  1507. Name "Universal2D"
  1508. Tags
  1509. {
  1510. "LightMode" = "Universal2D"
  1511. }
  1512. Blend One Zero
  1513. ZWrite On
  1514. ZTest LEqual
  1515. Offset 0,0
  1516. ColorMask RGBA
  1517. /*ase_stencil*/
  1518. HLSLPROGRAM
  1519. #pragma multi_compile _ LIGHTMAP_ON
  1520. #pragma multi_compile _ DIRLIGHTMAP_COMBINED
  1521. #pragma multi_compile _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
  1522. #pragma multi_compile _ DEBUG_DISPLAY
  1523. #pragma vertex vert
  1524. #pragma fragment frag
  1525. #define SHADERPASS SHADERPASS_UNLIT
  1526. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  1527. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
  1528. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  1529. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  1530. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl"
  1531. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
  1532. /*ase_srp_cond_begin:>=140010*/
  1533. #if ASE_SRP_VERSION >=140010
  1534. #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
  1535. #endif
  1536. /*ase_srp_cond_end*/
  1537. /*ase_srp_cond_begin:<140010*/
  1538. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl"
  1539. /*ase_srp_cond_end*/
  1540. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  1541. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DBuffer.hlsl"
  1542. #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
  1543. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Debug/Debugging3D.hlsl"
  1544. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceData.hlsl"
  1545. /*ase_pragma*/
  1546. struct Attributes
  1547. {
  1548. float4 positionOS : POSITION;
  1549. float3 normalOS : NORMAL;
  1550. /*ase_vdata:p=p;n=n*/
  1551. UNITY_VERTEX_INPUT_INSTANCE_ID
  1552. };
  1553. struct PackedVaryings
  1554. {
  1555. float4 positionCS : SV_POSITION;
  1556. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1557. float3 positionWS : TEXCOORD0;
  1558. #endif
  1559. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1560. float4 shadowCoord : TEXCOORD1;
  1561. #endif
  1562. #ifdef ASE_FOG
  1563. float fogFactor : TEXCOORD2;
  1564. #endif
  1565. /*ase_interp(3,):sp=sp;wp=tc0;sc=tc1*/
  1566. UNITY_VERTEX_INPUT_INSTANCE_ID
  1567. UNITY_VERTEX_OUTPUT_STEREO
  1568. };
  1569. /*ase_globals*/
  1570. /*ase_funcs*/
  1571. PackedVaryings vert( Attributes input /*ase_vert_input*/ )
  1572. {
  1573. PackedVaryings output = (PackedVaryings)0;
  1574. UNITY_SETUP_INSTANCE_ID(input);
  1575. UNITY_TRANSFER_INSTANCE_ID(input, output);
  1576. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
  1577. /*ase_vert_code:input=Attributes;output=PackedVaryings*/
  1578. #ifdef ASE_ABSOLUTE_VERTEX_POS
  1579. float3 defaultVertexValue = input.positionOS.xyz;
  1580. #else
  1581. float3 defaultVertexValue = float3(0, 0, 0);
  1582. #endif
  1583. float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;5;-1;_Vertex*/defaultVertexValue/*end*/;
  1584. #ifdef ASE_ABSOLUTE_VERTEX_POS
  1585. input.positionOS.xyz = vertexValue;
  1586. #else
  1587. input.positionOS.xyz += vertexValue;
  1588. #endif
  1589. input.normalOS = /*ase_vert_out:Vertex Normal;Float3;6;-1;_Normal*/input.normalOS/*end*/;
  1590. float3 positionWS = TransformObjectToWorld( input.positionOS.xyz );
  1591. float4 positionCS = TransformWorldToHClip( positionWS );
  1592. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1593. output.positionWS = positionWS;
  1594. #endif
  1595. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1596. VertexPositionInputs vertexInput = (VertexPositionInputs)0;
  1597. vertexInput.positionWS = positionWS;
  1598. vertexInput.positionCS = positionCS;
  1599. output.shadowCoord = GetShadowCoord( vertexInput );
  1600. #endif
  1601. #ifdef ASE_FOG
  1602. output.fogFactor = ComputeFogFactor( positionCS.z );
  1603. #endif
  1604. output.positionCS = positionCS;
  1605. return output;
  1606. }
  1607. half4 frag ( PackedVaryings input /*ase_frag_input*/ ) : SV_Target
  1608. {
  1609. UNITY_SETUP_INSTANCE_ID( input );
  1610. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( input );
  1611. #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
  1612. /*ase_local_var:wp*/float3 WorldPosition = input.positionWS;
  1613. #endif
  1614. /*ase_local_var:sc*/float4 ShadowCoords = float4( 0, 0, 0, 0 );
  1615. #if defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
  1616. #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
  1617. ShadowCoords = input.shadowCoord;
  1618. #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
  1619. ShadowCoords = TransformWorldToShadowCoord( WorldPosition );
  1620. #endif
  1621. #endif
  1622. /*ase_frag_code:input=PackedVaryings*/
  1623. float3 BakedAlbedo = /*ase_frag_out:Baked Albedo;Float3;0;-1;_Albedo*/0/*end*/;
  1624. float3 BakedEmission = /*ase_frag_out:Baked Emission;Float3;1;-1;_Emission*/0/*end*/;
  1625. float3 Color = /*ase_frag_out:Color;Float3;2;-1;_Color*/float3( 0.5, 0.5, 0.5 )/*end*/;
  1626. float Alpha = /*ase_frag_out:Alpha;Float;3;-1;_Alpha*/1/*end*/;
  1627. float AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;4;-1;_AlphaClip*/0.5/*end*/;
  1628. float AlphaClipThresholdShadow = /*ase_frag_out:Alpha Clip Threshold Shadow;Float;7;-1;_AlphaClipShadow*/0.5/*end*/;
  1629. #ifdef _ALPHATEST_ON
  1630. clip( Alpha - AlphaClipThreshold );
  1631. #endif
  1632. #if defined(_DBUFFER)
  1633. ApplyDecalToBaseColor(input.positionCS, Color);
  1634. #endif
  1635. #ifdef ASE_FOG
  1636. Color = MixFog( Color, input.fogFactor );
  1637. #endif
  1638. return half4( Color, Alpha );
  1639. }
  1640. ENDHLSL
  1641. }
  1642. /*ase_pass*/
  1643. Pass
  1644. {
  1645. /*ase_hide_pass*/
  1646. Name "SceneSelectionPass"
  1647. Tags
  1648. {
  1649. "LightMode" = "SceneSelectionPass"
  1650. }
  1651. Cull Off
  1652. AlphaToMask Off
  1653. HLSLPROGRAM
  1654. /*ase_srp_cond_begin:<140007*/
  1655. #pragma multi_compile _ DOTS_INSTANCING_ON
  1656. /*ase_srp_cond_end*/
  1657. #pragma vertex vert
  1658. #pragma fragment frag
  1659. #define ATTRIBUTES_NEED_NORMAL
  1660. #define ATTRIBUTES_NEED_TANGENT
  1661. #define SHADERPASS SHADERPASS_DEPTHONLY
  1662. /*ase_srp_cond_begin:>=140007*/
  1663. #if ASE_SRP_VERSION >=140007
  1664. #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
  1665. #endif
  1666. /*ase_srp_cond_end*/
  1667. /*ase_srp_cond_begin:>=140007*/
  1668. #if ASE_SRP_VERSION >=140007
  1669. #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"
  1670. #endif
  1671. /*ase_srp_cond_end*/
  1672. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  1673. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
  1674. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  1675. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  1676. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
  1677. /*ase_srp_cond_begin:>=140010*/
  1678. #if ASE_SRP_VERSION >=140010
  1679. #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
  1680. #endif
  1681. /*ase_srp_cond_end*/
  1682. /*ase_srp_cond_begin:<140010*/
  1683. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl"
  1684. /*ase_srp_cond_end*/
  1685. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  1686. #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
  1687. /*ase_pragma*/
  1688. struct Attributes
  1689. {
  1690. float4 positionOS : POSITION;
  1691. float3 normalOS : NORMAL;
  1692. /*ase_vdata:p=p;n=n*/
  1693. UNITY_VERTEX_INPUT_INSTANCE_ID
  1694. };
  1695. struct PackedVaryings
  1696. {
  1697. float4 positionCS : SV_POSITION;
  1698. /*ase_interp(0,):sp=sp*/
  1699. UNITY_VERTEX_INPUT_INSTANCE_ID
  1700. UNITY_VERTEX_OUTPUT_STEREO
  1701. };
  1702. CBUFFER_START(UnityPerMaterial)
  1703. #ifdef ASE_TESSELLATION
  1704. float _TessPhongStrength;
  1705. float _TessValue;
  1706. float _TessMin;
  1707. float _TessMax;
  1708. float _TessEdgeLength;
  1709. float _TessMaxDisp;
  1710. #endif
  1711. CBUFFER_END
  1712. /*ase_globals*/
  1713. /*ase_funcs*/
  1714. int _ObjectId;
  1715. int _PassValue;
  1716. struct SurfaceDescription
  1717. {
  1718. float Alpha;
  1719. float AlphaClipThreshold;
  1720. };
  1721. PackedVaryings VertexFunction(Attributes input /*ase_vert_input*/ )
  1722. {
  1723. PackedVaryings output;
  1724. ZERO_INITIALIZE(PackedVaryings, output);
  1725. UNITY_SETUP_INSTANCE_ID(input);
  1726. UNITY_TRANSFER_INSTANCE_ID(input, output);
  1727. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
  1728. /*ase_vert_code:input=Attributes;output=PackedVaryings*/
  1729. #ifdef ASE_ABSOLUTE_VERTEX_POS
  1730. float3 defaultVertexValue = input.positionOS.xyz;
  1731. #else
  1732. float3 defaultVertexValue = float3(0, 0, 0);
  1733. #endif
  1734. float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;2;-1;_Vertex*/defaultVertexValue/*end*/;
  1735. #ifdef ASE_ABSOLUTE_VERTEX_POS
  1736. input.positionOS.xyz = vertexValue;
  1737. #else
  1738. input.positionOS.xyz += vertexValue;
  1739. #endif
  1740. input.normalOS = /*ase_vert_out:Vertex Normal;Float3;3;-1;_Normal*/input.normalOS/*end*/;
  1741. float3 positionWS = TransformObjectToWorld( input.positionOS.xyz );
  1742. output.positionCS = TransformWorldToHClip(positionWS);
  1743. return output;
  1744. }
  1745. #if defined(ASE_TESSELLATION)
  1746. struct VertexControl
  1747. {
  1748. float4 positionOS : INTERNALTESSPOS;
  1749. float3 normalOS : NORMAL;
  1750. /*ase_vcontrol*/
  1751. UNITY_VERTEX_INPUT_INSTANCE_ID
  1752. };
  1753. struct TessellationFactors
  1754. {
  1755. float edge[3] : SV_TessFactor;
  1756. float inside : SV_InsideTessFactor;
  1757. };
  1758. VertexControl vert ( Attributes input )
  1759. {
  1760. VertexControl output;
  1761. UNITY_SETUP_INSTANCE_ID(input);
  1762. UNITY_TRANSFER_INSTANCE_ID(input, output);
  1763. output.positionOS = input.positionOS;
  1764. output.normalOS = input.normalOS;
  1765. /*ase_control_code:input=Attributes;output=VertexControl*/
  1766. return output;
  1767. }
  1768. TessellationFactors TessellationFunction (InputPatch<VertexControl,3> input)
  1769. {
  1770. TessellationFactors output;
  1771. float4 tf = 1;
  1772. float tessValue = /*ase_inline_begin*/_TessValue/*ase_inline_end*/; float tessMin = /*ase_inline_begin*/_TessMin/*ase_inline_end*/; float tessMax = /*ase_inline_begin*/_TessMax/*ase_inline_end*/;
  1773. float edgeLength = /*ase_inline_begin*/_TessEdgeLength/*ase_inline_end*/; float tessMaxDisp = /*ase_inline_begin*/_TessMaxDisp/*ase_inline_end*/;
  1774. #if defined(ASE_FIXED_TESSELLATION)
  1775. tf = FixedTess( tessValue );
  1776. #elif defined(ASE_DISTANCE_TESSELLATION)
  1777. tf = DistanceBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
  1778. #elif defined(ASE_LENGTH_TESSELLATION)
  1779. tf = EdgeLengthBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
  1780. #elif defined(ASE_LENGTH_CULL_TESSELLATION)
  1781. tf = EdgeLengthBasedTessCull(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
  1782. #endif
  1783. output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w;
  1784. return output;
  1785. }
  1786. [domain("tri")]
  1787. [partitioning("fractional_odd")]
  1788. [outputtopology("triangle_cw")]
  1789. [patchconstantfunc("TessellationFunction")]
  1790. [outputcontrolpoints(3)]
  1791. VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
  1792. {
  1793. return patch[id];
  1794. }
  1795. [domain("tri")]
  1796. PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
  1797. {
  1798. Attributes output = (Attributes) 0;
  1799. output.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z;
  1800. output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
  1801. /*ase_domain_code:patch=VertexControl;output=Attributes;bary=SV_DomainLocation*/
  1802. #if defined(ASE_PHONG_TESSELLATION)
  1803. float3 pp[3];
  1804. for (int i = 0; i < 3; ++i)
  1805. pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS));
  1806. float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/;
  1807. output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz;
  1808. #endif
  1809. UNITY_TRANSFER_INSTANCE_ID(patch[0], output);
  1810. return VertexFunction(output);
  1811. }
  1812. #else
  1813. PackedVaryings vert ( Attributes input )
  1814. {
  1815. return VertexFunction( input );
  1816. }
  1817. #endif
  1818. half4 frag(PackedVaryings input /*ase_frag_input*/) : SV_Target
  1819. {
  1820. SurfaceDescription surfaceDescription = (SurfaceDescription)0;
  1821. /*ase_frag_code:input=PackedVaryings*/
  1822. surfaceDescription.Alpha = /*ase_frag_out:Alpha;Float;0;-1;_Alpha*/1/*end*/;
  1823. surfaceDescription.AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;1;-1;_AlphaClip*/0.5/*end*/;
  1824. #if _ALPHATEST_ON
  1825. float alphaClipThreshold = 0.01f;
  1826. #if ALPHA_CLIP_THRESHOLD
  1827. alphaClipThreshold = surfaceDescription.AlphaClipThreshold;
  1828. #endif
  1829. clip(surfaceDescription.Alpha - alphaClipThreshold);
  1830. #endif
  1831. half4 outColor = half4(_ObjectId, _PassValue, 1.0, 1.0);
  1832. return outColor;
  1833. }
  1834. ENDHLSL
  1835. }
  1836. /*ase_pass*/
  1837. Pass
  1838. {
  1839. /*ase_hide_pass*/
  1840. Name "ScenePickingPass"
  1841. Tags
  1842. {
  1843. "LightMode" = "Picking"
  1844. }
  1845. AlphaToMask Off
  1846. HLSLPROGRAM
  1847. /*ase_srp_cond_begin:<140007*/
  1848. #pragma multi_compile _ DOTS_INSTANCING_ON
  1849. /*ase_srp_cond_end*/
  1850. #pragma vertex vert
  1851. #pragma fragment frag
  1852. #define ATTRIBUTES_NEED_NORMAL
  1853. #define ATTRIBUTES_NEED_TANGENT
  1854. #define SHADERPASS SHADERPASS_DEPTHONLY
  1855. /*ase_srp_cond_begin:>=140007*/
  1856. #if ASE_SRP_VERSION >=140007
  1857. #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
  1858. #endif
  1859. /*ase_srp_cond_end*/
  1860. /*ase_srp_cond_begin:>=140007*/
  1861. #if ASE_SRP_VERSION >=140007
  1862. #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"
  1863. #endif
  1864. /*ase_srp_cond_end*/
  1865. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  1866. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
  1867. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  1868. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  1869. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
  1870. /*ase_srp_cond_begin:>=140010*/
  1871. #if ASE_SRP_VERSION >=140010
  1872. #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
  1873. #endif
  1874. /*ase_srp_cond_end*/
  1875. /*ase_srp_cond_begin:<140010*/
  1876. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl"
  1877. /*ase_srp_cond_end*/
  1878. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  1879. #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
  1880. #if defined(LOD_FADE_CROSSFADE)
  1881. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl"
  1882. #endif
  1883. /*ase_pragma*/
  1884. struct Attributes
  1885. {
  1886. float4 positionOS : POSITION;
  1887. float3 normalOS : NORMAL;
  1888. /*ase_vdata:p=p;n=n*/
  1889. UNITY_VERTEX_INPUT_INSTANCE_ID
  1890. };
  1891. struct PackedVaryings
  1892. {
  1893. float4 positionCS : SV_POSITION;
  1894. /*ase_interp(0,):sp=sp*/
  1895. UNITY_VERTEX_INPUT_INSTANCE_ID
  1896. UNITY_VERTEX_OUTPUT_STEREO
  1897. };
  1898. CBUFFER_START(UnityPerMaterial)
  1899. #ifdef ASE_TESSELLATION
  1900. float _TessPhongStrength;
  1901. float _TessValue;
  1902. float _TessMin;
  1903. float _TessMax;
  1904. float _TessEdgeLength;
  1905. float _TessMaxDisp;
  1906. #endif
  1907. CBUFFER_END
  1908. /*ase_globals*/
  1909. /*ase_funcs*/
  1910. float4 _SelectionID;
  1911. struct SurfaceDescription
  1912. {
  1913. float Alpha;
  1914. float AlphaClipThreshold;
  1915. };
  1916. PackedVaryings VertexFunction(Attributes input /*ase_vert_input*/ )
  1917. {
  1918. PackedVaryings output;
  1919. ZERO_INITIALIZE(PackedVaryings, output);
  1920. UNITY_SETUP_INSTANCE_ID(input);
  1921. UNITY_TRANSFER_INSTANCE_ID(input, output);
  1922. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
  1923. /*ase_vert_code:input=Attributes;output=PackedVaryings*/
  1924. #ifdef ASE_ABSOLUTE_VERTEX_POS
  1925. float3 defaultVertexValue = input.positionOS.xyz;
  1926. #else
  1927. float3 defaultVertexValue = float3(0, 0, 0);
  1928. #endif
  1929. float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;2;-1;_Vertex*/defaultVertexValue/*end*/;
  1930. #ifdef ASE_ABSOLUTE_VERTEX_POS
  1931. input.positionOS.xyz = vertexValue;
  1932. #else
  1933. input.positionOS.xyz += vertexValue;
  1934. #endif
  1935. input.normalOS = /*ase_vert_out:Vertex Normal;Float3;3;-1;_Normal*/input.normalOS/*end*/;
  1936. float3 positionWS = TransformObjectToWorld( input.positionOS.xyz );
  1937. output.positionCS = TransformWorldToHClip(positionWS);
  1938. return output;
  1939. }
  1940. #if defined(ASE_TESSELLATION)
  1941. struct VertexControl
  1942. {
  1943. float4 positionOS : INTERNALTESSPOS;
  1944. float3 normalOS : NORMAL;
  1945. /*ase_vcontrol*/
  1946. UNITY_VERTEX_INPUT_INSTANCE_ID
  1947. };
  1948. struct TessellationFactors
  1949. {
  1950. float edge[3] : SV_TessFactor;
  1951. float inside : SV_InsideTessFactor;
  1952. };
  1953. VertexControl vert ( Attributes input )
  1954. {
  1955. VertexControl output;
  1956. UNITY_SETUP_INSTANCE_ID(input);
  1957. UNITY_TRANSFER_INSTANCE_ID(input, output);
  1958. output.positionOS = input.positionOS;
  1959. output.normalOS = input.normalOS;
  1960. /*ase_control_code:input=Attributes;output=VertexControl*/
  1961. return output;
  1962. }
  1963. TessellationFactors TessellationFunction (InputPatch<VertexControl,3> input)
  1964. {
  1965. TessellationFactors output;
  1966. float4 tf = 1;
  1967. float tessValue = /*ase_inline_begin*/_TessValue/*ase_inline_end*/; float tessMin = /*ase_inline_begin*/_TessMin/*ase_inline_end*/; float tessMax = /*ase_inline_begin*/_TessMax/*ase_inline_end*/;
  1968. float edgeLength = /*ase_inline_begin*/_TessEdgeLength/*ase_inline_end*/; float tessMaxDisp = /*ase_inline_begin*/_TessMaxDisp/*ase_inline_end*/;
  1969. #if defined(ASE_FIXED_TESSELLATION)
  1970. tf = FixedTess( tessValue );
  1971. #elif defined(ASE_DISTANCE_TESSELLATION)
  1972. tf = DistanceBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
  1973. #elif defined(ASE_LENGTH_TESSELLATION)
  1974. tf = EdgeLengthBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
  1975. #elif defined(ASE_LENGTH_CULL_TESSELLATION)
  1976. tf = EdgeLengthBasedTessCull(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
  1977. #endif
  1978. output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w;
  1979. return output;
  1980. }
  1981. [domain("tri")]
  1982. [partitioning("fractional_odd")]
  1983. [outputtopology("triangle_cw")]
  1984. [patchconstantfunc("TessellationFunction")]
  1985. [outputcontrolpoints(3)]
  1986. VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
  1987. {
  1988. return patch[id];
  1989. }
  1990. [domain("tri")]
  1991. PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
  1992. {
  1993. Attributes output = (Attributes) 0;
  1994. output.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z;
  1995. output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
  1996. /*ase_domain_code:patch=VertexControl;output=Attributes;bary=SV_DomainLocation*/
  1997. #if defined(ASE_PHONG_TESSELLATION)
  1998. float3 pp[3];
  1999. for (int i = 0; i < 3; ++i)
  2000. pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS));
  2001. float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/;
  2002. output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz;
  2003. #endif
  2004. UNITY_TRANSFER_INSTANCE_ID(patch[0], output);
  2005. return VertexFunction(output);
  2006. }
  2007. #else
  2008. PackedVaryings vert ( Attributes input )
  2009. {
  2010. return VertexFunction( input );
  2011. }
  2012. #endif
  2013. half4 frag(PackedVaryings input /*ase_frag_input*/) : SV_Target
  2014. {
  2015. SurfaceDescription surfaceDescription = (SurfaceDescription)0;
  2016. /*ase_frag_code:input=PackedVaryings*/
  2017. surfaceDescription.Alpha = /*ase_frag_out:Alpha;Float;0;-1;_Alpha*/1/*end*/;
  2018. surfaceDescription.AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;1;-1;_AlphaClip*/0.5/*end*/;
  2019. #if _ALPHATEST_ON
  2020. float alphaClipThreshold = 0.01f;
  2021. #if ALPHA_CLIP_THRESHOLD
  2022. alphaClipThreshold = surfaceDescription.AlphaClipThreshold;
  2023. #endif
  2024. clip(surfaceDescription.Alpha - alphaClipThreshold);
  2025. #endif
  2026. half4 outColor = 0;
  2027. outColor = _SelectionID;
  2028. return outColor;
  2029. }
  2030. ENDHLSL
  2031. }
  2032. /*ase_pass*/
  2033. Pass
  2034. {
  2035. /*ase_hide_pass*/
  2036. Name "DepthNormals"
  2037. Tags
  2038. {
  2039. "LightMode" = "DepthNormalsOnly"
  2040. }
  2041. ZTest LEqual
  2042. ZWrite On
  2043. HLSLPROGRAM
  2044. /*ase_srp_cond_begin:<140007*/
  2045. #pragma multi_compile _ DOTS_INSTANCING_ON
  2046. /*ase_srp_cond_end*/
  2047. #pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
  2048. /*ase_srp_cond_begin:<140007*/
  2049. #pragma multi_compile_fragment _ _WRITE_RENDERING_LAYERS
  2050. /*ase_srp_cond_end*/
  2051. #pragma vertex vert
  2052. #pragma fragment frag
  2053. #define ATTRIBUTES_NEED_NORMAL
  2054. #define ATTRIBUTES_NEED_TANGENT
  2055. #define VARYINGS_NEED_NORMAL_WS
  2056. #define SHADERPASS SHADERPASS_DEPTHNORMALSONLY
  2057. /*ase_srp_cond_begin:>=140007*/
  2058. #if ASE_SRP_VERSION >=140007
  2059. #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
  2060. #endif
  2061. /*ase_srp_cond_end*/
  2062. /*ase_srp_cond_begin:>=140007*/
  2063. #if ASE_SRP_VERSION >=140007
  2064. #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"
  2065. #endif
  2066. /*ase_srp_cond_end*/
  2067. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  2068. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
  2069. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  2070. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  2071. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
  2072. /*ase_srp_cond_begin:>=140010*/
  2073. #if ASE_SRP_VERSION >=140010
  2074. #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
  2075. #endif
  2076. /*ase_srp_cond_end*/
  2077. /*ase_srp_cond_begin:<140010*/
  2078. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl"
  2079. /*ase_srp_cond_end*/
  2080. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  2081. #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
  2082. #if defined(LOD_FADE_CROSSFADE)
  2083. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl"
  2084. #endif
  2085. /*ase_pragma*/
  2086. #if defined(ASE_EARLY_Z_DEPTH_OPTIMIZE) && (SHADER_TARGET >= 45)
  2087. #define ASE_SV_DEPTH SV_DepthLessEqual
  2088. #define ASE_SV_POSITION_QUALIFIERS linear noperspective centroid
  2089. #else
  2090. #define ASE_SV_DEPTH SV_Depth
  2091. #define ASE_SV_POSITION_QUALIFIERS
  2092. #endif
  2093. struct Attributes
  2094. {
  2095. float4 positionOS : POSITION;
  2096. float3 normalOS : NORMAL;
  2097. /*ase_vdata:p=p;n=n*/
  2098. UNITY_VERTEX_INPUT_INSTANCE_ID
  2099. };
  2100. struct PackedVaryings
  2101. {
  2102. ASE_SV_POSITION_QUALIFIERS float4 positionCS : SV_POSITION;
  2103. float4 clipPosV : TEXCOORD0;
  2104. float3 positionWS : TEXCOORD1;
  2105. float3 normalWS : TEXCOORD2;
  2106. /*ase_interp(3,):sp=sp;wp=tc1;wn=tc2*/
  2107. UNITY_VERTEX_INPUT_INSTANCE_ID
  2108. UNITY_VERTEX_OUTPUT_STEREO
  2109. };
  2110. CBUFFER_START(UnityPerMaterial)
  2111. #ifdef ASE_TESSELLATION
  2112. float _TessPhongStrength;
  2113. float _TessValue;
  2114. float _TessMin;
  2115. float _TessMax;
  2116. float _TessEdgeLength;
  2117. float _TessMaxDisp;
  2118. #endif
  2119. CBUFFER_END
  2120. /*ase_globals*/
  2121. /*ase_funcs*/
  2122. struct SurfaceDescription
  2123. {
  2124. float Alpha;
  2125. float AlphaClipThreshold;
  2126. };
  2127. PackedVaryings VertexFunction( Attributes input /*ase_vert_input*/ )
  2128. {
  2129. PackedVaryings output;
  2130. ZERO_INITIALIZE(PackedVaryings, output);
  2131. UNITY_SETUP_INSTANCE_ID(input);
  2132. UNITY_TRANSFER_INSTANCE_ID(input, output);
  2133. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
  2134. /*ase_vert_code:input=Attributes;output=PackedVaryings*/
  2135. #ifdef ASE_ABSOLUTE_VERTEX_POS
  2136. float3 defaultVertexValue = input.positionOS.xyz;
  2137. #else
  2138. float3 defaultVertexValue = float3(0, 0, 0);
  2139. #endif
  2140. float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;2;-1;_Vertex*/defaultVertexValue/*end*/;
  2141. #ifdef ASE_ABSOLUTE_VERTEX_POS
  2142. input.positionOS.xyz = vertexValue;
  2143. #else
  2144. input.positionOS.xyz += vertexValue;
  2145. #endif
  2146. input.normalOS = /*ase_vert_out:Vertex Normal;Float3;3;-1;_Normal*/input.normalOS/*end*/;
  2147. VertexPositionInputs vertexInput = GetVertexPositionInputs( input.positionOS.xyz );
  2148. output.positionCS = vertexInput.positionCS;
  2149. output.clipPosV = vertexInput.positionCS;
  2150. output.positionWS = vertexInput.positionWS;
  2151. output.normalWS = TransformObjectToWorldNormal( input.normalOS );
  2152. return output;
  2153. }
  2154. #if defined(ASE_TESSELLATION)
  2155. struct VertexControl
  2156. {
  2157. float4 positionOS : INTERNALTESSPOS;
  2158. float3 normalOS : NORMAL;
  2159. /*ase_vcontrol*/
  2160. UNITY_VERTEX_INPUT_INSTANCE_ID
  2161. };
  2162. struct TessellationFactors
  2163. {
  2164. float edge[3] : SV_TessFactor;
  2165. float inside : SV_InsideTessFactor;
  2166. };
  2167. VertexControl vert ( Attributes input )
  2168. {
  2169. VertexControl output;
  2170. UNITY_SETUP_INSTANCE_ID(input);
  2171. UNITY_TRANSFER_INSTANCE_ID(input, output);
  2172. output.positionOS = input.positionOS;
  2173. output.normalOS = input.normalOS;
  2174. /*ase_control_code:input=Attributes;output=VertexControl*/
  2175. return output;
  2176. }
  2177. TessellationFactors TessellationFunction (InputPatch<VertexControl,3> input)
  2178. {
  2179. TessellationFactors output;
  2180. float4 tf = 1;
  2181. float tessValue = /*ase_inline_begin*/_TessValue/*ase_inline_end*/; float tessMin = /*ase_inline_begin*/_TessMin/*ase_inline_end*/; float tessMax = /*ase_inline_begin*/_TessMax/*ase_inline_end*/;
  2182. float edgeLength = /*ase_inline_begin*/_TessEdgeLength/*ase_inline_end*/; float tessMaxDisp = /*ase_inline_begin*/_TessMaxDisp/*ase_inline_end*/;
  2183. #if defined(ASE_FIXED_TESSELLATION)
  2184. tf = FixedTess( tessValue );
  2185. #elif defined(ASE_DISTANCE_TESSELLATION)
  2186. tf = DistanceBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
  2187. #elif defined(ASE_LENGTH_TESSELLATION)
  2188. tf = EdgeLengthBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
  2189. #elif defined(ASE_LENGTH_CULL_TESSELLATION)
  2190. tf = EdgeLengthBasedTessCull(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
  2191. #endif
  2192. output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w;
  2193. return output;
  2194. }
  2195. [domain("tri")]
  2196. [partitioning("fractional_odd")]
  2197. [outputtopology("triangle_cw")]
  2198. [patchconstantfunc("TessellationFunction")]
  2199. [outputcontrolpoints(3)]
  2200. VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
  2201. {
  2202. return patch[id];
  2203. }
  2204. [domain("tri")]
  2205. PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
  2206. {
  2207. Attributes output = (Attributes) 0;
  2208. output.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z;
  2209. output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
  2210. /*ase_domain_code:patch=VertexControl;output=Attributes;bary=SV_DomainLocation*/
  2211. #if defined(ASE_PHONG_TESSELLATION)
  2212. float3 pp[3];
  2213. for (int i = 0; i < 3; ++i)
  2214. pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS));
  2215. float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/;
  2216. output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz;
  2217. #endif
  2218. UNITY_TRANSFER_INSTANCE_ID(patch[0], output);
  2219. return VertexFunction(output);
  2220. }
  2221. #else
  2222. PackedVaryings vert ( Attributes input )
  2223. {
  2224. return VertexFunction( input );
  2225. }
  2226. #endif
  2227. void frag(PackedVaryings input
  2228. , out half4 outNormalWS : SV_Target0
  2229. #ifdef ASE_DEPTH_WRITE_ON
  2230. ,out float outputDepth : ASE_SV_DEPTH
  2231. #endif
  2232. #ifdef _WRITE_RENDERING_LAYERS
  2233. , out float4 outRenderingLayers : SV_Target1
  2234. #endif
  2235. /*ase_frag_input*/ )
  2236. {
  2237. UNITY_SETUP_INSTANCE_ID(input);
  2238. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( input );
  2239. /*ase_local_var:wp*/float3 WorldPosition = input.positionWS;
  2240. /*ase_local_var:wn*/float3 WorldNormal = input.normalWS;
  2241. /*ase_local_var:sp*/float4 ClipPos = input.clipPosV;
  2242. /*ase_local_var:spu*/float4 ScreenPos = ComputeScreenPos( input.clipPosV );
  2243. /*ase_frag_code:input=PackedVaryings*/
  2244. float Alpha = /*ase_frag_out:Alpha;Float;0;-1;_Alpha*/1/*end*/;
  2245. float AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;1;-1;_AlphaClip*/0.5/*end*/;
  2246. #ifdef ASE_DEPTH_WRITE_ON
  2247. float DepthValue = /*ase_frag_out:Depth Value;Float;17;-1;_DepthValue*/input.positionCS.z/*end*/;
  2248. #endif
  2249. #ifdef _ALPHATEST_ON
  2250. clip(Alpha - AlphaClipThreshold);
  2251. #endif
  2252. #if defined(LOD_FADE_CROSSFADE)
  2253. LODFadeCrossFade( input.positionCS );
  2254. #endif
  2255. #ifdef ASE_DEPTH_WRITE_ON
  2256. outputDepth = DepthValue;
  2257. #endif
  2258. #if defined(_GBUFFER_NORMALS_OCT)
  2259. float3 normalWS = normalize(input.normalWS);
  2260. float2 octNormalWS = PackNormalOctQuadEncode(normalWS);
  2261. float2 remappedOctNormalWS = saturate(octNormalWS * 0.5 + 0.5);
  2262. half3 packedNormalWS = PackFloat2To888(remappedOctNormalWS);
  2263. outNormalWS = half4(packedNormalWS, 0.0);
  2264. #else
  2265. float3 normalWS = input.normalWS;
  2266. outNormalWS = half4(NormalizeNormalPerPixel(normalWS), 0.0);
  2267. #endif
  2268. #ifdef _WRITE_RENDERING_LAYERS
  2269. uint renderingLayers = GetMeshRenderingLayer();
  2270. outRenderingLayers = float4(EncodeMeshRenderingLayer(renderingLayers), 0, 0, 0);
  2271. #endif
  2272. }
  2273. ENDHLSL
  2274. }
  2275. /*ase_pass*/
  2276. Pass // -- DEPRECATED --
  2277. {
  2278. /*ase_hide_pass*/
  2279. Name "DepthNormalsOnly"
  2280. Tags
  2281. {
  2282. "LightMode" = "DepthNormalsOnly"
  2283. }
  2284. ZTest LEqual
  2285. ZWrite On
  2286. HLSLPROGRAM
  2287. #pragma exclude_renderers gles gles3 glcore
  2288. /*ase_srp_cond_begin:<140007*/
  2289. #pragma multi_compile _ DOTS_INSTANCING_ON
  2290. /*ase_srp_cond_end*/
  2291. #pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
  2292. /*ase_srp_cond_begin:<140007*/
  2293. #pragma multi_compile_fragment _ _WRITE_RENDERING_LAYERS
  2294. /*ase_srp_cond_end*/
  2295. #pragma vertex vert
  2296. #pragma fragment frag
  2297. #define ATTRIBUTES_NEED_NORMAL
  2298. #define ATTRIBUTES_NEED_TANGENT
  2299. #define ATTRIBUTES_NEED_TEXCOORD1
  2300. #define VARYINGS_NEED_NORMAL_WS
  2301. #define VARYINGS_NEED_TANGENT_WS
  2302. #define SHADERPASS SHADERPASS_DEPTHNORMALSONLY
  2303. /*ase_srp_cond_begin:>=140007*/
  2304. #if ASE_SRP_VERSION >=140007
  2305. #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
  2306. #endif
  2307. /*ase_srp_cond_end*/
  2308. /*ase_srp_cond_begin:>=140007*/
  2309. #if ASE_SRP_VERSION >=140007
  2310. #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"
  2311. #endif
  2312. /*ase_srp_cond_end*/
  2313. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  2314. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
  2315. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  2316. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  2317. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
  2318. /*ase_srp_cond_begin:>=140010*/
  2319. #if ASE_SRP_VERSION >=140010
  2320. #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
  2321. #endif
  2322. /*ase_srp_cond_end*/
  2323. /*ase_srp_cond_begin:<140010*/
  2324. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl"
  2325. /*ase_srp_cond_end*/
  2326. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  2327. #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
  2328. #if defined(LOD_FADE_CROSSFADE)
  2329. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl"
  2330. #endif
  2331. /*ase_pragma*/
  2332. struct Attributes
  2333. {
  2334. float4 positionOS : POSITION;
  2335. float3 normalOS : NORMAL;
  2336. /*ase_vdata:p=p;n=n*/
  2337. UNITY_VERTEX_INPUT_INSTANCE_ID
  2338. };
  2339. struct PackedVaryings
  2340. {
  2341. float4 positionCS : SV_POSITION;
  2342. float4 clipPosV : TEXCOORD0;
  2343. float3 normalWS : TEXCOORD1;
  2344. /*ase_interp(2,):sp=sp;wn=tc0*/
  2345. UNITY_VERTEX_INPUT_INSTANCE_ID
  2346. UNITY_VERTEX_OUTPUT_STEREO
  2347. };
  2348. CBUFFER_START(UnityPerMaterial)
  2349. #ifdef ASE_TESSELLATION
  2350. float _TessPhongStrength;
  2351. float _TessValue;
  2352. float _TessMin;
  2353. float _TessMax;
  2354. float _TessEdgeLength;
  2355. float _TessMaxDisp;
  2356. #endif
  2357. CBUFFER_END
  2358. /*ase_globals*/
  2359. /*ase_funcs*/
  2360. struct SurfaceDescription
  2361. {
  2362. float Alpha;
  2363. float AlphaClipThreshold;
  2364. };
  2365. PackedVaryings VertexFunction(Attributes input /*ase_vert_input*/ )
  2366. {
  2367. PackedVaryings output;
  2368. ZERO_INITIALIZE(PackedVaryings, output);
  2369. UNITY_SETUP_INSTANCE_ID(input);
  2370. UNITY_TRANSFER_INSTANCE_ID(input, output);
  2371. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
  2372. /*ase_vert_code:input=Attributes;output=PackedVaryings*/
  2373. #ifdef ASE_ABSOLUTE_VERTEX_POS
  2374. float3 defaultVertexValue = input.positionOS.xyz;
  2375. #else
  2376. float3 defaultVertexValue = float3(0, 0, 0);
  2377. #endif
  2378. float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;2;-1;_Vertex*/defaultVertexValue/*end*/;
  2379. #ifdef ASE_ABSOLUTE_VERTEX_POS
  2380. input.positionOS.xyz = vertexValue;
  2381. #else
  2382. input.positionOS.xyz += vertexValue;
  2383. #endif
  2384. input.normalOS = /*ase_vert_out:Vertex Normal;Float3;3;-1;_Normal*/input.normalOS/*end*/;
  2385. VertexPositionInputs vertexInput = GetVertexPositionInputs( input.positionOS.xyz );
  2386. output.positionCS = vertexInput.positionCS;
  2387. output.clipPosV = vertexInput.positionCS;
  2388. output.normalWS = TransformObjectToWorldNormal( input.normalOS );
  2389. return output;
  2390. }
  2391. #if defined(ASE_TESSELLATION)
  2392. struct VertexControl
  2393. {
  2394. float4 positionOS : INTERNALTESSPOS;
  2395. float3 normalOS : NORMAL;
  2396. /*ase_vcontrol*/
  2397. UNITY_VERTEX_INPUT_INSTANCE_ID
  2398. };
  2399. struct TessellationFactors
  2400. {
  2401. float edge[3] : SV_TessFactor;
  2402. float inside : SV_InsideTessFactor;
  2403. };
  2404. VertexControl vert ( Attributes input )
  2405. {
  2406. VertexControl output;
  2407. UNITY_SETUP_INSTANCE_ID(input);
  2408. UNITY_TRANSFER_INSTANCE_ID(input, output);
  2409. output.positionOS = input.positionOS;
  2410. output.normalOS = input.normalOS;
  2411. /*ase_control_code:input=Attributes;output=VertexControl*/
  2412. return output;
  2413. }
  2414. TessellationFactors TessellationFunction (InputPatch<VertexControl,3> input)
  2415. {
  2416. TessellationFactors output;
  2417. float4 tf = 1;
  2418. float tessValue = /*ase_inline_begin*/_TessValue/*ase_inline_end*/; float tessMin = /*ase_inline_begin*/_TessMin/*ase_inline_end*/; float tessMax = /*ase_inline_begin*/_TessMax/*ase_inline_end*/;
  2419. float edgeLength = /*ase_inline_begin*/_TessEdgeLength/*ase_inline_end*/; float tessMaxDisp = /*ase_inline_begin*/_TessMaxDisp/*ase_inline_end*/;
  2420. #if defined(ASE_FIXED_TESSELLATION)
  2421. tf = FixedTess( tessValue );
  2422. #elif defined(ASE_DISTANCE_TESSELLATION)
  2423. tf = DistanceBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
  2424. #elif defined(ASE_LENGTH_TESSELLATION)
  2425. tf = EdgeLengthBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
  2426. #elif defined(ASE_LENGTH_CULL_TESSELLATION)
  2427. tf = EdgeLengthBasedTessCull(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
  2428. #endif
  2429. output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w;
  2430. return output;
  2431. }
  2432. [domain("tri")]
  2433. [partitioning("fractional_odd")]
  2434. [outputtopology("triangle_cw")]
  2435. [patchconstantfunc("TessellationFunction")]
  2436. [outputcontrolpoints(3)]
  2437. VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
  2438. {
  2439. return patch[id];
  2440. }
  2441. [domain("tri")]
  2442. PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
  2443. {
  2444. Attributes output = (Attributes) 0;
  2445. output.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z;
  2446. output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
  2447. /*ase_domain_code:patch=VertexControl;output=Attributes;bary=SV_DomainLocation*/
  2448. #if defined(ASE_PHONG_TESSELLATION)
  2449. float3 pp[3];
  2450. for (int i = 0; i < 3; ++i)
  2451. pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS));
  2452. float phongStrength = /*ase_inline_begin*/_TessPhongStrength/*ase_inline_end*/;
  2453. output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz;
  2454. #endif
  2455. UNITY_TRANSFER_INSTANCE_ID(patch[0], output);
  2456. return VertexFunction(output);
  2457. }
  2458. #else
  2459. PackedVaryings vert ( Attributes input )
  2460. {
  2461. return VertexFunction( input );
  2462. }
  2463. #endif
  2464. half4 frag(PackedVaryings input /*ase_frag_input*/) : SV_Target
  2465. {
  2466. /*ase_local_var:sp*/float4 ClipPos = input.clipPosV;
  2467. /*ase_local_var:spu*/float4 ScreenPos = ComputeScreenPos( input.clipPosV );
  2468. /*ase_frag_code:input=PackedVaryings*/
  2469. float Alpha = /*ase_frag_out:Alpha;Float;0;-1;_Alpha*/1/*end*/;
  2470. float AlphaClipThreshold = /*ase_frag_out:Alpha Clip Threshold;Float;1;-1;_AlphaClip*/0.5/*end*/;
  2471. #if _ALPHATEST_ON
  2472. clip( Alpha - AlphaClipThreshold );
  2473. #endif
  2474. return half4( NormalizeNormalPerPixel( input.normalWS ), 0.0 );
  2475. }
  2476. ENDHLSL
  2477. }
  2478. /*ase_pass_end*/
  2479. }
  2480. /*ase_lod*/
  2481. CustomEditor "UnityEditor.ShaderGraphUnlitGUI"
  2482. FallBack "Hidden/Shader Graph/FallbackError"
  2483. }