summaryrefslogtreecommitdiffstats
path: root/disinfo_lighting.cginc
blob: 94fc667358255817ade63b1cbae91c18ca4e7830 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef DISINFO_LIGHTING
#define DISINFO_LIGHTING

#include "AutoLight.cginc"
#include "UnityPBSLighting.cginc"

#include "interpolators.cginc"
#include "disinfo.cginc"

void getVertexLightColor(inout v2f i)
{
  #if defined(VERTEXLIGHT_ON)
  i.vertexLightColor = Shade4PointLights(
    unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0,
    unity_LightColor[0].rgb,
    unity_LightColor[1].rgb,
    unity_LightColor[2].rgb,
    unity_LightColor[3].rgb,
    unity_4LightAtten0, i.worldPos, i.normal
  );
  #endif
}

v2f vert(appdata v)
{
  v2f o;
  o.position = UnityObjectToClipPos(v.position);
  o.worldPos = mul(unity_ObjectToWorld, v.position);
  o.normal = UnityObjectToWorldNormal(v.normal);

  o.uv = v.uv;
  getVertexLightColor(o);

  return o;
}

fixed4 frag(v2f i) : SV_Target
{
  float2 uv = i.uv;
  int2 cell_pos;
  float2 cell_uv;
  if (!getBoxLoc(uv, 0.1, 0.9, /*res=*/int2(4,4), cell_pos, cell_uv)) {
    return float4(0, 0, 0, 1);
  }
  float2 duv = float2(ddx(i.uv.x), ddy(i.uv.y)) / 4;
  float4 font_color = renderInBox(67, cell_uv, duv);

  return font_color;
}

#endif  // DISINFO_LIGHTING