Add Emission to Custom Shader
Posted: Mon Jun 06, 2022 9:15 pm
I want to be able to use the Emission property found within Unity's standard shader within my custom shader. I have tried a few things I found online but nothing works as of yet.
This is to improve one aspect of the Transparent Windows mod, to allow exterior windows to retain their blue (or yellow) emission depending on the time of day. Right now they are just black as no emission has been added to my custom shader.
Basically I just need the properties highlighted below:
Here is the code for my custom shader (without emission):
This is to improve one aspect of the Transparent Windows mod, to allow exterior windows to retain their blue (or yellow) emission depending on the time of day. Right now they are just black as no emission has been added to my custom shader.
Basically I just need the properties highlighted below:
Here is the code for my custom shader (without emission):
Code: Select all
Shader "Custom/ClipBoxShader" {
Properties{
_MainTex("Albedo (RGB)", 2D) = "white" {}
_Glossiness("Smoothness", Range(0,1)) = 0.5
_Metallic("Metallic", Range(0,1)) = 0.0
}
SubShader{
Tags { "RenderType" = "Transparent" }
LOD 200
CGPROGRAM
#pragma surface surf Standard fullforwardshadows addshadow
#pragma target 3.0
sampler2D _MainTex;
half _Glossiness;
half _Metallic;
float4x4 _WorldToBox;
struct Input {
float2 uv_MainTex;
float3 worldPos;
};
void surf(Input IN, inout SurfaceOutputStandard o) {
float3 boxPosition = mul(_WorldToBox, float4(IN.worldPos, 1));
if (all(boxPosition > -0.5 && boxPosition < 0.5))
discard;
fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}