DebugGrassDisplacementTex.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace Lux_SRP_GrassDisplacement
  5. {
  6. public class DebugGrassDisplacementTex : MonoBehaviour
  7. {
  8. [System.Serializable]
  9. public enum DebugSize {
  10. _128 = 128,
  11. _256 = 256,
  12. _512 = 512,
  13. _1024 = 1024
  14. }
  15. public bool m_EnableDebug = true;
  16. public DebugSize currentDebugSize = DebugSize._256;
  17. #if UNITY_EDITOR
  18. void OnDrawGizmos() {
  19. if (m_EnableDebug) {
  20. var GrassDisplacementTex = Shader.GetGlobalTexture("_Lux_DisplacementRT");
  21. if(GrassDisplacementTex != null) {
  22. GL.PushMatrix();
  23. var size = (int)currentDebugSize;
  24. GL.LoadPixelMatrix(0, Screen.width, Screen.height, 0);
  25. Graphics.DrawTexture(new Rect(0, 0, size, size), Texture2D.normalTexture);
  26. Graphics.DrawTexture(new Rect(0, 0, size, size), GrassDisplacementTex);
  27. GL.PopMatrix();
  28. }
  29. }
  30. }
  31. #endif
  32. }
  33. }