Untitled
Loading...
Searching...
No Matches
shadow.vert
Go to the documentation of this file.
1
2#version 460
3layout(location = 0) in vec3 aPosition;
4layout(location = 1) in vec3 aNormal;
5layout(location = 2) in vec4 aTangent;
6layout(location = 3) in ivec4 aJointIndices;
7layout(location = 4) in vec4 aWeights;
8layout(location = 5) in vec2 aUV;
9layout(location = 6) in mat4 aInstanceMatrix;
10layout(location = 10) in ivec2 aPointLight;
11layout(location = 11) in ivec2 aDirectionalLight;
12layout(location = 12) in ivec2 aSpotLight;
13layout(location = 13) in int aSkinOffset;
14
16uniform mat4 view;
17
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
28layout(std430, binding = 5) buffer DrawArraysData {
29
30 DrawArraysIndirectCommand draw_arrays_commands[];
31};
32struct Transform
33{
34 uint mn_id;
35 uint command_id;
37 uvec2 spot_lights;
38 uint skin_offset;
39 uint material;
40 mat4 mat;
41};
42
43layout(std430, binding = 7) buffer TransformData {
44
45 Transform trs[];
46
47};
48
49struct 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
66layout(std430, binding = 15) buffer MeshNodeData {
67
68 float focal_distance;
69 uint pad0;
70 uint pad1;
71 uint pad2;
73
74};
75
76
77#define MAX_INSTANCES 1024
78layout(std430, binding = 4) buffer VisibleData {
79
80 uint visible_indices[];
81
82};
83
84layout(std430, binding = 11) buffer JointData {
85
86 mat4 joint_mats[];
87
88};
90uniform uint uOffset;
91uniform uint uDynamicPass;
92out vec2 UV;
93flat out uint Mat;
94uniform uint uStartArr;
95uniform uint uStartEle;
96
97void 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;
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(local_size_x=16, local_size_y=16) in
void main()
in vec2 UV
flat in uint Mat
uniform uint uDynamicPass
uniform uint uOffset
uniform uint uStartArr
uniform uint uStartEle
uniform int index_offset
Definition dynamic.frag:234
#define MAX_INSTANCES
Maximum amount of TransformGPU instances to push in one frame (used for SSBO sizing).
#define MAX_MESH_NODES
Maximum MeshNodes in a scene (used for SSBO sizing).
uint pad1
Definition coc.frag:55
uint first
Definition coc.frag:52
vec4 min
Definition coc.frag:44
uint material
Definition coc.frag:51
vec4 max
Definition coc.frag:45
uint lm_offset
Definition coc.frag:50
uvec2 directional_lights
uint pad0
Definition coc.frag:54
vec4 center
Definition coc.frag:46
uint instance_count
Definition coc.frag:48
bool static_mesh
If this mesh is static (DrawArrays) or dynamic (DrawElements), used to indicate Lightmap status.
size_t count
Count of vertices pushed into the MAIN_VBO.
vec4 extents
Definition coc.frag:47
DrawArraysIndirect commands are used for static meshes (eg.
MeshNodes that describe the position of Meshes, GLTF nodes for GLTFAnimations, or hold references to ...
Transforms for MeshNode models.
in vec3 FragWorldPos
uniform mat4 projection
Definition shadow.vert:15
uniform mat4 view
Definition shadow.vert:16
Definition types.h:14
Definition types.h:16
Definition types.h:21
Definition types.h:11
Definition types.h:12
Definition types.h:13