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 Zitoox · Sep 16, 2016 at 03:53 PM · sphereeffecttransparentinsidesee through

How to see a sphere from inside it

I know this was questioned LOTS of times, but i couldn't find an answer for it. Most of the scripts that people made to correct this are outdated, the tutorials don't work anymore, and i couldn't find any shader that could do that or something...

Look at the image below: alt text

I made a transparent sphere, and i wanted to put it in the first person character's camera, so it would fit like a helmet or something. The Player can see it when it is far from it, like in the image. But when i put the sphere in the camera, to look like a helmet, the Player doesn't have the "glass" effect. I wanted the player to actually SEE AND FEEL that his head is inside a glass bubble\helmet.

The problem is that i can't get it to work! I already reduced the clipping of the camera, but it still doesn't work. It is the same problem that occurs with water, as it is just a plane, and you can't see it when you are UNDER it. Do someone have an updated answer for this? Something that would make the player see the sphere from insidet it without changing it's appearence.

I have a Double Face script but it doesn't do anything, so i will not post it in here. I would appreciate if anyone could help me. I think Unity should make this an option, you know? Make an asset with some scripts, and one like this included. Like, something with a public variable wich you could turn ON or OFF the "see from inside".

howto.png (355.3 kB)
Comment
Add comment · Show 5
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 NerdClown · Sep 16, 2016 at 04:44 PM 2
Share

You're on the right track with the double-face stuff. The reason you can't see the sphere from the inside is that it's made from polygons that are one-sided. The reason for it being done this way is that the engine can quickly decide to not render the polygons facing away from the camera and therefore render faster.

There's probably some haxy way to get two sides on the unity primitives, but I'd suggest building a model that's essentially just a sphere with the polygons facing inside.

Edit: I like your idea btw. Could be great with a VR camera too.

avatar image Jessespike · Sep 16, 2016 at 05:13 PM 1
Share

How did you create that glass effect? Is it a standard shader? A legacy shader? A random shader you found on the Internet? A material asset from the store? This would be helpful to know.

The code for disabling back culling hasn't changed at all afaik. Anyway, create a new shader or modify the one you have. Enable blending and transparency and disable back face culling. Or cull the front faces if you are only looking from the inside. Another option is to reverse the normals on the mesh.

 Tags { "RenderType"="Transparent" }
 
 Pass
 {
         Blend SrcAlpha One$$anonymous$$inusSrcAlpha
          Cull Off

http://answers.unity3d.com/search.html?f=&type=question&redirect=search%2Fsearch&sort=relevance&q=shader+two+sided

http://answers.unity3d.com/search.html?f=&type=question&redirect=search%2Fsearch&sort=relevance&q=shader+cull

https://docs.unity3d.com/$$anonymous$$anual/SL-CullAndDepth.html

https://docs.unity3d.com/$$anonymous$$anual/SL-Blend.html

https://www.google.ca/search?newwindow=1&q=unity+two+sided&oq=unity+two+sided&gs_l=serp.3..0l7j0i20k1.18227.19249.0.19396.9.5.0.4.4.0.127.367.3j1.4.0....0...1c.1.64.serp..1.8.376.JR4e2yn5OHE

https://www.google.ca/search?q=unity+back+face&ie=utf-8&oe=utf-8&gws_rd=cr&ei=SifcV4$$anonymous$$TBIG6-QHej7_gBw

avatar image Zitoox Jessespike · Sep 16, 2016 at 06:08 PM 0
Share

@Jessespike

I made the glass effect by myself. I tried a lot of combinations until i found the perfect combination. I can explain to you how to make it if you want, just start a conversation with me in the forum =)

I am going to try it, hope i can make the helmet effect.

avatar image Jessespike Zitoox · Sep 16, 2016 at 06:43 PM 1
Share

No thanks, I'm not interested in recreating the effect, I was asking so I could help you. You asked a question about a problem but didn't explain how it was being done. It's fine, there should be enough info here for you to solve.

Show more comments

4 Replies

· Add your reply
  • Sort: 
avatar image
-2
Best Answer

Answer by Zitoox · Oct 01, 2016 at 11:01 PM

I made it! I used my double-face script with another one and now it is finished! Finally! My space exploration game is finally going to happen! (No, it will not be as No Man's Lie).

With my character you can now feel that you are really in a space suit. Combined with the breathing sound and some effects, the player now really feel that he is in a true space journey!

Unfortunately none of the answers were right, but i still thank you guys for trying =) I am also going to give some points to @RavenOfCode , you helped a lot ^.^

