Re: Offscreen Texture Alpha
I added Blend Off, which I believe was already on as a default setting.
Re: doing the operation during object vs render target camera rendering... The reason I am applying this shader to the output texture instead of the rendered object is so that I am not required to change the many shaders used by different game objects! I'm honestly at a loss for how to make this work with Noesis.
Code: Select all
Shader "Noesis/Alpha Blended Premultiply" {
Properties{
_MainTex("RenderTexture", 2D) = "black" {}
}
Category{
Blend Off
Cull Off
Lighting Off
ZWrite Off
Fog { Mode Off }
SubShader {
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _MainTex;
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
float2 texcoord : TEXCOORD0;
};
float4 _MainTex_ST;
v2f vert(appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
return o;
}
fixed4 frag(v2f i) : SV_Target
{
fixed4 c = tex2D(_MainTex, i.texcoord);
c.r *= c.a;
c.g *= c.a;
c.b *= c.a;
return c;
}
ENDCG
}
}
}
}
Re: Offscreen Texture Alpha
Could you please capture and attach the generated image with that shader? I want to analyze the RGBA values.
Re: Offscreen Texture Alpha
Yes. What texture format should the bytes be written as? (argb32)?
Re: Offscreen Texture Alpha
If possible, exported in a known format (png). If not possible, any raw format is valid, I will do the conversion. Thanks
Re: Offscreen Texture Alpha
OK, I have an update around this. This was a case of user error. I had some rogue shaders that were setting alpha to 1 for certain things.. The shader shared above is useful if you want it to make/remove all alpha, i.e. add ColorMask RGB, and have it remove alpha. Otherwise, a standard PBR shader seems to work well with Unity if the texture format is ARGB32.
Re: Offscreen Texture Alpha (User Error)
Great! Do you have a screenshot of the final result?
Re: Offscreen Texture Alpha (User Error)
Sure! Here's an example. The blended alpha of the planet atmosphere inline with the Noesis View/XAML was my goal. Very happy with the result!
Re: Offscreen Texture Alpha (User Error)
Awesome! Glad to know you solved it.
Re: Offscreen Texture Alpha (User Error)
Hi jstantos!
Hoping you are well. I just wanted to run this by you. The difference in color shown, where the render target texture (bottom left) is darker than what is shown in a Noesis rectangle (center - brighter) .... is that likely a premultiply alpha issue? I thought I had worked through this since you can clearly see that alpha is cut-out.
If I turn off post-processing it remains bright -- so I think I can rule it out.
Hoping you are well. I just wanted to run this by you. The difference in color shown, where the render target texture (bottom left) is darker than what is shown in a Noesis rectangle (center - brighter) .... is that likely a premultiply alpha issue? I thought I had worked through this since you can clearly see that alpha is cut-out.
If I turn off post-processing it remains bright -- so I think I can rule it out.
Re: Offscreen Texture Alpha (User Error)
That's seem to be a sRGB thing, I see the texture format is R8G8B8A8_SRGB. Are you using linear rendering in your project?
Who is online
Users browsing this forum: Bing [Bot] and 5 guests