Skip to content

Instantly share code, notes, and snippets.

@shivaduke28
Created February 23, 2022 14:34
Show Gist options
  • Save shivaduke28/3b6f94e5446808d51572286350189662 to your computer and use it in GitHub Desktop.
Save shivaduke28/3b6f94e5446808d51572286350189662 to your computer and use it in GitHub Desktop.
AVProScreen用のシェーダー
Shader "Custom/EmissiveGamma"
{
Properties
{
// _MainTex_ST is overridden by AVProVideoScreen.
// use _ScaleOffset instead of _MainTex_ST.
[NoScaleOffset] _MainTex("Texture", 2D) = "black" {}
_ScaleOffset("Tiling Offset", Vector) = (1, 1, 0, 0)
_Emission("Emission Scale", Float) = 1
// enable gamma for AVProVideo
[Toggle(APPLY_GAMMA)] _ApplyGamma("Apply Gamma", Float) = 0
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#pragma multi_compile APPLY_GAMMA_OFF APPLY_GAMMA
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
UNITY_FOG_COORDS(1)
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
float4 _MainTex_ST;
float4 _ScaleOffset;
half _Emission;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = (TRANSFORM_TEX(v.uv, _MainTex)) * _ScaleOffset.xy + _ScaleOffset.zw;
UNITY_TRANSFER_FOG(o,o.vertex);
return o;
}
half4 frag (v2f i) : SV_Target
{
half4 col = tex2D(_MainTex, i.uv);
#if APPLY_GAMMA
col.rgb = GammaToLinearSpace(col.rgb);
#endif
col *= _Emission;
UNITY_APPLY_FOG(i.fogCoord, col);
return col;
}
ENDCG
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment