How to Set properties based on LWRP.
Purpose of implementations this script.
Someone wanna binding camera FOV(Field of view) value to some of the shader features.
Writing Script.
Create new script as class like SetFovMatfromCamera.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering.LWRP;
Code language: CSS (css)
Adding one of using for LWRP inside script like below.
public Transform target;
private Camera _mMainCamera;
private float _setFov;
public Material mat;
Code language: PHP (php)
Adding several needed public or private value.
public float SetFov
{
get => _setFov;
set => _setFov = value;
}
Code language: PHP (php)
Adding SetFov(or _setFov) Setter function
This method are not necessarily requirement I just some test use this.
void Start()
{
_mMainCamera = Camera.main;
if (_mMainCamera != null && _mMainCamera.enabled)
{
Debug.Log(_mMainCamera.name.ToString());
Debug.Log(_mMainCamera.fieldOfView.ToString());
}
}
Code language: JavaScript (javascript)
Apply to Camera.main component into _mMainCamera value.
Writing to some of debugging.
Adding to Update feature
void Update()
{
_setFov = _mMainCamera.fieldOfView;
Debug.Log(_mMainCamera.fieldOfView.ToString());
mat.SetFloat("_getFOV", SetFov);
}
Code language: JavaScript (javascript)
Test Shader structure below.


Remember to Reference name that should be intensely change to your name of purpose.

When Camera FOV has change that affect to some of shader features like below.
I just setting up to fresnel fx which is if currently camera fov has over 45 then appearing to fresnel fx to this shader.
because I was implemented comparison between constant value of 45 and _getFOV value from camrea FOV.
