Dot product and full screen rendererr

goal : I want the screen to turn red with full screen pass renderer as the player does a 180. The screen effect(it turning red) percent will be connected as the player turns around so it wont be at 100% unless the player has done a full 180, this is why im using dot product. There is no certain trigger and this will happen when i press play. I would like the ditherspead float to change according to the player turning and dither spread starting at 0 and hiting x when the player does a full 180.

Im not the best at coding, but I tried to go as far as I could, here Ill leave the script so far. any help would be appreciated.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering.Universal;

public class FullScreenTestController : MonoBehaviour {

    private Vector3 startDirection;
    private Vector3 _180Direction;

    [Header("Time")]
    [SerializeField] private float _hurtDitherFadeInTime = 5;
    [SerializeField] private float _hurtColorResFadeInTime = 5;



    [Header("References")]
    [SerializeField] private ScriptableRendererFeature _fullscreeneffect;
    [SerializeField] private Material _material;

    private int _DitherSpread = Shader.PropertyToID("_DitherSpread");
    private int _ColorResolution = Shader.PropertyToID("_ColorResolution");

    private const int DITHERSPREAD_START_AMOUNT = 0;
    private const int COLORRESOLUTION_START_AMOUNT = 1000;


    private void Start() {
        _fullscreeneffect.SetActive(false);
        startDirection = Camera.main.transform.forward;
        _180Direction = Camera.main.transform.forward * -1;

    }

    private void Update() {

        if (Input.GetKey("e")) {
            //  _fullscreeneffect.SetActive(true);
            StartCoroutine(Death());
        }

        var dot = Vector3.Dot(startDirection, _180Direction);
   
        


    }
    private IEnumerator Death() {
        _fullscreeneffect.SetActive(true);
        _material.SetFloat(_DitherSpread, DITHERSPREAD_START_AMOUNT);
        _material.SetFloat(_ColorResolution, COLORRESOLUTION_START_AMOUNT);

        float elapsedTime = 0;
        while (elapsedTime < _hurtDitherFadeInTime) {
            while (elapsedTime < _hurtColorResFadeInTime) {

                elapsedTime += Time.deltaTime;

                float lerpedDither = Mathf.Lerp(DITHERSPREAD_START_AMOUNT, -0.09f, (elapsedTime / _hurtDitherFadeInTime));
                float lerpedColorRes = Mathf.Lerp(COLORRESOLUTION_START_AMOUNT, 0f, (elapsedTime / _hurtColorResFadeInTime));

                _material.SetFloat(_DitherSpread, lerpedDither);
                _material.SetFloat(_ColorResolution, lerpedColorRes);

                yield return null;
            }

        }

    }
}

tl;dr: why not use the angle between the vectors divided by 180°? That gives you a value going linearly from 0 to 1 as the angle of rotation approaches 180°, which you can then directly use to lerp the color towards red. (I would also set the y component of the two vectors you compare to 0 in case the camera can look up/down, so you only check the angle in the xz-plane).
More background rambling:
The dot product between two vectors a and b is defined as the product of the lengths of both vectors multiplied by the cosine of the angle between them. Since your vectors are both unit vectors (length 1), that simplifies to just the cosine of the angle. That value is between 1 (both vectors parallel, angle 0°) and -1 (both vectors exactly opposite, angle 180°), which is not optimal for what you’re trying to do.
I believe Vector3.Angle does use the dot product to calculate the angle so it makes no computational difference, but I feel it’s more straightforward and easier to understand, which is always a plus for any code I feel.

You are partly right, here are some of my homebrewn implementations

/// <summary> Computes unsigned angle between 3D vectors. (In radians.) </summary>
static public float angle(Vector3 a, Vector3 b) {
  var sqrd = sqrMag(a) * sqrMag(b);
  return sqrd < 1E-10f? 0f : acos(signedSat(dot(a, b) / sqrt(sqrd)));
}

/// <summary> Computes signed angle between 3D vectors. (In radians.) </summary>
static public float signedAngle(Vector3 a, Vector3 b, Vector3 axis)
  => copySign(angle(a,b), dot(axis, cross(a, b));

Transcribed to C# (and classic Unity) API

using System; // for Math and MathF;

static public float angle(Vector3 a, Vector3 b) {
  var sqrd = a.sqrMagnitude * b.sqrMagnitude; // ||a||^2 * ||b||^2
  if(sqrd < 1E-10f) return 0f; // this is to prevent errors due to zero vectors
  var cosine = Vector3.Dot(a, b) / MathF.Sqrt(sqrd); // we just want to neutralize the magnitude effect
  // because dot already results in the cosine of the angle
  // clamp is used to prevent floating point inaccuracies that would break acos
  return MathF.Acos(Math.Clamp(cosine, -1f, 1f));
}

static public float signedAngle(Vector3 a, Vector3 b, Vector3 axis)
  => Math.Sign(Vector3.Dot(axis, Vector3.Cross(a, b))) * angle(a, b);

This is because
{\displaystyle \mathbf {a} \cdot \mathbf {b} =\left\|\mathbf {a} \right\|\left\|\mathbf {b} \right\|\cos \theta ,}

That said, with unit directions and usage of atan2 you can get a much more robust computation

/// <summary> Computes unsigned angle between 3D directions (unit vectors). (Better stability; In radians.) </summary>
static public float angleUnit(Vector3 a, Vector3 b) => 2f * MathF.Atan2((a - b).magnitude, mag(a + b).magnitude);

So dot isn’t actually required, at least not as an explicit function call.

Edit:
Scratch the last example, that’s in fact an ill-formed 2D only variant, I’ll have to tidy up my angles lib it seems :smiley:

To amend my last example, in 3D we still need cross and dot, like so

static public float angleUnit(Vector3 a, Vector3 b)
  => MathF.Atan2(Vector3.Cross(a, b).magnitude, Vector3.Dot(a, b));

The cross magnitude will be zero for two perpendicular parallel vectors, just to clarify. Edit: oops