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 /
avatar image
0
Question by $$anonymous$$ · Jul 06, 2016 at 12:05 PM · shaderrendering

A little Shader rendering problem

Recently I've downloaded some shield effect shader which works fine but there's one annoing thing about it and that's that anything that is like GL line or something like that is just not being rendered like ion the image - 1st img is how it should be just some GL lines

alt text

2nd is the shield highlighted in the editor crossing the lines (there is that rendering problem) and 3rd is the same but the shield is not highlighted

alt text

I have absolutely not idea what to change so I would be happy for any response


Here is that shader:

 Shader "Custom/ShieldFX" {
     Properties {
         _FieldColor ("Field Color", Color) = (1.0, 1.0, 1.0, 1.0)
 
         _Sampler_A ("Sampler_A" ,2D) = "" {}
         _Sampler_B ("Sampler_B" ,2D) = "" {}
 
         _Pos_a ("Position", Vector) = (0.0, 0.0, 0.0, 0.0)    
         _MaskPower ("Mask Power", Range(0.01, 5.0)) = 1.0
         _Offset("Mesh offset", Range(0, 0.1)) = 0.02
     }
     Category {
 
         Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
         Cull Back Lighting Off
         Blend SrcAlpha One
         ZWrite On
 
         SubShader {    
             Pass {
 
                 CGPROGRAM
                 #pragma vertex vert
                 #pragma fragment frag
                 #pragma fragmentoption ARB_precision_hint_fastest
 
                 #pragma target 3.0
 
                 #include "UnityCG.cginc"                
 
                 float4 _FieldColor;
 
                 sampler2D _Sampler_A;
                 sampler2D _Sampler_B;
 
                 float4 _Sampler_A_ST;
                 float4 _Sampler_B_ST;
 
                 fixed4 _Pos_a;            
 
                 float _MaskPower;
                 float _Offset;
 
                 struct a2v {                    
                     float4 vertex : POSITION;                    
                     float4 texcoord : TEXCOORD0;
                     float4 normal : NORMAL;
                 };
 
                 struct v2f {
                     float4 vertex : SV_POSITION;                    
                     float2 uv : TEXCOORD0;
                     float4 vPos : TEXCOORD1;
                 };
 
                  float2 uvPanner(float2 uv, float x, float y)
                 {
                     float t = _Time * 10.0;
                     return float2(uv.x + x * t, uv.y + y * t);
                 }
                 
                 inline float4 brightness(float4 v, float b)
                 {
                     return v + b;
                 }
 
                 inline float4 contrast(float4 v, float c)
                 {
                     return  c * (v - 0.5 ) + 0.5;
                 }
 
                 /// VERTEX
 
                 v2f vert (a2v v)
                 {
                     v2f o;
                     v.vertex.xyz += v.normal * _Offset;
                     o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
                     o.vPos = v.vertex;
                     o.uv = TRANSFORM_TEX ( v.texcoord, _Sampler_A );
                     return o;
                 }
 
                 /// FRAGMENT
 
                 fixed4 frag (v2f i) : COLOR
                 {
                     float uvTime = _Time * 10.0;
                     float2 locUV1 = float2(i.uv.x - uvTime * 0.1, i.uv.y - uvTime * 0.25);
                     float2 locUV2 = float2(i.uv.x + uvTime * 0.25, i.uv.y - uvTime * 0.1);                    
                     float locTex1 = saturate(tex2D(_Sampler_A, locUV1).g * 1.5);
                     float locTex2 = saturate(tex2D(_Sampler_A, locUV2).g * 2.0);
                     float locTex3 = tex2D(_Sampler_A, i.uv).a; 
                     float locCombine = saturate(contrast(brightness((locTex1 + locTex2).xxxx, 0.25), 2)) * locTex3;
                     float locTex4 = tex2D(_Sampler_A, i.uv).b;
                     locCombine = clamp(locCombine + locTex4, 0.0, 1.0);    
                     float2 locUV3 = float2(i.uv.x, i.uv.y - uvTime * 0.25);
                     float3 locTex5 = tex2D(_Sampler_B, locUV3) ;
                     float3 locCombine2 = saturate((locTex5 * 2 - 1 + 0.03)) * locCombine;
                     fixed4 field = float4(locCombine2.rg , 0,  1) * 0.5;
                     float locTex6 = tex2D(_Sampler_A, uvPanner(i.uv, 0.03, -0.12).xy + field.xy);
                     float locTex7 = tex2D(_Sampler_A, uvPanner(i.uv, -0.03, -0.185).xy + field.xy);
                     float dist_a = distance(_Pos_a.xyz, i.vPos.xyz);
                     fixed4 mask_a = saturate(lerp(fixed4(1.0, 1.0 ,1.0, 1.0), fixed4(0.0, 0.0 ,0.0, 1.0), dist_a * _Pos_a.w ) * _Pos_a.w);
                     fixed4 subMask_a = saturate(lerp(fixed4(0.0, 0.0 ,0.0, 1.0), fixed4(0.5, 0.5 ,0.5, 1.0), _Pos_a.w * 0.5));
                     fixed4 a = saturate(pow((subMask_a + mask_a) * 2 * mask_a , 3) + (subMask_a + mask_a) * 0.3);    
                     fixed4 ff = pow(locTex2 * locTex1 * 2, _MaskPower) * (locTex6.xxxx + locTex7.xxxx);                    
                     return clamp(_FieldColor *  (ff + locTex7 + locTex6) * a * 3, 0, 50);                
                 }
                 ENDCG 
             }
         }
     }    
 }
 


img2.png (127.0 kB)
img1.png (113.3 kB)
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
1
Best Answer

Answer by tanoshimi · Jul 06, 2016 at 12:48 PM

You want it not to block things behind it? Then change:

 ZWrite On

to:

 ZWrite Off
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 $$anonymous$$ · Jul 06, 2016 at 01:00 PM 0
Share

Easy business thank you mate :)

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

60 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

Related Questions

custom shader error. copy of "Nature/Tree Soft Occlusion Leaves" 0 Answers

Sprite not visible from behind 0 Answers

shader pass controll 0 Answers

Screen freezes after running the game [ Shaders problem ] 0 Answers

QuickOutline: how can I change the shader to work with objects with two materials? 3 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