Hello guys ,
I'm having a bit of troubke when trying to make cuatom postbprocessing effects that require extra texgures . Here is my code :
[Serializable]
[PostProcess(typeof(TextureOverlayRenderer), PostProcessEvent.BeforeStack, "Custom/TextureOverlay")]
public sealed class PostProcessingEffect_TextureOverlay : PostProcessEffectSettings
{
[Tooltip("Texture To Apply")]
public TextureParameter overlayTexture = new TextureParameter();
[Range(1.0f, 20.0f), Tooltip("Texture Repeat Factor")]
public FloatParameter textureRepeatFactor = new FloatParameter { value = 1.0f };
[Range(0f, 1f), Tooltip("Effect Opacity")]
public FloatParameter opacity = new FloatParameter { value = 0.5f };
public override bool IsEnabledAndSupported(PostProcessRenderContext context)
{
return enabled.value && (overlayTexture != null) && (opacity>0);
}
}
public sealed class TextureOverlayRenderer : PostProcessEffectRenderer
{
public override void Render(PostProcessRenderContext context)
{
var sheet = context.propertySheets.Get(Shader.Find("Hidden/Custom/TextureOverlay"));
sheet.properties.SetTexture("_OverlayTexture", settings.overlayTexture);
sheet.properties.SetFloat("_TextureRepeatFactor", settings.textureRepeatFactor);
sheet.properties.SetFloat("_EffectOpacity", settings.opacity);
context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, 0);
}
}
As you can see , I´m declaring the texture and setting it to new TextureParameter(). However in editor I'm always getting erros concerning that texture. The most common one is "Argument Null Exception , Argument cannot be null. Parameter Name:Value"
I really don't know what to do , when I move something in the effect editor or add the effect to the post processing cinemachine component those errors show up . But whem I'm in play mode they seem to go away.
↧