LuminanceEdgeBlur.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. public var showGeneratedNormals : boolean = false;
  2. public var offsetScale : float = 0.1;
  3. public var blurRadius : float = 18.0;
  4. @script ExecuteInEditMode
  5. @script RequireComponent (Camera)
  6. @script AddComponentMenu ("Image Effects/Edge Blur (Luminance)")
  7. class LuminanceEdgeBlur extends PostEffectsBase
  8. {
  9. public var luminance2Normals : Shader;
  10. private var _luminance2NormalsBasedBlur : Material = null;
  11. function CreateMaterials ()
  12. {
  13. _luminance2NormalsBasedBlur = CheckShaderAndCreateMaterial(luminance2Normals,_luminance2NormalsBasedBlur);
  14. }
  15. function Start ()
  16. {
  17. CreateMaterials();
  18. CheckSupport(false);
  19. }
  20. function OnRenderImage (source : RenderTexture, destination : RenderTexture)
  21. {
  22. CreateMaterials ();
  23. _luminance2NormalsBasedBlur.SetFloat("_OffsetScale", offsetScale);
  24. _luminance2NormalsBasedBlur.SetFloat("_BlurRadius", blurRadius);
  25. if (showGeneratedNormals)
  26. {
  27. luminance2Normals.EnableKeyword("SHOW_DEBUG_ON");
  28. luminance2Normals.DisableKeyword("SHOW_DEBUG_OFF");
  29. }
  30. else
  31. {
  32. luminance2Normals.DisableKeyword("SHOW_DEBUG_ON");
  33. luminance2Normals.EnableKeyword("SHOW_DEBUG_OFF");
  34. }
  35. Graphics.Blit (source, destination, _luminance2NormalsBasedBlur);
  36. }
  37. }