Page 2 of 3

Re: Offscreen Texture Alpha

Posted: 06 Apr 2019, 16:06
by stonstad
I added Blend Off, which I believe was already on as a default setting.
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: 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.

Re: Offscreen Texture Alpha

Posted: 08 Apr 2019, 17:49
by jsantos
Could you please capture and attach the generated image with that shader? I want to analyze the RGBA values.

Re: Offscreen Texture Alpha

Posted: 09 Apr 2019, 22:02
by stonstad
Yes. What texture format should the bytes be written as? (argb32)?

Re: Offscreen Texture Alpha

Posted: 10 Apr 2019, 20:22
by jsantos
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

Posted: 21 May 2019, 22:20
by stonstad
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)

Posted: 25 May 2019, 10:13
by jsantos
Great! Do you have a screenshot of the final result?

Re: Offscreen Texture Alpha (User Error)

Posted: 03 Jun 2019, 06:50
by stonstad
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!

Image

Re: Offscreen Texture Alpha (User Error)

Posted: 03 Jun 2019, 12:15
by jsantos
Awesome! Glad to know you solved it.

Re: Offscreen Texture Alpha (User Error)

Posted: 15 Oct 2019, 23:47
by stonstad
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.

Image

If I turn off post-processing it remains bright -- so I think I can rule it out.

Re: Offscreen Texture Alpha (User Error)

Posted: 16 Oct 2019, 08:54
by jsantos
That's seem to be a sRGB thing, I see the texture format is R8G8B8A8_SRGB. Are you using linear rendering in your project?