Giter Site home page Giter Site logo

asparagus15 / gaussianshader Goto Github PK

View Code? Open in Web Editor NEW
288.0 10.0 23.0 111.3 MB

code for GaussianShader: 3D Gaussian Splatting with Shading Functions for Reflective Surfaces

License: Other

CMake 11.18% C++ 63.94% GLSL 3.59% Gnuplot 0.13% C 1.29% Python 15.32% Batchfile 0.12% Cuda 4.44%

gaussianshader's Introduction

GaussianShader: 3D Gaussian Splatting with Shading Functions for Reflective Surfaces

Yingwenqi Jiang, Jiadong Tu, Yuan Liu, Xifeng Gao, Xiaoxiao Long*, Wenping Wang, Yuexin Ma*

*Corresponding authors

Introduction

The advent of neural 3D Gaussians has recently brought about a revolution in the field of neural rendering, facilitating the generation of high-quality renderings at real-time speeds. However, the explicit and discrete representation encounters challenges when applied to scenes featuring reflective surfaces. In this paper, we present GaussianShader, a novel method that applies a simplified shading function on 3D Gaussians to enhance the neural rendering in scenes with reflective surfaces while preserving the training and rendering efficiency.

Relit

GaussianShader maintains real-time rendering speed and renders high-fidelity images for both general and reflective surfaces. GaussianShader enables free-viewpoint rendering objects under distinct lighting environments.


Pipeline

GaussianShader initiates with the neural 3D Gaussian spheres that integrate both conventional attributes and the newly introduced shading attributes to accurately capture view-dependent appearances. We incorporate a differentiable environment lighting map to simulate realistic lighting. The end-to-end training leads to a model that reconstructs both reflective and diffuse surfaces, achieving high material and lighting fidelity.


Installation

Provide installation instructions for your project. Include any dependencies and commands needed to set up the project.

# Clone the repository
git clone https://github.com/Asparagus15/GaussianShader.git
cd GaussianShader

# Install dependencies
conda env create --file environment.yml
conda activate gaussian_shader

Running

Download the example data and put it to the data folder. Execute the optimizer using the following command:

python train.py -s data/horse_blender --eval -m output/horse_blender -w --brdf_dim 0 --sh_degree -1 --lambda_predicted_normal 2e-1 --brdf_env 512 

Rendering

python render.py -m output/horse_blender --brdf_dim 0 --sh_degree -1 --brdf_mode envmap --brdf_env 512

Dataset

We mainly evaluate our method on NeRF Synthetic, Tanks&Temples, Shiny Blender and Glossy Synthetic. You can use nero2blender.py to convert the Glossy Synthetic data into Blender format.

More features

The repo is still being under construction, thanks for your patience.

  • Arguments explanation.
  • Residual color training code.

Acknowledgement

We have intensively borrow codes from the following repositories. Many thanks to the authors for sharing their codes.

Citation

If you find this repository useful in your project, please cite the following work. :)

@article{jiang2023gaussianshader,
  title={GaussianShader: 3D Gaussian Splatting with Shading Functions for Reflective Surfaces},
  author={Jiang, Yingwenqi and Tu, Jiadong and Liu, Yuan and Gao, Xifeng and Long, Xiaoxiao and Wang, Wenping and Ma, Yuexin},
  journal={arXiv preprint arXiv:2311.17977},
  year={2023}
}

gaussianshader's People

Contributors

asparagus15 avatar xxlong0 avatar

Stargazers

 avatar Qiyu Dai avatar Cornu avatar  avatar ksdfhaksfhgkajh avatar  avatar Yuan Sun avatar Shreyas Jagannath avatar Kyubeom Han avatar wjt avatar Freeverc avatar  avatar  avatar Dogyoon Lee avatar wenqing wang avatar  avatar fangyan avatar Loping151 avatar  avatar Ramana Kiran avatar Jiangyu1181 avatar  avatar  avatar Pierre-Yves JACQUES avatar Yusuke Tomoto avatar Nate Merrill avatar  avatar Ruijie Lu avatar  avatar  avatar  avatar slam_study avatar Youjia avatar Pengcheng Yu avatar Youquan Liu avatar Weijie Lyu avatar Wieland Morgenstern avatar David avatar  avatar  avatar HanFish avatar yzy avatar Aegis226 avatar AI/ML Engineer avatar Xiaobing Han avatar Weidong Liu avatar Amelia Young avatar  avatar Yujian Zhang avatar 逗比学长 avatar WOOJUNE PARK avatar onvallamimi avatar Jinguang Tong avatar 龙笑泽 avatar  avatar Chenghao (Shenghao) Li avatar O_LEX avatar Batuhan Ozcomlekci avatar  avatar Yufei Liu avatar Han Hu avatar Geunsik Bae avatar Zhou Yuqi avatar Wei Wu avatar Warren Lu avatar Jesse Jaeseong Lee avatar Suiliang Mai avatar  avatar ShadowX avatar Boxiang Rong avatar  avatar Xiaohan Lei avatar Pablo Martin avatar zling avatar Liu Ziling avatar Chongshan avatar Jason Wang avatar  avatar Tosin avatar simba-wang avatar Deheng Zhang avatar morin avatar Yael avatar Chengkun Li avatar Hong Yu avatar  avatar Guo Han avatar CAI Zeyu avatar Neil Z. SHAO avatar Duotun Wang avatar Run avatar Tomáš Pazdiora avatar Ritchie avatar  avatar Jorge Guberte avatar Yuze Wang avatar zhanglb avatar CharlesGuo avatar Euphoria avatar Drewvv avatar

