Camera filters (#242)

* Spaceball cleanup and small bug fix

* Replace old hit sound in spaceball

* Camera filters

* added 9 new filters, including 3 types of sepia

* oops

* remark

* normalization of fade out and fade in on filters are by 100

* GenerateFilterTypeEnum comments
This commit is contained in:
Braedon Lewis 2023-01-26 22:42:16 -05:00 committed by GitHub
parent ef8f6c99d9
commit 7cb592fc69
230 changed files with 13676 additions and 39 deletions

8
Assets/AmplifyColor.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2da996c32df04564489a2edb6c5dd1df
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: d8eb449559debed41a87670ef19b5cc8

Binary file not shown.

View File

@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: 9bcf3af9279275d49a2cd3810ad68d24
PluginImporter:
serializedVersion: 1
iconMap: {}
executionOrder: {}
isPreloaded: 0
platformData:
Any:
enabled: 1
settings: {}
Editor:
enabled: 0
settings:
DefaultValueInitialized: true
WindowsStoreApps:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,923 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Serialization;
namespace AmplifyColor
{
public enum Quality
{
Mobile,
Standard
}
public enum Tonemapping
{
Disabled = 0,
Photographic = 1,
FilmicHable = 2,
FilmicACES = 3
}
}
[AddComponentMenu( "" )]
public class AmplifyColorBase : MonoBehaviour
{
public const int LutSize = 32;
public const int LutWidth = LutSize * LutSize;
public const int LutHeight = LutSize;
const int DepthCurveLutRange = 1024;
// HDR Control
public AmplifyColor.Tonemapping Tonemapper = AmplifyColor.Tonemapping.Disabled;
public float Exposure = 1.0f;
public float LinearWhitePoint = 11.2f;
[FormerlySerializedAs( "UseDithering" )]
public bool ApplyDithering = false;
// Color Grading
public AmplifyColor.Quality QualityLevel = AmplifyColor.Quality.Standard;
public float BlendAmount = 0f;
public Texture LutTexture = null;
public Texture LutBlendTexture = null;
public Texture MaskTexture = null;
public bool UseDepthMask = false;
public AnimationCurve DepthMaskCurve = new AnimationCurve( new Keyframe( 0, 1 ), new Keyframe( 1, 1 ) );
// Effect Volumes
public bool UseVolumes = false;
public float ExitVolumeBlendTime = 1.0f;
public Transform TriggerVolumeProxy = null;
public LayerMask VolumeCollisionMask = ~0;
private Camera ownerCamera = null;
private Shader shaderBase = null;
private Shader shaderBlend = null;
private Shader shaderBlendCache = null;
private Shader shaderMask = null;
private Shader shaderMaskBlend = null;
private Shader shaderDepthMask = null;
private Shader shaderDepthMaskBlend = null;
private Shader shaderProcessOnly = null;
private RenderTexture blendCacheLut = null;
private Texture2D defaultLut = null;
private Texture2D depthCurveLut = null;
private Color32[] depthCurveColors = null;
private ColorSpace colorSpace = ColorSpace.Uninitialized;
private AmplifyColor.Quality qualityLevel = AmplifyColor.Quality.Standard;
public Texture2D DefaultLut { get { return ( defaultLut == null ) ? CreateDefaultLut() : defaultLut ; } }
private Material materialBase = null;
private Material materialBlend = null;
private Material materialBlendCache = null;
private Material materialMask = null;
private Material materialMaskBlend = null;
private Material materialDepthMask = null;
private Material materialDepthMaskBlend = null;
private Material materialProcessOnly = null;
private bool blending;
private float blendingTime;
private float blendingTimeCountdown;
private System.Action onFinishBlend;
private AnimationCurve prevDepthMaskCurve = new AnimationCurve();
private bool volumesBlending;
private float volumesBlendingTime;
private float volumesBlendingTimeCountdown;
private Texture volumesLutBlendTexture = null;
private float volumesBlendAmount = 0f;
public bool IsBlending { get { return blending; } }
private Texture worldLUT = null;
private AmplifyColorVolumeBase currentVolumeLut = null;
private RenderTexture midBlendLUT = null;
private bool blendingFromMidBlend = false;
private AmplifyColor.VolumeEffect worldVolumeEffects = null;
private AmplifyColor.VolumeEffect currentVolumeEffects = null;
private AmplifyColor.VolumeEffect blendVolumeEffects = null;
private float worldExposure = 1.0f;
private float currentExposure = 1.0f;
private float blendExposure = 1.0f;
private float effectVolumesBlendAdjust = 0.0f;
private float effectVolumesBlendAdjusted { get { return Mathf.Clamp01( effectVolumesBlendAdjust < 0.99f ? ( volumesBlendAmount - effectVolumesBlendAdjust ) / ( 1.0f - effectVolumesBlendAdjust ) : 1.0f ); } }
private List<AmplifyColorVolumeBase> enteredVolumes = new List<AmplifyColorVolumeBase>();
private AmplifyColorTriggerProxyBase actualTriggerProxy = null;
[HideInInspector] public AmplifyColor.VolumeEffectFlags EffectFlags = new AmplifyColor.VolumeEffectFlags();
[SerializeField, HideInInspector] private string sharedInstanceID = "";
public string SharedInstanceID { get { return sharedInstanceID; } }
private bool silentError = false;
#if TRIAL
private Texture2D watermark = null;
#endif
public bool WillItBlend { get { return LutTexture != null && LutBlendTexture != null && !blending; } }
public void NewSharedInstanceID()
{
sharedInstanceID = Guid.NewGuid().ToString();
}
void ReportMissingShaders()
{
Debug.LogError( "[AmplifyColor] Failed to initialize shaders. Please attempt to re-enable the Amplify Color Effect component. If that fails, please reinstall Amplify Color." );
enabled = false;
}
void ReportNotSupported()
{
Debug.LogError( "[AmplifyColor] This image effect is not supported on this platform." );
enabled = false;
}
bool CheckShader( Shader s )
{
if ( s == null )
{
ReportMissingShaders();
return false;
}
if ( !s.isSupported )
{
ReportNotSupported();
return false;
}
return true;
}
bool CheckShaders()
{
return CheckShader( shaderBase ) && CheckShader( shaderBlend ) && CheckShader( shaderBlendCache ) &&
CheckShader( shaderMask ) && CheckShader( shaderMaskBlend ) && CheckShader( shaderProcessOnly );
}
bool CheckSupport()
{
#if !UNITY_2019_1_OR_NEWER
// Disable if we don't support image effect or render textures
#if UNITY_5_6_OR_NEWER
if ( !SystemInfo.supportsImageEffects )
#else
if ( !SystemInfo.supportsImageEffects || !SystemInfo.supportsRenderTextures )
#endif
{
ReportNotSupported();
return false;
}
#endif
return true;
}
void OnEnable()
{
#if UNITY_5_6_OR_NEWER
bool nullDev = ( SystemInfo.graphicsDeviceType == GraphicsDeviceType.Null );
#else
bool nullDev = ( SystemInfo.graphicsDeviceName == "Null Device" );
#endif
if ( nullDev )
{
Debug.LogWarning( "[AmplifyColor] Null graphics device detected. Skipping effect silently." );
silentError = true;
return;
}
if ( !CheckSupport() )
return;
if ( !CreateMaterials() )
return;
Texture2D lutTex2d = LutTexture as Texture2D;
Texture2D lutBlendTex2d = LutBlendTexture as Texture2D;
if ( ( lutTex2d != null && lutTex2d.mipmapCount > 1 ) || ( lutBlendTex2d != null && lutBlendTex2d.mipmapCount > 1 ) )
Debug.LogError( "[AmplifyColor] Please disable \"Generate Mip Maps\" import settings on all LUT textures to avoid visual glitches. " +
"Change Texture Type to \"Advanced\" to access Mip settings." );
#if TRIAL
watermark = new Texture2D( 4, 4 ) { hideFlags = HideFlags.HideAndDontSave };
watermark.LoadImage( AmplifyColor.Watermark.ImageData );
#endif
}
void OnDisable()
{
if ( actualTriggerProxy != null )
{
DestroyImmediate( actualTriggerProxy.gameObject );
actualTriggerProxy = null;
}
ReleaseMaterials();
ReleaseTextures();
#if TRIAL
if ( watermark != null )
{
DestroyImmediate( watermark );
watermark = null;
}
#endif
}
private void VolumesBlendTo( Texture blendTargetLUT, float blendTimeInSec )
{
volumesLutBlendTexture = blendTargetLUT;
volumesBlendAmount = 0.0f;
volumesBlendingTime = blendTimeInSec;
volumesBlendingTimeCountdown = blendTimeInSec;
volumesBlending = true;
}
public void BlendTo( Texture blendTargetLUT, float blendTimeInSec, System.Action onFinishBlend )
{
LutBlendTexture = blendTargetLUT;
BlendAmount = 0.0f;
this.onFinishBlend = onFinishBlend;
blendingTime = blendTimeInSec;
blendingTimeCountdown = blendTimeInSec;
blending = true;
}
private void CheckCamera()
{
if ( ownerCamera == null )
ownerCamera = GetComponent<Camera>();
if ( UseDepthMask && ( ownerCamera.depthTextureMode & DepthTextureMode.Depth ) == 0 )
ownerCamera.depthTextureMode |= DepthTextureMode.Depth;
}
private void Start()
{
if ( silentError )
return;
CheckCamera();
worldLUT = LutTexture;
worldVolumeEffects = EffectFlags.GenerateEffectData( this );
blendVolumeEffects = currentVolumeEffects = worldVolumeEffects;
worldExposure = Exposure;
blendExposure = currentExposure = worldExposure;
}
void Update()
{
if ( silentError )
return;
CheckCamera();
bool volumesBlendFinished = false;
if ( volumesBlending )
{
volumesBlendAmount = ( volumesBlendingTime - volumesBlendingTimeCountdown ) / volumesBlendingTime;
volumesBlendingTimeCountdown -= Time.smoothDeltaTime;
if ( volumesBlendAmount >= 1.0f )
{
volumesBlendAmount = 1;
volumesBlendFinished = true;
}
}
else
volumesBlendAmount = Mathf.Clamp01( volumesBlendAmount );
if ( blending )
{
BlendAmount = ( blendingTime - blendingTimeCountdown ) / blendingTime;
blendingTimeCountdown -= Time.smoothDeltaTime;
if ( BlendAmount >= 1.0f )
{
LutTexture = LutBlendTexture;
BlendAmount = 0.0f;
blending = false;
LutBlendTexture = null;
if ( onFinishBlend != null )
onFinishBlend();
}
}
else
BlendAmount = Mathf.Clamp01( BlendAmount );
if ( UseVolumes )
{
if ( actualTriggerProxy == null )
{
GameObject obj = new GameObject( name + "+ACVolumeProxy" ) { hideFlags = HideFlags.HideAndDontSave };
if ( TriggerVolumeProxy != null && TriggerVolumeProxy.GetComponent<Collider2D>() != null )
actualTriggerProxy = obj.AddComponent<AmplifyColorTriggerProxy2D>();
else
actualTriggerProxy = obj.AddComponent<AmplifyColorTriggerProxy>();
actualTriggerProxy.OwnerEffect = this;
}
UpdateVolumes();
}
else if ( actualTriggerProxy != null )
{
DestroyImmediate( actualTriggerProxy.gameObject );
actualTriggerProxy = null;
}
if ( volumesBlendFinished )
{
LutTexture = volumesLutBlendTexture;
volumesBlendAmount = 0.0f;
volumesBlending = false;
volumesLutBlendTexture = null;
effectVolumesBlendAdjust = 0.0f;
currentVolumeEffects = blendVolumeEffects;
currentVolumeEffects.SetValues( this );
currentExposure = blendExposure;
if ( blendingFromMidBlend && midBlendLUT != null )
midBlendLUT.DiscardContents();
blendingFromMidBlend = false;
}
}
public void EnterVolume( AmplifyColorVolumeBase volume )
{
if ( !enteredVolumes.Contains( volume ) )
enteredVolumes.Insert( 0, volume );
}
public void ExitVolume( AmplifyColorVolumeBase volume )
{
if ( enteredVolumes.Contains( volume ) )
enteredVolumes.Remove( volume );
}
private void UpdateVolumes()
{
if ( volumesBlending )
currentVolumeEffects.BlendValues( this, blendVolumeEffects, effectVolumesBlendAdjusted );
if ( volumesBlending )
Exposure = Mathf.Lerp( currentExposure, blendExposure, effectVolumesBlendAdjusted );
Transform reference = ( TriggerVolumeProxy == null ) ? transform : TriggerVolumeProxy;
if ( actualTriggerProxy.transform.parent != reference )
{
actualTriggerProxy.Reference = reference;
actualTriggerProxy.gameObject.layer = reference.gameObject.layer;
}
AmplifyColorVolumeBase foundVolume = null;
int maxPriority = int.MinValue;
// Find volume with higher priority
for ( int i = 0; i < enteredVolumes.Count; i++ )
{
AmplifyColorVolumeBase vol = enteredVolumes[ i ];
if ( vol.Priority > maxPriority )
{
foundVolume = vol;
maxPriority = vol.Priority;
}
}
// Trigger blend on volume transition
if ( foundVolume != currentVolumeLut )
{
currentVolumeLut = foundVolume;
Texture blendTex = ( foundVolume == null ? worldLUT : foundVolume.LutTexture );
float blendTime = ( foundVolume == null ? ExitVolumeBlendTime : foundVolume.EnterBlendTime );
if ( volumesBlending && !blendingFromMidBlend && blendTex == LutTexture )
{
// Going back to previous volume optimization
LutTexture = volumesLutBlendTexture;
volumesLutBlendTexture = blendTex;
volumesBlendingTimeCountdown = blendTime * ( ( volumesBlendingTime - volumesBlendingTimeCountdown ) / volumesBlendingTime );
volumesBlendingTime = blendTime;
currentVolumeEffects = AmplifyColor.VolumeEffect.BlendValuesToVolumeEffect( EffectFlags, currentVolumeEffects, blendVolumeEffects, effectVolumesBlendAdjusted );
currentExposure = Mathf.Lerp( currentExposure, blendExposure, effectVolumesBlendAdjusted );
effectVolumesBlendAdjust = 1 - volumesBlendAmount;
volumesBlendAmount = 1 - volumesBlendAmount;
}
else
{
if ( volumesBlending )
{
materialBlendCache.SetFloat( "_LerpAmount", volumesBlendAmount );
if ( blendingFromMidBlend )
{
Graphics.Blit( midBlendLUT, blendCacheLut );
materialBlendCache.SetTexture( "_RgbTex", blendCacheLut );
}
else
materialBlendCache.SetTexture( "_RgbTex", LutTexture );
materialBlendCache.SetTexture( "_LerpRgbTex", ( volumesLutBlendTexture != null ) ? volumesLutBlendTexture : defaultLut );
Graphics.Blit( midBlendLUT, midBlendLUT, materialBlendCache );
blendCacheLut.DiscardContents();
#if !UNITY_5_6_OR_NEWER
midBlendLUT.MarkRestoreExpected();
#endif
currentVolumeEffects = AmplifyColor.VolumeEffect.BlendValuesToVolumeEffect( EffectFlags, currentVolumeEffects, blendVolumeEffects, effectVolumesBlendAdjusted );
currentExposure = Mathf.Lerp( currentExposure, blendExposure, effectVolumesBlendAdjusted );
effectVolumesBlendAdjust = 0.0f;
blendingFromMidBlend = true;
}
VolumesBlendTo( blendTex, blendTime );
}
blendVolumeEffects = ( foundVolume == null ) ? worldVolumeEffects : foundVolume.EffectContainer.FindVolumeEffect( this );
blendExposure = ( foundVolume == null ) ? worldExposure : foundVolume.Exposure;
if ( blendVolumeEffects == null )
blendVolumeEffects = worldVolumeEffects;
}
}
private void SetupShader()
{
colorSpace = QualitySettings.activeColorSpace;
qualityLevel = QualityLevel;
shaderBase = Shader.Find( "Hidden/Amplify Color/Base" );
shaderBlend = Shader.Find( "Hidden/Amplify Color/Blend" );
shaderBlendCache = Shader.Find( "Hidden/Amplify Color/BlendCache" );
shaderMask = Shader.Find( "Hidden/Amplify Color/Mask" );
shaderMaskBlend = Shader.Find( "Hidden/Amplify Color/MaskBlend" );
shaderDepthMask = Shader.Find( "Hidden/Amplify Color/DepthMask" );
shaderDepthMaskBlend = Shader.Find( "Hidden/Amplify Color/DepthMaskBlend" );
shaderProcessOnly = Shader.Find( "Hidden/Amplify Color/ProcessOnly" );
}
private void ReleaseMaterials()
{
SafeRelease( ref materialBase );
SafeRelease( ref materialBlend );
SafeRelease( ref materialBlendCache );
SafeRelease( ref materialMask );
SafeRelease( ref materialMaskBlend );
SafeRelease( ref materialDepthMask );
SafeRelease( ref materialDepthMaskBlend );
SafeRelease( ref materialProcessOnly );
}
private Texture2D CreateDefaultLut()
{
const int maxSize = LutSize - 1;
defaultLut = new Texture2D( LutWidth, LutHeight, TextureFormat.RGB24, false, true ) { hideFlags = HideFlags.HideAndDontSave };
defaultLut.name = "DefaultLut";
defaultLut.hideFlags = HideFlags.DontSave;
defaultLut.anisoLevel = 1;
defaultLut.filterMode = FilterMode.Bilinear;
Color32[] colors = new Color32[ LutWidth * LutHeight ];
for ( int z = 0; z < LutSize; z++ )
{
int zoffset = z * LutSize;
for ( int y = 0; y < LutSize; y++ )
{
int yoffset = zoffset + y * LutWidth;
for ( int x = 0; x < LutSize; x++ )
{
float fr = x / ( float ) maxSize;
float fg = y / ( float ) maxSize;
float fb = z / ( float ) maxSize;
byte br = ( byte ) ( fr * 255 );
byte bg = ( byte ) ( fg * 255 );
byte bb = ( byte ) ( fb * 255 );
colors[ yoffset + x ] = new Color32( br, bg, bb, 255 );
}
}
}
defaultLut.SetPixels32( colors );
defaultLut.Apply();
return defaultLut;
}
private Texture2D CreateDepthCurveLut()
{
SafeRelease( ref depthCurveLut );
depthCurveLut = new Texture2D( DepthCurveLutRange, 1, TextureFormat.Alpha8, false, true ) { hideFlags = HideFlags.HideAndDontSave };
depthCurveLut.name = "DepthCurveLut";
depthCurveLut.hideFlags = HideFlags.DontSave;
depthCurveLut.anisoLevel = 1;
depthCurveLut.wrapMode = TextureWrapMode.Clamp;
depthCurveLut.filterMode = FilterMode.Bilinear;
depthCurveColors = new Color32[ DepthCurveLutRange ];
return depthCurveLut;
}
private void UpdateDepthCurveLut()
{
if ( depthCurveLut == null )
CreateDepthCurveLut();
const float rcpMaxRange = 1.0f / ( DepthCurveLutRange - 1 );
float time = 0;
for ( int x = 0; x < DepthCurveLutRange; x++, time += rcpMaxRange )
depthCurveColors[ x ].a = ( byte ) Mathf.FloorToInt( Mathf.Clamp01( DepthMaskCurve.Evaluate( time ) ) * 255.0f );
depthCurveLut.SetPixels32( depthCurveColors );
depthCurveLut.Apply();
}
private void CheckUpdateDepthCurveLut()
{
// check if keyframes differ
bool changed = false;
if ( DepthMaskCurve.length != prevDepthMaskCurve.length )
changed = true;
else
{
const float rcpMaxRange = 1.0f / ( DepthCurveLutRange - 1 );
float time = 0;
for ( int i = 0; i < DepthMaskCurve.length; i++, time += rcpMaxRange )
{
if ( Mathf.Abs( DepthMaskCurve.Evaluate( time ) - prevDepthMaskCurve.Evaluate( time ) ) > float.Epsilon )
{
changed = true;
break;
}
}
}
if ( depthCurveLut == null || changed )
{
// update curve lut texture
UpdateDepthCurveLut();
prevDepthMaskCurve = new AnimationCurve( DepthMaskCurve.keys );
}
}
private void CreateHelperTextures()
{
ReleaseTextures();
blendCacheLut = new RenderTexture( LutWidth, LutHeight, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear ) { hideFlags = HideFlags.HideAndDontSave };
blendCacheLut.name = "BlendCacheLut";
blendCacheLut.wrapMode = TextureWrapMode.Clamp;
blendCacheLut.useMipMap = false;
blendCacheLut.anisoLevel = 0;
blendCacheLut.Create();
midBlendLUT = new RenderTexture( LutWidth, LutHeight, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear ) { hideFlags = HideFlags.HideAndDontSave };
midBlendLUT.name = "MidBlendLut";
midBlendLUT.wrapMode = TextureWrapMode.Clamp;
midBlendLUT.useMipMap = false;
midBlendLUT.anisoLevel = 0;
midBlendLUT.Create();
#if !UNITY_5_6_OR_NEWER
midBlendLUT.MarkRestoreExpected();
#endif
CreateDefaultLut();
if ( UseDepthMask )
CreateDepthCurveLut();
}
bool CheckMaterialAndShader( Material material, string name )
{
if ( material == null || material.shader == null )
{
Debug.LogWarning( "[AmplifyColor] Error creating " + name + " material. Effect disabled." );
enabled = false;
}
else if ( !material.shader.isSupported )
{
Debug.LogWarning( "[AmplifyColor] " + name + " shader not supported on this platform. Effect disabled." );
enabled = false;
}
else
{
material.hideFlags = HideFlags.HideAndDontSave;
}
return enabled;
}
private bool CreateMaterials()
{
SetupShader();
if ( !CheckShaders() )
return false;
ReleaseMaterials();
materialBase = new Material( shaderBase );
materialBlend = new Material( shaderBlend );
materialBlendCache = new Material( shaderBlendCache );
materialMask = new Material( shaderMask );
materialMaskBlend = new Material( shaderMaskBlend );
materialDepthMask = new Material( shaderDepthMask );
materialDepthMaskBlend = new Material( shaderDepthMaskBlend );
materialProcessOnly = new Material( shaderProcessOnly );
bool ok = true;
ok = ok && CheckMaterialAndShader( materialBase, "BaseMaterial" );
ok = ok && CheckMaterialAndShader( materialBlend, "BlendMaterial" );
ok = ok && CheckMaterialAndShader( materialBlendCache, "BlendCacheMaterial" );
ok = ok && CheckMaterialAndShader( materialMask, "MaskMaterial" );
ok = ok && CheckMaterialAndShader( materialMaskBlend, "MaskBlendMaterial" );
ok = ok && CheckMaterialAndShader( materialDepthMask, "DepthMaskMaterial" );
ok = ok && CheckMaterialAndShader( materialDepthMaskBlend, "DepthMaskBlendMaterial" );
ok = ok && CheckMaterialAndShader( materialProcessOnly, "ProcessOnlyMaterial" );
if ( !ok )
return false;
CreateHelperTextures();
return true;
}
void SetMaterialKeyword( string keyword, bool state )
{
#if !UNITY_5_6_OR_NEWER
if ( state )
Shader.EnableKeyword( keyword );
else
Shader.DisableKeyword( keyword );
#else
bool keywordEnabled = materialBase.IsKeywordEnabled( keyword );
if ( state && !keywordEnabled )
{
materialBase.EnableKeyword( keyword );
materialBlend.EnableKeyword( keyword );
materialBlendCache.EnableKeyword( keyword );
materialMask.EnableKeyword( keyword );
materialMaskBlend.EnableKeyword( keyword );
materialDepthMask.EnableKeyword( keyword );
materialDepthMaskBlend.EnableKeyword( keyword );
materialProcessOnly.EnableKeyword( keyword );
}
else if ( !state && materialBase.IsKeywordEnabled( keyword ) )
{
materialBase.DisableKeyword( keyword );
materialBlend.DisableKeyword( keyword );
materialBlendCache.DisableKeyword( keyword );
materialMask.DisableKeyword( keyword );
materialMaskBlend.DisableKeyword( keyword );
materialDepthMask.DisableKeyword( keyword );
materialDepthMaskBlend.DisableKeyword( keyword );
materialProcessOnly.DisableKeyword( keyword );
}
#endif
}
private void SafeRelease<T>( ref T obj ) where T : UnityEngine.Object
{
if ( obj != null )
{
if ( obj.GetType() == typeof( RenderTexture ) )
( obj as RenderTexture ).Release();
DestroyImmediate( obj );
obj = null;
}
}
private void ReleaseTextures()
{
RenderTexture.active = null;
SafeRelease( ref blendCacheLut );
SafeRelease( ref midBlendLUT );
SafeRelease( ref defaultLut );
SafeRelease( ref depthCurveLut );
}
public static bool ValidateLutDimensions( Texture lut )
{
bool valid = true;
if ( lut != null )
{
if ( ( lut.width / lut.height ) != lut.height )
{
Debug.LogWarning( "[AmplifyColor] Lut " + lut.name + " has invalid dimensions." );
valid = false;
}
else
{
if ( lut.anisoLevel != 0 )
lut.anisoLevel = 0;
}
}
return valid;
}
private void UpdatePostEffectParams()
{
if ( UseDepthMask )
CheckUpdateDepthCurveLut();
Exposure = Mathf.Max( Exposure, 0 );
}
private int ComputeShaderPass()
{
bool isMobile = ( QualityLevel == AmplifyColor.Quality.Mobile );
bool isLinear = ( colorSpace == ColorSpace.Linear );
#if UNITY_5_6_OR_NEWER
bool isHDR = ownerCamera.allowHDR;
#else
bool isHDR = ownerCamera.hdr;
#endif
int pass = isMobile ? 18 : 0;
if ( isHDR )
{
pass += 2; // skip LDR
pass += isLinear ? 8 : 0; // skip GAMMA, if applicable
pass += ApplyDithering ? 4 : 0; // skip DITHERING, if applicable
pass += ( int ) Tonemapper;
}
else
{
pass += isLinear ? 1 : 0;
}
return pass;
}
private void OnRenderImage( RenderTexture source, RenderTexture destination )
{
if ( silentError )
{
Graphics.Blit( source, destination );
return;
}
BlendAmount = Mathf.Clamp01( BlendAmount );
if ( colorSpace != QualitySettings.activeColorSpace || qualityLevel != QualityLevel )
CreateMaterials();
UpdatePostEffectParams();
bool validLut = ValidateLutDimensions( LutTexture );
bool validLutBlend = ValidateLutDimensions( LutBlendTexture );
bool skip = ( LutTexture == null && LutBlendTexture == null && volumesLutBlendTexture == null );
Texture lut = ( LutTexture == null ) ? defaultLut : LutTexture;
Texture lutBlend = LutBlendTexture;
int pass = ComputeShaderPass();
bool blend = ( BlendAmount != 0.0f ) || blending;
bool requiresBlend = blend || ( blend && lutBlend != null );
bool useBlendCache = requiresBlend;
bool processOnly = !validLut || !validLutBlend || skip;
Material material;
if ( processOnly )
{
material = materialProcessOnly;
}
else
{
if ( requiresBlend || volumesBlending )
{
if ( UseDepthMask )
material = materialDepthMaskBlend;
else
material = ( MaskTexture != null ) ? materialMaskBlend : materialBlend;
}
else
{
if ( UseDepthMask )
material = materialDepthMask;
else
material = ( MaskTexture != null ) ? materialMask : materialBase;
}
}
// HDR control params
material.SetFloat( "_Exposure", Exposure );
material.SetFloat( "_ShoulderStrength", 0.22f );
material.SetFloat( "_LinearStrength", 0.30f );
material.SetFloat( "_LinearAngle", 0.10f );
material.SetFloat( "_ToeStrength", 0.20f );
material.SetFloat( "_ToeNumerator", 0.01f );
material.SetFloat( "_ToeDenominator", 0.30f );
material.SetFloat( "_LinearWhite", LinearWhitePoint );
// Blending params
material.SetFloat( "_LerpAmount", BlendAmount );
if ( MaskTexture != null )
material.SetTexture( "_MaskTex", MaskTexture );
if ( UseDepthMask )
material.SetTexture( "_DepthCurveLut", depthCurveLut );
// Stereo
#if UNITY_5_6_OR_NEWER
if ( MaskTexture != null && source.dimension == TextureDimension.Tex2DArray )
{
material.SetVector( "_StereoScale", new Vector4( 0.5f, 1, 0.5f, 0 ) );
}
else
{
material.SetVector( "_StereoScale", new Vector4( 1, 1, 0, 0 ) );
}
#else
material.SetVector( "_StereoScale", new Vector4( 1, 1, 0, 0 ) );
#endif
if ( !processOnly )
{
if ( volumesBlending )
{
volumesBlendAmount = Mathf.Clamp01( volumesBlendAmount );
materialBlendCache.SetFloat( "_LerpAmount", volumesBlendAmount );
if ( blendingFromMidBlend )
materialBlendCache.SetTexture( "_RgbTex", midBlendLUT );
else
materialBlendCache.SetTexture( "_RgbTex", lut );
materialBlendCache.SetTexture( "_LerpRgbTex", ( volumesLutBlendTexture != null ) ? volumesLutBlendTexture : defaultLut );
Graphics.Blit( lut, blendCacheLut, materialBlendCache );
}
if ( useBlendCache )
{
materialBlendCache.SetFloat( "_LerpAmount", BlendAmount );
RenderTexture temp = null;
if ( volumesBlending )
{
temp = RenderTexture.GetTemporary( blendCacheLut.width, blendCacheLut.height, blendCacheLut.depth, blendCacheLut.format, RenderTextureReadWrite.Linear );
Graphics.Blit( blendCacheLut, temp );
materialBlendCache.SetTexture( "_RgbTex", temp );
}
else
materialBlendCache.SetTexture( "_RgbTex", lut );
materialBlendCache.SetTexture( "_LerpRgbTex", ( lutBlend != null ) ? lutBlend : defaultLut );
Graphics.Blit( lut, blendCacheLut, materialBlendCache );
if ( temp != null )
RenderTexture.ReleaseTemporary( temp );
material.SetTexture( "_RgbBlendCacheTex", blendCacheLut );
}
else if ( volumesBlending )
{
material.SetTexture( "_RgbBlendCacheTex", blendCacheLut );
}
else
{
if ( lut != null )
material.SetTexture( "_RgbTex", lut );
if ( lutBlend != null )
material.SetTexture( "_LerpRgbTex", lutBlend );
}
}
Graphics.Blit( source, destination, material, pass );
if ( useBlendCache || volumesBlending )
blendCacheLut.DiscardContents();
}
#if TRIAL
void OnGUI()
{
if ( !silentError && watermark != null )
GUI.DrawTexture( new Rect( 15, Screen.height - watermark.height - 12, watermark.width, watermark.height ), watermark );
}
#endif
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 544d7113f2240ba4ca0e854ddf1d5cb2
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -0,0 +1,15 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using UnityEngine;
#if UNITY_5_6_OR_NEWER
[ImageEffectAllowedInSceneView]
#endif
[ImageEffectTransformsToLDR]
[ExecuteInEditMode]
[AddComponentMenu( "Image Effects/Amplify Color" )]
sealed public class AmplifyColorEffect : AmplifyColorBase
{
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 6b9e31fdf962e3e4ca3b62ec3ecc2f4e
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: cde8652f320cde043a6c4f57aa6d242f, type: 3}

View File

@ -0,0 +1,13 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using UnityEngine;
[ExecuteInEditMode]
[RequireComponent( typeof( Camera ) )]
[RequireComponent( typeof( AmplifyColorEffect ) )]
[AddComponentMenu( "Image Effects/Amplify Color Render Mask" )]
public class AmplifyColorRenderMask : AmplifyColorRenderMaskBase
{
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 98653e2840386544bab0f9ac48776ee6
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -0,0 +1,230 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
#if UNITY_5_6_OR_NEWER
#define MANUAL_DETECT_SINGLE_PASS
#endif
using System;
using UnityEngine;
using UnityEngine.Serialization;
#if UNITY_2017_2_OR_NEWER
using UnityEngine.Rendering;
using UnityEngine.XR;
#elif UNITY_5_6_OR_NEWER
using UnityEngine.Rendering;
using UnityEngine.VR;
#endif
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace AmplifyColor
{
[Serializable]
public struct RenderLayer
{
public LayerMask mask;
public Color color;
public RenderLayer( LayerMask mask, Color color )
{
this.mask = mask;
this.color = color;
}
}
}
[ExecuteInEditMode]
[RequireComponent( typeof( Camera ) )]
[AddComponentMenu( "" )]
public class AmplifyColorRenderMaskBase : MonoBehaviour
{
[FormerlySerializedAs( "clearColor" )]
public Color ClearColor = Color.black;
[FormerlySerializedAs( "renderLayers" )]
public AmplifyColor.RenderLayer[] RenderLayers = new AmplifyColor.RenderLayer[ 0 ];
[FormerlySerializedAs( "debug" )]
public bool DebugMask;
private Camera referenceCamera;
private Camera maskCamera;
private AmplifyColorBase colorEffect;
private int width, height;
private RenderTexture maskTexture;
private Shader colorMaskShader;
private bool singlePassStereo = false;
void OnEnable()
{
if ( maskCamera == null )
{
var go = new GameObject( "Mask Camera", typeof( Camera ) ) { hideFlags = HideFlags.HideAndDontSave };
go.transform.parent = gameObject.transform;
maskCamera = go.GetComponent<Camera>();
}
referenceCamera = GetComponent<Camera>();
colorEffect = GetComponent<AmplifyColorBase>();
colorMaskShader = Shader.Find( "Hidden/RenderMask" );
}
void OnDisable()
{
DestroyCamera();
DestroyRenderTextures();
}
void DestroyCamera()
{
if ( maskCamera != null )
{
DestroyImmediate( maskCamera.gameObject );
maskCamera = null;
}
}
void DestroyRenderTextures()
{
if ( maskTexture != null )
{
RenderTexture.active = null;
DestroyImmediate( maskTexture );
maskTexture = null;
}
}
void UpdateRenderTextures( bool singlePassStereo )
{
int width = referenceCamera.pixelWidth;
int height = referenceCamera.pixelHeight;
if ( maskTexture == null || this.width != width || this.height != height || !maskTexture.IsCreated() || this.singlePassStereo != singlePassStereo )
{
this.width = width;
this.height = height;
DestroyRenderTextures();
#if UNITY_2017_2_OR_NEWER
if ( XRSettings.enabled )
{
width = XRSettings.eyeTextureWidth * ( singlePassStereo ? 2 : 1 );
height = XRSettings.eyeTextureHeight;
}
#endif
if ( maskTexture == null )
{
maskTexture = new RenderTexture( width, height, 24, RenderTextureFormat.Default, RenderTextureReadWrite.sRGB ) { hideFlags = HideFlags.HideAndDontSave, name = "MaskTexture" };
maskTexture.name = "AmplifyColorMaskTexture";
#if UNITY_5_6_OR_NEWER
bool allowMSAA = maskCamera.allowMSAA;
#else
bool allowMSAA = true;
#endif
maskTexture.antiAliasing = ( allowMSAA && QualitySettings.antiAliasing > 0 ) ? QualitySettings.antiAliasing : 1;
}
maskTexture.Create();
this.singlePassStereo = singlePassStereo;
}
if ( colorEffect != null )
{
colorEffect.MaskTexture = maskTexture;
}
}
void UpdateCameraProperties()
{
maskCamera.CopyFrom( referenceCamera );
maskCamera.targetTexture = maskTexture;
maskCamera.clearFlags = CameraClearFlags.Nothing;
maskCamera.renderingPath = RenderingPath.VertexLit;
maskCamera.pixelRect = new Rect( 0, 0, width, height );
maskCamera.depthTextureMode = DepthTextureMode.None;
#if UNITY_5_6_OR_NEWER
maskCamera.allowHDR = false;
#else
maskCamera.hdr = false;
#endif
maskCamera.enabled = false;
}
void OnPreRender()
{
if ( maskCamera != null )
{
RenderBuffer prevColor = Graphics.activeColorBuffer;
RenderBuffer prevDepth = Graphics.activeDepthBuffer;
// single pass not supported in RenderWithShader() as of Unity 2018.1; do multi-pass
bool singlePassStereo = false;
#if UNITY_2017_2_OR_NEWER
if ( referenceCamera.stereoEnabled )
{
singlePassStereo = ( XRSettings.eyeTextureDesc.vrUsage == VRTextureUsage.TwoEyes );
maskCamera.SetStereoViewMatrix( Camera.StereoscopicEye.Left, referenceCamera.GetStereoViewMatrix( Camera.StereoscopicEye.Left ) );
maskCamera.SetStereoViewMatrix( Camera.StereoscopicEye.Right, referenceCamera.GetStereoViewMatrix( Camera.StereoscopicEye.Right ) );
maskCamera.SetStereoProjectionMatrix( Camera.StereoscopicEye.Left, referenceCamera.GetStereoProjectionMatrix( Camera.StereoscopicEye.Left ) );
maskCamera.SetStereoProjectionMatrix( Camera.StereoscopicEye.Right, referenceCamera.GetStereoProjectionMatrix( Camera.StereoscopicEye.Right ) );
}
#endif
UpdateRenderTextures( singlePassStereo );
UpdateCameraProperties();
Graphics.SetRenderTarget( maskTexture );
GL.Clear( true, true, ClearColor );
#if UNITY_2017_2_OR_NEWER
if ( singlePassStereo )
{
maskCamera.worldToCameraMatrix = referenceCamera.GetStereoViewMatrix( Camera.StereoscopicEye.Left );
maskCamera.projectionMatrix = referenceCamera.GetStereoProjectionMatrix( Camera.StereoscopicEye.Left );
maskCamera.rect = new Rect( 0, 0, 0.5f, 1 );
}
#endif
foreach ( var layer in RenderLayers )
{
Shader.SetGlobalColor( "_COLORMASK_Color", layer.color );
maskCamera.cullingMask = layer.mask;
maskCamera.RenderWithShader( colorMaskShader, "RenderType" );
}
#if UNITY_2017_2_OR_NEWER
if ( singlePassStereo )
{
maskCamera.worldToCameraMatrix = referenceCamera.GetStereoViewMatrix( Camera.StereoscopicEye.Right );
maskCamera.projectionMatrix = referenceCamera.GetStereoProjectionMatrix( Camera.StereoscopicEye.Right );
maskCamera.rect = new Rect( 0.5f, 0, 0.5f, 1 );
foreach ( var layer in RenderLayers )
{
Shader.SetGlobalColor( "_COLORMASK_Color", layer.color );
maskCamera.cullingMask = layer.mask;
maskCamera.RenderWithShader( colorMaskShader, "RenderType" );
}
}
#endif
Graphics.SetRenderTarget( prevColor, prevDepth );
}
}
#if UNITY_EDITOR
void OnGUI()
{
if ( DebugMask )
{
GUI.DrawTexture( new Rect( 0, 0, Screen.width, Screen.height ), maskTexture );
}
}
#endif
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: eed917f35ace957469ca95ea3c7f8b7f
timeCreated: 1505318568
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,31 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using System.Collections;
[RequireComponent( typeof( Rigidbody ) )]
[RequireComponent( typeof( SphereCollider ) )]
[AddComponentMenu( "" )]
public class AmplifyColorTriggerProxy : AmplifyColorTriggerProxyBase
{
private SphereCollider sphereCollider;
private Rigidbody rigidBody;
void Start()
{
sphereCollider = GetComponent<SphereCollider>();
sphereCollider.radius = 0.01f;
sphereCollider.isTrigger = true;
rigidBody = GetComponent<Rigidbody>();
rigidBody.useGravity = false;
rigidBody.isKinematic = true;
}
void LateUpdate()
{
transform.position = Reference.position;
transform.rotation = Reference.rotation;
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 98bffd318ecbfb74a94d9ab8c4140834
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -0,0 +1,31 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using System.Collections;
[RequireComponent( typeof( Rigidbody2D ) )]
[RequireComponent( typeof( CircleCollider2D ) )]
[AddComponentMenu( "" )]
public class AmplifyColorTriggerProxy2D : AmplifyColorTriggerProxyBase
{
private CircleCollider2D circleCollider;
private Rigidbody2D rigidBody;
void Start()
{
circleCollider = GetComponent<CircleCollider2D>();
circleCollider.radius = 0.01f;
circleCollider.isTrigger = true;
rigidBody = GetComponent<Rigidbody2D>();
rigidBody.gravityScale = 0;
rigidBody.isKinematic = true;
}
void LateUpdate()
{
transform.position = Reference.position;
transform.rotation = Reference.rotation;
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 4524aa0ac2b17c94f9cfa6f982c7e609
timeCreated: 1443525278
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,12 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using System.Collections;
[AddComponentMenu( "" )]
public class AmplifyColorTriggerProxyBase : MonoBehaviour
{
public Transform Reference;
public AmplifyColorBase OwnerEffect;
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f3d76614a6644204fa8aea7d5d81b83f
timeCreated: 1443525278
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,24 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using System.Collections;
[RequireComponent( typeof( BoxCollider ) )]
[AddComponentMenu( "Image Effects/Amplify Color Volume" )]
public class AmplifyColorVolume : AmplifyColorVolumeBase
{
void OnTriggerEnter( Collider other )
{
AmplifyColorTriggerProxy tp = other.GetComponent<AmplifyColorTriggerProxy>();
if ( tp != null && tp.OwnerEffect.UseVolumes && ( tp.OwnerEffect.VolumeCollisionMask & ( 1 << gameObject.layer ) ) != 0 )
tp.OwnerEffect.EnterVolume( this );
}
void OnTriggerExit( Collider other )
{
AmplifyColorTriggerProxy tp = other.GetComponent<AmplifyColorTriggerProxy>();
if ( tp != null && tp.OwnerEffect.UseVolumes && ( tp.OwnerEffect.VolumeCollisionMask & ( 1 << gameObject.layer ) ) != 0 )
tp.OwnerEffect.ExitVolume( this );
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 80a2ce78f94161948a5dcf16ec84f0c4
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 7662ff3b3eb367545b8e4f8c9dd17802, type: 3}

View File

@ -0,0 +1,24 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using System.Collections;
[RequireComponent( typeof( BoxCollider2D ) )]
[AddComponentMenu( "Image Effects/Amplify Color Volume 2D" )]
public class AmplifyColorVolume2D : AmplifyColorVolumeBase
{
void OnTriggerEnter2D( Collider2D other )
{
AmplifyColorTriggerProxy2D tp = other.GetComponent<AmplifyColorTriggerProxy2D>();
if ( tp != null && tp.OwnerEffect.UseVolumes && ( tp.OwnerEffect.VolumeCollisionMask & ( 1 << gameObject.layer ) ) != 0 )
tp.OwnerEffect.EnterVolume( this );
}
void OnTriggerExit2D( Collider2D other )
{
AmplifyColorTriggerProxy2D tp = other.GetComponent<AmplifyColorTriggerProxy2D>();
if ( tp != null && tp.OwnerEffect.UseVolumes && ( tp.OwnerEffect.VolumeCollisionMask & ( 1 << gameObject.layer ) ) != 0 )
tp.OwnerEffect.ExitVolume( this );
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ceed598233ebfb04980d5ed04813881d
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 7662ff3b3eb367545b8e4f8c9dd17802, type: 3}

View File

@ -0,0 +1,99 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
using System.Collections;
[ExecuteInEditMode]
[AddComponentMenu( "" )]
public class AmplifyColorVolumeBase : MonoBehaviour
{
public Texture2D LutTexture;
public float Exposure = 1.0f;
public float EnterBlendTime = 1.0f;
public int Priority = 0;
public bool ShowInSceneView = true;
[HideInInspector] public AmplifyColor.VolumeEffectContainer EffectContainer = new AmplifyColor.VolumeEffectContainer();
#if UNITY_EDITOR
public static EditorWindow Window;
void OnEnable()
{
if ( Window != null )
Window.Repaint();
}
void OnDestroy()
{
if ( Window != null )
Window.Repaint();
}
#endif
void OnDrawGizmos()
{
if ( ShowInSceneView )
{
BoxCollider box = GetComponent<BoxCollider>();
BoxCollider2D box2d = GetComponent<BoxCollider2D>();
if ( box != null || box2d != null )
{
Vector3 center, size;
if ( box != null )
{
center = box.center;
size = box.size;
}
else
{
#if UNITY_5_6_OR_NEWER
center = box2d.offset;
#else
center = box2d.center;
#endif
size = box2d.size;
}
Gizmos.color = Color.green;
Gizmos.matrix = transform.localToWorldMatrix;
Gizmos.DrawWireCube( center, size );
}
}
}
void OnDrawGizmosSelected()
{
BoxCollider box = GetComponent<BoxCollider>();
BoxCollider2D box2d = GetComponent<BoxCollider2D>();
if ( box != null || box2d != null )
{
Color col = Color.green;
col.a = 0.2f;
Gizmos.color = col;
Gizmos.matrix = transform.localToWorldMatrix;
Vector3 center, size;
if ( box != null )
{
center = box.center;
size = box.size;
}
else
{
#if UNITY_5_6_OR_NEWER
center = box2d.offset;
#else
center = box2d.center;
#endif
size = box2d.size;
}
Gizmos.DrawCube( center, size );
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 96e3345975b3bdb4ca8a26a5785692a0
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 355faf3b9260d9344824e4bbc0196854

View File

@ -0,0 +1,88 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace AmplifyColor
{
public class About : EditorWindow
{
private const string AboutImagePath = "AmplifyColor/Textures/About.png";
private Vector2 m_scrollPosition = Vector2.zero;
private Texture2D m_aboutImage;
[MenuItem( "Window/Amplify Color/About...", false, 20 )]
static void Init()
{
About window = ( About ) EditorWindow.GetWindow( typeof( About ) , true , "About Amplify Color" );
window.minSize = new Vector2( 502, 290 );
window.maxSize = new Vector2( 502, 290 );
window.Show();
}
public void OnFocus()
{
string[] guids = AssetDatabase.FindAssets( "About t:Texture" );
string asset = "";
foreach ( string guid in guids )
{
string path = AssetDatabase.GUIDToAssetPath( guid );
if ( path.EndsWith( AboutImagePath ) )
{
asset = path;
break;
}
}
if ( !string.IsNullOrEmpty( asset ) )
{
TextureImporter importer = AssetImporter.GetAtPath( asset ) as TextureImporter;
if ( importer.textureType != TextureImporterType.GUI )
{
importer.textureType = TextureImporterType.GUI;
AssetDatabase.ImportAsset( asset );
}
m_aboutImage = AssetDatabase.LoadAssetAtPath( asset, typeof( Texture2D ) ) as Texture2D;
}
else
Debug.LogWarning( "[AmplifyColor] About image not found at " + AboutImagePath );
}
public void OnGUI()
{
m_scrollPosition = GUILayout.BeginScrollView( m_scrollPosition );
GUILayout.BeginVertical();
GUILayout.Space( 10 );
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUILayout.Box( m_aboutImage, GUIStyle.none );
if ( Event.current.type == EventType.MouseUp && GUILayoutUtility.GetLastRect().Contains( Event.current.mousePosition ) )
Application.OpenURL( "http://www.amplify.pt" );
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUIStyle labelStyle = new GUIStyle( EditorStyles.label );
labelStyle.alignment = TextAnchor.MiddleCenter;
labelStyle.wordWrap = true;
GUILayout.Label( "\nAmplify Color " + VersionInfo.StaticToString(), labelStyle, GUILayout.ExpandWidth( true ) );
GUILayout.Label( "\nCopyright (c) Amplify Creations, Lda. All rights reserved.\n", labelStyle, GUILayout.ExpandWidth( true ) );
GUILayout.EndVertical();
GUILayout.EndScrollView();
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 3d40c53f54c673248966d89bc163cfa2
timeCreated: 1432119206
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: 9cd25b46b385d6e47bb987265e487b11
PluginImporter:
serializedVersion: 1
iconMap: {}
executionOrder: {}
isPreloaded: 0
platformData:
Any:
enabled: 0
settings: {}
Editor:
enabled: 1
settings:
DefaultValueInitialized: true
WindowsStoreApps:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,16 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using UnityEditor;
using UnityEngine;
[CustomEditor( typeof( AmplifyColorEffect ) )]
class AmplifyColorEffectEditor : AmplifyColorEffectEditorBase
{
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ec4d675186432d549a3cbf2f61623d49
timeCreated: 1433276791
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,212 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using UnityEditor;
using UnityEngine;
public class AmplifyColorEffectEditorBase : Editor
{
SerializedProperty tonemapper;
SerializedProperty exposure;
SerializedProperty linearWhitePoint;
SerializedProperty useDithering;
SerializedProperty qualityLevel;
SerializedProperty blendAmount;
SerializedProperty lutTexture;
SerializedProperty lutBlendTexture;
SerializedProperty maskTexture;
SerializedProperty useDepthMask;
SerializedProperty depthMaskCurve;
SerializedProperty useVolumes;
SerializedProperty exitVolumeBlendTime;
SerializedProperty triggerVolumeProxy;
SerializedProperty volumeCollisionMask;
void OnEnable()
{
tonemapper = serializedObject.FindProperty( "Tonemapper" );
exposure = serializedObject.FindProperty( "Exposure" );
linearWhitePoint = serializedObject.FindProperty( "LinearWhitePoint" );
useDithering = serializedObject.FindProperty( "ApplyDithering" );
qualityLevel = serializedObject.FindProperty( "QualityLevel" );
blendAmount = serializedObject.FindProperty( "BlendAmount" );
lutTexture = serializedObject.FindProperty( "LutTexture" );
lutBlendTexture = serializedObject.FindProperty( "LutBlendTexture" );
maskTexture = serializedObject.FindProperty( "MaskTexture" );
useDepthMask = serializedObject.FindProperty( "UseDepthMask" );
depthMaskCurve = serializedObject.FindProperty( "DepthMaskCurve" );
useVolumes = serializedObject.FindProperty( "UseVolumes" );
exitVolumeBlendTime = serializedObject.FindProperty( "ExitVolumeBlendTime" );
triggerVolumeProxy = serializedObject.FindProperty( "TriggerVolumeProxy" );
volumeCollisionMask = serializedObject.FindProperty( "VolumeCollisionMask" );
if ( !Application.isPlaying )
{
AmplifyColorBase effect = target as AmplifyColorBase;
bool needsNewID = string.IsNullOrEmpty( effect.SharedInstanceID );
if ( !needsNewID )
needsNewID = FindClone( effect );
if ( needsNewID )
{
effect.NewSharedInstanceID();
EditorUtility.SetDirty( target );
}
}
}
bool FindClone( AmplifyColorBase effect )
{
#if UNITY_2018_3_OR_NEWER
GameObject effectPrefab = PrefabUtility.GetCorrespondingObjectFromSource( effect.gameObject ) as GameObject;
PrefabAssetType effectPrefabType = PrefabUtility.GetPrefabAssetType( effect.gameObject );
PrefabInstanceStatus effectPrefabInstanceStatus = PrefabUtility.GetPrefabInstanceStatus( effect.gameObject );
bool effectIsPrefab = ( effectPrefabType != PrefabAssetType.NotAPrefab && effectPrefabInstanceStatus == PrefabInstanceStatus.NotAPrefab );
#else
#if UNITY_2018_2_OR_NEWER
GameObject effectPrefab = PrefabUtility.GetCorrespondingObjectFromSource( effect.gameObject ) as GameObject;
#else
GameObject effectPrefab = PrefabUtility.GetPrefabParent( effect.gameObject ) as GameObject;
#endif
PrefabType effectPrefabType = PrefabUtility.GetPrefabType( effect.gameObject );
bool effectIsPrefab = ( effectPrefabType != PrefabType.None && effectPrefabType != PrefabType.PrefabInstance );
#endif
bool effectHasPrefab = ( effectPrefab != null );
AmplifyColorBase[] all = Resources.FindObjectsOfTypeAll( typeof( AmplifyColorBase ) ) as AmplifyColorBase[];
bool foundClone = false;
foreach ( AmplifyColorBase other in all )
{
if ( other == effect || other.SharedInstanceID != effect.SharedInstanceID )
{
// skip: same effect or already have different ids
continue;
}
#if UNITY_2018_3_OR_NEWER
GameObject otherPrefab = PrefabUtility.GetCorrespondingObjectFromSource( other.gameObject ) as GameObject;
PrefabAssetType otherPrefabType = PrefabUtility.GetPrefabAssetType( other.gameObject );
PrefabInstanceStatus otherPrefabInstanceStatus = PrefabUtility.GetPrefabInstanceStatus( other.gameObject );
bool otherIsPrefab = ( otherPrefabType != PrefabAssetType.NotAPrefab && otherPrefabInstanceStatus == PrefabInstanceStatus.NotAPrefab );
#else
#if UNITY_2018_2_OR_NEWER
GameObject otherPrefab = PrefabUtility.GetCorrespondingObjectFromSource( other.gameObject ) as GameObject;
#else
GameObject otherPrefab = PrefabUtility.GetPrefabParent( other.gameObject ) as GameObject;
#endif
PrefabType otherPrefabType = PrefabUtility.GetPrefabType( other.gameObject );
bool otherIsPrefab = ( otherPrefabType != PrefabType.None && otherPrefabType != PrefabType.PrefabInstance );
#endif
bool otherHasPrefab = ( otherPrefab != null );
if ( otherIsPrefab && effectHasPrefab && effectPrefab == other.gameObject )
{
// skip: other is a prefab and effect's prefab is other
continue;
}
if ( effectIsPrefab && otherHasPrefab && otherPrefab == effect.gameObject )
{
// skip: effect is a prefab and other's prefab is effect
continue;
}
if ( !effectIsPrefab && !otherIsPrefab && effectHasPrefab && otherHasPrefab && effectPrefab == otherPrefab )
{
// skip: both aren't prefabs and both have the same parent prefab
continue;
}
foundClone = true;
}
return foundClone;
}
void ToggleContextTitle( SerializedProperty prop, string title )
{
GUILayout.Space( 5 );
GUILayout.BeginHorizontal();
prop.boolValue = GUILayout.Toggle( prop.boolValue, "", GUILayout.Width( 15 ) );
GUILayout.BeginVertical();
GUILayout.Space( 3 );
GUILayout.Label( title );
GUILayout.EndVertical();
GUILayout.EndHorizontal();
}
public override void OnInspectorGUI()
{
serializedObject.Update();
Camera ownerCamera = ( target as AmplifyColorBase ).GetComponent<Camera>();
GUILayout.BeginVertical();
if ( ownerCamera != null )
{
GUILayout.Space( 12 );
GUILayout.Label( "HDR Control", EditorStyles.boldLabel );
GUILayout.Space( -4 );
EditorGUILayout.PropertyField( tonemapper );
EditorGUILayout.PropertyField( exposure );
GUI.enabled = ( tonemapper.enumValueIndex == ( int ) AmplifyColor.Tonemapping.FilmicHable );
EditorGUILayout.PropertyField( linearWhitePoint );
GUI.enabled = true;
linearWhitePoint.floatValue = Mathf.Max( 0, linearWhitePoint.floatValue );
EditorGUILayout.PropertyField( useDithering );
GUILayout.Space( 4 );
}
else
GUILayout.Space( 12 );
GUILayout.Label( "Color Grading", EditorStyles.boldLabel );
GUILayout.Space( -4 );
EditorGUILayout.PropertyField( qualityLevel );
EditorGUILayout.PropertyField( blendAmount );
EditorGUILayout.PropertyField( lutTexture );
EditorGUILayout.PropertyField( lutBlendTexture );
EditorGUILayout.PropertyField( maskTexture );
EditorGUILayout.PropertyField( useDepthMask );
EditorGUILayout.PropertyField( depthMaskCurve );
GUILayout.Space( 4 );
GUILayout.Label( "Effect Volumes", EditorStyles.boldLabel );
GUILayout.Space( -4 );
EditorGUILayout.PropertyField( useVolumes );
EditorGUILayout.PropertyField( exitVolumeBlendTime );
EditorGUILayout.PropertyField( triggerVolumeProxy );
EditorGUILayout.PropertyField( volumeCollisionMask );
#if UNITY_5_6_OR_NEWER
bool hdr = ownerCamera.allowHDR;
#else
bool hdr = ownerCamera.hdr;
#endif
if ( ownerCamera != null && ( tonemapper.enumValueIndex != ( int ) AmplifyColor.Tonemapping.Disabled || exposure.floatValue != 1.0f ||
linearWhitePoint.floatValue != 11.2f || useDithering.boolValue ) && !hdr )
{
GUILayout.Space( 4 );
EditorGUILayout.HelpBox( "HDR Control requires Camera HDR to be enabled", MessageType.Warning );
}
GUILayout.Space( 4 );
GUILayout.EndHorizontal();
serializedObject.ApplyModifiedProperties();
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 432600ef85621d14e98fa35f97c90986
timeCreated: 1443525278
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,10 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEditor;
using UnityEngine;
[CustomEditor( typeof( AmplifyColorRenderMask ) )]
public class AmplifyColorRenderMaskEditor : AmplifyColorRenderMaskEditorBase
{
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1995219c57d48f14d8c18298296827eb
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -0,0 +1,63 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace AmplifyColor
{
[CustomPropertyDrawer( typeof( RenderLayer ) )]
public class AmplifyColorRenderLayerDrawer : PropertyDrawer
{
public override void OnGUI( Rect position, SerializedProperty property, GUIContent label )
{
EditorGUI.BeginProperty( position, label, property );
position = EditorGUI.PrefixLabel( position, GUIUtility.GetControlID( FocusType.Passive ), label );
int indent = EditorGUI.indentLevel;
EditorGUI.indentLevel = 0;
float halfWidth = position.width / 2.0f - 4.0f;
Rect maskRect = new Rect( position.x, position.y, halfWidth, position.height );
Rect colorRect = new Rect( position.x + halfWidth + 4.0f, position.y, halfWidth, position.height );
EditorGUI.PropertyField( maskRect, property.FindPropertyRelative( "mask" ), GUIContent.none );
EditorGUI.PropertyField( colorRect, property.FindPropertyRelative( "color" ), GUIContent.none );
EditorGUI.indentLevel = indent;
EditorGUI.EndProperty();
}
}
}
public class AmplifyColorRenderMaskEditorBase : Editor
{
public override void OnInspectorGUI()
{
serializedObject.Update();
var renderColorMask = target as AmplifyColorRenderMaskBase;
int length = renderColorMask.RenderLayers.Length;
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField( serializedObject.FindProperty( "ClearColor" ) );
EditorGUILayout.PropertyField( serializedObject.FindProperty( "RenderLayers" ), true );
EditorGUILayout.PropertyField( serializedObject.FindProperty( "DebugMask" ) );
if ( EditorGUI.EndChangeCheck() )
{
serializedObject.ApplyModifiedProperties();
if ( renderColorMask.RenderLayers.Length > length )
{
for ( int i = length; i < renderColorMask.RenderLayers.Length; i++ )
{
renderColorMask.RenderLayers[ i ] = new AmplifyColor.RenderLayer( 0, Color.white );
}
}
}
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0feb6b427e2ecf342b4e51cfd3800705
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@ -0,0 +1,20 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using UnityEditor;
using UnityEngine;
public class AmplifyColorVolumeEditor : AmplifyColor.VolumeEditorBase
{
[MenuItem( "Window/Amplify Color/Volume Editor", false, 1 )]
public static void Init()
{
GetWindow<AmplifyColorVolumeEditor>( false, "Volume Editor", true );
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 6c081e84f351b6b41bf1be4754c33340
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -0,0 +1,745 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using UnityEditor;
using UnityEngine;
namespace AmplifyColor
{
public class VolumeEditorBase : EditorWindow
{
class NewLineContainer
{
public AmplifyColorBase camera;
public string component;
public string fieldName;
public string fieldType;
public object value;
public NewLineContainer()
{
}
public NewLineContainer( AmplifyColorBase camera )
{
this.camera = camera;
}
public NewLineContainer( AmplifyColorBase camera, string component )
{
this.camera = camera;
this.component = component;
}
public NewLineContainer( AmplifyColorBase camera, string component, string fieldName, string fieldType, object value )
{
this.camera = camera;
this.component = component;
this.fieldName = fieldName;
this.fieldType = fieldType;
this.value = value;
}
public static string GenerateUniqueID( AmplifyColorBase camera, string component, string fieldName )
{
return camera.GetInstanceID().ToString() + "." + component + "." + fieldName;
}
public string GenerateUniqueID()
{
return ( ( camera != null ) ? camera.GetInstanceID().ToString() : "" ) + "." + component + "." + fieldName;
}
public void SetCamera( AmplifyColorBase camera )
{
this.camera = camera;
component = "";
fieldName = "";
fieldType = "";
value = null;
}
public void SetComponent( string component )
{
this.component = component;
fieldName = "";
fieldType = "";
value = null;
}
}
private Vector2 scrollPosition = new Vector2( 0, 0 );
private GUIStyle removeButtonStyle;
void OnGUI()
{
if ( removeButtonStyle == null )
{
removeButtonStyle = new GUIStyle( EditorStyles.miniButton );
removeButtonStyle.border = new RectOffset( 0, 0, 0, 0 );
removeButtonStyle.margin = new RectOffset( 0, 0, 1, 0 );
removeButtonStyle.padding = new RectOffset( 0, 0, 0, 0 );
removeButtonStyle.contentOffset = new Vector2( 0, 0 );
}
scrollPosition = GUILayout.BeginScrollView( scrollPosition );
DrawVolumeList();
GUILayout.EndScrollView();
}
const int iconMinWidth = 20, iconMaxWidth = 43;
const int activeMinWidth = 10, activeMaxWidth = 40;
const int visibleMinWidth = 10, visibleMaxWidth = 40;
const int selectWidth = 16;
const int nameMinWidth = 59, nameMaxWidth = 305;
const int blendMinWidth = 20, blendMaxWidth = 94;
const int priorityMinWidth = 20, priorityMaxWidth = 40;
const int exposureMinWidth = 30, exposureMaxWidth = 50;
const int lutWidth = 40;
const int minIndentWidth = 0, maxIndentWidth = 8;
const int minColumnWidth = 19, maxColumnWidth = 90;
const int minValueWidth = 100, maxValueWidth = 200;
private Texture2D volumeIcon = null;
private string editName = "";
private GameObject editObject = null;
private Dictionary<string,NewLineContainer> copyLines = new Dictionary<string,NewLineContainer>();
private Dictionary<object, List<NewLineContainer>> newLines;
private bool dirtyVolumeFlags = false;
public void OnEnable()
{
newLines = new Dictionary<object, List<NewLineContainer>>();
removeButtonStyle = null;
copyLines.Clear();
#if UNITY_EDITOR
AmplifyColorVolumeBase.Window = this;
#endif
}
public void OnDisable()
{
#if UNITY_EDITOR
AmplifyColorVolumeBase.Window = null;
#endif
}
static string GetEditorPrefsKey( AmplifyColorVolumeBase volume )
{
return "AmplifyColor.VolumeEditor.Foldout." + volume.GetHashCode();
}
bool SetFoldout( AmplifyColorVolumeBase volume, bool state )
{
EditorPrefs.SetBool( GetEditorPrefsKey( volume ), state );
return state;
}
bool GetFoldout( AmplifyColorVolumeBase volume )
{
string key = GetEditorPrefsKey( volume );
if ( !EditorPrefs.HasKey( key ) )
EditorPrefs.SetBool( key, false );
return EditorPrefs.GetBool( key );
}
void DrawHeader( List<AmplifyColorVolumeBase> volumes )
{
GUILayout.BeginHorizontal();
GUILayout.Space( 10 );
if ( volumes.Count > 0 )
{
EditorGUILayout.LabelField( "", GUILayout.MinWidth( iconMinWidth ), GUILayout.MaxWidth( iconMaxWidth - 8 ) );
GUILayout.Space( 0 );
EditorGUILayout.LabelField( "Active", EditorStyles.miniBoldLabel, GUILayout.MinWidth( activeMinWidth ), GUILayout.MaxWidth( activeMaxWidth ) );
GUILayout.Space( 4 );
EditorGUILayout.LabelField( "Visible", EditorStyles.miniBoldLabel, GUILayout.MinWidth( visibleMinWidth ), GUILayout.MaxWidth( visibleMaxWidth ) );
GUILayout.Space( 3 );
EditorGUILayout.LabelField( "", EditorStyles.miniBoldLabel, GUILayout.Width( selectWidth ) );
GUILayout.Space( 10 );
EditorGUILayout.LabelField( "Name", EditorStyles.miniBoldLabel, GUILayout.MinWidth( nameMinWidth ), GUILayout.MaxWidth( nameMaxWidth ) );
GUILayout.Space( 8 );
EditorGUILayout.LabelField( "Blend Time", EditorStyles.miniBoldLabel, GUILayout.MinWidth( blendMinWidth ), GUILayout.MaxWidth( blendMaxWidth ) );
GUILayout.Space( 1 );
EditorGUILayout.LabelField( "Exposure", EditorStyles.miniBoldLabel, GUILayout.MinWidth( exposureMinWidth ), GUILayout.MaxWidth( exposureMaxWidth ) );
GUILayout.Space( 3 );
EditorGUILayout.LabelField( "Priority", EditorStyles.miniBoldLabel, GUILayout.MinWidth( priorityMinWidth ), GUILayout.MaxWidth( priorityMaxWidth ) );
GUILayout.Space( 1 );
EditorGUILayout.LabelField( "LUT", EditorStyles.miniBoldLabel, GUILayout.Width( lutWidth ) );
}
else
{
EditorGUILayout.LabelField( "No Amplify Color Volumes were found in the scene.", EditorStyles.wordWrappedLabel );
GUILayout.FlexibleSpace();
}
GUILayout.EndHorizontal();
}
void DrawVolumeProperties( AmplifyColorVolumeBase volume )
{
GameObject obj = volume.gameObject;
GUILayout.BeginHorizontal();
GUILayout.Space( 10 );
volumeIcon = ( volumeIcon == null ) ? Resources.Load( "volume-icon", typeof( Texture2D ) ) as Texture2D : volumeIcon;
GUILayout.Label( "", GUILayout.MinWidth( iconMinWidth ), GUILayout.MaxWidth( iconMaxWidth ) );
GUILayout.Space( -iconMinWidth * 2 );
GUILayout.Label( volumeIcon, GUILayout.Width( 20 ), GUILayout.Height( 20 ) );
GUILayout.Space( 16 );
GUILayout.Space( 0 );
bool active = obj.activeInHierarchy;
bool keep = EditorGUILayout.Toggle( active, GUILayout.MinWidth( activeMinWidth ), GUILayout.MaxWidth( activeMaxWidth ) );
if ( keep != active )
obj.SetActive( keep );
GUILayout.Space( 6 );
volume.ShowInSceneView = EditorGUILayout.Toggle( volume.ShowInSceneView, GUILayout.MinWidth( visibleMinWidth ), GUILayout.MaxWidth( visibleMaxWidth ) );
GUILayout.Space( 6 );
GUI.skin.textField.fontSize = 10;
GUI.skin.textField.alignment = TextAnchor.UpperCenter;
if ( GUILayout.Button( ( Selection.activeObject == obj ) ? "●" : "", EditorStyles.textField, GUILayout.Width( 16 ), GUILayout.Height( 16 ) ) )
Selection.activeObject = ( Selection.activeObject == obj ) ? null : obj;
GUILayout.Space( 0 );
GUI.skin.textField.fontSize = 11;
GUI.skin.textField.alignment = TextAnchor.MiddleLeft;
string instId = obj.GetInstanceID().ToString();
GUI.SetNextControlName( instId );
if ( editObject != obj )
EditorGUILayout.TextField( obj.name, GUILayout.MinWidth( nameMinWidth ), GUILayout.MaxWidth( nameMaxWidth ) );
else
editName = EditorGUILayout.TextField( editName, GUILayout.MinWidth( nameMinWidth ), GUILayout.MaxWidth( nameMaxWidth ) );
if ( GUI.GetNameOfFocusedControl() == instId )
{
if ( editObject != obj )
{
editName = obj.name;
editObject = obj;
}
}
if ( Event.current.type == EventType.KeyUp && Event.current.keyCode == KeyCode.Return && editObject == obj )
{
obj.name = editName;
editName = "";
editObject = null;
Repaint();
}
GUILayout.Space( 3 );
EditorGUIUtility.labelWidth = 5;
volume.EnterBlendTime = EditorGUILayout.FloatField( " ", volume.EnterBlendTime, GUILayout.MinWidth( blendMinWidth ), GUILayout.MaxWidth( blendMaxWidth ) );
GUILayout.Space( 3 );
volume.Exposure = EditorGUILayout.FloatField( " ", volume.Exposure, GUILayout.MinWidth( exposureMinWidth ), GUILayout.MaxWidth( exposureMaxWidth ) );
GUILayout.Space( 3 );
volume.Priority = EditorGUILayout.IntField( " ", volume.Priority, GUILayout.MinWidth( priorityMinWidth ), GUILayout.MaxWidth( priorityMaxWidth ) );
GUILayout.EndHorizontal();
}
void DrawVolumeEffects( AmplifyColorVolumeBase volume )
{
GUIStyle layerTitleStyle = new GUIStyle( EditorStyles.miniBoldLabel );
layerTitleStyle.alignment = TextAnchor.MiddleLeft;
layerTitleStyle.margin = new RectOffset( 0, 0, 0, 0 );
GUIStyle foldoutTitleStyle = new GUIStyle( EditorStyles.foldout );
foldoutTitleStyle.fontSize = 10;
GUILayout.BeginHorizontal();
GUILayout.Space( 10 );
GUILayout.Label( "", GUILayout.MinWidth( iconMinWidth ), GUILayout.MaxWidth( iconMaxWidth - 10 ) );
GUILayout.Space( 2 );
GUILayout.BeginVertical();
GUILayout.Space( 0 );
GUILayout.BeginHorizontal();
bool foldout = SetFoldout( volume, EditorGUILayout.Foldout( GetFoldout( volume ), "Blend Effects", foldoutTitleStyle ) );
GUILayout.EndHorizontal();
GUILayout.Space( 3 );
if ( foldout )
DrawVolumeEffectFields( volume );
GUILayout.EndVertical();
GUILayout.Space( 0 );
GUILayout.EndHorizontal();
}
Vector4 DrawFixedVector4Field( Vector4 vec )
{
Vector3 xyz = new Vector3( vec.x, vec.y, vec.z );
xyz = EditorGUILayout.Vector3Field( "", xyz, GUILayout.MinWidth( minValueWidth / 4 * 3 - 4 ), GUILayout.MaxWidth( maxValueWidth / 4 * 3 - 4 ), GUILayout.MaxHeight( 16 ) );
EditorGUIUtility.labelWidth = 16;
float w = EditorGUILayout.FloatField( "W", vec.w, GUILayout.MinWidth( minValueWidth / 4 ), GUILayout.MaxWidth( maxValueWidth / 4 ), GUILayout.MaxHeight( 16 ) );
return new Vector4( xyz.x, xyz.y, xyz.z, w );
}
void DrawVolumeEffectFields( AmplifyColorVolumeBase volume )
{
List<AmplifyColor.VolumeEffect> effectsToDelete = new List<AmplifyColor.VolumeEffect>();
float removeButtonSize = 16;
List<NewLineContainer> volumeLines = null;
if ( !( newLines.TryGetValue( volume, out volumeLines ) ) )
volumeLines = newLines[ volume ] = new List<NewLineContainer>();
GUIStyle minusStyle = new GUIStyle( ( GUIStyle ) "OL Minus" );
GUIStyle plusStyle = new GUIStyle( ( GUIStyle ) "OL Plus" );
minusStyle.margin.top = 2;
plusStyle.margin.top = 2;
#region CurrentEffectFields
int fieldPosition = 0;
foreach ( AmplifyColor.VolumeEffect effectVol in volume.EffectContainer.volumes )
{
if ( effectVol.gameObject == null )
continue;
AmplifyColorBase effect = effectVol.gameObject;
List<AmplifyColor.VolumeEffectComponent> compsToDelete = new List<AmplifyColor.VolumeEffectComponent>();
foreach ( AmplifyColor.VolumeEffectComponent comp in effectVol.components )
{
Component c = effect.GetComponent( comp.componentName );
if ( c == null )
continue;
List<AmplifyColor.VolumeEffectField> fieldsToDelete = new List<AmplifyColor.VolumeEffectField>();
List<KeyValuePair<string,int>> fieldsToAdd = new List<KeyValuePair<string,int>>();
foreach ( AmplifyColor.VolumeEffectField field in comp.fields )
{
EditorGUILayout.BeginHorizontal();
GUILayout.Label( "", GUILayout.MinWidth( minIndentWidth ), GUILayout.MaxWidth( maxIndentWidth ) );
GUILayout.Space( 0 );
if ( GUILayout.Button( "", minusStyle, GUILayout.MinWidth( 18 ), GUILayout.MaxWidth( 18 ), GUILayout.Height( 20 ) ) )
fieldsToDelete.Add( field );
Camera selectedCamera = EditorGUILayout.ObjectField( effect.GetComponent<Camera>(), typeof( Camera ), true, GUILayout.MinWidth( minColumnWidth * 1.5f ), GUILayout.MaxWidth( maxColumnWidth * 1.5f ) ) as Camera;
AmplifyColorBase selectedEffect = ( selectedCamera != null ) ? selectedCamera.GetComponent<AmplifyColorBase>() : null;
if ( selectedEffect != effect )
{
fieldsToDelete.Add( field );
dirtyVolumeFlags = true;
volumeLines.Add( new NewLineContainer( selectedEffect ) );
}
Component[] compArray = AmplifyColor.VolumeEffect.ListAcceptableComponents( effectVol.gameObject );
List<string> compFlagsArray = compArray.Select( s => s.GetType().Name ).ToList();
compFlagsArray.Remove( comp.componentName );
string[] compNamesArray = new string[] { comp.componentName }.Concat( compFlagsArray ).ToArray();
int selectedComponent = 0;
selectedComponent = EditorGUILayout.Popup( selectedComponent, compNamesArray, GUILayout.MinWidth( minColumnWidth ), GUILayout.MaxWidth( maxColumnWidth ) );
if ( selectedComponent != 0 )
{
volumeLines.Add( new NewLineContainer( effect, compNamesArray[ selectedComponent ] ) );
fieldsToDelete.Add( field );
dirtyVolumeFlags = true;
}
FieldInfo[] fieldArray = AmplifyColor.VolumeEffectComponent.ListAcceptableFields( c );
string[] fieldFlagsArray = fieldArray.Select( s => s.Name ).ToArray();
string[] fieldNamesArray = comp.GetFieldNames();
fieldFlagsArray = fieldFlagsArray.Except( fieldNamesArray ).ToArray();
List<string> names = new List<string>();
names.Add( field.fieldName );
names.AddRange( fieldFlagsArray );
for ( int i = 0; i < names.Count; i++ )
{
if ( i == 0 )
continue;
FieldInfo fi = Array.Find( fieldArray, s => ( names[ i ] == s.Name ) );
if ( fi != null )
names[ i ] += " : " + fi.FieldType.Name;
}
int selectedField = 0;
selectedField = EditorGUILayout.Popup( selectedField, names.ToArray(), GUILayout.MinWidth( minColumnWidth ), GUILayout.MaxWidth( maxColumnWidth ) );
if ( selectedField != 0 )
{
fieldsToAdd.Add( new KeyValuePair<string,int>( fieldFlagsArray[ selectedField - 1 ], fieldPosition ) );
fieldsToDelete.Add( field );
dirtyVolumeFlags = true;
}
fieldPosition++;
switch ( field.fieldType )
{
case "System.Single": field.valueSingle = EditorGUILayout.FloatField( field.valueSingle, GUILayout.MinWidth( minValueWidth ), GUILayout.MaxWidth( maxValueWidth ) ); break;
case "System.Boolean": field.valueBoolean = EditorGUILayout.Toggle( "", field.valueBoolean, GUILayout.MinWidth( minValueWidth ), GUILayout.MaxWidth( maxValueWidth ) ); break;
case "UnityEngine.Vector2": field.valueVector2 = EditorGUILayout.Vector2Field( "", field.valueVector2, GUILayout.MinWidth( minValueWidth ), GUILayout.MaxWidth( maxValueWidth ), GUILayout.MaxHeight( 16 ) ); break;
case "UnityEngine.Vector3": field.valueVector3 = EditorGUILayout.Vector3Field( "", field.valueVector3, GUILayout.MinWidth( minValueWidth ), GUILayout.MaxWidth( maxValueWidth ), GUILayout.MaxHeight( 16 ) ); break;
case "UnityEngine.Vector4": field.valueVector4 = DrawFixedVector4Field( field.valueVector4 ); break;
case "UnityEngine.Color": field.valueColor = EditorGUILayout.ColorField( field.valueColor, GUILayout.MinWidth( minValueWidth ), GUILayout.MaxWidth( maxValueWidth ) ); break;
default: EditorGUILayout.LabelField( field.fieldType, GUILayout.MinWidth( minValueWidth ), GUILayout.MaxWidth( maxValueWidth ) ); break;
}
// COPY TO CLIPBOARD
string luid = NewLineContainer.GenerateUniqueID( effect, comp.componentName, field.fieldName );
bool copied = copyLines.ContainsKey( luid );
bool keep = GUILayout.Toggle( copied, "c", removeButtonStyle, GUILayout.Width( removeButtonSize ), GUILayout.Height( removeButtonSize ) );
if ( keep != copied )
{
if ( keep )
{
object valueCopy = null;
switch ( field.fieldType )
{
case "System.Single": valueCopy = field.valueSingle; break;
case "System.Boolean": valueCopy = field.valueBoolean; break;
case "UnityEngine.Vector2": valueCopy = field.valueVector2; break;
case "UnityEngine.Vector3": valueCopy = field.valueVector3; break;
case "UnityEngine.Vector4": valueCopy = field.valueVector4; break;
case "UnityEngine.Color": valueCopy = field.valueColor; break;
}
copyLines.Add( luid, new NewLineContainer( effect, comp.componentName, field.fieldName, field.fieldType, valueCopy ) );
}
else
copyLines.Remove( luid );
//Debug.Log( "CopyComplete: " + luid + ", " + keep + ", " + volume.name );
}
EditorGUILayout.EndHorizontal();
GUILayout.Space( 2 );
}
bool fieldRemoved = false;
foreach ( AmplifyColor.VolumeEffectField field in fieldsToDelete )
{
comp.RemoveEffectField( field );
fieldRemoved = true;
}
foreach ( KeyValuePair<string,int> pair in fieldsToAdd )
{
FieldInfo pi = c.GetType().GetField( pair.Key);
if ( pi != null )
comp.AddField( pi, c, pair.Value );
}
if ( fieldRemoved && comp.fields.Count <= 0 )
compsToDelete.Add( comp );
}
bool compRemoved = false;
foreach ( AmplifyColor.VolumeEffectComponent comp in compsToDelete )
{
effectVol.RemoveEffectComponent( comp );
compRemoved = true;
}
if ( compRemoved && effectVol.components.Count <= 0 )
effectsToDelete.Add( effectVol );
}
foreach ( AmplifyColor.VolumeEffect effectVol in effectsToDelete )
volume.EffectContainer.RemoveVolumeEffect( effectVol );
#endregion CurrentEffectFields
#region NewLines
List<NewLineContainer> linesToDelete = new List<NewLineContainer>();
foreach ( NewLineContainer line in volumeLines )
{
EditorGUILayout.BeginHorizontal();
GUILayout.Label( "", GUILayout.MinWidth( minIndentWidth ), GUILayout.MaxWidth( maxIndentWidth ) );
GUILayout.Space( 0 );
if ( GUILayout.Button( "", minusStyle, GUILayout.MinWidth( 18 ), GUILayout.MaxWidth( 18 ), GUILayout.Height( 20 ) ) )
linesToDelete.Add( line );
Camera selectedCamera = EditorGUILayout.ObjectField( line.camera, typeof( Camera ), true, GUILayout.MinWidth( minColumnWidth * 1.5f ), GUILayout.MaxWidth( maxColumnWidth * 1.5f ) ) as Camera;
AmplifyColorBase selectedEffect = ( selectedCamera != null ) ? selectedCamera.GetComponent<AmplifyColorBase>() : null;
if ( selectedEffect != null && selectedEffect != line.camera )
line.SetCamera( selectedEffect );
AmplifyColor.VolumeEffect effectVol = null;
if ( line.camera != null )
effectVol = volume.EffectContainer.FindVolumeEffect( line.camera );
if ( line.camera != null )
{
Component[] compArray = AmplifyColor.VolumeEffect.ListAcceptableComponents( line.camera );
List<string> names = compArray.Select( s => s.GetType().Name ).ToList<string>();
int popupSelected = names.IndexOf( line.component ) + 1;
names.Insert( 0, "<Component>" );
int selectedComponent = popupSelected;
selectedComponent = EditorGUILayout.Popup( selectedComponent, names.ToArray(), GUILayout.MinWidth( minColumnWidth ), GUILayout.MaxWidth( maxColumnWidth ) );
if ( selectedComponent != popupSelected )
line.SetComponent( selectedComponent == 0 ? null : names[ selectedComponent ] );
}
else
{
GUI.enabled = false;
EditorGUILayout.Popup( 0, new string[] { "<Component>" }, GUILayout.MaxWidth( maxColumnWidth ) );
GUI.enabled = true;
}
Component c = ( line.camera == null ) ? null : line.camera.GetComponent( line.component );
AmplifyColor.VolumeEffectComponent comp = null;
if ( effectVol != null )
comp = effectVol.FindEffectComponent( line.component );
if ( c != null )
{
FieldInfo[] fieldArray = AmplifyColor.VolumeEffectComponent.ListAcceptableFields( c );
string[] fieldFlagsArray = fieldArray.Select( s => s.Name ).ToArray();
if ( comp != null )
{
string[] fieldNamesArray = comp.GetFieldNames();
fieldFlagsArray = fieldFlagsArray.Except( fieldNamesArray ).ToArray();
}
List<string> names = fieldFlagsArray.ToList();
for ( int i = 0; i < names.Count; i++ )
{
FieldInfo fi = Array.Find( fieldArray, s => ( names[ i ] == s.Name ) );
if ( fi != null )
names[ i ] += " : " + fi.FieldType.Name;
}
names.Insert( 0, "<Field>" );
int selectedField = 0;
selectedField = EditorGUILayout.Popup( selectedField, names.ToArray(), GUILayout.MinWidth( minColumnWidth ), GUILayout.MaxWidth( maxColumnWidth ) );
if ( selectedField > 0 )
{
FieldInfo pi = c.GetType().GetField( fieldFlagsArray[ selectedField - 1 ] );
if ( pi != null )
{
if ( effectVol == null )
effectVol = volume.EffectContainer.AddJustColorEffect( line.camera );
if ( comp == null )
comp = effectVol.AddComponent( c, null );
comp.AddField( pi, c );
linesToDelete.Add( line );
dirtyVolumeFlags = true;
}
}
EditorGUILayout.LabelField( "", GUILayout.MinWidth( minValueWidth ), GUILayout.MaxWidth( maxValueWidth ) );
}
else
{
GUI.enabled = false;
EditorGUILayout.Popup( 0, new string[] { "<Field>" }, GUILayout.MaxWidth( maxColumnWidth ) );
EditorGUILayout.TextField( "", GUILayout.MinWidth( minValueWidth ), GUILayout.MaxWidth( maxValueWidth ) );
GUI.enabled = true;
}
if ( line.camera != null )
{
string luid = NewLineContainer.GenerateUniqueID( line.camera, line.component, line.fieldName );
bool copied = copyLines.ContainsKey( luid );
bool keep = GUILayout.Toggle( copied, "c", removeButtonStyle, GUILayout.Width( removeButtonSize ), GUILayout.Height( removeButtonSize ) );
if ( keep != copied )
{
if ( keep )
copyLines.Add( luid, new NewLineContainer( line.camera, line.component, line.fieldName, line.fieldType, line.value ) );
else
copyLines.Remove( luid );
//Debug.Log( "CopyIncomplete: " + luid + ", " + keep + ", " + volume.name );
}
}
else
{
GUI.enabled = false;
GUILayout.Button( "c", removeButtonStyle, GUILayout.Width( removeButtonSize ), GUILayout.Height( removeButtonSize ) );
GUI.enabled = true;
}
EditorGUILayout.EndHorizontal();
GUILayout.Space( 2 );
}
foreach ( NewLineContainer line in linesToDelete )
{
copyLines.Remove( line.GenerateUniqueID() );
//Debug.Log( "Removed " + line.GenerateUniqueID() );
volumeLines.Remove( line );
}
#endregion NewLines
#region AddPaste
EditorGUILayout.BeginHorizontal();
GUILayout.Label( "", GUILayout.MinWidth( minIndentWidth ), GUILayout.MaxWidth( maxIndentWidth ) );
GUILayout.Space( 0 );
bool add = GUILayout.Button( "", plusStyle, GUILayout.MinWidth( 18 ), GUILayout.MaxWidth( 18 ), GUILayout.Height( 20 ) );
if ( add || GUILayout.Button( "Add New", GUILayout.MinWidth( minColumnWidth ), GUILayout.MaxWidth( maxColumnWidth ), GUILayout.Height( 20 ) ) )
volumeLines.Add( new NewLineContainer() );
GUI.enabled = ( copyLines.Count > 0 );
if ( GUILayout.Button( "Paste", GUILayout.MinWidth( minColumnWidth ), GUILayout.MaxWidth( maxColumnWidth ), GUILayout.Height( 20 ) ) )
{
foreach ( var pair in copyLines )
{
NewLineContainer line = pair.Value;
Component c = ( line.camera == null ) ? null : line.camera.GetComponent( line.component );
FieldInfo pi = ( c != null ) ? c.GetType().GetField( line.fieldName ) : null;
if ( pi == null )
volumeLines.Add( new NewLineContainer( line.camera, line.component, line.fieldName, line.fieldType, line.value ) );
else
{
AmplifyColor.VolumeEffect effectVol = volume.EffectContainer.FindVolumeEffect( line.camera );
if ( effectVol == null )
effectVol = volume.EffectContainer.AddJustColorEffect( line.camera );
AmplifyColor.VolumeEffectComponent comp = effectVol.FindEffectComponent( line.component );
if ( comp == null )
comp = effectVol.AddComponent( c, null );
AmplifyColor.VolumeEffectField field = comp.FindEffectField( line.fieldName );
if ( field == null )
field = comp.AddField( pi, c );
else
Debug.LogWarning( "[AmplifyColor] Blend Effect field already added to Volume " + volume.name + "." );
field.UpdateValue( line.value );
}
}
dirtyVolumeFlags = true;
}
GUI.enabled = true;
EditorGUILayout.EndHorizontal();
GUILayout.Space( 5 );
#endregion AddPaste
}
void DrawLut( AmplifyColorVolumeBase volume )
{
GUILayout.Space( 0 );
volume.LutTexture = ( Texture2D ) EditorGUILayout.ObjectField( volume.LutTexture, typeof( Texture2D ), false, GUILayout.Width( lutWidth ), GUILayout.Height( lutWidth ) );
GUILayout.FlexibleSpace();
GUILayout.Space( 5 );
}
void DrawLineSeparator()
{
GUILayout.BeginHorizontal();
GUILayout.Space( 10 );
GUILayout.Label( "", GUILayout.MinWidth( iconMinWidth ), GUILayout.MaxWidth( iconMaxWidth - 10 ) );
GUILayout.Space( 4 );
GUILayout.BeginVertical();
GUILayout.Box( "", GUILayout.MaxWidth( 538 ), GUILayout.Height( 1 ) );
GUILayout.EndVertical();
GUILayout.Space( 5 );
GUILayout.EndHorizontal();
}
private double searchDelayDuration = 0.25f;
private DateTime searchDelayStart = DateTime.Now;
private AmplifyColorVolumeBase[] volumeList;
private void DrawVolumeList()
{
double searchDelayElapsed = ( DateTime.Now - searchDelayStart ).TotalSeconds;
if ( volumeList == null || searchDelayElapsed > searchDelayDuration )
{
volumeList = Resources.FindObjectsOfTypeAll( typeof( AmplifyColorVolumeBase ) ) as AmplifyColorVolumeBase[];
searchDelayStart = DateTime.Now;
}
volumeList = volumeList.Where( c => c != null ).ToArray();
List<AmplifyColorVolumeBase> filtered = volumeList.OrderBy( o => o.name ).ToList<AmplifyColorVolumeBase>();
GUILayout.BeginVertical();
GUILayout.Space( 15 );
DrawHeader( filtered );
GUILayout.Space( 15 );
dirtyVolumeFlags = false;
foreach ( AmplifyColorVolumeBase volume in filtered )
{
GUILayout.BeginHorizontal();
GUILayout.BeginVertical();
DrawVolumeProperties( volume );
EditorGUILayout.Separator();
DrawVolumeEffects( volume );
GUILayout.Space( 3 );
GUILayout.EndVertical();
DrawLut( volume );
GUILayout.EndHorizontal();
DrawLineSeparator();
}
if ( dirtyVolumeFlags )
{
GUI.FocusControl( "" );
AmplifyColorBase[] effects = Resources.FindObjectsOfTypeAll( typeof( AmplifyColorBase ) ) as AmplifyColorBase[];
AmplifyColorVolumeBase[] volumes = Resources.FindObjectsOfTypeAll( typeof( AmplifyColorVolumeBase ) ) as AmplifyColorVolumeBase[];
AmplifyColor.VolumeEffectFlags.UpdateCamFlags( effects, volumes );
}
GUILayout.EndVertical();
if ( GUI.changed )
SceneView.RepaintAll();
}
[MenuItem( "GameObject/Amplify Color/Amplify Color Volume", false, 10 )]
static void CreateColorVolume()
{
GameObject go = new GameObject( "Amplify Color Volume" );
go.AddComponent<BoxCollider>().isTrigger = true;
go.AddComponent( Type.GetType( "AmplifyColorVolume, Assembly-CSharp" ) );
Selection.activeObject = go;
}
[MenuItem( "GameObject/Amplify Color/Amplify Color Volume 2D", false, 10 )]
static void CreateColorVolume2D()
{
GameObject go = new GameObject( "Amplify Color Volume 2D" );
go.AddComponent<BoxCollider2D>().isTrigger = true;
go.AddComponent( Type.GetType( "AmplifyColorVolume2D, Assembly-CSharp" ) );
Selection.activeObject = go;
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 921a3d09a02ba504f9caa4004e6f4582
timeCreated: 1443525278
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,116 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEngine;
namespace AmplifyColor
{
public class BackBufferHandler
{
private readonly CameraCollection _cameras;
public BackBufferHandler( CameraCollection cameras )
{
_cameras = cameras;
}
public bool ReadBackBuffer( out ImageResult imageResult )
{
imageResult = null;
if ( _cameras == null )
{
Debug.LogError( "[AmplifyColor] Camera collection is invalid." );
return false;
}
var camera = _cameras.SelectedCamera;
if ( camera == null )
{
Debug.LogError( "[AmplifyColor] Selected camera is invalid." );
return false;
}
AmplifyColorBase component = camera.GetComponent<AmplifyColorBase>();
Tonemapping prevTonemapper = Tonemapping.Disabled;
float prevExposure = 1.0f;
float prevLinearWhitePoint = 11.2f;
bool prevApplyDithering = false;
float prevBlendAmount = 0.0f;
Texture prevLUT = null;
if ( component != null )
{
prevTonemapper = component.Tonemapper;
prevExposure = component.Exposure;
prevLinearWhitePoint = component.LinearWhitePoint;
prevApplyDithering = component.ApplyDithering;
prevBlendAmount = component.BlendAmount;
prevLUT = component.LutTexture;
component.Tonemapper = ToolSettings.Instance.ApplyHDRControl ? component.Tonemapper : Tonemapping.Disabled;
component.Exposure = ToolSettings.Instance.ApplyHDRControl ? component.Exposure : 1.0f;
component.LinearWhitePoint = ToolSettings.Instance.ApplyHDRControl ? component.LinearWhitePoint : 11.2f;
component.ApplyDithering = ToolSettings.Instance.ApplyHDRControl ? component.ApplyDithering : false;
component.BlendAmount = ToolSettings.Instance.ApplyColorGrading ? component.BlendAmount : 0.0f;
component.LutTexture = ToolSettings.Instance.ApplyColorGrading ? component.LutTexture : null;
}
var width = ToolSettings.Instance.Resolution.TargetWidth;
var height = ToolSettings.Instance.Resolution.TargetHeight;
//if (ToolSettings.Instance.Resolution.IsGameWindowSize)
//{
// width = Screen.width;
// height = Screen.height;
//}
var cameratarget = camera.targetTexture;
var rt = RenderTexture.GetTemporary( width, height, 24, RenderTextureFormat.ARGB32 );
camera.targetTexture = rt;
camera.Render();
camera.targetTexture = cameratarget;
var activert = RenderTexture.active;
RenderTexture.active = rt;
var text = new Texture2D( width, height, TextureFormat.ARGB32, false );
text.ReadPixels( new Rect( 0, 0, width, height ), 0, 0 );
text.Apply();
RenderTexture.active = activert;
var colors = text.GetPixels( 0, 0, width, height );
Texture2D.DestroyImmediate( text );
var colordata = new Color[ width, height ];
for ( int i = height - 1; i >= 0; i-- )
{
for ( int j = 0; j < width; j++ )
{
colordata[ j, ( height - 1 - i ) ] = colors[ i * width + j ];
colordata[ j, ( height - 1 - i ) ].a = 1;
}
}
if ( component != null )
{
component.Tonemapper = prevTonemapper;
component.Exposure = prevExposure;
component.LinearWhitePoint = prevLinearWhitePoint;
component.ApplyDithering = prevApplyDithering;
component.BlendAmount = prevBlendAmount;
component.LutTexture = prevLUT;
}
imageResult = new ImageResult( colordata );
return true;
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a17467deec097824e81d75a962e828cf
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -0,0 +1,146 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using System.Collections.Generic;
using UnityEngine;
namespace AmplifyColor
{
public class CameraCollection
{
private string[] _cameraNames;
private Camera _selectedCamera;
private int _selectedIndex = -1;
private string _selectedCameraName;
private List<Camera> _camerasList;
private List<string> _namesList;
public string SelectedCameraName
{
get { return _selectedCameraName; }
}
public string[] CameraNames
{
get
{
return _cameraNames;
}
}
public int SelectedIndex
{
get { return _selectedIndex; }
set
{
_selectedIndex = value;
SetupCamera();
}
}
public Camera SelectedCamera
{
get { return _selectedCamera; }
}
private void SetupCamera()
{
try
{
_selectedCameraName = _camerasList[ _selectedIndex ].name;
}
catch ( Exception )
{
_selectedIndex = 0;
_selectedCameraName = "";
return;
}
}
public void GenerateCameraList()
{
var cameras = Camera.allCameras;
if ( cameras == null || cameras.Length == 0 )
{
_selectedCameraName = "No cameras were found in the scene";
_selectedCamera = null;
_selectedIndex = 0;
_camerasList = new List<Camera>();
_cameraNames = new[] { _selectedCameraName };
_namesList = new List<string>( _cameraNames );
return;
}
_camerasList = new List<Camera>();
for ( int i = 0; i < cameras.Length; i++ )
{
//bool hidden = (cameras[i].hideFlags & HideFlags.HideAndDontSave) != 0 ||
// (cameras[i].hideFlags & HideFlags.HideInHierarchy) != 0 ||
// (cameras[i].hideFlags & HideFlags.HideInInspector) != 0;
//if (!hidden)
_camerasList.Add( cameras[ i ] );
}
_namesList = new List<string>();
foreach ( var camera in _camerasList )
{
_namesList.Add( camera.name );
}
int index = _namesList.IndexOf( _selectedCameraName ?? "" );
if ( index >= 0 )
{
_selectedIndex = index;
}
else
{
if ( Camera.main == null )
index = 0;
else
index = _namesList.IndexOf( Camera.main.name );
_selectedIndex = index >= 0 ? index : 0;
}
_cameraNames = _namesList.ToArray();
_selectedCamera = _camerasList[ _selectedIndex ];
_selectedCameraName = _selectedCamera.name;
}
public Texture2D GetCurrentEffectTexture()
{
var camera = SelectedCamera;
if ( camera == null )
{
return null;
}
var component = ( MonoBehaviour ) camera.GetComponent<AmplifyColorBase>();
if ( component != null )
{
Texture2D texture = null;
try
{
var propInfo = component.GetType().GetField( "LutTexture" );
texture = ( Texture2D ) propInfo.GetValue( component );
}
catch ( System.Exception )
{
}
return texture;
}
return null;
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 45784efbbdcc7064681835eac45c4ea1
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -0,0 +1,57 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using System.Security.Cryptography;
using System.Text;
namespace AmplifyColor
{
public class EncryptDecrypt
{
private readonly ICryptoTransform _eCipher;
private readonly ICryptoTransform _dCipher;
// these must match the values used in Photoshop DO NOT CHANGE
// get the password from the dialog settings in Photoshop
private readonly char[] _salt = { 'A', 'd', 'o', 'b', 'e', ' ', 'P', 'h', 'o', 't', 'o', 's', 'h', 'o', 'p' };
private const int IterationCount = 1000;
private const int KeyLength = 24;
public EncryptDecrypt( String passPhrase )
{
var encoder = new ASCIIEncoding();
//byte[] bytepass = encoder.GetBytes(passPhrase);
byte[] bytesalt = encoder.GetBytes( _salt );
var tripleDes = new TripleDESCryptoServiceProvider
{
Mode = CipherMode.CBC,
Padding = PaddingMode.PKCS7,
};
var rfc2898DeriveBytes = new Rfc2898DeriveBytes( passPhrase, bytesalt, IterationCount );
var key = rfc2898DeriveBytes.GetBytes( KeyLength );
var empty = new byte[ 8 ];
_eCipher = tripleDes.CreateEncryptor( key, empty );
_dCipher = tripleDes.CreateDecryptor( key, empty );
}
public byte[] encrypt( byte[] data )
{
byte[] encryptedBytes = _eCipher.TransformFinalBlock( data, 0, data.Length );
return encryptedBytes;
}
public byte[] decrypt( byte[] data )
{
byte[] decryptedBytes = _dCipher.TransformFinalBlock( data, 0, data.Length );
return decryptedBytes;
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f7b3a08005fb4a046836ee6a570501b4
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -0,0 +1,149 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System.IO;
using UnityEngine;
using UnityEditor;
namespace AmplifyColor
{
public class FileHandler
{
private readonly BackBufferHandler _backBufferHandler;
private readonly LUTWriter _lutWriter;
private readonly ToolSettings _settings;
private readonly CameraCollection _cameraCollection;
public FileHandler( BackBufferHandler backBufferHandler, LUTWriter lutWriter, ToolSettings settings, CameraCollection cameraCollection )
{
_backBufferHandler = backBufferHandler;
_lutWriter = lutWriter;
_settings = settings;
_cameraCollection = cameraCollection;
}
public void SaveToFile()
{
ImageResult imageResult;
if ( _backBufferHandler.ReadBackBuffer( out imageResult ) )
{
var path = EditorUtility.SaveFilePanel( "Save reference file", _settings.FilePath ?? "", "reference", "png" );
if ( !string.IsNullOrEmpty( path ) )
{
_settings.FilePath = path;
if ( _settings.AddLut )
{
Texture2D luttexture = _cameraCollection.GetCurrentEffectTexture();
if ( _settings.ApplyColorGrading && luttexture != null )
{
if ( !imageResult.AddLUTFromTexture( _settings.LUT, luttexture ) )
{
_settings.Message = "Couldnt add the LUT to the image. Try changing the lut size or settings";
return;
}
}
else
{
if ( !imageResult.AddLUT( _settings.LUT ) )
{
_settings.Message = "Couldnt add the LUT to the image. Try changing the lut size or settings";
return;
}
}
}
var texture = imageResult.GenerateTexture2D();
if ( texture != null )
{
File.WriteAllBytes( _settings.FilePath, texture.EncodeToPNG() );
};
Texture2D.DestroyImmediate( texture );
}
}
else
{
_settings.Message = "No camera selected";
}
}
public void ReadFromFile()
{
var path = EditorUtility.OpenFilePanel( "Load graded file", _settings.FilePath ?? "", "png" );
if ( !string.IsNullOrEmpty( path ) )
{
_settings.FilePath = path;
if ( File.Exists( _settings.FilePath ) )
{
var data = File.ReadAllBytes( _settings.FilePath );
var screenshottexture = new Texture2D( 16, 16, TextureFormat.ARGB32, false );
screenshottexture.LoadImage( data );
var imageResult = ImageResult.FromTexture( screenshottexture );
if ( imageResult != null )
{
LUTResult lutResult = imageResult.GetLUT( _settings.LUT );
if ( lutResult != null )
{
_lutWriter.SaveLUT( lutResult );
}
lutResult.Release();
}
Texture2D.DestroyImmediate( screenshottexture );
}
}
}
public void Reload()
{
if ( string.IsNullOrEmpty( _settings.FilePath ) )
{
ReadFromFile();
return;
}
if ( File.Exists( _settings.FilePath ) )
{
var data = File.ReadAllBytes( _settings.FilePath );
var screenshottexture = new Texture2D( 16, 16, TextureFormat.ARGB32, false );
screenshottexture.LoadImage( data );
var imageResult = ImageResult.FromTexture( screenshottexture );
if ( imageResult != null )
{
LUTResult lutResult = imageResult.GetLUT( _settings.LUT );
if ( lutResult != null )
{
_lutWriter.SaveLUT( lutResult );
}
lutResult.Release();
}
Texture2D.DestroyImmediate( screenshottexture );
}
else
{
if ( EditorUtility.DisplayDialog( "File doesnt exist", "Target file doesn't exit. Please select a new one.", "ok", "cancel" ) )
{
ReadFromFile();
return;
}
}
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ad3b4a7acbb8cd54aa0a0eb6739e92f3
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -0,0 +1,290 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using System.Linq;
using UnityEngine;
namespace AmplifyColor
{
public class ImageResult
{
public ImageResult( Color[ , ] colorData )
{
ColorData = colorData;
Width = colorData.GetLength( 0 );
Height = colorData.GetLength( 1 );
}
public Color[ , ] ColorData { get; private set; }
public int Width { get; private set; }
public int Height { get; private set; }
public Texture2D GenerateTexture2D()
{
var data = new Color[ Width * Height ];
for ( int h = Height - 1, i = 0; h >= 0; h-- )
{
for ( int w = 0; w < Width; w++ )
{
data[ i++ ] = ColorData[ w, h ];
}
}
var texture = new Texture2D( Width, Height );
texture.SetPixels( data );
return texture;
}
public Color[] GenerateColorArray()
{
var data = new Color[ Width * Height ];
for ( int h = 0, i = 0; h < Height; h++ )
{
for ( int w = 0; w < Width; w++ )
{
data[ i++ ] = ColorData[ w, h ];
}
}
return data;
}
public byte[] GenerateRGBData()
{
var data = new byte[ Width * Height * 3 ];
for ( int h = 0, i = 0; h < Height; h++ )
{
for ( int w = 0; w < Width; w++ )
{
var color = ColorData[ w, h ];
data[ i++ ] = ( byte ) ( color.r * 255 );
data[ i++ ] = ( byte ) ( color.g * 255 );
data[ i++ ] = ( byte ) ( color.b * 255 );
}
}
return data;
}
public bool AddLUT( LUTSettings settings )
{
int size = settings.Size;
int columns = settings.Columns;
int rows = settings.Rows;
if ( Width < columns * size )
{
return false;
}
if ( Height < rows * size )
{
return false;
}
var data = ColorData;
for ( int r = 0; r < rows; r++ )
{
for ( int c = 0; c < columns; c++ )
{
for ( int h = 0; h < size; h++ )
{
for ( int w = 0; w < size; w++ )
{
int row = r * size + h;
int col = c * size + w;
float rf = ( float ) w / ( size - 1 );
float gf = ( float ) h / ( size - 1 );
float bf = ( float ) ( c + r * columns ) / ( size - 1 );
data[ col, row ] = new Color( rf, gf, bf );
}
}
}
}
return true;
}
public static ImageResult FromPhotoshopResult( byte[] decryptedBytes )
{
int imageWidth = GetBigEndianInt( decryptedBytes, 1 );
int imageHeight = GetBigEndianInt( decryptedBytes, 5 );
var bytesize = imageWidth * imageHeight * 3;
const int headerLength = 16;
if ( bytesize + headerLength > decryptedBytes.Length )
{
return null;
}
var imageData = new Color[ imageWidth, imageHeight ];
for ( int i = 0, k = headerLength; i < imageHeight; i++ )
{
for ( int j = 0; j < imageWidth; j++ )
{
imageData[ j, i ] = new Color( decryptedBytes[ k++ ] / 255f, decryptedBytes[ k++ ] / 255f, decryptedBytes[ k++ ] / 255f, 1f );
}
}
return new ImageResult( imageData );
}
private static readonly byte[] Temp = new byte[ 4 ];
private static int GetBigEndianInt( byte[] bytes, int offset )
{
if ( bytes.Length <= offset + 4 )
{
return -1;
}
for ( int j = 0, i = 3; j < 4; j++, i-- )
{
Temp[ j ] = bytes[ offset + i ];
}
return BitConverter.ToInt32( Temp, 0 );
}
public static ImageResult FromTexture( Texture2D texture )
{
if ( texture == null )
{
return null;
}
var width = texture.width;
var height = texture.height;
if ( width == 0 || height == 0 )
{
return null;
}
var data = texture.GetPixels();
var colorData = new Color[ width, height ];
for ( int h = 0; h < height; h++ )
{
for ( int w = 0; w < width; w++ )
{
int index = w + ( height - h - 1 ) * width;
colorData[ w, h ] = data[ index ];
}
}
return new ImageResult( colorData );
}
public LUTResult GetLUT( LUTSettings lutSettings )
{
int size = lutSettings.Size;
int columns = lutSettings.Columns;
int rows = lutSettings.Rows;
if ( Width < columns * size )
{
return null;
}
if ( Height < rows * size )
{
return null;
}
Color[ , , ] data = new Color[ size, size, size ];
var colorData = ColorData;
for ( int r = 0; r < rows; r++ )
{
for ( int c = 0; c < columns; c++ )
{
for ( int h = 0; h < size; h++ )
{
for ( int w = 0; w < size; w++ )
{
int row = r * size + h;
int col = c * size + w;
int stack = ( c + r * columns );
data[ w, h, stack ] = colorData[ col, row ];
}
}
}
}
return new LUTResult( data );
}
public bool AddLUTFromTexture( LUTSettings lutSettings, Texture2D lutTexture )
{
if ( lutSettings == null || lutTexture == null )
{
return false;
}
var size = lutTexture.height;
if ( size != lutSettings.Size )
{
return false;
}
var irt = FromTexture( lutTexture );
var lut = irt.GetLUT( new LUTSettings( size, 1 ) );
if ( lut == null )
{
return false;
}
int columns = lutSettings.Columns;
int rows = lutSettings.Rows;
if ( Width < columns * size )
{
return false;
}
if ( Height < rows * size )
{
return false;
}
var lutdata = lut.Data;
var data = ColorData;
for ( int r = 0; r < rows; r++ )
{
for ( int c = 0; c < columns; c++ )
{
for ( int h = 0; h < size; h++ )
{
for ( int w = 0; w < size; w++ )
{
int row = r * size + h;
int col = c * size + w;
//data[col, row] = new Color((float)w / size, (float)h / size, (float)(c + r * columns) / size);
data[ col, row ] = lutdata[ w, size - h - 1, ( c + r * columns ) ];
}
}
}
}
lut.Release();
return true;
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b4a9c4655c6830d42a6546458c862981
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -0,0 +1,307 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System.IO;
using UnityEditor;
using UnityEngine;
namespace AmplifyColor
{
public class LUTEditor : EditorWindow
{
public ToolSettings Settings { get { return ToolSettings.Instance; } }
protected PhotoshopConnection Connection { get; set; }
protected PhotoshopProtocol PhotoshopProtocol { get; set; }
protected CameraCollection Cameras { get; set; }
protected BackBufferHandler BackBufferHandler { get; set; }
protected LUTWriter LUTWriter { get; set; }
protected PhotoshopHandler PhotoshopHandler { get; set; }
protected FileHandler FileHandler { get; set; }
private bool lut_foldout = false;
private bool conn_foldout = false;
[MenuItem( "Window/Amplify Color/LUT Editor", false, 0 )]
public static void Init()
{
GetWindow<LUTEditor>( false, "LUT Editor", true );
}
void OnEnable()
{
Connection = new PhotoshopConnection();
PhotoshopProtocol = new PhotoshopProtocol( Connection );
Cameras = new CameraCollection();
BackBufferHandler = new BackBufferHandler( Cameras );
LUTWriter = new LUTWriter();
PhotoshopHandler = new PhotoshopHandler( PhotoshopProtocol, BackBufferHandler, LUTWriter, Settings, Cameras );
FileHandler = new FileHandler( BackBufferHandler, LUTWriter, Settings, Cameras );
Cameras.GenerateCameraList();
}
void OnDestroy()
{
}
Vector2 _scrollPosition = new Vector2( 0, 0 );
void OnGUI()
{
_scrollPosition = GUILayout.BeginScrollView( _scrollPosition );
Settings.SelectedTab = EditorPrefs.GetInt( "AmplifyColor.SelectedTab", 3 );
Settings.SelectedTab = GUILayout.Toolbar( Settings.SelectedTab, new[] { "Photoshop", "File", "Settings" } );
EditorPrefs.SetInt( "AmplifyColor.SelectedTab", Settings.SelectedTab );
switch ( Settings.SelectedTab )
{
case 0:
ShowReadBackBufferGUI();
ShowGUIPhotoshop();
ShowGUITargetFile();
ShowGUIStatusBar();
ShowLUTChecklist();
break;
case 1:
ShowReadBackBufferGUI();
ShowGUIFile();
ShowGUITargetFile();
ShowGUIStatusBar();
break;
case 2:
ShowGUISettings();
ShowGUIStatusBar();
ShowConnectionChecklist();
break;
}
GUILayout.EndScrollView();
}
private void ShowLUTChecklist()
{
EditorGUILayout.Space();
EditorGUILayout.Separator();
EditorGUILayout.Space();
lut_foldout = EditorGUILayout.Foldout( lut_foldout, "Help: Your LUT doesn't look right?" );
if ( lut_foldout )
{
GUILayout.BeginHorizontal();
GUILayout.Space( 10 );
GUILayout.BeginVertical();
GUILayout.Label( "1) Go to your LUT import settings and set \"Texture Type\" to Advanced.", EditorStyles.wordWrappedLabel );
GUILayout.Label( "2) Enable \"Bypass sRGB Sampling\".", EditorStyles.wordWrappedLabel );
GUILayout.Label( "3) Disable \"Generate Mip Maps\".", EditorStyles.wordWrappedLabel );
GUILayout.Label( "4) Set \"Wrap Mode\" to Clamp.", EditorStyles.wordWrappedLabel );
GUILayout.Label( "5) Set \"Filter Mode\" to Bilinear.", EditorStyles.wordWrappedLabel );
GUILayout.Label( "6) Set \"Aniso Level\" to 0.", EditorStyles.wordWrappedLabel );
GUILayout.Label( "7) Set \"Max Size\" to 1024.", EditorStyles.wordWrappedLabel );
GUILayout.Label( "8) Set \"Format\" to Automatic Truecolor.", EditorStyles.wordWrappedLabel );
GUILayout.EndVertical();
GUILayout.EndHorizontal();
}
}
private void ShowConnectionChecklist()
{
EditorGUILayout.Space();
EditorGUILayout.Separator();
EditorGUILayout.Space();
conn_foldout = EditorGUILayout.Foldout( conn_foldout, "Help: Having trouble connecting?" );
if ( conn_foldout )
{
GUILayout.BeginHorizontal();
GUILayout.Space( 10 );
GUILayout.BeginVertical();
GUILayout.Label( "1) Use Photoshop CS 5.1 or above.", EditorStyles.wordWrappedLabel );
GUILayout.Label( "2) Enable Remote access in Photoshop \"Edit/Remote Connections...\"", EditorStyles.wordWrappedLabel );
GUILayout.Label( "3) Make sure both passwords match. Reset them just in case.", EditorStyles.wordWrappedLabel );
GUILayout.Label( "4) Add Unity and Photoshop to firewall as exceptions.", EditorStyles.wordWrappedLabel );
GUILayout.Label( "5) Set your active Build Target to Standalone.", EditorStyles.wordWrappedLabel );
GUILayout.Label( "6) Set Host to target machine; usually 'localhost' or '127.0.0.1'.", EditorStyles.wordWrappedLabel );
GUILayout.EndVertical();
GUILayout.EndHorizontal();
}
}
private void ShowGUITargetFile()
{
EditorGUILayout.Space();
EditorGUILayout.Space();
EditorGUILayout.BeginVertical();
EditorGUILayout.BeginHorizontal();
var lutpath = EditorGUILayout.TextField( "Save Preset to File", LUTWriter.TexturePath );
if ( GUILayout.Button( "Browse" ) )
{
var path = EditorUtility.SaveFilePanelInProject( "Save as", Path.GetFileName( LUTWriter.TexturePath ), "png", "Please enter a file name to save the texture to" );
if ( !string.IsNullOrEmpty( path ) )
{
lutpath = path;
}
}
EditorGUILayout.EndHorizontal();
LUTWriter.Overwrite = EditorGUILayout.Toggle( "Overwrite Existing File", LUTWriter.Overwrite );
//var lutobject = (Texture2D)EditorGUILayout.ObjectField("Texture", LUTWriter.TextureObject, typeof(Texture2D), false);
//LUTWriter.Update(lutpath, lutobject);
LUTWriter.TexturePath = lutpath;
EditorGUILayout.EndVertical();
}
private void ShowGUIStatusBar()
{
EditorGUILayout.Space();
EditorGUILayout.Separator();
EditorGUILayout.Space();
EditorGUILayout.LabelField( "Status", Settings.Message ?? "", EditorStyles.wordWrappedLabel );
}
private void ShowGUIFile()
{
EditorGUILayout.Space();
if ( GUILayout.Button( "Save reference file" ) )
{
FileHandler.SaveToFile();
}
if ( GUILayout.Button( "Load graded file" ) )
{
FileHandler.ReadFromFile();
}
EditorGUILayout.BeginHorizontal();
Settings.FilePath = EditorGUILayout.TextField( Settings.FilePath ?? "" );
if ( GUILayout.Button( "Reload" ) )
{
FileHandler.Reload();
}
EditorGUILayout.EndHorizontal();
}
private void ShowGUIPhotoshop()
{
EditorGUILayout.Space();
if ( GUILayout.Button( "Send screenshot to Photoshop" ) )
{
PhotoshopHandler.SendToPhotoshop();
}
if ( GUILayout.Button( "Read preset from Photoshop" ) )
{
PhotoshopHandler.ReadFromPhotoshopTools();
}
}
private void ShowReadBackBufferGUI()
{
EditorGUILayout.BeginVertical();
EditorGUILayout.LabelField( "", "Screenshot settings" );
EditorGUILayout.Space();
Cameras.GenerateCameraList();
Cameras.SelectedIndex = EditorGUILayout.Popup( "Camera", Cameras.SelectedIndex, Cameras.CameraNames );
EditorGUILayout.Space();
ShowGUIResolution();
Settings.AddLut = EditorGUILayout.Toggle( "Add LUT", Settings.AddLut );
Settings.ApplyHDRControl = EditorGUILayout.Toggle( "Apply HDR Control", Settings.ApplyHDRControl );
Settings.ApplyColorGrading = EditorGUILayout.Toggle( "Apply Color Grading", Settings.ApplyColorGrading );
EditorGUILayout.EndVertical();
EditorGUILayout.Space();
EditorGUILayout.Space();
}
private void ShowGUIResolution()
{
Settings.Resolution.SelectedResolution = EditorPrefs.GetInt( "AmplifyColor.SelectedResolution", 3 );
Settings.Resolution.SelectedResolution = EditorGUILayout.Popup( "Resolution", Settings.Resolution.SelectedResolution, Settings.Resolution.ResolutionOptions );
EditorPrefs.SetInt( "AmplifyColor.SelectedResolution", Settings.Resolution.SelectedResolution );
if ( Settings.Resolution.IsCustom )
{
Settings.Resolution.TargetWidth = EditorGUILayout.IntField( "Width", Settings.Resolution.TargetWidth );
Settings.Resolution.TargetHeight = EditorGUILayout.IntField( "Height", Settings.Resolution.TargetHeight );
}
EditorGUILayout.Space();
}
private void ShowGUISettings()
{
EditorGUILayout.LabelField( "", "Setup Photoshop connection" );
EditorGUILayout.Space();
Settings.Host = EditorPrefs.GetString( "AmplifyColor.NetworkHost", "localhost" );
Settings.Password = EditorPrefs.GetString( "AmplifyColor.NetworkPassword", "password" );
bool showPassword = EditorPrefs.GetBool( "AmplifyColor.ShowPassword", false );
Settings.Host = EditorGUILayout.TextField( "Host", Settings.Host );
if ( showPassword )
Settings.Password = EditorGUILayout.TextField( "Password", Settings.Password );
else
Settings.Password = EditorGUILayout.PasswordField( "Password", Settings.Password );
showPassword = EditorGUILayout.Toggle( "Show Password", showPassword );
EditorPrefs.SetString( "AmplifyColor.NetworkHost", Settings.Host );
EditorPrefs.SetString( "AmplifyColor.NetworkPassword", Settings.Password );
EditorPrefs.SetBool( "AmplifyColor.ShowPassword", showPassword );
EditorGUILayout.Separator();
if ( GUILayout.Button( "Test Connection" ) )
{
Connection.TestConnection();
}
//EditorGUILayout.Space();
//EditorGUILayout.Space();
//EditorGUILayout.LabelField("", "LUT Settings");
//var size = EditorGUILayout.IntSlider("Size", Settings.LUT.Size, 0, 64);
//var columns = EditorGUILayout.IntField("Columns", Settings.LUT.Columns);
//var rows = EditorGUILayout.IntField("Rows", Settings.LUT.Rows);
//Settings.LUT.Update(size, columns, rows);
//bool toggle = true;
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: db7a7573b0762094b87789612826a2a0
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -0,0 +1,80 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using UnityEngine;
namespace AmplifyColor
{
public class LUTResult
{
private readonly Color[ , , ] _data;
private Texture2D _texture;
public LUTResult( Color[ , , ] data )
{
_data = data;
GenerateTexture();
}
public void Release()
{
if ( _texture != null )
{
Texture2D.DestroyImmediate( _texture );
_texture = null;
}
}
private void GenerateTexture()
{
if ( _data == null )
{
throw new ArgumentNullException();
}
int width = _data.GetLength( 0 );
int length = _data.GetLength( 1 );
int height = _data.GetLength( 2 );
if ( width != length || width != height || length != height )
{
throw new ArgumentOutOfRangeException();
}
int size = width;
if ( _texture != null )
Texture2D.DestroyImmediate( _texture );
_texture = new Texture2D( size * size, size, TextureFormat.ARGB32, false );
var textureData = new Color[ size * size * size ];
for ( int w = 0; w < size; w++ )
{
for ( int l = 0; l < size; l++ )
{
for ( int h = 0; h < size; h++ )
{
int index = w + h * size + l * size * size;
textureData[ index ] = _data[ w, l, h ];
}
}
}
_texture.SetPixels( textureData );
}
public Texture2D Texture
{
get { return _texture; }
}
public Color[ , , ] Data
{
get { return _data; }
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 04e1ecc030e6b3b48ba2e412e1d674a4
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -0,0 +1,112 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
namespace AmplifyColor
{
public class LUTSettings
{
private int _columns;
private int _rows;
private int _size;
public LUTSettings()
{
_size = 32;
_columns = 8;
_rows = 4;
}
public LUTSettings( int size )
{
_size = size;
RecalcLutSize();
}
public LUTSettings( int columns, int rows )
{
_columns = columns;
_rows = rows;
_size = columns * rows;
}
public int Size
{
get { return _size; }
}
public int Columns
{
get { return _columns; }
}
public int Rows
{
get { return _rows; }
}
public int Height
{
get { return _rows * _size; }
}
public int Width
{
get { return _columns * _size; }
}
private void RecalcLutSize()
{
_size = Math.Min( _size, 256 );
if ( _size == 0 )
{
_columns = 1;
_rows = 1;
_size = 1;
return;
}
double colsize;
double rowsize;
double root = Math.Sqrt( _size );
rowsize = Math.Floor( root );
do
{
colsize = _size / rowsize;
rowsize -= 1.0;
} while ( colsize != Math.Floor( colsize ) );
rowsize += 1.0;
_columns = ( int ) colsize;
_rows = ( int ) rowsize;
}
public void Update( int size, int columns, int rows )
{
if ( _size != size )
{
_size = Math.Min( size, 64 );
RecalcLutSize();
}
else
{
_size = columns * rows;
_columns = columns;
_rows = rows;
if ( size > 64 )
{
_size = 64;
RecalcLutSize();
}
}
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: aadba7bf2fdd71b4d91cbdddd9929510
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -0,0 +1,99 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System.IO;
using UnityEditor;
using UnityEngine;
namespace AmplifyColor
{
public class LUTWriter
{
private string _texturePath;
private bool _overwrite = false;
public string TexturePath
{
get { return _texturePath; }
set { _texturePath = value; }
}
public bool Overwrite
{
get { return _overwrite; }
set { _overwrite = value; }
}
public void SaveLUT( LUTResult lutResult )
{
if ( lutResult == null )
{
ToolSettings.Instance.Message = "Error while reading LUT data.";
return;
}
var assetpath = _texturePath;
bool justBrowsed = false;
if ( string.IsNullOrEmpty( assetpath ) )
{
if ( EditorUtility.DisplayDialog( "Browse?", "There is no current path to save the file to.", "Browse", "Cancel" ) )
{
var path = EditorUtility.SaveFilePanelInProject( "Save as", Path.GetFileName( _texturePath ), "png", "Please enter a file name to save the texture to" );
justBrowsed = true;
if ( string.IsNullOrEmpty( path ) )
{
return;
}
_texturePath = path;
}
else
{
return;
}
}
if ( File.Exists( _texturePath ) && !justBrowsed && !_overwrite )
{
if ( !EditorUtility.DisplayDialog( "Overwrite?", "File already exists. This action will overwrite the current file. Do you want to continue?", "Overwrite", "Cancel" ) )
return;
}
File.WriteAllBytes( _texturePath, lutResult.Texture.EncodeToPNG() );
AssetDatabase.Refresh();
var text = AssetDatabase.LoadAssetAtPath( _texturePath, typeof( Texture2D ) ) as Texture2D;
if ( text != null )
{
text.wrapMode = TextureWrapMode.Clamp;
text.filterMode = FilterMode.Bilinear;
}
TextureImporter tImporter = AssetImporter.GetAtPath( _texturePath ) as TextureImporter;
if ( tImporter != null )
{
tImporter.mipmapEnabled = false;
tImporter.isReadable = false;
tImporter.filterMode = FilterMode.Bilinear;
tImporter.anisoLevel = 0;
#if UNITY_5_6_OR_NEWER
tImporter.textureType = TextureImporterType.Default;
tImporter.textureCompression = TextureImporterCompression.Uncompressed;
tImporter.sRGBTexture = false;
#else
tImporter.textureType = TextureImporterType.Advanced;
tImporter.textureFormat = TextureImporterFormat.AutomaticTruecolor;
tImporter.linearTexture = true;
#endif
tImporter.wrapMode = TextureWrapMode.Clamp;
tImporter.maxTextureSize = 1024;
AssetDatabase.ImportAsset( _texturePath, ImportAssetOptions.ForceUpdate );
}
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 783bdcee9e603da40beecc70fc0c54df
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -0,0 +1,245 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using UnityEngine;
using UnityEditor;
namespace AmplifyColor
{
public class PhotoshopConnection
{
private const int ServerPort = 49494;
private string _lastHost;
private string _lastPassword;
private TcpClient _socket;
private NetworkStream _stream;
public NetworkStream Stream { get; private set; }
static int SwapEndian( int x )
{
uint ux = ( uint ) x;
ux = ( ( ux & 0x000000ff ) << 24 ) + ( ( ux & 0x0000ff00 ) << 8 ) +
( ( ux & 0x00ff0000 ) >> 8 ) + ( ( ux & 0xff000000 ) >> 24 );
return ( int ) ux;
}
string FlushRead()
{
_stream.Flush();
string result = "";
while ( _stream.DataAvailable )
{
var buf = new byte[ 4 ];
_stream.Read( buf, 0, 4 );
int inLength = BitConverter.ToInt32( buf.Reverse().ToArray(), 0 );
_stream.Read( buf, 0, 4 );
//int inComStatus = BitConverter.ToInt32( buf.Reverse().ToArray(), 0 );
//Debug.Log("Reading length: " + inLength);
//Debug.Log("Reading com status: " + inComStatus);
var skip = new byte[ inLength ];
_stream.Read( skip, 0, inLength );
result += Encoding.UTF8.GetString( skip );
}
return result;
}
string SendTestImage( PhotoshopProtocol pp )
{
string result = "";
result += FlushRead();
byte[] image = {
0x02,
0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x01,
0x01,
0x03,
0x08,
0xff, 0x00, 0x00 };
MemoryStream temp_stream = new MemoryStream();
BinaryWriter bw = new BinaryWriter( temp_stream );
bw.Write( SwapEndian( PhotoshopProtocol.ProtocolVersion ) ); // Protocol version
bw.Write( SwapEndian( pp._transactionId++ ) ); // Transaction ID
bw.Write( SwapEndian( 3 ) ); // Content Type
bw.Write( image ); // Image data
bw.Flush();
long len = temp_stream.Length;
temp_stream.Seek( 0, SeekOrigin.Begin );
BinaryReader br = new BinaryReader( temp_stream );
var message = new byte[ len ];
br.Read( message, 0, ( int ) len );
string password = EditorPrefs.GetString( "AmplifyColor.NetworkPassword", "password" );
EncryptDecrypt encryptDecrypt = new EncryptDecrypt( password );
var encryptedMessage = encryptDecrypt.encrypt( message );
//string str = "";
//for (int i = 0; i < message.Length; i++)
//{
// str += ( ( message[i] & 0xff ) + 0x100 ).ToString( "x" ).Substring( 1 ) + " ";
// if (i > 0 && (((i+1) % 8) == 0))
// str += "\n";
//}
//Debug.Log( str );
//str = "";
//for (int i = 0; i < encryptedMessage.Length; i++)
//{
// str += ( ( encryptedMessage[i] & 0xff ) + 0x100 ).ToString( "x" ).Substring( 1 ) + " ";
// if (i > 0 && (((i+1) % 8) == 0))
// str += "\n";
//}
//Debug.Log( str );
int messageLength = PhotoshopProtocol.CommLength + encryptedMessage.Length;
_stream.Write( BitConverter.GetBytes( messageLength ).Reverse().ToArray(), 0, 4 );
_stream.Write( BitConverter.GetBytes( PhotoshopProtocol.NoCommError ).Reverse().ToArray(), 0, 4 );
_stream.Write( encryptedMessage, 0, encryptedMessage.Length );
_stream.Flush();
System.Threading.Thread.Sleep( 1000 );
result += FlushRead();
return result;
}
public void TestConnection()
{
if ( string.IsNullOrEmpty( ToolSettings.Instance.Host ) )
{
ToolSettings.Instance.Message = "Host can't be empty";
return;
}
try
{
if ( !Connect() )
{
ToolSettings.Instance.Message =
"There was an error. Check if the host is available to this machine.";
return;
}
var pp = new PhotoshopProtocol( this );
//string result = pp.SendJSCommand("scriptingVersion");
string result = SendTestImage( pp );
//while ( _stream.DataAvailable )
//{
// var buf = new byte[ 4 ];
// _stream.Read( buf, 0, 4);
// int inLength = BitConverter.ToInt32( buf.Reverse().ToArray(), 0 );
// _stream.Read( buf, 0, 4);
// int inComStatus = BitConverter.ToInt32( buf.Reverse().ToArray(), 0 );
//
// Debug.Log("Reading length: " + inLength);
// Debug.Log("Reading com status: " + inComStatus);
//
// var skip = new byte[ inLength ];
// _stream.Read( skip, 0, inLength );
//
// result += Encoding.UTF8.GetString( skip );
//}
if ( result.ToLowerInvariant().Contains( "error" ) )
{
ToolSettings.Instance.Message = "There was an error. Try checking the password.";
CleanConnection();
}
else
{
ToolSettings.Instance.Message = "Test successfull";
}
}
catch ( Exception )
{
ToolSettings.Instance.Message = "Connection could not be established";
}
}
public bool Connect()
{
if ( string.IsNullOrEmpty( ToolSettings.Instance.Host ) )
{
ToolSettings.Instance.Message = "Host can't be empty";
return false;
}
if ( string.IsNullOrEmpty( ToolSettings.Instance.Password ) )
{
ToolSettings.Instance.Message = "Password can't be empty";
return false;
}
if ( _socket != null )
{
if ( _socket.Connected )
{
if ( string.Equals( _lastHost, ToolSettings.Instance.Host ) )
{
if ( string.Equals( _lastPassword, ToolSettings.Instance.Password ) )
{
return true;
}
}
}
}
try
{
_socket = new TcpClient( ToolSettings.Instance.Host, ServerPort );
_stream = _socket.GetStream();
Stream = _stream;
_lastHost = ToolSettings.Instance.Host;
_lastPassword = ToolSettings.Instance.Password;
}
catch ( Exception )
{
CleanConnection();
return false;
}
return true;
}
public void CleanConnection()
{
if ( _stream != null )
{
_stream.Flush();
_stream.Close();
_stream = null;
}
if ( _socket != null )
{
_socket.Client.Close();
_socket = null;
}
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 97de723f1ed73ae4c8454c1c7a10d738
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -0,0 +1,57 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using System.Security.Cryptography;
using System.Text;
namespace AmplifyColor
{
public class PhotoshopEncryptDecrypt
{
private readonly ICryptoTransform _eCipher;
private readonly ICryptoTransform _dCipher;
// these must match the values used in Photoshop DO NOT CHANGE
// get the password from the dialog settings in Photoshop
private readonly char[] _salt = { 'A', 'd', 'o', 'b', 'e', ' ', 'P', 'h', 'o', 't', 'o', 's', 'h', 'o', 'p' };
private const int IterationCount = 1000;
private const int KeyLength = 24;
public PhotoshopEncryptDecrypt( String passPhrase )
{
var encoder = new ASCIIEncoding();
//byte[] bytepass = encoder.GetBytes(passPhrase);
byte[] bytesalt = encoder.GetBytes( _salt );
var tripleDes = new TripleDESCryptoServiceProvider
{
Mode = CipherMode.CBC,
Padding = PaddingMode.PKCS7,
};
var rfc2898DeriveBytes = new Rfc2898DeriveBytes( passPhrase, bytesalt, IterationCount );
var key = rfc2898DeriveBytes.GetBytes( KeyLength );
var empty = new byte[ 8 ];
_eCipher = tripleDes.CreateEncryptor( key, empty );
_dCipher = tripleDes.CreateDecryptor( key, empty );
}
public byte[] Encrypt( byte[] data )
{
byte[] encryptedBytes = _eCipher.TransformFinalBlock( data, 0, data.Length );
return encryptedBytes;
}
public byte[] Decrypt( byte[] data )
{
byte[] decryptedBytes = _dCipher.TransformFinalBlock( data, 0, data.Length );
return decryptedBytes;
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 9f9f97ff14f42ab4b843a92f5dd9668b
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -0,0 +1,153 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using System.IO;
using UnityEngine;
using UnityEditor;
using System.Net.Sockets;
namespace AmplifyColor
{
public class PhotoshopHandler
{
private readonly PhotoshopProtocol _photoshopProtocol;
private readonly BackBufferHandler _backBufferHandler;
private readonly LUTWriter _lutWriter;
private readonly ToolSettings _settings;
private readonly CameraCollection _cameraCollection;
public PhotoshopHandler( PhotoshopProtocol photoshopProtocol, BackBufferHandler backBufferHandler, LUTWriter lutWriter, ToolSettings settings, CameraCollection cameraCollection )
{
_photoshopProtocol = photoshopProtocol;
_backBufferHandler = backBufferHandler;
_lutWriter = lutWriter;
_settings = settings;
_cameraCollection = cameraCollection;
}
public void SendToPhotoshop()
{
ImageResult imageResult;
if ( _backBufferHandler.ReadBackBuffer( out imageResult ) )
{
if ( _settings.AddLut )
{
Texture2D luttexture = _cameraCollection.GetCurrentEffectTexture();
if ( _settings.ApplyColorGrading && luttexture != null )
{
if ( !imageResult.AddLUTFromTexture( _settings.LUT, luttexture ) )
{
_settings.Message = "Couldnt add the LUT to the image. Try changing the lut size or settings";
return;
}
}
else
{
if ( !imageResult.AddLUT( _settings.LUT ) )
{
_settings.Message = "Couldnt add the LUT to the image. Try changing the lut size or settings";
return;
}
}
}
if ( SendImage( imageResult ) )
{
_photoshopProtocol.SendJSCommand( "app.activeDocument.bitsPerChannel = BitsPerChannelType.SIXTEEN;" +
"takeSnapshot();" +
" function takeSnapshot ()" +
" { var desc = new ActionDescriptor();" +
" var sref = new ActionReference(); sref.putClass(charIDToTypeID(\"SnpS\"));" +
"desc.putReference(charIDToTypeID(\"null\"), sref);" +
"var fref = new ActionReference();" +
" fref.putProperty(charIDToTypeID(\"HstS\")," +
" charIDToTypeID(\"CrnH\")); " +
"desc.putReference(charIDToTypeID(\"From\"), fref );" +
" executeAction(charIDToTypeID(\"Mk \"), desc, DialogModes.NO );} " );
ToolSettings.Instance.Message = "Sent";
}
else
{
ToolSettings.Instance.Message = "Error sending the image to Photoshop";
}
}
else
{
_settings.Message = "No camera selected";
}
}
public void ReadFromPhotoshopTools()
{
LUTResult lutResult;
if ( ReadLUT( out lutResult ) )
{
_lutWriter.SaveLUT( lutResult );
lutResult.Release();
}
}
public bool ReadLUT( out LUTResult lutResult )
{
_photoshopProtocol.SendJSCommand( "takeSnapshot();" +
" function takeSnapshot ()" +
" { var desc = new ActionDescriptor();" +
" var sref = new ActionReference(); sref.putClass(charIDToTypeID(\"SnpS\"));" +
"desc.putReference(charIDToTypeID(\"null\"), sref);" +
"var fref = new ActionReference();" +
" fref.putProperty(charIDToTypeID(\"HstS\")," +
" charIDToTypeID(\"CrnH\")); " +
"desc.putReference(charIDToTypeID(\"From\"), fref );" +
" executeAction(charIDToTypeID(\"Mk \"), desc, DialogModes.NO );} " );
var rulerunits = _photoshopProtocol.SendJSCommand( "app.preferences.rulerUnits;" );
_photoshopProtocol.SendJSCommand( "app.preferences.rulerUnits = Units.PIXELS;" );
_photoshopProtocol.SendJSCommand( string.Format( "app.activeDocument.crop(new Array(0,0,{0},{1}), 0, {0}, {1})", ToolSettings.Instance.LUT.Width, ToolSettings.Instance.LUT.Height ) );
ImageResult imageData;
_photoshopProtocol.ReceiveImage( "", out imageData );
_photoshopProtocol.SendJSCommand( "revertToLastSnapshot(); " +
"function revertToLastSnapshot() " +
"{ var docRef = app.activeDocument; " +
"var hsObj = docRef.historyStates; " +
"var hsLength = hsObj.length; " +
"for (var i=hsLength - 1;i>-1;i--) { " +
"if (hsObj[i].snapshot) { " +
"docRef.activeHistoryState = docRef.historyStates[i]; break; } } }" );
_photoshopProtocol.SendJSCommand( string.Format( "app.preferences.rulerUnits = {0};", rulerunits ) );
lutResult = null;
if ( imageData != null )
{
lutResult = imageData.GetLUT( _settings.LUT );
ToolSettings.Instance.Message = "Done.";
return true;
}
ToolSettings.Instance.Message = "Error reading LUT from Photoshop Image.";
return false;
}
public bool SendImage( ImageResult imageResult )
{
if ( imageResult == null )
{
return false;
}
_photoshopProtocol.SendImage( imageResult );
return true;
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e44b84c92f880434f888e3d8243a9bc5
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -0,0 +1,398 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using UnityEngine;
using UnityEditor;
namespace AmplifyColor
{
public class PhotoshopProtocol
{
private readonly PhotoshopConnection _connection;
/** values for transaction type */
internal const int IllegalType = 0;
internal const int ErrorstringType = 1;
internal const int JavascriptType = 2;
internal const int ImageType = 3;
internal const int ProfileType = 4;
internal const int DataType = 5;
/** current protocol version */
internal const int ProtocolVersion = 1;
/** length of the header not including the actual length byte or the communication status */
internal const int ProtocolLength = 4 + 4 + 4;
internal const int CommLength = 4;
internal const int NoCommError = 0;
/** messages are encrypted, helper class to encrypt and decrypt messages */
private EncryptDecrypt _encryptDecrypt;
private readonly UTF8Encoding _utf8Encoding;
internal int _transactionId;
public PhotoshopProtocol( PhotoshopConnection connection )
{
_connection = connection;
_utf8Encoding = new UTF8Encoding();
}
public string SendJSCommand( string command )
{
if ( !_connection.Connect() )
{
return "Error connecting to Photoshop.";
}
var stream = _connection.Stream;
string password = EditorPrefs.GetString( "AmplifyColor.NetworkPassword", "password" );
_encryptDecrypt = new EncryptDecrypt( password );
try
{
/* WRITE */
byte[] strBytes = _utf8Encoding.GetBytes( command + "\n" );
byte[] allBytes;
using ( var memoryStream = new MemoryStream() )
{
BitConverter.GetBytes( ProtocolVersion );
memoryStream.Write( BitConverter.GetBytes( ProtocolVersion ).Reverse().ToArray(), 0, 4 );
_transactionId++;
memoryStream.Write( BitConverter.GetBytes( _transactionId ).Reverse().ToArray(), 0, 4 );
memoryStream.Write( BitConverter.GetBytes( JavascriptType ).Reverse().ToArray(), 0, 4 );
memoryStream.Write( strBytes, 0, strBytes.Length );
allBytes = memoryStream.GetBuffer().Take( ProtocolLength + strBytes.Length ).ToArray();
}
var encryptedBytes = _encryptDecrypt.encrypt( allBytes );
int messageLength = CommLength + encryptedBytes.Length;
stream.Write( BitConverter.GetBytes( messageLength ).Reverse().ToArray(), 0, 4 );
stream.Write( BitConverter.GetBytes( NoCommError ).Reverse().ToArray(), 0, 4 );
stream.Write( encryptedBytes, 0, encryptedBytes.Length );
/* READ */
var buffer = new byte[ 4 ];
stream.Read( buffer, 0, 4 );
buffer = buffer.Reverse().ToArray();
int inLength = BitConverter.ToInt32( buffer, 0 );
stream.Read( buffer, 0, 4 );
buffer = buffer.Reverse().ToArray();
int inComStatus = BitConverter.ToInt32( buffer, 0 );
if ( inComStatus != 0 )
{
stream.Read( buffer, 0, 4 );
buffer = buffer.Reverse().ToArray();
//int inVersion = BitConverter.ToInt32(buffer, 0);
stream.Read( buffer, 0, 4 );
buffer = buffer.Reverse().ToArray();
//int inTransaction = BitConverter.ToInt32(buffer, 0);
stream.Read( buffer, 0, 4 );
buffer = buffer.Reverse().ToArray();
int inType = BitConverter.ToInt32( buffer, 0 );
if ( inType == JavascriptType || inType == ErrorstringType )
{
inLength -= ProtocolLength;
var bytemessage = new byte[ inLength + 1 ];
int rr = stream.Read( bytemessage, 0, inLength );
if ( rr > 0 )
{
var encoder = new UTF8Encoding();
var message = encoder.GetString( bytemessage );
Debug.LogWarning( "[AmplifyColor] Uncoded Message: " + message + ". Please check your password." );
return message.Trim( new[] { '\0' } );
}
}
else
{
return "Message types: " + inType;
}
}
else
{
inLength = inLength - 4;
var messageBytes = new byte[ inLength ];
stream.Read( messageBytes, 0, inLength );
IEnumerable<byte> decryptedBytes = _encryptDecrypt.decrypt( messageBytes );
byte[] tempbytes;
//tempbytes = decryptedBytes.Take(4).Reverse().ToArray();
decryptedBytes = decryptedBytes.Skip( 4 );
//int messageVersion = BitConverter.ToInt32(tempbytes, 0);
//tempbytes = decryptedBytes.Take(4).Reverse().ToArray();
decryptedBytes = decryptedBytes.Skip( 4 );
//int messageId = BitConverter.ToInt32(tempbytes, 0);
tempbytes = decryptedBytes.Take( 4 ).Reverse().ToArray();
decryptedBytes = decryptedBytes.Skip( 4 );
int messageType = BitConverter.ToInt32( tempbytes, 0 );
if ( messageType == JavascriptType || messageType == ErrorstringType )
{
var encoder = new UTF8Encoding();
var message = encoder.GetString( decryptedBytes.ToArray() );
return message.Trim( new[] { '\0' } );
}
return "Message types: " + messageType;
}
}
catch ( Exception e )
{
return "Exception: " + e.Message;
}
return string.Empty;
}
public string ReceiveImage( string documentName, out ImageResult imageData )
{
imageData = null;
if ( !_connection.Connect() )
{
return "Error connecting to Photoshop.";
}
var stream = _connection.Stream;
string password = EditorPrefs.GetString( "AmplifyColor.NetworkPassword", "password" );
_encryptDecrypt = new EncryptDecrypt( password );
var commandBuilder = new StringBuilder();
if ( !string.IsNullOrEmpty( documentName ) )
{
commandBuilder.Append( "app.activeDocument = app.documents.getByName('" + documentName + "');\n" );
}
commandBuilder.Append( "var idNS = stringIDToTypeID('sendDocumentThumbnailToNetworkClient');\n" );
commandBuilder.Append( "var desc1 = new ActionDescriptor();\n" );
commandBuilder.Append( "desc1.putInteger( stringIDToTypeID('width'), app.activeDocument.width );\n" );
commandBuilder.Append( "desc1.putInteger( stringIDToTypeID('height'), app.activeDocument.height );\n" );
commandBuilder.Append( "desc1.putInteger( stringIDToTypeID('format'), 2 );\n" );
commandBuilder.Append( "executeAction( idNS, desc1, DialogModes.NO );" );
string command = commandBuilder.ToString();
try
{
/* WRITE */
byte[] strBytes = _utf8Encoding.GetBytes( command + "\n" );
byte[] allBytes;
using ( var memoryStream = new MemoryStream() )
{
BitConverter.GetBytes( ProtocolVersion );
memoryStream.Write( BitConverter.GetBytes( ProtocolVersion ).Reverse().ToArray(), 0, 4 );
_transactionId++;
memoryStream.Write( BitConverter.GetBytes( _transactionId ).Reverse().ToArray(), 0, 4 );
memoryStream.Write( BitConverter.GetBytes( JavascriptType ).Reverse().ToArray(), 0, 4 );
memoryStream.Write( strBytes, 0, strBytes.Length );
allBytes = memoryStream.GetBuffer().Take( ProtocolLength + strBytes.Length ).ToArray();
}
var encryptedBytes = _encryptDecrypt.encrypt( allBytes );
int messageLength = CommLength + encryptedBytes.Length;
stream.Write( BitConverter.GetBytes( messageLength ).Reverse().ToArray(), 0, 4 );
stream.Write( BitConverter.GetBytes( NoCommError ).Reverse().ToArray(), 0, 4 );
stream.Write( encryptedBytes, 0, encryptedBytes.Length );
/* READ */
DateTime start = DateTime.Now;
int messageType = 0;
while ( messageType != ImageType && ( DateTime.Now - start ).TotalMilliseconds < 1000 )
{
if ( !stream.DataAvailable )
continue;
var buffer = new byte[ 4 ];
stream.Read( buffer, 0, 4 );
buffer = buffer.Reverse().ToArray();
int inLength = BitConverter.ToInt32( buffer, 0 );
stream.Read( buffer, 0, 4 );
buffer = buffer.Reverse().ToArray();
int inComStatus = BitConverter.ToInt32( buffer, 0 );
if ( inComStatus != 0 )
{
stream.Read( buffer, 0, 4 );
buffer = buffer.Reverse().ToArray();
//int inVersion = BitConverter.ToInt32(buffer, 0);
stream.Read( buffer, 0, 4 );
buffer = buffer.Reverse().ToArray();
//int inTransaction = BitConverter.ToInt32(buffer, 0);
stream.Read( buffer, 0, 4 );
buffer = buffer.Reverse().ToArray();
messageType = BitConverter.ToInt32( buffer, 0 );
if ( messageType == JavascriptType || messageType == ErrorstringType )
{
inLength -= ProtocolLength;
var bytemessage = new byte[ inLength + 1 ];
int rr = stream.Read( bytemessage, 0, inLength );
if ( rr > 0 )
{
var encoder = new UTF8Encoding();
var message = encoder.GetString( bytemessage );
return message.Trim( new[] { '\0' } );
}
}
else
{
return "Message types: " + messageType;
}
}
else
{
inLength = inLength - 4;
var messageBytes = new List<byte>();
var messagebuffer = new byte[ 1000 ];
int totalread = 0;
while ( totalread < inLength || stream.DataAvailable )
{
int bytesread = stream.Read( messagebuffer, 0, 1000 );
totalread += bytesread;
messageBytes.AddRange( messagebuffer.Take( bytesread ) );
}
IEnumerable<byte> decryptedBytes = _encryptDecrypt.decrypt( messageBytes.ToArray() );
decryptedBytes = decryptedBytes.Skip( 4 );
decryptedBytes = decryptedBytes.Skip( 4 );
byte[] tempbytes = decryptedBytes.Take( 4 ).Reverse().ToArray();
decryptedBytes = decryptedBytes.Skip( 4 );
messageType = BitConverter.ToInt32( tempbytes, 0 );
if ( messageType == ImageType )
imageData = ImageResult.FromPhotoshopResult( decryptedBytes.ToArray() );
else if ( messageType == ErrorstringType )
return Encoding.UTF8.GetString( decryptedBytes.ToArray() );
}
}
//return "Message types: " + messageType;
return "Image Received";
}
catch ( Exception e )
{
return e.Message;
}
}
static int SwapEndian( int x )
{
uint ux = ( uint ) x;
ux = ( ( ux & 0x000000ff ) << 24 ) + ( ( ux & 0x0000ff00 ) << 8 ) +
( ( ux & 0x00ff0000 ) >> 8 ) + ( ( ux & 0xff000000 ) >> 24 );
return ( int ) ux;
}
public string SendImage( ImageResult imageData )
{
if ( !_connection.Connect() )
{
return "Error connecting to Photoshop.";
}
var stream = _connection.Stream;
int width = imageData.Width;
int height = imageData.Height;
string password = EditorPrefs.GetString( "AmplifyColor.NetworkPassword", "password" );
_encryptDecrypt = new EncryptDecrypt( password );
try
{
/* WRITE */
var temp_stream = new MemoryStream();
var w = new BinaryWriter( temp_stream );
w.Write( SwapEndian( ProtocolVersion ) );
w.Write( SwapEndian( _transactionId++ ) );
w.Write( SwapEndian( ImageType ) );
w.Write( ( byte ) 2 ); //imagetype (2 for PixMap);
w.Write( SwapEndian( width ) );
w.Write( SwapEndian( height ) );
w.Write( SwapEndian( width * 3 ) ); //bytesPerScanLine
w.Write( ( byte ) 1 ); //color mode RGB
w.Write( ( byte ) 3 ); //channel count
w.Write( ( byte ) 8 ); //bits per channel
var data = imageData.GenerateRGBData();
w.Write( data, 0, data.Length );
w.Flush();
long len = temp_stream.Length;
temp_stream.Seek( 0, SeekOrigin.Begin );
BinaryReader r = new BinaryReader( temp_stream );
var message = new byte[ len ];
r.Read( message, 0, ( int ) len );
var encryptedMessage = _encryptDecrypt.encrypt( message );
int messageLength = CommLength + encryptedMessage.Length;
stream.Write( BitConverter.GetBytes( messageLength ).Reverse().ToArray(), 0, 4 );
stream.Write( BitConverter.GetBytes( NoCommError ).Reverse().ToArray(), 0, 4 );
stream.Write( encryptedMessage, 0, encryptedMessage.Length );
// Photoshop CS6 will issue a response, make sure we skip it (small timeout)
DateTime start = DateTime.Now;
while ( ( DateTime.Now - start ).TotalMilliseconds < 100 )
{
if ( !stream.DataAvailable )
continue;
var buf = new byte[ 4 ];
stream.Read( buf, 0, 4 );
int length = BitConverter.ToInt32( buf.Reverse().ToArray(), 0 );
buf = new byte[ length ];
stream.Read( buf, 0, length );
}
return "Sent";
}
catch ( Exception e )
{
//Debug.Log( e.Message );
return e.Message;
}
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 3b27e57967578884a9bf3a9a37dc4834
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -0,0 +1,120 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using System.Linq;
using UnityEngine;
namespace AmplifyColor
{
public static class PhotoshopTouchHelper
{
public static bool LoadTexture2DLutFromPhotoshopData( byte[] data, LUTSettings settings, ref Texture2D texture )
{
int columns = settings.Columns;
int rows = settings.Rows;
int size = settings.Size;
var decryptedBytes = data.AsEnumerable();
//byte imageType = decryptedBytes.Take(1).First();
decryptedBytes = decryptedBytes.Skip( 1 );
var tempbytes = decryptedBytes.Take( 4 ).Reverse().ToArray();
decryptedBytes = decryptedBytes.Skip( 4 );
int imageWidth = BitConverter.ToInt32( tempbytes, 0 );
tempbytes = decryptedBytes.Take( 4 ).Reverse().ToArray();
decryptedBytes = decryptedBytes.Skip( 4 );
int imageHeight = BitConverter.ToInt32( tempbytes, 0 );
//tempbytes = decryptedBytes.Take(4).Reverse().ToArray();
decryptedBytes = decryptedBytes.Skip( 4 );
//int rowBytes = BitConverter.ToInt32(tempbytes, 0);
//byte colorMode = decryptedBytes.Take(1).First();
decryptedBytes = decryptedBytes.Skip( 1 );
//byte channelCount = decryptedBytes.Take(1).First();
decryptedBytes = decryptedBytes.Skip( 1 );
//byte bitsChannel = decryptedBytes.Take(1).First();
decryptedBytes = decryptedBytes.Skip( 1 );
var imageData = new Color[ imageWidth, imageHeight ];
var bytesarray = decryptedBytes.ToArray();
for ( int i = 0, k = 0; i < imageHeight; i++ )
{
for ( int j = 0; j < imageWidth; j++ )
{
imageData[ j, i ] = new Color( bytesarray[ k++ ] / 255f, bytesarray[ k++ ] / 255f, bytesarray[ k++ ] / 255f, 1f );
}
}
var lutTexture = new Texture2D( size * size, size, TextureFormat.ARGB32, false );
var lutData = new Color[ size * size * size ];
for ( int h = 0, i = 0; h < size; h++ )
{
for ( int r = 0; r < rows; r++ )
{
for ( int w = 0; w < size * columns; w++ )
{
lutData[ i++ ] = imageData[ w, h + r * size ];
}
}
}
lutTexture.SetPixels( lutData );
lutTexture.Apply();
if ( texture != null )
Texture2D.DestroyImmediate( texture );
texture = lutTexture;
return true;
}
public static bool LoadTexture2DLutFromImage( Texture2D texture, ToolSettings settings, ref Texture2D lutTexture )
{
var width = settings.Resolution.TargetWidth;
var height = settings.Resolution.TargetHeight;
var size = settings.LUT.Size;
var cols = settings.LUT.Columns;
var rows = settings.LUT.Rows;
var imageData = texture.GetPixels();
var lutText = new Texture2D( size * size, size, TextureFormat.ARGB32, false );
var lutData = new Color[ size * size * size ];
for ( int h = 0, i = 0; h < size; h++ )
{
for ( int r = 0; r < rows; r++ )
{
for ( int w = 0; w < size * cols; w++ )
{
var x = w;
var y = h + r * size;
y = height - 1 - y;
lutData[ i++ ] = imageData[ x + y * width ];
}
}
}
lutText.SetPixels( lutData );
lutText.Apply();
if ( lutTexture != null )
Texture2D.DestroyImmediate( lutTexture );
lutTexture = lutText;
return true;
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 7b4fc7d9717fb1f48821f596ddd2fff0
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -0,0 +1,96 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
namespace AmplifyColor
{
public class ResolutionSettings
{
private readonly string[] _resolutionOptions = new[]
{
//"Game Window",
"640x480",
"800x600",
"1024x768",
"1280x720",
"1680x1050",
"1920x1080",
"Custom",
};
private int _selectedResolution = 3;
private int _targetWidth = 1280;
private int _targetHeight = 720;
public int TargetWidth
{
get { return _targetWidth; }
set
{
if ( IsCustom )
_targetWidth = value;
}
}
public int TargetHeight
{
get { return _targetHeight; }
set
{
if ( IsCustom )
_targetHeight = value;
}
}
public int SelectedResolution
{
get { return _selectedResolution; }
set
{
_selectedResolution = value;
SetResolution();
}
}
public bool IsCustom
{
get { return SelectedResolution == ( _resolutionOptions.Length - 1 ); }
}
public string[] ResolutionOptions
{
get { return _resolutionOptions; }
}
private void SetResolution()
{
switch ( _selectedResolution )
{
case 0:
_targetWidth = 640;
_targetHeight = 480;
break;
case 1:
_targetWidth = 800;
_targetHeight = 600;
break;
case 2:
_targetWidth = 1024;
_targetHeight = 768;
break;
case 3:
_targetWidth = 1280;
_targetHeight = 720;
break;
case 4:
_targetWidth = 1680;
_targetHeight = 1050;
break;
case 5:
_targetWidth = 1920;
_targetHeight = 1080;
break;
}
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 1359f2bc92c6caf4db87f92cb2e0e0e9
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 8ed03f9a4c976d6499b12b36976038db

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -0,0 +1,56 @@
fileFormatVersion: 2
guid: cde8652f320cde043a6c4f57aa6d242f
timeCreated: 1445525763
licenseType: Store
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 8
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -2
maxTextureSize: 32
textureSettings:
filterMode: 0
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 2
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,56 @@
fileFormatVersion: 2
guid: 7662ff3b3eb367545b8e4f8c9dd17802
timeCreated: 1448362455
licenseType: Store
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: .25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 8
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 128
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: .5, y: .5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
textureType: 2
buildTargetSettings: []
spriteSheet:
sprites: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,49 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEditor;
namespace AmplifyColor
{
public class ToolSettings
{
private static readonly ToolSettings _instance = new ToolSettings();
public bool AddLut = true;
public bool ApplyHDRControl = true;
public bool ApplyColorGrading = false;
public string FilePath = "";
public string Host = "localhost";
public LUTSettings LUT = new LUTSettings();
public string Message = string.Empty;
public string Password = "password";
public ResolutionSettings Resolution = new ResolutionSettings();
public int SelectedTab;
private ToolSettings()
{
if ( !EditorPrefs.HasKey( "AmplifyColor.NetworkHost" ) )
EditorPrefs.SetString( "AmplifyColor.NetworkHost", Host );
else
Host = EditorPrefs.GetString( "AmplifyColor.NetworkHost", "localhost" );
if ( !EditorPrefs.HasKey( "AmplifyColor.NetworkPassword" ) )
EditorPrefs.SetString( "AmplifyColor.NetworkPassword", Password );
else
Password = EditorPrefs.GetString( "AmplifyColor.NetworkPassword", "password" );
if ( !EditorPrefs.HasKey( "AmplifyColor.SelectedTab" ) )
EditorPrefs.SetInt( "AmplifyColor.SelectedTab", SelectedTab );
else
SelectedTab = EditorPrefs.GetInt( "AmplifyColor.SelectedTab", 0 );
}
public static ToolSettings Instance
{
get { return _instance; }
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 03edf517f5868b041b0229b6dd449426
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: f3a1c18151a4d8a45b5d7f3cd7e30235

View File

@ -0,0 +1,64 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using UnityEngine;
namespace AmplifyColor
{
[Serializable]
public class VersionInfo
{
public const byte Major = 1;
public const byte Minor = 8;
public const byte Release = 2;
private static string StageSuffix = "";
#if TRIAL
private static string TrialSuffix = " Trial";
#else
private static string TrialSuffix = "";
#endif
public static string StaticToString()
{
return string.Format( "{0}.{1}.{2}", Major, Minor, Release ) + StageSuffix + TrialSuffix;
}
public override string ToString()
{
return string.Format( "{0}.{1}.{2}", m_major, m_minor, m_release ) + StageSuffix + TrialSuffix;
}
public int Number { get { return m_major * 100 + m_minor * 10 + m_release; } }
[SerializeField] private int m_major;
[SerializeField] private int m_minor;
[SerializeField] private int m_release;
VersionInfo()
{
m_major = Major;
m_minor = Minor;
m_release = Release;
}
VersionInfo( byte major, byte minor, byte release )
{
m_major = major;
m_minor = minor;
m_release = release;
}
public static VersionInfo Current()
{
return new VersionInfo( Major, Minor, Release );
}
public static bool Matches( VersionInfo version )
{
return ( Major == version.m_major ) && ( Minor == version.m_minor ) && ( Release == version.m_release );
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 5e5b349ef10703d459eecdd138c96ea7
timeCreated: 1432119206
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,450 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.Serialization;
using System;
using System.Linq;
namespace AmplifyColor
{
[Serializable]
public class VolumeEffectField
{
public string fieldName;
public string fieldType;
public System.Single valueSingle;
public UnityEngine.Color valueColor;
public System.Boolean valueBoolean;
public UnityEngine.Vector2 valueVector2;
public UnityEngine.Vector3 valueVector3;
public UnityEngine.Vector4 valueVector4;
public VolumeEffectField( string fieldName, string fieldType )
{
this.fieldName = fieldName;
this.fieldType = fieldType;
}
public VolumeEffectField( FieldInfo pi, Component c )
: this( pi.Name, pi.FieldType.FullName )
{
object val = pi.GetValue( c );
UpdateValue( val );
}
public static bool IsValidType( string type )
{
switch ( type )
{
case "System.Single":
case "System.Boolean":
case "UnityEngine.Color":
case "UnityEngine.Vector2":
case "UnityEngine.Vector3":
case "UnityEngine.Vector4":
return true;
}
return false;
}
public void UpdateValue( object val )
{
switch ( fieldType )
{
case "System.Single": valueSingle = ( System.Single ) val; break;
case "System.Boolean": valueBoolean = ( System.Boolean ) val; break;
case "UnityEngine.Color": valueColor = ( UnityEngine.Color ) val; break;
case "UnityEngine.Vector2": valueVector2 = ( UnityEngine.Vector2 ) val; break;
case "UnityEngine.Vector3": valueVector3 = ( UnityEngine.Vector3 ) val; break;
case "UnityEngine.Vector4": valueVector4 = ( UnityEngine.Vector4 ) val; break;
}
}
}
[Serializable]
public class VolumeEffectComponent
{
public string componentName;
public List<VolumeEffectField> fields;
public VolumeEffectComponent( string name )
{
componentName = name;
fields = new List<VolumeEffectField>();
}
public VolumeEffectField AddField( FieldInfo pi, Component c )
{
return AddField( pi, c, -1 );
}
public VolumeEffectField AddField( FieldInfo pi, Component c, int position )
{
VolumeEffectField field = VolumeEffectField.IsValidType( pi.FieldType.FullName ) ? new VolumeEffectField( pi, c ) : null;
if ( field != null )
{
if ( position < 0 || position >= fields.Count )
fields.Add( field );
else
fields.Insert( position, field );
}
return field;
}
public void RemoveEffectField( VolumeEffectField field )
{
fields.Remove( field );
}
public VolumeEffectComponent( Component c, VolumeEffectComponentFlags compFlags )
: this( compFlags.componentName )
{
foreach ( VolumeEffectFieldFlags fieldFlags in compFlags.componentFields )
{
if ( !fieldFlags.blendFlag )
continue;
#if !UNITY_EDITOR && UNITY_METRO
FieldInfo pi = c.GetType ().GetRuntimeField (fieldFlags.fieldName);
#else
FieldInfo pi = c.GetType().GetField( fieldFlags.fieldName );
#endif
VolumeEffectField field = VolumeEffectField.IsValidType( pi.FieldType.FullName ) ? new VolumeEffectField( pi, c ) : null;
if ( field != null )
fields.Add( field );
}
}
public void UpdateComponent( Component c, VolumeEffectComponentFlags compFlags )
{
foreach ( VolumeEffectFieldFlags fieldFlags in compFlags.componentFields )
{
if ( !fieldFlags.blendFlag )
continue;
if ( !fields.Exists( s => s.fieldName == fieldFlags.fieldName ) )
{
#if !UNITY_EDITOR && UNITY_METRO
FieldInfo pi=c.GetType().GetRuntimeField(fieldFlags.fieldName);
#else
FieldInfo pi = c.GetType().GetField( fieldFlags.fieldName );
#endif
VolumeEffectField field = VolumeEffectField.IsValidType( pi.FieldType.FullName ) ? new VolumeEffectField( pi, c ) : null;
if ( field != null )
fields.Add( field );
}
}
}
public VolumeEffectField FindEffectField( string fieldName )
{
for ( int i = 0; i < fields.Count; i++ )
{
if ( fields[ i ].fieldName == fieldName )
return fields[ i ];
}
return null;
}
public static FieldInfo[] ListAcceptableFields( Component c )
{
if ( c == null )
return new FieldInfo[ 0 ];
#if !UNITY_EDITOR && UNITY_METRO
FieldInfo[] fields=c.GetType().GetRuntimeFields().ToArray();
#else
FieldInfo[] fields = c.GetType().GetFields();
#endif
return ( fields.Where( f => VolumeEffectField.IsValidType( f.FieldType.FullName ) ) ).ToArray();
}
public string[] GetFieldNames()
{
return ( from r in fields select r.fieldName ).ToArray();
}
}
[Serializable]
public class VolumeEffect
{
public AmplifyColorBase gameObject;
public List<VolumeEffectComponent> components;
public VolumeEffect( AmplifyColorBase effect )
{
gameObject = effect;
components = new List<VolumeEffectComponent>();
}
public static VolumeEffect BlendValuesToVolumeEffect( VolumeEffectFlags flags, VolumeEffect volume1, VolumeEffect volume2, float blend )
{
VolumeEffect resultVolume = new VolumeEffect( volume1.gameObject );
foreach ( VolumeEffectComponentFlags compFlags in flags.components )
{
if ( !compFlags.blendFlag )
continue;
VolumeEffectComponent ec1 = volume1.FindEffectComponent( compFlags.componentName );
VolumeEffectComponent ec2 = volume2.FindEffectComponent( compFlags.componentName );
if ( ec1 == null || ec2 == null )
continue;
VolumeEffectComponent resultComp = new VolumeEffectComponent( ec1.componentName );
foreach ( VolumeEffectFieldFlags fieldFlags in compFlags.componentFields )
{
if ( fieldFlags.blendFlag )
{
VolumeEffectField ef1 = ec1.FindEffectField( fieldFlags.fieldName );
VolumeEffectField ef2 = ec2.FindEffectField( fieldFlags.fieldName );
if ( ef1 == null || ef2 == null )
continue;
VolumeEffectField resultField = new VolumeEffectField( ef1.fieldName, ef1.fieldType );
switch ( resultField.fieldType )
{
case "System.Single": resultField.valueSingle = Mathf.Lerp( ef1.valueSingle, ef2.valueSingle, blend ); break;
case "System.Boolean": resultField.valueBoolean = ef2.valueBoolean; break;
case "UnityEngine.Vector2": resultField.valueVector2 = Vector2.Lerp( ef1.valueVector2, ef2.valueVector2, blend ); break;
case "UnityEngine.Vector3": resultField.valueVector3 = Vector3.Lerp( ef1.valueVector3, ef2.valueVector3, blend ); break;
case "UnityEngine.Vector4": resultField.valueVector4 = Vector4.Lerp( ef1.valueVector4, ef2.valueVector4, blend ); break;
case "UnityEngine.Color": resultField.valueColor = Color.Lerp( ef1.valueColor, ef2.valueColor, blend ); break;
}
resultComp.fields.Add( resultField );
}
}
resultVolume.components.Add( resultComp );
}
return resultVolume;
}
public VolumeEffectComponent AddComponent( Component c, VolumeEffectComponentFlags compFlags )
{
if ( compFlags == null )
{
VolumeEffectComponent created = new VolumeEffectComponent( c.GetType() + "" );
components.Add( created );
return created;
}
else
{
VolumeEffectComponent component;
if ( ( component = FindEffectComponent( c.GetType() + "" ) ) != null )
{
component.UpdateComponent( c, compFlags );
return component;
}
else
{
VolumeEffectComponent created = new VolumeEffectComponent( c, compFlags );
components.Add( created );
return created;
}
}
}
public void RemoveEffectComponent( VolumeEffectComponent comp )
{
components.Remove( comp );
}
public void UpdateVolume()
{
if ( gameObject == null )
return;
VolumeEffectFlags effectFlags = gameObject.EffectFlags;
foreach ( VolumeEffectComponentFlags compFlags in effectFlags.components )
{
if ( !compFlags.blendFlag )
continue;
Component c = gameObject.GetComponent( compFlags.componentName );
if ( c != null )
AddComponent( c, compFlags );
}
}
public void SetValues( AmplifyColorBase targetColor )
{
VolumeEffectFlags effectFlags = targetColor.EffectFlags;
GameObject go = targetColor.gameObject;
foreach ( VolumeEffectComponentFlags compFlags in effectFlags.components )
{
if ( !compFlags.blendFlag )
continue;
Component c = go.GetComponent( compFlags.componentName );
VolumeEffectComponent effectComp = FindEffectComponent( compFlags.componentName );
if ( c == null || effectComp == null )
continue;
foreach ( VolumeEffectFieldFlags fieldFlags in compFlags.componentFields )
{
if ( !fieldFlags.blendFlag )
continue;
#if !UNITY_EDITOR && UNITY_METRO
FieldInfo fi = c.GetType().GetRuntimeField(fieldFlags.fieldName);
#else
FieldInfo fi = c.GetType().GetField( fieldFlags.fieldName );
#endif
VolumeEffectField effectField = effectComp.FindEffectField( fieldFlags.fieldName );
if ( fi == null || effectField == null )
continue;
switch ( fi.FieldType.FullName )
{
case "System.Single": fi.SetValue( c, effectField.valueSingle ); break;
case "System.Boolean": fi.SetValue( c, effectField.valueBoolean ); break;
case "UnityEngine.Vector2": fi.SetValue( c, effectField.valueVector2 ); break;
case "UnityEngine.Vector3": fi.SetValue( c, effectField.valueVector3 ); break;
case "UnityEngine.Vector4": fi.SetValue( c, effectField.valueVector4 ); break;
case "UnityEngine.Color": fi.SetValue( c, effectField.valueColor ); break;
}
}
}
}
public void BlendValues( AmplifyColorBase targetColor, VolumeEffect other, float blendAmount )
{
VolumeEffectFlags effectFlags = targetColor.EffectFlags;
GameObject go = targetColor.gameObject;
for ( int comp = 0; comp < effectFlags.components.Count; comp++ )
{
VolumeEffectComponentFlags compFlags = effectFlags.components[ comp ];
if ( !compFlags.blendFlag )
continue;
Component c = go.GetComponent( compFlags.componentName );
VolumeEffectComponent effectComp = FindEffectComponent( compFlags.componentName );
VolumeEffectComponent effectCompOther = other.FindEffectComponent( compFlags.componentName );
if ( c == null || effectComp == null || effectCompOther == null )
continue;
for ( int i = 0; i < compFlags.componentFields.Count; i++ )
{
VolumeEffectFieldFlags fieldFlags = compFlags.componentFields[ i ];
if ( !fieldFlags.blendFlag )
continue;
#if !UNITY_EDITOR && UNITY_METRO
FieldInfo fi = c.GetType().GetRuntimeField(fieldFlags.fieldName);
#else
FieldInfo fi = c.GetType().GetField( fieldFlags.fieldName );
#endif
VolumeEffectField effectField = effectComp.FindEffectField( fieldFlags.fieldName );
VolumeEffectField effectFieldOther = effectCompOther.FindEffectField( fieldFlags.fieldName );
if ( fi == null || effectField == null || effectFieldOther == null )
continue;
switch ( fi.FieldType.FullName )
{
case "System.Single": fi.SetValue( c, Mathf.Lerp( effectField.valueSingle, effectFieldOther.valueSingle, blendAmount ) ); break;
case "System.Boolean": fi.SetValue( c, effectFieldOther.valueBoolean ); break;
case "UnityEngine.Vector2": fi.SetValue( c, Vector2.Lerp( effectField.valueVector2, effectFieldOther.valueVector2, blendAmount ) ); break;
case "UnityEngine.Vector3": fi.SetValue( c, Vector3.Lerp( effectField.valueVector3, effectFieldOther.valueVector3, blendAmount ) ); break;
case "UnityEngine.Vector4": fi.SetValue( c, Vector4.Lerp( effectField.valueVector4, effectFieldOther.valueVector4, blendAmount ) ); break;
case "UnityEngine.Color": fi.SetValue( c, Color.Lerp( effectField.valueColor, effectFieldOther.valueColor, blendAmount ) ); break;
}
}
}
}
public VolumeEffectComponent FindEffectComponent( string compName )
{
for ( int i = 0; i < components.Count; i++ )
{
if ( components[ i ].componentName == compName )
return components[ i ];
}
return null;
}
public static Component[] ListAcceptableComponents( AmplifyColorBase go )
{
if ( go == null )
return new Component[ 0 ];
Component[] comps = go.GetComponents( typeof( Component ) );
return ( comps.Where( comp => comp != null && ( !( ( comp.GetType() + "" ).StartsWith( "UnityEngine." ) || comp.GetType() == typeof( AmplifyColorBase ) ) ) ) ).ToArray();
}
public string[] GetComponentNames()
{
return ( from r in components select r.componentName ).ToArray();
}
}
[Serializable]
public class VolumeEffectContainer
{
public List<VolumeEffect> volumes;
public VolumeEffectContainer()
{
volumes = new List<VolumeEffect>();
}
public void AddColorEffect( AmplifyColorBase colorEffect )
{
VolumeEffect volume;
if ( ( volume = FindVolumeEffect( colorEffect ) ) != null )
volume.UpdateVolume();
else
{
volume = new VolumeEffect( colorEffect );
volumes.Add( volume );
volume.UpdateVolume();
}
}
public VolumeEffect AddJustColorEffect( AmplifyColorBase colorEffect )
{
VolumeEffect created = new VolumeEffect( colorEffect );
volumes.Add( created );
return created;
}
public VolumeEffect FindVolumeEffect( AmplifyColorBase colorEffect )
{
// find by reference first
for ( int i = 0; i < volumes.Count; i++ )
{
if ( volumes[ i ].gameObject == colorEffect )
return volumes[ i ];
}
// in case reference fails, find by instance id (e.g. instantiated prefabs)
for ( int i = 0; i < volumes.Count; i++ )
{
if ( volumes[ i ].gameObject != null && volumes[ i ].gameObject.SharedInstanceID == colorEffect.SharedInstanceID )
return volumes[ i ];
}
// not found
return null;
}
public void RemoveVolumeEffect( VolumeEffect volume )
{
volumes.Remove( volume );
}
public AmplifyColorBase[] GetStoredEffects()
{
return ( from r in volumes select r.gameObject ).ToArray();
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 7d3fd1d6655eb04499053fa75ba87ace
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -0,0 +1,178 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
using System.Reflection;
using System.Linq;
namespace AmplifyColor
{
[Serializable]
public class VolumeEffectFieldFlags
{
public string fieldName;
public string fieldType;
public bool blendFlag = false;
public VolumeEffectFieldFlags( FieldInfo pi )
{
fieldName = pi.Name;
fieldType = pi.FieldType.FullName;
}
public VolumeEffectFieldFlags( VolumeEffectField field )
{
fieldName = field.fieldName;
fieldType = field.fieldType;
blendFlag = true; // why?...
}
}
[Serializable]
public class VolumeEffectComponentFlags
{
public string componentName;
public List<VolumeEffectFieldFlags> componentFields;
public bool blendFlag = false;
public VolumeEffectComponentFlags( string name )
{
componentName = name;
componentFields = new List<VolumeEffectFieldFlags>();
}
public VolumeEffectComponentFlags( VolumeEffectComponent comp )
: this( comp.componentName )
{
blendFlag = true;
foreach ( VolumeEffectField field in comp.fields )
{
if ( VolumeEffectField.IsValidType( field.fieldType ) )
componentFields.Add( new VolumeEffectFieldFlags( field ) );
}
}
public VolumeEffectComponentFlags( Component c )
: this( c.GetType() + "" )
{
#if !UNITY_EDITOR && UNITY_METRO
FieldInfo[] fields=c.GetType().GetRuntimeFields().ToArray();
#else
FieldInfo[] fields = c.GetType().GetFields();
#endif
foreach ( FieldInfo pi in fields )
{
if ( VolumeEffectField.IsValidType( pi.FieldType.FullName ) )
componentFields.Add( new VolumeEffectFieldFlags( pi ) );
}
}
public void UpdateComponentFlags( VolumeEffectComponent comp )
{
foreach ( VolumeEffectField field in comp.fields )
{
if ( componentFields.Find( s => s.fieldName == field.fieldName ) == null && VolumeEffectField.IsValidType( field.fieldType ) )
componentFields.Add( new VolumeEffectFieldFlags( field ) );
}
}
public void UpdateComponentFlags( Component c )
{
#if !UNITY_EDITOR && UNITY_METRO
FieldInfo[] fields=c.GetType().GetRuntimeFields().ToArray();
#else
FieldInfo[] fields = c.GetType().GetFields();
#endif
foreach ( FieldInfo pi in fields )
{
if ( !componentFields.Exists( s => s.fieldName == pi.Name ) && VolumeEffectField.IsValidType( pi.FieldType.FullName ) )
componentFields.Add( new VolumeEffectFieldFlags( pi ) );
}
}
public string[] GetFieldNames()
{
return ( from r in componentFields where r.blendFlag select r.fieldName ).ToArray();
}
}
[Serializable]
public class VolumeEffectFlags
{
public List<VolumeEffectComponentFlags> components;
public VolumeEffectFlags()
{
components = new List<VolumeEffectComponentFlags>();
}
public void AddComponent( Component c )
{
VolumeEffectComponentFlags componentFlags;
if ( ( componentFlags = components.Find( s => s.componentName == c.GetType() + "" ) ) != null )
componentFlags.UpdateComponentFlags( c );
else
components.Add( new VolumeEffectComponentFlags( c ) );
}
public void UpdateFlags( VolumeEffect effectVol )
{
foreach ( VolumeEffectComponent comp in effectVol.components )
{
VolumeEffectComponentFlags compFlags = null;
if ( ( compFlags = components.Find( s => s.componentName == comp.componentName ) ) == null )
components.Add( new VolumeEffectComponentFlags( comp ) );
else
compFlags.UpdateComponentFlags( comp );
}
}
public static void UpdateCamFlags( AmplifyColorBase[] effects, AmplifyColorVolumeBase[] volumes )
{
foreach ( AmplifyColorBase effect in effects )
{
effect.EffectFlags = new VolumeEffectFlags();
foreach ( AmplifyColorVolumeBase volume in volumes )
{
VolumeEffect effectVolume = volume.EffectContainer.FindVolumeEffect( effect );
if ( effectVolume != null )
effect.EffectFlags.UpdateFlags( effectVolume );
}
}
}
public VolumeEffect GenerateEffectData( AmplifyColorBase go )
{
VolumeEffect result = new VolumeEffect( go );
foreach ( VolumeEffectComponentFlags compFlags in components )
{
if ( !compFlags.blendFlag )
continue;
Component c = go.GetComponent( compFlags.componentName );
if ( c != null )
result.AddComponent( c, compFlags );
}
return result;
}
public VolumeEffectComponentFlags FindComponentFlags( string compName )
{
for ( int i = 0; i < components.Count; i++ )
{
if ( components[ i ].componentName == compName )
return components[ i ];
}
return null;
}
public string[] GetComponentNames()
{
return ( from r in components where r.blendFlag select r.componentName ).ToArray();
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 0b8c14f1da8837b42bc65996a3507400
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -0,0 +1,81 @@
About
Amplify Color (c) Amplify Creations, Lda. All rights reserved.
Amplify Color is an Advanced Color Grading extension for Unity Pro
Redistribution of Amplify Color is frowned upon. If you want to share the
software, please refer others to the official download page:
http://amplify.pt/unity/amplify-color
Description
Amplify Color, previously known as Color3 Advanced Grading, brings industry-level
color grading to your game by mimicking the color transforms made inside a tool
like Photoshop; e.g. change contrast, color curves, exposure, saturation, hue and
more, or a combination of all transforms at once. So fast, it runs on mobile.
Features
* Advanced color grading
* High-performance and Mobile-ready
* Semi-automated Photoshop workflow
* File-based standard workflow
* Dynamic blending between profiles
* Texture-based per-pixel masking
* Depth-based masking
* Filmic tone mapping
* 2D and 3D volume effect triggers
Supported Platforms
* All platforms
Minimum Requirements
Software
Unity 4.6.8f1
Quick Guide
1) Export a reference screenshot from Unity, using "Window/Amplify Color/LUT Editor"
2) Open reference screenshot in your favorite image editing software
3) Apply any color changes you desire. E.g. hue, exposure
4) Save and load it into Unity using "Window/Amplify Color/LUT Editor"
5) Amplify Color automatically generates a texture containing a color grading
look-up-table (LUT).
6) Apply a "Amplify Color" component to your main camera.
7) Assign the previously generated LUT texture to the effect
8) Enjoy changes you made to the reference screenshot applied to every frame of your game.
Documentation
Please refer to the following website for an up-to-date online manual:
http://amplify.pt/unity/amplify-color/manual
Feedback
To file error reports, questions or suggestions, you may use
our feedback form online:
http://amplify.pt/contact
Or contact us directly:
For general inquiries - info@amplify.pt
For technical support - support@amplify.pt (customers only)
Acknowledgements
This project was originally built in partnership with Tiago Carvalho
http://pt.linkedin.com/pub/tiago-carvalho/18/aa1/306

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: eb2e41e7c0fd793468bb8d374d4c40fa

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: af380f538edd08c4d8f107ad2daa59ff

View File

@ -0,0 +1,120 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
Shader "Hidden/Amplify Color/Base"
{
Properties
{
_MainTex ( "Base (RGB)", Any ) = "" {}
_RgbTex ( "LUT (RGB)", 2D ) = "" {}
_LerpRgbTex ( "LerpRGB (RGB)", 2D ) = "" {}
}
CGINCLUDE
#pragma vertex vert
#pragma fragment frag
#include "Common.cginc"
inline float4 frag_ldr_gamma( v2f i, const bool mobile )
{
init_frag( i );
float4 color = fetch_process_ldr_gamma( i, mobile );
color = apply( color, mobile );
return output_ldr_gamma( color );
}
inline float4 frag_ldr_linear( v2f i, const bool mobile )
{
init_frag( i );
float4 color = fetch_process_ldr_linear( i, mobile );
color = apply( color, mobile );
return output_ldr_linear( color );
}
inline float4 frag_hdr_gamma( v2f i, const bool mobile, const bool dithering, const int tonemapper )
{
init_frag( i );
float4 color = fetch_process_hdr_gamma( i, mobile, dithering, tonemapper );
color = apply( color, mobile );
return output_hdr_gamma( color );
}
inline float4 frag_hdr_linear( v2f i, const bool mobile, const bool dithering, const int tonemapper )
{
init_frag( i );
float4 color = fetch_process_hdr_linear( i, mobile, dithering, tonemapper );
color = apply( color, mobile );
return output_hdr_linear( color );
}
ENDCG
Subshader
{
ZTest Always Cull Off ZWrite Off Blend Off Fog { Mode off }
// -- QUALITY NORMAL --------------------------------------------------------------
// 0 => LDR GAMMA
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_ldr_gamma( i, false ); } ENDCG }
// 1 => LDR LINEAR
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_ldr_linear( i, false ); } ENDCG }
// 2-5 => HDR GAMMA / DITHERING: OFF
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, false, TONEMAPPING_DISABLED ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, false, TONEMAPPING_PHOTO ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, false, TONEMAPPING_HABLE ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, false, TONEMAPPING_ACES ); } ENDCG }
// 6-9 => HDR GAMMA / DITHERING: ON
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, true, TONEMAPPING_DISABLED ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, true, TONEMAPPING_PHOTO ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, true, TONEMAPPING_HABLE ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, true, TONEMAPPING_ACES ); } ENDCG }
// 10-13 => HDR LINEAR / DITHERING: OFF
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, false, TONEMAPPING_DISABLED ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, false, TONEMAPPING_PHOTO ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, false, TONEMAPPING_HABLE ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, false, TONEMAPPING_ACES ); } ENDCG }
// 14-17 => HDR LINEAR / DITHERING: ON
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, true, TONEMAPPING_DISABLED ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, true, TONEMAPPING_PHOTO ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, true, TONEMAPPING_HABLE ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, true, TONEMAPPING_ACES ); } ENDCG }
// -- QUALITY MOBILE --------------------------------------------------------------
// 18 => LDR GAMMA
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_ldr_gamma( i, true ); } ENDCG }
// 19 => LDR LINEAR
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_ldr_linear( i, true ); } ENDCG }
// 20-23 => HDR GAMMA / DITHERING: OFF
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, false, TONEMAPPING_DISABLED ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, false, TONEMAPPING_PHOTO ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, false, TONEMAPPING_HABLE ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, false, TONEMAPPING_ACES ); } ENDCG }
// 24-27 => HDR GAMMA / DITHERING: ON
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, true, TONEMAPPING_DISABLED ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, true, TONEMAPPING_PHOTO ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, true, TONEMAPPING_HABLE ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, true, TONEMAPPING_ACES ); } ENDCG }
// 28-31 => HDR LINEAR / DITHERING: OFF
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, false, TONEMAPPING_DISABLED ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, false, TONEMAPPING_PHOTO ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, false, TONEMAPPING_HABLE ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, false, TONEMAPPING_ACES ); } ENDCG }
// 32-35 => HDR LINEAR / DITHERING: ON
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, true, TONEMAPPING_DISABLED ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, true, TONEMAPPING_PHOTO ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, true, TONEMAPPING_HABLE ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, true, TONEMAPPING_ACES ); } ENDCG }
}
Fallback Off
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 68f9938c7bf52e94bb37d6a74297f0ae

View File

@ -0,0 +1,120 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
Shader "Hidden/Amplify Color/Blend"
{
Properties
{
_MainTex ( "Base (RGB)", Any ) = "" {}
_RgbTex ( "LUT (RGB)", 2D ) = "" {}
_RgbBlendCacheTex ( "RgbBlendCache (RGB)", 2D ) = "" {}
}
CGINCLUDE
#pragma vertex vert
#pragma fragment frag
#include "Common.cginc"
inline float4 frag_ldr_gamma( v2f i, const bool mobile )
{
init_frag( i );
float4 color = fetch_process_ldr_gamma( i, mobile );
color = apply_blend( color, mobile );
return output_ldr_gamma( color );
}
inline float4 frag_ldr_linear( v2f i, const bool mobile )
{
init_frag( i );
float4 color = fetch_process_ldr_linear( i, mobile );
color = apply_blend( color, mobile );
return output_ldr_linear( color );
}
inline float4 frag_hdr_gamma( v2f i, const bool mobile, const bool dithering, const int tonemapper )
{
init_frag( i );
float4 color = fetch_process_hdr_gamma( i, mobile, dithering, tonemapper );
color = apply_blend( color, mobile );
return output_hdr_gamma( color );
}
inline float4 frag_hdr_linear( v2f i, const bool mobile, const bool dithering, const int tonemapper )
{
init_frag( i );
float4 color = fetch_process_hdr_linear( i, mobile, dithering, tonemapper );
color = apply_blend( color, mobile );
return output_hdr_linear( color );
}
ENDCG
Subshader
{
ZTest Always Cull Off ZWrite Off Blend Off Fog { Mode off }
// -- QUALITY NORMAL --------------------------------------------------------------
// 0 => LDR GAMMA
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_ldr_gamma( i, false ); } ENDCG }
// 1 => LDR LINEAR
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_ldr_linear( i, false ); } ENDCG }
// 2-5 => HDR GAMMA / DITHERING: OFF
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, false, TONEMAPPING_DISABLED ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, false, TONEMAPPING_PHOTO ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, false, TONEMAPPING_HABLE ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, false, TONEMAPPING_ACES ); } ENDCG }
// 6-9 => HDR GAMMA / DITHERING: ON
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, true, TONEMAPPING_DISABLED ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, true, TONEMAPPING_PHOTO ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, true, TONEMAPPING_HABLE ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, true, TONEMAPPING_ACES ); } ENDCG }
// 10-13 => HDR LINEAR / DITHERING: OFF
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, false, TONEMAPPING_DISABLED ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, false, TONEMAPPING_PHOTO ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, false, TONEMAPPING_HABLE ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, false, TONEMAPPING_ACES ); } ENDCG }
// 14-17 => HDR LINEAR / DITHERING: ON
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, true, TONEMAPPING_DISABLED ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, true, TONEMAPPING_PHOTO ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, true, TONEMAPPING_HABLE ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, true, TONEMAPPING_ACES ); } ENDCG }
// -- QUALITY MOBILE --------------------------------------------------------------
// 18 => LDR GAMMA
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_ldr_gamma( i, true ); } ENDCG }
// 19 => LDR LINEAR
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_ldr_linear( i, true ); } ENDCG }
// 20-23 => HDR GAMMA / DITHERING: OFF
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, false, TONEMAPPING_DISABLED ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, false, TONEMAPPING_PHOTO ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, false, TONEMAPPING_HABLE ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, false, TONEMAPPING_ACES ); } ENDCG }
// 24-27 => HDR GAMMA / DITHERING: ON
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, true, TONEMAPPING_DISABLED ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, true, TONEMAPPING_PHOTO ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, true, TONEMAPPING_HABLE ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, true, TONEMAPPING_ACES ); } ENDCG }
// 28-31 => HDR LINEAR / DITHERING: OFF
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, false, TONEMAPPING_DISABLED ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, false, TONEMAPPING_PHOTO ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, false, TONEMAPPING_HABLE ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, false, TONEMAPPING_ACES ); } ENDCG }
// 32-35 => HDR LINEAR / DITHERING: ON
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, true, TONEMAPPING_DISABLED ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, true, TONEMAPPING_PHOTO ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, true, TONEMAPPING_HABLE ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, true, TONEMAPPING_ACES ); } ENDCG }
}
Fallback Off
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: ce4cea5500fd1664ab8ec906187a8f6e

View File

@ -0,0 +1,36 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
Shader "Hidden/Amplify Color/BlendCache"
{
Properties
{
_MainTex ( "Base (RGB)", Any ) = "" {}
_RgbTex ( "LUT (RGB)", 2D ) = "" {}
_LerpRgbTex ( "LerpRGB (RGB)", 2D ) = "" {}
}
Subshader
{
ZTest Always Cull Off ZWrite Off Blend Off Fog { Mode off }
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "Common.cginc"
float4 frag( v2f i ) : SV_Target
{
float4 lut1 = tex2D( _RgbTex, i.uv01.xy );
float4 lut2 = tex2D( _LerpRgbTex, i.uv01.xy );
return lerp( lut1, lut2, _LerpAmount );
}
ENDCG
}
}
Fallback Off
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 9f3f6f752b5025443bac6d8a81d38478

View File

@ -0,0 +1,380 @@
// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
#ifndef AMPLIFY_COLOR_COMMON_INCLUDED
#define AMPLIFY_COLOR_COMMON_INCLUDED
#include "UnityCG.cginc"
// Enabling Stereo adjustment in versions prior to 4.5
#ifndef UnityStereoScreenSpaceUVAdjust
#ifdef UNITY_SINGLE_PASS_STEREO
inline float2 UnityStereoScreenSpaceUVAdjustInternal ( float2 uv, float4 scaleAndOffset )
{
return saturate ( uv.xy ) * scaleAndOffset.xy + scaleAndOffset.zw;
}
inline float4 UnityStereoScreenSpaceUVAdjustInternal ( float4 uv, float4 scaleAndOffset )
{
return float4( UnityStereoScreenSpaceUVAdjustInternal ( uv.xy, scaleAndOffset ), UnityStereoScreenSpaceUVAdjustInternal ( uv.zw, scaleAndOffset ) );
}
#define UnityStereoScreenSpaceUVAdjust(x, y) UnityStereoScreenSpaceUVAdjustInternal(x, y)
#else
#define UnityStereoScreenSpaceUVAdjust(x, y) x
#endif
#endif
#ifndef UNITY_DECLARE_SCREENSPACE_TEXTURE
#define UNITY_DECLARE_SCREENSPACE_TEXTURE( tex ) sampler2D tex;
#endif
#ifndef UNITY_SAMPLE_SCREENSPACE_TEXTURE
#define UNITY_SAMPLE_SCREENSPACE_TEXTURE tex2D
#endif
#ifndef UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX
#define UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( x )
#endif
UNITY_DECLARE_SCREENSPACE_TEXTURE( _MainTex );
uniform float4 _MainTex_TexelSize;
uniform float4 _MainTex_ST;
uniform float4 _StereoScale;
uniform sampler2D _RgbTex;
uniform sampler2D _LerpRgbTex;
uniform sampler2D _RgbBlendCacheTex;
uniform sampler2D _MaskTex;
uniform float4 _MaskTex_TexelSize;
#if UNITY_VERSION >= 560
UNITY_DECLARE_DEPTH_TEXTURE( _CameraDepthTexture );
#else
sampler2D_float _CameraDepthTexture;
#endif
uniform sampler2D _DepthCurveLut;
uniform float _LerpAmount;
uniform float _Exposure;
uniform float _ShoulderStrength;
uniform float _LinearStrength;
uniform float _LinearAngle;
uniform float _ToeStrength;
uniform float _ToeNumerator;
uniform float _ToeDenominator;
uniform float _LinearWhite;
inline float4 CustomObjectToClipPos( in float3 pos )
{
#if UNITY_VERSION >= 540
return UnityObjectToClipPos( pos );
#else
return mul( UNITY_MATRIX_VP, mul( unity_ObjectToWorld, float4( pos, 1.0 ) ) );
#endif
}
// Enabling Stereo adjustment in versions prior to 4.5
#ifndef UnityStereoScreenSpaceUVAdjust
#ifdef UNITY_SINGLE_PASS_STEREO
inline float2 UnityStereoScreenSpaceUVAdjustInternal ( float2 uv, float4 scaleAndOffset )
{
return saturate ( uv.xy ) * scaleAndOffset.xy + scaleAndOffset.zw;
}
inline float4 UnityStereoScreenSpaceUVAdjustInternal ( float4 uv, float4 scaleAndOffset )
{
return float4( UnityStereoScreenSpaceUVAdjustInternal ( uv.xy, scaleAndOffset ), UnityStereoScreenSpaceUVAdjustInternal ( uv.zw, scaleAndOffset ) );
}
#define UnityStereoScreenSpaceUVAdjust(x, y) UnityStereoScreenSpaceUVAdjustInternal(x, y)
#else
#define UnityStereoScreenSpaceUVAdjust(x, y) x
#endif
#endif
struct appdata
{
float4 vertex : POSITION;
half2 texcoord : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos : SV_POSITION;
float4 screenPos : TEXCOORD0;
float4 uv01 : TEXCOORD1;
float4 uv01Stereo : TEXCOORD2;
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert( appdata v )
{
v2f o;
UNITY_SETUP_INSTANCE_ID( v );
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( o );
o.pos = CustomObjectToClipPos( v.vertex );
o.screenPos = ComputeScreenPos( o.pos );
o.uv01.xy = v.texcoord.xy;
o.uv01.zw = v.texcoord.xy;
#if defined( UNITY_UV_STARTS_AT_TOP )
if ( _MainTex_TexelSize.y < 0 )
o.uv01.w = 1 - o.uv01.w;
#endif
#if defined( UNITY_HALF_TEXEL_OFFSET )
o.uv01.zw += _MaskTex_TexelSize.xy * float2( -0.5, 0.5 );
#endif
o.uv01Stereo = UnityStereoScreenSpaceUVAdjust( o.uv01, _MainTex_ST );
return o;
}
inline float4 to_srgb( float4 c )
{
c.rgb = max( 1.055 * pow( c.rgb, 0.416666667 ) - 0.055, 0 );
return c;
}
inline float4 to_linear( float4 c )
{
c.rgb = c.rgb * ( c.rgb * ( c.rgb * 0.305306011 + 0.682171111 ) + 0.012522878 );
return c;
}
#define TONEMAPPING_DISABLED ( 0 )
#define TONEMAPPING_PHOTO ( 1 )
#define TONEMAPPING_HABLE ( 2 )
#define TONEMAPPING_ACES ( 3 )
inline float3 tonemap_photo( float3 color )
{
color *= _Exposure;
return 1.0 - exp2( -color );
}
inline float3 tonemap_hable( float3 color )
{
// Uncharted 2 tone mapping operator, by John Hable
// http://www.gdcvault.com/play/1012459/Uncharted_2__HDR_Lighting
// http://filmicgames.com/archives/75
const float A = _ShoulderStrength;
const float B = _LinearStrength;
const float C = _LinearAngle;
const float D = _ToeStrength;
const float E = _ToeNumerator;
const float F = _ToeDenominator;
const float W = _LinearWhite;
float4 x = float4( color.rgb * _Exposure * 2.0, _LinearWhite );
x = ( ( x * ( A * x + C * B ) + D * E ) / ( x * ( A * x + B ) + D * F ) ) - E / F;
return x.rgb / x.w;
}
inline float3 tonemap_aces( float3 color )
{
// ACES Filmic Tone Mapping Curve, by Krzysztof Narkowicz
// https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/
color *= _Exposure;
const float a = 2.51;
const float b = 0.03;
const float c = 2.43;
const float d = 0.59;
const float e = 0.14;
return saturate( ( color * ( a * color + b ) ) / ( color * ( c * color + d ) + e ) );
}
inline float3 tonemap( const int tonemapper, float3 color )
{
if ( tonemapper == TONEMAPPING_PHOTO )
{
color.rgb = tonemap_photo( color.rgb );
}
else if ( tonemapper == TONEMAPPING_HABLE )
{
color.rgb = tonemap_hable( color.rgb );
}
else if ( tonemapper == TONEMAPPING_ACES )
{
color.rgb = tonemap_aces( color.rgb );
}
else
{
color.rgb *= _Exposure;
}
return color;
}
inline float4 safe_tex2D( sampler2D tex, float2 uv )
{
#if ( UNITY_VERSION >= 540 ) && !defined( SHADER_API_D3D11_9X )
return tex2Dlod( tex, float4( uv, 0, 0 ) );
#else
return tex2D( tex, uv );
#endif
}
inline float3 screen_space_dither( float4 screenPos )
{
// Iestyn's RGB dither (7 asm instructions) from Portal 2 X360, slightly modified for VR
// http://alex.vlachos.com/graphics/Alex_Vlachos_Advanced_VR_Rendering_GDC2015.pdf
float3 d = dot( float2( 171.0, 231.0 ), UNITY_PROJ_COORD( screenPos ).xy * _MainTex_TexelSize.zw ).xxx;
d.rgb = frac( d.rgb / float3( 103.0, 71.0, 97.0 ) ) - float3( 0.5, 0.5, 0.5 );
return d.rgb / 255.0;
}
inline void init_frag( inout v2f i )
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( i );
}
inline float4 fetch_process_ldr_gamma( v2f i, const bool mobile )
{
// fetch
float4 color = UNITY_SAMPLE_SCREENSPACE_TEXTURE( _MainTex, i.uv01Stereo.xy );
// clamp
if ( mobile )
{
color.rgb = min( ( 0.999 ).xxx, color.rgb ); // dev/hw compatibility
}
return color;
}
inline float4 fetch_process_ldr_linear( v2f i, const bool mobile )
{
// fetch
float4 color = UNITY_SAMPLE_SCREENSPACE_TEXTURE( _MainTex, i.uv01Stereo.xy );
// convert to gamma
color = to_srgb( color );
// clamp
if ( mobile )
{
color.rgb = min( ( 0.999 ).xxx, color.rgb ); // dev/hw compatibility
}
return color;
}
inline float4 fetch_process_hdr_gamma( v2f i, const bool mobile, const bool dithering, const int tonemapper )
{
// fetch
float4 color = UNITY_SAMPLE_SCREENSPACE_TEXTURE( _MainTex, i.uv01Stereo.xy );
// tonemap
color.rgb = tonemap( tonemapper, color.rgb );
// dither
if ( dithering )
{
color.rgb += screen_space_dither( i.screenPos );
}
// clamp
if ( mobile )
{
color.rgb = clamp( ( 0.0 ).xxx, ( 0.999 ).xxx, color.rgb ); // dev/hw compatibility
}
else
{
color.rgb = saturate( color.rgb );
}
return color;
}
inline float4 fetch_process_hdr_linear( v2f i, const bool mobile, const bool dithering, const int tonemapper )
{
// fetch
float4 color = UNITY_SAMPLE_SCREENSPACE_TEXTURE( _MainTex, i.uv01Stereo.xy );
// tonemap
color.rgb = tonemap( tonemapper, color.rgb );
// convert to gamma
color = to_srgb( color );
// dither
if ( dithering )
{
color.rgb += screen_space_dither( i.screenPos );
}
// clamp
if ( mobile )
{
color.rgb = clamp( ( 0.0 ).xxx, ( 0.999 ).xxx, color.rgb ); // dev/hw compatibility
}
else
{
color.rgb = saturate( color.rgb );
}
return color;
}
inline float4 output_ldr_gamma( float4 color )
{
return color;
}
inline float4 output_hdr_gamma( float4 color )
{
return color;
}
inline float4 output_ldr_linear( float4 color )
{
return to_linear( color );
}
inline float4 output_hdr_linear( float4 color )
{
return to_linear( color );
}
inline float3 apply_lut( float3 color, sampler2D lut, const bool mobile )
{
const float4 coord_scale = float4( 0.0302734375, 0.96875, 31.0, 0.0 );
const float4 coord_offset = float4( 0.00048828125, 0.015625, 0.0, 0.0 );
const float2 texel_height_X0 = float2( 0.03125, 0.0 );
float3 coord = color * coord_scale + coord_offset;
if ( mobile )
{
float3 coord_floor = floor( coord + 0.5 );
float2 coord_bot = coord.xy + coord_floor.zz * texel_height_X0;
color.rgb = safe_tex2D( lut, coord_bot ).rgb;
}
else
{
float3 coord_frac = frac( coord );
float3 coord_floor = coord - coord_frac;
float2 coord_bot = coord.xy + coord_floor.zz * texel_height_X0;
float2 coord_top = coord_bot + texel_height_X0;
float3 lutcol_bot = safe_tex2D( lut, coord_bot ).rgb;
float3 lutcol_top = safe_tex2D( lut, coord_top ).rgb;
color.rgb = lerp( lutcol_bot, lutcol_top, coord_frac.z );
}
return color;
}
inline float4 apply( float4 color, const bool mobile )
{
color.rgb = apply_lut( color.rgb, _RgbTex, mobile );
return color;
}
inline float4 apply_blend( float4 color, const bool mobile )
{
color.rgb = apply_lut( color.rgb, _RgbBlendCacheTex, mobile );
return color;
}
#endif // AMPLIFY_COLOR_COMMON_INCLUDED

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 4b705e0ba3258d04eb414afd584acaa2

View File

@ -0,0 +1,130 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
Shader "Hidden/Amplify Color/DepthMask"
{
Properties
{
_MainTex ( "Base (RGB)", Any ) = "" {}
_RgbTex ( "LUT (RGB)", 2D ) = "" {}
_MaskTex ( "Mask (RGB)", Any ) = "" {}
_DepthCurveLut ( "Depth Curve LUT (RGB)", 2D ) = "" {}
_LerpRgbTex ( "LerpRGB (RGB)", 2D ) = "" {}
}
CGINCLUDE
#pragma vertex vert
#pragma fragment frag
#pragma target 3.0
#include "Common.cginc"
inline float4 apply_grading( v2f i, float4 color, const bool mobile )
{
float depth = Linear01Depth( SAMPLE_DEPTH_TEXTURE( _CameraDepthTexture, i.uv01Stereo.zw ) );
float mask = tex2D( _DepthCurveLut, depth.xx ).a;
return lerp( color, apply( color, mobile ), mask );
}
inline float4 frag_ldr_gamma( v2f i, const bool mobile )
{
init_frag( i );
float4 color = fetch_process_ldr_gamma( i, mobile );
color = apply_grading( i, color, mobile );
return output_ldr_gamma( color );
}
inline float4 frag_ldr_linear( v2f i, const bool mobile )
{
init_frag( i );
float4 color = fetch_process_ldr_linear( i, mobile );
color = apply_grading( i, color, mobile );
return output_ldr_linear( color );
}
inline float4 frag_hdr_gamma( v2f i, const bool mobile, const bool dithering, const int tonemapper )
{
init_frag( i );
float4 color = fetch_process_hdr_gamma( i, mobile, dithering, tonemapper );
color = apply_grading( i, color, mobile );
return output_hdr_gamma( color );
}
inline float4 frag_hdr_linear( v2f i, const bool mobile, const bool dithering, const int tonemapper )
{
init_frag( i );
float4 color = fetch_process_hdr_linear( i, mobile, dithering, tonemapper );
color = apply_grading( i, color, mobile );
return output_hdr_linear( color );
}
ENDCG
Subshader
{
ZTest Always Cull Off ZWrite Off Blend Off Fog { Mode off }
// -- QUALITY NORMAL --------------------------------------------------------------
// 0 => LDR GAMMA
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_ldr_gamma( i, false ); } ENDCG }
// 1 => LDR LINEAR
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_ldr_linear( i, false ); } ENDCG }
// 2-5 => HDR GAMMA / DITHERING: OFF
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, false, TONEMAPPING_DISABLED ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, false, TONEMAPPING_PHOTO ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, false, TONEMAPPING_HABLE ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, false, TONEMAPPING_ACES ); } ENDCG }
// 6-9 => HDR GAMMA / DITHERING: ON
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, true, TONEMAPPING_DISABLED ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, true, TONEMAPPING_PHOTO ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, true, TONEMAPPING_HABLE ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, true, TONEMAPPING_ACES ); } ENDCG }
// 10-13 => HDR LINEAR / DITHERING: OFF
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, false, TONEMAPPING_DISABLED ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, false, TONEMAPPING_PHOTO ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, false, TONEMAPPING_HABLE ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, false, TONEMAPPING_ACES ); } ENDCG }
// 14-17 => HDR LINEAR / DITHERING: ON
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, true, TONEMAPPING_DISABLED ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, true, TONEMAPPING_PHOTO ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, true, TONEMAPPING_HABLE ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, true, TONEMAPPING_ACES ); } ENDCG }
// -- QUALITY MOBILE --------------------------------------------------------------
// 18 => LDR GAMMA
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_ldr_gamma( i, true ); } ENDCG }
// 19 => LDR LINEAR
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_ldr_linear( i, true ); } ENDCG }
// 20-23 => HDR GAMMA / DITHERING: OFF
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, false, TONEMAPPING_DISABLED ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, false, TONEMAPPING_PHOTO ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, false, TONEMAPPING_HABLE ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, false, TONEMAPPING_ACES ); } ENDCG }
// 24-27 => HDR GAMMA / DITHERING: ON
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, true, TONEMAPPING_DISABLED ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, true, TONEMAPPING_PHOTO ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, true, TONEMAPPING_HABLE ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, true, TONEMAPPING_ACES ); } ENDCG }
// 28-31 => HDR LINEAR / DITHERING: OFF
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, false, TONEMAPPING_DISABLED ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, false, TONEMAPPING_PHOTO ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, false, TONEMAPPING_HABLE ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, false, TONEMAPPING_ACES ); } ENDCG }
// 32-35 => HDR LINEAR / DITHERING: ON
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, true, TONEMAPPING_DISABLED ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, true, TONEMAPPING_PHOTO ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, true, TONEMAPPING_HABLE ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, true, TONEMAPPING_ACES ); } ENDCG }
}
Fallback Off
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 91ab9eda50e124647a3851a996917df9
timeCreated: 1437683618
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,130 @@
// Amplify Color - Advanced Color Grading for Unity
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
Shader "Hidden/Amplify Color/DepthMaskBlend"
{
Properties
{
_MainTex ( "Base (RGB)", Any ) = "" {}
_RgbTex ( "LUT (RGB)", 2D ) = "" {}
_MaskTex ( "Mask (RGB)", Any ) = "" {}
_RgbBlendCacheTex ( "RgbBlendCache (RGB)", 2D ) = "" {}
_DepthCurveLut ( "Depth Curve LUT (RGB)", 2D ) = "" {}
}
CGINCLUDE
#pragma vertex vert
#pragma fragment frag
#pragma target 3.0
#include "Common.cginc"
inline float4 apply_grading( v2f i, float4 color, const bool mobile )
{
float depth = Linear01Depth( SAMPLE_DEPTH_TEXTURE( _CameraDepthTexture, i.uv01Stereo.zw ) );
float mask = tex2D( _DepthCurveLut, depth.xx ).a;
return lerp( color, apply_blend( color, mobile ), mask );
}
inline float4 frag_ldr_gamma( v2f i, const bool mobile )
{
init_frag( i );
float4 color = fetch_process_ldr_gamma( i, mobile );
color = apply_grading( i, color, mobile );
return output_ldr_gamma( color );
}
inline float4 frag_ldr_linear( v2f i, const bool mobile )
{
init_frag( i );
float4 color = fetch_process_ldr_linear( i, mobile );
color = apply_grading( i, color, mobile );
return output_ldr_linear( color );
}
inline float4 frag_hdr_gamma( v2f i, bool mobile, const bool dithering, const int tonemapper )
{
init_frag( i );
float4 color = fetch_process_hdr_gamma( i, mobile, dithering, tonemapper );
color = apply_grading( i, color, mobile );
return output_hdr_gamma( color );
}
inline float4 frag_hdr_linear( v2f i, bool mobile, const bool dithering, const int tonemapper )
{
init_frag( i );
float4 color = fetch_process_hdr_linear( i, mobile, dithering, tonemapper );
color = apply_grading( i, color, mobile );
return output_hdr_linear( color );
}
ENDCG
Subshader
{
ZTest Always Cull Off ZWrite Off Blend Off Fog { Mode off }
// -- QUALITY NORMAL --------------------------------------------------------------
// 0 => LDR GAMMA
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_ldr_gamma( i, false ); } ENDCG }
// 1 => LDR LINEAR
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_ldr_linear( i, false ); } ENDCG }
// 2-5 => HDR GAMMA / DITHERING: OFF
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, false, TONEMAPPING_DISABLED ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, false, TONEMAPPING_PHOTO ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, false, TONEMAPPING_HABLE ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, false, TONEMAPPING_ACES ); } ENDCG }
// 6-9 => HDR GAMMA / DITHERING: ON
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, true, TONEMAPPING_DISABLED ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, true, TONEMAPPING_PHOTO ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, true, TONEMAPPING_HABLE ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_gamma( i, false, true, TONEMAPPING_ACES ); } ENDCG }
// 10-13 => HDR LINEAR / DITHERING: OFF
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, false, TONEMAPPING_DISABLED ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, false, TONEMAPPING_PHOTO ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, false, TONEMAPPING_HABLE ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, false, TONEMAPPING_ACES ); } ENDCG }
// 14-17 => HDR LINEAR / DITHERING: ON
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, true, TONEMAPPING_DISABLED ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, true, TONEMAPPING_PHOTO ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, true, TONEMAPPING_HABLE ); } ENDCG }
Pass{ CGPROGRAM float4 frag( v2f i ) : SV_Target{ return frag_hdr_linear( i, false, true, TONEMAPPING_ACES ); } ENDCG }
// -- QUALITY MOBILE --------------------------------------------------------------
// 18 => LDR GAMMA
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_ldr_gamma( i, true ); } ENDCG }
// 19 => LDR LINEAR
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_ldr_linear( i, true ); } ENDCG }
// 20-23 => HDR GAMMA / DITHERING: OFF
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, false, TONEMAPPING_DISABLED ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, false, TONEMAPPING_PHOTO ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, false, TONEMAPPING_HABLE ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, false, TONEMAPPING_ACES ); } ENDCG }
// 24-27 => HDR GAMMA / DITHERING: ON
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, true, TONEMAPPING_DISABLED ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, true, TONEMAPPING_PHOTO ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, true, TONEMAPPING_HABLE ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_gamma( i, true, true, TONEMAPPING_ACES ); } ENDCG }
// 28-31 => HDR LINEAR / DITHERING: OFF
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, false, TONEMAPPING_DISABLED ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, false, TONEMAPPING_PHOTO ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, false, TONEMAPPING_HABLE ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, false, TONEMAPPING_ACES ); } ENDCG }
// 32-35 => HDR LINEAR / DITHERING: ON
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, true, TONEMAPPING_DISABLED ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, true, TONEMAPPING_PHOTO ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, true, TONEMAPPING_HABLE ); } ENDCG }
Pass { CGPROGRAM float4 frag( v2f i ) : SV_Target { return frag_hdr_linear( i, true, true, TONEMAPPING_ACES ); } ENDCG }
}
Fallback Off
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 764c4b3c00d8a31489a5b825dbfa1553
timeCreated: 1437689081
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

Some files were not shown because too many files have changed in this diff Show More