How to stop shadows on shader from depending on camera angle
EDIT:
So I found out that the error was coming from the fact that ToonShader gets it's toony effect by using an image in the cube map slot, which is where reflection data is supposed to go, reflection data being dependent on camera angle. This seems like a bad way to do it. Any other better ways?
My shader:
Shader "Toon/Basic"
{
Properties
{
_Color ("Main Color", Color) = (0.5, 0.5, 0.5, 1)
_MainTex ("Base (RGB)", 2D) = "white" { }
_ToonShade ("ToonShader Cubemap(RGB)", CUBE) = "" { }
}
SubShader
{
Tags { "LightMode" = "ForwardBase" }
Pass
{
Name "BASE"
Cull Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#include "UnityCG.cginc"
samplerCUBE _ToonShade;
sampler2D _MainTex;
float4 _MainTex_ST;
float4 _Color;
struct appdata
{
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
float3 normal : NORMAL;
fixed4 col : COLOR0;
};
struct v2f
{
float4 pos : SV_POSITION;
float2 texcoord : TEXCOORD0;
float3 cubenormal : TEXCOORD1;
UNITY_FOG_COORDS(2)
};
v2f vert (appdata v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
o.cubenormal = mul (UNITY_MATRIX_MV - 0.2, float4(v.normal, 0));
UNITY_TRANSFER_FOG(o, o.pos);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = _Color * tex2D(_MainTex, i.texcoord);
fixed4 cube = texCUBE(_ToonShade, i.cubenormal);
fixed4 c = fixed4(2.0f * cube.rgb * col.rgb, col.a);
UNITY_APPLY_FOG(i.fogCoord, c);
return c;
}
ENDCG
}
}
Fallback "VertexLit"
}
This is a modified version of the ToonBasic script. The issue I'm having is that when the camera angle changes so do all the shadows and highlights using this shader.
It's incredibly unrealistic and looks horrible especially when going over hills. I can't see anything in here that involves camera angles so I'm really stuck. I have no idea about shaders, I work in C# not whatever language this is so I have no idea how to solve this.
Any ideas?
Answer by Willard720 · Dec 09, 2018 at 11:04 PM
Found the answer. Because they were using a reflection for that effect, it depending on the camera angle. So I found this shader instead.
It doesn't change on the camera angle, and I can choose how many levels I want.