Shader Help : Add emission to my shader.
Hi all. I'm totally newbie to shaders and I need some help. I created shader below(with help of internet) and i need somehow add real time emission based on emission map.I need parts on emission map look bright and illuminate surrounding area. Do someone help me ?
Shader "Simple Memory Saving Shader"
{
Properties
{
_Color("Color",COLOR)=(0.5,0.5,0.5,1.0)
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader
{
Tags { "Queue"="Transparent" "RenderType"="Transparent"}
LOD 150
CGPROGRAM
#pragma surface surf Lambert alpha
sampler2D _MainTex;
fixed4 _Color;
struct Input
{
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o)
{
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Alpha = tex2D (_MainTex, IN.uv_MainTex).a* c.a;
}
ENDCG
}
Fallback "Diffuse"
}
-Garrom
Answer by Pangamini · Feb 01, 2018 at 04:11 PM
Shader itself cannot act as a source of light. The only exception is when you are using some kind of lightmaps (baking), in which case you have to write a standard emissive shader (just write some color to o.Emission in your surf shader)
@Panga$$anonymous$$i Alright, now i have
_Emission$$anonymous$$ap ("Emission $$anonymous$$ap", 2D) = "black" {}
_EmissionColor ("Emission Color", Color) = (0,0,0)
But i don't know how to pass it to o.Emission. Can you give me line of code please ?I really didn't write any shaders before. I'm now forced to write own shader because my levels are GIANT and standard shader need lot of memory.
try o.Emission = tex2D(Emission$$anonymous$$ap, IN.uv$$anonymous$$ainTex).rgb * _EmissionColor.rgb;
Also you have to declare your variables in the CG code, not just in properties; note how it's done in your code above struct Input; Just do the same with the emission properties
Answer by shadowx311 · Sep 17, 2018 at 05:46 PM
I'm trying to add a second emission, but it's not working: https://pastebin.com/dLvDG5tA