On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

I have a technical question!

A topic by BlindseekersOath created Jul 29, 2023 Views: 220 Replies: 30
Viewing posts 1 to 16
Submitted

Does anyone know how to get Vignette in unity C#?

Submitted (1 edit)

post processing  or URP , post processing would have like 3 more steps but both ways are pretty simple

Submitted

Um...post processing, I think.

Submitted

Do you need help?

Submitted

Yes.

Submitted

In the Package Manager add Post Prosesing , then create a gameobject and add a volume, create a layer for the gameobject name post, then on the camera add something with layer i believe then set the layer to post and that is it. The volume need to be set to global.

Submitted

I haven't found any sources on this, but I am trying to access a Vignette within a volume.

Submitted

I give you a pretty good instructions i believe and i would like to ask what game did you chose to work on the last day?

using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Rendering.PostProcessing;  public class VignetteController : MonoBehaviour {     public PostProcessVolume postProcessVolume;     private Vignette vignette;     private float startIntensity;     public float maxIntensity = 0.7f; // You can change this value to your desired maximum intensity     public float decreaseSpeed = 0.5f; // The speed at which the intensity decreases      private void Start()     {         if (postProcessVolume == null)         {             Debug.LogError("Post-Process Volume is not assigned!");             this.enabled = false;             return;         }          // Try to get the Vignette effect from the volume         if (!postProcessVolume.profile.TryGetSettings(out vignette))         {             Debug.LogError("Vignette is not found in the Post-Process Volume!");             this.enabled = false;             return;         }          // Cache the initial intensity         startIntensity = vignette.intensity;     }      public void SetVignetteIntensity(float target)     {         float targetValue = Mathf.Lerp(startIntensity, maxIntensity, target);         if (targetValue < vignette.intensity.value) return;         vignette.intensity.value = targetValue;     }      private void Update()     {         if (vignette.intensity > startIntensity)         {             // Gradually decrease the intensity over time             vignette.intensity.value -= decreaseSpeed * Time.deltaTime;              // Make sure the intensity doesn't go below the initial value             vignette.intensity.value = Mathf.Max(vignette.intensity, startIntensity);         }     } }
Submitted

What I meant, was that I am trying to edit a Vignette with a C# script, but can't get it. 

^ code of my VignetteController, feel free to use if you need

Submitted

OOO right now i understand the question, sorry

(1 edit)

using UnityEngine.Rendering.PostProcessing;

is the namespace:

    public PostProcessVolume postProcessVolume;   
  private Vignette vignette;

is the volume


if (!postProcessVolume.profile.TryGetSettings(out vignette))

        {

            Debug.LogError("Vignette is not found in the Post-Process Volume!");

            this.enabled = false;

            return;

        }

gets the vignette settings

then vignette.intensity.value controls it

Submitted (1 edit) (+1)

I think this is correct first add this "using UnityEngine.Rendering.PostProcessing;" then in the code put this "

public PostProcessVolume postProcessVolume;

  private Vignette vignette; 

private void Start() 

postProcessVolume.profile.TryGetSettings(out vignette);

 }"

This should work perfectly :)

Submitted

:>

Submitted

Okay, I'll try.

Submitted

I can't drag the postproccessingvolume into the script. Does that mean it's a URP Volume then?

is it just called Volume? then yes

Submitted
Deleted 341 days ago
Submitted

Yes, it is.

Submitted

i believe yes

Submitted

Hope this works!

Submitted

on what game are you working?

Submitted

Octalian...your version, I belive(You spawn in a pipe)

Submitted

Is the vignette just called a vignette?

Submitted

i think yes, i cannot confirm it because i dont the unity open.

For URP:
using UnityEngine.Rendering.Universal;
using UnityEngine.Rendering;
using UnityEngine; 
public class VignetteManager : MonoBehaviour {
    public Volume volume;      
    private Vignette vignette;      
    private void Start()     {         
        if (volume.profile.TryGet(out vignette))         {             
        // The vignette was found and assigned successfully.             
        // You can now use the 'vignette' variable to modify the vignette properties.         
        }
    }
}
Submitted

I'll try this, thanks!

Submitted

And how would I assign a color to that?

Submitted

try vignette.color= new Color32(0,0,0);

Submitted

Okay. Thanks.