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"
}
@jodeyiam
Copy link

jodeyiam commented Sep 8, 2018

Thanks a bunch man. You saved my life

@andrewminton
Copy link

This renders the video with text back to front inside the sphere. Is there a way around this?

@IsDon
Copy link

IsDon commented Oct 18, 2019

This renders the video with text back to front inside the sphere. Is there a way around this?

@andrewminton There's a section in https://catlikecoding.com/unity/tutorials/advanced-rendering/triplanar-mapping/ that talks about mirrored mapping. Should let you modify this one to suit.

@rsauchuck-gp
Copy link

Is it possible to programmatically adjust the alpha of this shader to allow for a fade in effect?

@blasco
Copy link

blasco commented Nov 4, 2020

Is this working with URP? I cannot make it work

@babalwatom
Copy link

Thank you!

@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