{"id":16751016,"url":"https://github.com/elerac/btf-rendering","last_synced_at":"2025-04-10T15:38:21.075Z","repository":{"id":114595353,"uuid":"294681680","full_name":"elerac/btf-rendering","owner":"elerac","description":"Custom plugin in Python for BTF (Bidirectional Texture Function) rendering with Mitsuba 2","archived":false,"fork":false,"pushed_at":"2023-12-08T01:48:14.000Z","size":8446,"stargazers_count":14,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T13:21:25.912Z","etag":null,"topics":["btf","mitsuba","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elerac.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-11T11:51:16.000Z","updated_at":"2024-10-21T12:48:51.000Z","dependencies_parsed_at":"2025-02-17T12:42:03.213Z","dependency_job_id":null,"html_url":"https://github.com/elerac/btf-rendering","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elerac%2Fbtf-rendering","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elerac%2Fbtf-rendering/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elerac%2Fbtf-rendering/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elerac%2Fbtf-rendering/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elerac","download_url":"https://codeload.github.com/elerac/btf-rendering/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248243482,"owners_count":21071054,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["btf","mitsuba","python"],"created_at":"2024-10-13T02:42:50.335Z","updated_at":"2025-04-10T15:38:21.054Z","avatar_url":"https://github.com/elerac.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BTF Rendering\nCustom plugin in Python to render measured BTF (Bidirectional Texture Function)  with Mitsuba 2.\n\n![](documents/cloth_wool.jpg)\n\n## Requirement in Python\nMake sure that the following libraries are available in python.\n- [SciPy](https://www.scipy.org/)\n- [BTF Extractor](https://github.com/2-propanol/BTF_extractor)\n- [tqdm](https://github.com/tqdm/tqdm) (optional)\n\n## Usage \n1. Clone and compile [Mitsuba 2](https://github.com/mitsuba-renderer/mitsuba2). Check whether you can `import mitsuba` in python.\n2. Clone this repository and move it there.\n```bash\ngit clone https://github.com/elerac/btf-rendering.git\ncd btf-rendering\n```\n3. Download [UBO2003 BTF Dataset](https://cg.cs.uni-bonn.de/en/projects/btfdbb/download/ubo2003/). Make directory named `UBO2003/` and save the data under there. OR, you can run [download_large_data.py](https://github.com/elerac/btf-rendering/blob/master/download_large_data.py) and the data will download automatically.  \nHave you placed BTF Dataset as shown below?\n```\n.\n├── UBO2003\n│   ├── UBO_IMPALLA256.zip\n│   ├── ...\n├── custom_bsdf\n├── download_large_data.py\n├── rendering.py\n├── scenes\n├── ...\n```\n4. Run [rendering.py](https://github.com/elerac/btf-rendering/blob/master/rendering.py) and get [rendered image using BTF](https://github.com/elerac/btf-rendering/blob/master/documents/simple_sphere_impalla.jpg).\n\n## Measured BTF (*measuredbtf*)\n| Parameter | Type | Description | \n| :-- | :-- | :-- |\n| filename | string | Filename of the BTF database file to be loaded. The type of dataset is distinguished by its extension. .zip for UBO2003, .btf for UBO2014.|\n| reflectance| float | Adjust the reflectance of the BTF. (Default: 1.0) |\n| apply_inv_gamma | boolean | Whether to apply inverse gamma correction. If the input is the gamma-corrected image, this process should be applied. (Default: *true*) | \n| power_parameter | float | Determine the smoothness of the interpolation. The smaller the value, the smoother it is. (Default: 4.0) |\n| wrap_mode | string | Controls the behavior of texture evaluations that fall outside of the [0,1] range. The `repeat` and `mirror` options are currently available. (Default: `repeat`)|\n| to_uv | transform | Specifies an optional 3x3 UV transformation matrix. A 4x4 matrix can also be provided, in which case the extra row and column are ignored. (Default: none) |\n\n| | | \n| :-: | :-: |\n| ![](documents/matpreview_impalla.jpg)| ![](documents/matpreview_leather09.jpg) |\n| UBO2003 IMPALLA | UBO2014 leather09 |\n\nThis custom plugin implements a BTF for rendering reflections of textures taken in a real scene. The BTF is a set of images with different illumination and viewing directions.\n\n`filename` is the name of the BTF database file. This file should follow the format of the BTF dataset of University of Bonn.\nDownload the [UBO2003](https://cg.cs.uni-bonn.de/en/projects/btfdbb/download/ubo2003/) or [ATRIUM](https://cg.cs.uni-bonn.de/en/projects/btfdbb/download/atrium/) or [UBO2014](https://cg.cs.uni-bonn.de/en/projects/btfdbb/download/ubo2014/) dataset for rendering.\n\n```xml\n\u003cbsdf type=\"measuredbtf\"\u003e\n    \u003c!-- UBO2003 case --\u003e\n    \u003cstring name=\"filename\" value=\"UBO_IMPALLA256.zip\"/\u003e\n    \u003ctransform name=\"to_uv\"\u003e\n        \u003cscale value=\"5\"/\u003e\n    \u003c/transform\u003e\n\u003c/bsdf\u003e\n```\n\n### Interpolation and Power Parameter\nThis custom plugin interpolates BTF. The interpolation is done by [k-nearest neighbor sampling](https://en.wikipedia.org/wiki/K-nearest_neighbors_algorithm) and [inverse distance weighting](https://en.wikipedia.org/wiki/Inverse_distance_weighting).\nThe weight of the inverse distance weighting can be adjusted by the `power_parameter` *p*. The parameter *p* determines the influence of the distance between the interpolation points. The smaller *p* is, the smoother the interpolation will be.\n\nThe following figures show the difference in appearance when *p* is changed. When *p* is small (*p*=1), the texture is smooth and specular reflection is weak. On the other hand, when *p* is large (*p*=32), the texture has discontinuous boundaries. This is because the angle of the captured BTF data is sparse.\n| | | | | \n| :-: | :-: | :-: | :-: |\n| ![](documents/simple_sphere_p1.jpg) | ![](documents/simple_sphere_p2.jpg) | ![](documents/simple_sphere_p4.jpg) | ![](documents/simple_sphere_p32.jpg) |\n| *p* = 1 | *p* = 2 | *p* = 4 | *p* = 32 |\n\n\n## Warning\nIn the `scalar_rgb` variant, the execution of this plugin is **extremely slow**. Thus, using the `gpu_rgb` variant is recommended.\n\n## Rendered Images from Other Papers\n\nI collected the rendered images from other papers that employ the 3D model of cloth originated at this repository ([`scenes/cloth/cloth.obj`](scenes/cloth/)). These beautifully rendered images enhance the effectiveness of their excellent methods for BTF data processing.\n\n![Rendered image borrowed from Fig.1](documents/kavoosighafi2023.jpg)\n*Kavoosighafi et al., \"SparseBTF: Sparse Representation Learning for Bidirectional Texture Functions\", Eurographics Symposium on Rendering, 2023. [[Link]](https://diglib.eg.org/handle/10.2312/sr20231123)*\n\n![Rendered image borrowed from Fig.10](documents/dou2023.jpg)\n*Dou et al., \"Real-Time Neural BRDF with Spherically Distributed Primitives\", arXiv, 2023. [[Link]](https://arxiv.org/abs/2310.08332)*\n\nYou are free to use my 3D model and scene file of cloth (and also my code) for academic purposes. If you use them, it is not necessary, but I would appreciate it if you refer to my name.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felerac%2Fbtf-rendering","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felerac%2Fbtf-rendering","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felerac%2Fbtf-rendering/lists"}