Skip to content

Instantly share code, notes, and snippets.

@keijiro
Created January 6, 2014 07:34
Show Gist options
  • Save keijiro/8279455 to your computer and use it in GitHub Desktop.
Save keijiro/8279455 to your computer and use it in GitHub Desktop.
Shader "Custom/Skybox RGBM HDR Linear" {
Properties {
_Cubemap ("Cubemap", Cube) = "white" {}
_Exposure ("Exposure", Float) = 20.0
}
SubShader {
Tags { "Queue"="Background" "RenderType"="Background" }
Cull Off
ZWrite Off
Fog { Mode Off }
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
samplerCUBE _Cubemap;
half _Exposure;
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
float3 texcoord : TEXCOORD0;
};
struct v2f {
float4 vertex : POSITION;
float3 texcoord : TEXCOORD0;
};
v2f vert (appdata_t v)
{
v2f o;
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
o.texcoord = v.texcoord;
return o;
}
half4 frag (v2f i) : COLOR
{
float4 c = texCUBE(_Cubemap, i.texcoord);
half e = c.a;
half e2 = e * e;
half lin_e = dot(half2(0.7532, 0.2468), half2(e2, e2 * e));
c.rgb = c.rgb * lin_e * _Exposure;
c.a = 1.0;
return c;
}
ENDCG
}
}
FallBack Off
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment