Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nobolu-ootsuka-unrealengine/bea9a04411824600fdbc2f14f09bc231 to your computer and use it in GitHub Desktop.
Save nobolu-ootsuka-unrealengine/bea9a04411824600fdbc2f14f09bc231 to your computer and use it in GitHub Desktop.
SkyBox6sided-simple.shader
Shader "Custom/SkyBox6sided-simple" {
Properties {
_Tint ("Tint Color", Color) = (.5, .5, .5, .5)
[Gamma] _Exposure ("Exposure", Range(0, 8)) = 1.0
_Rotation ("Rotation", Range(0, 360)) = 0
//_SkyBlend ("Blend", Range(0.0, 1.0)) = 0.0
[NoScaleOffset] _FrontTex_01 ("Front_01 [+Z] (HDR)", 2D) = "grey" {}
[NoScaleOffset] _BackTex_01 ("Back_01 [-Z] (HDR)", 2D) = "grey" {}
[NoScaleOffset] _LeftTex_01 ("Left_01 [+X] (HDR)", 2D) = "grey" {}
[NoScaleOffset] _RightTex_01 ("Right_01 [-X] (HDR)", 2D) = "grey" {}
[NoScaleOffset] _UpTex_01 ("Up_01 [+Y] (HDR)", 2D) = "grey" {}
[NoScaleOffset] _DownTex_01 ("Down_01 [-Y] (HDR)", 2D) = "grey" {}
/**
[NoScaleOffset] _FrontTex_02 ("Front_02 [+Z] (HDR)", 2D) = "grey" {}
[NoScaleOffset] _BackTex_02 ("Back_02 [-Z] (HDR)", 2D) = "grey" {}
[NoScaleOffset] _LeftTex_02 ("Left_02 [+X] (HDR)", 2D) = "grey" {}
[NoScaleOffset] _RightTex_02 ("Right_02 [-X] (HDR)", 2D) = "grey" {}
[NoScaleOffset] _UpTex_02 ("Up_02 [+Y] (HDR)", 2D) = "grey" {}
[NoScaleOffset] _DownTex_02 ("Down_02 [-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;
//float _SkyBlend;
float4 RotateAroundYInDegrees (float4 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 float4(mul(m, vertex.xz), vertex.yw).xzyw;
}
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
float2 texcoord : TEXCOORD0;
};
v2f vert (appdata_t v)
{
v2f o;
o.vertex = mul(UNITY_MATRIX_MVP, RotateAroundYInDegrees(v.vertex, _Rotation));
o.texcoord = v.texcoord;
return o;
}
/*
half4 skybox_frag (v2f i, sampler2D smp1, half4 smpDecode1, sampler2D smp2, half4 smpDecode2)
{
half4 tex1 = tex2D (smp1, i.texcoord);
half4 tex2 = tex2D (smp2, i.texcoord);
half3 c1 = DecodeHDR (tex1, smpDecode1);
half3 c2 = DecodeHDR (tex2, smpDecode2);
half3 c = lerp(c1, c2, _SkyBlend);
c = c * _Tint.rgb * unity_ColorSpaceDouble;
c *= _Exposure;
return half4(c, 1);
}
*/
//half4 skybox_frag_simple(v2f i, sampler2D smp1, half4 smpDecode1, sampler2D smp2, half4 smpDecode2)
half4 skybox_frag_simple(v2f i, sampler2D smp1, half4 smpDecode1)
{
half4 tex1 = tex2D(smp1, i.texcoord);
//half4 tex2 = tex2D(smp2, i.texcoord);
half3 c1 = DecodeHDR(tex1, smpDecode1);
//half3 c2 = DecodeHDR(tex2, smpDecode2);
//half3 c = lerp(c1, c2, _SkyBlend)
half3 c = c1;
c = c * _Tint.rgb * unity_ColorSpaceDouble;
c *= _Exposure;
return half4(c, 1);
}
ENDCG
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
sampler2D _FrontTex_01;
//sampler2D _FrontTex_02;
half4 _FrontTex_01_HDR;
//half4 _FrontTex_02_HDR;
half4 frag (v2f i) : SV_Target {
return skybox_frag_simple(i,_FrontTex_01, _FrontTex_01_HDR);
}
ENDCG
}
Pass{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
sampler2D _BackTex_01;
//sampler2D _BackTex_02;
half4 _BackTex_01_HDR;
//half4 _BackTex_02_HDR;
half4 frag (v2f i) : SV_Target {
return skybox_frag_simple(i,_BackTex_01, _BackTex_01_HDR);
}
ENDCG
}
Pass{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
sampler2D _LeftTex_01;
//sampler2D _LeftTex_02;
half4 _LeftTex_01_HDR;
//half4 _LeftTex_02_HDR;
half4 frag (v2f i) : SV_Target {
return skybox_frag_simple(i,_LeftTex_01, _LeftTex_01_HDR);
}
ENDCG
}
Pass{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
sampler2D _RightTex_01;
//sampler2D _RightTex_02;
half4 _RightTex_01_HDR;
//half4 _RightTex_02_HDR;
half4 frag (v2f i) : SV_Target {
return skybox_frag_simple(i,_RightTex_01, _RightTex_01_HDR);
}
ENDCG
}
Pass{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
sampler2D _UpTex_01;
//sampler2D _UpTex_02;
half4 _UpTex_01_HDR;
//half4 _UpTex_02_HDR;
half4 frag (v2f i) : SV_Target {
return skybox_frag_simple(i,_UpTex_01, _UpTex_01_HDR);
}
ENDCG
}
Pass{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
sampler2D _DownTex_01;
//sampler2D _DownTex_02;
half4 _DownTex_01_HDR;
//half4 _DownTex_02_HDR;
half4 frag (v2f i) : SV_Target {
return skybox_frag_simple(i,_DownTex_01, _DownTex_01_HDR);
}
ENDCG
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment