2020-12-22 03:13:43 +00:00
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
2020-11-27 22:47:33 +00:00
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using Random = UnityEngine.Random;
|
|
|
|
|
|
|
|
|
|
|
|
[ExecuteInEditMode]
|
|
|
|
|
|
public class BlueNoiseProvider : MonoBehaviour
|
|
|
|
|
|
{
|
|
|
|
|
|
public Texture2D NoiseTexture;
|
|
|
|
|
|
|
2020-11-29 22:50:12 +00:00
|
|
|
|
private void Start()
|
2020-11-27 22:47:33 +00:00
|
|
|
|
{
|
|
|
|
|
|
Shader.SetGlobalTexture("_DitheringTex", NoiseTexture);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
|
|
{
|
|
|
|
|
|
Shader.SetGlobalVector("_DitheringCoords", new Vector4(
|
2021-05-02 20:59:45 +01:00
|
|
|
|
(float)Screen.width / NoiseTexture.width,
|
|
|
|
|
|
(float)Screen.height / NoiseTexture.height,
|
2020-11-27 22:47:33 +00:00
|
|
|
|
Random.value,
|
|
|
|
|
|
Random.value
|
|
|
|
|
|
));
|
2021-04-12 14:36:32 +01:00
|
|
|
|
Shader.SetGlobalInt("_FrameNumber", Time.frameCount);
|
2020-11-27 22:47:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|