Aetheria/Assets/Scripts/BlueNoiseProvider.cs
Reinier Vens d12d7c5c45 Initial ARPG Port
ARPG scene assets from old project are now correctly visualizing sectors generated by ZoneGenerator and updated by GameContext
2020-11-27 22:47:33 +00:00

30 lines
722 B
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Random = UnityEngine.Random;
[ExecuteInEditMode]
public class BlueNoiseProvider : MonoBehaviour
{
public Texture2D NoiseTexture;
private Camera _camera;
void Start()
{
_camera = Camera.main;
Shader.SetGlobalTexture("_DitheringTex", NoiseTexture);
}
private void Update()
{
Shader.SetGlobalVector("_DitheringCoords", new Vector4(
(float)_camera.scaledPixelWidth / (float)NoiseTexture.width,
(float)_camera.scaledPixelWidth / (float)NoiseTexture.height,
Random.value,
Random.value
));
}
}