Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice
  2. Read here for Unity's latest plans on OpenXR.
    Dismiss Notice

Sphere with Cutout + Flipped Normals

Discussion in 'AR/VR (XR) Discussion' started by Delidragon, Feb 7, 2018.

  1. Delidragon

    Delidragon

    Joined:
    Feb 6, 2018
    Posts:
    2
    Hey Guys,
    for my 3D Project I need a Sphere with a flipped normals shader and a cutout shader is this possible? Flipped the Normals of a Sphere with this shader:
    Code (CSharp):
    1. // Based on Unlit shader, but culls the front faces instead of the back
    2.  
    3. Shader "Insideout" {
    4. Properties {
    5.     _MainTex ("Base (RGB)", 2D) = "white" {}
    6. }
    7.  
    8. SubShader {
    9.     Tags { "RenderType"="Opaque" }
    10.     Cull front    // ADDED BY BERNIE, TO FLIP THE SURFACES
    11.     LOD 100
    12.  
    13.     Pass {
    14.         CGPROGRAM
    15.             #pragma vertex vert
    16.             #pragma fragment frag
    17.        
    18.             #include "UnityCG.cginc"
    19.  
    20.             struct appdata_t {
    21.                 float4 vertex : POSITION;
    22.                 float2 texcoord : TEXCOORD0;
    23.             };
    24.  
    25.             struct v2f {
    26.                 float4 vertex : SV_POSITION;
    27.                 half2 texcoord : TEXCOORD0;
    28.             };
    29.  
    30.             sampler2D _MainTex;
    31.             float4 _MainTex_ST;
    32.        
    33.             v2f vert (appdata_t v)
    34.             {
    35.                 v2f o;
    36.                 o.vertex = UnityObjectToClipPos(v.vertex);
    37.                 // ADDED BY BERNIE:
    38.                 v.texcoord.x = 1 - v.texcoord.x;          
    39.                 o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
    40.                 return o;
    41.             }
    42.        
    43.             fixed4 frag (v2f i) : SV_Target
    44.             {
    45.                 fixed4 col = tex2D(_MainTex, i.texcoord);
    46.                 return col;
    47.             }
    48.         ENDCG
    49.     }
    50. }
    51.  
    52. }
     
    Last edited: Feb 7, 2018
  2. Delidragon

    Delidragon

    Joined:
    Feb 6, 2018
    Posts:
    2
    Solved! Just set the backfaceculling on after i import the sphere in Blender then i choosed the normal cutout shader.
     
    ArchieRobinson likes this.
  3. ArchieRobinson

    ArchieRobinson

    Joined:
    Jun 9, 2019
    Posts:
    1
    I am having the same problem. I don't really understand your solution. I would be interested to know more. I never use blender but it is installed on my computer.
     
unityunity