Forked from keijiro/Skybox RGBM HDR Linear.shader
Last active
August 29, 2015 14:27
-
-
Save keiranlovett/5927ed442f75ba15a7c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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