ExposureNode.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Amplify Shader Editor - Visual Shader Editing Tool
  2. // Copyright (c) Amplify Creations, Lda <info@amplify.pt>
  3. using System;
  4. using UnityEngine;
  5. using UnityEditor;
  6. namespace AmplifyShaderEditor
  7. {
  8. [Serializable]
  9. [NodeAttributes( "Exposure", "Lighting", "Get camera exposure value." )]
  10. public sealed class Exposure : ParentNode
  11. {
  12. protected override void CommonInit( int uniqueId )
  13. {
  14. base.CommonInit( uniqueId );
  15. AddOutputPort( WirePortDataType.FLOAT, Constants.EmptyPortValue );
  16. }
  17. public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
  18. {
  19. if ( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
  20. return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory );
  21. bool isHDRP = ( dataCollector.CurrentSRPType == TemplateSRPType.HDRP );
  22. bool isURP17xOrAbove = ( dataCollector.CurrentSRPType == TemplateSRPType.URP && ASEPackageManagerHelper.CurrentSRPVersion >= ( int )ASESRPBaseline.ASE_SRP_17 );
  23. string result;
  24. if ( isHDRP || isURP17xOrAbove )
  25. {
  26. result = "GetCurrentExposureMultiplier()";
  27. }
  28. else
  29. {
  30. result = "( 1.0 )";
  31. }
  32. return CreateOutputLocalVariable( 0, result, ref dataCollector );
  33. }
  34. }
  35. }