Material/Texture on the Inside of a Sphere

I was wondering if you can put a material of texture on the inside of a sphere.

I am asking this because I am making a game and a spaceship is floating in space, and eventually you are forced off the ship and to fall on to a planet you are in orbit of.

Thank you for any help you can provide.

Just assuming the texture is for the planet, how come you need to render the inside of the sphere? Or is it a nifty-awesome-sphere spaceship?

5 Answers

5

Or, you could just build a simple texture-shader and use Cull Front or Cull Off instead of Cull Back to display either both sides or just the backside. If you need lighting you´ll need to reverse the normals aswell, below is an example of a simple diffuse shader doing this to create a “inside-out”-colored box:

Shader "Show Insides" {
    SubShader {
      
      Tags { "RenderType" = "Opaque" }
      
      Cull Front
      
      CGPROGRAM
      
      #pragma surface surf Lambert vertex:vert
      
      void vert(inout appdata_full v)
      {
      	v.normal.xyz = v.normal * -1;
      }
      
      struct Input {
          float4 color : COLOR;
      };
      
      void surf (Input IN, inout SurfaceOutput o) {
          o.Albedo = 1;
      }
      
      ENDCG
      
    }
    
    Fallback "Diffuse"
    
  }

The shader above is working for me, but I can't seem to get it to display a texture on the inside. Is there some modification to the code needed?

Change line 6 to 'Cull Off'

This shader allows one to set a texture on the inside of a sphere:

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"
    }

You can only put materials on one side of any given object, unless you are using shaders which specifically render backfaces. Because of backface culling being one of the simplest and fastest graphics optimisations, it is always assumed that you will be viewing meshes from one side only!

For what you want to do here, I would have two spheres- one with the normals pointing out, and one with the normals pointing in. You’ll have to use some external application to make the ‘inside-out’ one, because Unity does not normally provide that kind.

Thanks for you help. What application would you recommend?

Have a look at [Blender][1]. [1]: http://www.blender.org/

Thank for the help

how can i apply “unlit texture” property in this shader…?? “unlit-texture” property is very helpful for making 360 photo gallery etc.

That shader really does work thank you.