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 OtioseEntertainment · Mar 10, 2017 at 04:17 PM · shadertransparencyrenderqueue

Transparent water shader and problems with render queue

Hi there,

I wrote my own water shader and everything works fine in the scene view, but in the game view some objects with that shader are getting squashed together and render at a wrong position: alt text

When moving the camera some objects start working again and others break. I tried to play around with the render queue and everything works when using the geometry queue instead of the transparent one. But using the geometry queue, the water somehow doesn't render above the background (small stripes shining through): alt text So how can I fix that weird displacement bug? Thanks in advance!

 Shader "Custom/WaterDisplace" {
 Properties {
       _Color("Color", Color) = (1.0, 1.0, 1.0, 1.0)
         _Cube("Cubemap", CUBE) = "" {}
       _MainTex ("Texture", 2D) = "white" {}
       _Amount ("Amplitude", Range(0.001,1)) = 0.2
       _Detail("Detail", Range(0.001,2)) = 0.5
       _SpeedX("Speed", Range(0.001,3)) = 0.5
       _SpeedY("Speed", Range(0.001,3)) = 0.5
     }
     SubShader {
       Tags { "RenderType" = "Transparent" "Queue" = "Transparent" }
       Blend SrcAlpha OneMinusSrcAlpha
       Cull Off
       LOD 100
 
       CGPROGRAM
       #pragma surface surf Lambert vertex:vert addshadow alpha 
       struct Input {
           float2 uv_MainTex;
           float3 worldRefl;
       };
 
       fixed4 _Color;
       sampler2D _MainTex;
       samplerCUBE _Cube;
       float _Amount;
       float _Detail;
       float _SpeedX;
       float _SpeedY;
 
       void vert (inout appdata_full v) {
 
           v.vertex.z = _Amount * (-0.5 + tex2Dlod(_MainTex, float4(float2(v.vertex.x * _Detail + _Time.x *_SpeedX, v.vertex.y * _Detail + _Time.x * _SpeedY), 0, 0)));
       }
       
       void surf (Input IN, inout SurfaceOutput o) {
           o.Albedo = _Color.rgb;
           o.Alpha = _Color.a;
           o.Emission = texCUBE(_Cube, IN.worldRefl).rgb;
       }
 
       fixed4 LightingLambert(SurfaceOutput s, fixed3 lightDir, fixed atten)
       {
           fixed diff = abs(dot(s.Normal, lightDir));
 
           fixed4 c;
           c.rgb = s.Albedo * _LightColor0.rgb * (diff * atten * 2);
           c.a = s.Alpha;
           return c;
       }
       ENDCG
     } 
     //Fallback "Diffuse"
 }

bug2.png (118.1 kB)
bug.png (146.3 kB)
Comment
Add comment · Show 1
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 OtioseEntertainment · Mar 15, 2017 at 08:03 PM 0
Share

Any ideas on what could cause this problem? It only occurs with more than one object using this shader.

0 Replies

· Add your reply
  • Sort: 

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

120 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

Related Questions

Problem with overlapping objects and transparency 0 Answers

Leaves disappear in game mode 0 Answers

Shader Transparency problem 1 Answer

Buttons are not transparent against Grid 0 Answers

Best way to achieve color by data? 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