열차 목업의 내부 확인용 프로젝트
smchoi
2024-07-31 9fe33c1ae076b0f6501619388e6b4cc872b76f80
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
//////////////////////////////////////////////////////
// MK Glow Lite                                     //
//                                                    //
// Created by Michael Kremmel                       //
// www.michaelkremmel.de                            //
// Copyright © 2020 All rights reserved.            //
//////////////////////////////////////////////////////
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
 
namespace MK.Glow.Legacy
{
    #if UNITY_2018_3_OR_NEWER
        [ExecuteAlways]
    #else
        [ExecuteInEditMode]
    #endif
    [DisallowMultipleComponent]
    [ImageEffectAllowedInSceneView]
    [RequireComponent(typeof(UnityEngine.Camera))]
    public class MKGlowLite : MonoBehaviour, MK.Glow.ICameraData, MK.Glow.ISettings
    {
        #if UNITY_EDITOR
        public bool showEditorMainBehavior = true;
        public bool showEditorBloomBehavior;
        public bool showEditorLensSurfaceBehavior;
        #endif
 
        //Main
        public DebugView debugView = MK.Glow.DebugView.None;
        public Workflow workflow = MK.Glow.Workflow.Threshold;
        public LayerMask selectiveRenderLayerMask = -1;
        [Range(-1f, 1f)]
        public float anamorphicRatio = 0f;
 
        //Bloom
        [MK.Glow.MinMaxRange(0, 10)]
        public MinMaxRange bloomThreshold = new MinMaxRange(1.25f, 10f);
        [Range(1f, 10f)]
        public float bloomScattering = 7f;
        public float bloomIntensity = 1f;
 
        //LensSurface
        public bool allowLensSurface = false;
        public Texture2D lensSurfaceDirtTexture;
        public float lensSurfaceDirtIntensity = 2.5f;
        public Texture2D lensSurfaceDiffractionTexture;
        public float lensSurfaceDiffractionIntensity = 2.0f;
 
        private Effect _effect;
 
        private RenderTarget _source, _destination;
 
        private UnityEngine.Camera renderingCamera
        {
            get { return GetComponent<UnityEngine.Camera>(); }
        }
 
        public void OnEnable()
        {
            _effect = new Effect();
            _effect.Enable(RenderPipeline.Legacy);
 
            enabled = Compatibility.IsSupported;
        }
 
        public void OnDisable()
        {
            _effect.Disable();
        }
 
        private void OnRenderImage(RenderTexture source, RenderTexture destination)
        {
            if(workflow == Workflow.Selective && (UnityEngine.Rendering.GraphicsSettings.renderPipelineAsset || PipelineProperties.xrEnabled))
            {
                Graphics.Blit(source, destination);
                return;
            }
 
            _source.renderTexture = source;
            _destination.renderTexture = destination;
            _effect.Build(_source, _destination, this, null, this, renderingCamera);
 
            Graphics.Blit(source, destination, _effect.renderMaterialNoGeometry, _effect.currentRenderIndex);
            _effect.AfterCompositeCleanup();
        }
 
        /////////////////////////////////////////////////////////////////////////////////////////////
        // Settings
        /////////////////////////////////////////////////////////////////////////////////////////////
        public bool GetAllowGeometryShaders()
        { 
            return false;
        }
        public bool GetAllowComputeShaders()
        { 
            return false;
        }
        public MK.Glow.DebugView GetDebugView()
        { 
            return debugView;
        }
        public MK.Glow.Workflow GetWorkflow()
        { 
            return workflow;
        }
        public LayerMask GetSelectiveRenderLayerMask()
        { 
            return selectiveRenderLayerMask;
        }
        public float GetAnamorphicRatio()
        { 
            return anamorphicRatio;
        }
 
        //Bloom
        public MK.Glow.MinMaxRange GetBloomThreshold()
        { 
            return bloomThreshold;
        }
        public float GetBloomScattering()
        { 
            return bloomScattering;
        }
        public float GetBloomIntensity()
        { 
            return bloomIntensity;
        }
 
        //LensSurface
        public bool GetAllowLensSurface()
        { 
            return allowLensSurface;
        }
        public Texture2D GetLensSurfaceDirtTexture()
        { 
            return lensSurfaceDirtTexture;
        }
        public float GetLensSurfaceDirtIntensity()
        { 
            return lensSurfaceDirtIntensity;
        }
        public Texture2D GetLensSurfaceDiffractionTexture()
        { 
            return lensSurfaceDiffractionTexture;
        }
        public float GetLensSurfaceDiffractionIntensity()
        { 
            return lensSurfaceDiffractionIntensity;
        }
 
        /////////////////////////////////////////////////////////////////////////////////////////////
        // Camera Data
        /////////////////////////////////////////////////////////////////////////////////////////////
        public int GetCameraWidth()
        {
            return renderingCamera.pixelWidth;
        }
        public int GetCameraHeight()
        {
            return renderingCamera.pixelHeight;
        }
        public bool GetStereoEnabled()
        {
            return renderingCamera.stereoEnabled;
        }
        public float GetAspect()
        {
            return renderingCamera.aspect;
        }
        public Matrix4x4 GetWorldToCameraMatrix()
        {
            return renderingCamera.worldToCameraMatrix;
        }
        public bool GetOverwriteDescriptor()
        {
            return false;
        }
        public UnityEngine.Rendering.TextureDimension GetOverwriteDimension()
        {
            return UnityEngine.Rendering.TextureDimension.Tex2D;
        }
        public int GetOverwriteVolumeDepth()
        {
            return 1;
        }
        public bool GetTargetTexture()
        {
            return renderingCamera.targetTexture != null ? true : false;
        }
    }
}