Comment
Add comment · Show 2 · 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 Lohoris2 · Feb 08, 2017 at 11:42 AM 5
Share

Just saying that you made it is not terribly useful to whoever comes by this question.

At first you complained you couldn't find a working solution, and this is no different: still no working solution here.

avatar image nslinco · Feb 20, 2018 at 05:28 AM 2
Share

Why wouldn't you post the solution? Not only is this not an answer, it's not even the best answer in the thread.

avatar image
1

Answer by RavenOfCode · Sep 16, 2016 at 06:38 PM

Your gonna want to make a sphere with the normals inverted. The normals are the direction of the quads on your object. To see them the normal must be pointed at you, if you flip them you can flip the object and still see the sphere. If you have blender you can invert a sphere quite simply (if you don't its free so you should get it, it can do almost anything). Go into edit mode (tab) > select all faces (a) (make sure they all light up, you may have to press this a few times) > press w > then select flip normals. And boom your good.

If you don't have blender and want to do it in Unity there are a few ways of doing it. You can use a script to create a sphere with inverted normals, something like this. Or you could turn off culling (its recommended you don't as it is a huge performance hit) but it will render both sides, if you want to do this then go ahead, it should be your last resort though.

If you have any questions feel free to ask. Hope this helps!

Comment
Add comment · Show 2 · 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 Zitoox · Sep 16, 2016 at 11:35 PM 1
Share

Still, nothing, nothing changed with the script. When i approach the sphere to the player, automatically when the sphere enters in the camera's area, it simply disappear.

Do you know how do i turn off culling? I want to test it. Probaly it will not change almost anything, the game doesn't focus on having much details, so i am pretty sure that it will not change more than a few fps. Unless it turns 60fps to 10fps when you turn it off, i am pretty sure this is the best option.

avatar image RavenOfCode · Sep 17, 2016 at 03:35 PM 1
Share

Did you try making a sphere with inverted normals in blender? That is the easiest way.

If you want to look into culling you need a shader with Cull Off, or Cull Front to flip what is rendered. Cull basically means what not to render, Cull Back is default. After looking into this more Cull Front is a great way to do this, there should be no performance hit as the same amount of stuff is getting rendered.

Here is the manual on it.

avatar image
0

Answer by Casiell · Feb 21, 2018 at 10:22 AM

Seeing as this question is the first link you find in google I figured I would post a solution.

Just add this script to the object you want to see from the inside. It reverses normals of the mesh on Start so you have to press "Play" to see the effect. The side effect is that you don't see the object from the outside now, but if you need that just duplicate your object and place it in the same spot.

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

Answer by Honorsoft · Jun 20, 2018 at 08:07 PM

