How do I invert normals of a sphere???

Hey, I want to create an atmosphere shader. I found someone used “sphere with the normals inverted” and using X - Ray Shader. (Atmospheric Shader Help - Unity Answers) And I really want to do the same :slight_smile: So my question is, How do I do that? I am Using this X - Ray Shader if you have to know: ftp://www.photonworkshop.com/photonworkshop.com/HostedFiles/Mobile-XrayEffect.shader

Here is an editor script that will produce an inverted sphere. Put it in your Assets/Editor folder of your project. Then GameObject > Create Other > Inverted Sphere…

using UnityEngine;
using UnityEditor;

public class InvertedSphere : EditorWindow {
	private string st = "1.0";
 
    [MenuItem("GameObject/Create Other/Inverted Sphere...")]
    public static void ShowWindow() {
        EditorWindow.GetWindow(typeof(InvertedSphere));
    }
 
    public void OnGUI() {
		GUILayout.Label("Enter sphere size:");
		st = GUILayout.TextField (st);
		
		float f;
		if (!float.TryParse (st, out f))
			f = 1.0f;
        if (GUILayout.Button("Create Inverted Sphere")) {
            CreateInvertedSphere(f);
        }
    }
	
    private void CreateInvertedSphere(float size) {
		GameObject go = GameObject.CreatePrimitive(PrimitiveType.Sphere);
		MeshFilter mf = go.GetComponent<MeshFilter>();
		Mesh mesh = mf.sharedMesh;
		
		GameObject goNew = new GameObject();	
		goNew.name = "Inverted Sphere";
		MeshFilter mfNew = goNew.AddComponent<MeshFilter>();
		mfNew.sharedMesh = new Mesh();

		
		//Scale the vertices;
		Vector3[] vertices = mesh.vertices;
		for (int i = 0; i < vertices.Length; i++)
			vertices <em>= vertices _* size;_</em>

* mfNew.sharedMesh.vertices = vertices;*

* // Reverse the triangles*
* int[] triangles = mesh.triangles;*
* for (int i = 0; i < triangles.Length; i += 3) {*
_ int t = triangles*;
triangles = triangles[i+2];
triangles[i+2] = t;
}
mfNew.sharedMesh.triangles = triangles;*_

* // Reverse the normals;*
* Vector3[] normals = mesh.normals;*
* for (int i = 0; i < normals.Length; i++)*
normals = -normals*;*
* mfNew.sharedMesh.normals = normals;*

* mfNew.sharedMesh.uv = mesh.uv;*
* mfNew.sharedMesh.uv2 = mesh.uv2;*
* mfNew.sharedMesh.RecalculateBounds();*

* // Add the same material that the original sphere used*
* MeshRenderer mr = goNew.AddComponent();*
* mr.sharedMaterial = go.renderer.sharedMaterial;*

* DestroyImmediate(go);*
* }*
}

Here is a shader for back face rendering.

Shader "Backfaced Bumped Diffuse" {
Properties {
	_Color ("Main Color", Color) = (1,1,1,1)
	_MainTex ("Base (RGB)", 2D) = "white" {}
	_BumpMap ("Normalmap", 2D) = "bump" {}
}

SubShader {
	Tags { "RenderType"="Opaque" }
	LOD 300
	Cull Off

CGPROGRAM
#pragma surface surf Lambert

sampler2D _MainTex;
sampler2D _BumpMap;
fixed4 _Color;

struct Input {
	float2 uv_MainTex;
	float2 uv_BumpMap;
};

void surf (Input IN, inout SurfaceOutput o) {
	fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
	o.Albedo = c.rgb;
	o.Alpha = c.a;
	o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
}
ENDCG  
}

FallBack "Diffuse"
}

To Use: In Unity Editor Right Click > Create > Shader, Name it Backface Bumped Diffuse, Open the shader with monodevelop and paste the code above, Now change your materials that are having issues to “Backface Bumped Diffuse”.