21 |
BibTeX
22 |
@Article{kerbl3Dgaussians,
23 | author = {Kerbl, Bernhard and Kopanas, Georgios and Leimk{\"u}hler, Thomas and Drettakis, George},
24 | title = {3D Gaussian Splatting for Real-Time Radiance Field Rendering},
25 | journal = {ACM Transactions on Graphics},
26 | number = {4},
27 | volume = {42},
28 | month = {July},
29 | year = {2023},
30 | url = {https://repo-sam.inria.fr/fungraph/3d-gaussian-splatting/}
31 | }
32 |
33 |
--------------------------------------------------------------------------------
/submodules/depth-diff-gaussian-rasterization/cuda_rasterizer/auxiliary.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023, Inria
3 | * GRAPHDECO research group, https://team.inria.fr/graphdeco
4 | * All rights reserved.
5 | *
6 | * This software is free for non-commercial, research and evaluation use
7 | * under the terms of the LICENSE.md file.
8 | *
9 | * For inquiries contact george.drettakis@inria.fr
10 | */
11 |
12 | #ifndef CUDA_RASTERIZER_AUXILIARY_H_INCLUDED
13 | #define CUDA_RASTERIZER_AUXILIARY_H_INCLUDED
14 |
15 | #include "config.h"
16 | #include "stdio.h"
17 |
18 | #define BLOCK_SIZE (BLOCK_X * BLOCK_Y)
19 | #define NUM_WARPS (BLOCK_SIZE/32)
20 |
21 | // Spherical harmonics coefficients
22 | __device__ const float SH_C0 = 0.28209479177387814f;
23 | __device__ const float SH_C1 = 0.4886025119029199f;
24 | __device__ const float SH_C2[] = {
25 | 1.0925484305920792f,
26 | -1.0925484305920792f,
27 | 0.31539156525252005f,
28 | -1.0925484305920792f,
29 | 0.5462742152960396f
30 | };
31 | __device__ const float SH_C3[] = {
32 | -0.5900435899266435f,
33 | 2.890611442640554f,
34 | -0.4570457994644658f,
35 | 0.3731763325901154f,
36 | -0.4570457994644658f,
37 | 1.445305721320277f,
38 | -0.5900435899266435f
39 | };
40 |
41 | __forceinline__ __device__ float ndc2Pix(float v, int S)
42 | {
43 | return ((v + 1.0) * S - 1.0) * 0.5;
44 | }
45 |
46 | __forceinline__ __device__ void getRect(const float2 p, int max_radius, uint2& rect_min, uint2& rect_max, dim3 grid)
47 | {
48 | rect_min = {
49 | min(grid.x, max((int)0, (int)((p.x - max_radius) / BLOCK_X))),
50 | min(grid.y, max((int)0, (int)((p.y - max_radius) / BLOCK_Y)))
51 | };
52 | rect_max = {
53 | min(grid.x, max((int)0, (int)((p.x + max_radius + BLOCK_X - 1) / BLOCK_X))),
54 | min(grid.y, max((int)0, (int)((p.y + max_radius + BLOCK_Y - 1) / BLOCK_Y)))
55 | };
56 | }
57 |
58 | __forceinline__ __device__ float3 transformPoint4x3(const float3& p, const float* matrix)
59 | {
60 | float3 transformed = {
61 | matrix[0] * p.x + matrix[4] * p.y + matrix[8] * p.z + matrix[12],
62 | matrix[1] * p.x + matrix[5] * p.y + matrix[9] * p.z + matrix[13],
63 | matrix[2] * p.x + matrix[6] * p.y + matrix[10] * p.z + matrix[14],
64 | };
65 | return transformed;
66 | }
67 |
68 | __forceinline__ __device__ float4 transformPoint4x4(const float3& p, const float* matrix)
69 | {
70 | float4 transformed = {
71 | matrix[0] * p.x + matrix[4] * p.y + matrix[8] * p.z + matrix[12],
72 | matrix[1] * p.x + matrix[5] * p.y + matrix[9] * p.z + matrix[13],
73 | matrix[2] * p.x + matrix[6] * p.y + matrix[10] * p.z + matrix[14],
74 | matrix[3] * p.x + matrix[7] * p.y + matrix[11] * p.z + matrix[15]
75 | };
76 | return transformed;
77 | }
78 |
79 | __forceinline__ __device__ float3 transformVec4x3(const float3& p, const float* matrix)
80 | {
81 | float3 transformed = {
82 | matrix[0] * p.x + matrix[4] * p.y + matrix[8] * p.z,
83 | matrix[1] * p.x + matrix[5] * p.y + matrix[9] * p.z,
84 | matrix[2] * p.x + matrix[6] * p.y + matrix[10] * p.z,
85 | };
86 | return transformed;
87 | }
88 |
89 | __forceinline__ __device__ float3 transformVec4x3Transpose(const float3& p, const float* matrix)
90 | {
91 | float3 transformed = {
92 | matrix[0] * p.x + matrix[1] * p.y + matrix[2] * p.z,
93 | matrix[4] * p.x + matrix[5] * p.y + matrix[6] * p.z,
94 | matrix[8] * p.x + matrix[9] * p.y + matrix[10] * p.z,
95 | };
96 | return transformed;
97 | }
98 |
99 | __forceinline__ __device__ float dnormvdz(float3 v, float3 dv)
100 | {
101 | float sum2 = v.x * v.x + v.y * v.y + v.z * v.z;
102 | float invsum32 = 1.0f / sqrt(sum2 * sum2 * sum2);
103 | float dnormvdz = (-v.x * v.z * dv.x - v.y * v.z * dv.y + (sum2 - v.z * v.z) * dv.z) * invsum32;
104 | return dnormvdz;
105 | }
106 |
107 | __forceinline__ __device__ float3 dnormvdv(float3 v, float3 dv)
108 | {
109 | float sum2 = v.x * v.x + v.y * v.y + v.z * v.z;
110 | float invsum32 = 1.0f / sqrt(sum2 * sum2 * sum2);
111 |
112 | float3 dnormvdv;
113 | dnormvdv.x = ((+sum2 - v.x * v.x) * dv.x - v.y * v.x * dv.y - v.z * v.x * dv.z) * invsum32;
114 | dnormvdv.y = (-v.x * v.y * dv.x + (sum2 - v.y * v.y) * dv.y - v.z * v.y * dv.z) * invsum32;
115 | dnormvdv.z = (-v.x * v.z * dv.x - v.y * v.z * dv.y + (sum2 - v.z * v.z) * dv.z) * invsum32;
116 | return dnormvdv;
117 | }
118 |
119 | __forceinline__ __device__ float4 dnormvdv(float4 v, float4 dv)
120 | {
121 | float sum2 = v.x * v.x + v.y * v.y + v.z * v.z + v.w * v.w;
122 | float invsum32 = 1.0f / sqrt(sum2 * sum2 * sum2);
123 |
124 | float4 vdv = { v.x * dv.x, v.y * dv.y, v.z * dv.z, v.w * dv.w };
125 | float vdv_sum = vdv.x + vdv.y + vdv.z + vdv.w;
126 | float4 dnormvdv;
127 | dnormvdv.x = ((sum2 - v.x * v.x) * dv.x - v.x * (vdv_sum - vdv.x)) * invsum32;
128 | dnormvdv.y = ((sum2 - v.y * v.y) * dv.y - v.y * (vdv_sum - vdv.y)) * invsum32;
129 | dnormvdv.z = ((sum2 - v.z * v.z) * dv.z - v.z * (vdv_sum - vdv.z)) * invsum32;
130 | dnormvdv.w = ((sum2 - v.w * v.w) * dv.w - v.w * (vdv_sum - vdv.w)) * invsum32;
131 | return dnormvdv;
132 | }
133 |
134 | __forceinline__ __device__ float sigmoid(float x)
135 | {
136 | return 1.0f / (1.0f + expf(-x));
137 | }
138 |
139 | __forceinline__ __device__ bool in_frustum(int idx,
140 | const float* orig_points,
141 | const float* viewmatrix,
142 | const float* projmatrix,
143 | bool prefiltered,
144 | float3& p_view)
145 | {
146 | float3 p_orig = { orig_points[3 * idx], orig_points[3 * idx + 1], orig_points[3 * idx + 2] };
147 |
148 | // Bring points to screen space
149 | float4 p_hom = transformPoint4x4(p_orig, projmatrix);
150 | float p_w = 1.0f / (p_hom.w + 0.0000001f);
151 | float3 p_proj = { p_hom.x * p_w, p_hom.y * p_w, p_hom.z * p_w };
152 | p_view = transformPoint4x3(p_orig, viewmatrix);
153 |
154 | if (p_view.z <= 0.2f)// || ((p_proj.x < -1.3 || p_proj.x > 1.3 || p_proj.y < -1.3 || p_proj.y > 1.3)))
155 | {
156 | if (prefiltered)
157 | {
158 | printf("Point is filtered although prefiltered is set. This shouldn't happen!");
159 | __trap();
160 | }
161 | return false;
162 | }
163 | return true;
164 | }
165 |
166 | #define CHECK_CUDA(A, debug) \
167 | A; if(debug) { \
168 | auto ret = cudaDeviceSynchronize(); \
169 | if (ret != cudaSuccess) { \
170 | std::cerr << "\n[CUDA ERROR] in " << __FILE__ << "\nLine " << __LINE__ << ": " << cudaGetErrorString(ret); \
171 | throw std::runtime_error(cudaGetErrorString(ret)); \
172 | } \
173 | }
174 |
175 | #endif
--------------------------------------------------------------------------------
/submodules/depth-diff-gaussian-rasterization/cuda_rasterizer/backward.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2023, Inria
3 | * GRAPHDECO research group, https://team.inria.fr/graphdeco
4 | * All rights reserved.
5 | *
6 | * This software is free for non-commercial, research and evaluation use
7 | * under the terms of the LICENSE.md file.
8 | *
9 | * For inquiries contact george.drettakis@inria.fr
10 | */
11 |
12 | #ifndef CUDA_RASTERIZER_BACKWARD_H_INCLUDED
13 | #define CUDA_RASTERIZER_BACKWARD_H_INCLUDED
14 |
15 | #include