Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by growling_egg · Jun 07, 2014 at 08:35 PM · linerendererreflectionwater pro

Line Renderer water reflection issue

alt text

I'm using Unity Pro 4.5. I've made a terrain with water:

As you see, there is a big straight white line jutting up out of the moat, into the sky. It's a line renderer I'm going to use as the basis for a lightning bolt. I'd like for the lightning to be able to strike the ground somewhere on the map and have its reflection appear in the water. (Seems like a trivial graphical feature, but I have other lightning-above-water effects in the game as well and it'd be awesome if it was doable).

The castle and skybox both reflect accurately, but not the line renderer. Any wisdom out there?

castle.jpg (97.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 Matou · Jun 30, 2014 at 07:09 AM 0
Share

Sorry I don't have an answer, but I can confirm I have the same issue (in 4.3.4f1). Anyways, 4.5.1 is out by now, maybe you should try with it?

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Matou · Jun 30, 2014 at 08:34 AM

Okay, I made a few tests and found a workaround.

Actually I think that linerenderer geometry is dynamically computed to match the orientation of the main camera (the polygons always face the main camera). However, when we use a water shader, the camera used for reflection doesn't recompute the linerenderer orientation. Thus, in the reflection we see the "other side" of the linerenderer. Sadly, most materials in Unity are only 1-sided.

A trick is to use a two-sided material shader, such as this one:

 Shader "Custom/UnlitCutout2Sided" 
 {
     Properties
     {
         _TintColor ("Tint Color", Color) = (1,1,1,1)
         _MainTex ("Base (RGB) Trans. (Alpha)", 2D) = "white" { }
         _CutOff ("Alpha cutoff", Range(0,1)) = 0.5
     }
     
     SubShader {
         Tags { "Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
         ZWrite On
         Cull Off
         AlphaTest Greater 0.5
 
         Pass {
             Lighting Off
             CGPROGRAM
             
             #pragma vertex vert_img
             #pragma fragment frag
 
             #include "UnityCG.cginc"
 
             uniform sampler2D _MainTex;
             float4 _TintColor; 
                         
             half4 frag(v2f_img i):COLOR
             {
                 return _TintColor*tex2D(_MainTex, i.uv);
             }
             ENDCG
         }
     } 
     Fallback "Transparent/Cutout/Diffuse"
   }

You can use a lot of different shaders, the important part is "Cull Off" which renders both sides of a mesh. I don't know if Unity provides default 2-sided shaders, but, if it does, they should do the job as well.

Maybe it's not the best solution, but it kinda works for me. I hope it helps :)

Peace.

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 Xylord · May 09, 2016 at 03:39 AM 0
Share

Hey, just wanted to tell you that worked great. Thanks dude.

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

23 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

Related Questions

How to refract a linerenderer through a 2d object using Physics2D ? 0 Answers

How to make Water Pro work in a Flash compilation? 0 Answers

Change color of WaterPro (Standard Assets) when a Particle touch it,Particle Collision with Water and change Refraction Color 0 Answers

Laser Render Reflect Angle incorrect 1 Answer

Create a sine wave(using line renderer) and reflect it from colliders 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