Cubemap shader for sphere

Hello!

I have a sphere that I'm trying to apply a cubemap to. It's going to end up being a planet with a procedurally generated texture, but for now, I'm just using some earth textures.

I'm writing a shader that will render it. I'm not doing any reflection or anything, just using the cubemap for color. This is my code:

Shader "Planet/CubeMap" {
    Properties {
        _CubeTex("Cubemap", CUBE) = "" {}
    }
    SubShader {
        Tags { "RenderType"="Opaque" }
        LOD 200

        CGPROGRAM
        #pragma surface surf Lambert vertex:vert

        samplerCUBE _CubeTex;

        struct Input {
            float3 uv_CubeTex;
            float3 worldRefl;
        };

        void vert(inout appdata_full v) {
            //v.normal = normalize(v.vertex).xyz;
            v.texcoord.xyz = v.normal;
        }

        void surf(Input i, inout SurfaceOutput o) {
            o.Albedo = texCUBE(_CubeTex, i.uv_CubeTex).rgb; // <-- This does NOT compile
            //o.Albedo = texCUBE(_CubeTex, i.worldRefl).rgb; // <-- This compiles
            o.Alpha = 1;
        }
        ENDCG
    } 
    FallBack "Diffuse"
}

The line of code that samples the cube texture generates 2 compiler errors:

"Shader error in 'Planet/CubeMap': Program 'frag_surf', assignment of incompatible types at line 50" "Shader error in 'Planet/CubeMap': Program 'vert_surf', assignment of incompatible types at line 50"

If I comment out the call to texCUBE that uses i.uv_CubeTex and use i.worldRefl instead, then the code compiles just fine. It doesn't work for me though, because the texture is always oriented based on the camera, so no matter how the sphere rotates, it looks the same.

How can I use a cube map for color only? I've searched for all different kinds of things, but I can't seem to find any info on this.

Thanks!

-Tom

EDIT:

This is a custom shader that colors the sphere how I want, but of course, it doesn't take advantage of all the features of surface shaders:

Shader "Planet/CubeMap" {
    Properties {
        _CubeTex("Cubemap", CUBE) = "" {}
    }
    SubShader {
        Tags { "RenderType"="Opaque" }

        Pass {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #pragma fragmentoption ARB_precision_hint_fastest

            #include "UnityCG.cginc"

            samplerCUBE _CubeTex;

            struct appdata_t {
                float4 vertex : POSITION;
                float3 normal : NORMAL;
            };

            struct v2f {
                float4 vertex : POSITION;
                float3 texcoord : TEXCOORD0;
            };

            v2f vert(appdata_t v) {
                v2f OUT;
                OUT.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
                OUT.texcoord = v.normal;
                return OUT;
            }

            half4 frag(v2f IN) : COLOR {
                return texCUBE(_CubeTex, IN.texcoord);
            }
            ENDCG 
        }
    } 
    FallBack "Diffuse"
}

This is a really simple thing, and I hope that surface shaders aren't "too smart" for it. =)

I had this problem today, and it was driving me nuts. It seems that it doesn’t like the texcoord being declared as anything other than a float2. When I changed my shader to declare the texcoord as float2 and used other variables to pass the values that I’d being trying to put int texcoord.z and w, it compiled fine.

I don’t know if it has anything to do with texture not being defined as 3D in the properties.