- Home /
Question by
JawadWalkerUnity · Jun 11, 2016 at 06:58 PM ·
unity 5shaderimage effectsbufferdeferred rendering
G-Buffers don't exist...
Hi, I'm trying to make a shader that adds my custom sunlight effect, so in an image effect, I need to acces the normal g-buffer (_CameraGBufferTexture2), but it doesn't exist (Unity never sets the uniform anywhere). I know this because when I try to sample it, it gives me a grey color, and when I sample a sampler that obviously wouldn't exist, it also gives me a grey color. Here's my shader code:
Shader "Hidden/Grayscale Effect" {
Properties {
}
SubShader {
Pass {
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"
uniform sampler2D _CameraGBufferTexture2;
float4 frag (v2f_img i) : SV_Target
{
half4 normal=tex2D(_CameraGBufferTexture2, i.uv);
return float4(normal.x,normal.y,normal.z,1.0);
}
ENDCG
}
}
Fallback off
}
I'm working off the greyscale image effect from the standard assets, so do I need to set anything else outside the shader? I'm using unity 5.4b20. Thank you :)
Comment