Cycles: new Microfacet-based Hair BSDF with elliptical cross-section support #105600

Merged
Weizhen Huang merged 114 commits from weizhen/blender:microfacet_hair into main 2023-08-18 12:46:20 +02:00

114 Commits

Author SHA1 Message Date
Weizhen Huang 130a10a8a1 Fix function not available due to recent change in main 2023-08-18 11:50:37 +02:00
Weizhen Huang 37b7e90306 Cleanup: comments and empty line 2023-08-18 11:41:54 +02:00
Weizhen Huang 9c9c18c659 Merge remote-tracking branch 'origin' into microfacet_hair 2023-08-18 11:40:00 +02:00
Weizhen Huang b71d6840fa Merge remote-tracking branch 'origin' into microfacet_hair 2023-08-15 16:36:17 +02:00
Weizhen Huang e6b102efc9 Rename `principled_hair` -> `hair_chiang`, `microfacet_hair` -> `hair_huang` 2023-08-15 16:32:10 +02:00
Weizhen Huang 45c79b0cfd Use geometric series to compute albedo 2023-08-15 15:36:25 +02:00
Weizhen Huang c606b6515a Fix OSL missing early-out when the modulation factors are zero 2023-08-14 18:16:43 +02:00
Weizhen Huang 7d14b8da7e Fix transparent closure not allocated 2023-08-14 17:51:37 +02:00
Weizhen Huang 1a6b4c6d0c Fix assertion error
`total_energy` could be zero even when the modulation factors are non-zero
2023-08-14 17:50:05 +02:00
Weizhen Huang 40b8bc055b Resolve some review comments 2023-08-14 15:12:53 +02:00
Weizhen Huang 04bb899969 Merge remote-tracking branch 'origin' into microfacet_hair 2023-08-14 12:28:20 +02:00
Lukas Stockner 4e14e4d0de Fix transparency early-out 2023-08-09 18:35:05 -07:00
Lukas Stockner 68501a20e2 Move early-out logic to shader setup time 2023-08-07 17:08:12 -07:00
Weizhen Huang 8e22265389 Merge remote-tracking branch 'origin' into microfacet_hair 2023-08-04 18:14:59 +02:00
Weizhen Huang e888002668 Cleanup: rearrange data nodes 2023-08-04 18:13:21 +02:00
Weizhen Huang 40e45dee57 Cleanup: remove unnecessary lines 2023-08-04 15:51:54 +02:00
Weizhen Huang 91dae1866b Cleanup: rename functions 2023-08-04 15:51:40 +02:00
Weizhen Huang ae5176c92b Cleanup: format in comments 2023-08-04 15:50:22 +02:00
Weizhen Huang b278dbadbc Cleanup: move utility functions to `bsdf_util.h` 2023-08-04 15:49:03 +02:00
Weizhen Huang 408c90224e Remove microfacet distribution type, use GGX 2023-08-04 15:47:14 +02:00
Weizhen Huang cc9c70d9ef Merge principled hair and microfacet hair in one shader node 2023-08-04 12:57:22 +02:00
Weizhen Huang b5eca9c2c5 Merge remote-tracking branch 'origin' into microfacet_hair 2023-08-02 15:54:04 +02:00
Weizhen Huang b5d445797e Merge remote-tracking branch 'origin' into microfacet_hair 2023-06-05 12:57:19 +02:00
Weizhen Huang d00e7fd9c7 Revert "Merge remote-tracking branch 'origin' into microfacet_hair"
This reverts commit e2409b4e56.
2023-06-05 12:36:27 +02:00
Weizhen Huang e2409b4e56 Merge remote-tracking branch 'origin' into microfacet_hair 2023-06-05 12:32:47 +02:00
Weizhen Huang 9fd0c502d6 Approximate TRRT+ terms 2023-05-04 17:57:40 +02:00
Weizhen Huang 2ec576f1a3 Cleanup: invert the direction of `refract_angle()` 2023-05-04 17:21:57 +02:00
Weizhen Huang 1a7203edbb Merge remote-tracking branch 'origin' into microfacet_hair 2023-05-03 10:50:10 +02:00
Weizhen Huang 91562e880e Add albedo scaling to reduce energy loss 2023-05-03 10:49:43 +02:00
Weizhen Huang 824a998a14 Reduce visibility check 2023-05-02 19:20:24 +02:00
Weizhen Huang 34d6b3eb54 Use non-separable visibility term to reduce energy loss 2023-05-01 15:22:14 +02:00
Weizhen Huang 12d4f515a0 float3 -> Spectrum 2023-05-01 14:58:20 +02:00
Weizhen Huang cab3b5eeed Remove unused variable
buildbot/vexp-code-patch-coordinator Build done. Details
2023-04-18 16:14:01 +02:00
Weizhen Huang 1b08175c30 Add back `SD_BSDF_HAS_TRANSMISSION` flag
buildbot/vexp-code-patch-coordinator Build done. Details
2023-04-17 17:06:44 +02:00
Weizhen Huang 778de47f31 Merge remote-tracking branch 'origin' into microfacet_hair 2023-04-17 11:13:05 +02:00
Weizhen Huang 1c6d728248 Negate `tilt` in `setup()` instead of `eval()` and `sample()` 2023-04-17 11:11:16 +02:00
Weizhen Huang a8c3ba0593 Precalculate some quantities 2023-04-17 11:01:10 +02:00
Weizhen Huang 028f09ccf5 Fix multiplying radius instead of dividing 2023-04-17 10:52:46 +02:00
Weizhen Huang c499e2247b small cleanups 2023-04-14 19:46:29 +02:00
Weizhen Huang cc0e4cca1f Only 2 closures used 2023-04-13 17:39:11 +02:00
Weizhen Huang 22f9898b4d Some cleanups 2023-04-13 17:39:02 +02:00
Weizhen Huang b47cc2aaa7 Remove unused node inputs 2023-04-13 17:12:09 +02:00
Weizhen Huang 738f284e95 Minor cleanups 2023-04-13 14:25:16 +02:00
Weizhen Huang 90cf06c874 Cleanup: de-duplicate code in `closure.h` 2023-04-13 14:25:08 +02:00
Weizhen Huang 6ea34518b9 Merge remote-tracking branch 'origin' into microfacet_hair 2023-04-13 11:01:29 +02:00
Weizhen Huang 869fbcc712 Some comments 2023-04-12 18:49:35 +02:00
Weizhen Huang d07c115957 Fix compile error on GPU 2023-04-12 18:49:18 +02:00
Weizhen Huang dfbe7c544f Remove `LABEL_TRANSMIT` 2023-04-12 18:22:14 +02:00
Weizhen Huang a9534f0fdd Cleanup: reorder #MicrofacetHairBSDF and #MicrofacetHairExtra 2023-04-12 17:52:02 +02:00
Weizhen Huang 68605cd1c7 Modified position and description of the R, TT and TRT lobes 2023-04-12 14:56:47 +02:00
Weizhen Huang 1cd5c44e68 Fix wrong projected radius in sampling 2023-04-11 18:42:17 +02:00
Weizhen Huang 1ad653dae0 Merge remote-tracking branch 'origin' into microfacet_hair 2023-04-11 18:06:34 +02:00
Weizhen Huang f486679a3b Fix assert error with preview ball 2023-04-11 17:08:11 +02:00
Weizhen Huang aab4328641 Merge remote-tracking branch 'origin' into microfacet_hair 2023-04-11 11:06:48 +02:00
Weizhen Huang 9039f76928 Revert changes regarding curve normal computation
This is irrelevant to the shader itself, should be put in a separate patch.
2023-03-09 16:17:13 +01:00
Weizhen Huang 6858fba43d Add identifier to a few input sockets 2023-03-09 15:44:24 +01:00
Weizhen Huang d0cb0d5fbc Merge remote-tracking branch 'origin' into microfacet_hair 2023-03-09 14:54:50 +01:00
Weizhen Huang c78f23f71b Merge remote-tracking branch 'origin' into microfacet_hair 2023-03-07 17:26:27 +01:00
Weizhen Huang a903e7bb32 Merge remote-tracking branch 'origin' into microfacet_hair 2023-03-07 14:59:54 +01:00
Weizhen Huang b7070df8a7 Merge remote-tracking branch 'origin' into microfacet_hair 2023-03-07 14:20:17 +01:00
Weizhen Huang 5926f69f39 Format comment 2023-01-23 12:20:11 +01:00
Weizhen Huang 167b3bb17d Add paper citation and format comments 2023-01-23 12:15:22 +01:00
Weizhen Huang 035ee375ac Use functions in `bsdf_microfacet.h` 2023-01-23 11:58:15 +01:00
Weizhen Huang 05e7caed94 Merge branch 'master' into microfacet_hair 2023-01-23 10:22:28 +01:00
Weizhen Huang 33ff1ce7b2 Merge code for circular and elliptical cross-sections 2023-01-20 20:11:30 +01:00
Weizhen Huang 46bc834a3d Merge branch 'master' into microfacet_hair 2023-01-20 15:18:29 +01:00
Weizhen Huang 0383da5f44 Cleanup: unify notations: O for outgoing direction, I for incoming/viewing/camera direction 2023-01-16 18:53:21 +01:00
Weizhen Huang 935f500501 Reuse albedo functions in principled hair BSDF 2023-01-16 16:49:52 +01:00
Weizhen Huang 9e5c1787a5 Remove empirical scaling to match microfacet and principled hair BSDF 2023-01-16 16:20:00 +01:00
Weizhen Huang f0529cfabc Add support for OSL shader to microfacet hair model 2023-01-16 16:16:58 +01:00
Weizhen Huang e69877c217 Cleanup: renaming and formatting comments 2023-01-12 19:52:24 +01:00
Weizhen Huang 5c9581920e Remove node input "Blur" 2023-01-12 18:40:43 +01:00
Weizhen Huang 0da0f29c17 Replace legacy custom fields with node storage struct 2023-01-12 17:55:01 +01:00
Weizhen Huang 9b99cc216b Add description to shader node inputs 2023-01-11 20:09:31 +01:00
Weizhen Huang f7f0888635 Renaming R lobe to Reflection 2023-01-11 18:42:52 +01:00
Weizhen Huang f88b91fe61 Split `model_type` into `cross_section_type` and `distribution_type`
Also disable analytical GGX R because it seems confusing
2023-01-11 18:23:04 +01:00
Weizhen Huang 08684b2601 Merge branch 'master' into microfacet_hair 2023-01-10 13:24:52 +01:00
Weizhen Huang c1413e64d1 Deal with cases where derivatives = 0 2023-01-09 18:26:53 +01:00
Weizhen Huang 8ee7e626a5 Interpolate between the curvature vector and the minimal twist vector
with custom weight
2023-01-09 17:32:17 +01:00
Weizhen Huang 74cab3ea05 Cleanup: remove unneeded variable 2023-01-06 14:26:13 +01:00
Weizhen Huang 148e954dbb Add comment to failed test 2023-01-06 13:04:53 +01:00
Weizhen Huang b47fc535f1 Merge branch 'master' into microfacet_hair 2023-01-06 11:44:26 +01:00
Weizhen Huang 6b5f323b90 Small modification to comment 2023-01-05 18:27:57 +01:00
Weizhen Huang 5015c8219b Compute hair normal with minimal total potential energy
Although computed in the geometry node, this normal is specific for
hairs is only implemented for Catmull-Rom splines. Questions remain
whether this should be generalized, also a few design ideas are obscure.
{F14115834}
2023-01-05 17:46:59 +01:00
Weizhen Huang 8af16fd087 Fix compiler error in the normal and tangent computation 2023-01-02 16:14:42 +01:00
Weizhen Huang 93e0559f54 WIP: calculate normals aligned with the curvature vector
Only works for Catmull-Rom and poly curve types for now
2023-01-02 15:49:28 +01:00
Weizhen Huang c574ddc104 Fix wrong interval numbers in composite Simpson's method 2022-12-28 12:41:33 +01:00
Weizhen Huang 767eb3cd6a Only add normal attributes for elliptical hairs 2022-12-27 13:52:25 +01:00
Weizhen Huang 8bad526d51 Fix normal attribute was defined per curve instead of per key 2022-12-27 13:51:58 +01:00
Weizhen Huang 4990122abb Merge branch 'master' into microfacet_hair 2022-12-27 11:07:13 +01:00
Weizhen Huang b1c549059d Cleanup: remove unused variables 2022-12-22 18:49:09 +01:00
Weizhen Huang 4415ebc336 Cleanup: rename eccentricity -> aspect ratio 2022-12-22 18:47:21 +01:00
Weizhen Huang e73d4734f9 Switch normal and binormal if aspect ratio larger than 1 2022-12-22 18:35:54 +01:00
Weizhen Huang f4987bdb06 Treat hair as transparent if intersection lies outside of the radius 2022-12-22 18:24:58 +01:00
Weizhen Huang 9c59a200b5 Add TODO for curve API 2022-12-22 15:55:04 +01:00
Weizhen Huang c80ff8a39d Add comments to normal computations 2022-12-22 15:21:39 +01:00
Weizhen Huang ba62e31b45 Compute normal for new hair system 2022-12-22 15:13:07 +01:00
Weizhen Huang 8125657606 Pass dummy normal to elliptical hairs 2022-12-22 15:05:00 +01:00
Weizhen Huang 5e21a0909c Cleanup: formatting and `fast_sincosf()` call 2022-12-20 12:05:35 +01:00
Weizhen Huang 63d51d3305 Cleanup: formatting float 2022-12-19 20:22:37 +01:00
Weizhen Huang a8608aab3d Merge branch 'master' into microfacet_hair 2022-12-19 20:09:43 +01:00
Weizhen Huang d96320c2da Cleanup: pass pointer of variable that will be modified 2022-12-19 20:08:36 +01:00
Weizhen Huang 028918661a Fix variable passed to `fresnel()` being `NaN` sometimes 2022-12-19 20:03:03 +01:00
Weizhen Huang bf0075f886 Cleanup: delete unused variables 2022-12-19 19:22:29 +01:00
Weizhen Huang 0c07582169 Cleanup: minor API change for `sample_wh()`` 2022-12-19 19:18:42 +01:00
Weizhen Huang b08064d867 Start with less parameters 2022-12-19 17:09:20 +01:00
Weizhen Huang 5be12da189 Merge branch 'master' into microfacet_hair 2022-12-16 15:43:44 +01:00
Weizhen Huang f15010bbe6 Remove unnecessary Jacobians 2022-12-15 16:16:13 +01:00
Weizhen Huang 7bd7538b25 Revert to original implementation (needs investigation) 2022-12-14 15:18:43 +01:00
Weizhen Huang 1edaee9926 Cleanup: renaming a few functions and variables 2022-12-14 15:13:15 +01:00
Weizhen Huang 4234a8017e Merge branch 'master' into microfacet_hair 2022-12-13 11:47:00 +01:00
Weizhen Huang e5dc796da9 Cleanup: remove unused variables in `fresnel()` 2022-12-07 18:08:09 +01:00
Weizhen Huang cc7317af53 Cleanup: adjust the usage and naming of a few utility functions 2022-12-07 17:20:15 +01:00
Weizhen Huang 68573757bc Cycles: initial commit of microfacet hair bsdf
This is an implementation of the paper [A Microfacet-based Hair Scattering Model](https://onlinelibrary.wiley.com/doi/full/10.1111/cgf.14588) by Weizhen Huang, Matthias Hullin, and Johannes Hanika.
Original implementation in [Mitsuba 2](https://github.com/RiverIntheSky/roughhair) by Weizhen Huang.
Adapted to Cycles by Olivier Maury D16682 and Christophe Hery.
2022-12-06 18:43:56 +01:00