How to make the non-illuminated side of the object illuminated? Shader and Normals
I am writing a surface shader. How to make the non-illuminated side of the object illuminated? The object should be lit evenly from all sides! Illumination of the object should not depend on the position or rotation of the object. I managed to achieve the desired result, but it only works on the Particle system. It must be the surface shader, because I need the emission parameter.
Shader "Custom/Illuminate"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
[HDR]_Color("Color", Color) = (1,1,1,1)
_Glossiness("Smoothness", Range(0,1)) = 0.5
_Metallic("Metallic", Range(0,1)) = 0.0
_Emission("Emission", Range(0,10)) = 0.0
[HDR]_EmissionColor("EmissionColor", Color) = (1,1,1,1)
}
SubShader
{
Tags { "RenderType" = "Opaque" "IgnoreProjector" = "True" }
LOD 200
CGPROGRAM
#include "UnityCG.cginc"
#pragma surface surf Standard vertex:vert
#pragma target 3.0
sampler2D _MainTex;
struct Input
{
float2 uv_MainTex;
};
half _Glossiness;
half _Metallic;
fixed4 _Color;
float _Emission;
fixed4 _EmissionColor;
void vert(inout appdata_full v, out Input o)
{
UNITY_INITIALIZE_OUTPUT(Input,o);
v.normal = normalize(WorldSpaceLightDir(v.vertex));
}
void surf(Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
c *= c.a;
o.Albedo = c.rgb;
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Emission = _EmissionColor*_Emission;
o.Alpha = c.a;
}
ENDCG
}
FallBack "VertexLit"
}
Left - Particle System, Right - Mesh
if I add a tag: Tags { "LightMode"="ForwardBase"} then everything works the other way around and a black duplicate of the object appears.
Your answer
Follow this Question
Related Questions
Telling a shader where shadows should go 0 Answers
Serious shadow bleeding problems! 0 Answers
Problem with Light/Shadow on 3D-Objects in Unity,UV-Map light/shadow problems on 3D Objects in VR 0 Answers
Lighting is reversed on one object 1 Answer
Why are the corners of my generated Mesh going dark/light like this? 1 Answer