Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Custom effect disappearing from post process profile

Discussion in 'Image Effects' started by SLGSimon, Feb 8, 2020.

  1. SLGSimon

    SLGSimon

    Joined:
    Jul 23, 2019
    Posts:
    80
    I'm using PostProcessing v2 with the built-in renderer, and I have a custom effect. When I add the effect to a post processing profile it shows up in the UI fine and works, but after closing and re-opening unity it is gone. Adding it again seems to save a new instance in the asset file each time, but none are visible.

    The asset looks like:
    Code (CSharp):
    1. %YAML 1.1
    2. %TAG !u! tag:unity3d.com,2011:
    3. --- !u!114 &-3795299448803683089
    4. MonoBehaviour:
    5.   m_ObjectHideFlags: 0
    6.   m_CorrespondingSourceObject: {fileID: 0}
    7.   m_PrefabInstance: {fileID: 0}
    8.   m_PrefabAsset: {fileID: 0}
    9.   m_GameObject: {fileID: 0}
    10.   m_Enabled: 1
    11.   m_EditorHideFlags: 0
    12.   m_Script: {fileID: 11500000, guid: 8e6292b2c06870d4495f009f912b9600, type: 3}
    13.   m_Name: UnderWater
    14.   m_EditorClassIdentifier:
    15.   settings:
    16.   - {fileID: 7439252449767837915}
    17. --- !u!114 &7439252449767837915
    18. MonoBehaviour:
    19.   m_ObjectHideFlags: 3
    20.   m_CorrespondingSourceObject: {fileID: 0}
    21.   m_PrefabInstance: {fileID: 0}
    22.   m_PrefabAsset: {fileID: 0}
    23.   m_GameObject: {fileID: 0}
    24.   m_Enabled: 1
    25.   m_EditorHideFlags: 0
    26.   m_Script: {fileID: 0}
    27.   m_Name: UnderWater
    28.   m_EditorClassIdentifier: Eco.Client::UnderWater
    29.   active: 1
    30.   enabled:
    31.     overrideState: 1
    32.     value: 1
    33.   Intensity:
    34.     overrideState: 0
    35.     value: 0.5
    36.   Speed:
    37.     overrideState: 0
    38.     value: 0.5
    39.   DistortionTexture:
    40.     overrideState: 0
    41.     value: {fileID: 0}
    42.     defaultState: 1
    43.  
    And the code for the effect:
    Code (CSharp):
    1.  
    2. using System;
    3. using System.Collections;
    4. using System.Collections.Generic;
    5. using UnityEngine;
    6. using UnityEngine.Rendering.PostProcessing;
    7. using UnityEngine.Scripting;
    8.  
    9. [Serializable]
    10. [PostProcess(typeof(UnderWaterRenderer), PostProcessEvent.AfterStack, "Custom/Underwater")]
    11. public sealed class UnderWater : PostProcessEffectSettings
    12. {
    13.     [Range(0f, 1f), Tooltip("Distortion intensity.")]
    14.     public FloatParameter Intensity = new FloatParameter { value = 0.5f };
    15.  
    16.     [Range(0f, 10f), Tooltip("Distortion speed.")]
    17.     public FloatParameter Speed = new FloatParameter { value = 0.5f };
    18.  
    19.     [Tooltip("Distortion texture.")]
    20.     public TextureParameter DistortionTexture = new TextureParameter { value = null };
    21. }
    22.  
    23. [Preserve]
    24. public sealed class UnderWaterRenderer : PostProcessEffectRenderer<UnderWater>
    25. {
    26.     public override void Render(PostProcessRenderContext context)
    27.     {
    28.         var sheet = context.propertySheets.Get(Shader.Find("PostFX/Under Water"));
    29.         sheet.properties.SetFloat("_DistortionIntensity", settings.Intensity);
    30.         sheet.properties.SetFloat("_DistortionSpeed", settings.Speed);
    31.         sheet.properties.SetTexture("_DistortionTexture", settings.DistortionTexture);
    32.         context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, 0);
    33.     }
    34. }
    35.  
    36.  
     
  2. Elliesh7

    Elliesh7

    Joined:
    Mar 22, 2020
    Posts:
    1
    Not necessarily. KS3P's default settings were excessive mainly to clearly show what it's capable of, all at once. But I took it that documentation for the settings and profiling were non-existent. Used well, post-processing mods add to how the universe itself feels and helps that much more in their own special way to making KSP look/feel [realistic; or like it was built to fully exploit the GPU like high class games of this generation].

    Just the advanced shadow effects (AO, more point lights and shadow casters, best example is the Mun crash scene) can do wonders for a game with barely there graphics. The shadows round the KSC are a misfire (way too much spread) imo. It tells me that the AO raytracing length (or shadow strength) may be excessive. But, like KS3P, that may just be to clearly show the power of this mod, or I haven't seen examples that confirm that shadows between buildings would behave like this.
     
  3. SLGSimon

    SLGSimon

    Joined:
    Jul 23, 2019
    Posts:
    80
    I'm not sure exactly what you're responding to?
     
  4. SLGSimon

    SLGSimon

    Joined:
    Jul 23, 2019
    Posts:
    80
    The cause of the problem I was having was actually because the source filename didn't match the name of the effect class in case. Pretty annoying issue in general, but they did mention it in the docs.
     
    victor_apihtin and bgm0 like this.
  5. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    @SLGSimon yes it will cause problems with serialization. I did the same mistake a while ago by accident.
     
    bgm0 likes this.