2DLit.shader 23 KB

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