- Home /
Question by
hypeatized · Apr 20, 2016 at 05:50 PM ·
shadershadersshader programmingpost processingpostprocess
Custom postprocess white in build
I'm having some trouble with a custom post process i wrote for Unity. It's supposed to fade the colors of the scene using a color ramp texture according to depth. It works fine when I'm playing the game through the editor. But when I build the game everything is all white. So in some way my shader only gives white when running in a build but not in the play mode in the editor. I added my shader code below, the interesting rows are probably 34-37. Any suggestions?
Shader "Custom/Tint"
{
Properties
{
_MainTex("", any) = "" {}
_FogRamp("", 2D) = "white" {}
}
CGINCLUDE
#pragma target 4.0
#include "UnityCG.cginc"
struct v2f
{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
sampler2D _MainTex;
sampler2D _CameraDepthTexture;
sampler2D _FogRamp;
v2f vert(appdata_img v)
{
v2f o = (v2f)0;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.uv = v.texcoord;
return o;
}
float4 frag(v2f input) : SV_Target
{
float depth = Linear01Depth(tex2D(_CameraDepthTexture, input.uv));
float4 fogColor = tex2D(_FogRamp, float2(depth, 0));
float4 result = lerp(tex2D(_MainTex, input.uv), fogColor, fogColor.a);
return result;
}
ENDCG
SubShader
{
Pass
{
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
ENDCG
}
}
Fallback off
}
Comment