├── .gitignore ├── Assets ├── JCDeferredShading.meta └── JCDeferredShading │ ├── JCDSCamera.cs │ ├── JCDSCamera.cs.meta │ ├── JCDSRenderTexture.cs │ ├── JCDSRenderTexture.cs.meta │ ├── JCDeferredShading.mat │ ├── JCDeferredShading.mat.meta │ ├── JCDeferredShading1.mat │ ├── JCDeferredShading1.mat.meta │ ├── Orc Skin (Diffuse).psd │ ├── Orc Skin (Diffuse).psd.meta │ ├── Orc Skin (Normal).png │ ├── Orc Skin (Normal).png.meta │ ├── Resources.meta │ ├── Resources │ ├── BackFaceDepth.shader │ ├── BackFaceDepth.shader.meta │ ├── CompositeResultBuffer.shader │ ├── CompositeResultBuffer.shader.meta │ ├── FrontFaceDepth.shader │ ├── FrontFaceDepth.shader.meta │ ├── JCDSInclude.cginc │ ├── JCDSInclude.cginc.meta │ ├── JCDeferredShading.shader │ ├── JCDeferredShading.shader.meta │ ├── ScreenSpaceReflection.shader │ └── ScreenSpaceReflection.shader.meta │ ├── Test0.unity │ ├── Test0.unity.meta │ ├── Test1.cs │ ├── Test1.cs.meta │ ├── Test1.unity │ ├── Test1.unity.meta │ ├── Tiles_Albedo.jpg │ ├── Tiles_Albedo.jpg.meta │ ├── Tiles_Normal.png │ ├── Tiles_Normal.png.meta │ ├── Wall 1.mat │ ├── Wall 1.mat.meta │ ├── Wall.mat │ ├── Wall.mat.meta │ ├── Wall.physicMaterial │ ├── Wall.physicMaterial.meta │ ├── wall.tga │ ├── wall.tga.meta │ ├── wallN.tga │ └── wallN.tga.meta ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset ├── UnityAdsSettings.asset └── UnityConnectSettings.asset ├── README.md ├── ScreenShot.jpg ├── ScreenShotSSR.jpg └── ScreenShotSSR2.jpg /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | Library 3 | 4 | Temp 5 | 6 | Assembly-CSharp.csproj 7 | 8 | DeferredRendering.sln 9 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 48f9aadc67ee41c458ec74ff82a80d0b 3 | folderAsset: yes 4 | timeCreated: 1481872184 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/JCDSCamera.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | 6 | namespace JCDeferredShading 7 | { 8 | [RequireComponent(typeof(Camera))] 9 | public class JCDSCamera : MonoBehaviour 10 | { 11 | private static JCDSCamera s_instance = null; 12 | public static JCDSCamera instance 13 | { 14 | get 15 | { 16 | return s_instance; 17 | } 18 | } 19 | 20 | public bool debug = false; 21 | 22 | public Mesh pointLightMesh = null; 23 | 24 | private Camera cam = null; 25 | private Camera doubleFaceDepthCam = null; 26 | 27 | // 0 : diffuse(rgb) shininess(a) 28 | // 1 : normal(rgb) 29 | // 2 : position(rgb) 30 | private JCDSRenderTexture mrtGBuffer = null; 31 | 32 | // 0 : result (rgb) depthBuffer 33 | private JCDSRenderTexture resultRT = null; 34 | 35 | // 0 : ssr (rgb) 36 | private JCDSRenderTexture ssrRT = null; 37 | 38 | // 0 : fonrt face depth(r) back face depth(g) 39 | private JCDSRenderTexture doubleFaceDepthRT = null; 40 | 41 | private Material compositeResultBufferMtrl = null; 42 | private Material ssrMtrl = null; 43 | 44 | private Shader frontFaceDepthShader = null; 45 | private Shader backFaceDepthShader = null; 46 | 47 | private int shaderPropId_diffuseBuffer = 0; 48 | private int shaderPropId_normalBuffer = 0; 49 | private int shaderPropId_positionBuffer = 0; 50 | private int shaderPropId_resultBuffer = 0; 51 | private int shaderPropId_ssrBuffer = 0; 52 | private int shaderPropId_doubleFaceDepthBuffer = 0; 53 | 54 | private int shaderPropId_ssrVMatrix = 0; 55 | private int shaderPropId_ssrPMatrix = 0; 56 | 57 | private int shaderPropId_screenPixelSize = 0; 58 | 59 | private int shaderPropId_dirLightDir = 0; 60 | private int shaderPropId_dirLightColor = 0; 61 | private int shaderPropId_dirLightIntensity = 0; 62 | 63 | private int shaderPropId_pointLightPos = 0; 64 | private int shaderPropId_pointLightColor = 0; 65 | private int shaderPropId_pointLightRange = 0; 66 | 67 | private Light[] dirLights = null; 68 | private Light[] pointLights = null; 69 | 70 | private void Awake() 71 | { 72 | s_instance = this; 73 | 74 | cam = GetComponent(); 75 | 76 | compositeResultBufferMtrl = new Material(Shader.Find("Hidden/JCDeferredShading/CompositeResultBuffer")); 77 | ssrMtrl = new Material(Shader.Find("Hidden/JCDeferredShading/ScreenSpaceReflection")); 78 | 79 | frontFaceDepthShader = Shader.Find("Hidden/JCDeferredShading/FrontFaceDepth"); 80 | backFaceDepthShader = Shader.Find("Hidden/JCDeferredShading/BackFaceDepth"); 81 | 82 | shaderPropId_diffuseBuffer = Shader.PropertyToID("_DiffuseBuffer"); 83 | shaderPropId_normalBuffer = Shader.PropertyToID("_NormalBuffer"); 84 | shaderPropId_positionBuffer = Shader.PropertyToID("_PositionBuffer"); 85 | shaderPropId_resultBuffer = Shader.PropertyToID("_ResultBuffer"); 86 | shaderPropId_ssrBuffer = Shader.PropertyToID("_SSRBuffer"); 87 | shaderPropId_doubleFaceDepthBuffer = Shader.PropertyToID("_DoubleFaceDepthBuffer"); 88 | 89 | shaderPropId_ssrVMatrix = Shader.PropertyToID("_SSR_V_MATRIX"); 90 | shaderPropId_ssrPMatrix = Shader.PropertyToID("_SSR_P_MATRIX"); 91 | 92 | shaderPropId_screenPixelSize = Shader.PropertyToID("_ScreenPixelSize"); 93 | 94 | shaderPropId_dirLightDir = Shader.PropertyToID("_DirLightDir"); 95 | shaderPropId_dirLightColor = Shader.PropertyToID("_DirLightColor"); 96 | 97 | shaderPropId_pointLightPos = Shader.PropertyToID("_PointLightPos"); 98 | shaderPropId_pointLightColor = Shader.PropertyToID("_PointLightColor"); 99 | shaderPropId_pointLightRange = Shader.PropertyToID("_PointLightRange"); 100 | 101 | mrtGBuffer = new JCDSRenderTexture( 102 | 3, Screen.width, Screen.height, 103 | JCDSRenderTexture.ValueToMask(null), 104 | RenderTextureFormat.ARGBHalf, FilterMode.Point, false 105 | ); 106 | 107 | resultRT = new JCDSRenderTexture( 108 | 1, Screen.width, Screen.height, 109 | JCDSRenderTexture.ValueToMask(new bool[] { true }), 110 | RenderTextureFormat.ARGB32, FilterMode.Point, false 111 | ); 112 | 113 | ssrRT = new JCDSRenderTexture( 114 | 1, Screen.width, Screen.height, 115 | JCDSRenderTexture.ValueToMask(null), 116 | RenderTextureFormat.ARGB32, FilterMode.Point, false 117 | ); 118 | 119 | doubleFaceDepthRT = new JCDSRenderTexture( 120 | 1, Screen.width, Screen.height, 121 | JCDSRenderTexture.ValueToMask(new bool[] { true }), 122 | RenderTextureFormat.ARGBFloat, FilterMode.Point, false 123 | ); 124 | 125 | CollectLights(); 126 | 127 | CreateDoubleFaceDepthCamera(); 128 | } 129 | 130 | private void OnDestroy() 131 | { 132 | if (mrtGBuffer != null) 133 | { 134 | mrtGBuffer.Destroy(); 135 | mrtGBuffer = null; 136 | } 137 | if(resultRT != null) 138 | { 139 | resultRT.Destroy(); 140 | resultRT = null; 141 | } 142 | if(ssrRT != null) 143 | { 144 | ssrRT.Destroy(); 145 | ssrRT = null; 146 | } 147 | if(doubleFaceDepthRT != null) 148 | { 149 | doubleFaceDepthRT.Destroy(); 150 | doubleFaceDepthRT = null; 151 | } 152 | 153 | if(compositeResultBufferMtrl != null) 154 | { 155 | Material.Destroy(compositeResultBufferMtrl); 156 | compositeResultBufferMtrl = null; 157 | } 158 | 159 | if(ssrMtrl != null) 160 | { 161 | Material.Destroy(ssrMtrl); 162 | ssrMtrl = null; 163 | } 164 | 165 | frontFaceDepthShader = null; 166 | backFaceDepthShader = null; 167 | 168 | s_instance = null; 169 | } 170 | 171 | private void OnPreRender() 172 | { 173 | mrtGBuffer.ResetSize(Screen.width, Screen.height); 174 | resultRT.ResetSize(Screen.width, Screen.height); 175 | ssrRT.ResetSize(Screen.width, Screen.height); 176 | doubleFaceDepthRT.ResetSize(Screen.width, Screen.height); 177 | 178 | JCDSRenderTexture.StoreCurrentActiveBuffers(); 179 | JCDSRenderTexture.SetMultipleRenderTargets(cam, mrtGBuffer, resultRT, 0); 180 | } 181 | 182 | private void OnPostRender() 183 | { 184 | doubleFaceDepthRT.SetActiveRenderTexture(0); 185 | JCDSRenderTexture.ClearActiveRenderTexture(true, true, Color.black, 1.0f); 186 | JCDSRenderTexture.SetMultipleRenderTargets(doubleFaceDepthCam, doubleFaceDepthRT, doubleFaceDepthRT, 0); 187 | doubleFaceDepthCam.RenderWithShader(frontFaceDepthShader, null); 188 | JCDSRenderTexture.ClearActiveRenderTexture(true, false, Color.black, 1.0f); 189 | doubleFaceDepthCam.RenderWithShader(backFaceDepthShader, null); 190 | 191 | resultRT.SetActiveRenderTexture(0); 192 | JCDSRenderTexture.ClearActiveRenderTexture(true, true, Color.black, 0.0f); 193 | 194 | compositeResultBufferMtrl.SetTexture(shaderPropId_diffuseBuffer, mrtGBuffer.GetRenderTexture(0)); 195 | compositeResultBufferMtrl.SetTexture(shaderPropId_normalBuffer, mrtGBuffer.GetRenderTexture(1)); 196 | compositeResultBufferMtrl.SetTexture(shaderPropId_positionBuffer, mrtGBuffer.GetRenderTexture(2)); 197 | compositeResultBufferMtrl.SetTexture(shaderPropId_resultBuffer, resultRT.GetRenderTexture(0)); 198 | compositeResultBufferMtrl.SetTexture(shaderPropId_ssrBuffer, ssrRT.GetRenderTexture(0)); 199 | 200 | int numDirLights = dirLights == null ? 0 : dirLights.Length; 201 | for (int i = 0; i < numDirLights; ++i) 202 | { 203 | Light light = dirLights[i]; 204 | if (light != null && light.enabled && light.gameObject.activeSelf) 205 | { 206 | Vector3 dir = -light.transform.forward; 207 | compositeResultBufferMtrl.SetVector(shaderPropId_dirLightDir, new Vector4(dir.x, dir.y, dir.z, light.intensity)); 208 | compositeResultBufferMtrl.SetColor(shaderPropId_dirLightColor, light.color); 209 | DrawScreenQuad(compositeResultBufferMtrl, 0, false, false); 210 | } 211 | } 212 | 213 | int numPointLights = pointLights == null ? 0 : pointLights.Length; 214 | for (int i = 0; i < numPointLights; ++i) 215 | { 216 | Light light = pointLights[i]; 217 | if (light != null && light.enabled && light.gameObject.activeSelf) 218 | { 219 | compositeResultBufferMtrl.SetVector(shaderPropId_pointLightPos, light.transform.position); 220 | compositeResultBufferMtrl.SetColor(shaderPropId_pointLightColor, light.color); 221 | compositeResultBufferMtrl.SetVector(shaderPropId_pointLightRange, new Vector4(1.0f / light.range, light.intensity, 0, 0)); 222 | compositeResultBufferMtrl.SetPass(2); 223 | Graphics.DrawMeshNow(pointLightMesh, Matrix4x4.TRS(light.transform.position, Quaternion.identity, Vector3.one * light.range * 2)); 224 | } 225 | } 226 | 227 | ssrMtrl.SetTexture(shaderPropId_diffuseBuffer, mrtGBuffer.GetRenderTexture(0)); 228 | ssrMtrl.SetTexture(shaderPropId_normalBuffer, mrtGBuffer.GetRenderTexture(1)); 229 | ssrMtrl.SetTexture(shaderPropId_positionBuffer, mrtGBuffer.GetRenderTexture(2)); 230 | ssrMtrl.SetTexture(shaderPropId_resultBuffer, resultRT.GetRenderTexture(0)); 231 | ssrMtrl.SetTexture(shaderPropId_doubleFaceDepthBuffer, doubleFaceDepthRT.GetRenderTexture(0)); 232 | ssrMtrl.SetMatrix(shaderPropId_ssrVMatrix, cam.worldToCameraMatrix); 233 | ssrMtrl.SetMatrix(shaderPropId_ssrPMatrix, cam.projectionMatrix); 234 | ssrMtrl.SetVector(shaderPropId_screenPixelSize, new Vector2(Screen.width, Screen.height)); 235 | ssrRT.SetActiveRenderTexture(0); 236 | JCDSRenderTexture.ClearActiveRenderTexture(true, true, Color.black, 1.0f); 237 | DrawScreenQuad(ssrMtrl, 0, false, false); 238 | 239 | JCDSRenderTexture.ResetActiveRenderTexture(); 240 | DrawScreenQuad(compositeResultBufferMtrl, 3, true, true); 241 | 242 | JCDSRenderTexture.RestoreCurrentActiveBuffers(cam); 243 | } 244 | 245 | private void OnGUI() 246 | { 247 | if (debug) 248 | { 249 | int width = Screen.width / 4; 250 | int height = Screen.height / 4; 251 | Rect rect = new Rect(0, 0, width, height); 252 | OnGUI_DrawRTs(mrtGBuffer, ref rect, true); 253 | OnGUI_DrawRTs(ssrRT, ref rect, false); 254 | OnGUI_DrawRTs(resultRT, ref rect, true); 255 | OnGUI_DrawRTs(doubleFaceDepthRT, ref rect, false); 256 | } 257 | } 258 | 259 | private void OnGUI_DrawRTs(JCDSRenderTexture rt, ref Rect rect, bool isNewColumn) 260 | { 261 | int numRTs = rt.numRTs; 262 | for (int i = 0; i < numRTs; ++i) 263 | { 264 | GUI.DrawTexture(rect, rt.GetRenderTexture(i), ScaleMode.ScaleToFit, false); 265 | rect.y += rect.height; 266 | } 267 | if (isNewColumn) 268 | { 269 | rect.x += rect.width; 270 | rect.y = 0; 271 | } 272 | } 273 | 274 | private void CreateDoubleFaceDepthCamera() 275 | { 276 | GameObject go = new GameObject("DoubleFaceDepthCameraGo"); 277 | go.hideFlags = HideFlags.HideAndDontSave; 278 | go.transform.parent = cam.transform; 279 | go.transform.localPosition = Vector3.zero; 280 | go.transform.localEulerAngles = Vector3.zero; 281 | go.transform.localScale = Vector3.one; 282 | 283 | doubleFaceDepthCam = go.AddComponent(); 284 | doubleFaceDepthCam.enabled = false; 285 | doubleFaceDepthCam.cullingMask = cam.cullingMask; 286 | doubleFaceDepthCam.fieldOfView = cam.fieldOfView; 287 | doubleFaceDepthCam.orthographic = cam.orthographic; 288 | doubleFaceDepthCam.nearClipPlane = cam.nearClipPlane; 289 | doubleFaceDepthCam.farClipPlane = cam.farClipPlane; 290 | doubleFaceDepthCam.rect = cam.rect; 291 | doubleFaceDepthCam.clearFlags = CameraClearFlags.Nothing; 292 | } 293 | 294 | public void CollectLights() 295 | { 296 | dirLights = Light.GetLights(LightType.Directional, 0); 297 | pointLights = Light.GetLights(LightType.Point, 0); 298 | } 299 | 300 | private void DrawScreenQuad(Material mtrl, int pass, bool isScreen, bool clearScreen) 301 | { 302 | GraphicsDeviceType type = SystemInfo.graphicsDeviceType; 303 | bool isOpenGLLike = 304 | type == GraphicsDeviceType.OpenGL2 || 305 | type == GraphicsDeviceType.OpenGLCore || 306 | type == GraphicsDeviceType.OpenGLES2 || 307 | type == GraphicsDeviceType.OpenGLES3; 308 | 309 | bool isUvUpsideDown = isOpenGLLike || isScreen; 310 | 311 | if (clearScreen) 312 | { 313 | GL.Clear(true, true, Color.black); 314 | } 315 | mtrl.SetPass(isUvUpsideDown ? pass : (pass + 1)); 316 | GL.PushMatrix(); 317 | GL.Begin(GL.QUADS); 318 | GL.TexCoord2(0, 0); 319 | GL.Vertex3(-1, -1, 0); 320 | GL.TexCoord2(0, 1); 321 | GL.Vertex3(-1, 1, 0); 322 | GL.TexCoord2(1, 1); 323 | GL.Vertex3(1, 1, 0); 324 | GL.TexCoord2(1, 0); 325 | GL.Vertex3(1, -1, 0); 326 | GL.End(); 327 | GL.PopMatrix(); 328 | } 329 | } 330 | } 331 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/JCDSCamera.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b7888ae76a73edb4b83b82e210cef35e 3 | timeCreated: 1481874069 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/JCDSRenderTexture.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | namespace JCDeferredShading 5 | { 6 | public class JCDSRenderTexture 7 | { 8 | private static RenderBuffer currentActiveColorBuffer; 9 | 10 | private static RenderBuffer currentActiveDepthBuffer; 11 | 12 | private RenderTexture[] rts = null; 13 | 14 | private RenderBuffer[] colorBuffers = null; 15 | 16 | private RenderBuffer[] depthBuffers = null; 17 | 18 | private int depthBuffersMask = 0; 19 | 20 | private bool isDestroyed = false; 21 | 22 | public int numRTs 23 | { 24 | get 25 | { 26 | CheckIsDestroyed(); 27 | return rts == null ? 0 : rts.Length; 28 | } 29 | } 30 | 31 | public JCDSRenderTexture(int numRTs, int width, int height, int depthBuffersMask, RenderTextureFormat format, FilterMode filterMode, bool useMipMap) 32 | { 33 | CheckSize(width, height); 34 | 35 | if (numRTs <= 0) 36 | { 37 | throw new System.ArgumentException(); 38 | } 39 | 40 | if(!SystemInfo.SupportsRenderTextureFormat(format)) 41 | { 42 | throw new System.FormatException(); 43 | } 44 | 45 | rts = new RenderTexture[numRTs]; 46 | colorBuffers = new RenderBuffer[numRTs]; 47 | depthBuffers = new RenderBuffer[numRTs]; 48 | this.depthBuffersMask = depthBuffersMask; 49 | 50 | for(int i = 0; i < numRTs; ++i) 51 | { 52 | bool useDepth = MaskIsSet(depthBuffersMask, i); 53 | 54 | RenderTexture rt = new RenderTexture(width, height, useDepth ? 32 : 0, format); 55 | rt.generateMips = useMipMap; 56 | rt.useMipMap = useMipMap; 57 | rt.filterMode = filterMode; 58 | rt.Create(); 59 | rts[i] = rt; 60 | 61 | colorBuffers[i] = rt.colorBuffer; 62 | 63 | if(useDepth) 64 | { 65 | depthBuffers[i] = rt.depthBuffer; 66 | } 67 | } 68 | } 69 | 70 | public void Destroy() 71 | { 72 | if (rts != null) 73 | { 74 | int numRTs = rts.Length; 75 | for (int i = 0; i < numRTs; ++i) 76 | { 77 | RenderTexture.Destroy(rts[i]); 78 | rts[i] = null; 79 | } 80 | rts = null; 81 | 82 | colorBuffers = null; 83 | depthBuffers = null; 84 | } 85 | isDestroyed = true; 86 | } 87 | 88 | public void ResetSize(int width, int height) 89 | { 90 | CheckIsDestroyed(); 91 | CheckSize(width, height); 92 | 93 | int numRTs = rts.Length; 94 | for(int i = 0; i < numRTs; ++i) 95 | { 96 | RenderTexture rt = rts[i]; 97 | if(!rt.IsCreated() || rt.width != width || rt.height != height) 98 | { 99 | bool useDepth = MaskIsSet(depthBuffersMask, i); 100 | 101 | rt.Release(); 102 | rt.width = width; 103 | rt.height = height; 104 | rt.Create(); 105 | 106 | colorBuffers[i] = rt.colorBuffer; 107 | 108 | if(useDepth) 109 | { 110 | depthBuffers[i] = rt.depthBuffer; 111 | } 112 | } 113 | } 114 | } 115 | 116 | public static void SetMultipleRenderTargets(Camera camera, JCDSRenderTexture colorBuffers, JCDSRenderTexture depthBuffer, int depthBufferIndex) 117 | { 118 | if(camera == null || colorBuffers == null || depthBuffer == null) 119 | { 120 | throw new System.ArgumentNullException(); 121 | } 122 | 123 | camera.SetTargetBuffers(colorBuffers.GetColorBuffers(), depthBuffer.GetDepthBuffer(depthBufferIndex)); 124 | } 125 | 126 | public static void StoreCurrentActiveBuffers() 127 | { 128 | currentActiveColorBuffer = Graphics.activeColorBuffer; 129 | currentActiveDepthBuffer = Graphics.activeDepthBuffer; 130 | } 131 | 132 | public static void RestoreCurrentActiveBuffers(Camera camera) 133 | { 134 | camera.SetTargetBuffers(currentActiveColorBuffer, currentActiveDepthBuffer); 135 | } 136 | 137 | public void SetActiveRenderTexture(int index) 138 | { 139 | CheckIsDestroyed(); 140 | CheckIndex(index); 141 | 142 | RenderTexture rt = GetRenderTexture(index); 143 | Graphics.SetRenderTarget(rt); 144 | } 145 | 146 | public static void ResetActiveRenderTexture() 147 | { 148 | Graphics.SetRenderTarget(null); 149 | } 150 | 151 | public static void ClearActiveRenderTexture(bool clearDepth, bool clearColor, Color backgroundColor, float defaultDepthValue) 152 | { 153 | GL.Clear(clearDepth, clearColor, backgroundColor, defaultDepthValue); 154 | } 155 | 156 | public RenderTexture[] GetRenderTextures() 157 | { 158 | CheckIsDestroyed(); 159 | return rts; 160 | } 161 | 162 | public RenderBuffer[] GetColorBuffers() 163 | { 164 | CheckIsDestroyed(); 165 | return colorBuffers; 166 | } 167 | 168 | public RenderBuffer[] GetDepthBuffers() 169 | { 170 | CheckIsDestroyed(); 171 | return depthBuffers; 172 | } 173 | 174 | public RenderTexture GetRenderTexture(int index) 175 | { 176 | CheckIsDestroyed(); 177 | CheckIndex(index); 178 | 179 | return rts[index]; 180 | } 181 | 182 | public RenderBuffer GetColorBuffer(int index) 183 | { 184 | CheckIsDestroyed(); 185 | CheckIndex(index); 186 | 187 | return colorBuffers[index]; 188 | } 189 | 190 | public RenderBuffer GetDepthBuffer(int index) 191 | { 192 | CheckIsDestroyed(); 193 | 194 | if (!MaskIsSet(depthBuffersMask, index)) 195 | { 196 | throw new System.ArgumentException(); 197 | } 198 | 199 | return depthBuffers[index]; 200 | } 201 | 202 | private void CheckSize(int width, int height) 203 | { 204 | if (width <= 0 || height <= 0) 205 | { 206 | throw new System.ArgumentException(); 207 | } 208 | } 209 | 210 | private void CheckIndex(int index) 211 | { 212 | if (index < 0 || index >= rts.Length) 213 | { 214 | throw new System.IndexOutOfRangeException(); 215 | } 216 | } 217 | 218 | private void CheckIsDestroyed() 219 | { 220 | if(isDestroyed) 221 | { 222 | throw new System.InvalidOperationException(); 223 | } 224 | } 225 | 226 | public static bool MaskIsSet(int mask, int index) 227 | { 228 | return ((mask >> index) & 1) == 1; 229 | } 230 | 231 | public static int ValueToMask(bool[] values) 232 | { 233 | int mask = 0; 234 | if (values == null) 235 | { 236 | return mask; 237 | } 238 | for (int i = 0; i < values.Length; ++i) 239 | { 240 | if (values[i]) 241 | { 242 | mask |= 1 << i; 243 | } 244 | } 245 | return mask; 246 | } 247 | } 248 | } 249 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/JCDSRenderTexture.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7dd3a59007aca094ab579ec4ad224da2 3 | timeCreated: 1482977105 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/JCDeferredShading.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/Assets/JCDeferredShading/JCDeferredShading.mat -------------------------------------------------------------------------------- /Assets/JCDeferredShading/JCDeferredShading.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 67bef245cc8ed65449afbb4dd3d78872 3 | timeCreated: 1481877304 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/JCDeferredShading1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/Assets/JCDeferredShading/JCDeferredShading1.mat -------------------------------------------------------------------------------- /Assets/JCDeferredShading/JCDeferredShading1.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3c57743dad322a34b8a81b713bd703a1 3 | timeCreated: 1481877304 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Orc Skin (Diffuse).psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/Assets/JCDeferredShading/Orc Skin (Diffuse).psd -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Orc Skin (Diffuse).psd.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a96ee9c8f84d70749b6b23a54d7bfd17 3 | timeCreated: 1482202241 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 2 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | linearTexture: 0 12 | correctGamma: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 0 25 | cubemapConvolution: 0 26 | cubemapConvolutionSteps: 7 27 | cubemapConvolutionExponent: 1.5 28 | seamlessCubemap: 0 29 | textureFormat: -1 30 | maxTextureSize: 2048 31 | textureSettings: 32 | filterMode: -1 33 | aniso: -1 34 | mipBias: -1 35 | wrapMode: -1 36 | nPOTScale: 1 37 | lightmap: 0 38 | rGBM: 0 39 | compressionQuality: 50 40 | spriteMode: 0 41 | spriteExtrude: 1 42 | spriteMeshType: 1 43 | alignment: 0 44 | spritePivot: {x: 0.5, y: 0.5} 45 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 46 | spritePixelsToUnits: 100 47 | alphaIsTransparency: 0 48 | spriteTessellationDetail: -1 49 | textureType: -1 50 | buildTargetSettings: [] 51 | spriteSheet: 52 | serializedVersion: 2 53 | sprites: [] 54 | outline: [] 55 | spritePackingTag: 56 | userData: 57 | assetBundleName: 58 | assetBundleVariant: 59 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Orc Skin (Normal).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/Assets/JCDeferredShading/Orc Skin (Normal).png -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Orc Skin (Normal).png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 80247ad3e6cc18e4f966bf64eb366483 3 | timeCreated: 1482202240 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 2 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | linearTexture: 1 12 | correctGamma: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 1 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 0 25 | cubemapConvolution: 0 26 | cubemapConvolutionSteps: 7 27 | cubemapConvolutionExponent: 1.5 28 | seamlessCubemap: 0 29 | textureFormat: -1 30 | maxTextureSize: 2048 31 | textureSettings: 32 | filterMode: -1 33 | aniso: -1 34 | mipBias: -1 35 | wrapMode: -1 36 | nPOTScale: 1 37 | lightmap: 0 38 | rGBM: 0 39 | compressionQuality: 50 40 | spriteMode: 0 41 | spriteExtrude: 1 42 | spriteMeshType: 1 43 | alignment: 0 44 | spritePivot: {x: 0.5, y: 0.5} 45 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 46 | spritePixelsToUnits: 100 47 | alphaIsTransparency: 0 48 | spriteTessellationDetail: -1 49 | textureType: 1 50 | buildTargetSettings: [] 51 | spriteSheet: 52 | serializedVersion: 2 53 | sprites: [] 54 | outline: [] 55 | spritePackingTag: 56 | userData: 57 | assetBundleName: 58 | assetBundleVariant: 59 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9bb7c44bbe4f33346ac986d7e0eb7765 3 | folderAsset: yes 4 | timeCreated: 1482122553 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Resources/BackFaceDepth.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/JCDeferredShading/BackFaceDepth" 2 | { 3 | Properties 4 | { 5 | } 6 | 7 | CGINCLUDE 8 | 9 | #include "UnityCG.cginc" 10 | #include "JCDSInclude.cginc" 11 | 12 | ENDCG 13 | 14 | SubShader 15 | { 16 | Pass 17 | { 18 | ColorMask G 19 | ZTest LEqual 20 | ZWrite On 21 | Cull Front 22 | 23 | CGPROGRAM 24 | #pragma vertex vert_double_face_depth 25 | #pragma fragment frag_back_face_depth 26 | ENDCG 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Resources/BackFaceDepth.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9cc1142ed3990744b9995ebfd40b51d3 3 | timeCreated: 1482122474 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Resources/CompositeResultBuffer.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/JCDeferredShading/CompositeResultBuffer" 2 | { 3 | Properties 4 | { 5 | } 6 | 7 | CGINCLUDE 8 | 9 | #include "UnityCG.cginc" 10 | #include "JCDSInclude.cginc" 11 | 12 | v2f vert_point_lighting(appdata v) 13 | { 14 | v2f o; 15 | UNITY_INITIALIZE_OUTPUT(v2f, o); 16 | 17 | o.vertex = UnityObjectToClipPos(v.vertex); 18 | o.pos = o.vertex; 19 | o.uv = v.uv; 20 | return o; 21 | } 22 | 23 | float4 frag_dir_lighting(v2f i) : SV_Target 24 | { 25 | float4 diffuse = tex2D(_DiffuseBuffer, i.uv); 26 | float3 wNormal = tex2D(_NormalBuffer, i.uv); 27 | float3 wLightDir = _DirLightDir.xyz; 28 | float4 c = diffuse * _DirLightColor * _DirLightDir.w * dot(wNormal, wLightDir); 29 | 30 | return c; 31 | } 32 | 33 | float4 frag_point_lighting(v2f i) : SV_Target 34 | { 35 | float2 screenUV = pos_to_screen_uv(i.pos); 36 | 37 | float4 diffuse = tex2D(_DiffuseBuffer, screenUV); 38 | float4 wFragPos = tex2D(_PositionBuffer, screenUV); 39 | float3 wLightDir = _PointLightPos.xyz - wFragPos.xyz; 40 | float3 wLightDir_norm = normalize(wLightDir); 41 | float3 wNormal = tex2D(_NormalBuffer, screenUV); 42 | float3 wEyePos = _WorldSpaceCameraPos.xyz; 43 | float3 wEyeDir = normalize(wEyePos - wFragPos.xyz); 44 | float3 wHalf = normalize(wEyeDir + wLightDir_norm); 45 | float wNdotH = max(0, dot(wHalf, wNormal)); 46 | float specular = pow(wNdotH, diffuse.a); 47 | float wNdotD = max(0, dot(wNormal, wLightDir_norm)); 48 | float attenuation = (1 - saturate(length(wLightDir) * _PointLightRange.x)); 49 | 50 | float4 c = float4(0,0,0,1); 51 | c += diffuse *_PointLightColor * _PointLightRange.y * wNdotD * attenuation; 52 | c += specular * attenuation * wNdotD * _PointLightRange.y; 53 | c.a = 1; 54 | 55 | return c; 56 | } 57 | 58 | float4 frag_result(v2f i) : SV_Target 59 | { 60 | fixed4 resultC = tex2D(_ResultBuffer, i.uv); 61 | fixed4 ssrC = tex2D(_SSRBuffer, i.uv); 62 | fixed4 c = resultC + resultC * ssrC * 2; 63 | return c; 64 | } 65 | 66 | ENDCG 67 | 68 | SubShader 69 | { 70 | // Directional Lighting 71 | // Normal uv orientation 72 | Pass 73 | { 74 | Blend One One 75 | ZTest Always 76 | ZWrite Off 77 | Cull Back 78 | 79 | CGPROGRAM 80 | #pragma vertex vert_screen_quad 81 | #pragma fragment frag_dir_lighting 82 | ENDCG 83 | } 84 | 85 | // Directional Lighting 86 | // Upside down uv orientation(UV_STARTS_AT_TOP) 87 | Pass 88 | { 89 | Blend One One 90 | ZTest Always 91 | ZWrite Off 92 | Cull Front 93 | 94 | CGPROGRAM 95 | #pragma vertex vert_screen_quad 96 | #pragma fragment frag_dir_lighting 97 | ENDCG 98 | } 99 | 100 | // Point lighting 101 | Pass 102 | { 103 | Blend One One 104 | ZTest Greater 105 | ZWrite Off 106 | Cull Front 107 | 108 | CGPROGRAM 109 | #pragma vertex vert_point_lighting 110 | #pragma fragment frag_point_lighting 111 | ENDCG 112 | } 113 | 114 | // Result 115 | Pass 116 | { 117 | CGPROGRAM 118 | #pragma vertex vert_screen_quad 119 | #pragma fragment frag_result 120 | ENDCG 121 | } 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Resources/CompositeResultBuffer.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cc1ce5572d28eca49a32dac0076a8143 3 | timeCreated: 1482122474 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Resources/FrontFaceDepth.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/JCDeferredShading/FrontFaceDepth" 2 | { 3 | Properties 4 | { 5 | } 6 | 7 | CGINCLUDE 8 | 9 | #include "UnityCG.cginc" 10 | #include "JCDSInclude.cginc" 11 | 12 | ENDCG 13 | 14 | SubShader 15 | { 16 | Pass 17 | { 18 | ColorMask R 19 | ZTest LEqual 20 | ZWrite On 21 | Cull Back 22 | 23 | CGPROGRAM 24 | #pragma vertex vert_double_face_depth 25 | #pragma fragment frag_front_face_depth 26 | ENDCG 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Resources/FrontFaceDepth.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: afd126dff31e9704db826128494d3be2 3 | timeCreated: 1482122474 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Resources/JCDSInclude.cginc: -------------------------------------------------------------------------------- 1 | #ifndef __JCDS_INCLUDE__ 2 | #define __JCDS_INCLUDE__ 3 | 4 | uniform sampler2D _DiffuseBuffer; 5 | uniform sampler2D _NormalBuffer; 6 | uniform sampler2D _PositionBuffer; 7 | uniform sampler2D _ResultBuffer; 8 | uniform sampler2D _SSRBuffer; 9 | uniform sampler2D _DoubleFaceDepthBuffer; 10 | 11 | uniform float4x4 _SSR_VP_MATRIX; 12 | uniform float4x4 _SSR_V_MATRIX; 13 | uniform float4x4 _SSR_P_MATRIX; 14 | 15 | uniform float2 _ScreenPixelSize; 16 | 17 | uniform float4 _DirLightDir; 18 | uniform fixed4 _DirLightColor; 19 | 20 | uniform float3 _PointLightPos; 21 | uniform fixed4 _PointLightColor; 22 | uniform float4 _PointLightRange; 23 | 24 | struct appdata 25 | { 26 | float4 vertex : POSITION; 27 | float2 uv : TEXCOORD0; 28 | }; 29 | 30 | struct v2f 31 | { 32 | float2 uv : TEXCOORD0; 33 | float4 pos : TEXCOORD1; 34 | float4 vertex : SV_POSITION; 35 | }; 36 | 37 | v2f vert_screen_quad(appdata v) 38 | { 39 | v2f o; 40 | UNITY_INITIALIZE_OUTPUT(v2f, o); 41 | 42 | o.vertex = v.vertex; 43 | o.uv = v.uv; 44 | 45 | if (_ProjectionParams.x < 0) 46 | o.uv.y = 1 - o.uv.y; 47 | 48 | return o; 49 | } 50 | 51 | inline float2 pos_to_screen_uv(float4 pos) 52 | { 53 | float2 screenUV = pos.xy / pos.w * 0.5 + 0.5; 54 | 55 | #if UNITY_UV_STARTS_AT_TOP 56 | screenUV.y = 1.0 - screenUV.y; 57 | #endif 58 | 59 | return screenUV; 60 | } 61 | 62 | struct ps_out_double_fade_depth 63 | { 64 | float4 depth : SV_TARGET0; 65 | }; 66 | 67 | v2f vert_double_face_depth(appdata v) 68 | { 69 | v2f o; 70 | UNITY_INITIALIZE_OUTPUT(v2f, o); 71 | 72 | o.vertex = UnityObjectToClipPos(v.vertex); 73 | o.pos = mul(UNITY_MATRIX_V, mul(unity_ObjectToWorld, v.vertex)); 74 | return o; 75 | } 76 | 77 | ps_out_double_fade_depth frag_front_face_depth(v2f i) 78 | { 79 | ps_out_double_fade_depth o; 80 | UNITY_INITIALIZE_OUTPUT(ps_out_double_fade_depth, o); 81 | 82 | float4 depth = float4(i.pos.z, 0, 0, 0); 83 | o.depth = depth; 84 | return o; 85 | } 86 | 87 | ps_out_double_fade_depth frag_back_face_depth(v2f i) 88 | { 89 | ps_out_double_fade_depth o; 90 | UNITY_INITIALIZE_OUTPUT(ps_out_double_fade_depth, o); 91 | 92 | float4 depth = float4(0, i.pos.z, 0, 0); 93 | o.depth = depth; 94 | return o; 95 | } 96 | 97 | #endif -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Resources/JCDSInclude.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 00b10eb34cfa6bf46b8d8087b4c17f53 3 | timeCreated: 1482991231 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Resources/JCDeferredShading.shader: -------------------------------------------------------------------------------- 1 | Shader "Unlit/JCDeferredShading" 2 | { 3 | Properties 4 | { 5 | _MainTex ("Texture", 2D) = "white" {} 6 | _BumpMap("Bump Map", 2D) = "bump" {} 7 | _Shininess("Shininess", Range(0.1, 500)) = 50 8 | _BumpIntensity("Bump Intensity", Range(0.1, 1)) = 1 9 | } 10 | SubShader 11 | { 12 | Tags { "RenderType"="Opaque" } 13 | LOD 100 14 | 15 | Pass 16 | { 17 | CGPROGRAM 18 | #pragma vertex vert 19 | #pragma fragment frag 20 | 21 | #include "UnityCG.cginc" 22 | 23 | struct appdata 24 | { 25 | float4 vertex : POSITION; 26 | float2 uv : TEXCOORD0; 27 | float3 normal : NORMAL; 28 | float4 tangent : TANGENT; 29 | }; 30 | 31 | struct v2f 32 | { 33 | float2 uv : TEXCOORD0; 34 | float2 uv_bump : TEXCOORD1; 35 | float4 vertex : SV_POSITION; 36 | float3 wNormal : TEXCOORD2; 37 | float3 wTangent : TEXCOORD3; 38 | float3 wBinormal : TEXCOORD4; 39 | float3 wPos : TEXCOORD5; 40 | }; 41 | 42 | struct ps_out 43 | { 44 | float4 diffuse : SV_TARGET0; 45 | float4 normal : SV_TARGET1; 46 | float4 position : SV_TARGET2; 47 | }; 48 | 49 | sampler2D _MainTex; 50 | float4 _MainTex_ST; 51 | 52 | sampler2D _BumpMap; 53 | float4 _BumpMap_ST; 54 | 55 | float _Shininess; 56 | float _BumpIntensity; 57 | 58 | v2f vert (appdata v) 59 | { 60 | v2f o; 61 | o.vertex = UnityObjectToClipPos(v.vertex); 62 | o.uv = TRANSFORM_TEX(v.uv, _MainTex); 63 | o.uv_bump = TRANSFORM_TEX(v.uv, _BumpMap); 64 | 65 | o.wNormal = UnityObjectToWorldNormal(v.normal); 66 | o.wTangent = UnityObjectToWorldDir(v.tangent.xyz); 67 | o.wBinormal = cross(o.wNormal, o.wTangent) * v.tangent.w; 68 | 69 | o.wPos = mul(unity_ObjectToWorld, v.vertex).xyz; 70 | 71 | return o; 72 | } 73 | 74 | ps_out frag (v2f i) 75 | { 76 | ps_out o; 77 | UNITY_INITIALIZE_OUTPUT(ps_out, o); 78 | 79 | fixed4 col = tex2D(_MainTex, i.uv); 80 | float3 normal = UnpackNormal(tex2D(_BumpMap, i.uv_bump)); 81 | normal = lerp(float3(0,0,1), normal, _BumpIntensity); 82 | float3x3 worldToTangent = float3x3(i.wTangent, i.wBinormal, i.wNormal); 83 | float3 wNormal = normalize(mul(normal, worldToTangent))/*tangent to world*/; 84 | 85 | o.diffuse = float4(col.rgb, _Shininess); 86 | o.normal = float4(wNormal, 1); 87 | o.position = float4(i.wPos, 1); 88 | 89 | return o; 90 | } 91 | ENDCG 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Resources/JCDeferredShading.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 887b07dd0a401bc4e8c5106192c7d4cc 3 | timeCreated: 1481872208 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Resources/ScreenSpaceReflection.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/JCDeferredShading/ScreenSpaceReflection" 2 | { 3 | Properties 4 | { 5 | } 6 | 7 | CGINCLUDE 8 | 9 | #include "UnityCG.cginc" 10 | #include "JCDSInclude.cginc" 11 | 12 | fixed4 frag(v2f i) : SV_Target 13 | { 14 | fixed4 c = fixed4(0,0,0,0); 15 | float2 screenUV = i.uv; 16 | 17 | float4 wFragPos = tex2D(_PositionBuffer, screenUV); 18 | if (wFragPos.w == 0) 19 | { 20 | return c; 21 | } 22 | else 23 | { 24 | float3 wNormal = tex2D(_NormalBuffer, screenUV); 25 | float3 wEyePos = _WorldSpaceCameraPos.xyz; 26 | float3 wEyeDir = normalize(wEyePos - wFragPos.xyz); 27 | float3 wRefl = reflect(-wEyeDir, wNormal); 28 | 29 | if (dot(wEyeDir, wNormal) <= 0) 30 | { 31 | return c; 32 | } 33 | 34 | float3 vRefl = mul(_SSR_V_MATRIX, float4(wRefl, 0)).xyz; 35 | float3 vPos0 = mul(_SSR_V_MATRIX, float4(wFragPos.xyz, 1)).xyz; 36 | float3 vPos1 = vPos0 + vRefl; 37 | float4 clipPos0 = mul(_SSR_P_MATRIX, float4(vPos0, 1)); 38 | float4 clipPos1 = mul(_SSR_P_MATRIX, float4(vPos1, 1)); 39 | float2 uv0 = clipPos0.xy / clipPos0.w * 0.5 + 0.5; 40 | float2 uv1 = clipPos1.xy / clipPos1.w * 0.5 + 0.5; 41 | float2 pixel0 = uv0 * _ScreenPixelSize; 42 | float2 pixel1 = uv1 * _ScreenPixelSize; 43 | 44 | float2 delta = pixel1 - pixel0; 45 | bool isSwapped = false; 46 | if (abs(delta.x) < abs(delta.y)) 47 | { 48 | isSwapped = true; 49 | delta.xy = delta.yx; 50 | pixel0.xy = pixel0.yx; 51 | pixel1.xy = pixel1.yx; 52 | } 53 | float signDir = sign(delta.x); 54 | if (signDir == 0) 55 | { 56 | return c; 57 | } 58 | float invdx = signDir / delta.x; 59 | float2 dPixel = float2(signDir, delta.y * invdx); 60 | float dVPosZ = (vPos1.z - vPos0.z) * invdx; 61 | 62 | float depthTolerance = 0; 63 | float startOffsetFactor = 2; 64 | float stepScale = 1.5; 65 | float vPosZ = vPos0.z + dVPosZ*startOffsetFactor; 66 | float2 pixel = pixel0 + dPixel*startOffsetFactor; 67 | float count = 0; 68 | float loop = 100; 69 | for (; /*pixel.x * __sign < pixel1.x * __sign*/count < loop; pixel += dPixel*stepScale, vPosZ += dVPosZ*stepScale, ++count) 70 | { 71 | float2 unswappedPixel = isSwapped ? pixel.yx : pixel.xy; 72 | float2 uv = unswappedPixel / _ScreenPixelSize; 73 | if (uv.x < 0 || uv.y < 0 || uv.x > 1 || uv.y > 1) 74 | { 75 | break; 76 | } 77 | float4 doubleFaceDepth = tex2D(_DoubleFaceDepthBuffer, uv); 78 | // vPosZ and doubleFaceDepth.xy are negative values 79 | if (vPosZ < doubleFaceDepth.x-depthTolerance && vPosZ > doubleFaceDepth.y+depthTolerance) 80 | { 81 | c = tex2D(_ResultBuffer, uv) * min((1 - (count / loop)) * 1.5, 1); 82 | break; 83 | } 84 | } 85 | 86 | return c; 87 | } 88 | } 89 | ENDCG 90 | 91 | SubShader 92 | { 93 | Pass 94 | { 95 | Blend One One 96 | ZTest Always 97 | ZWrite Off 98 | Cull Back 99 | 100 | CGPROGRAM 101 | #pragma vertex vert_screen_quad 102 | #pragma fragment frag 103 | ENDCG 104 | } 105 | 106 | Pass 107 | { 108 | Blend One One 109 | ZTest Always 110 | ZWrite Off 111 | Cull Front 112 | 113 | CGPROGRAM 114 | #pragma vertex vert_screen_quad 115 | #pragma fragment frag 116 | ENDCG 117 | } 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Resources/ScreenSpaceReflection.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 275334557e25f98498d5d1d92e4a79f6 3 | timeCreated: 1482974555 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Test0.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/Assets/JCDeferredShading/Test0.unity -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Test0.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9b33b25424c78be47b4541f1ab6eca3a 3 | timeCreated: 1481872142 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Test1.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using JCDeferredShading; 5 | 6 | public class Test1 : MonoBehaviour 7 | { 8 | private class LightObject 9 | { 10 | public Light light = null; 11 | 12 | public float lifeTime = 0.0f; 13 | } 14 | 15 | public GameObject lightPrefab = null; 16 | 17 | private List workingLights = null; 18 | 19 | private List freeLights = null; 20 | 21 | private float time = 0.0f; 22 | 23 | private void Start() 24 | { 25 | workingLights = new List(); 26 | freeLights = new List(); 27 | } 28 | 29 | private void Update() 30 | { 31 | time += Time.deltaTime; 32 | if(time > 0.75f) 33 | { 34 | time = 0; 35 | 36 | LightObject lightObj = null; 37 | if(freeLights.Count == 0) 38 | { 39 | lightObj = new LightObject() { light = (GameObject.Instantiate(lightPrefab) as GameObject).GetComponent() }; 40 | } 41 | else 42 | { 43 | lightObj = freeLights[freeLights.Count - 1]; 44 | freeLights.RemoveAt(freeLights.Count - 1); 45 | } 46 | 47 | lightObj.lifeTime = 60.0f; 48 | workingLights.Add(lightObj); 49 | lightObj.light.intensity = 1; 50 | lightObj.light.color = new Color(Random.Range(0.1f, 1.0f), Random.Range(0.1f, 1.0f), Random.Range(0.1f, 1.0f)); 51 | lightObj.light.transform.position = transform.position; 52 | lightObj.light.gameObject.SetActive(true); 53 | lightObj.light.GetComponent().isKinematic = false; 54 | lightObj.light.GetComponent().AddForce(transform.up*1000, ForceMode.Acceleration); 55 | 56 | if(JCDSCamera.instance != null) 57 | { 58 | JCDSCamera.instance.CollectLights(); 59 | } 60 | } 61 | 62 | int numLights = workingLights.Count; 63 | for(int i = 0; i < numLights; ++i) 64 | { 65 | LightObject lightObj = workingLights[i]; 66 | lightObj.lifeTime -= Time.deltaTime; 67 | if(lightObj.lifeTime < 1.0f) 68 | { 69 | lightObj.light.intensity -= 0.5f * Time.deltaTime; 70 | } 71 | if(lightObj.lifeTime < 0.0f && lightObj.light.intensity <= 0) 72 | { 73 | lightObj.light.GetComponent().isKinematic = true; 74 | lightObj.light.gameObject.SetActive(false); 75 | workingLights.RemoveAt(i); 76 | freeLights.Add(lightObj); 77 | --numLights; 78 | --i; 79 | } 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Test1.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4eecaabd454e1894baa8b839664b5684 3 | timeCreated: 1482212922 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Test1.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/Assets/JCDeferredShading/Test1.unity -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Test1.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b45018c09a20a4544bf63135e1f360d9 3 | timeCreated: 1482210601 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Tiles_Albedo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/Assets/JCDeferredShading/Tiles_Albedo.jpg -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Tiles_Albedo.jpg.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 56010d8af5bea49418da64dacebbe726 3 | timeCreated: 1483002548 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 2 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | linearTexture: 0 12 | correctGamma: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 0 25 | cubemapConvolution: 0 26 | cubemapConvolutionSteps: 7 27 | cubemapConvolutionExponent: 1.5 28 | seamlessCubemap: 0 29 | textureFormat: -1 30 | maxTextureSize: 2048 31 | textureSettings: 32 | filterMode: -1 33 | aniso: -1 34 | mipBias: -1 35 | wrapMode: -1 36 | nPOTScale: 1 37 | lightmap: 0 38 | rGBM: 0 39 | compressionQuality: 50 40 | spriteMode: 0 41 | spriteExtrude: 1 42 | spriteMeshType: 1 43 | alignment: 0 44 | spritePivot: {x: 0.5, y: 0.5} 45 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 46 | spritePixelsToUnits: 100 47 | alphaIsTransparency: 0 48 | spriteTessellationDetail: -1 49 | textureType: -1 50 | buildTargetSettings: [] 51 | spriteSheet: 52 | serializedVersion: 2 53 | sprites: [] 54 | outline: [] 55 | spritePackingTag: 56 | userData: 57 | assetBundleName: 58 | assetBundleVariant: 59 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Tiles_Normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/Assets/JCDeferredShading/Tiles_Normal.png -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Tiles_Normal.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9f33d950c30f7f04caec8d60bd4a6159 3 | timeCreated: 1483002549 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 2 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | linearTexture: 1 12 | correctGamma: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 1 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 0 25 | cubemapConvolution: 0 26 | cubemapConvolutionSteps: 7 27 | cubemapConvolutionExponent: 1.5 28 | seamlessCubemap: 0 29 | textureFormat: -1 30 | maxTextureSize: 2048 31 | textureSettings: 32 | filterMode: -1 33 | aniso: -1 34 | mipBias: -1 35 | wrapMode: -1 36 | nPOTScale: 1 37 | lightmap: 0 38 | rGBM: 0 39 | compressionQuality: 50 40 | spriteMode: 0 41 | spriteExtrude: 1 42 | spriteMeshType: 1 43 | alignment: 0 44 | spritePivot: {x: 0.5, y: 0.5} 45 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 46 | spritePixelsToUnits: 100 47 | alphaIsTransparency: 0 48 | spriteTessellationDetail: -1 49 | textureType: 1 50 | buildTargetSettings: [] 51 | spriteSheet: 52 | serializedVersion: 2 53 | sprites: [] 54 | outline: [] 55 | spritePackingTag: 56 | userData: 57 | assetBundleName: 58 | assetBundleVariant: 59 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Wall 1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/Assets/JCDeferredShading/Wall 1.mat -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Wall 1.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e353b323056a64c94a3ff3bc3f8303c4 3 | timeCreated: 1482212189 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Wall.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/Assets/JCDeferredShading/Wall.mat -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Wall.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 73ca92c5ccf2c3a479c51ed55390dc80 3 | timeCreated: 1482212189 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Wall.physicMaterial: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/Assets/JCDeferredShading/Wall.physicMaterial -------------------------------------------------------------------------------- /Assets/JCDeferredShading/Wall.physicMaterial.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b9472af31dda574469b99b285bfa9c57 3 | timeCreated: 1482212673 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/wall.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/Assets/JCDeferredShading/wall.tga -------------------------------------------------------------------------------- /Assets/JCDeferredShading/wall.tga.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9069284085b0c584dae447ab977305a4 3 | timeCreated: 1482212258 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 2 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | linearTexture: 0 12 | correctGamma: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 0 25 | cubemapConvolution: 0 26 | cubemapConvolutionSteps: 7 27 | cubemapConvolutionExponent: 1.5 28 | seamlessCubemap: 0 29 | textureFormat: -1 30 | maxTextureSize: 2048 31 | textureSettings: 32 | filterMode: -1 33 | aniso: -1 34 | mipBias: -1 35 | wrapMode: -1 36 | nPOTScale: 1 37 | lightmap: 0 38 | rGBM: 0 39 | compressionQuality: 50 40 | spriteMode: 0 41 | spriteExtrude: 1 42 | spriteMeshType: 1 43 | alignment: 0 44 | spritePivot: {x: 0.5, y: 0.5} 45 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 46 | spritePixelsToUnits: 100 47 | alphaIsTransparency: 0 48 | spriteTessellationDetail: -1 49 | textureType: -1 50 | buildTargetSettings: [] 51 | spriteSheet: 52 | serializedVersion: 2 53 | sprites: [] 54 | outline: [] 55 | spritePackingTag: 56 | userData: 57 | assetBundleName: 58 | assetBundleVariant: 59 | -------------------------------------------------------------------------------- /Assets/JCDeferredShading/wallN.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/Assets/JCDeferredShading/wallN.tga -------------------------------------------------------------------------------- /Assets/JCDeferredShading/wallN.tga.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 27c26c47eb235ca4fa02be3871ca91d6 3 | timeCreated: 1482212336 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 2 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | linearTexture: 1 12 | correctGamma: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 1 19 | externalNormalMap: 1 20 | heightScale: 0.061 21 | normalMapFilter: 1 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 0 25 | cubemapConvolution: 0 26 | cubemapConvolutionSteps: 7 27 | cubemapConvolutionExponent: 1.5 28 | seamlessCubemap: 0 29 | textureFormat: -1 30 | maxTextureSize: 2048 31 | textureSettings: 32 | filterMode: -1 33 | aniso: -1 34 | mipBias: -1 35 | wrapMode: -1 36 | nPOTScale: 1 37 | lightmap: 0 38 | rGBM: 0 39 | compressionQuality: 50 40 | spriteMode: 0 41 | spriteExtrude: 1 42 | spriteMeshType: 1 43 | alignment: 0 44 | spritePivot: {x: 0.5, y: 0.5} 45 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 46 | spritePixelsToUnits: 100 47 | alphaIsTransparency: 0 48 | spriteTessellationDetail: -1 49 | textureType: 1 50 | buildTargetSettings: [] 51 | spriteSheet: 52 | serializedVersion: 2 53 | sprites: [] 54 | outline: [] 55 | spritePackingTag: 56 | userData: 57 | assetBundleName: 58 | assetBundleVariant: 59 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/ProjectSettings/ClusterInputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/ProjectSettings/NavMeshAreas.asset -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 5.4.0f3 2 | m_StandardAssetsVersion: 0 3 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /ProjectSettings/UnityAdsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/ProjectSettings/UnityAdsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/ProjectSettings/UnityConnectSettings.asset -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | My First Deferred Rendering 2 | 3 | Deferred Shading: 4 | 5 | ![img](ScreenShot.jpg) 6 | 7 | Deferred Shading & Screen Space Reflection(World Space): 8 | 9 | ![img](ScreenShotSSR.jpg) 10 | 11 | Deferred Shading & Screen Space Reflection(Pixel Space): 12 | 13 | ![img](ScreenShotSSR2.jpg) -------------------------------------------------------------------------------- /ScreenShot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/ScreenShot.jpg -------------------------------------------------------------------------------- /ScreenShotSSR.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/ScreenShotSSR.jpg -------------------------------------------------------------------------------- /ScreenShotSSR2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chengkehan/DeferredRendering/1ceb4ac11919e8a8ce6a5cf85fb6ad2ff38eafe4/ScreenShotSSR2.jpg --------------------------------------------------------------------------------