Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
5
Question by nerdjnerdbird · Oct 22, 2013 at 02:22 PM · particlesrender texture

Particles not showing up using render texture

I have an object with particles shooting out the sides of it. It renders perfectly fine in the camera that it has attached to it. Previously I was doing a camera overlay onto my main camera to get this object to render but I switched it to a render texture. The object itself looks fine but you can't see the particles once they escape the bounds of the object. It's like nothing is being rendered outside of the main object itself. Anybody know why this is happening? I tried changing the clear flags, the clipping planes, the culling mask, etc on the camera but nothing worked. I added textures to the particles and they still aren't being shown.

Thanks!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
8

Answer by nerdjnerdbird · Oct 22, 2013 at 05:25 PM

So, it looks like it comes down to the shader I'm using. Most of the shaders don't show anything because the particles don't have anything behind them. Particles-> Alpha Blending shader shows nothing... BUT Mobile->Particles->Alpha Blending works for some strange reason. You can see the particles with the correct shader!

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image FlyingHighUp · Oct 24, 2016 at 03:03 AM 1
Share

I found that the normal Particles shader has "Color$$anonymous$$ask RGB", while the mobile one doesn't. Removing that allows you to use it with a RenderTexture. The only side effect I've seen is alpha gets slightly greyer when your RenderTexture includes the skybox, but it's so small it's worth it. Otherwise it works flawlessly.

To save someone the trouble, here's the Particles/Alpha Blended shader with that line removed. You can use it under "Particles/Alpha Blended RenderTexture"

 Shader "Particles/Alpha Blended RenderTexture" {
 Properties {
     _TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)
     _$$anonymous$$ainTex ("Particle Texture", 2D) = "white" {}
     _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0
 }
 
 Category {
     Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
     Blend SrcAlpha One$$anonymous$$inusSrcAlpha
     Cull Off Lighting Off ZWrite Off
 
     SubShader {
         Pass {
         
             CGPROGRA$$anonymous$$
             #pragma vertex vert
             #pragma fragment frag
             #pragma target 2.0
             #pragma multi_compile_particles
             #pragma multi_compile_fog
             
             #include "UnityCG.cginc"
 
             sampler2D _$$anonymous$$ainTex;
             fixed4 _TintColor;
             
             struct appdata_t {
                 float4 vertex : POSITION;
                 fixed4 color : COLOR;
                 float2 texcoord : TEXCOORD0;
             };
 
             struct v2f {
                 float4 vertex : SV_POSITION;
                 fixed4 color : COLOR;
                 float2 texcoord : TEXCOORD0;
                 UNITY_FOG_COORDS(1)
                 #ifdef SOFTPARTICLES_ON
                 float4 projPos : TEXCOORD2;
                 #endif
             };
             
             float4 _$$anonymous$$ainTex_ST;
 
             v2f vert (appdata_t v)
             {
                 v2f o;
                 o.vertex = UnityObjectToClipPos(v.vertex);
                 #ifdef SOFTPARTICLES_ON
                 o.projPos = ComputeScreenPos (o.vertex);
                 CO$$anonymous$$PUTE_EYEDEPTH(o.projPos.z);
                 #endif
                 o.color = v.color;
                 o.texcoord = TRANSFOR$$anonymous$$_TEX(v.texcoord,_$$anonymous$$ainTex);
                 UNITY_TRANSFER_FOG(o,o.vertex);
                 return o;
             }
 
             sampler2D_float _CameraDepthTexture;
             float _InvFade;
             
             fixed4 frag (v2f i) : SV_Target
             {
                 #ifdef SOFTPARTICLES_ON
                 float sceneZ = LinearEyeDepth (SA$$anonymous$$PLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
                 float partZ = i.projPos.z;
                 float fade = saturate (_InvFade * (sceneZ-partZ));
                 i.color.a *= fade;
                 #endif
                 
                 fixed4 col = 2.0f * i.color * _TintColor * tex2D(_$$anonymous$$ainTex, i.texcoord);
                 UNITY_APPLY_FOG(i.fogCoord, col);
                 return col;
             }
             ENDCG 
         }
     }    
 }
 }
 
avatar image sohamxbr · Oct 26, 2021 at 05:32 AM 0
Share

@nerdjnerdbird You are damn genius... The shader u specified "Mobile->Particles->Alpha Blending" works exacyly like Magic wand.It made the Impossible to Possible. Thank you very much for the solution, you rock.

avatar image
5

Answer by Rickshao · Jul 13, 2017 at 06:34 AM

Default partilce shaders use ColorMask RGB so alpha value will not be wrote to cache. When renderring to render texture, it gets the color (r, g, b , a) where the value a is 0, as texture uses alpha premultiplied to store color infomation, the color you get become (r*a, g*a, b*a, a) ——(0, 0, 0, 0) then color you eventually get.

Just remove "ColorMask RGB" or replace it with "ColorMask RGBA", you will get the correct picture.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image svlewis · Feb 22, 2021 at 05:56 AM 0
Share

Simple fix that worked for me!

avatar image
1

Answer by kwea123 · Nov 07, 2021 at 09:39 PM

for URP, I found it can be solved using URP/Unlit with Render Face: Both ,for URP, I found it can be solved using URP/Unlit with Render Face: Both

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image azzaki · Nov 18, 2021 at 12:45 PM 0
Share

Thanks! It worked

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Render particle system to texture. 0 Answers

How to remove camera background from render texutre? 0 Answers

Sub emitter lighting problems 1 Answer

Particles effect in a progress bar 1 Answer

Get all particles within trigger collider? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges