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.
63 lines
1.4 KiB
63 lines
1.4 KiB
//Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
|
|
|
|
Shader "Conversion/CubemapToEquirectangularSqueeze" {
|
|
|
|
Properties{
|
|
_MainTex("Cubemap (RGB)", CUBE) = "" {}
|
|
_EquiRotation("Value", Float) = 1.0
|
|
_EquiRotationY("Value", Float) = 1.0
|
|
_DivideY("Divide Y", Float) = 2
|
|
_DivideX("Divide X", Float) = 4
|
|
}
|
|
|
|
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;
|
|
float _EquiRotation;
|
|
float _EquiRotationY;
|
|
float _DivideY;
|
|
float _DivideX;
|
|
|
|
v2f vert(appdata_img v)
|
|
{
|
|
v2f o;
|
|
o.pos = UnityObjectToClipPos(v.vertex);
|
|
o.uv = v.texcoord.xy * float2(TWOPI/_DivideX, PI/_DivideY);
|
|
return o;
|
|
}
|
|
|
|
fixed4 frag(v2f i) : COLOR
|
|
{
|
|
float theta = i.uv.y + ((_EquiRotationY * PI/2));
|
|
float phi = i.uv.x + ((_EquiRotation * TWOPI/4));
|
|
float3 unit = float3(0,0,0);
|
|
|
|
unit.x = sin(phi) * sin(theta) * -1;
|
|
unit.y = cos(theta) * -1;
|
|
unit.z = cos(phi) * sin(theta) * -1;
|
|
|
|
return texCUBE(_MainTex, unit);
|
|
}
|
|
ENDCG
|
|
}
|
|
}
|
|
Fallback Off
|
|
}
|