No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TMP_SDFShaderGUI.cs 25KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789
  1. using UnityEngine;
  2. using UnityEditor;
  3. namespace TMPro.EditorUtilities
  4. {
  5. public class TMP_SDFShaderGUI : TMP_BaseShaderGUI
  6. {
  7. static ShaderFeature s_OutlineFeature, s_UnderlayFeature, s_BevelFeature, s_GlowFeature, s_MaskFeature;
  8. static bool s_Face = true, s_Outline = true, s_Outline2 = true, s_Outline3 = true, s_Underlay = true, s_Lighting = true, s_Glow, s_Bevel, s_Light, s_Bump, s_Env;
  9. static string[]
  10. s_FaceUVSpeedName = { "_FaceUVSpeed" },
  11. s_FaceUvSpeedNames = { "_FaceUVSpeedX", "_FaceUVSpeedY" },
  12. s_OutlineUvSpeedNames = { "_OutlineUVSpeedX", "_OutlineUVSpeedY" },
  13. s_OutlineUvSpeedName = { "_OutlineUVSpeed" };
  14. static TMP_SDFShaderGUI()
  15. {
  16. s_OutlineFeature = new ShaderFeature()
  17. {
  18. undoLabel = "Outline",
  19. keywords = new[] { "OUTLINE_ON" }
  20. };
  21. s_UnderlayFeature = new ShaderFeature()
  22. {
  23. undoLabel = "Underlay",
  24. keywords = new[] { "UNDERLAY_ON", "UNDERLAY_INNER" },
  25. label = new GUIContent("Underlay Type"),
  26. keywordLabels = new[]
  27. {
  28. new GUIContent("None"), new GUIContent("Normal"), new GUIContent("Inner")
  29. }
  30. };
  31. s_BevelFeature = new ShaderFeature()
  32. {
  33. undoLabel = "Bevel",
  34. keywords = new[] { "BEVEL_ON" }
  35. };
  36. s_GlowFeature = new ShaderFeature()
  37. {
  38. undoLabel = "Glow",
  39. keywords = new[] { "GLOW_ON" }
  40. };
  41. s_MaskFeature = new ShaderFeature()
  42. {
  43. undoLabel = "Mask",
  44. keywords = new[] { "MASK_HARD", "MASK_SOFT" },
  45. label = new GUIContent("Mask"),
  46. keywordLabels = new[]
  47. {
  48. new GUIContent("Mask Off"), new GUIContent("Mask Hard"), new GUIContent("Mask Soft")
  49. }
  50. };
  51. }
  52. protected override void DoGUI()
  53. {
  54. bool isSRPMaterial = m_Material.HasProperty(ShaderUtilities.ID_IsoPerimeter);
  55. s_Face = BeginPanel("Face", s_Face);
  56. if (s_Face)
  57. {
  58. DoFacePanel();
  59. }
  60. EndPanel();
  61. // Outline panels
  62. if (isSRPMaterial)
  63. {
  64. DoOutlinePanels();
  65. }
  66. else
  67. {
  68. s_Outline = m_Material.HasProperty(ShaderUtilities.ID_OutlineTex) ? BeginPanel("Outline", s_Outline) : BeginPanel("Outline", s_OutlineFeature, s_Outline);
  69. if (s_Outline)
  70. {
  71. DoOutlinePanel();
  72. }
  73. EndPanel();
  74. if (m_Material.HasProperty(ShaderUtilities.ID_Outline2Color))
  75. {
  76. s_Outline2 = BeginPanel("Outline 2", s_OutlineFeature, s_Outline2);
  77. if (s_Outline2)
  78. {
  79. DoOutline2Panel();
  80. }
  81. EndPanel();
  82. }
  83. }
  84. // Underlay panel
  85. if (m_Material.HasProperty(ShaderUtilities.ID_UnderlayColor))
  86. {
  87. if (isSRPMaterial)
  88. {
  89. s_Underlay = BeginPanel("Underlay", s_Underlay);
  90. if (s_Underlay)
  91. {
  92. DoUnderlayPanel();
  93. }
  94. EndPanel();
  95. }
  96. else
  97. {
  98. s_Underlay = BeginPanel("Underlay", s_UnderlayFeature, s_Underlay);
  99. if (s_Underlay)
  100. {
  101. DoUnderlayPanel();
  102. }
  103. EndPanel();
  104. }
  105. }
  106. // Lighting panel
  107. if (m_Material.HasProperty("_SpecularColor"))
  108. {
  109. if (isSRPMaterial)
  110. DrawLightingPanelSRP();
  111. else
  112. DrawLightingPanelLegacy();
  113. }
  114. else if (m_Material.HasProperty("_SpecColor"))
  115. {
  116. s_Bevel = BeginPanel("Bevel", s_Bevel);
  117. if (s_Bevel)
  118. {
  119. DoBevelPanel();
  120. }
  121. EndPanel();
  122. s_Light = BeginPanel("Surface Lighting", s_Light);
  123. if (s_Light)
  124. {
  125. DoSurfaceLightingPanel();
  126. }
  127. EndPanel();
  128. s_Bump = BeginPanel("Bump Map", s_Bump);
  129. if (s_Bump)
  130. {
  131. DoBumpMapPanel();
  132. }
  133. EndPanel();
  134. s_Env = BeginPanel("Environment Map", s_Env);
  135. if (s_Env)
  136. {
  137. DoEnvMapPanel();
  138. }
  139. EndPanel();
  140. }
  141. if (m_Material.HasProperty(ShaderUtilities.ID_GlowColor))
  142. {
  143. s_Glow = BeginPanel("Glow", s_GlowFeature, s_Glow);
  144. if (s_Glow)
  145. {
  146. DoGlowPanel();
  147. }
  148. EndPanel();
  149. }
  150. s_DebugExtended = BeginPanel("Debug Settings", s_DebugExtended);
  151. if (s_DebugExtended)
  152. {
  153. if (isSRPMaterial)
  154. DoDebugPanelSRP();
  155. else
  156. DoDebugPanel();
  157. }
  158. EndPanel();
  159. EditorGUILayout.Space();
  160. EditorGUILayout.Space();
  161. if (isSRPMaterial)
  162. {
  163. m_Editor.RenderQueueField();
  164. m_Editor.EnableInstancingField();
  165. m_Editor.DoubleSidedGIField();
  166. m_Editor.EmissionEnabledProperty();
  167. }
  168. }
  169. private void DrawLightingPanelSRP()
  170. {
  171. s_Lighting = BeginPanel("Lighting", s_Lighting);
  172. if (s_Lighting)
  173. {
  174. s_Bevel = BeginPanel("Bevel", s_Bevel);
  175. if (s_Bevel)
  176. {
  177. DoBevelPanelSRP();
  178. }
  179. EndPanel();
  180. s_Light = BeginPanel("Local Lighting", s_Light);
  181. if (s_Light)
  182. {
  183. DoLocalLightingPanel();
  184. }
  185. EndPanel();
  186. }
  187. EndPanel();
  188. }
  189. private void DrawLightingPanelLegacy()
  190. {
  191. s_Lighting = BeginPanel("Lighting", s_BevelFeature, s_Lighting);
  192. if (s_Lighting)
  193. {
  194. s_Bevel = BeginPanel("Bevel", s_Bevel);
  195. if (s_Bevel)
  196. {
  197. DoBevelPanel();
  198. }
  199. EndPanel();
  200. s_Light = BeginPanel("Local Lighting", s_Light);
  201. if (s_Light)
  202. {
  203. DoLocalLightingPanel();
  204. }
  205. EndPanel();
  206. s_Bump = BeginPanel("Bump Map", s_Bump);
  207. if (s_Bump)
  208. {
  209. DoBumpMapPanel();
  210. }
  211. EndPanel();
  212. s_Env = BeginPanel("Environment Map", s_Env);
  213. if (s_Env)
  214. {
  215. DoEnvMapPanel();
  216. }
  217. EndPanel();
  218. }
  219. EndPanel();
  220. }
  221. void DoFacePanel()
  222. {
  223. EditorGUI.indentLevel += 1;
  224. DoColor("_FaceColor", "Color");
  225. if (m_Material.HasProperty(ShaderUtilities.ID_FaceTex))
  226. {
  227. if (m_Material.HasProperty("_FaceUVSpeedX"))
  228. {
  229. DoTexture2D("_FaceTex", "Texture", true, s_FaceUvSpeedNames);
  230. }
  231. else if (m_Material.HasProperty("_FaceUVSpeed"))
  232. {
  233. DoTexture2D("_FaceTex", "Texture", true, s_FaceUVSpeedName);
  234. }
  235. else
  236. {
  237. DoTexture2D("_FaceTex", "Texture", true);
  238. }
  239. }
  240. if (m_Material.HasProperty("_Softness"))
  241. {
  242. DoSlider("_Softness", "X", new Vector2(0, 1), "Softness");
  243. }
  244. if (m_Material.HasProperty("_OutlineSoftness"))
  245. {
  246. DoSlider("_OutlineSoftness", "Softness");
  247. }
  248. if (m_Material.HasProperty(ShaderUtilities.ID_FaceDilate))
  249. {
  250. DoSlider("_FaceDilate", "Dilate");
  251. if (m_Material.HasProperty(ShaderUtilities.ID_Shininess))
  252. {
  253. DoSlider("_FaceShininess", "Gloss");
  254. }
  255. }
  256. if (m_Material.HasProperty(ShaderUtilities.ID_IsoPerimeter))
  257. {
  258. DoSlider("_IsoPerimeter", "X", new Vector2(-1, 1), "Dilate");
  259. }
  260. EditorGUI.indentLevel -= 1;
  261. EditorGUILayout.Space();
  262. }
  263. void DoOutlinePanel()
  264. {
  265. EditorGUI.indentLevel += 1;
  266. DoColor("_OutlineColor", "Color");
  267. if (m_Material.HasProperty(ShaderUtilities.ID_OutlineTex))
  268. {
  269. if (m_Material.HasProperty("_OutlineUVSpeedX"))
  270. {
  271. DoTexture2D("_OutlineTex", "Texture", true, s_OutlineUvSpeedNames);
  272. }
  273. else if (m_Material.HasProperty("_OutlineUVSpeed"))
  274. {
  275. DoTexture2D("_OutlineTex", "Texture", true, s_OutlineUvSpeedName);
  276. }
  277. else
  278. {
  279. DoTexture2D("_OutlineTex", "Texture", true);
  280. }
  281. }
  282. DoSlider("_OutlineWidth", "Thickness");
  283. if (m_Material.HasProperty("_OutlineShininess"))
  284. {
  285. DoSlider("_OutlineShininess", "Gloss");
  286. }
  287. EditorGUI.indentLevel -= 1;
  288. EditorGUILayout.Space();
  289. }
  290. void DoOutlinePanel(int outlineID, string propertyField, string label)
  291. {
  292. EditorGUI.indentLevel += 1;
  293. DoColor("_OutlineColor" + outlineID, label);
  294. if (outlineID != 3)
  295. DoOffset("_OutlineOffset" + outlineID, "Offset");
  296. else
  297. {
  298. if (m_Material.GetFloat(ShaderUtilities.ID_OutlineMode) == 0)
  299. DoOffset("_OutlineOffset" + outlineID, "Offset");
  300. }
  301. DoSlider("_Softness", propertyField, new Vector2(0, 1), "Softness");
  302. DoSlider("_IsoPerimeter", propertyField, new Vector2(-1, 1), "Dilate");
  303. if (outlineID == 3)
  304. {
  305. DoToggle("_OutlineMode", "Outline Mode");
  306. }
  307. if (m_Material.HasProperty("_OutlineShininess"))
  308. {
  309. //DoSlider("_OutlineShininess", "Gloss");
  310. }
  311. EditorGUI.indentLevel -= 1;
  312. EditorGUILayout.Space();
  313. }
  314. void DoOutlinePanelWithTexture(int outlineID, string propertyField, string label)
  315. {
  316. EditorGUI.indentLevel += 1;
  317. DoColor("_OutlineColor" + outlineID, label);
  318. if (m_Material.HasProperty(ShaderUtilities.ID_OutlineTex))
  319. {
  320. if (m_Material.HasProperty("_OutlineUVSpeedX"))
  321. {
  322. DoTexture2D("_OutlineTex", "Texture", true, s_OutlineUvSpeedNames);
  323. }
  324. else if (m_Material.HasProperty("_OutlineUVSpeed"))
  325. {
  326. DoTexture2D("_OutlineTex", "Texture", true, s_OutlineUvSpeedName);
  327. }
  328. else
  329. {
  330. DoTexture2D("_OutlineTex", "Texture", true);
  331. }
  332. }
  333. DoOffset("_OutlineOffset" + outlineID, "Offset");
  334. DoSlider("_Softness", propertyField, new Vector2(0, 1), "Softness");
  335. DoSlider("_IsoPerimeter", propertyField, new Vector2(-1, 1), "Dilate");
  336. if (m_Material.HasProperty("_OutlineShininess"))
  337. {
  338. //DoSlider("_OutlineShininess", "Gloss");
  339. }
  340. EditorGUI.indentLevel -= 1;
  341. EditorGUILayout.Space();
  342. }
  343. void DoOutline2Panel()
  344. {
  345. EditorGUI.indentLevel += 1;
  346. DoColor("_Outline2Color", "Color");
  347. //if (m_Material.HasProperty(ShaderUtilities.ID_OutlineTex))
  348. //{
  349. // if (m_Material.HasProperty("_OutlineUVSpeedX"))
  350. // {
  351. // DoTexture2D("_OutlineTex", "Texture", true, s_OutlineUvSpeedNames);
  352. // }
  353. // else
  354. // {
  355. // DoTexture2D("_OutlineTex", "Texture", true);
  356. // }
  357. //}
  358. DoSlider("_Outline2Width", "Thickness");
  359. //if (m_Material.HasProperty("_OutlineShininess"))
  360. //{
  361. // DoSlider("_OutlineShininess", "Gloss");
  362. //}
  363. EditorGUI.indentLevel -= 1;
  364. EditorGUILayout.Space();
  365. }
  366. void DoOutlinePanels()
  367. {
  368. s_Outline = BeginPanel("Outline 1", s_Outline);
  369. if (s_Outline)
  370. DoOutlinePanelWithTexture(1, "Y", "Color");
  371. EndPanel();
  372. s_Outline2 = BeginPanel("Outline 2", s_Outline2);
  373. if (s_Outline2)
  374. DoOutlinePanel(2, "Z", "Color");
  375. EndPanel();
  376. s_Outline3 = BeginPanel("Outline 3", s_Outline3);
  377. if (s_Outline3)
  378. DoOutlinePanel(3, "W", "Color");
  379. EndPanel();
  380. }
  381. void DoUnderlayPanel()
  382. {
  383. EditorGUI.indentLevel += 1;
  384. if (m_Material.HasProperty(ShaderUtilities.ID_IsoPerimeter))
  385. {
  386. DoColor("_UnderlayColor", "Color");
  387. DoSlider("_UnderlayOffset", "X", new Vector2(-1, 1), "Offset X");
  388. DoSlider("_UnderlayOffset", "Y", new Vector2(-1, 1), "Offset Y");
  389. DoSlider("_UnderlayDilate", new Vector2(-1, 1), "Dilate");
  390. DoSlider("_UnderlaySoftness", new Vector2(0, 1), "Softness");
  391. }
  392. else
  393. {
  394. s_UnderlayFeature.DoPopup(m_Editor, m_Material);
  395. DoColor("_UnderlayColor", "Color");
  396. DoSlider("_UnderlayOffsetX", "Offset X");
  397. DoSlider("_UnderlayOffsetY", "Offset Y");
  398. DoSlider("_UnderlayDilate", "Dilate");
  399. DoSlider("_UnderlaySoftness", "Softness");
  400. }
  401. EditorGUI.indentLevel -= 1;
  402. EditorGUILayout.Space();
  403. }
  404. static GUIContent[] s_BevelTypeLabels =
  405. {
  406. new GUIContent("Outer Bevel"),
  407. new GUIContent("Inner Bevel")
  408. };
  409. void DoBevelPanel()
  410. {
  411. EditorGUI.indentLevel += 1;
  412. DoPopup("_ShaderFlags", "Type", s_BevelTypeLabels);
  413. DoSlider("_Bevel", "Amount");
  414. DoSlider("_BevelOffset", "Offset");
  415. DoSlider("_BevelWidth", "Width");
  416. DoSlider("_BevelRoundness", "Roundness");
  417. DoSlider("_BevelClamp", "Clamp");
  418. EditorGUI.indentLevel -= 1;
  419. EditorGUILayout.Space();
  420. }
  421. void DoBevelPanelSRP()
  422. {
  423. EditorGUI.indentLevel += 1;
  424. DoPopup("_BevelType", "Type", s_BevelTypeLabels);
  425. DoSlider("_BevelAmount", "Amount");
  426. DoSlider("_BevelOffset", "Offset");
  427. DoSlider("_BevelWidth", "Width");
  428. DoSlider("_BevelRoundness", "Roundness");
  429. DoSlider("_BevelClamp", "Clamp");
  430. EditorGUI.indentLevel -= 1;
  431. EditorGUILayout.Space();
  432. }
  433. void DoLocalLightingPanel()
  434. {
  435. EditorGUI.indentLevel += 1;
  436. DoSlider("_LightAngle", "Light Angle");
  437. DoColor("_SpecularColor", "Specular Color");
  438. DoSlider("_SpecularPower", "Specular Power");
  439. DoSlider("_Reflectivity", "Reflectivity Power");
  440. DoSlider("_Diffuse", "Diffuse Shadow");
  441. DoSlider("_Ambient", "Ambient Shadow");
  442. EditorGUI.indentLevel -= 1;
  443. EditorGUILayout.Space();
  444. }
  445. void DoSurfaceLightingPanel()
  446. {
  447. EditorGUI.indentLevel += 1;
  448. DoColor("_SpecColor", "Specular Color");
  449. EditorGUI.indentLevel -= 1;
  450. EditorGUILayout.Space();
  451. }
  452. void DoBumpMapPanel()
  453. {
  454. EditorGUI.indentLevel += 1;
  455. DoTexture2D("_BumpMap", "Texture");
  456. DoSlider("_BumpFace", "Face");
  457. DoSlider("_BumpOutline", "Outline");
  458. EditorGUI.indentLevel -= 1;
  459. EditorGUILayout.Space();
  460. }
  461. void DoEnvMapPanel()
  462. {
  463. EditorGUI.indentLevel += 1;
  464. DoColor("_ReflectFaceColor", "Face Color");
  465. DoColor("_ReflectOutlineColor", "Outline Color");
  466. DoCubeMap("_Cube", "Texture");
  467. DoVector3("_EnvMatrixRotation", "Rotation");
  468. EditorGUI.indentLevel -= 1;
  469. EditorGUILayout.Space();
  470. }
  471. void DoGlowPanel()
  472. {
  473. EditorGUI.indentLevel += 1;
  474. DoColor("_GlowColor", "Color");
  475. DoSlider("_GlowOffset", "Offset");
  476. DoSlider("_GlowInner", "Inner");
  477. DoSlider("_GlowOuter", "Outer");
  478. DoSlider("_GlowPower", "Power");
  479. EditorGUI.indentLevel -= 1;
  480. EditorGUILayout.Space();
  481. }
  482. void DoDebugPanel()
  483. {
  484. EditorGUI.indentLevel += 1;
  485. DoTexture2D("_MainTex", "Font Atlas");
  486. DoFloat("_GradientScale", "Gradient Scale");
  487. DoFloat("_TextureWidth", "Texture Width");
  488. DoFloat("_TextureHeight", "Texture Height");
  489. EditorGUILayout.Space();
  490. DoFloat("_ScaleX", "Scale X");
  491. DoFloat("_ScaleY", "Scale Y");
  492. if (m_Material.HasProperty(ShaderUtilities.ID_Sharpness))
  493. DoSlider("_Sharpness", "Sharpness");
  494. DoSlider("_PerspectiveFilter", "Perspective Filter");
  495. EditorGUILayout.Space();
  496. DoFloat("_VertexOffsetX", "Offset X");
  497. DoFloat("_VertexOffsetY", "Offset Y");
  498. if (m_Material.HasProperty(ShaderUtilities.ID_MaskCoord))
  499. {
  500. EditorGUILayout.Space();
  501. s_MaskFeature.ReadState(m_Material);
  502. s_MaskFeature.DoPopup(m_Editor, m_Material);
  503. if (s_MaskFeature.Active)
  504. {
  505. DoMaskSubgroup();
  506. }
  507. EditorGUILayout.Space();
  508. DoVector("_ClipRect", "Clip Rect", s_LbrtVectorLabels);
  509. }
  510. else if (m_Material.HasProperty("_MaskTex"))
  511. {
  512. DoMaskTexSubgroup();
  513. }
  514. else if (m_Material.HasProperty(ShaderUtilities.ID_MaskSoftnessX))
  515. {
  516. EditorGUILayout.Space();
  517. DoFloat("_MaskSoftnessX", "Softness X");
  518. DoFloat("_MaskSoftnessY", "Softness Y");
  519. DoVector("_ClipRect", "Clip Rect", s_LbrtVectorLabels);
  520. }
  521. if (m_Material.HasProperty(ShaderUtilities.ID_StencilID))
  522. {
  523. EditorGUILayout.Space();
  524. DoFloat("_Stencil", "Stencil ID");
  525. DoFloat("_StencilComp", "Stencil Comp");
  526. }
  527. EditorGUILayout.Space();
  528. EditorGUI.BeginChangeCheck();
  529. bool useRatios = EditorGUILayout.Toggle("Use Ratios", !m_Material.IsKeywordEnabled("RATIOS_OFF"));
  530. if (EditorGUI.EndChangeCheck())
  531. {
  532. m_Editor.RegisterPropertyChangeUndo("Use Ratios");
  533. if (useRatios)
  534. {
  535. m_Material.DisableKeyword("RATIOS_OFF");
  536. }
  537. else
  538. {
  539. m_Material.EnableKeyword("RATIOS_OFF");
  540. }
  541. }
  542. if (m_Material.HasProperty(ShaderUtilities.ShaderTag_CullMode))
  543. {
  544. EditorGUILayout.Space();
  545. DoPopup("_CullMode", "Cull Mode", s_CullingTypeLabels);
  546. }
  547. EditorGUILayout.Space();
  548. EditorGUI.BeginDisabledGroup(true);
  549. DoFloat("_ScaleRatioA", "Scale Ratio A");
  550. DoFloat("_ScaleRatioB", "Scale Ratio B");
  551. DoFloat("_ScaleRatioC", "Scale Ratio C");
  552. EditorGUI.EndDisabledGroup();
  553. EditorGUI.indentLevel -= 1;
  554. EditorGUILayout.Space();
  555. }
  556. void DoDebugPanelSRP()
  557. {
  558. EditorGUI.indentLevel += 1;
  559. DoTexture2D("_MainTex", "Font Atlas");
  560. DoFloat("_GradientScale", "Gradient Scale");
  561. //DoFloat("_TextureWidth", "Texture Width");
  562. //DoFloat("_TextureHeight", "Texture Height");
  563. EditorGUILayout.Space();
  564. /*
  565. DoFloat("_ScaleX", "Scale X");
  566. DoFloat("_ScaleY", "Scale Y");
  567. if (m_Material.HasProperty(ShaderUtilities.ID_Sharpness))
  568. DoSlider("_Sharpness", "Sharpness");
  569. DoSlider("_PerspectiveFilter", "Perspective Filter");
  570. EditorGUILayout.Space();
  571. DoFloat("_VertexOffsetX", "Offset X");
  572. DoFloat("_VertexOffsetY", "Offset Y");
  573. if (m_Material.HasProperty(ShaderUtilities.ID_MaskCoord))
  574. {
  575. EditorGUILayout.Space();
  576. s_MaskFeature.ReadState(m_Material);
  577. s_MaskFeature.DoPopup(m_Editor, m_Material);
  578. if (s_MaskFeature.Active)
  579. {
  580. DoMaskSubgroup();
  581. }
  582. EditorGUILayout.Space();
  583. DoVector("_ClipRect", "Clip Rect", s_LbrtVectorLabels);
  584. }
  585. else if (m_Material.HasProperty("_MaskTex"))
  586. {
  587. DoMaskTexSubgroup();
  588. }
  589. else if (m_Material.HasProperty(ShaderUtilities.ID_MaskSoftnessX))
  590. {
  591. EditorGUILayout.Space();
  592. DoFloat("_MaskSoftnessX", "Softness X");
  593. DoFloat("_MaskSoftnessY", "Softness Y");
  594. DoVector("_ClipRect", "Clip Rect", s_LbrtVectorLabels);
  595. }
  596. if (m_Material.HasProperty(ShaderUtilities.ID_StencilID))
  597. {
  598. EditorGUILayout.Space();
  599. DoFloat("_Stencil", "Stencil ID");
  600. DoFloat("_StencilComp", "Stencil Comp");
  601. }
  602. EditorGUILayout.Space();
  603. EditorGUI.BeginChangeCheck();
  604. bool useRatios = EditorGUILayout.Toggle("Use Ratios", !m_Material.IsKeywordEnabled("RATIOS_OFF"));
  605. if (EditorGUI.EndChangeCheck())
  606. {
  607. m_Editor.RegisterPropertyChangeUndo("Use Ratios");
  608. if (useRatios)
  609. {
  610. m_Material.DisableKeyword("RATIOS_OFF");
  611. }
  612. else
  613. {
  614. m_Material.EnableKeyword("RATIOS_OFF");
  615. }
  616. }
  617. */
  618. if (m_Material.HasProperty(ShaderUtilities.ShaderTag_CullMode))
  619. {
  620. EditorGUILayout.Space();
  621. DoPopup("_CullMode", "Cull Mode", s_CullingTypeLabels);
  622. }
  623. EditorGUILayout.Space();
  624. /*
  625. EditorGUI.BeginDisabledGroup(true);
  626. DoFloat("_ScaleRatioA", "Scale Ratio A");
  627. DoFloat("_ScaleRatioB", "Scale Ratio B");
  628. DoFloat("_ScaleRatioC", "Scale Ratio C");
  629. EditorGUI.EndDisabledGroup();
  630. */
  631. EditorGUI.indentLevel -= 1;
  632. EditorGUILayout.Space();
  633. }
  634. void DoMaskSubgroup()
  635. {
  636. DoVector("_MaskCoord", "Mask Bounds", s_XywhVectorLabels);
  637. if (Selection.activeGameObject != null)
  638. {
  639. Renderer renderer = Selection.activeGameObject.GetComponent<Renderer>();
  640. if (renderer != null)
  641. {
  642. Rect rect = EditorGUILayout.GetControlRect();
  643. rect.x += EditorGUIUtility.labelWidth;
  644. rect.width -= EditorGUIUtility.labelWidth;
  645. if (GUI.Button(rect, "Match Renderer Bounds"))
  646. {
  647. FindProperty("_MaskCoord", m_Properties).vectorValue = new Vector4(
  648. 0,
  649. 0,
  650. Mathf.Round(renderer.bounds.extents.x * 1000) / 1000,
  651. Mathf.Round(renderer.bounds.extents.y * 1000) / 1000
  652. );
  653. }
  654. }
  655. }
  656. if (s_MaskFeature.State == 1)
  657. {
  658. DoFloat("_MaskSoftnessX", "Softness X");
  659. DoFloat("_MaskSoftnessY", "Softness Y");
  660. }
  661. }
  662. void DoMaskTexSubgroup()
  663. {
  664. EditorGUILayout.Space();
  665. DoTexture2D("_MaskTex", "Mask Texture");
  666. DoToggle("_MaskInverse", "Inverse Mask");
  667. DoColor("_MaskEdgeColor", "Edge Color");
  668. DoSlider("_MaskEdgeSoftness", "Edge Softness");
  669. DoSlider("_MaskWipeControl", "Wipe Position");
  670. DoFloat("_MaskSoftnessX", "Softness X");
  671. DoFloat("_MaskSoftnessY", "Softness Y");
  672. DoVector("_ClipRect", "Clip Rect", s_LbrtVectorLabels);
  673. }
  674. }
  675. }