stonstad
Topic Author
Posts: 96
Joined: 06 Jun 2016, 18:14

Re: Offscreen Texture Alpha

06 Apr 2019, 16:06

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.

Tags:
 
User avatar
jsantos
Site Admin
Posts: 2506
Joined: 20 Jan 2012, 17:18
Contact:

Re: Offscreen Texture Alpha

08 Apr 2019, 17:49

Could you please capture and attach the generated image with that shader? I want to analyze the RGBA values.
 
stonstad
Topic Author
Posts: 96
Joined: 06 Jun 2016, 18:14

Re: Offscreen Texture Alpha

09 Apr 2019, 22:02

Yes. What texture format should the bytes be written as? (argb32)?
 
User avatar
jsantos
Site Admin
Posts: 2506
Joined: 20 Jan 2012, 17:18
Contact:

Re: Offscreen Texture Alpha

10 Apr 2019, 20:22

If possible, exported in a known format (png). If not possible, any raw format is valid, I will do the conversion. Thanks
 
stonstad
Topic Author
Posts: 96
Joined: 06 Jun 2016, 18:14

Re: Offscreen Texture Alpha

21 May 2019, 22:20

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.
 
User avatar
jsantos
Site Admin
Posts: 2506
Joined: 20 Jan 2012, 17:18
Contact:

Re: Offscreen Texture Alpha (User Error)

25 May 2019, 10:13

Great! Do you have a screenshot of the final result?
 
stonstad
Topic Author
Posts: 96
Joined: 06 Jun 2016, 18:14

Re: Offscreen Texture Alpha (User Error)

03 Jun 2019, 06:50

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
 
User avatar
jsantos
Site Admin
Posts: 2506
Joined: 20 Jan 2012, 17:18
Contact:

Re: Offscreen Texture Alpha (User Error)

03 Jun 2019, 12:15

Awesome! Glad to know you solved it.

Who is online

Users browsing this forum: No registered users and 1 guest