Instead of flipping normal back and forth, you can simply give the object (that you want to be visible from the inside) a shader with culling turned off. I have seen no 'performance hit'. You can add "Cull Off" to the sub-shader section of any shader, here is the Standard Shader with Cull Off, it should work with Unity 5, but doesn't seem to compile with Unity 2018: //Save as StandardCullOFF.shader Shader "StandardCullOFF" { Properties { _Color("Color", Color) = (1,1,1,1) _MainTex("Albedo", 2D) = "white" {}

     _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5

     _Glossiness("Smoothness", Range(0.0, 1.0)) = 0.5
     _GlossMapScale("Smoothness Scale", Range(0.0, 1.0)) = 1.0
     [Enum(Metallic Alpha,0,Albedo Alpha,1)] _SmoothnessTextureChannel ("Smoothness texture channel", Float) = 0

     [Gamma] _Metallic("Metallic", Range(0.0, 1.0)) = 0.0
     _MetallicGlossMap("Metallic", 2D) = "white" {}

     [ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0
     [ToggleOff] _GlossyReflections("Glossy Reflections", Float) = 1.0

     _BumpScale("Scale", Float) = 1.0
     _BumpMap("Normal Map", 2D) = "bump" {}

     _Parallax ("Height Scale", Range (0.005, 0.08)) = 0.02
     _ParallaxMap ("Height Map", 2D) = "black" {}

     _OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0
     _OcclusionMap("Occlusion", 2D) = "white" {}

     _EmissionColor("Color", Color) = (0,0,0)
     _EmissionMap("Emission", 2D) = "white" {}
     
     _DetailMask("Detail Mask", 2D) = "white" {}

     _DetailAlbedoMap("Detail Albedo x2", 2D) = "grey" {}
     _DetailNormalMapScale("Scale", Float) = 1.0
     _DetailNormalMap("Normal Map", 2D) = "bump" {}

     [Enum(UV0,0,UV1,1)] _UVSec ("UV Set for secondary textures", Float) = 0


     // Blending state
      _Mode ("__mode", Float) = 0.0
      _SrcBlend ("__src", Float) = 1.0
      _DstBlend ("__dst", Float) = 0.0
      _ZWrite ("__zw", Float) = 1.0
 }

 CGINCLUDE
     #define UNITY_SETUP_BRDF_INPUT MetallicSetup
 ENDCG

 SubShader
 {
     Tags { "RenderType"="Opaque" "PerformanceChecks"="False" }
     LOD 300
 

     // ------------------------------------------------------------------
     //  Base forward pass (directional light, emission, lightmaps, ...)
     Pass
     {
         
         Name "FORWARD" 
         Tags { "LightMode" = "ForwardBase" }

         Blend [_SrcBlend] [_DstBlend]
         ZWrite [_ZWrite]
         Cull Off

         CGPROGRAM
         #pragma target 3.0

         // -------------------------------------

         #pragma shader_feature _NORMALMAP
         #pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
         #pragma shader_feature _EMISSION
         #pragma shader_feature _METALLICGLOSSMAP
         #pragma shader_feature ___ _DETAIL_MULX2
         #pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
         #pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF
         #pragma shader_feature _ _GLOSSYREFLECTIONS_OFF
         #pragma shader_feature _PARALLAXMAP

         #pragma multi_compile_fwdbase
         #pragma multi_compile_fog

         #pragma vertex vertBase
         #pragma fragment fragBase
         #include "UnityStandardCoreForward.cginc"

         ENDCG
     }
     // ------------------------------------------------------------------
     //  Additive forward pass (one light per pass)
     Pass
     {
         Name "FORWARD_DELTA"
         Tags { "LightMode" = "ForwardAdd" }
         Blend [_SrcBlend] One
         Fog { Color (0,0,0,0) } // in additive pass fog should be black
         ZWrite Off
         ZTest LEqual

         CGPROGRAM
         #pragma target 3.0

         // -------------------------------------


         #pragma shader_feature _NORMALMAP
         #pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
         #pragma shader_feature _METALLICGLOSSMAP
         #pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
         #pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF
         #pragma shader_feature ___ _DETAIL_MULX2
         #pragma shader_feature _PARALLAXMAP

         #pragma multi_compile_fwdadd_fullshadows
         #pragma multi_compile_fog


         #pragma vertex vertAdd
         #pragma fragment fragAdd
         #include "UnityStandardCoreForward.cginc"

         ENDCG
     }
     // ------------------------------------------------------------------
     //  Shadow rendering pass
     Pass {
         Name "ShadowCaster"
         Tags { "LightMode" = "ShadowCaster" }

         ZWrite On ZTest LEqual

         CGPROGRAM
         #pragma target 3.0

         // -------------------------------------


         #pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
         #pragma shader_feature _METALLICGLOSSMAP
         #pragma shader_feature _PARALLAXMAP
         #pragma multi_compile_shadowcaster

         #pragma vertex vertShadowCaster
         #pragma fragment fragShadowCaster

         #include "UnityStandardShadow.cginc"

         ENDCG
     }
     // ------------------------------------------------------------------
     //  Deferred pass
     Pass
     {
         Name "DEFERRED"
         Tags { "LightMode" = "Deferred" }

         CGPROGRAM
         #pragma target 3.0
         #pragma exclude_renderers nomrt


         // -------------------------------------

         #pragma shader_feature _NORMALMAP
         #pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
         #pragma shader_feature _EMISSION
         #pragma shader_feature _METALLICGLOSSMAP
         #pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
         #pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF
         #pragma shader_feature ___ _DETAIL_MULX2
         #pragma shader_feature _PARALLAXMAP

         #pragma multi_compile ___ UNITY_HDR_ON
         #pragma multi_compile ___ LIGHTMAP_ON
         #pragma multi_compile ___ DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE
         #pragma multi_compile ___ DYNAMICLIGHTMAP_ON

         #pragma vertex vertDeferred
         #pragma fragment fragDeferred

         #include "UnityStandardCore.cginc"

         ENDCG
     }

     // ------------------------------------------------------------------
     // Extracts information for lightmapping, GI (emission, albedo, ...)
     // This pass it not used during regular rendering.
     Pass
     {
         Name "META" 
         Tags { "LightMode"="Meta" }

         Cull Off

         CGPROGRAM
         #pragma vertex vert_meta
         #pragma fragment frag_meta

         #pragma shader_feature _EMISSION
         #pragma shader_feature _METALLICGLOSSMAP
         #pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
         #pragma shader_feature ___ _DETAIL_MULX2

         #include "UnityStandardMeta.cginc"
         ENDCG
     }
 }

 SubShader
 {
     Tags { "RenderType"="Opaque" "PerformanceChecks"="False" }
     LOD 150

     // ------------------------------------------------------------------
     //  Base forward pass (directional light, emission, lightmaps, ...)
     Pass
     {
         Name "FORWARD" 
         Tags { "LightMode" = "ForwardBase" }

         Blend [_SrcBlend] [_DstBlend]
         ZWrite [_ZWrite]

         CGPROGRAM
         #pragma target 2.0
         
         #pragma shader_feature _NORMALMAP
         #pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
         #pragma shader_feature _EMISSION 
         #pragma shader_feature _METALLICGLOSSMAP 
         #pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
         #pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF
         #pragma shader_feature _ _GLOSSYREFLECTIONS_OFF
         // SM2.0: NOT SUPPORTED shader_feature ___ _DETAIL_MULX2
         // SM2.0: NOT SUPPORTED shader_feature _PARALLAXMAP

         #pragma skip_variants SHADOWS_SOFT DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE

         #pragma multi_compile_fwdbase
         #pragma multi_compile_fog

         #pragma vertex vertBase
         #pragma fragment fragBase
         #include "UnityStandardCoreForward.cginc"

         ENDCG
     }
     // ------------------------------------------------------------------
     //  Additive forward pass (one light per pass)
     Pass
     {
         Name "FORWARD_DELTA"
         Tags { "LightMode" = "ForwardAdd" }
         Blend [_SrcBlend] One
         Fog { Color (0,0,0,0) } // in additive pass fog should be black
         ZWrite Off
         ZTest LEqual
         
         CGPROGRAM
         #pragma target 2.0

         #pragma shader_feature _NORMALMAP
         #pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
         #pragma shader_feature _METALLICGLOSSMAP
         #pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
         #pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF
         #pragma shader_feature ___ _DETAIL_MULX2
         // SM2.0: NOT SUPPORTED shader_feature _PARALLAXMAP
         #pragma skip_variants SHADOWS_SOFT
         
         #pragma multi_compile_fwdadd_fullshadows
         #pragma multi_compile_fog
         
         #pragma vertex vertAdd
         #pragma fragment fragAdd
         #include "UnityStandardCoreForward.cginc"

         ENDCG
     }
     // ------------------------------------------------------------------
     //  Shadow rendering pass
     Pass {
         Name "ShadowCaster"
         Tags { "LightMode" = "ShadowCaster" }
         
         ZWrite On ZTest LEqual

         CGPROGRAM
         #pragma target 2.0

         #pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
         #pragma shader_feature _METALLICGLOSSMAP
         #pragma skip_variants SHADOWS_SOFT
         #pragma multi_compile_shadowcaster

         #pragma vertex vertShadowCaster
         #pragma fragment fragShadowCaster

         #include "UnityStandardShadow.cginc"

         ENDCG
     }

     // ------------------------------------------------------------------
     // Extracts information for lightmapping, GI (emission, albedo, ...)
     // This pass it not used during regular rendering.
     Pass
     {
         Name "META" 
         Tags { "LightMode"="Meta" }

         Cull Off

         CGPROGRAM
         #pragma vertex vert_meta
         #pragma fragment frag_meta

         #pragma shader_feature _EMISSION
         #pragma shader_feature _METALLICGLOSSMAP
         #pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
         #pragma shader_feature ___ _DETAIL_MULX2

         #include "UnityStandardMeta.cginc"
         ENDCG
     }
 }


 FallBack "VertexLit"
 CustomEditor "StandardShaderGUI"

}

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

57 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

Related Questions

Random insideUnitSphere but outside other UnitSphere? 2 Answers

Flip normals 0 Answers

Random spawn script 1 Answer

Procedural sphere defects 1 Answer

Check if two spheres are overlapping one another? 1 Answer


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