Question by
Daedalus216 · Jun 06, 2017 at 03:42 PM ·
shaderterrainmeshlightingdirectional light
Mesh is lit through the terrain?
I'm preparing to add a day/night cycle to my game and am just adjusting my shaders so the world looks natural at any time of day, and I noticed that objects using my custom shader remain illuminated at night, as if the directional sunlight it shining through the terrain. This doesnt happen with any of my other shaders, however. Could anyone 'shed some light' on what the solution might be? Here's the culprit shader and a screen of whats happening:
Shader "Nature Sprite (2 Sided)" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_Shininess ("Shininess", Range (0.01, 1)) = 0.078125
_MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {}
_BumpMap ("Normalmap", 2D) = "bump" {}
_GlossMap ("Gloss (A)", 2D) = "black" {}
_TranslucencyMap ("Translucency (A)", 2D) = "white" {}
_ShadowOffset ("Shadow Offset (A)", 2D) = "black" {}
// These are here only to provide default values
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.3
[HideInInspector] _TreeInstanceColor ("TreeInstanceColor", Vector) = (1,1,1,1)
[HideInInspector] _TreeInstanceScale ("TreeInstanceScale", Vector) = (1,1,1,1)
[HideInInspector] _SquashAmount ("Squash", Float) = 1
}
SubShader {
Tags { "IgnoreProjector"="True" "RenderType"="TreeLeaf" }
LOD 200
Cull Off
CGPROGRAM
#pragma surface surf TreeLeaf alphatest:_Cutoff vertex:TreeVertLeaf addshadow nolightmap noforwardadd
#include "UnityBuiltin3xTreeLibrary.cginc"
sampler2D _MainTex;
sampler2D _BumpMap;
sampler2D _GlossMap;
sampler2D _TranslucencyMap;
half _Shininess;
struct Input {
float2 uv_MainTex;
fixed4 color : COLOR; // color.a = AO
};
void surf (Input IN, inout LeafSurfaceOutput o) {
fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb * IN.color.rgb * IN.color.a;
o.Translucency = tex2D(_TranslucencyMap, IN.uv_MainTex).rgb;
o.Gloss = tex2D(_GlossMap, IN.uv_MainTex).a;
o.Alpha = c.a;
o.Specular = _Shininess;
o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_MainTex));
}
ENDCG
}
Dependency "OptimizedShader" = "Hidden/Nature/Tree Creator Leaves Optimized"
FallBack "Diffuse"
}
night.png
(49.7 kB)
Comment