Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

PA Particle Field - Superfast, GPU Based, Persistent Particles

Discussion in 'Assets and Asset Store' started by popupAsylum, Apr 17, 2015.

  1. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    422
    @popupAsylum Sadly changing random seed made no difference. I've got a test project if it helps, nothing in it except PAParticleField but it is LWRP, so maybe that's where the problem lies. What a shame!
    Let me know if you want me to send it to you in a PM
     
  2. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    336
    Hi,

    Would it work with HDRP? We're really tempted to upgrade our project to HDRP but we're using PA Particle Field...
     
  3. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,511
    Yeah, we want to know if this works with LWRP and HDRP...
     
  4. ffertigo

    ffertigo

    Joined:
    May 31, 2015
    Posts:
    12
    Hi,
    I'm wondering how to change the Particle Size X and Y values by script in the Global Particle Properties. Any help would be amazing, Thanks.
     

    Attached Files:

  5. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,013
    @popupAsylum I see an issue where the particle field is no longer visible. I've attached the snow demo prefab to my player's camera and everything looks good for the most part. However, if you make the player look down at the ground then the snow effect disappears. Is there any way to solve this?
     
  6. popupAsylum

    popupAsylum

    Joined:
    Apr 7, 2014
    Posts:
    119
    @magique Sounds like a culling issue. PAPF controls its Renderer's bounds, that Unity uses for frustum culling, by setting its Mesh's bounds to the field size plus 1 particle in each direction (this happens at the end of SetShaderValues).

    Can you check that you don't have negative particle sizes, and if there's anything special about your camera's projection matrix?
     
  7. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,013
    Definitely no negative particle sizes. What should I look for special about the camera's projection matrix. As far as I can tell, there is nothing unusual.
     
  8. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,013
    @popupAsylum Weird, but I just set my character up again with a different model and now the issue doesn't occur. I even changed the camera settings to what I had before and it still works. So I have no idea what was causing the issue, but it's fine now.
     
  9. NuclearC00kie

    NuclearC00kie

    Joined:
    Apr 11, 2019
    Posts:
    32
    Hi @popupAsylum do you have any update on URP support for this asset?
    Are you actively working on it?

    Thank you!
     
  10. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,013
    @popupAsylum I am also interested in URP support. I have PAPF in a project I'd like to upgrade to URP, but would have to eliminate PAPF it it won't be updated.
     
  11. zelmund

    zelmund

    Joined:
    Mar 2, 2012
    Posts:
    432
    hi there.
    have a problem
    particles in build getting strech option adn got this strech. but if i start to change side force (for wind simulation) i see only vertical strech, other strech not coming and this looks ugly. this bug only in build, in editor all fine.

    unity 5.6.6
     
    Last edited: Apr 10, 2020
  12. zelmund

    zelmund

    Joined:
    Mar 2, 2012
    Posts:
    432
    found this message
    tried to include all shaders. didnt helped

    please. its important. custumer asking to fix bug in weather.
     
    Last edited: Apr 10, 2020
  13. popupAsylum

    popupAsylum

    Joined:
    Apr 7, 2014
    Posts:
    119
    Hi @zelmund

    Just to confirm, you're enabling stretch at runtime and in the editor the particles stretch and orient in the direction they are moving, but in the build they dont change orientation or stretch at all?

    If that's the case it does sound like a shader variant issue. Can you locate the PAPF shader you're using (e.g. TransparentLit) in the Shaders folder of PAParticleField, open it in an editor and in the line:
    Code (CSharp):
    1. #pragma shader_feature _ DIRECTIONAL_ON SPIN_ON
    Change
    shader_feature
    to
    multi_compile

    That will force the variant to be included and at least give us an indication that that was the problem.

    The Lit shaders have 2 passes containing that line so if its a lit shader remember to change both.

    Hope that helps, what platform are you building for?
     
    zelmund likes this.
  14. popupAsylum

    popupAsylum

    Joined:
    Apr 7, 2014
    Posts:
    119
    @magique @NuclearC00kie I'm not working on URP support yet, it's API needs to stabilize a bit. How's your experience been working with it?
     
  15. zelmund

    zelmund

    Joined:
    Mar 2, 2012
    Posts:
    432
    yes. thats the problem.

    thats work!!!! thak you!!!
    god, it saved alot of work.

    im building for windows.
    pa is v1.342
     
  16. popupAsylum

    popupAsylum

    Joined:
    Apr 7, 2014
    Posts:
    119
    @zelmund glad its working, that means its a variant issue. Using
    multi_compile
    forces the variant you need to be included but may also add some variants to your build that you never use, increasing the build size by a couple of MB, this tends to be an issue for web and mobile projects where the prefab in the scene or using a shader variant collection is probably a cleaner way of handling it.
     
  17. pierre92nicot

    pierre92nicot

    Joined:
    Aug 21, 2018
    Posts:
    57
  18. popupAsylum

    popupAsylum

    Joined:
    Apr 7, 2014
    Posts:
    119
    Hi @pierre92nicot,

    You'll need to create a custom PAPF shader and a material that uses it, then change the field's material type to Custom and assign the material. I've written up an example customised shader with comments where changes have been made.

    Code (CSharp):
    1. Shader "PAPF_AuraTest" {
    2.     Properties {
    3.         _Color ("Color", Color) = (1, 1, 1, 1)
    4.         _MainTex ("Texture Image", 2D) = "white" {}
    5.     }
    6.     SubShader {          
    7.         Tags{
    8.             "Queue"="Transparent"
    9.             "RenderType"="Transparent"
    10.             "IgnoreProjector"="True"
    11.         }
    12.         Pass {
    13.             ZWrite Off
    14.             Blend SrcAlpha OneMinusSrcAlpha
    15.            
    16.             CGPROGRAM
    17.  
    18.             #include "UnityCG.cginc"
    19.             // Allow calls to PAPF functions (by absolute path)
    20.             #include "Assets/PopupAsylum/PAParticleField/Shaders/ParticleField.cginc"
    21.             // Allow calls to Aura 2
    22.             #include "Assets/Aura 2/System/Code/Shaders/Aura.cginc"
    23.            
    24.             #pragma exclude_renderers flash
    25.        
    26.             #pragma vertex vert
    27.             #pragma fragment frag
    28.             #pragma multi_compile_fog
    29.             #pragma target 3.0
    30.  
    31.             // Include the full PAPF feature set
    32.             #pragma shader_feature _ DIRECTIONAL_ON SPIN_ON
    33.             #pragma shader_feature _ SOFTPARTICLES_ON
    34.             #pragma shader_feature _ WORLDSPACE_ON
    35.             #pragma shader_feature _ SHAPE_SPHERE SHAPE_CYLINDER
    36.             #pragma multi_compile _ EXCLUSION_ON      
    37.             #pragma shader_feature _ TURBULENCE_SIMPLEX2D TURBULENCE_SIMPLEX
    38.  
    39.             uniform sampler2D _MainTex;          
    40.             fixed4 _Color;          
    41.             fixed _Softness;
    42.  
    43.             // -- Modified vertex output from ParticleField.cginc
    44.             struct v2f {
    45.                 float4 pos : SV_POSITION;
    46.                 fixed4 color : COLOR;
    47.                 float4 worldPos : TEXCOORD0;
    48.                 float2 tex : TEXCOORD1;
    49.                 UNITY_FOG_COORDS(2)
    50.  
    51.                 #ifdef LIGHTING_ON
    52.                     LIGHTING_COORDS(3, 4)
    53.                 #endif
    54.                 #ifdef SOFTPARTICLES_ON
    55.                     float4 projPos : TEXCOORD5;
    56.                 #endif  
    57.  
    58.                 // -- Added member for Aura 2 Coords
    59.                 float3 aura2Coords : TEXCOORD6;
    60.             };
    61.  
    62.             // -- Modified vertex function (vertParticleFieldCube) from ParticleField.cginc
    63.             v2f vert(appdata_full v)
    64.             {
    65.                 v2f o;
    66.                 UNITY_INITIALIZE_OUTPUT(v2f, o);
    67.  
    68.                 PAParticleField(v);
    69.  
    70.                 // -- Pass through the aura coords
    71.                 o.aura2Coords = Aura2_GetFrustumSpaceCoordinates(v.vertex);
    72.  
    73.                 o.color = v.color;
    74.                 o.worldPos = float4(v.vertex.xyz, 1);
    75.                 o.tex = v.texcoord;
    76.  
    77.                 #ifndef WORLDSPACE_ON
    78.                     #ifdef LIGHTING_ON
    79.                         TRANSFER_VERTEX_TO_FRAGMENT(o);
    80.                     #endif
    81.                 #endif
    82.  
    83.                 v.vertex = mul(_World2Object, o.worldPos);
    84.  
    85.                 #ifdef WORLDSPACE_ON
    86.                     #ifdef LIGHTING_ON
    87.                         TRANSFER_VERTEX_TO_FRAGMENT(o);
    88.                     #endif
    89.                 #endif
    90.  
    91.                 o.pos = PAPositionVertex(o.worldPos);
    92.  
    93.                 #ifdef SOFTPARTICLES_ON
    94.                     o.projPos = ComputeScreenPos(o.pos);
    95.                     #if UNITY_VERSION >= 550
    96.                                     COMPUTE_EYEDEPTH(o.projPos.z);
    97.                     #endif
    98.                 #endif  
    99.  
    100.                 UNITY_TRANSFER_FOG(o, o.pos);
    101.  
    102.                 return o;
    103.             }
    104.  
    105.             // -- Modified fragment function from ParticleFieldTransparent.shader
    106.             float4 frag(v2f i) : COLOR
    107.             {
    108.                 #ifdef SOFTPARTICLES_ON
    109.                 i.color.a *= GetAlphaFromDepth(i.projPos, _Softness);
    110.                 #endif
    111.            
    112.                 fixed4 col = tex2D(_MainTex, i.tex.xy) * i.color * _Color;
    113.                 #ifndef SHADER_API_MOBILE
    114.                 clip(col.a - 0.01);
    115.                 #endif
    116.  
    117.                 UNITY_APPLY_FOG(i.fogCoord, col);
    118.                
    119.                 // -- Applying Aura2 effect --
    120.                 // Assuming lightingFactor is to allow the effect to be blended in
    121.                 float lightingFactor = 1;
    122.                 // Aura2_ApplyLighting expects a float3 so extract it
    123.                 float3 colorToApply = col.rgb;
    124.                 // Apply the lighting using the geneated coords, colorToApply will be modified
    125.                 Aura2_ApplyLighting(/*inout*/ colorToApply, i.aura2Coords, lightingFactor);
    126.                 Aura2_ApplyFog(/*inout*/ colorToApply, i.aura2Coords);
    127.                 // copy the effected color back to the return value
    128.                 col.rgb = colorToApply;
    129.  
    130.                 return col;
    131.             }
    132.        
    133.             ENDCG
    134.         }
    135.        
    136.     }
    137.    
    138.     Fallback "VertexLit"
    139. }

    I fully expect it will need tweaking but it hopefully will give you a good idea where to start
     
    pierre92nicot likes this.
  19. pierre92nicot

    pierre92nicot

    Joined:
    Aug 21, 2018
    Posts:
    57
    Thanks a lot !
     
  20. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,511
  21. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,511
    Was also wondering if there is way to set the life time of the particles?
     
  22. popupAsylum

    popupAsylum

    Joined:
    Apr 7, 2014
    Posts:
    119
    @castor76 URP support is unchanged, the Unlit shaders work as expected and I'm using it in a few URP projects now.

    In terms of life time, the particles don't really have one, they last forever and are recycled when they reach the bounds of the field, what sort of effect are you trying to achieve?
     
  23. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,511
    Oh, I see. I wanted to simulate "dust particle effect" which I can do a twinkle with sprite sheet animation, but I guess I can never make them sort of hover around and then fade away without making them "move" or scroll to the edge of the bounding box.

    So basically a simple life time based on a random range and then change color based on life time.

    I guess the best work around is to have a huge amount of sprite animation frames and simulate "fade off" and then "fade in" again..
     
  24. RazT

    RazT

    Joined:
    Feb 7, 2019
    Posts:
    15
    Hi 2 all! I changed to URP and the particles are showing up, yet I get this counting and counting.:
     

    Attached Files:

  25. RazT

    RazT

    Joined:
    Feb 7, 2019
    Posts:
    15
    I am using my belowed "specks" in VR single pass. Unity 2019.4.18f1 . I am not using camera stacking (diesnt work correctly in 2019 ) and there is no post effects in scene
     
  26. popupAsylum

    popupAsylum

    Joined:
    Apr 7, 2014
    Posts:
    119
    @RazT Its not ideal but URP doesn't seem to populate Camera.current, if you're not attempting to use soft particles (where the particles fade as they come into contact with other opaque objects) you can safely comment that line out
     
  27. jh092

    jh092

    Joined:
    Sep 2, 2018
    Posts:
    48
    Hi there, I'm super interested in getting this asset, looks wonderful thank you. Quick question if I may please, is there any way for the particles to be affected by external forces? Specifically I'm thinking about wind as the use-case here.

    Many thanks

    John
     
  28. popupAsylum

    popupAsylum

    Joined:
    Apr 7, 2014
    Posts:
    119
    There's a global 'Force' property that can be used to emulate wind, its a Vector3 that will be applied uniformly to all the particles in a field each update, you might normally combine it with a bit of turbulence.
     
  29. FuzzyOnion

    FuzzyOnion

    Joined:
    Aug 22, 2014
    Posts:
    31
    @popupAsylum
    Thank you for a wonderful asset! Been a great pair with mobile VR. Finally switching to URP so a humble +1 for URP support.
     
  30. pierre92nicot

    pierre92nicot

    Joined:
    Aug 21, 2018
    Posts:
    57
    Hi, is there a way to make the PA transparent shader work with single pass instanced?