I'm trying to apply the Skybox 6-Sided shader to a piece of geometry. The results are that the texture doesn't look like it's applied correctly. I included a copy of the shader I'm talking about, below. (Although, I'm still on Unity 5.6.3) It looks to me that there is certainly a dependency on the uv tex coords as indicated by the vertex shader output. Does anyone know, or if it's documented somewhere, what the actual skybox geometry looks like when Unity applies it as the background? I'm a little confused. Code (shader): // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt) Shader "Skybox/6 Sided" { Properties { _Tint ("Tint Color", Color) = (.5, .5, .5, .5) [Gamma] _Exposure ("Exposure", Range(0, 8)) = 1.0 _Rotation ("Rotation", Range(0, 360)) = 0 [NoScaleOffset] _FrontTex ("Front [+Z] (HDR)", 2D) = "grey" {} [NoScaleOffset] _BackTex ("Back [-Z] (HDR)", 2D) = "grey" {} [NoScaleOffset] _LeftTex ("Left [+X] (HDR)", 2D) = "grey" {} [NoScaleOffset] _RightTex ("Right [-X] (HDR)", 2D) = "grey" {} [NoScaleOffset] _UpTex ("Up [+Y] (HDR)", 2D) = "grey" {} [NoScaleOffset] _DownTex ("Down [-Y] (HDR)", 2D) = "grey" {} } SubShader { Tags { "Queue"="Background" "RenderType"="Background" "PreviewType"="Skybox" } Cull Off ZWrite Off CGINCLUDE #include "UnityCG.cginc" half4 _Tint; half _Exposure; float _Rotation; float3 RotateAroundYInDegrees (float3 vertex, float degrees) { float alpha = degrees * UNITY_PI / 180.0; float sina, cosa; sincos(alpha, sina, cosa); float2x2 m = float2x2(cosa, -sina, sina, cosa); return float3(mul(m, vertex.xz), vertex.y).xzy; } struct appdata_t { float4 vertex : POSITION; float2 texcoord : TEXCOORD0; UNITY_VERTEX_INPUT_INSTANCE_ID }; struct v2f { float4 vertex : SV_POSITION; float2 texcoord : TEXCOORD0; UNITY_VERTEX_OUTPUT_STEREO }; v2f vert (appdata_t v) { v2f o; UNITY_SETUP_INSTANCE_ID(v); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); float3 rotated = RotateAroundYInDegrees(v.vertex, _Rotation); o.vertex = UnityObjectToClipPos(rotated); o.texcoord = v.texcoord; return o; } half4 skybox_frag (v2f i, sampler2D smp, half4 smpDecode) { half4 tex = tex2D (smp, i.texcoord); half3 c = DecodeHDR (tex, smpDecode); c = c * _Tint.rgb * unity_ColorSpaceDouble.rgb; c *= _Exposure; return half4(c, 1); } ENDCG Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #pragma target 2.0 sampler2D _FrontTex; half4 _FrontTex_HDR; half4 frag (v2f i) : SV_Target { return skybox_frag(i,_FrontTex, _FrontTex_HDR); } ENDCG } Pass{ CGPROGRAM #pragma vertex vert #pragma fragment frag #pragma target 2.0 sampler2D _BackTex; half4 _BackTex_HDR; half4 frag (v2f i) : SV_Target { return skybox_frag(i,_BackTex, _BackTex_HDR); } ENDCG } Pass{ CGPROGRAM #pragma vertex vert #pragma fragment frag #pragma target 2.0 sampler2D _LeftTex; half4 _LeftTex_HDR; half4 frag (v2f i) : SV_Target { return skybox_frag(i,_LeftTex, _LeftTex_HDR); } ENDCG } Pass{ CGPROGRAM #pragma vertex vert #pragma fragment frag #pragma target 2.0 sampler2D _RightTex; half4 _RightTex_HDR; half4 frag (v2f i) : SV_Target { return skybox_frag(i,_RightTex, _RightTex_HDR); } ENDCG } Pass{ CGPROGRAM #pragma vertex vert #pragma fragment frag #pragma target 2.0 sampler2D _UpTex; half4 _UpTex_HDR; half4 frag (v2f i) : SV_Target { return skybox_frag(i,_UpTex, _UpTex_HDR); } ENDCG } Pass{ CGPROGRAM #pragma vertex vert #pragma fragment frag #pragma target 2.0 sampler2D _DownTex; half4 _DownTex_HDR; half4 frag (v2f i) : SV_Target { return skybox_frag(i,_DownTex, _DownTex_HDR); } ENDCG } } }
The Skybox 6-Sided shader is a very odd legacy thing that only works correctly when used as a skybox and cannot be used on any geometry in the scene and get anything useful. When Unity sees that shader is being used for a skybox it switches to some legacy skybox code that renders 6 specially oriented quads with each successive pass of the shader. Nothing else in Unity works that way. If you want something like that, you should be using a cube map and the Skybox/Cubemap shader. Note, do not use the legacy Cubemap asset that lets you build a cubemap from 6 textures, you need to composite your 6 textures into one of the accepted layouts and import it as a cubemap texture type. https://docs.unity3d.com/Manual/class-Cubemap.html
Anyone happen to know of a tool that takes 6 individual pngs and combines them into a single texture for cubemaps? I'm using the AllSky textures, and they're all laid out as individual pngs. Failing that, I guess I can write a tool myself. EDIT: Er, nevermind. AllSky already includes cubemaps as .EXR files EDIT2: Actually, the included .EXR files are low-res, most likely due to their intended use as reflection maps, and not skybox textures, so the question still stands.