-
Notifications
You must be signed in to change notification settings - Fork 0
/
ColourBlindComponent.cs
94 lines (80 loc) · 2.47 KB
/
ColourBlindComponent.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MelonLoader;
using UnityEngine;
namespace VRChatAccessibility
{
[RegisterTypeInIl2Cpp]
public class ColourBlindComponent : MonoBehaviour
{
public ColourBlindComponent(IntPtr ptr) : base(ptr){}
public enum AssistType
{
Normal,
Deuteranopia,
Protanopia,
Tritanopia
}
public AssistType AssistMode;
public float Strength = 1.0f;
public Material Material;
public bool IsLinear => QualitySettings.activeColorSpace == ColorSpace.Linear;
void Start()
{
// Disable if we don't support image effects
if (!SystemInfo.supportsImageEffects)
{
MelonLogger.Error("Image Effects are not supported on this platform.");
enabled = false;
return;
}
// Disable if we don't support render textures
if (!SystemInfo.supportsRenderTextures)
{
MelonLogger.Error("RenderTextures are not supported on this platform.");
enabled = false;
return;
}
if (Material == null)
{
MelonLogger.Error("Material Is Null!");
enabled = false;
return;
}
if (Material.shader == null)
{
MelonLogger.Error("Shader Is Null!");
enabled = false;
return;
}
// Disable the image effect if the shader can't
// run on the users graphics card
if (!Material.shader.isSupported)
{
MelonLogger.Error("Unsupported shader.");
enabled = false;
return;
}
}
void OnDestroy()
{
if (Material)
{
DestroyImmediate(Material);
}
}
void OnRenderImage(RenderTexture source, RenderTexture destination)
{
if (Material.shader == null || AssistMode == AssistType.Normal)
{
Graphics.Blit(source, destination);
return;
}
Material.SetFloat("_Strength", Strength);
Graphics.Blit(source, destination, Material, ((int)AssistMode - 1) + (IsLinear ? 3 : 0));
}
}
}