Quantcast
Channel: Latest Questions by Emil_FAWorks
Viewing all articles
Browse latest Browse all 6

Why doesn't my CGshader affect the cameraZbuffer?

$
0
0
I'm using a CGshader that changes the z of any given object. But I can't see the result in the zbuffer result of the camera (thus rendering it useless for post effects) I'm going crazy over this :( Here's an example code: Shader "Custom/DioramaBG" { Properties { } SubShader { Pass { CGPROGRAM #pragma target 4.0 #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" struct v2f { float4 position : POSITION; float2 uv : TEXCOORD0; }; struct fragOut { half4 color : SV_Target; float depth : SV_Depth; }; v2f vert(appdata_base v) { v2f o; o.position = mul(UNITY_MATRIX_MVP, v.vertex); o.uv = v.texcoord; return o; } fragOut frag(in v2f i) { fragOut o; o.color = 1; o.depth = i.position.z+0.001; return o; } ENDCG } } }

Viewing all articles
Browse latest Browse all 6

Latest Images

Trending Articles





Latest Images