Untitled
Toggle main menu visibility
Loading...
Searching...
No Matches
depth_pre_pass_no_gbuffer.vert
Go to the documentation of this file.
1
2
#version 460
3
layout
(location = 0) in
vec3
aPosition;
4
layout
(location = 1) in
vec3
aNormal;
5
layout
(location = 2) in
vec4
aTangent;
6
layout
(location = 3) in
ivec4
aJointIndices;
7
layout
(location = 4) in
vec4
aWeights;
8
layout
(location = 5) in
vec2
aUV;
9
layout
(location = 6) in
mat4
aInstanceMatrix;
10
layout
(location = 10) in
ivec2
aPointLight;
11
layout
(location = 11) in
ivec2
aDirectionalLight;
12
layout
(location = 12) in
ivec2
aSpotLight;
13
layout
(location = 13) in
int
aSkinOffset;
14
15
16
struct
DrawArraysIndirectCommand
{
17
uint count;
18
uint instanceCount;
19
uint first;
20
uint baseInstance;
21
uint instanceOffset;
// the amount of instances pushed this frame
22
uint pad0;
23
};
24
25
26
layout
(std430, binding = 5) buffer DrawArraysData {
27
28
DrawArraysIndirectCommand
draw_arrays_commands[];
29
};
30
#define MAX_INSTANCES 1024
31
layout
(std430, binding = 4) buffer VisibleData {
32
33
uint visible_indices[];
34
35
};
36
layout
(std140, binding = 0) uniform CameraData {
37
vec4
cam_pos;
38
vec4
cam_vel;
39
mat4
projection
;
40
mat4
unjittered_projection;
41
mat4
view
;
42
mat4
inv_projection;
43
mat4
unjittered_inv_projection;
44
mat4
inv_view;
45
};
46
layout
(std140, binding = 1) uniform RenderingData {
47
ivec4
resolution;
48
};
49
layout
(std140, binding = 2) uniform LightCameraData {
50
mat4
light_proj[4];
51
mat4
light_view[4];
52
};
53
54
layout
(std140, binding = 4) uniform PrevCameraData {
55
vec4
prev_cam_pos;
56
vec4
prev_cam_vel;
57
mat4
prev_projection;
58
mat4
prev_unjittered_projection;
59
mat4
prev_view;
60
mat4
prev_inv_projection;
61
mat4
prev_unjittered_inv_projection;
62
mat4
prev_inv_view;
63
};
64
struct
MeshNode
65
{
66
vec4
min
;
67
vec4
max
;
68
vec4
center
;
69
vec4
extents
;
70
uint
instance_count
;
71
uint
static_mesh
;
72
uint
lm_offset
;
73
uint
material
;
74
uint
first
;
75
uint
count
;
76
uint
pad0
;
77
uint
pad1
;
78
};
79
80
#define MAX_MESH_NODES 1024
81
layout
(std430, binding = 15) buffer MeshNodeData {
82
83
float
focal_distance;
84
uint pad0;
85
uint pad1;
86
uint pad2;
87
MeshNode
mns[
MAX_MESH_NODES
];
88
89
};
90
struct
Transform
91
{
92
uint
mn_id
;
93
uint
command_id
;
94
uvec2
directional_lights
;
95
uvec2
spot_lights
;
96
uint
skin_offset
;
97
uint
material
;
98
mat4
mat
;
99
};
100
101
layout
(std430, binding = 7) buffer TransformData {
102
103
Transform
trs[];
104
105
};
106
layout
(std430, binding = 9) buffer PrevTransformData {
107
108
Transform
prev_trs[];
109
110
};
111
layout
(std430, binding = 11) buffer JointData {
112
113
mat4
joint_mats[];
114
115
};
116
117
out
vec3
vWorldPos
;
118
uniform uint
uOffset
;
119
uniform uint
uDynamicPass
;
120
out
vec3
ViewPos
;
121
122
out
vec3
Normal
;
123
out
vec3
ViewDirTanSpace
;
124
out
mat3
TBN
;
125
flat out uint
Mat
;
126
out
vec2
UV
;
127
out
vec4
ClipPos
;
128
out
vec4
PrevClipPos
;
129
uniform uint
uStartArr
;
130
uniform uint
uStartEle
;
131
132
void
main
()
133
{
134
135
vec3
pos = aPosition;
136
UV
= aUV;
137
138
uint off = 0;
139
uint
index_offset
=
uStartArr
+ gl_DrawID;
140
if
(
uDynamicPass
== 1)
141
{
142
143
index_offset
=
uStartEle
+ gl_DrawID;
144
index_offset
+=
uOffset
;
145
146
}
147
uint visible_offset =
index_offset
*
MAX_INSTANCES
;
148
Transform
tr = trs[visible_indices[visible_offset + gl_InstanceID]];
149
Transform
prev_tr = prev_trs[visible_indices[visible_offset + gl_InstanceID]];
150
MeshNode
mn = mns[tr.
mn_id
];
151
Mat
= tr.
material
;
152
153
mat4
skinMat =
154
joint_mats[aJointIndices.x] * aWeights.x +
155
joint_mats[aJointIndices.y] * aWeights.y +
156
joint_mats[aJointIndices.z] * aWeights.z +
157
joint_mats[aJointIndices.w] * aWeights.w;
158
159
// mat4 skinMat = mat4(1.0);
160
161
mat4
model = tr.
mat
;
162
vec4
skinned_pos = skinMat *
vec4
(pos, 1.0);
163
164
165
mat4
view_model =
view
* model;
166
mat3
normalMatrix = transpose(inverse(
mat3
(view_model) *
mat3
(skinMat)));
167
Normal
= normalize(normalMatrix * aNormal);
168
169
vec3
tangent;
170
int
tangent_sign;
171
vec3
up;
172
if
(aTangent.w == 2)
173
{
174
175
if
(abs(
Normal
.
z
) > 0.9f)
176
{
177
up =
vec3
(0,0,1);
178
}
179
else
180
{
181
up =
vec3
(1,0,0);
182
}
183
tangent = normalize(cross(up,
Normal
));
184
tangent_sign = 1;
185
}
186
else
187
{
188
189
tangent = normalize(
mat3
(model) * aTangent.xyz);
190
tangent_sign = int(aTangent.w);
191
}
192
193
vec3
T = (tangent - dot(tangent, aNormal) * aNormal);
194
vec3
B
= cross(aNormal, tangent) * tangent_sign;
195
T = normalize(
vec3
(view_model *
vec4
(T, 0.0)));
196
B
= normalize(
vec3
(view_model *
vec4
(
B
, 0.0)));
197
vec3
N = normalize(
vec3
(view_model *
vec4
(aNormal, 0.0)));
198
199
200
TBN
=
mat3
(T,
B
, N);
201
202
vec3
reg_Normal = normalize(
mat3
(inv_view) *
Normal
);
203
vec3
reg_T = normalize((tangent - dot(tangent, reg_Normal) * reg_Normal));
204
vec3
reg_B = normalize(cross(reg_Normal, tangent) * tangent_sign);
205
206
207
208
mat3
regular_TBN =
mat3
(reg_T, reg_B, reg_Normal);
209
210
vec4
wp = model *
vec4
(pos, 1.0);
211
212
ViewPos
= (
view
* model * skinned_pos).xyz;
213
ViewDirTanSpace
= transpose(regular_TBN) * (cam_pos.xyz - wp.xyz);
214
215
216
217
218
PrevClipPos
= prev_unjittered_projection * prev_view * prev_tr.
mat
* skinned_pos;
219
ClipPos
= unjittered_projection *
view
* model * skinned_pos;
220
221
222
gl_Position =
projection
*
view
* model * skinned_pos;
223
}
layout
layout(local_size_x=16, local_size_y=16) in
main
void main()
Definition
audio_probe_bake.comp:465
Normal
in vec3 Normal
Definition
depth_pre_pass.frag:67
ClipPos
in vec4 ClipPos
Definition
depth_pre_pass.frag:73
ViewDirTanSpace
in vec3 ViewDirTanSpace
Definition
depth_pre_pass.frag:75
UV
in vec2 UV
Definition
depth_pre_pass.frag:70
Mat
flat in uint Mat
Definition
depth_pre_pass.frag:69
ViewPos
in vec3 ViewPos
Definition
depth_pre_pass.frag:72
TBN
in mat3 TBN
Definition
depth_pre_pass.frag:68
PrevClipPos
in vec4 PrevClipPos
Definition
depth_pre_pass.frag:74
uDynamicPass
uniform uint uDynamicPass
Definition
depth_pre_pass.vert:114
uOffset
uniform uint uOffset
Definition
depth_pre_pass.vert:113
vWorldPos
out vec3 vWorldPos
Definition
depth_pre_pass.vert:112
uStartArr
uniform uint uStartArr
Definition
depth_pre_pass_no_gbuffer.vert:129
uStartEle
uniform uint uStartEle
Definition
depth_pre_pass_no_gbuffer.vert:130
index_offset
uniform int index_offset
Definition
dynamic.frag:234
MAX_INSTANCES
#define MAX_INSTANCES
Maximum amount of TransformGPU instances to push in one frame (used for SSBO sizing).
Definition
engine_types.h:111
MAX_MESH_NODES
#define MAX_MESH_NODES
Maximum MeshNodes in a scene (used for SSBO sizing).
Definition
engine_types.h:108
Transform::mat
mat4 mat
Definition
cull_draw_calls.comp:79
MeshNode::pad1
uint pad1
Definition
coc.frag:55
MeshNode::first
uint first
Definition
coc.frag:52
MeshNode::min
vec4 min
Definition
coc.frag:44
Transform::skin_offset
uint skin_offset
Definition
cull_draw_calls.comp:77
MeshNode::material
uint material
Definition
coc.frag:51
MeshNode::max
vec4 max
Definition
coc.frag:45
MeshNode::lm_offset
uint lm_offset
Definition
coc.frag:50
Transform::directional_lights
uvec2 directional_lights
Definition
cull_draw_calls.comp:75
Transform::mn_id
uint mn_id
Definition
cull_draw_calls.comp:73
Transform::material
uint material
Definition
cull_draw_calls.comp:78
Transform::command_id
uint command_id
Definition
cull_draw_calls.comp:74
MeshNode::pad0
uint pad0
Definition
coc.frag:54
MeshNode::center
vec4 center
Definition
coc.frag:46
MeshNode::instance_count
uint instance_count
Definition
coc.frag:48
MeshNode::static_mesh
bool static_mesh
If this mesh is static (DrawArrays) or dynamic (DrawElements), used to indicate Lightmap status.
Definition
engine_types.h:2399
MeshNode::count
size_t count
Count of vertices pushed into the MAIN_VBO.
Definition
engine_types.h:2402
MeshNode::extents
vec4 extents
Definition
coc.frag:47
Transform::spot_lights
uvec2 spot_lights
Definition
cull_draw_calls.comp:76
DrawArraysIndirectCommand
DrawArraysIndirect commands are used for static meshes (eg.
Definition
engine_types.h:842
MeshNode
MeshNodes that describe the position of Meshes, GLTF nodes for GLTFAnimations, or hold references to ...
Definition
audio_probe_bake.comp:85
Transform
Transforms for MeshNode models.
Definition
cull_draw_calls.comp:72
projection
uniform mat4 projection
Definition
shadow.vert:15
view
uniform mat4 view
Definition
shadow.vert:16
B
@ B
Definition
types.h:26
vec3::z
float z
Definition
types.h:12
ivec2
Definition
types.h:14
ivec4
Definition
types.h:16
mat3
Definition
types.h:20
mat4
Definition
types.h:21
vec2
Definition
types.h:11
vec3
Definition
types.h:12
vec4
Definition
types.h:13
src
render
depth_pre_pass_no_gbuffer.vert
Generated by
1.18.0