summaryrefslogtreecommitdiffstats
path: root/data.cginc
blob: 2f6e21ca4102f83666bdcec725cbcf69fcf680df (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#ifndef __DATA_INC
#define __DATA_INC

#include "glitter.cginc"
#include "globals.cginc"

// From filament: min roughness s.t. MIN_PERCEPTUAL_ROUGHNESS^4 > 0 in target
// precision. Although we use fp32, the higher min roughness gives us a broader
// specular highlight, which is preferable.
#define MIN_PERCEPTUAL_ROUGHNESS 0.045
#define MIN_ROUGHNESS            0.002025

struct Pbr {
  float4 albedo;
  float3 geometric_normal;
  float3 normal;
  float3x3 tbn;
  float smoothness;
  float roughness_perceptual;
  float roughness;
  float metallic;
#if (defined(_EMISSIONS) || defined(_LETTER_GRID)) && defined(FORWARD_BASE_PASS)
  float3 emission;
#endif
#if defined(_BENT_NORMALS)
  float3 bent_normal;
#endif
#if defined(_CLEARCOAT)
  float3 cc_normal;
  float cc_roughness;
  float cc_roughness_perceptual;
  float cc_strength;
#endif
#if defined(_PARALLAX_HEIGHTMAP) || defined(_BURLEY_TILING_HEIGHTMAP)
  float height;
#endif
#if defined(_DEBUG_VIEW_TANGENT_SPACE_NORMALS)
  float3 tangent_normal;
#endif
};

struct LightCommon {
  float3 V;
  float3 N;
  float NoV;
  float ao;
  float spec_ao;
#if defined(_CLEARCOAT)
  float NoV_cc;
#endif
};

struct LightDirect {
  float3 dir;

  float3 H;
  float NoH;
  float NoL;
#if defined(_CLEARCOAT)
  float NoH_cc;
  float NoL_cc;
#endif
  float LoH;
  float LoV;
  float double_LoV;

  float3 color;
};

struct LightIndirect {
  float3 dir;

  float3 H;
  float NoH;
  float NoL;
  float LoH;
  float LoV;
  float double_LoV;

  float3 specular;
#if defined(_CLEARCOAT)
  float3 specular_cc;
#endif
  float3 diffuse;
#if defined(_SHADOWS) || defined(_SSFD)
  float3 diffuse_dominant_dir;
#endif

  float3 L00;
  float3 L01r;
  float3 L01g;
  float3 L01b;
};

struct LightData {
  LightCommon common;
  LightDirect direct;
  LightIndirect indirect;
#if defined(_GLITTER)
  LightGlitter glitter;
#endif
};

struct BrdfData {
  float direct_d;
  float3 direct_f;
  float direct_g;

#if defined(_CLEARCOAT)
  float direct_d_cc;
  float direct_f_cc;
  float direct_g_cc;
#endif

  float4 ibl_dfg;
#if defined(_CLEARCOAT)
  float4 ibl_dfg_cc;
#endif
};

#endif  // __DATA_INC