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

Skydome with particle

Discussion in 'General Graphics' started by DarkX, Jul 24, 2015.

  1. DarkX

    DarkX

    Joined:
    Apr 6, 2014
    Posts:
    42
    Hey guys i am working in one weather system,
    but i saw one error in the shader of the rain,
    when the particle is forward of the sky( skydome), her simply disappear
    look one example,

    http://i.imgur.com/oYPB4aP.png

    note i am using,
    particle/alpha blended - not modified
    and standard / fade - not modified - for the sky

    how i can fix this ?

    thanks in advance
     
    Last edited: Jul 24, 2015
  2. DarkX

    DarkX

    Joined:
    Apr 6, 2014
    Posts:
    42
    bump

    shaders
    Code (csharp):
    1.  
    2. Shader "Particles/Additive" {
    3. Properties {
    4.     _TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)
    5.     _MainTex ("Particle Texture", 2D) = "white" {}
    6.     _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0
    7. }
    8.  
    9. Category {
    10.     Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
    11.     Blend SrcAlpha One
    12.     AlphaTest Greater .01
    13.     ColorMask RGB
    14.     Cull Off Lighting Off ZWrite Off
    15.    
    16.     SubShader {
    17.         Pass {
    18.        
    19.             CGPROGRAM
    20.             #pragma vertex vert
    21.             #pragma fragment frag
    22.             #pragma multi_compile_particles
    23.             #pragma multi_compile_fog
    24.  
    25.             #include "UnityCG.cginc"
    26.  
    27.             sampler2D _MainTex;
    28.             fixed4 _TintColor;
    29.            
    30.             struct appdata_t {
    31.                 float4 vertex : POSITION;
    32.                 fixed4 color : COLOR;
    33.                 float2 texcoord : TEXCOORD0;
    34.             };
    35.  
    36.             struct v2f {
    37.                 float4 vertex : SV_POSITION;
    38.                 fixed4 color : COLOR;
    39.                 float2 texcoord : TEXCOORD0;
    40.                 UNITY_FOG_COORDS(1)
    41.                 #ifdef SOFTPARTICLES_ON
    42.                 float4 projPos : TEXCOORD2;
    43.                 #endif
    44.             };
    45.            
    46.             float4 _MainTex_ST;
    47.  
    48.             v2f vert (appdata_t v)
    49.             {
    50.                 v2f o;
    51.                 o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
    52.                 #ifdef SOFTPARTICLES_ON
    53.                 o.projPos = ComputeScreenPos (o.vertex);
    54.                 COMPUTE_EYEDEPTH(o.projPos.z);
    55.                 #endif
    56.                 o.color = v.color;
    57.                 o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
    58.                 UNITY_TRANSFER_FOG(o,o.vertex);
    59.                 return o;
    60.             }
    61.  
    62.             sampler2D_float _CameraDepthTexture;
    63.             float _InvFade;
    64.            
    65.             fixed4 frag (v2f i) : SV_Target
    66.             {
    67.                 #ifdef SOFTPARTICLES_ON
    68.                 float sceneZ = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
    69.                 float partZ = i.projPos.z;
    70.                 float fade = saturate (_InvFade * (sceneZ-partZ));
    71.                 i.color.a *= fade;
    72.                 #endif
    73.                
    74.                 fixed4 col = 2.0f * i.color * _TintColor * tex2D(_MainTex, i.texcoord);
    75.                 UNITY_APPLY_FOG_COLOR(i.fogCoord, col, fixed4(0,0,0,0)); // fog towards black due to our blend mode
    76.                 return col;
    77.             }
    78.             ENDCG
    79.         }
    80.     }  
    81. }
    82. }
    83.  
    84.  
    Code (csharp):
    1.  
    2.  Shader "Transparent/VertexLit with Z" {
    3.  Properties {
    4.      _Color ("Main Color", Color) = (1,1,1,1)
    5.      _SpecColor ("Spec Color", Color) = (1,1,1,0)
    6.      _Emission ("Emissive Color", Color) = (0,0,0,0)
    7.      _Shininess ("Shininess", Range (0.1, 1)) = 0.7
    8.      _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
    9.  }
    10.      SubShader {
    11.          Tags {"RenderType"="Transparent" "Queue"="Transparent"}
    12.          // Render into depth buffer only
    13.          Pass {
    14.              ColorMask 0
    15.          }
    16.          // Render normally
    17.          Pass {
    18.              ZWrite Off
    19.              Blend SrcAlpha OneMinusSrcAlpha
    20.              ColorMask RGB
    21.              Fog {Mode Off}
    22.              Material {
    23.                  Diffuse [_Color]
    24.                  Ambient [_Color]
    25.                  Shininess [_Shininess]
    26.                  Specular [_SpecColor]
    27.                  Emission [_Emission]
    28.              }
    29.              Lighting On
    30.              SetTexture [_MainTex] {
    31.                  Combine texture * primary DOUBLE, texture * primary
    32.              }
    33.          }
    34.      }
    35.  }
    36.  

    the second shader, set all values to white,

    that you will see the bug

    best regards :D
     
  3. DarkX

    DarkX

    Joined:
    Apr 6, 2014
    Posts:
    42
    solved