Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to load two GS ply at the same time and render it #1

Open
RanYu-GN opened this issue Jan 4, 2025 · 2 comments
Open

How to load two GS ply at the same time and render it #1

RanYu-GN opened this issue Jan 4, 2025 · 2 comments

Comments

@RanYu-GN
Copy link

RanYu-GN commented Jan 4, 2025

At present, I want to add a scene to render together when rendering. I load two point cloud files and copy them to cuda together. However, the merged GS data cannot be rendered correctly and the color is very strange. I cannot render correctly after various tests. However, when I reduce my copy below to a single GS data, I can render correctly, do you have a better way?
`
count = P_array[0] * 2;
CUDA_SAFE_CALL_ALWAYS(cudaMalloc((void**)&pos_cuda, count * sizeof(Pos)));
CUDA_SAFE_CALL_ALWAYS(cudaMemcpy(pos_cuda, pos_cuda_array[0], P_array[0] * sizeof(Pos), cudaMemcpyDeviceToDevice));
CUDA_SAFE_CALL_ALWAYS(cudaMemcpy(pos_cuda + P_array[0], pos_cuda_array[0], P_array[0] * sizeof(Pos), cudaMemcpyDeviceToDevice));

CUDA_SAFE_CALL_ALWAYS(cudaMalloc((void**)&rot_cuda, count * sizeof(Rot)));
CUDA_SAFE_CALL_ALWAYS(cudaMemcpy(rot_cuda, rot_cuda_array[0], P_array[0] * sizeof(Rot), cudaMemcpyDeviceToDevice));
CUDA_SAFE_CALL_ALWAYS(cudaMemcpy(rot_cuda + P_array[0], rot_cuda_array[0], P_array[0] * sizeof(Rot), cudaMemcpyDeviceToDevice));

CUDA_SAFE_CALL_ALWAYS(cudaMalloc((void**)&scale_cuda, count * sizeof(Scale)));
CUDA_SAFE_CALL_ALWAYS(cudaMemcpy(scale_cuda, scale_cuda_array[0], P_array[0] * sizeof(Scale), cudaMemcpyDeviceToDevice));
CUDA_SAFE_CALL_ALWAYS(cudaMemcpy(scale_cuda + P_array[0], scale_cuda_array[0], P_array[0] * sizeof(Scale), cudaMemcpyDeviceToDevice));

CUDA_SAFE_CALL_ALWAYS(cudaMalloc((void**)&opacity_cuda, count * sizeof(float)));
CUDA_SAFE_CALL_ALWAYS(cudaMemcpy(opacity_cuda, opacity_cuda_array[0], P_array[0] * sizeof(float), cudaMemcpyDeviceToDevice));
CUDA_SAFE_CALL_ALWAYS(cudaMemcpy(opacity_cuda + P_array[0], opacity_cuda_array[0], P_array[0] * sizeof(float), cudaMemcpyDeviceToDevice));

CUDA_SAFE_CALL_ALWAYS(cudaMalloc((void**)&shs_cuda, count * sizeof(SHs<3>)));
CUDA_SAFE_CALL_ALWAYS(cudaMemcpy(shs_cuda, shs_cuda_array[0], P_array[0] * sizeof(SHs<3>), cudaMemcpyDeviceToDevice));
 CUDA_SAFE_CALL_ALWAYS(cudaMemcpy(shs_cuda + P_array[0], shs_cuda_array[0], P_array[0] * sizeof(SHs<3>), cudaMemcpyDeviceToDevice));

CUDA_SAFE_CALL_ALWAYS(cudaMalloc((void**)&rect_cuda, 2 * count * sizeof(int)));
CUDA_SAFE_CALL_ALWAYS(cudaMemcpy(rect_cuda, rect_cuda_array[0], 2 * P_array[0] * sizeof(int), cudaMemcpyDeviceToDevice));
CUDA_SAFE_CALL_ALWAYS(cudaMemcpy(rect_cuda + 2 * P_array[0], rect_cuda_array[0], 2 * P_array[0] * sizeof(int), cudaMemcpyDeviceToDevice));

`

@AuthorityWang
Copy link
Owner

Hi,
I wonder if you want to load two sequences and render them together in one scene. If so, I wonder if you set the count correctly, as it should be the sum of the number of points in the two point cloud, not directly 2 times of P_array[0]. Which may result in render correctly for single GS data but error for two different GS data.
Besides, I suggest you can merge them before copy to CUDA memory, and then copy the new vector to CUDA like the process for single data.

@RanYu-GN
Copy link
Author

RanYu-GN commented Jan 7, 2025

Thank you very much for your reply! I found the wrong place before me.
pos_cuda + P_array[0] * sizeof(Pos) / sizeof(float)
CUDA_SAFE_CALL_ALWAYS(cudaMalloc((void**)&pos_cuda, count * sizeof(Pos))); CUDA_SAFE_CALL_ALWAYS(cudaMemcpy(pos_cuda, pos_cuda_array[0], P_array[0] * sizeof(Pos), cudaMemcpyDeviceToDevice)); CUDA_SAFE_CALL_ALWAYS(cudaMemcpy(pos_cuda + P_array[0] * sizeof(Pos) / sizeof(float), pos_cuda_array[0], P_array[0] * sizeof(Pos), cudaMemcpyDeviceToDevice));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants