My transparent cutout shader for ‘home doorsteps’ is showing just fine on the MainCamera…
But when I call Camera.Render() on a secondary camera for generating item screenshots, it does not show up…
Shader code:
Shader "Custom/CutoutZAlways"
{
Properties{
_Color("Main Color", Color) = (1,1,1,1)
_MainTex("Base (RGB) Trans (A)", 2D) = "white" {}
_Cutoff("Alpha cutoff", Range(0,1)) = 0.5
}
SubShader{
Tags {"IgnoreProjector" = "True" "RenderType" = "TransparentCutout"}
LOD 200
ZTest Always
CGPROGRAM
#pragma surface surf Lambert alphatest:_Cutoff
sampler2D _MainTex;
fixed4 _Color;
struct Input {
float2 uv_MainTex;
};
void surf(Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
Fallback "Diffuse"
}
Screenshot code:
item_screenshots_cam.backgroundColor = new Color(0, 0, 0, 0);
RenderTexture rt = new RenderTexture(128, 128, 32);
item_screenshots_cam.targetTexture = rt;
Texture2D screenShot = new Texture2D(128, 128, TextureFormat.ARGB32, false);
item_screenshots_cam.Render();
RenderTexture.active = rt;
screenShot.ReadPixels(new Rect(0, 0, 128, 128), 0, 0);
//screenShot.Apply();
item_screenshots_cam.targetTexture = null;
RenderTexture.active = null; // JC: added to avoid errors
Destroy(rt);