Aetheria/Assets/Scripts/Sector Display/BlueNoiseProvider.cs
Reinier Vens a981a46170 Asteroid Belts
Sector renderer is now also rendering asteroid belts. All gravity calculations have been moved out of monobehaviors.
2020-11-29 22:50:12 +00:00

30 lines
730 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;
private 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
));
}
}