I have a semi transparent shader on some objects which looks great in a render but when I encode it to a png via ReadPixels I get a different result and therefore its impossible to re-create the same image outside of Unity for example in photoshop. Is there a trick to fixing this?
So in a Unity render it looks like the second image and after saving and comping it looks like the top one. How do I make the top one look like the bottom one?
I can almost get what I want using “Screen” mode in photoshop but that messes up the non-transparent bits. Is there a way to modify the image alpha/colours before encoding it to png so it will comp the transparent bits like in screen mode but leave the rest untouched when just using a normal composite?
The shader code looks like this
Shader "My Shaders/XRay" {
Properties {
_Color ("Tint (RGB)", Color) = (1,1,1,1)
_RampTex ("Facing Ratio Ramp (RGB)", 2D) = "white" {}
_Tint ("Texture tint", Color) = (1,1,1,1)
_Rle ("Rle color", Color) = (0.5,0.5,0.5,1)
}
SubShader {
Cull Off //turn this on if using Blend One One
ZWrite Off
Tags { "RenderType"="Opaque" "Queue" = "Transparent" "VisibleInDepth"="On" }
//Blend One One
Blend One OneMinusSrcColor
Pass {
CGPROGRAM
#pragma vertex vert
#include "UnityCG.cginc"
struct v2f {
V2F_POS_FOG;
float4 uv : TEXCOORD0;
};
v2f vert (appdata_base v) {
v2f o;
PositionFog( v.vertex, o.pos, o.fog );
float3 viewDir = normalize(ObjSpaceViewDir(v.vertex));
o.uv = float4( abs(dot(viewDir,v.normal)), 0.5, 0.0, 1.0 );
return o;
}
ENDCG
SetTexture [_RampTex] {constantColor[_Color] combine texture * constant}
}
}
// Fallback to Alpha Vertex Lit
Fallback "Alpha/VertexLit", 2
}



