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.

520 lines
22 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEditor;
  5. namespace AmplifyShaderEditor
  6. {
  7. [Serializable]
  8. public sealed class TemplatesStencilBufferModule : TemplateModuleParent
  9. {
  10. private const string FoldoutLabelStr = " Stencil Buffer";
  11. private GUIContent ReferenceValueContent = new GUIContent( "Reference", "The value to be compared against (if Comparison is anything else than always) and/or the value to be written to the buffer (if either Pass, Fail or ZFail is set to replace)" );
  12. private GUIContent ReadMaskContent = new GUIContent( "Read Mask", "An 8 bit mask as an 0-255 integer, used when comparing the reference value with the contents of the buffer (referenceValue & readMask) comparisonFunction (stencilBufferValue & readMask)" );
  13. private GUIContent WriteMaskContent = new GUIContent( "Write Mask", "An 8 bit mask as an 0-255 integer, used when writing to the buffer" );
  14. private const string ComparisonStr = "Comparison";
  15. private const string PassStr = "Pass";
  16. private const string FailStr = "Fail";
  17. private const string ZFailStr = "ZFail";
  18. private const string ComparisonFrontStr = "Comp. Front";
  19. private const string PassFrontStr = "Pass Front";
  20. private const string FailFrontStr = "Fail Front";
  21. private const string ZFailFrontStr = "ZFail Front";
  22. private const string ComparisonBackStr = "Comp. Back";
  23. private const string PassBackStr = "Pass Back";
  24. private const string FailBackStr = "Fail Back";
  25. private const string ZFailBackStr = "ZFail Back";
  26. private Dictionary<string, int> m_comparisonDict = new Dictionary<string, int>();
  27. private Dictionary<string, int> m_stencilOpsDict = new Dictionary<string, int>();
  28. [SerializeField]
  29. private bool m_active = true;
  30. [SerializeField]
  31. private InlineProperty m_reference = new InlineProperty();
  32. // Read Mask
  33. private const int ReadMaskDefaultValue = 255;
  34. [SerializeField]
  35. private InlineProperty m_readMask = new InlineProperty( ReadMaskDefaultValue );
  36. //Write Mask
  37. private const int WriteMaskDefaultValue = 255;
  38. [SerializeField]
  39. private InlineProperty m_writeMask = new InlineProperty( WriteMaskDefaultValue );
  40. //Comparison Function
  41. private const int ComparisonDefaultValue = 0;
  42. [SerializeField]
  43. private InlineProperty m_comparisonFunctionFrontIdx = new InlineProperty( ComparisonDefaultValue );
  44. [SerializeField]
  45. private InlineProperty m_comparisonFunctionBackIdx = new InlineProperty( ComparisonDefaultValue );
  46. //Pass Stencil Op
  47. private const int PassStencilOpDefaultValue = 0;
  48. [SerializeField]
  49. private InlineProperty m_passStencilOpFrontIdx = new InlineProperty( PassStencilOpDefaultValue );
  50. [SerializeField]
  51. private InlineProperty m_passStencilOpBackIdx = new InlineProperty( PassStencilOpDefaultValue );
  52. //Fail Stencil Op
  53. private const int FailStencilOpDefaultValue = 0;
  54. [SerializeField]
  55. private InlineProperty m_failStencilOpFrontIdx = new InlineProperty( FailStencilOpDefaultValue );
  56. [SerializeField]
  57. private InlineProperty m_failStencilOpBackIdx = new InlineProperty( FailStencilOpDefaultValue );
  58. //ZFail Stencil Op
  59. private const int ZFailStencilOpDefaultValue = 0;
  60. [SerializeField]
  61. private InlineProperty m_zFailStencilOpFrontIdx = new InlineProperty( ZFailStencilOpDefaultValue );
  62. [SerializeField]
  63. private InlineProperty m_zFailStencilOpBackIdx = new InlineProperty( ZFailStencilOpDefaultValue );
  64. public TemplatesStencilBufferModule() : base("Stencil Buffer")
  65. {
  66. for( int i = 0; i < StencilBufferOpHelper.StencilComparisonValues.Length; i++ )
  67. {
  68. m_comparisonDict.Add( StencilBufferOpHelper.StencilComparisonValues[ i ].ToLower(), i );
  69. }
  70. for( int i = 0; i < StencilBufferOpHelper.StencilOpsValues.Length; i++ )
  71. {
  72. m_stencilOpsDict.Add( StencilBufferOpHelper.StencilOpsValues[ i ].ToLower(), i );
  73. }
  74. }
  75. public void CopyFrom( TemplatesStencilBufferModule other , bool allData )
  76. {
  77. if( allData )
  78. m_independentModule = other.IndependentModule;
  79. m_active = other.Active;
  80. m_reference.CopyFrom( other.Reference );
  81. m_readMask.CopyFrom( other.ReadMask );
  82. m_writeMask.CopyFrom( other.WriteMask );
  83. m_comparisonFunctionFrontIdx.CopyFrom( other.ComparisonFunctionIdx );
  84. m_comparisonFunctionBackIdx.CopyFrom( other.ComparisonFunctionBackIdx );
  85. m_passStencilOpFrontIdx.CopyFrom( other.PassStencilOpIdx );
  86. m_passStencilOpBackIdx.CopyFrom( other.PassStencilOpBackIdx );
  87. m_failStencilOpFrontIdx.CopyFrom( other.FailStencilOpIdx );
  88. m_failStencilOpBackIdx.CopyFrom( other.FailStencilOpBackIdx );
  89. m_zFailStencilOpFrontIdx.CopyFrom( other.ZFailStencilOpIdx );
  90. m_zFailStencilOpBackIdx.CopyFrom( other.ZFailStencilOpBackIdx );
  91. }
  92. public void ConfigureFromTemplateData( TemplateStencilData stencilData )
  93. {
  94. bool newValidData = ( stencilData.DataCheck == TemplateDataCheck.Valid );
  95. if( newValidData && m_validData != newValidData )
  96. {
  97. m_active = stencilData.Active;
  98. m_independentModule = stencilData.IndependentModule;
  99. if( string.IsNullOrEmpty( stencilData.ReferenceInline ) )
  100. {
  101. m_reference.IntValue = stencilData.Reference;
  102. m_reference.ResetProperty();
  103. }
  104. else
  105. {
  106. m_reference.SetInlineByName( stencilData.ReferenceInline );
  107. }
  108. if( string.IsNullOrEmpty( stencilData.ReadMaskInline ) )
  109. {
  110. m_readMask.IntValue = stencilData.ReadMask;
  111. m_readMask.ResetProperty();
  112. }
  113. else
  114. {
  115. m_readMask.SetInlineByName( stencilData.ReadMaskInline );
  116. }
  117. if( string.IsNullOrEmpty( stencilData.WriteMaskInline ) )
  118. {
  119. m_writeMask.IntValue = stencilData.WriteMask;
  120. m_writeMask.ResetProperty();
  121. }
  122. else
  123. {
  124. m_writeMask.SetInlineByName( stencilData.WriteMaskInline );
  125. }
  126. if( string.IsNullOrEmpty( stencilData.ComparisonFrontInline ) )
  127. {
  128. if( !string.IsNullOrEmpty( stencilData.ComparisonFront ) )
  129. {
  130. m_comparisonFunctionFrontIdx.IntValue = m_comparisonDict[ stencilData.ComparisonFront.ToLower() ];
  131. }
  132. else
  133. {
  134. m_comparisonFunctionFrontIdx.IntValue = m_comparisonDict[ "always" ];
  135. }
  136. m_comparisonFunctionFrontIdx.ResetProperty();
  137. }
  138. else
  139. {
  140. m_comparisonFunctionFrontIdx.SetInlineByName( stencilData.ComparisonFrontInline );
  141. }
  142. if( string.IsNullOrEmpty( stencilData.PassFrontInline ) )
  143. {
  144. if( !string.IsNullOrEmpty( stencilData.PassFront ) )
  145. {
  146. m_passStencilOpFrontIdx.IntValue = m_stencilOpsDict[ stencilData.PassFront.ToLower() ];
  147. }
  148. else
  149. {
  150. m_passStencilOpFrontIdx.IntValue = m_stencilOpsDict[ "keep" ];
  151. }
  152. m_passStencilOpFrontIdx.ResetProperty();
  153. }
  154. else
  155. {
  156. m_passStencilOpFrontIdx.SetInlineByName( stencilData.PassFrontInline );
  157. }
  158. if( string.IsNullOrEmpty( stencilData.FailFrontInline ) )
  159. {
  160. if( !string.IsNullOrEmpty( stencilData.FailFront ) )
  161. {
  162. m_failStencilOpFrontIdx.IntValue = m_stencilOpsDict[ stencilData.FailFront.ToLower() ];
  163. }
  164. else
  165. {
  166. m_failStencilOpFrontIdx.IntValue = m_stencilOpsDict[ "keep" ];
  167. }
  168. m_failStencilOpFrontIdx.ResetProperty();
  169. }
  170. else
  171. {
  172. m_failStencilOpFrontIdx.SetInlineByName( stencilData.FailFrontInline );
  173. }
  174. if( string.IsNullOrEmpty( stencilData.ZFailFrontInline ) )
  175. {
  176. if( !string.IsNullOrEmpty( stencilData.ZFailFront ) )
  177. {
  178. m_zFailStencilOpFrontIdx.IntValue = m_stencilOpsDict[ stencilData.ZFailFront.ToLower() ];
  179. }
  180. else
  181. {
  182. m_zFailStencilOpFrontIdx.IntValue = m_stencilOpsDict[ "keep" ];
  183. }
  184. m_zFailStencilOpFrontIdx.ResetProperty();
  185. }
  186. else
  187. {
  188. m_zFailStencilOpFrontIdx.SetInlineByName( stencilData.ZFailFrontInline );
  189. }
  190. if( string.IsNullOrEmpty( stencilData.ComparisonBackInline ) )
  191. {
  192. if( !string.IsNullOrEmpty( stencilData.ComparisonBack ) )
  193. {
  194. m_comparisonFunctionBackIdx.IntValue = m_comparisonDict[ stencilData.ComparisonBack.ToLower() ];
  195. }
  196. else
  197. {
  198. m_comparisonFunctionBackIdx.IntValue = m_comparisonDict[ "always" ];
  199. }
  200. m_comparisonFunctionBackIdx.ResetProperty();
  201. }
  202. else
  203. {
  204. m_comparisonFunctionBackIdx.SetInlineByName( stencilData.ComparisonBackInline );
  205. }
  206. if( string.IsNullOrEmpty( stencilData.PassBackInline ) )
  207. {
  208. if( !string.IsNullOrEmpty( stencilData.PassBack ) )
  209. {
  210. m_passStencilOpBackIdx.IntValue = m_stencilOpsDict[ stencilData.PassBack.ToLower() ];
  211. }
  212. else
  213. {
  214. m_passStencilOpBackIdx.IntValue = m_stencilOpsDict[ "keep" ];
  215. }
  216. m_passStencilOpBackIdx.ResetProperty();
  217. }
  218. else
  219. {
  220. m_passStencilOpBackIdx.SetInlineByName( stencilData.PassBackInline );
  221. }
  222. if( string.IsNullOrEmpty( stencilData.FailBackInline ) )
  223. {
  224. if( !string.IsNullOrEmpty( stencilData.FailBack ) )
  225. {
  226. m_failStencilOpBackIdx.IntValue = m_stencilOpsDict[ stencilData.FailBack.ToLower() ];
  227. }
  228. else
  229. {
  230. m_failStencilOpBackIdx.IntValue = m_stencilOpsDict[ "keep" ];
  231. }
  232. m_failStencilOpBackIdx.ResetProperty();
  233. }
  234. else
  235. {
  236. m_failStencilOpBackIdx.SetInlineByName( stencilData.FailBackInline );
  237. }
  238. if( string.IsNullOrEmpty( stencilData.ZFailBackInline ) )
  239. {
  240. if( !string.IsNullOrEmpty( stencilData.ZFailBack ) )
  241. {
  242. m_zFailStencilOpBackIdx.IntValue = m_stencilOpsDict[ stencilData.ZFailBack.ToLower() ];
  243. }
  244. else
  245. {
  246. m_zFailStencilOpBackIdx.IntValue = m_stencilOpsDict[ "keep" ];
  247. }
  248. m_zFailStencilOpBackIdx.ResetProperty();
  249. }
  250. else
  251. {
  252. m_zFailStencilOpBackIdx.SetInlineByName( stencilData.ZFailBackInline );
  253. }
  254. }
  255. m_validData = newValidData;
  256. }
  257. public string CreateStencilOp( CullMode cullMode )
  258. {
  259. if( !m_active )
  260. return string.Empty;
  261. string result = "Stencil\n{\n";
  262. result += string.Format( "\tRef {0}\n", m_reference.GetValueOrProperty() );
  263. if( m_readMask.IsValid || m_readMask.IntValue != ReadMaskDefaultValue )
  264. {
  265. result += string.Format( "\tReadMask {0}\n", m_readMask.GetValueOrProperty() );
  266. }
  267. if( m_writeMask.IsValid || m_writeMask.IntValue != WriteMaskDefaultValue )
  268. {
  269. result += string.Format( "\tWriteMask {0}\n", m_writeMask.GetValueOrProperty() );
  270. }
  271. if( cullMode == CullMode.Off &&
  272. ( m_comparisonFunctionBackIdx.IsValid || m_comparisonFunctionBackIdx.IntValue != ComparisonDefaultValue ||
  273. m_passStencilOpBackIdx.IsValid || m_passStencilOpBackIdx.IntValue != PassStencilOpDefaultValue ||
  274. m_failStencilOpBackIdx.IsValid || m_failStencilOpBackIdx.IntValue != FailStencilOpDefaultValue ||
  275. m_zFailStencilOpBackIdx.IsValid || m_zFailStencilOpBackIdx.IntValue != ZFailStencilOpDefaultValue ) )
  276. {
  277. if( m_comparisonFunctionFrontIdx.IsValid || m_comparisonFunctionFrontIdx.IntValue != ComparisonDefaultValue )
  278. result += string.Format( "\tCompFront {0}\n", m_comparisonFunctionFrontIdx.GetValueOrProperty( StencilBufferOpHelper.StencilComparisonValues[ m_comparisonFunctionFrontIdx.IntValue ] ) );
  279. if( m_passStencilOpFrontIdx.IsValid || m_passStencilOpFrontIdx.IntValue != PassStencilOpDefaultValue )
  280. result += string.Format( "\tPassFront {0}\n", m_passStencilOpFrontIdx.GetValueOrProperty( StencilBufferOpHelper.StencilOpsValues[ m_passStencilOpFrontIdx.IntValue ] ) );
  281. if( m_failStencilOpFrontIdx.IsValid || m_failStencilOpFrontIdx.IntValue != FailStencilOpDefaultValue )
  282. result += string.Format( "\tFailFront {0}\n", m_failStencilOpFrontIdx.GetValueOrProperty( StencilBufferOpHelper.StencilOpsValues[ m_failStencilOpFrontIdx.IntValue ] ) );
  283. if( m_zFailStencilOpFrontIdx.IsValid || m_zFailStencilOpFrontIdx.IntValue != ZFailStencilOpDefaultValue )
  284. result += string.Format( "\tZFailFront {0}\n", m_zFailStencilOpFrontIdx.GetValueOrProperty( StencilBufferOpHelper.StencilOpsValues[ m_zFailStencilOpFrontIdx.IntValue ] ) );
  285. if( m_comparisonFunctionBackIdx.IsValid || m_comparisonFunctionBackIdx.IntValue != ComparisonDefaultValue )
  286. result += string.Format( "\tCompBack {0}\n", m_comparisonFunctionBackIdx.GetValueOrProperty( StencilBufferOpHelper.StencilComparisonValues[ m_comparisonFunctionBackIdx.IntValue ] ) );
  287. if( m_passStencilOpBackIdx.IsValid || m_passStencilOpBackIdx.IntValue != PassStencilOpDefaultValue )
  288. result += string.Format( "\tPassBack {0}\n", m_passStencilOpBackIdx.GetValueOrProperty( StencilBufferOpHelper.StencilOpsValues[ m_passStencilOpBackIdx.IntValue ] ) );
  289. if( m_failStencilOpBackIdx.IsValid || m_failStencilOpBackIdx.IntValue != FailStencilOpDefaultValue )
  290. result += string.Format( "\tFailBack {0}\n", m_failStencilOpBackIdx.GetValueOrProperty( StencilBufferOpHelper.StencilOpsValues[ m_failStencilOpBackIdx.IntValue ] ));
  291. if( m_zFailStencilOpBackIdx.IsValid || m_zFailStencilOpBackIdx.IntValue != ZFailStencilOpDefaultValue )
  292. result += string.Format( "\tZFailBack {0}\n", m_zFailStencilOpBackIdx.GetValueOrProperty( StencilBufferOpHelper.StencilOpsValues[ m_zFailStencilOpBackIdx.IntValue ] ));
  293. }
  294. else
  295. {
  296. if( m_comparisonFunctionFrontIdx.IsValid || m_comparisonFunctionFrontIdx.IntValue != ComparisonDefaultValue )
  297. result += string.Format( "\tComp {0}\n", m_comparisonFunctionFrontIdx.GetValueOrProperty(StencilBufferOpHelper.StencilComparisonValues[ m_comparisonFunctionFrontIdx.IntValue ] ));
  298. if( m_passStencilOpFrontIdx.IsValid || m_passStencilOpFrontIdx.IntValue != PassStencilOpDefaultValue )
  299. result += string.Format( "\tPass {0}\n", m_passStencilOpFrontIdx.GetValueOrProperty( StencilBufferOpHelper.StencilOpsValues[ m_passStencilOpFrontIdx.IntValue ] ));
  300. if( m_failStencilOpFrontIdx.IsValid || m_failStencilOpFrontIdx.IntValue != FailStencilOpDefaultValue )
  301. result += string.Format( "\tFail {0}\n", m_failStencilOpFrontIdx.GetValueOrProperty( StencilBufferOpHelper.StencilOpsValues[ m_failStencilOpFrontIdx.IntValue ] ));
  302. if( m_zFailStencilOpFrontIdx.IsValid || m_zFailStencilOpFrontIdx.IntValue != ZFailStencilOpDefaultValue )
  303. result += string.Format( "\tZFail {0}\n", m_zFailStencilOpFrontIdx.GetValueOrProperty(StencilBufferOpHelper.StencilOpsValues[ m_zFailStencilOpFrontIdx.IntValue ] ));
  304. }
  305. result += "}";
  306. return result;
  307. }
  308. public override void ShowUnreadableDataMessage( ParentNode owner )
  309. {
  310. bool foldout = owner.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedStencilOptions;
  311. NodeUtils.DrawPropertyGroup( ref foldout, FoldoutLabelStr, base.ShowUnreadableDataMessage );
  312. owner.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedStencilOptions = foldout;
  313. }
  314. public void Draw( UndoParentNode owner, CullMode cullMode , bool style = true )
  315. {
  316. bool foldout = owner.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedStencilOptions;
  317. if( style )
  318. {
  319. NodeUtils.DrawPropertyGroup( ref foldout, FoldoutLabelStr, () =>
  320. {
  321. DrawBlock( owner, cullMode );
  322. } );
  323. }
  324. else
  325. {
  326. NodeUtils.DrawNestedPropertyGroup( owner, ref foldout, ref m_active, FoldoutLabelStr, () =>
  327. {
  328. DrawBlock( owner, cullMode );
  329. } );
  330. }
  331. owner.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedStencilOptions = foldout;
  332. }
  333. void DrawBlock( UndoParentNode owner, CullMode cullMode )
  334. {
  335. bool guiEnabled = GUI.enabled;
  336. GUI.enabled = m_active;
  337. EditorGUI.BeginChangeCheck();
  338. {
  339. m_reference.IntSlider( ref owner, ReferenceValueContent, 0, 255 );
  340. m_readMask.IntSlider( ref owner, ReadMaskContent, 0, 255 );
  341. m_writeMask.IntSlider( ref owner, WriteMaskContent, 0, 255 );
  342. if( cullMode == CullMode.Off )
  343. {
  344. m_comparisonFunctionFrontIdx.EnumTypePopup( ref owner, ComparisonFrontStr, StencilBufferOpHelper.StencilComparisonLabels );
  345. m_passStencilOpFrontIdx.EnumTypePopup( ref owner, PassFrontStr, StencilBufferOpHelper.StencilOpsLabels );
  346. m_failStencilOpFrontIdx.EnumTypePopup( ref owner, FailFrontStr, StencilBufferOpHelper.StencilOpsLabels );
  347. m_zFailStencilOpFrontIdx.EnumTypePopup( ref owner, ZFailFrontStr, StencilBufferOpHelper.StencilOpsLabels );
  348. EditorGUILayout.Separator();
  349. m_comparisonFunctionBackIdx.EnumTypePopup( ref owner, ComparisonBackStr, StencilBufferOpHelper.StencilComparisonLabels );
  350. m_passStencilOpBackIdx.EnumTypePopup( ref owner, PassBackStr, StencilBufferOpHelper.StencilOpsLabels );
  351. m_failStencilOpBackIdx.EnumTypePopup( ref owner, FailBackStr, StencilBufferOpHelper.StencilOpsLabels );
  352. m_zFailStencilOpBackIdx.EnumTypePopup( ref owner, ZFailBackStr, StencilBufferOpHelper.StencilOpsLabels );
  353. }
  354. else
  355. {
  356. m_comparisonFunctionFrontIdx.EnumTypePopup( ref owner, ComparisonStr, StencilBufferOpHelper.StencilComparisonLabels );
  357. m_passStencilOpFrontIdx.EnumTypePopup( ref owner, PassFrontStr, StencilBufferOpHelper.StencilOpsLabels );
  358. m_failStencilOpFrontIdx.EnumTypePopup( ref owner, FailFrontStr, StencilBufferOpHelper.StencilOpsLabels );
  359. m_zFailStencilOpFrontIdx.EnumTypePopup( ref owner, ZFailFrontStr, StencilBufferOpHelper.StencilOpsLabels );
  360. }
  361. }
  362. if( EditorGUI.EndChangeCheck() )
  363. {
  364. m_isDirty = true;
  365. }
  366. GUI.enabled = guiEnabled;
  367. }
  368. public override void ReadFromString( ref uint index, ref string[] nodeParams )
  369. {
  370. bool validDataOnMeta = m_validData;
  371. if( UIUtils.CurrentShaderVersion() > TemplatesManager.MPShaderVersion )
  372. {
  373. validDataOnMeta = Convert.ToBoolean( nodeParams[ index++ ] );
  374. }
  375. if( validDataOnMeta )
  376. {
  377. if( UIUtils.CurrentShaderVersion() > 15307 )
  378. {
  379. m_active = Convert.ToBoolean( nodeParams[ index++ ] );
  380. }
  381. if( UIUtils.CurrentShaderVersion() < 15304 )
  382. {
  383. m_reference.IntValue = Convert.ToInt32( nodeParams[ index++ ] );
  384. m_readMask.IntValue = Convert.ToInt32( nodeParams[ index++ ] );
  385. m_writeMask.IntValue = Convert.ToInt32( nodeParams[ index++ ] );
  386. m_comparisonFunctionFrontIdx.IntValue = Convert.ToInt32( nodeParams[ index++ ] );
  387. m_passStencilOpFrontIdx.IntValue = Convert.ToInt32( nodeParams[ index++ ] );
  388. m_failStencilOpFrontIdx.IntValue = Convert.ToInt32( nodeParams[ index++ ] );
  389. m_zFailStencilOpFrontIdx.IntValue = Convert.ToInt32( nodeParams[ index++ ] );
  390. m_comparisonFunctionBackIdx.IntValue = Convert.ToInt32( nodeParams[ index++ ] );
  391. m_passStencilOpBackIdx.IntValue = Convert.ToInt32( nodeParams[ index++ ] );
  392. m_failStencilOpBackIdx.IntValue = Convert.ToInt32( nodeParams[ index++ ] );
  393. m_zFailStencilOpBackIdx.IntValue = Convert.ToInt32( nodeParams[ index++ ] );
  394. }
  395. else
  396. {
  397. m_reference.ReadFromString( ref index, ref nodeParams );
  398. m_readMask.ReadFromString( ref index, ref nodeParams );
  399. m_writeMask.ReadFromString( ref index, ref nodeParams );
  400. m_comparisonFunctionFrontIdx.ReadFromString( ref index, ref nodeParams );
  401. m_passStencilOpFrontIdx.ReadFromString( ref index, ref nodeParams );
  402. m_failStencilOpFrontIdx.ReadFromString( ref index, ref nodeParams );
  403. m_zFailStencilOpFrontIdx.ReadFromString( ref index, ref nodeParams );
  404. m_comparisonFunctionBackIdx.ReadFromString( ref index, ref nodeParams );
  405. m_passStencilOpBackIdx.ReadFromString( ref index, ref nodeParams );
  406. m_failStencilOpBackIdx.ReadFromString( ref index, ref nodeParams );
  407. m_zFailStencilOpBackIdx.ReadFromString( ref index, ref nodeParams );
  408. }
  409. }
  410. }
  411. public override void WriteToString( ref string nodeInfo )
  412. {
  413. IOUtils.AddFieldValueToString( ref nodeInfo, m_validData );
  414. if( m_validData )
  415. {
  416. IOUtils.AddFieldValueToString( ref nodeInfo, m_active );
  417. m_reference.WriteToString( ref nodeInfo );
  418. m_readMask.WriteToString( ref nodeInfo );
  419. m_writeMask.WriteToString( ref nodeInfo );
  420. m_comparisonFunctionFrontIdx.WriteToString( ref nodeInfo );
  421. m_passStencilOpFrontIdx.WriteToString( ref nodeInfo );
  422. m_failStencilOpFrontIdx.WriteToString( ref nodeInfo );
  423. m_zFailStencilOpFrontIdx.WriteToString( ref nodeInfo );
  424. m_comparisonFunctionBackIdx.WriteToString( ref nodeInfo );
  425. m_passStencilOpBackIdx.WriteToString( ref nodeInfo );
  426. m_failStencilOpBackIdx.WriteToString( ref nodeInfo );
  427. m_zFailStencilOpBackIdx.WriteToString( ref nodeInfo );
  428. }
  429. }
  430. public override void Destroy()
  431. {
  432. m_comparisonDict.Clear();
  433. m_comparisonDict = null;
  434. m_stencilOpsDict.Clear();
  435. m_stencilOpsDict = null;
  436. m_reference = null;
  437. m_readMask = null;
  438. m_writeMask = null;
  439. m_comparisonFunctionFrontIdx = null;
  440. m_passStencilOpFrontIdx = null;
  441. m_failStencilOpFrontIdx = null;
  442. m_zFailStencilOpFrontIdx = null;
  443. m_comparisonFunctionBackIdx = null;
  444. m_passStencilOpBackIdx = null;
  445. m_failStencilOpBackIdx = null;
  446. m_zFailStencilOpBackIdx = null;
  447. }
  448. public bool Active { get { return m_active; } }
  449. public InlineProperty Reference { get { return m_reference; } }
  450. public InlineProperty ReadMask { get { return m_readMask; } }
  451. public InlineProperty WriteMask { get { return m_writeMask; } }
  452. public InlineProperty ComparisonFunctionIdx { get { return m_comparisonFunctionFrontIdx; } }
  453. public InlineProperty ComparisonFunctionBackIdx { get { return m_comparisonFunctionBackIdx; } }
  454. public InlineProperty PassStencilOpIdx { get { return m_passStencilOpFrontIdx; } }
  455. public InlineProperty PassStencilOpBackIdx { get { return m_passStencilOpBackIdx; } }
  456. public InlineProperty FailStencilOpIdx { get { return m_failStencilOpFrontIdx; } }
  457. public InlineProperty FailStencilOpBackIdx { get { return m_failStencilOpBackIdx; } }
  458. public InlineProperty ZFailStencilOpIdx { get { return m_zFailStencilOpFrontIdx; } }
  459. public InlineProperty ZFailStencilOpBackIdx { get { return m_zFailStencilOpBackIdx; } }
  460. }
  461. }