Created
April 19, 2017 01:00
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |
} |
This renders the video with text back to front inside the sphere. Is there a way around this?
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.
Is it possible to programmatically adjust the alpha of this shader to allow for a fade in effect?
Is this working with URP? I cannot make it work
Thank you!
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
Thanks a bunch man. You saved my life