a repository for recording different projection views (equirectangular, rectinlinear/gnomonic).
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.3 KiB

11 months ago
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Conversion/CubemapToEquirectangular" {
Properties{
_MainTex("Cubemap (RGB)", CUBE) = "" {}
}
Subshader{
Pass {
ZTest Always Cull Off ZWrite Off
Fog { Mode off }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
//#pragma fragmentoption ARB_precision_hint_nicest
#include "UnityCG.cginc"
#define PI 3.141592653589793
#define TWOPI 6.283185307179587
struct v2f {
float4 pos : POSITION;
float2 uv : TEXCOORD0;
};
samplerCUBE _MainTex;
v2f vert(appdata_img v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = v.texcoord.xy * float2(TWOPI, PI);
return o;
}
fixed4 frag(v2f i) : COLOR
{
float3 unit = float3(1.0, 1.0, 0.0);
float theta = i.uv.y;
float phi = i.uv.x;
unit.x = sin(phi) * sin(theta) * -1;
unit.y = cos(theta) * -1;
unit.z = cos(phi) * sin(theta) * -1;
// Exclude the top and bottom regions based on UV coordinates
if (i.uv.y > PI/3.5 && i.uv.y < PI - PI/3.5)
{
return texCUBE(_MainTex, unit);
}
else
{
return texCUBE(_MainTex, unit);
//return fixed4(0, 0, 0, 1);
}
}
ENDCG
}
}
Fallback Off
}