2DCustomLit.shader 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  1. Shader /*ase_name*/ "Hidden/Universal/2D Custom Lit" /*end*/
  2. {
  3. Properties
  4. {
  5. /*ase_props*/
  6. [HideInInspector][NoScaleOffset] unity_Lightmaps("unity_Lightmaps", 2DArray) = "" {}
  7. [HideInInspector][NoScaleOffset] unity_LightmapsInd("unity_LightmapsInd", 2DArray) = "" {}
  8. [HideInInspector][NoScaleOffset] unity_ShadowMasks("unity_ShadowMasks", 2DArray) = "" {}
  9. }
  10. SubShader
  11. {
  12. /*ase_subshader_options:Name=Additional Options
  13. Option:Vertex Position:Absolute,Relative:Relative
  14. Absolute:SetDefine:ASE_ABSOLUTE_VERTEX_POS 1
  15. Absolute:SetPortName:Sprite Lit:4,Vertex Position
  16. Relative:RemoveDefine:ASE_ABSOLUTE_VERTEX_POS 1
  17. Relative:SetPortName:Sprite Lit:4,Vertex Offset
  18. Option:Debug Display:false,true:false
  19. true:SetDefine:pragma multi_compile _ DEBUG_DISPLAY
  20. false,disable:RemoveDefine:pragma multi_compile _ DEBUG_DISPLAY
  21. */
  22. Tags
  23. {
  24. "RenderPipeline"="UniversalPipeline"
  25. "RenderType"="Transparent"
  26. "UniversalMaterialType" = "Lit"
  27. "Queue"="Transparent"
  28. "ShaderGraphShader"="true"
  29. "ShaderGraphTargetId"=""
  30. }
  31. Cull Off
  32. Blend SrcAlpha OneMinusSrcAlpha, One OneMinusSrcAlpha
  33. ZTest LEqual
  34. ZWrite Off
  35. Offset 0,0
  36. ColorMask RGBA
  37. /*ase_stencil*/
  38. HLSLINCLUDE
  39. #pragma target 2.0
  40. #pragma prefer_hlslcc gles
  41. #pragma exclude_renderers d3d9 // ensure rendering platforms toggle list is visible
  42. ENDHLSL
  43. /*ase_pass*/
  44. Pass
  45. {
  46. /*ase_hide_pass*/
  47. Name "Sprite Lit"
  48. Tags
  49. {
  50. "LightMode" = "Universal2D"
  51. }
  52. HLSLPROGRAM
  53. #pragma vertex vert
  54. #pragma fragment frag
  55. #define _SURFACE_TYPE_TRANSPARENT 1
  56. #define ATTRIBUTES_NEED_NORMAL
  57. #define ATTRIBUTES_NEED_TANGENT
  58. #define ATTRIBUTES_NEED_TEXCOORD0
  59. #define ATTRIBUTES_NEED_COLOR
  60. #define VARYINGS_NEED_POSITION_WS
  61. #define VARYINGS_NEED_TEXCOORD0
  62. #define VARYINGS_NEED_COLOR
  63. #define VARYINGS_NEED_SCREENPOSITION
  64. #define FEATURES_GRAPH_VERTEX
  65. #define SHADERPASS SHADERPASS_SPRITELIT
  66. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  67. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
  68. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  69. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  70. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl"
  71. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
  72. /*ase_unity_cond_begin:>=20220316*/
  73. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl"
  74. /*ase_unity_cond_end*/
  75. /*ase_unity_cond_begin:>=20220316*/
  76. #if ASE_SRP_VERSION >=140009
  77. #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
  78. #endif
  79. /*ase_unity_cond_end*/
  80. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  81. #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
  82. #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/SurfaceData2D.hlsl"
  83. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Debug/Debugging2D.hlsl"
  84. /*ase_pragma*/
  85. struct VertexInput
  86. {
  87. float3 positionOS : POSITION;
  88. float3 normal : NORMAL;
  89. float4 tangent : TANGENT;
  90. float4 uv0 : TEXCOORD0;
  91. float4 color : COLOR;
  92. /*ase_vdata:p=p;n=n;t=t;c=c;uv0=tc0*/
  93. UNITY_VERTEX_INPUT_INSTANCE_ID
  94. };
  95. struct VertexOutput
  96. {
  97. float4 positionCS : SV_POSITION;
  98. float4 texCoord0 : TEXCOORD0;
  99. float3 positionWS : TEXCOORD1;
  100. float4 color : TEXCOORD2;
  101. float4 screenPosition : TEXCOORD3;
  102. /*ase_interp(4,):sp=sp;uv0=tc0;wp=tc1;c=tc2;spn=tc3*/
  103. UNITY_VERTEX_INPUT_INSTANCE_ID
  104. UNITY_VERTEX_OUTPUT_STEREO
  105. };
  106. struct SurfaceDescription
  107. {
  108. float3 BaseColor;
  109. float Alpha;
  110. };
  111. half4 _RendererColor;
  112. /*ase_globals*/
  113. /*ase_funcs*/
  114. VertexOutput vert( VertexInput v /*ase_vert_input*/ )
  115. {
  116. VertexOutput o;
  117. ZERO_INITIALIZE(VertexOutput, o);
  118. UNITY_SETUP_INSTANCE_ID(v);
  119. UNITY_TRANSFER_INSTANCE_ID(v, o);
  120. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
  121. /*ase_vert_code:v=VertexInput;o=VertexOutput*/
  122. #ifdef ASE_ABSOLUTE_VERTEX_POS
  123. float3 defaultVertexValue = v.positionOS.xyz;
  124. #else
  125. float3 defaultVertexValue = float3(0, 0, 0);
  126. #endif
  127. float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;2;-1;_Vertex*/defaultVertexValue/*end*/;
  128. #ifdef ASE_ABSOLUTE_VERTEX_POS
  129. v.positionOS.xyz = vertexValue;
  130. #else
  131. v.positionOS.xyz += vertexValue;
  132. #endif
  133. v.normal = /*ase_vert_out:Vertex Normal;Float3;3;-1;_VNormal*/v.normal/*end*/;
  134. v.tangent.xyz = /*ase_vert_out:Vertex Tangent;Float3;4;-1;_VTangent*/v.tangent.xyz/*end*/;
  135. VertexPositionInputs vertexInput = GetVertexPositionInputs(v.positionOS.xyz);
  136. o.positionCS = vertexInput.positionCS;
  137. o.positionWS.xyz = vertexInput.positionWS;
  138. o.texCoord0.xyzw = v.uv0;
  139. o.color.xyzw = v.color;
  140. o.screenPosition.xyzw = vertexInput.positionNDC;
  141. return o;
  142. }
  143. half4 frag( VertexOutput IN /*ase_frag_input*/ ) : SV_TARGET
  144. {
  145. UNITY_SETUP_INSTANCE_ID(IN);
  146. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(IN);
  147. /*ase_frag_code:IN=VertexOutput*/
  148. SurfaceDescription surfaceDescription = (SurfaceDescription)0;
  149. surfaceDescription.BaseColor = /*ase_frag_out:Color;Float3;0;-1;_Color*/IsGammaSpace() ? float3(0.5, 0.5, 0.5) : SRGBToLinear(float3(0.5, 0.5, 0.5))/*end*/;
  150. surfaceDescription.Alpha = /*ase_frag_out:Alpha;Float;1;-1;_Alpha*/1/*end*/;
  151. half4 color = half4(surfaceDescription.BaseColor, surfaceDescription.Alpha);
  152. #if defined(DEBUG_DISPLAY)
  153. SurfaceData2D surfaceData;
  154. InitializeSurfaceData(color.rgb, color.a, surfaceData);
  155. InputData2D inputData;
  156. InitializeInputData(IN.positionWS.xy, half2(IN.texCoord0.xy), inputData);
  157. half4 debugColor = 0;
  158. SETUP_DEBUG_DATA_2D(inputData, IN.positionWS);
  159. if (CanDebugOverrideOutputColor(surfaceData, inputData, debugColor))
  160. {
  161. return debugColor;
  162. }
  163. #endif
  164. color *= IN.color * _RendererColor;
  165. return color;
  166. }
  167. ENDHLSL
  168. }
  169. /*ase_pass*/
  170. Pass
  171. {
  172. /*ase_hide_pass*/
  173. Name "Sprite Normal"
  174. Tags
  175. {
  176. "LightMode" = "NormalsRendering"
  177. }
  178. HLSLPROGRAM
  179. #pragma vertex vert
  180. #pragma fragment frag
  181. #define _SURFACE_TYPE_TRANSPARENT 1
  182. #define ATTRIBUTES_NEED_NORMAL
  183. #define ATTRIBUTES_NEED_TANGENT
  184. #define VARYINGS_NEED_NORMAL_WS
  185. #define VARYINGS_NEED_TANGENT_WS
  186. #define FEATURES_GRAPH_VERTEX
  187. #define SHADERPASS SHADERPASS_SPRITENORMAL
  188. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  189. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
  190. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  191. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  192. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl"
  193. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
  194. /*ase_unity_cond_begin:>=20220316*/
  195. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl"
  196. /*ase_unity_cond_end*/
  197. /*ase_unity_cond_begin:>=20220316*/
  198. #if ASE_SRP_VERSION >=140009
  199. #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
  200. #endif
  201. /*ase_unity_cond_end*/
  202. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  203. #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/NormalsRenderingShared.hlsl"
  204. #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
  205. /*ase_pragma*/
  206. /*ase_globals*/
  207. struct VertexInput
  208. {
  209. float3 positionOS : POSITION;
  210. float3 normal : NORMAL;
  211. float4 tangent : TANGENT;
  212. /*ase_vdata:p=p;n=n;t=t*/
  213. UNITY_VERTEX_INPUT_INSTANCE_ID
  214. };
  215. struct VertexOutput
  216. {
  217. float4 positionCS : SV_POSITION;
  218. float3 normalWS : TEXCOORD0;
  219. float4 tangentWS : TEXCOORD1;
  220. /*ase_interp(2,):sp=sp;wn=tc0;wt=tc1*/
  221. UNITY_VERTEX_INPUT_INSTANCE_ID
  222. UNITY_VERTEX_OUTPUT_STEREO
  223. };
  224. struct SurfaceDescription
  225. {
  226. float3 NormalTS;
  227. float Alpha;
  228. };
  229. /*ase_funcs*/
  230. VertexOutput vert( VertexInput v /*ase_vert_input*/ )
  231. {
  232. VertexOutput o;
  233. ZERO_INITIALIZE(VertexOutput, o);
  234. UNITY_SETUP_INSTANCE_ID(v);
  235. UNITY_TRANSFER_INSTANCE_ID(v, o);
  236. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
  237. /*ase_vert_code:v=VertexInput;o=VertexOutput*/
  238. #ifdef ASE_ABSOLUTE_VERTEX_POS
  239. float3 defaultVertexValue = v.positionOS.xyz;
  240. #else
  241. float3 defaultVertexValue = float3(0, 0, 0);
  242. #endif
  243. float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;2;-1;_Vertex*/defaultVertexValue/*end*/;
  244. #ifdef ASE_ABSOLUTE_VERTEX_POS
  245. v.positionOS.xyz = vertexValue;
  246. #else
  247. v.positionOS.xyz += vertexValue;
  248. #endif
  249. v.normal = /*ase_vert_out:Vertex Normal;Float3;3;-1;_VNormal*/v.normal/*end*/;
  250. v.tangent.xyz = /*ase_vert_out:Vertex Tangent;Float3;4;-1;_VTangent*/v.tangent.xyz/*end*/;
  251. float3 positionWS = TransformObjectToWorld(v.positionOS);
  252. float4 tangentWS = float4(TransformObjectToWorldDir(v.tangent.xyz), v.tangent.w);
  253. o.positionCS = TransformWorldToHClip(positionWS);
  254. o.normalWS.xyz = -GetViewForwardDir();
  255. o.tangentWS.xyzw = tangentWS;
  256. return o;
  257. }
  258. half4 frag( VertexOutput IN /*ase_frag_input*/ ) : SV_TARGET
  259. {
  260. UNITY_SETUP_INSTANCE_ID(IN);
  261. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(IN);
  262. /*ase_frag_code:IN=VertexOutput*/
  263. SurfaceDescription surfaceDescription = (SurfaceDescription)0;
  264. surfaceDescription.NormalTS = /*ase_frag_out:Normal;Float3;0;-1;_Normal*/float3(0.0f, 0.0f, 1.0f)/*end*/;
  265. surfaceDescription.Alpha = /*ase_frag_out:Alpha;Float;1;-1;_Alpha*/1/*end*/;
  266. half crossSign = (IN.tangentWS.w > 0.0 ? 1.0 : -1.0) * GetOddNegativeScale();
  267. half3 bitangent = crossSign * cross(IN.normalWS.xyz, IN.tangentWS.xyz);
  268. half4 color = half4(1.0,1.0,1.0, surfaceDescription.Alpha);
  269. return NormalsRenderingShared(color, surfaceDescription.NormalTS, IN.tangentWS.xyz, bitangent, IN.normalWS);
  270. }
  271. ENDHLSL
  272. }
  273. /*ase_pass*/
  274. Pass
  275. {
  276. /*ase_hide_pass*/
  277. Name "SceneSelectionPass"
  278. Tags
  279. {
  280. "LightMode" = "SceneSelectionPass"
  281. }
  282. Cull Off
  283. Blend Off
  284. ZTest LEqual
  285. ZWrite On
  286. HLSLPROGRAM
  287. #pragma vertex vert
  288. #pragma fragment frag
  289. #define _SURFACE_TYPE_TRANSPARENT 1
  290. #define ATTRIBUTES_NEED_NORMAL
  291. #define ATTRIBUTES_NEED_TANGENT
  292. #define FEATURES_GRAPH_VERTEX
  293. #define SHADERPASS SHADERPASS_DEPTHONLY
  294. #define SCENESELECTIONPASS 1
  295. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  296. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
  297. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  298. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  299. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl"
  300. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
  301. /*ase_unity_cond_begin:>=20220316*/
  302. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl"
  303. /*ase_unity_cond_end*/
  304. /*ase_unity_cond_begin:>=20220316*/
  305. #if ASE_SRP_VERSION >=140009
  306. #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
  307. #endif
  308. /*ase_unity_cond_end*/
  309. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  310. #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
  311. #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
  312. /*ase_pragma*/
  313. /*ase_globals*/
  314. struct VertexInput
  315. {
  316. float3 positionOS : POSITION;
  317. float3 normal : NORMAL;
  318. float4 tangent : TANGENT;
  319. /*ase_vdata:p=p;n=n;t=t*/
  320. UNITY_VERTEX_INPUT_INSTANCE_ID
  321. };
  322. struct VertexOutput
  323. {
  324. float4 positionCS : SV_POSITION;
  325. /*ase_interp(0,):sp=sp*/
  326. UNITY_VERTEX_INPUT_INSTANCE_ID
  327. UNITY_VERTEX_OUTPUT_STEREO
  328. };
  329. int _ObjectId;
  330. int _PassValue;
  331. struct SurfaceDescription
  332. {
  333. float Alpha;
  334. };
  335. /*ase_funcs*/
  336. VertexOutput vert(VertexInput v /*ase_vert_input*/)
  337. {
  338. VertexOutput o;
  339. ZERO_INITIALIZE(VertexOutput, o);
  340. UNITY_SETUP_INSTANCE_ID(v);
  341. UNITY_TRANSFER_INSTANCE_ID(v, o);
  342. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
  343. /*ase_vert_code:v=VertexInput;o=VertexOutput*/
  344. #ifdef ASE_ABSOLUTE_VERTEX_POS
  345. float3 defaultVertexValue = v.positionOS.xyz;
  346. #else
  347. float3 defaultVertexValue = float3(0, 0, 0);
  348. #endif
  349. float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;1;-1;_Vertex*/defaultVertexValue/*end*/;
  350. #ifdef ASE_ABSOLUTE_VERTEX_POS
  351. v.positionOS.xyz = vertexValue;
  352. #else
  353. v.positionOS.xyz += vertexValue;
  354. #endif
  355. float3 positionWS = TransformObjectToWorld(v.positionOS);
  356. o.positionCS = TransformWorldToHClip(positionWS);
  357. return o;
  358. }
  359. half4 frag(VertexOutput IN/*ase_frag_input*/) : SV_TARGET
  360. {
  361. UNITY_SETUP_INSTANCE_ID(IN);
  362. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(IN);
  363. /*ase_frag_code:IN=VertexOutput*/
  364. SurfaceDescription surfaceDescription = (SurfaceDescription)0;
  365. surfaceDescription.Alpha = /*ase_frag_out:Alpha;Float;0;-1;_Alpha*/1/*end*/;
  366. #if _ALPHATEST_ON
  367. float alphaClipThreshold = 0.01f;
  368. #if ALPHA_CLIP_THRESHOLD
  369. alphaClipThreshold = surfaceDescription.AlphaClipThreshold;
  370. #endif
  371. clip(surfaceDescription.Alpha - alphaClipThreshold);
  372. #endif
  373. half4 outColor = half4(_ObjectId, _PassValue, 1.0, 1.0);
  374. return outColor;
  375. }
  376. ENDHLSL
  377. }
  378. /*ase_pass*/
  379. Pass
  380. {
  381. /*ase_hide_pass*/
  382. Name "ScenePickingPass"
  383. Tags
  384. {
  385. "LightMode" = "Picking"
  386. }
  387. Cull Off
  388. Blend Off
  389. ZTest LEqual
  390. ZWrite On
  391. HLSLPROGRAM
  392. #pragma vertex vert
  393. #pragma fragment frag
  394. #define _SURFACE_TYPE_TRANSPARENT 1
  395. #define ATTRIBUTES_NEED_NORMAL
  396. #define ATTRIBUTES_NEED_TANGENT
  397. #define FEATURES_GRAPH_VERTEX
  398. #define SHADERPASS SHADERPASS_DEPTHONLY
  399. #define SCENEPICKINGPASS 1
  400. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  401. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
  402. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  403. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  404. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl"
  405. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
  406. /*ase_unity_cond_begin:>=20220316*/
  407. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl"
  408. /*ase_unity_cond_end*/
  409. /*ase_unity_cond_begin:>=20220316*/
  410. #if ASE_SRP_VERSION >=140009
  411. #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
  412. #endif
  413. /*ase_unity_cond_end*/
  414. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  415. #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
  416. #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
  417. /*ase_pragma*/
  418. /*ase_globals*/
  419. struct VertexInput
  420. {
  421. float3 positionOS : POSITION;
  422. float3 normal : NORMAL;
  423. float4 tangent : TANGENT;
  424. /*ase_vdata:p=p;n=n;t=t*/
  425. UNITY_VERTEX_INPUT_INSTANCE_ID
  426. };
  427. struct VertexOutput
  428. {
  429. float4 positionCS : SV_POSITION;
  430. /*ase_interp(0,):sp=sp*/
  431. UNITY_VERTEX_INPUT_INSTANCE_ID
  432. UNITY_VERTEX_OUTPUT_STEREO
  433. };
  434. float4 _SelectionID;
  435. struct SurfaceDescription
  436. {
  437. float Alpha;
  438. };
  439. /*ase_funcs*/
  440. VertexOutput vert(VertexInput v /*ase_vert_input*/ )
  441. {
  442. VertexOutput o;
  443. ZERO_INITIALIZE(VertexOutput, o);
  444. UNITY_SETUP_INSTANCE_ID(v);
  445. UNITY_TRANSFER_INSTANCE_ID(v, o);
  446. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
  447. /*ase_vert_code:v=VertexInput;o=VertexOutput*/
  448. #ifdef ASE_ABSOLUTE_VERTEX_POS
  449. float3 defaultVertexValue = v.positionOS.xyz;
  450. #else
  451. float3 defaultVertexValue = float3(0, 0, 0);
  452. #endif
  453. float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;1;-1;_Vertex*/defaultVertexValue/*end*/;
  454. #ifdef ASE_ABSOLUTE_VERTEX_POS
  455. v.positionOS.xyz = vertexValue;
  456. #else
  457. v.positionOS.xyz += vertexValue;
  458. #endif
  459. float3 positionWS = TransformObjectToWorld(v.positionOS);
  460. o.positionCS = TransformWorldToHClip(positionWS);
  461. return o;
  462. }
  463. half4 frag(VertexOutput IN /*ase_frag_input*/) : SV_TARGET
  464. {
  465. UNITY_SETUP_INSTANCE_ID(IN);
  466. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(IN);
  467. /*ase_frag_code:IN=VertexOutput*/
  468. SurfaceDescription surfaceDescription = (SurfaceDescription)0;
  469. surfaceDescription.Alpha = /*ase_frag_out:Alpha;Float;0;-1;_Alpha*/1/*end*/;
  470. #if _ALPHATEST_ON
  471. float alphaClipThreshold = 0.01f;
  472. #if ALPHA_CLIP_THRESHOLD
  473. alphaClipThreshold = surfaceDescription.AlphaClipThreshold;
  474. #endif
  475. clip(surfaceDescription.Alpha - alphaClipThreshold);
  476. #endif
  477. half4 outColor = _SelectionID;
  478. return outColor;
  479. }
  480. ENDHLSL
  481. }
  482. /*ase_pass*/
  483. Pass
  484. {
  485. /*ase_main_pass*/
  486. Name "Sprite Forward"
  487. Tags
  488. {
  489. "LightMode" = "UniversalForward"
  490. }
  491. HLSLPROGRAM
  492. #pragma vertex vert
  493. #pragma fragment frag
  494. #define _SURFACE_TYPE_TRANSPARENT 1
  495. #define ATTRIBUTES_NEED_NORMAL
  496. #define ATTRIBUTES_NEED_TANGENT
  497. #define ATTRIBUTES_NEED_TEXCOORD0
  498. #define ATTRIBUTES_NEED_COLOR
  499. #define VARYINGS_NEED_POSITION_WS
  500. #define VARYINGS_NEED_TEXCOORD0
  501. #define VARYINGS_NEED_COLOR
  502. #define FEATURES_GRAPH_VERTEX
  503. #define SHADERPASS SHADERPASS_SPRITEFORWARD
  504. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
  505. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
  506. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  507. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  508. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl"
  509. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
  510. /*ase_unity_cond_begin:>=20220316*/
  511. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl"
  512. /*ase_unity_cond_end*/
  513. /*ase_unity_cond_begin:>=20220316*/
  514. #if ASE_SRP_VERSION >=140009
  515. #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
  516. #endif
  517. /*ase_unity_cond_end*/
  518. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
  519. #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
  520. #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/SurfaceData2D.hlsl"
  521. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Debug/Debugging2D.hlsl"
  522. /*ase_pragma*/
  523. /*ase_globals*/
  524. struct VertexInput
  525. {
  526. float3 positionOS : POSITION;
  527. float3 normal : NORMAL;
  528. float4 tangent : TANGENT;
  529. float4 uv0 : TEXCOORD0;
  530. float4 color : COLOR;
  531. /*ase_vdata:p=p;n=n;t=t;c=c;uv0=tc0*/
  532. UNITY_VERTEX_INPUT_INSTANCE_ID
  533. };
  534. struct VertexOutput
  535. {
  536. float4 positionCS : SV_POSITION;
  537. float4 texCoord0 : TEXCOORD0;
  538. float3 positionWS : TEXCOORD1;
  539. float4 color : TEXCOORD2;
  540. /*ase_interp(3,):sp=sp;uv0=tc0;wp=tc1;c=tc2*/
  541. UNITY_VERTEX_INPUT_INSTANCE_ID
  542. UNITY_VERTEX_OUTPUT_STEREO
  543. };
  544. struct SurfaceDescription
  545. {
  546. float3 BaseColor;
  547. float Alpha;
  548. float3 NormalTS;
  549. };
  550. /*ase_funcs*/
  551. VertexOutput vert( VertexInput v /*ase_vert_input*/ )
  552. {
  553. VertexOutput o;
  554. ZERO_INITIALIZE(VertexOutput, o);
  555. UNITY_SETUP_INSTANCE_ID(v);
  556. UNITY_TRANSFER_INSTANCE_ID(v, o);
  557. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
  558. /*ase_vert_code:v=VertexInput;o=VertexOutput*/
  559. #ifdef ASE_ABSOLUTE_VERTEX_POS
  560. float3 defaultVertexValue = v.positionOS.xyz;
  561. #else
  562. float3 defaultVertexValue = float3( 0, 0, 0 );
  563. #endif
  564. float3 vertexValue = /*ase_vert_out:Vertex Offset;Float3;3;-1;_Vertex*/defaultVertexValue/*end*/;
  565. #ifdef ASE_ABSOLUTE_VERTEX_POS
  566. v.positionOS.xyz = vertexValue;
  567. #else
  568. v.positionOS.xyz += vertexValue;
  569. #endif
  570. v.normal = /*ase_vert_out:Vertex Normal;Float3;4;-1;_VNormal*/v.normal/*end*/;
  571. v.tangent.xyz = /*ase_vert_out:Vertex Tangent;Float3;5;-1;_VTangent*/v.tangent.xyz/*end*/;
  572. float3 positionWS = TransformObjectToWorld(v.positionOS);
  573. o.positionCS = TransformWorldToHClip(positionWS);
  574. o.positionWS.xyz = positionWS;
  575. o.texCoord0.xyzw = v.uv0;
  576. o.color.xyzw = v.color;
  577. return o;
  578. }
  579. half4 frag( VertexOutput IN /*ase_frag_input*/ ) : SV_TARGET
  580. {
  581. UNITY_SETUP_INSTANCE_ID(IN);
  582. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(IN);
  583. /*ase_frag_code:IN=VertexOutput*/
  584. SurfaceDescription surfaceDescription = (SurfaceDescription)0;
  585. surfaceDescription.BaseColor = /*ase_frag_out:Color;Float3;0;-1;_Color*/IsGammaSpace() ? float3(0.5, 0.5, 0.5) : SRGBToLinear(float3(0.5, 0.5, 0.5))/*end*/;
  586. surfaceDescription.NormalTS = /*ase_frag_out:Normal;Float3;1;-1;_Normal*/float3(0.0f, 0.0f, 1.0f)/*end*/;
  587. surfaceDescription.Alpha = /*ase_frag_out:Alpha;Float;2;-1;_Alpha*/1/*end*/;
  588. half4 color = half4(surfaceDescription.BaseColor, surfaceDescription.Alpha);
  589. #if defined(DEBUG_DISPLAY)
  590. SurfaceData2D surfaceData;
  591. InitializeSurfaceData(color.rgb, color.a, surfaceData);
  592. InputData2D inputData;
  593. InitializeInputData(IN.positionWS.xy, half2(IN.texCoord0.xy), inputData);
  594. half4 debugColor = 0;
  595. SETUP_DEBUG_DATA_2D(inputData, IN.positionWS);
  596. if (CanDebugOverrideOutputColor(surfaceData, inputData, debugColor))
  597. {
  598. return debugColor;
  599. }
  600. #endif
  601. color *= IN.color;
  602. return color;
  603. }
  604. ENDHLSL
  605. }
  606. /*ase_pass_end*/
  607. }
  608. CustomEditor "UnityEditor.ShaderGraph.GenericShaderGraphMaterialGUI"
  609. FallBack "Hidden/Shader Graph/FallbackError"
  610. }