-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtype_common.h
109 lines (94 loc) · 2.95 KB
/
type_common.h
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
// Copyright (c) 2022 Feng Yang
//
// I am making my contributions/submissions to this project solely in my
// personal capacity and am not conveying any rights to any intellectual
// property of any third parties.
#pragma once
#import <simd/simd.h>
#import "config.h"
typedef enum {
Position = 0,
Normal = 1,
UV_0 = 2,
Tangent = 3,
Bitangent = 4,
Color_0 = 5,
Weights_0 = 6,
Joints_0 = 7,
UV_1 = 8,
UV_2 = 9,
UV_3 = 10,
UV_4 = 11,
UV_5 = 12,
UV_6 = 13,
UV_7 = 14,
} Attributes;
// MARK: - Light
struct PointLightData {
/// Position in XYZ, radius squared in W.
vector_float4 posSqrRadius;
/// RGB color of light.
vector_float3 color;
/// Optional flags. May include `LIGHT_FOR_TRANSPARENT_FLAG`.
uint flags;
};
// Point light information for culling.
struct PointLightCullingData {
// Bounding sphere position in XYZ and radius of sphere in W.
// Sign of radius:
// positive - transparency affecting light
// negative - light does not affect transparency
vector_float4 posRadius;
};
struct SpotLightData {
/// Position in XYZ and height of spot in W.
vector_float4 posAndHeight;
/// Bounding sphere for quick visibility test.
vector_float4 boundingSphere;
/// RGB color of light.
vector_float4 colorAndInnerAngle;
/// Direction in XYZ, cone angle in W.
vector_float4 dirAndOuterAngle;
/// View projection matrix to light space.
matrix_float4x4 viewProjMatrix;
/// Optional flags. May include `LIGHT_FOR_TRANSPARENT_FLAG`.
uint flags;
};
// Spot light information for culling.
struct SpotLightCullingData {
// Bounding sphere position in XYZ and radius of sphere in W.
// Sign of radius:
// positive - transparency affecting light
// negative - light does not affect transparency
vector_float4 posRadius;
// View space position in XYZ and height of spot in W.
vector_float4 posAndHeight;
// View space direction in XYZ and cosine of outer angle in W.
vector_float4 dirAndOuterAngle ;
};
struct DirectLightData {
vector_float3 color;
vector_float3 direction;
};
typedef struct CameraData {
matrix_float4x4 u_viewMat;
matrix_float4x4 u_projMat;
matrix_float4x4 u_VPMat;
matrix_float4x4 u_viewInvMat;
matrix_float4x4 u_projInvMat;
matrix_float4x4 u_invViewProjectionMatrix;
vector_float3 u_cameraPos;
// Frustum planes in world space.
vector_float4 worldFrustumPlanes[6];
// A float4 containing the lower right 2x2 z,w block of inv projection matrix (column major);
// viewZ = (X * projZ + Z) / (Y * projZ + W)
vector_float4 invProjZ;
// Same as invProjZ but the result is a Z from 0...1 instead of N...F;
// effectively linearizes Z for easy visualization/storage.
vector_float4 invProjZNormalized;
} CameraData;
struct RendererData {
matrix_float4x4 u_localMat;
matrix_float4x4 u_modelMat;
matrix_float4x4 u_normalMat;
};