Watchers

Pablo Martin avatar Wei Wu avatar Snow avatar Bozidar Antic avatar  avatar  avatar hiyyg avatar Jiahao Cui avatar Francesco Fugazzi avatar  avatar

gaussianshader's Issues

How to get points3d.ply for blender datasets

Hi,
In the example dataset you provide (horse_blender), there is a points3d.ply file that can be used for initialization. May I ask how to produce this file for any blender dataset? The blender datasets I have found only have the camera position files and the images.
Thanks in advance,
Benoît

Creating a new bsdf_256_256.bin

Hi there! I need to create a new envmap from the .hdr file I just downloaded, but I can't convert the .hdr file into .bin format, is there a code or paper for such things?

Training mipnerf360 dataset performs poorly?

I trained the dataset with 3dgs example using your code and it works fine but I train mipnerf360
The effect is very poor when using the bicycle data set. The psnr of 3dgs is 25, but using your code is only 20. The rendered image also has many blurred areas.
图片1

How to lower memory consumption?

Hi, after an hour of running the training script with a custom dataset of 224 images, I've got:

[ITER 7000] Evaluating test: L1 0.030716074630618095 PSNR 17.14025115966797 [27/02 16:35:09]

[ITER 7000] Evaluating train: L1 0.030992737039923668 PSNR 17.04730796813965 [27/02 16:35:14]

