Is there a way of creating upside-down terrain?

Hi

I'm involved making a game which involves switching gravity as a core mechanic and want to create two terrains which can both be travelled on; one normal one and another which is flipped upside-down.

There could be a really easy way doing this that I've missed but anyway, any help would be very much appreciated!

(and it should be mentioned that I'm really awful at scripting!)

Unity terrains can't be flipped or rotated. In order to do that you have to use a standard mesh.

We’re using upside-down terrain as ceiling for caves.
What is needed is custom terrain shader with flipped normals and “Cull Front”

What is not working properly is shadows from Directional Light (sun), there are issues caused by Bias a SlopeBias, because shadow shader is applying them in opposive way. We didn’t try to fix it since we don’t need sun in caves.


We’ve taken original terrain shader, made a copy and changed few lines.
Similar changes has been done in other shaders (Add pass, Base, Base-gen, Picking, Selection)

Zip archive with all shaders & material (Unity 2019.1): [138557-terrainflip.zip|138557]

// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)

Shader "Nature/Terrain/Standard (flipped)" {
    Properties {
        // used in fallback on old cards & base map
        [HideInInspector] _MainTex ("BaseMap (RGB)", 2D) = "white" {}
        [HideInInspector] _Color ("Main Color", Color) = (1,1,1,1)
    }

    SubShader {
        Tags {
            "Queue" = "Geometry-100"
            "RenderType" = "Opaque"
        }

		Cull Front // FIRST CHANGE

        CGPROGRAM
        #pragma surface surf Standard vertex:SplatmapVert finalcolor:SplatmapFinalColor finalgbuffer:SplatmapFinalGBuffer addshadow fullforwardshadows
        #pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap forwardadd
        #pragma multi_compile_fog // needed because finalcolor oppresses fog code generation.
        #pragma target 3.0
        // needs more than 8 texcoords
        #pragma exclude_renderers gles
        #include "UnityPBSLighting.cginc"

        #pragma multi_compile __ _NORMALMAP

        #define TERRAIN_STANDARD_SHADER
        #define TERRAIN_INSTANCED_PERPIXEL_NORMAL
        #define TERRAIN_SURFACE_OUTPUT SurfaceOutputStandard
        #include "TerrainSplatmapCommon.cginc"

        half _Metallic0;
        half _Metallic1;
        half _Metallic2;
        half _Metallic3;

        half _Smoothness0;
        half _Smoothness1;
        half _Smoothness2;
        half _Smoothness3;

        void surf (Input IN, inout SurfaceOutputStandard o) {
            half4 splat_control;
            half weight;
            fixed4 mixedDiffuse;
            half4 defaultSmoothness = half4(_Smoothness0, _Smoothness1, _Smoothness2, _Smoothness3);
            SplatmapMix(IN, defaultSmoothness, splat_control, weight, mixedDiffuse, o.Normal);
            o.Albedo = mixedDiffuse.rgb;
            o.Alpha = weight;
			o.Normal *= -1; // SECOND CHANGE
            o.Smoothness = mixedDiffuse.a;
            o.Metallic = dot(splat_control, half4(_Metallic0, _Metallic1, _Metallic2, _Metallic3));
        }
        ENDCG

        UsePass "Hidden/Nature/Terrain/Utilities-flip/PICKING"
        UsePass "Hidden/Nature/Terrain/Utilities-flip/SELECTION"
    }

    // THIRD CHANGE (using flipped dependencies)
    Dependency "AddPassShader"    = "Hidden/TerrainEngine/Splatmap/Standard-flip-AddPass"
    Dependency "BaseMapShader"    = "Hidden/TerrainEngine/Splatmap/Standard-flip-Base"
    Dependency "BaseMapGenShader" = "Hidden/TerrainEngine/Splatmap/Standard-flip-BaseGen"

    Fallback "Nature/Terrain/Diffuse"
}

Export the unity terrain to any 3d modeling software save it as plain then imported back to unity