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

Unable to Render After Successfully Loading Volume #2

Open
TouKaienn opened this issue Jan 7, 2025 · 4 comments
Open

Unable to Render After Successfully Loading Volume #2

TouKaienn opened this issue Jan 7, 2025 · 4 comments

Comments

@TouKaienn
Copy link

Thanks for your amazing implementation.

I tried to run the code. However, I encountered an issue: the rendering result is always empty even after successfully loading the volume.
The terminal output:
image

The GUI output:
image

I found that this issue may be caused by this line;, the dir_world may output [0,0,0] and initialized ray direction may be [nan,nan,nan], which result in wrong rendering results.

I would greatly appreciate any guidance or suggestions to resolve this issue. Thank you for your time in advance!

@yuehaowang
Copy link
Owner

Hi,

Thanks for your questions!

This is a project I did many years ago. The last time I tried running it was nearly a year ago, and I didn't find any problems. So, before I can reproduce this issue, I may need to know your Linux distro, OpenGL & CUDA versions.

Also, could you help me check the line you mentioned, like printing the values of dir_world? It is not straightforward for me to see the reason why dir_world will become all zeros.

@TouKaienn
Copy link
Author

Many Thanks for your prompt response.

Here is more information about my environment:
Linux distro: Ubuntu 22.04
OpenGL version: 4.6.0 Nvidia 550.120
CUDA version: 11.8

The package versions do not exactly match the test environment in readme. Maybe I should try to downgrade opengl or cuda version in this case.

I print out the values of dir_world by modifying the line I mentioned into:

__host__ __device__ Ray Camera::generateRay(float dx, float dy) const
{
    float half_fov = vertical_fov / 2;
    float image_aspect_ratio = film.getAspectRatio(); 
    float im_plane_w = tan(half_fov * PI / 180) * image_aspect_ratio;
    float im_plane_h = tan(half_fov * PI / 180);
    
    float x_cam = (2 * (dx / film.resolution.x()) - 1) * im_plane_w;
    float y_cam = (2 * (dy / film.resolution.y()) - 1) * im_plane_h;
    Eigen::Vector3f dir_camera(x_cam, y_cam, -1.0);

    Eigen::Matrix3f view;
    view.col(0) << right;
    view.col(1) << up;
    view.col(2) << forward;
    Eigen::Vector3f dir_world = (view * dir_camera).normalized();
    // print out all dir_world
    printf("dir_world: %f %f %f\n", dir_world.x(), dir_world.y(), dir_world.z());
    
    
    return Ray(position, dir_world);
}

The terminal output is:
image

Thanks again for your help.

@TouKaienn
Copy link
Author

TouKaienn commented Jan 7, 2025

Hi,

I figured out how to solve this problem by calculating dir_world manually each time. In other words, I modified the line I mentioned above into:

__host__ __device__ Ray Camera::generateRay(float dx, float dy) const
{
    float half_fov = vertical_fov / 2;
    float image_aspect_ratio = film.getAspectRatio(); 
    float im_plane_w = tan(half_fov * PI / 180) * image_aspect_ratio;
    float im_plane_h = tan(half_fov * PI / 180);
    
    float x_cam = (2 * (dx / film.resolution.x()) - 1) * im_plane_w;
    float y_cam = (2 * (dy / film.resolution.y()) - 1) * im_plane_h;
    Eigen::Vector3f dir_camera(x_cam, y_cam, -1.0);

    Eigen::Matrix3f view;
    view.col(0) << right;
    view.col(1) << up;
    view.col(2) << forward;

    //original
    // Eigen::Vector3f dir_world = (view * dir_camera).normalized(); 

   //new
    float dir_world_x = view(0,0) * dir_camera.x() + view(0,1) * dir_camera.y() + view(0,2) * dir_camera.z();
    float dir_world_y = view(1,0) * dir_camera.x() + view(1,1) * dir_camera.y() + view(1,2) * dir_camera.z();
    float dir_world_z = view(2,0) * dir_camera.x() + view(2,1) * dir_camera.y() + view(2,2) * dir_camera.z();
    Eigen::Vector3f dir_world(dir_world_x,dir_world_y,dir_world_z);    

    return Ray(position, dir_world);
}

And the dir_world can be calculated correctly and the rendering result is correct.
image

However, I still have no idea why the computation of Eigen::Vector3f dir_world = (view * dir_camera).normalized(); can not perform correctly in this case.

You may close this issue if you wish.

@yuehaowang
Copy link
Owner

Great to know you've resolved this issue. Probably it is due to the incompatibility of Eigen and the latest Ubuntu / CUDA.
I will look into this issue if I can later find a PC with a similar environment.

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