Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by jordaneden · May 09, 2016 at 03:54 PM · shaderparticle systemfoghdralpha-blend

How to make this shader for a particle system work with HDR?

I'm using this shader for a particle system which when coupled with HDR becomes artifacted/inverted (alpha-blending issues I think). Judging by similar issues others have had, I'm hoping someone here knows how to rectify this shader script.

 Shader "LemonSpawn/LazyFog" {
     Properties {
         _Color ("Color", Color) = (1,1,1,1)
         _MainTex ("Albedo (RGB)", 2D) = "white" {}
         _Scale ("Scale", Range(0,5)) = 1
         _Intensity ("Intensity", Range(0,1)) = 0.5
         _Alpha ("Alpha", Range(0,2.5)) = 0.75
         _AlphaSub ("AlphaSub", Range(0,1)) = 0.0
         _Pow ("Pow", Range(0,4)) = 1.0
     }
 SubShader {
         Tags {"Queue"="Transparent+101" "IgnoreProjector"="True" "RenderType"="Transparent"}
         LOD 400
 
 
         Lighting On
         Cull Off
         ZWrite Off
         Blend SrcAlpha OneMinusSrcAlpha
        Pass
          {
 
          
              CGPROGRAM
             
              #pragma target 3.0
              #pragma fragmentoption ARB_precision_hint_fastest
              
              #pragma vertex vert
              #pragma fragment frag
              #pragma multi_compile_fwdbase
              
              #include "AutoLight.cginc"
              #include "UnityCG.cginc"
                          
 
              sampler2D _MainTex;
              float4 _Color;        
              float _Scale;
              float _Intensity;
              float _Alpha;
              float _AlphaSub;
              float _Pow;
             
              struct v2f
              {
                  float4 pos : POSITION;
                  float4 texcoord : TEXCOORD0;
                  float3 normal : TEXCOORD1;
                  float4 color: TEXCOORD2;
                  float2 uv : TEXCOORD3;
                  float3 worldPosition: TEXCOORD4;
  
              };
               
              v2f vert (appdata_full v)
              {
                  v2f o;
                  o.pos = mul( UNITY_MATRIX_MVP, v.vertex);
                  o.uv = v.texcoord;
                  o.normal = normalize(v.normal).xyz;
                  o.texcoord = v.texcoord;
                   o.worldPosition = mul (_Object2World, v.vertex).xyz;
                  o.color =v.color;
         //         TRANSFER_VERTEX_TO_FRAGMENT(o);
                  
                  return o;
              }
 
         fixed4 frag(v2f IN) : COLOR {
             float3 worldSpacePosition = IN.worldPosition;
             float3 N;
             float3 distScale = 0.5;        
             float3 viewDirection = normalize(_WorldSpaceCameraPos - worldSpacePosition);
             float dist = clamp(pow(length(0.1*distScale*(_WorldSpaceCameraPos - worldSpacePosition)),1.0),0,1);
             float scale = 5;
             float shadowscale = 1;
             float4 c = tex2D(_MainTex, IN.uv*_Scale);
             float xx = c.r*_Intensity;
             xx = pow(xx,_Pow);
             c.a = c.r;            
             c.rgb = float3(xx*_Color.r,xx*_Color.g,xx*_Color.b);    
             c.a *= IN.color.a-2.5*length(IN.uv-float2(0.5, 0.5));
             c.a*=_Alpha;
             c.a-=_AlphaSub;
             return c;
             
              }
              ENDCG
          }
     }
  }
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by jordaneden · May 09, 2016 at 04:03 PM

I've managed to get acceptable results by changing line 19:

 Blend SrcAlpha OneMinusSrcAlpha

To:

 Blend One One

To confirm details, I was using the SE Natural Bloom asset, which required the HDR camera for full effect, both of which seemed to conflict with the fog shader used in the LazyFog asset. It's by no means a perfect solution, but for now it shall suffice. Anyone with a better idea is welcome to have a crack.

Comment
Add comment · 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

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

70 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Sharp Cut-Out Height Fog? 0 Answers

Change color of object via input. HDRP, Unity 19.3.0b9 / Also Gradient in Shader Graph 0 Answers

How to make object not be affected by fog with URP 0 Answers

shader didn't draw texture when distance far 0 Answers

What basic shader is needed for change the color on particle system with particles based on a spritesheet? 0 Answers


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