Skip to content

Instantly share code, notes, and snippets.

@AdrianaVecc
Created April 19, 2017 01:00
Show Gist options
  • Save AdrianaVecc/20ae99182d89848086e95cbb6ed523e2 to your computer and use it in GitHub Desktop.
Save AdrianaVecc/20ae99182d89848086e95cbb6ed523e2 to your computer and use it in GitHub Desktop.
A shader to invert a sphere's normals in Unity in order to see it from inside out. Useful to create a 360 video player
Shader "Flipping Normals" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType" = "Opaque" }
Cull Off
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"
}
@frpe1
Copy link

frpe1 commented Dec 16, 2020

Any ideas how to flip normals when using URP without getting the pink color ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment