Skip to content

Instantly share code, notes, and snippets.

@mmechtley
Created December 16, 2022 05:21
Show Gist options
  • Save mmechtley/e67181fa7f8050f3ab74694412aa1461 to your computer and use it in GitHub Desktop.
Save mmechtley/e67181fa7f8050f3ab74694412aa1461 to your computer and use it in GitHub Desktop.
Convert Lift Gamma Gain coefficients from PostProcessing V2 to URP 12.x
// URP has a tool to convert postprocessing volumes but it doesn't transform the coefficients so the visuals won't look the same
// This does the transformation to make them match.
private static void ConvertLiftGammaGainValues( VolumeProfile profile )
{
if( profile != null && profile.TryGet( out LiftGammaGain lgg ) && lgg.active )
{
if( lgg.lift.overrideState )
{
lgg.lift.value = new Vector4( Mathf.LinearToGammaSpace( lgg.lift.value.x * 0.2f / 0.15f ),
Mathf.LinearToGammaSpace( lgg.lift.value.y * 0.2f / 0.15f ) ,
Mathf.LinearToGammaSpace( lgg.lift.value.z * 0.2f / 0.15f ) ,
lgg.lift.value.w * 0.2f );
}
if( lgg.gamma.overrideState )
{
lgg.gamma.value = new Vector4( Mathf.LinearToGammaSpace( lgg.gamma.value.x ),
Mathf.LinearToGammaSpace( lgg.gamma.value.y ),
Mathf.LinearToGammaSpace( lgg.gamma.value.z ),
lgg.gamma.value.w * 0.8f );
}
if( lgg.gain.overrideState )
{
lgg.gain.value = new Vector4( Mathf.LinearToGammaSpace( lgg.gain.value.x ),
Mathf.LinearToGammaSpace( lgg.gain.value.y ),
Mathf.LinearToGammaSpace( lgg.gain.value.z ),
lgg.gain.value.w * 0.8f );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment