Untitled
Loading...
Searching...
No Matches
point_light_shadows.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
15
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
26layout(std430, binding = 5) buffer DrawArraysData {
27
28 DrawArraysIndirectCommand draw_arrays_commands[];
29};
30layout(std140, binding = 0) uniform CameraData {
31 vec4 cam_pos;
32 vec4 cam_vel;
34 mat4 unjittered_projection;
35 mat4 view;
36 mat4 inv_projection;
37 mat4 unjittered_inv_projection;
38 mat4 inv_view;
39};
40layout(std140, binding = 1) uniform RenderingData {
41 ivec4 resolution;
42};
43layout(std140, binding = 2) uniform LightCameraData {
44 mat4 light_proj[4];
45 mat4 light_view[4];
46};
47
48layout(std140, binding = 4) uniform PrevCameraData {
49 vec4 prev_cam_pos;
50 vec4 prev_cam_vel;
51 mat4 prev_projection;
52 mat4 prev_unjittered_projection;
53 mat4 prev_view;
54 mat4 prev_inv_projection;
55 mat4 prev_unjittered_inv_projection;
56 mat4 prev_inv_view;
57};
58struct Transform
59{
60 uint mn_id;
61 uint command_id;
63 uvec2 spot_lights;
64 uint skin_offset;
65 uint material;
66 mat4 mat;
67};
68layout(std430, binding = 7) buffer TransformData {
69
70 Transform trs[];
71
72};
73struct MeshNode
74{
75 vec4 min;
76 vec4 max;
77 vec4 center;
78 vec4 extents;
79 uint instance_count;
80 uint static_mesh;
81 uint lm_offset;
82 uint material;
83 uint first;
84 uint count;
85 uint pad0;
86 uint pad1;
87};
88
89#define MAX_MESH_NODES 1024
90layout(std430, binding = 15) buffer MeshNodeData {
91
92 float focal_distance;
93 uint pad0;
94 uint pad1;
95 uint pad2;
97
98};
99
100#define MAX_INSTANCES 1024
101layout(std430, binding = 4) buffer VisibleData {
102
103 uint visible_indices[];
104
105};
106
107layout(std430, binding = 11) buffer JointData {
108
109 mat4 joint_mats[];
110
111};
112
113
114uniform uint uOffset;
115uniform uint uDynamicPass;
116
117uniform uint uStartArr;
119{
120 uint Mat;
122
124
125void main()
126{
127
128 vec3 pos = aPosition;
129
130 uint off = 0;
131 uint index_offset = uStartArr + gl_DrawID;
132 if (uDynamicPass == 1)
133 {
134
135 DrawArraysIndirectCommand com = draw_arrays_commands[uOffset-1];
136 off = com.instanceCount + com.baseInstance;
138 }
139 uint visible_offset = index_offset * MAX_INSTANCES;
140 Transform tr = trs[visible_indices[visible_offset + gl_InstanceID]];
141 mat4 skinMat =
142 joint_mats[aJointIndices.x] * aWeights.x +
143 joint_mats[aJointIndices.y] * aWeights.y +
144 joint_mats[aJointIndices.z] * aWeights.z +
145 joint_mats[aJointIndices.w] * aWeights.w;
146 vec4 skinned_pos = skinMat * vec4(pos, 1.0);
147 gs_in.Mat = tr.material;
148 gs_in.UV = aUV;
149 vec4 worldPos = tr.mat * skinned_pos;
150 gl_Position = worldPos;
151}
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 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.
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