yum-archive/Tooner
A toon shader for Unity's BIRP.
git clone https://git.yummers.dev/yum-archive/Tooner
2814e9b
v0.0.0
1using System ; 2using UnityEngine ; 3using UnityEngine . Rendering ; 4using UnityEditor ; 5 6public class ToonerGUI : ShaderGUI { 7Material target ; 8MaterialEditor editor ; 9MaterialProperty [] properties ; 10 11public override void OnGUI ( 12MaterialEditor editor , 13MaterialProperty [] properties ) { 14this . target = editor . target as Material ; 15this . editor = editor ; 16this . properties = properties ; 17DoMain () ; 18} 19 20static GUIContent staticLabel = new GUIContent () ; 21 22static GUIContent MakeLabel ( string prop , string tooltip = null ) { 23staticLabel . text = prop ; 24staticLabel . tooltip = tooltip ; 25return staticLabel ; 26} 27 28static GUIContent MakeLabel ( MaterialProperty prop , string tooltip = null ) { 29staticLabel . text = prop . displayName ; 30staticLabel . tooltip = tooltip ; 31return staticLabel ; 32} 33 34void RecordAction ( string label ) { 35editor . RegisterPropertyChangeUndo ( label ) ; 36} 37 38MaterialProperty FindProperty ( string label ) { 39return FindProperty ( label , properties ) ; 40} 41 42void SetKeyword ( string keyword , bool state ) { 43if ( state ) { 44target . EnableKeyword ( keyword ) ; 45} else { 46target . DisableKeyword ( keyword ) ; 47} 48} 49 50void DoBaseColor () { 51MaterialProperty bc = FindProperty ( "_BaseColor" ) ; 52MaterialProperty bct = FindProperty ( "_BaseColorTex" ) ; 53editor . TexturePropertySingleLine ( 54MakeLabel ( bct , "Base color (RGBA)" ) , 55bct , 56bc ) ; 57SetKeyword ( "_BASECOLOR_MAP" , bct . textureValue ) ; 58} 59 60void DoNormal () { 61MaterialProperty bct = FindProperty ( "_NormalTex" ) ; 62editor . TexturePropertySingleLine ( 63MakeLabel ( bct , "Normal" ) , 64bct , 65FindProperty ( "_Tex_NormalStr" )) ; 66SetKeyword ( "_NORMAL_MAP" , bct . textureValue ) ; 67} 68 69void DoMetallic () { 70MaterialProperty bc = FindProperty ( "_Metallic" ) ; 71MaterialProperty bct = FindProperty ( "_MetallicTex" ) ; 72editor . TexturePropertySingleLine ( 73MakeLabel ( bct , "Metallic (RGBA)" ) , 74bct , 75bc ) ; 76SetKeyword ( "_METALLIC_MAP" , bct . textureValue ) ; 77} 78 79void DoRoughness () { 80MaterialProperty bc = FindProperty ( "_Roughness" ) ; 81MaterialProperty bct = FindProperty ( "_RoughnessTex" ) ; 82editor . TexturePropertySingleLine ( 83MakeLabel ( bct , "Roughness (RGBA)" ) , 84bct , 85bc ) ; 86SetKeyword ( "_ROUGHNESS_MAP" , bct . textureValue ) ; 87} 88 89void DoPBROverlay () { 90MaterialProperty bc = FindProperty ( "_PBR_Overlay_Enable" ) ; 91bool enabled = bc . floatValue > 1E-6 ; 92EditorGUI . BeginChangeCheck () ; 93enabled = EditorGUILayout . Toggle ( "Enable" , enabled ) ; 94EditorGUI . EndChangeCheck () ; 95bc . floatValue = enabled ? 1.0f : 0.0f ; 96SetKeyword ( "_PBR_OVERLAY" , enabled ) ; 97 98if ( enabled ) { 99bc = FindProperty ( "_PBR_Overlay_BaseColor" ) ; 100MaterialProperty bct = FindProperty ( "_PBR_Overlay_BaseColorTex" ) ; 101editor . TexturePropertySingleLine ( 102MakeLabel ( bct , "Base color (RGBA)" ) , 103bct , 104bc ) ; 105SetKeyword ( "_PBR_OVERLAY_BASECOLOR_MAP" , bct . textureValue ) ; 106 107bct = FindProperty ( "_PBR_Overlay_NormalTex" ) ; 108editor . TexturePropertySingleLine ( 109MakeLabel ( bct , "Normal" ) , 110bct , 111FindProperty ( "_PBR_Overlay_Tex_NormalStr" )) ; 112SetKeyword ( "_PBR_OVERLAY_NORMAL_MAP" , bct . textureValue ) ; 113 114bc = FindProperty ( "_PBR_Overlay_Metallic" ) ; 115bct = FindProperty ( "_PBR_Overlay_MetallicTex" ) ; 116editor . TexturePropertySingleLine ( 117MakeLabel ( bct , "Metallic (RGBA)" ) , 118bct , 119bc ) ; 120SetKeyword ( "_PBR_OVERLAY_METALLIC_MAP" , bct . textureValue ) ; 121 122bc = FindProperty ( "_PBR_Overlay_Roughness" ) ; 123bct = FindProperty ( "_PBR_Overlay_RoughnessTex" ) ; 124editor . TexturePropertySingleLine ( 125MakeLabel ( bct , "Roughness (RGBA)" ) , 126bct , 127bc ) ; 128SetKeyword ( "_PBR_OVERLAY_ROUGHNESS_MAP" , bct . textureValue ) ; 129} 130} 131 132void DoCubemap () { 133MaterialProperty bc = FindProperty ( "_Cubemap" ) ; 134editor . TexturePropertySingleLine ( 135MakeLabel ( bc , "Cubemap" ) , 136bc ) ; 137SetKeyword ( "_CUBEMAP" , bc . textureValue ) ; 138} 139 140void DoBrightness () { 141MaterialProperty bc ; 142 143bc = FindProperty ( "_Min_Brightness" ) ; 144editor . RangeProperty ( 145bc , 146"Min brightness" ) ; 147 148bc = FindProperty ( "_Max_Brightness" ) ; 149editor . RangeProperty ( 150bc , 151"Max brightness" ) ; 152} 153 154void DoEmission () { 155MaterialProperty bc = FindProperty ( "_EmissionTex" ) ; 156MaterialProperty bct = FindProperty ( "_EmissionStrength" ) ; 157editor . TexturePropertySingleLine ( 158MakeLabel ( bct , "Emission map" ) , 159bc , 160bct ) ; 161SetKeyword ( "_EMISSION" , bc . textureValue ) ; 162} 163 164enum MatcapMode { 165Add , 166Multiply , 167Replace , 168Subtract , 169Min , 170Max , 171} 172 173void DoMatcap () { 174for ( int i = 0 ; i < 2 ; i ++ ) { 175GUILayout . Label ( $"Matcap { i } " , EditorStyles . boldLabel ) ; 176EditorGUI . indentLevel += 1 ; 177 178MaterialProperty bc ; 179 180bc = FindProperty ( $"_Matcap { i } " ) ; 181editor . TexturePropertySingleLine ( 182MakeLabel ( bc , $"Matcap { i } " ) , 183bc ) ; 184SetKeyword ( $"_MATCAP { i } " , bc . textureValue ) ; 185 186if ( ! bc . textureValue ) { 187EditorGUI . indentLevel -= 1 ; 188continue ; 189} 190 191bc = FindProperty ( $"_Matcap { i } _Mask" ) ; 192editor . TexturePropertySingleLine ( 193MakeLabel ( bc , "Mask" ) , 194bc ) ; 195SetKeyword ( $"_MATCAP { i } _MASK" , bc . textureValue ) ; 196 197if ( bc . textureValue ) { 198bc = FindProperty ( $"_Matcap { i } _Mask_Invert" ) ; 199bool enabled = bc . floatValue > 1E-6 ; 200EditorGUI . BeginChangeCheck () ; 201enabled = EditorGUILayout . Toggle ( "Invert mask" , enabled ) ; 202EditorGUI . EndChangeCheck () ; 203bc . floatValue = enabled ? 1.0f : 0.0f ; 204} 205 206EditorGUI . BeginChangeCheck () ; 207bc = FindProperty ( $"_Matcap { i } Mode" ) ; 208MatcapMode mode = ( MatcapMode ) Math . Round ( bc . floatValue ) ; 209mode = ( MatcapMode ) EditorGUILayout . EnumPopup ( 210MakeLabel ( "Matcap mode" ) , mode ) ; 211if ( EditorGUI . EndChangeCheck ()) { 212RecordAction ( $"Matcap { i } " ) ; 213foreach ( Material m in editor . targets ) { 214m . SetFloat ( $"_Matcap { i } Mode" , ( int ) mode ) ; 215} 216} 217 218bc = FindProperty ( $"_Matcap { i } Str" ) ; 219editor . FloatProperty ( 220bc , 221"Matcap strength" ) ; 222EditorGUI . indentLevel -= 1 ; 223} 224} 225 226void DoRimLighting () { 227for ( int i = 0 ; i < 2 ; i ++ ) { 228GUILayout . Label ( $"Rim lighting { i } " , EditorStyles . boldLabel ) ; 229EditorGUI . indentLevel += 1 ; 230 231MaterialProperty bc ; 232 233bc = FindProperty ( $"_Rim_Lighting { i } _Enabled" ) ; 234bool enabled = bc . floatValue > 1E-6 ; 235EditorGUI . BeginChangeCheck () ; 236enabled = EditorGUILayout . Toggle ( "Enable" , enabled ) ; 237EditorGUI . EndChangeCheck () ; 238bc . floatValue = enabled ? 1.0f : 0.0f ; 239SetKeyword ( $"_RIM_LIGHTING { i } " , enabled ) ; 240 241if ( ! enabled ) { 242return ; 243} 244 245bc = FindProperty ( $"_Rim_Lighting { i } _Color" ) ; 246editor . ColorProperty ( bc , "Color (RGB)" ) ; 247 248bc = FindProperty ( $"_Rim_Lighting { i } _Mask" ) ; 249editor . TexturePropertySingleLine ( 250MakeLabel ( bc , "Mask" ) , 251bc ) ; 252SetKeyword ( $"_RIM_LIGHTING { i } _MASK" , bc . textureValue ) ; 253 254if ( bc . textureValue ) { 255bc = FindProperty ( $"_Rim_Lighting { i } _Mask_Invert" ) ; 256enabled = bc . floatValue > 1E-6 ; 257EditorGUI . BeginChangeCheck () ; 258enabled = EditorGUILayout . Toggle ( "Invert mask" , enabled ) ; 259EditorGUI . EndChangeCheck () ; 260bc . floatValue = enabled ? 1.0f : 0.0f ; 261} 262 263EditorGUI . BeginChangeCheck () ; 264bc = FindProperty ( $"_Rim_Lighting { i } _Mode" ) ; 265MatcapMode mode = ( MatcapMode ) Math . Round ( bc . floatValue ) ; 266mode = ( MatcapMode ) EditorGUILayout . EnumPopup ( 267MakeLabel ( "Rim lighting mode" ) , mode ) ; 268if ( EditorGUI . EndChangeCheck ()) { 269RecordAction ( "Rim lighting mode" ) ; 270foreach ( Material m in editor . targets ) { 271m . SetFloat ( $"_Rim_Lighting { i } _Mode" , ( int ) mode ) ; 272} 273} 274 275bc = FindProperty ( $"_Rim_Lighting { i } _Center" ) ; 276editor . FloatProperty ( 277bc , 278"Center" ) ; 279 280bc = FindProperty ( $"_Rim_Lighting { i } _Power" ) ; 281editor . FloatProperty ( 282bc , 283"Power" ) ; 284 285bc = FindProperty ( $"_Rim_Lighting { i } _Strength" ) ; 286editor . FloatProperty ( 287bc , 288"Strength" ) ; 289 290EditorGUI . indentLevel -= 1 ; 291} 292} 293 294enum NormalsMode { 295Flat , 296Spherical 297} ; 298 299void DoShadingMode () { 300MaterialProperty bc ; 301 302bc = FindProperty ( $"_Mesh_Normals_Mode" ) ; 303EditorGUI . BeginChangeCheck () ; 304NormalsMode mode = ( NormalsMode ) Math . Round ( bc . floatValue , 0 ) ; 305mode = ( NormalsMode ) EditorGUILayout . EnumPopup ( 306MakeLabel ( "Normals mode" ) , mode ) ; 307if ( EditorGUI . EndChangeCheck ()) { 308RecordAction ( "Rendering Mode" ) ; 309} 310bc . floatValue = ( float ) mode ; 311 312if ( mode == NormalsMode . Flat ) { 313bc = FindProperty ( "_Flatten_Mesh_Normals_Str" ) ; 314editor . FloatProperty ( 315bc , 316"Flattening strength" ) ; 317} 318 319bc = FindProperty ( "_Confabulate_Normals" ) ; 320bool enabled = bc . floatValue > 1E-6 ; 321EditorGUI . BeginChangeCheck () ; 322enabled = EditorGUILayout . Toggle ( "Confabulate normals" , enabled ) ; 323EditorGUI . EndChangeCheck () ; 324bc . floatValue = enabled ? 1.0f : 0.0f ; 325} 326 327void DoOKLAB () { 328MaterialProperty bc ; 329 330bc = FindProperty ( "_OKLAB_Enabled" ) ; 331bool enabled = bc . floatValue > 1E-6 ; 332EditorGUI . BeginChangeCheck () ; 333enabled = EditorGUILayout . Toggle ( "Enable" , enabled ) ; 334EditorGUI . EndChangeCheck () ; 335bc . floatValue = enabled ? 1.0f : 0.0f ; 336 337SetKeyword ( "_OKLAB" , enabled ) ; 338 339if ( enabled ) { 340bc = FindProperty ( "_OKLAB_Mask" ) ; 341editor . TexturePropertySingleLine ( 342MakeLabel ( bc , "Mask" ) , 343bc ) ; 344 345bc = FindProperty ( "_OKLAB_Lightness_Shift" ) ; 346editor . RangeProperty ( 347bc , 348"Lightness shift" ) ; 349bc = FindProperty ( "_OKLAB_Chroma_Shift" ) ; 350editor . RangeProperty ( 351bc , 352"Chroma shift" ) ; 353bc = FindProperty ( "_OKLAB_Hue_Shift" ) ; 354editor . RangeProperty ( 355bc , 356"Hue shift" ) ; 357} 358} 359 360void DoClones () { 361MaterialProperty bc ; 362 363bc = FindProperty ( "_Clones_Enabled" ) ; 364bool enabled = bc . floatValue > 1E-6 ; 365EditorGUI . BeginChangeCheck () ; 366enabled = EditorGUILayout . Toggle ( "Enable" , enabled ) ; 367EditorGUI . EndChangeCheck () ; 368bc . floatValue = enabled ? 1.0f : 0.0f ; 369 370SetKeyword ( "_CLONES" , enabled ) ; 371 372if ( enabled ) { 373bc = FindProperty ( "_Clones_Count" ) ; 374editor . RangeProperty ( 375bc , 376"Number of clones" ) ; 377bc = FindProperty ( "_Clones_dx" ) ; 378editor . RangeProperty ( 379bc , 380"x offset" ) ; 381} 382} 383 384void DoOutlines () { 385MaterialProperty bc ; 386 387bc = FindProperty ( "_Outline_Width" ) ; 388editor . RangeProperty ( 389bc , 390"Outline width" ) ; 391SetKeyword ( "_OUTLINES" , bc . floatValue > 1E-6 ) ; 392 393if ( bc . floatValue > 1E-6 ) { 394bc = FindProperty ( "_Outline_Color" ) ; 395editor . ColorProperty ( 396bc , 397"Outline color (RGBA)" ) ; 398 399bc = FindProperty ( "_Outline_Emission_Strength" ) ; 400editor . RangeProperty ( 401bc , 402"Outline emission strength" ) ; 403 404bc = FindProperty ( "_Outline_Mask" ) ; 405editor . TexturePropertySingleLine ( 406MakeLabel ( bc , "Outline mask" ) , 407bc ) ; 408 409bc = FindProperty ( "_Outline_Mask_Invert" ) ; 410bool inverted = bc . floatValue > 1E-6 ; 411EditorGUI . BeginChangeCheck () ; 412inverted = EditorGUILayout . Toggle ( "Invert mask" , inverted ) ; 413EditorGUI . EndChangeCheck () ; 414bc . floatValue = inverted ? 1.0f : 0.0f ; 415} 416} 417 418void DoGlitter () { 419MaterialProperty bc = FindProperty ( "_Glitter_Enabled" ) ; 420bool enabled = bc . floatValue > 1E-6 ; 421 422EditorGUI . BeginChangeCheck () ; 423enabled = EditorGUILayout . Toggle ( "Enable" , enabled ) ; 424EditorGUI . EndChangeCheck () ; 425SetKeyword ( "_GLITTER" , enabled ) ; 426bc . floatValue = enabled ? 1.0f : 0.0f ; 427 428if ( enabled ) { 429bc = FindProperty ( "_Glitter_Mask" ) ; 430editor . TexturePropertySingleLine ( 431MakeLabel ( bc , "Glitter mask (RGBA)" ) , 432bc ) ; 433 434bc = FindProperty ( "_Glitter_Density" ) ; 435editor . FloatProperty ( 436bc , 437"Glitter density" ) ; 438 439bc = FindProperty ( "_Glitter_Amount" ) ; 440editor . FloatProperty ( 441bc , 442"Glitter amount" ) ; 443 444bc = FindProperty ( "_Glitter_Speed" ) ; 445editor . FloatProperty ( 446bc , 447"Glitter speed" ) ; 448 449bc = FindProperty ( "_Glitter_Brightness" ) ; 450editor . FloatProperty ( 451bc , 452"Glitter brightness" ) ; 453 454bc = FindProperty ( "_Glitter_Angle" ) ; 455editor . FloatProperty ( 456bc , 457"Glitter angle" ) ; 458} 459} 460 461void DoExplosion () { 462MaterialProperty bc = FindProperty ( "_Explode_Toggle" ) ; 463bool enabled = bc . floatValue > 1E-6 ; 464 465EditorGUI . BeginChangeCheck () ; 466enabled = EditorGUILayout . Toggle ( "Enable" , enabled ) ; 467EditorGUI . EndChangeCheck () ; 468SetKeyword ( "_EXPLODE" , enabled ) ; 469bc . floatValue = enabled ? 1.0f : 0.0f ; 470 471bc = FindProperty ( "_Explode_Phase" ) ; 472if ( enabled ) { 473editor . RangeProperty ( 474bc , 475"Explosion phase" ) ; 476} else { 477bc . floatValue = 0.0f ; 478} 479bc = FindProperty ( "_OutlinesCull" ) ; 480bc . floatValue = ( float ) UnityEngine . Rendering . CullMode . Front ; 481 482/* 483if (enabled) { 484bc = FindProperty("_Explode_Phase"); 485editor.RangeProperty( 486bc, 487"Explosion phase"); 488if (bc.floatValue > 1E-3) { 489bc = FindProperty("_Cull"); 490bc.floatValue = (float) UnityEngine.Rendering.CullMode.Back; 491} else { 492bc = FindProperty("_Cull"); 493bc.floatValue = (float) UnityEngine.Rendering.CullMode.Front; 494} 495} else { 496bc = FindProperty("_Explode_Phase"); 497bc.floatValue = 0.0f; 498bc = FindProperty("_Cull"); 499bc.floatValue = (float) UnityEngine.Rendering.CullMode.Front; 500} 501*/ 502} 503 504void DoGeoScroll () { 505MaterialProperty bc = FindProperty ( "_Scroll_Toggle" ) ; 506bool enabled = bc . floatValue > 1E-6 ; 507 508EditorGUI . BeginChangeCheck () ; 509enabled = EditorGUILayout . Toggle ( "Enable" , enabled ) ; 510EditorGUI . EndChangeCheck () ; 511SetKeyword ( "_SCROLL" , enabled ) ; 512bc . floatValue = enabled ? 1.0f : 0.0f ; 513 514if ( enabled ) { 515bc = FindProperty ( "_Scroll_Top" ) ; 516editor . RangeProperty ( 517bc , 518"Scroll top" ) ; 519 520bc = FindProperty ( "_Scroll_Bottom" ) ; 521editor . RangeProperty ( 522bc , 523"Scroll bottom" ) ; 524 525bc = FindProperty ( "_Scroll_Width" ) ; 526editor . RangeProperty ( 527bc , 528"Scroll width" ) ; 529 530bc = FindProperty ( "_Scroll_Strength" ) ; 531editor . RangeProperty ( 532bc , 533"Scroll strength" ) ; 534 535bc = FindProperty ( "_Scroll_Speed" ) ; 536editor . RangeProperty ( 537bc , 538"Scroll speed" ) ; 539} 540} 541 542void DoUVScroll () { 543MaterialProperty bc = FindProperty ( "_UVScroll_Enabled" ) ; 544bool enabled = bc . floatValue > 1E-6 ; 545 546EditorGUI . BeginChangeCheck () ; 547enabled = EditorGUILayout . Toggle ( "Enable" , enabled ) ; 548EditorGUI . EndChangeCheck () ; 549SetKeyword ( "_UVSCROLL" , enabled ) ; 550bc . floatValue = enabled ? 1.0f : 0.0f ; 551 552if ( enabled ) { 553bc = FindProperty ( "_UVScroll_Mask" ) ; 554editor . TexturePropertySingleLine ( 555MakeLabel ( bc , "Mask" ) , 556bc ) ; 557 558bc = FindProperty ( "_UVScroll_U_Speed" ) ; 559editor . FloatProperty ( 560bc , 561"U speed" ) ; 562 563bc = FindProperty ( "_UVScroll_V_Speed" ) ; 564editor . FloatProperty ( 565bc , 566"V speed" ) ; 567 568bc = FindProperty ( "_UVScroll_Alpha" ) ; 569editor . TexturePropertySingleLine ( 570MakeLabel ( bc , "Alpha" ) , 571bc ) ; 572} 573} 574 575void DoTessellation () { 576MaterialProperty bc = FindProperty ( "_Enable_Tessellation" ) ; 577bool enabled = bc . floatValue > 1E-6 ; 578 579EditorGUI . BeginChangeCheck () ; 580enabled = EditorGUILayout . Toggle ( "Enable" , enabled ) ; 581EditorGUI . EndChangeCheck () ; 582SetKeyword ( "_TESSELLATION" , enabled ) ; 583bc . floatValue = enabled ? 1.0f : 0.0f ; 584 585if ( enabled ) { 586bc = FindProperty ( "_Tess_Factor" ) ; 587editor . RangeProperty ( 588bc , 589"Tessellation factor" ) ; 590 591bc = FindProperty ( "_Tess_Dist_Cutoff" ) ; 592editor . FloatProperty ( 593bc , 594"Activation distance (negative=always on)" ) ; 595} 596} 597 598enum RenderingMode { 599Opaque , 600Cutout , 601Fade 602} 603 604void DoRendering () { 605RenderingMode mode = RenderingMode . Opaque ; 606if ( target . IsKeywordEnabled ( "_RENDERING_CUTOUT" )) { 607mode = RenderingMode . Cutout ; 608} else if ( target . IsKeywordEnabled ( "_RENDERING_FADE" )) { 609mode = RenderingMode . Fade ; 610} 611 612EditorGUI . BeginChangeCheck () ; 613mode = ( RenderingMode ) EditorGUILayout . EnumPopup ( 614MakeLabel ( "Rendering Mode" ) , mode ) ; 615BlendMode src_blend = BlendMode . One ; 616BlendMode dst_blend = BlendMode . Zero ; 617bool zwrite = false ; 618 619if ( EditorGUI . EndChangeCheck ()) { 620RecordAction ( "Rendering Mode" ) ; 621SetKeyword ( "_RENDERING_CUTOUT" , mode == RenderingMode . Cutout ) ; 622SetKeyword ( "_RENDERING_FADE" , mode == RenderingMode . Fade ) ; 623 624RenderQueue queue = RenderQueue . Geometry ; 625string render_type = "" ; 626switch ( mode ) { 627case RenderingMode . Opaque : 628queue = RenderQueue . Geometry ; 629render_type = "" ; 630src_blend = BlendMode . One ; 631dst_blend = BlendMode . Zero ; 632zwrite = true ; 633break ; 634case RenderingMode . Cutout : 635queue = RenderQueue . AlphaTest ; 636render_type = "TransparentCutout" ; 637src_blend = BlendMode . One ; 638dst_blend = BlendMode . Zero ; 639zwrite = true ; 640break ; 641case RenderingMode . Fade : 642queue = RenderQueue . Transparent ; 643render_type = "Transparent" ; 644src_blend = BlendMode . SrcAlpha ; 645dst_blend = BlendMode . OneMinusSrcAlpha ; 646zwrite = false ; 647break ; 648} 649foreach ( Material m in editor . targets ) { 650m . renderQueue = ( int ) queue ; 651m . SetOverrideTag ( "RenderType" , render_type ) ; 652m . SetInt ( "_SrcBlend" , ( int ) src_blend ) ; 653m . SetInt ( "_DstBlend" , ( int ) dst_blend ) ; 654m . SetInt ( "_ZWrite" , zwrite ? 1 : 0 ) ; 655} 656} 657 658MaterialProperty bc ; 659if ( mode == RenderingMode . Cutout ) { 660bc = FindProperty ( "_Alpha_Cutoff" ) ; 661editor . ShaderProperty ( bc , MakeLabel ( bc )) ; 662} 663 664bc = FindProperty ( "_Cull" ) ; 665UnityEngine . Rendering . CullMode cull_mode = ( UnityEngine . Rendering . CullMode ) bc . floatValue ; 666EditorGUI . BeginChangeCheck () ; 667cull_mode = ( UnityEngine . Rendering . CullMode ) EditorGUILayout . EnumPopup ( 668MakeLabel ( "Culling mode" ) , cull_mode ) ; 669if ( EditorGUI . EndChangeCheck ()) { 670RecordAction ( "Culling mode" ) ; 671bc . floatValue = ( float ) cull_mode ; 672} 673} 674 675void DoLTCGI () { 676#if LTCGI_INCLUDED 677GUILayout . Label ( $"Available: yes" ) ; 678 679MaterialProperty bc = FindProperty ( "_LTCGI_Enabled" ) ; 680bool enabled = bc . floatValue > 1E-6 ; 681EditorGUI . BeginChangeCheck () ; 682enabled = EditorGUILayout . Toggle ( "Enable" , enabled ) ; 683EditorGUI . EndChangeCheck () ; 684bc . floatValue = enabled ? 1.0f : 0.0f ; 685SetKeyword ( "_LTCGI" , enabled ) ; 686 687bc = FindProperty ( "_LTCGI_SpecularColor" ) ; 688editor . ColorProperty ( bc , "Specular color (RGB)" ) ; 689 690bc = FindProperty ( "_LTCGI_DiffuseColor" ) ; 691editor . ColorProperty ( bc , "Diffuse color (RGB)" ) ; 692#else 693GUILayout . Label ( $"Available: no" ) ; 694#endif // LTCGI_INCLUDED 695} 696 697void DoMain () { 698GUILayout . Label ( "PBR" , EditorStyles . boldLabel ) ; 699EditorGUI . indentLevel += 1 ; 700DoBaseColor () ; 701DoNormal () ; 702DoMetallic () ; 703DoRoughness () ; 704EditorGUI . indentLevel -= 1 ; 705 706GUILayout . Label ( "PBR overlay" , EditorStyles . boldLabel ) ; 707EditorGUI . indentLevel += 1 ; 708DoPBROverlay () ; 709EditorGUI . indentLevel -= 1 ; 710 711GUILayout . Label ( "Lighting" , EditorStyles . boldLabel ) ; 712EditorGUI . indentLevel += 1 ; 713DoCubemap () ; 714DoBrightness () ; 715EditorGUI . indentLevel -= 1 ; 716 717GUILayout . Label ( "Emission" , EditorStyles . boldLabel ) ; 718EditorGUI . indentLevel += 1 ; 719DoEmission () ; 720EditorGUI . indentLevel -= 1 ; 721 722GUILayout . Label ( "Shading" , EditorStyles . boldLabel ) ; 723EditorGUI . indentLevel += 1 ; 724DoShadingMode () ; 725EditorGUI . indentLevel -= 1 ; 726 727DoMatcap () ; 728DoRimLighting () ; 729 730GUILayout . Label ( "Outlines" , EditorStyles . boldLabel ) ; 731EditorGUI . indentLevel += 1 ; 732DoOutlines () ; 733EditorGUI . indentLevel -= 1 ; 734 735GUILayout . Label ( "Glitter" , EditorStyles . boldLabel ) ; 736EditorGUI . indentLevel += 1 ; 737DoGlitter () ; 738EditorGUI . indentLevel -= 1 ; 739 740GUILayout . Label ( "Explosion" , EditorStyles . boldLabel ) ; 741EditorGUI . indentLevel += 1 ; 742DoExplosion () ; 743EditorGUI . indentLevel -= 1 ; 744 745GUILayout . Label ( "Geometry scroll" , EditorStyles . boldLabel ) ; 746EditorGUI . indentLevel += 1 ; 747DoGeoScroll () ; 748EditorGUI . indentLevel -= 1 ; 749 750GUILayout . Label ( "UV scroll" , EditorStyles . boldLabel ) ; 751EditorGUI . indentLevel += 1 ; 752DoUVScroll () ; 753EditorGUI . indentLevel -= 1 ; 754 755GUILayout . Label ( "Tessellation" , EditorStyles . boldLabel ) ; 756EditorGUI . indentLevel += 1 ; 757DoTessellation () ; 758EditorGUI . indentLevel -= 1 ; 759 760GUILayout . Label ( "Hue shift" , EditorStyles . boldLabel ) ; 761EditorGUI . indentLevel += 1 ; 762DoOKLAB () ; 763EditorGUI . indentLevel -= 1 ; 764 765GUILayout . Label ( "Clones" , EditorStyles . boldLabel ) ; 766EditorGUI . indentLevel += 1 ; 767DoClones () ; 768EditorGUI . indentLevel -= 1 ; 769 770GUILayout . Label ( "Rendering" , EditorStyles . boldLabel ) ; 771EditorGUI . indentLevel += 1 ; 772DoRendering () ; 773EditorGUI . indentLevel -= 1 ; 774 775GUILayout . Label ( "LTCGI" , EditorStyles . boldLabel ) ; 776EditorGUI . indentLevel += 1 ; 777DoLTCGI () ; 778EditorGUI . indentLevel -= 1 ; 779} 780} 781 782