[ITER 7000] Saving Gaussians [27/02 16:35:14]
Training progress:  49%|██████████████████████████████████████████████████████████▍                                                             | 14620/30000 [1:25:05<1:31:25,  2.80it/s, Loss=0.05720Training progress:  49%|██████████████████████████████████████████████████████████▍                                                             | 14620/30000 [1:25:08<1:31:25,  2.80it/s, Loss=0.05952TrainiTraining progress:  61%|█████████████████████████████████████████████████████████████████████████▏                                              | 18310/30000 [1:47:45<1:13:37,  2.65it/s, Loss=0.0402723]Traceback (most recent call last):
  File "train.py", line 247, in <module>
    training(lp.extract(args), op.extract(args), pp.extract(args), args.test_iterations, args.save_iterations)
  File "train.py", line 83, in training
    render_pkg = render(viewpoint_cam, gaussians, pipe, background, debug=False)
  File "/data/projects/GaussianShader/gaussian_renderer/__init__.py", line 247, in render
    cov3D_precomp = cov3D_precomp)[0]
  File "/opt/conda/envs/gaussian_splatting/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "/data/projects/GaussianShader/submodules/diff-gaussian-rasterization/diff_gaussian_rasterization/__init__.py", line 194, in forward
    raster_settings,
  File "/data/projects/GaussianShader/submodules/diff-gaussian-rasterization/diff_gaussian_rasterization/__init__.py", line 37, in rasterize_gaussians
    raster_settings,
  File "/data/projects/GaussianShader/submodules/diff-gaussian-rasterization/diff_gaussian_rasterization/__init__.py", line 78, in forward
    num_rendered, color, radii, geomBuffer, binningBuffer, imgBuffer = _C.rasterize_gaussians(*args)
RuntimeError: CUDA out of memory. Tried to allocate 1.60 GiB (GPU 0; 23.73 GiB total capacity; 11.84 GiB already allocated; 1.39 GiB free; 18.54 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation.  See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
Training progress:  61%|█████████████████████████████████████████████████████████████████████████▏                                              | 18310/30000 [1:47:47<1:08:49,  2.83it/s, Loss=0.0402723]

I'm looking for a way to reduce the memory consumption, either in the rasterizer or in the input variables, so I don't have this problem.
Any recommendations?
Thank you!

bug: fail to save hdr

hi, thanks for your work, i run the latest code, try to reproduce the results, but got this error:

WARNING: FAILED to save image output/horse_blender/brdf_mlp/iteration_7000/brdf_mlp.hdr

looking forward to your reply, thanks. @Asparagus15

How to view the rendering output

Hi,
thanks for you wonderful paper and the released code.

I would like to test it, but I have some issues as there are no instructions.
I finally was able to train a scene successfully but I cannot view it. The regular version of the SIBR viewer crashes. I could see that the output of a trained scene is extended. Not sure what you have modified in the included SIBR viewer, but when I build it, it gives me only so files but no executable binary.

Another question? Why did you set self.iterations = 500000000000
Any help or some updated Readme build and run instruction would be very helpful.
Thank you,
Janusch

The evaluation results in the paper seem to differ

First of all, I would like to extend my sincere gratitude for contributing such an excellent method to the industry!

However, I noticed a discrepancy between the test results of Ref-NeRF and those presented in the original Ref-NeRF paper while reading your study. Could you please clarify if any specific factors might have led to these differences?

refnerf-ori
gaussianshader

question about relighting

That is a wonderful work!! I have a question:When do you plan to publish the script on relighting?
best

Unable to replicate results.

Could you please give the full instructions to train and render the results for:

  1. NeRF Synthetic Dataset
  2. Shiny Dataset

`get_minimum_axis` seems wrong?

image

I've got an example here:

  1. The sorting selects 2 (the last column)
  2. gather moves the last column to the first column
  3. BUT R_sorted[:,0,:] selects the first row

So R_sorted[:,0,:] should be changed to R_sorted[:,:,0] ?

Why sorting the columns of R instead of rows?


After playing with the math, I believe that gather should work on rows instead of columns.

R_sorted = torch.gather(R, dim=2, index=sorted_idx[:,None,:].repeat(1, 3, 1)).squeeze()
# changes to 
R_sorted = torch.gather(R, dim=1, index=sorted_idx[:,:,None].repeat(1,1,3)).squeeze()

After the discussion below, we(@nyy618 and me) think that the normal is got by selecting the column.

R_sorted = torch.gather(R, dim=2, index=sorted_idx[:,None,:].repeat(1, 3, 1)).squeeze()
return R_sorted[:,:,0]

Pull request updated accordingly.

A question about related NVDIFFREC

File "/mnt/projects/4DGaussians/scene/NVDIFFREC/light.py", line 148, in shade
python-BaseException
self.diffuse = ru.diffuse_cubemap(self.specular[-1])
File "/home/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1265, in getattr
raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'EnvironmentLight' object has no attribute 'diffuse'

Colmap datasets deliver just plain black results

Great job with it!
I am trying to make it run on a custom dataset, that I've made with colmap. So far the relevant files are only :

$ tree .
.
├── distorted
│   ├── images
...
│   └── sparse
...
├── images
│   ├── test53_sax_cam01_1_1.jpg
│   ├── test53_sax_cam01_1_10.jpg
│   ├── test53_sax_cam01_1_11.jpg
...
├── sparse
│   └── 0
│       ├── cameras.bin
│       ├── images.bin
│       ├── points3D.bin
│       └── points3D.ply

The images look:
image

Images and dataset has been undistorted
More details about the model:

$ colmap model_analyzer --path sparse/0/
Cameras: 1
Images: 224
Registered images: 224
Points: 11203
Observations: 114430
Mean track length: 10.214228
Mean observations per image: 510.848214
Mean reprojection error: 1.562057px

Executed:

python train.py -s /data/datasets/sax/test-jpg/ --eval -m /data/datasets/sax/test-jpg/gshader/ -w --brdf_dim 0 --sh_degree -1

but all renders end up being black after the render script, and even the files, and the file sizes are conspicuously small:

$ ls -lashrt input.ply
296K -rw-r--r-- 1 root root 296K Feb 28 19:57 input.ply
$ ls -lashrt brdf_mlp/iteration_30000/brdf_mlp.hdr
40K -rw-r--r-- 1 root root 39K Feb 28 21:32 brdf_mlp/iteration_30000/brdf_mlp.hdr

Am I missing something fundamental?

About the loss in the code

I am wondering if there is something wrong with your LOSS in the code.
if iteration<opt.normal_reg_util_iter:
losses_extra['predicted_normal'] = predicted_normal_loss(render_pkg["normal"], render_pkg["normal_ref"], render_pkg["alpha"])

The results will be blurred if this loss is computed.

How to reproduce the result quality in Fig 2?

Hi, thanks for this great work!
I am reproducing the experiment in Figure 2 with a metallic sphere. I find that the quality of outcome seems have some problem. I am wondering whether I do the things in a right way. Following is the result that I get
image
Below I describe how I conduct the experiment:

  1. I made a homogenous metallic ball in blender, and rendered it into 120 multi-view images with BlenderNeRF; views are randomly distributed on a sphere.
  2. Gaussian model was optimized on these images with the following command/parameters:
    python train.py -s dataset/metalball_entiresphere/ --eval -m output/metalball_entiresphere -w --brdf_dim 0 --sh_degree -1 --lambda_predicted_normal 2e-1 --brdf_env 64
    iterations are set to 30000; any other parameters are set to default.

Could you please give some help on the parameters used in this experiment? Thanks in advance!

Does this repository support SIBR viewer?

Hi

Thanks for the excellent work. I try to follow the instructions of the original GS repository to run the installation of the SIBR viewer, but I fail. Could you please share how you install SIBR viewer?

Paper Result

Can you provide a full instruction on ShinyBlender dataset? I have no idea how to reproduce the paper result. And I am wondering why the data in your paper are inconsistent.
111
222

How to reproduce the performance reported in your paper

Hi, authors,
Thanks for your interesting work! When I tried to reproduce the performance on Shiny Blender dataset and run your code, I found that some of your default arguments are not consistent with your paper. For example, the weighted hyperparameters of each loss terms. After I fixed these issues and made the code runnable, I still cannot reproduce the performance you report in the paper. Could you tell me how to config the arguments for shiny blender? For examples, brdf_dim = ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.