Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shader "Video/RealtimeEmissiveGamma-MetaOnlyEmissionStrength" {
- Properties {
- _MainTex ("Emissive (RGB)", 2D) = "white" {}
- _Emission ("Emission Scale", Float) = 1
- [Toggle(APPLY_GAMMA)] _ApplyGamma("Apply Gamma", Float) = 0
- }
- SubShader {
- Tags { "RenderType"="Opaque" }
- LOD 100
- Pass { Name "BASE" }
- CGPROGRAM
- #pragma surface surf Standard fullforwardshadows
- // Use shader model 3.0 target, to get nicer looking lighting
- #pragma target 3.0
- #pragma shader_feature _EMISSION
- #pragma multi_compile APPLY_GAMMA_OFF APPLY_GAMMA
- fixed _Emission;
- sampler2D _MainTex;
- struct Input {
- float2 uv_MainTex;
- };
- void surf (Input IN, inout SurfaceOutputStandard o) {
- // emissive comes from texture
- fixed4 e = tex2D (_MainTex, IN.uv_MainTex);
- o.Albedo = fixed4(0,0,0,0);
- o.Alpha = e.a;
- #if APPLY_GAMMA
- e.rgb = pow(e.rgb,2.2);
- #endif
- o.Emission = e; // fix emission to "real" value, scaled in meta pass
- o.Metallic = 0;
- o.Smoothness = 0;
- }
- ENDCG
- Pass
- {
- Name "META"
- Tags {"LightMode"="Meta"}
- Cull Off
- CGPROGRAM
- #include"UnityStandardMeta.cginc"
- fixed _Emission;
- float4 frag_meta2 (v2f_meta i): SV_Target
- {
- FragmentCommonData data = UNITY_SETUP_BRDF_INPUT (i.uv);
- UnityMetaInput o;
- UNITY_INITIALIZE_OUTPUT(UnityMetaInput, o);
- fixed4 c = tex2D (_MainTex, i.uv);
- o.Albedo = half3(0,0,0);
- o.Emission = half3(c.rgb * _Emission); // multiplied by strength
- return UnityMetaFragment(o);
- }
- #pragma vertex vert_meta
- #pragma fragment frag_meta2
- #pragma shader_feature _EMISSION
- #pragma shader_feature _METALLICGLOSSMAP
- #pragma shader_feature ___ _DETAIL_MULX2
- ENDCG
- }
- }
- FallBack "Diffuse"
- CustomEditor "RealtimeEmissiveGammaGUI"
- }
Advertisement
Add Comment
Please, Sign In to add comment