Untitled
Toggle main menu visibility
Loading...
Searching...
No Matches
shadow.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
uniform
mat4
projection
;
16
uniform
mat4
view
;
17
18
struct
DrawArraysIndirectCommand
{
19
uint count;
20
uint instanceCount;
21
uint first;
22
uint baseInstance;
23
uint instanceOffset;
// the amount of instances pushed this frame
24
uint pad0;
25
};
26
27
28
layout
(std430, binding = 5) buffer DrawArraysData {
29
30
DrawArraysIndirectCommand
draw_arrays_commands[];
31
};
32
struct
Transform
33
{
34
uint
mn_id
;
35
uint
command_id
;
36
uvec2
directional_lights
;
37
uvec2
spot_lights
;
38
uint
skin_offset
;
39
uint
material
;
40
mat4
mat
;
41
};
42
43
layout
(std430, binding = 7) buffer TransformData {
44
45
Transform
trs[];
46
47
};
48
49
struct
MeshNode
50
{
51
vec4
min
;
52
vec4
max
;
53
vec4
center
;
54
vec4
extents
;
55
uint
instance_count
;
56
uint
static_mesh
;
57
uint
lm_offset
;
58
uint
material
;
59
uint
first
;
60
uint
count
;
61
uint
pad0
;
62
uint
pad1
;
63
};
64
65
#define MAX_MESH_NODES 1024
66
layout
(std430, binding = 15) buffer MeshNodeData {
67
68
float
focal_distance;
69
uint pad0;
70
uint pad1;
71
uint pad2;
72
MeshNode
mns[
MAX_MESH_NODES
];
73
74
};
75
76
77
#define MAX_INSTANCES 1024
78
layout
(std430, binding = 4) buffer VisibleData {
79
80
uint visible_indices[];
81
82
};
83
84
layout
(std430, binding = 11) buffer JointData {
85
86
mat4
joint_mats[];
87
88
};
89
out
vec3
FragWorldPos
;
90
uniform uint
uOffset
;
91
uniform uint
uDynamicPass
;
92
out
vec2
UV
;
93
flat out uint
Mat
;
94
uniform uint
uStartArr
;
95
uniform uint
uStartEle
;
96
97
void
main
()
98
{
99
100
vec3
pos = aPosition;
101
102
uint off = 0;
103
uint
index_offset
=
uStartArr
+ gl_DrawID;
104
if
(
uDynamicPass
== 1)
105
{
106
107
DrawArraysIndirectCommand
com = draw_arrays_commands[
uOffset
-1];
108
off = com.
instanceCount
+ com.
baseInstance
;
109
index_offset
=
uStartEle
+ gl_DrawID;
110
index_offset
+=
uOffset
;
111
}
112
uint visible_offset =
index_offset
*
MAX_INSTANCES
;
113
Transform
tr = trs[visible_indices[visible_offset + gl_InstanceID]];
114
mat4
skinMat =
115
joint_mats[aJointIndices.x] * aWeights.x +
116
joint_mats[aJointIndices.y] * aWeights.y +
117
joint_mats[aJointIndices.z] * aWeights.z +
118
joint_mats[aJointIndices.w] * aWeights.w;
119
vec4
skinned_pos = skinMat *
vec4
(pos, 1.0);
120
vec4
worldPos = tr.
mat
* skinned_pos;
121
vec4
clipPos =
projection
*
view
* tr.
mat
* skinned_pos;
122
MeshNode
mn = mns[tr.
mn_id
];
123
Mat
= tr.
material
;
124
UV
= aUV;
125
FragWorldPos
= worldPos.xyz;
126
gl_Position = clipPos;
127
}
layout
layout(local_size_x=16, local_size_y=16) in
main
void main()
Definition
audio_probe_bake.comp:465
UV
in vec2 UV
Definition
depth_pre_pass.frag:70
Mat
flat in uint Mat
Definition
depth_pre_pass.frag:69
uDynamicPass
uniform uint uDynamicPass
Definition
depth_pre_pass.vert:114
uOffset
uniform uint uOffset
Definition
depth_pre_pass.vert:113
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
DrawArraysIndirectCommand::instanceCount
uint32_t instanceCount
Definition
engine_types.h:845
DrawArraysIndirectCommand::baseInstance
uint32_t baseInstance
Definition
engine_types.h:847
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
FragWorldPos
in vec3 FragWorldPos
Definition
point_light_shadows.frag:41
projection
uniform mat4 projection
Definition
shadow.vert:15
view
uniform mat4 view
Definition
shadow.vert:16
ivec2
Definition
types.h:14
ivec4
Definition
types.h:16
mat4
Definition
types.h:21
vec2
Definition
types.h:11
vec3
Definition
types.h:12
vec4
Definition
types.h:13
src
render
shadow.vert
Generated by
1.18.0