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 /
This question was closed Aug 19, 2018 at 08:57 PM by KalleRosendahl for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by KalleRosendahl · Aug 19, 2018 at 08:51 PM · shadershaderscullingwater4

Does anyone know why my rim shader effects water shader?

Ok so i have a hexagon map with each gameobject's material is set to a rim effect shader code:

Shader "SFHologram/HologramShader" { Properties { // General _Brightness("Brightness", Range(0.1, 6.0)) = 3.0 //_HexMapFadeEffect ("_HexMapFadeEffect", Range (0.0, 1.0)) = 1.0 _Direction ("Direction", Vector) = (0,1,0,0) // Main Color _MainTex ("MainTexture", 2D) = "white" {} _MainColor ("MainColor", Color) = (1,1,1,1) // Rim/Fresnel _RimColor ("Rim Color", Color) = (1,1,1,1) _RimPower ("Rim Power", Range(0.1, 10)) = 5.0 // Scanline _ScanTiling ("Scan Tiling", Range(0.01, 10.0)) = 0.05 _ScanSpeed ("Scan Speed", Range(-2.0, 2.0)) = 1.0 // Glow _GlowTiling ("Glow Tiling", Range(0.01, 1.0)) = 0.05 _GlowSpeed ("Glow Speed", Range(-10.0, 10.0)) = 1.0 // Glitch _GlitchSpeed ("Glitch Speed", Range(0, 50)) = 1.0 _GlitchIntensity ("Glitch Intensity", Float) = 0 // Alpha Flicker _FlickerTex ("Flicker Control Texture", 2D) = "white" {} _FlickerSpeed ("Flicker Speed", Range(0.01, 100)) = 1.0

         // Settings
         [HideInInspector] _Fold("__fld", Float) = 1.0
     }
     SubShader
     {
         Tags { "Queue"="Transparent" "RenderType"="Transparent" }
         Blend SrcAlpha OneMinusSrcAlpha
         LOD 100
         ColorMask RGB
         Cull Back
 
         Pass
         {
             CGPROGRAM
             #pragma shader_feature _SCAN_ON
             #pragma shader_feature _GLOW_ON
             #pragma shader_feature _GLITCH_ON
             #pragma vertex vert
             #pragma fragment frag
             
             #include "UnityCG.cginc"
 
             struct appdata
             {
                 float4 vertex : POSITION;
                 float3 normal : NORMAL;
                 float2 uv : TEXCOORD0;
             };
 
             struct v2f
             {
                 float4 vertex : SV_POSITION;
                 float2 uv : TEXCOORD0;
                 float4 worldVertex : TEXCOORD1;
                 float3 viewDir : TEXCOORD2;
                 float3 worldNormal : NORMAL;
             };
 
             sampler2D _MainTex;
             sampler2D _FlickerTex;
             float4 _Direction;
             float4 _MainTex_ST;
             float4 _MainColor;
             float4 _RimColor;
             float _RimPower;
             float _GlitchSpeed;
             float _GlitchIntensity;
             float _Brightness;
             float _HexMapFadeEffect;
             float _ScanTiling;
             float _ScanSpeed;
             float _GlowTiling;
             float _GlowSpeed;
             float _FlickerSpeed;
             
             v2f vert (appdata v)
             {
                 v2f o;
                 
                 // Glitches
                 #if _GLITCH_ON
                     v.vertex.x += _GlitchIntensity * (step(0.5, sin(_Time.y * 2.0 + v.vertex.y * 1.0)) * step(0.99, sin(_Time.y*_GlitchSpeed * 0.5)));
                 #endif
 
                 o.vertex = UnityObjectToClipPos(v.vertex);
                 
                 o.uv = TRANSFORM_TEX(v.uv, _MainTex);
                 o.worldVertex = mul(unity_ObjectToWorld, v.vertex);
                 o.worldNormal = UnityObjectToWorldNormal(v.normal);
                 o.viewDir = normalize(UnityWorldSpaceViewDir(o.worldVertex.xyz));
 
                 return o;
             }
 
             
             fixed4 frag (v2f i) : SV_Target
             {
                 fixed4 texColor = tex2D(_MainTex, i.uv);
 
                 half dirVertex = (dot(i.worldVertex, normalize(float4(_Direction.xyz, 1.0))) + 1) / 2;
 
                 // Scanlines
                 float scan = 0.0;
                 #ifdef _SCAN_ON
                     scan = step(frac(dirVertex * _ScanTiling + _Time.w * _ScanSpeed), 0.5) * 0.65;
                 #endif
 
                 // Glow
                 float glow = 0.0;
                 #ifdef _GLOW_ON
                     glow = frac(dirVertex * _GlowTiling - _Time.x * _GlowSpeed);
                 #endif
 
                 // Flicker
                 fixed4 flicker = tex2D(_FlickerTex, _Time * _FlickerSpeed);
 
                 // Rim Light
                 half rim = 1.0-saturate(dot(i.viewDir, i.worldNormal));
                 fixed4 rimColor = _RimColor * pow (rim, _RimPower);
 
                 fixed4 col = texColor * _MainColor + (glow * 0.35 * _MainColor) + rimColor;
                 col.a = texColor.a * _HexMapFadeEffect * (scan + rim + glow) * flicker;
 
                 col.rgb *= _Brightness;
 
                 return col;
             }
             ENDCG
         }
     }
 
     CustomEditor "HologramShaderGUI"
 }

when im in game it seems like this effects my water4Advanced and simply skips to draw it, if the water is far enough away from my camera so it gives me this output.. : WaterNotDrawn

whyyyy.png (230.9 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

  • Sort: 
avatar image
0
Best Answer

Answer by KalleRosendahl · Aug 19, 2018 at 08:56 PM

Nevermind i figured out that if i set the renderqueue on water to lower than my rim effect the water will get drawn before my rim can change something and that way i will always see my water

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

Follow this Question

Answers Answers and Comments

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

Related Questions

Extruded Surface Shader + Inner Fill Color 0 Answers

Rendering Depth Correctly With Multiple Cameras 0 Answers

shader material showing over every object. 0 Answers

change water4 fade distance 0 Answers

Drawing silhouette shader 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