Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add FPSSample v0.1.1 PostProcessing Diff
  • Loading branch information
0lento committed Nov 24, 2018
1 parent 4435dec commit 31238fb
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 0 deletions.
7 changes: 7 additions & 0 deletions PostProcessing/Runtime/Effects/AmbientOcclusion.cs
Expand Up @@ -64,13 +64,20 @@ public sealed class AmbientOcclusion : PostProcessEffectSettings
[Tooltip("Number of sample points, which affects quality and performance. Lowest, Low & Medium passes are downsampled. High and Ultra are not and should only be used on high-end hardware.")]
public AmbientOcclusionQualityParameter quality = new AmbientOcclusionQualityParameter { value = AmbientOcclusionQuality.Medium };

// sample-game begin: added globalEnable
public static bool globalEnable = true;
// sample-game end

// SRPs can call this method without a context set (see HDRP)
// We need a better way to handle this than checking for a null context, context should
// never be null.
public override bool IsEnabledAndSupported(PostProcessRenderContext context)
{
// sample-game begin: added globalEnable
bool state = enabled.value
&& globalEnable
&& intensity.value > 0f;
// sample-game end

if (mode.value == AmbientOcclusionMode.ScalableAmbientObscurance)
{
Expand Down
7 changes: 7 additions & 0 deletions PostProcessing/Runtime/Effects/Bloom.cs
Expand Up @@ -46,10 +46,17 @@ public sealed class Bloom : PostProcessEffectSettings
[Min(0f), Tooltip("Amount of dirtiness."), DisplayName("Intensity")]
public FloatParameter dirtIntensity = new FloatParameter { value = 0f };

// sample-game begin: added globalEnable
public static bool globalEnable = true;
// sample-game end:

public override bool IsEnabledAndSupported(PostProcessRenderContext context)
{
// sample-game begin: added globalEnable
return enabled.value
&& globalEnable
&& intensity.value > 0f;
// sample-game end:
}
}

Expand Down
9 changes: 9 additions & 0 deletions PostProcessing/Runtime/Effects/ColorGrading.cs
Expand Up @@ -131,6 +131,10 @@ public sealed class ColorGrading : PostProcessEffectSettings
[DisplayName("Gain"), Tooltip("Controls the lightest portions of the render."), Trackball(TrackballAttribute.Mode.Gain)]
public Vector4Parameter gain = new Vector4Parameter { value = new Vector4(1f, 1f, 1f, 0f) };

// sample-game begin: added globalGamma
public static float globalGamma = 1.0f;
// sample-game end:

public SplineParameter masterCurve = new SplineParameter { value = new Spline(new AnimationCurve(new Keyframe(0f, 0f, 1f, 1f), new Keyframe(1f, 1f, 1f, 1f)), 0f, false, new Vector2(0f, 1f)) };
public SplineParameter redCurve = new SplineParameter { value = new Spline(new AnimationCurve(new Keyframe(0f, 0f, 1f, 1f), new Keyframe(1f, 1f, 1f, 1f)), 0f, false, new Vector2(0f, 1f)) };
public SplineParameter greenCurve = new SplineParameter { value = new Spline(new AnimationCurve(new Keyframe(0f, 0f, 1f, 1f), new Keyframe(1f, 1f, 1f, 1f)), 0f, false, new Vector2(0f, 1f)) };
Expand Down Expand Up @@ -260,6 +264,11 @@ void RenderHDRPipeline3D(PostProcessRenderContext context)
var lift = ColorUtilities.ColorToLift(settings.lift.value * 0.2f);
var gain = ColorUtilities.ColorToGain(settings.gain.value * 0.8f);
var invgamma = ColorUtilities.ColorToInverseGamma(settings.gamma.value * 0.8f);

// sample-game begin: apply globalGamma
invgamma.Scale(Vector3.one * ColorGrading.globalGamma);
// sample-game end

cmd.SetComputeVectorParam(compute, "_Lift", new Vector4(lift.x, lift.y, lift.z, 0f));
cmd.SetComputeVectorParam(compute, "_InvGamma", new Vector4(invgamma.x, invgamma.y, invgamma.z, 0f));
cmd.SetComputeVectorParam(compute, "_Gain", new Vector4(gain.x, gain.y, gain.z, 0f));
Expand Down
7 changes: 7 additions & 0 deletions PostProcessing/Runtime/Effects/Grain.cs
Expand Up @@ -18,10 +18,17 @@ public sealed class Grain : PostProcessEffectSettings
[Range(0f, 1f), DisplayName("Luminance Contribution"), Tooltip("Controls the noisiness response curve based on scene luminance. Lower values mean less noise in dark areas.")]
public FloatParameter lumContrib = new FloatParameter { value = 0.8f };

// sample-game begin: added globalEnable
public static bool globalEnable = true;
// sample-game end:

public override bool IsEnabledAndSupported(PostProcessRenderContext context)
{
// sample-game begin: added globalEnable
return enabled.value
&& globalEnable
&& intensity.value > 0f;
// sample-game end:
}
}

Expand Down
7 changes: 7 additions & 0 deletions PostProcessing/Runtime/Effects/MotionBlur.cs
Expand Up @@ -12,10 +12,17 @@ public sealed class MotionBlur : PostProcessEffectSettings
[Range(4, 32), Tooltip("The amount of sample points, which affects quality and performances.")]
public IntParameter sampleCount = new IntParameter { value = 10 };

// sample-game begin: added globalEnable
public static bool globalEnable = true;
// sample-game end:

public override bool IsEnabledAndSupported(PostProcessRenderContext context)
{
// sample-game begin: added globalEnable
return enabled.value
&& shutterAngle.value > 0f
&& globalEnable
// sample-game end:
#if UNITY_EDITOR
// Don't render motion blur preview when the editor is not playing as it can in some
// cases results in ugly artifacts (i.e. when resizing the game view).
Expand Down
7 changes: 7 additions & 0 deletions PostProcessing/Runtime/Effects/ScreenSpaceReflections.cs
Expand Up @@ -46,9 +46,16 @@ public sealed class ScreenSpaceReflections : PostProcessEffectSettings
[Range(0f, 1f), Tooltip("Fades reflections close to the screen edges.")]
public FloatParameter vignette = new FloatParameter { value = 0.5f };

// sample-game begin: added globalEnable
public static bool globalEnable = true;
// sample-game end:

public override bool IsEnabledAndSupported(PostProcessRenderContext context)
{
// sample-game begin: added globalEnable
return enabled
&& globalEnable
// sample-game end:
&& context.camera.actualRenderingPath == RenderingPath.DeferredShading
&& SystemInfo.supportsMotionVectors
&& SystemInfo.supportsComputeShaders
Expand Down

0 comments on commit 31238fb

Please sign in to comment.