Created
March 17, 2016 04:36
-
-
Save EsProgram/87511d7dbaec40c88616 to your computer and use it in GitHub Desktop.
G-Bufferを見てみる
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef GBUFFER_VARIANT | |
#define GBUFFER_VARIANT | |
sampler2D _CameraGBufferTexture0; | |
sampler2D _CameraGBufferTexture1; | |
sampler2D _CameraGBufferTexture2; | |
sampler2D _CameraGBufferTexture3; | |
#endif //GBUFFER_VARIANT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using UnityEngine; | |
[RequireComponent(typeof(Camera))] | |
public class PostProcess : MonoBehaviour | |
{ | |
public Material mat; | |
public void Start() | |
{ | |
GetComponent<Camera>().depthTextureMode |= DepthTextureMode.Depth; | |
} | |
[ImageEffectOpaque] | |
public void OnRenderImage(RenderTexture source, RenderTexture destination) | |
{ | |
Graphics.Blit(source, destination, mat); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shader "DeferedShadingTest/ShowGBuffer" | |
{ | |
Properties | |
{ | |
[KeywordEnum(DIFF, SPEC, NORM, LIGHT, DEPTH)] | |
_GB("G-Buffer Selecter", Float) = 0 | |
} | |
SubShader | |
{ | |
Cull Off ZWrite Off ZTest Always | |
Pass | |
{ | |
CGPROGRAM | |
#pragma vertex vert_img | |
#pragma fragment frag | |
#pragma shader_feature _GB_DIFF _GB_SPEC _GB_NORM _GB_LIGHT _GB_DEPTH | |
#include "UnityCG.cginc" | |
#include "GBufferVariant.cginc" | |
#include "UnityDeferredLibrary.cginc" | |
fixed4 frag (v2f_img i) : SV_Target | |
{ | |
#ifdef _GB_DIFF | |
return tex2D(_CameraGBufferTexture0, i.uv); | |
#elif _GB_SPEC | |
return tex2D(_CameraGBufferTexture1, i.uv); | |
#elif _GB_NORM | |
return tex2D(_CameraGBufferTexture2, i.uv); | |
#elif _GB_LIGHT | |
return tex2D(_CameraGBufferTexture3, i.uv); | |
#else | |
return Linear01Depth(tex2D(_CameraDepthTexture, i.uv).r); | |
#endif | |
} | |
ENDCG | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment