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
1
Question by TargonStudios · Mar 14, 2016 at 11:15 PM · shadersspheretransparenttransparent shaderunlit

Making a shader for an inside out sphere unlit?

I found a code on the forum that allows for a texture on the inside of a sphere, which is perfect for me. Though, I need it to be unlit, have a Color field, along with transparent (fade) to work, but have very little knowledge on working with shaders. Any good recommendations on where to learn more about shaders? Here's the code:

  Shader "Flip Normals" {
           Properties {
              _MainTex ("Base (RGB)", 2D) = "white" {}
          }
           SubShader {
             
             Tags { "RenderType" = "Opaque" }
             
             Cull Front
             
             CGPROGRAM
             
             #pragma surface surf Lambert vertex:vert
             sampler2D _MainTex;
      
              struct Input {
                  float2 uv_MainTex;
                  float4 color : COLOR;
              };
             
             
             void vert(inout appdata_full v)
             {
                 v.normal.xyz = v.normal * -1;
             }
             
             void surf (Input IN, inout SurfaceOutput o) {
                       fixed3 result = tex2D(_MainTex, IN.uv_MainTex);
                  o.Albedo = result.rgb;
                  o.Alpha = 1;
             }
             
             ENDCG
             
           }
           
           Fallback "Diffuse"
      }

All help is greatly appreciated! Thanks!

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

3 Replies

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

Answer by Bunny83 · Mar 15, 2016 at 03:28 AM

You can turn any shader in an "inside shader" by simply adding this line:

 Cull Front

and by inverting the normal vector. Since you want an unlit shader you don't need a normal vector at all.

If the shader has already this line:

 Cull Back

then it has to be changed to the first one. By default most shaders cull (remove / ignore) the back faces of a mesh since a closed mesh usually isn't viewed from the inside. You can also use Cull Off which will render both sides.

See the documentation for more details.

I quickly created a new unlit shader in Unity and made that changes. I also added alpha blending and a color property.

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 TargonStudios · Mar 15, 2016 at 03:37 AM 0
Share

Exactly what I was looking for! Thank you so much!

avatar image ankstar1234 · Apr 13, 2018 at 03:47 AM 0
Share

The link for unlit texture shader seems to be broken. Can you share that again? @Zargo @Bunny83

avatar image
1

Answer by ttesla · Nov 25, 2018 at 05:35 PM

Unlit shader with "Cull Front":

 Shader "Unlit/UnlitCullFront"
 {
     Properties
     {
         _MainTex ("Texture", 2D) = "white" {}
     }
     SubShader
     {
         Tags { "RenderType"="Opaque" }
         LOD 100
         Cull Front // Cull Off - Cull Back
 
         Pass
         {
             CGPROGRAM
             #pragma vertex vert
             #pragma fragment frag
             
             #include "UnityCG.cginc"
 
             struct appdata
             {
                 float4 vertex : POSITION;
                 float2 uv : TEXCOORD0;
             };
 
             struct v2f
             {
                 float2 uv : TEXCOORD0;
                 float4 vertex : SV_POSITION;
             };
 
             sampler2D _MainTex;
             float4 _MainTex_ST;
             
             v2f vert (appdata v)
             {
                 v2f o;
                 o.vertex = UnityObjectToClipPos(v.vertex);
                 o.uv = TRANSFORM_TEX(v.uv, _MainTex);
                 o.uv.x = 1.0 - o.uv.x; // For mirroring image to inside of the sphere
                 return o;
             }
             
             fixed4 frag (v2f i) : SV_Target
             {
                 // sample the texture
                 fixed4 col = tex2D(_MainTex, i.uv);
                 return col;
             }
             ENDCG
         }
     }
 }
 

 
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 MisQQ · May 21, 2019 at 12:31 AM

Hello, Can someone tell me how to cut 1/3 of front ? Because this shader works fine but cut sphere in half.

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

42 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

Related Questions

Unlit Transparent Shader causing strange issues 1 Answer

Lighting support in Unlit shader 0 Answers

How to add true transparancy to this Wireframe Shader? 1 Answer

Mask particles inside an object with a transparent shader 0 Answers

Shader graph place small image/texture at specific location on object,Shader graph place texture at specific place on object 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