Commit Graph

224 Commits

Author SHA1 Message Date
Lukas Stockner
17f2cdd104 Cycles: Add thin film iridescence to Principled BSDF
This is an implementation of thin film iridescence in the Principled BSDF based on "A Practical Extension to Microfacet Theory for the Modeling of Varying Iridescence".

There are still several open topics that are left for future work:
- Currently, the thin film only affects dielectric Fresnel, not metallic. Properly specifying thin films on metals requires a proper conductive Fresnel term with complex IOR inputs, any attempt of trying to hack it into the F82 model we currently use for the Principled BSDF is fundamentally flawed. In the future, we'll add a node for proper conductive Fresnel, including thin films.
- The F0/F90 control is not very elegantly implemented right now. It fundamentally works, but enabling thin film while using a Specular Tint causes a jump in appearance since the models integrate it differently. Then again, thin film interference is a physical effect, so of course a non-physical tweak doesn't play nicely with it.
- The white point handling is currently quite crude. In short: The code computes XYZ values of the reflectance spectrum, but we'd need the XYZ values of the product of the reflectance spectrum and the neutral illuminant of the working color space. Currently, this is addressed by just dividing by the XYZ values of the illuminant, but it would be better to do a proper chromatic adaptation transform or to use the proper reference curves for the working space instead of the XYZ curves from the paper.

Pull Request: https://projects.blender.org/blender/blender/pulls/118477
2024-05-02 14:28:44 +02:00
Clément Foucault
e581ba077d Fix: EEVEE-Next: Principled BSDF transmission color applied twice
This was caused by the 2 transmission event approximation we
do for object with non-null thickness. This follows cycles
by using the square root of the color.
2024-04-30 19:32:52 +02:00
David Murmann
ee51f643b0 Cycles: Ray Portal BSDF
Transport rays that enter to another location in the scene, with
specified ray position and normal. This may be used to render portals
for visual effects, and other production rendering tricks.

This acts much like a Transparent BSDF. Render passes are passed
through, and this is affected by light path max transparent bounces.

Pull Request: https://projects.blender.org/blender/blender/pulls/114386
2024-04-29 12:37:51 +02:00
Alaska
f8c0050a25 Shaders: Add Roughness to Subsurface Scattering Node
Matching the Principled BSDF.

Pull Request: https://projects.blender.org/blender/blender/pulls/114499
2024-04-29 10:54:29 +02:00
Alaska
afa66fc628 Shader: Clamp invalid inputs of various BSDF nodes
Clamp some of the inputs of the Glossy BSDF, Glass BSDF, Sheen BSDF,
and Subsurface Scattering nodes to improve consistency between render
engines and to avoid unexpected results.

* Clamp roughness to 0..1
* Clamp subsurface radius to 0..inf
* Clamp colors to 0..inf

Pull Request: https://projects.blender.org/blender/blender/pulls/120390
2024-04-26 17:39:39 +02:00
Clément Foucault
6d347dd5ca Fix: EEVEE-Next: Point cloud macro coliding with voronoi texture
Was caused by macro declaration. Remove the macro
and add another `#if` case for EEVEE-next instead.

Fix #115438
2024-04-24 09:38:32 +02:00
Clément Foucault
c601569702 Fix: EEVEE-Next: Displacement: Revert object scaling on output
This was introduced by f371624b2e
but this breaks the render test. Need another approach to match
cycles with object scaling.
2024-04-18 12:30:03 +02:00
Campbell Barton
f8197098c6 Cleanup: spelling in comments 2024-04-17 14:18:33 +10:00
Clément Foucault
a772c84341 EEVEE-Next: Changes to thickness output
This contains two thing:
- default (nothing connected to socket) uses the bounding box min axis.
- transform the value plugged to the socket to world space.

We arbitrarly choose to output the axis with the minimum extent since
it is the axis along which the object is usually viewed at.

Rel #120384

Pull Request: https://projects.blender.org/blender/blender/pulls/120607
2024-04-15 12:16:51 +02:00
Clément Foucault
fdf5a05bde Fix: EEVEE-Next: Broken shader compilation because of displacement
Oversight inside f371624b2e
2024-04-13 12:57:50 +02:00
Clément Foucault
f371624b2e Fix: EEVEE-Next: Displacement: Wrong output space
The space of the displacement socket on the ouput node
is local space. We now scale it back to world space
as expected by the consumer code.
2024-04-13 12:37:29 +02:00
Hoshinova
c78c6b0bdf Fix #119797: Noise Texture Precision Issues
The Perlin noise algorithms suffer from precision issues when a coordinate
is greater than about 250000.

To fix this the Perlin noise texture is repeated every 100000 on each axis.
This causes discontinuities every 100000, however at such scales this
usually shouldn't be noticeable.

Pull Request: https://projects.blender.org/blender/blender/pulls/119884
2024-03-29 16:12:23 +01:00
Jeroen Bakker
f0f911590e EEVEE-Next: Viewport pixel size with up-sampling
EEVEE-Next performes less on integrated GPUs then discrete GPUs.
Most shaders have been analyzed, but there will always be bottlenecks
related to architectural differences.

In order to make EEVEE-Next run smooth on integrated GPUs this change
will implement viewport pixel size option similar to Cycles. The main difference
is that the samples will still be weighted and up-sampled to the final film
resolution. This makes the pixels not look squared in the viewport but will
resolve to something close to the results without up-scaling.

This improves the performance especially on integrated GPUs. The improvement
for discrete GPUs are less noticeable. See here the stats when playing
`rain_restaurant.blend` back on a RAPHAEL_MENDOCINO iGPU.

| Pixel size | Frames per second |
|------------|-------------------|
| 1x         | 0.25 FPS          |
| 2x         | 4.14 FPS          |
| 4x         | 6.90 FPS          |
| 8x         | 9.95 FPS          |

Related to: #114597
See PR for some example images.

Pull Request: https://projects.blender.org/blender/blender/pulls/118903
2024-03-13 12:00:24 +01:00
Jeroen Bakker
e6eecdf614 EEVEE-Next: Voronoi colors are pure emissive
The voronoi texture node only sets the first 3 components of the
color. The alpha value is never set. Normally this is covered
when using it in a shader node, but when directly connected to
the AOV output, the color was stored as a pure emissive color.

This resulted in incorrect colors in the viewport and image renders.

This is a partial fix for #118494

Pull Request: https://projects.blender.org/blender/blender/pulls/118497
2024-02-21 11:32:29 +01:00
Miguel Pozo
ef6b6031de Fix #117123: EEVEE: Broken Specular BSDF
Add missing disable sss flag
2024-01-15 16:57:18 +01:00
Miguel Pozo
31d8a6514f Fix: EEVEE(Legacy): Broken dielectric material shading
sss_radius r and g are already used for occlussion workarounds.
Use only sss_radius.b for flagging sss as disabled.
Regression from 2942147079.
2024-01-10 17:59:20 +01:00
Clément Foucault
ea989ebf94 EEVEE/EEVEE-Next: Split Diffuse and Subsurface closure
Even if related, they don't have the same performance
impact.

To avoid any performance hit, we replace the Diffuse
by a Subsurface Closure for legacy EEVEE and
use the subsurface closure only where needed for
EEVEE-Next leveraging the random sampling.

This increases the compatibility with cycles that
doesn't modulate the radius of the subsurface anymore.
This change is only present in EEVEE-Next.

This commit changes the principled BSDF code so that
it is easier to follow the flow of data.

For legacy EEVEE, the SSS switch is moved to a
`radius == -1` check.
2024-01-09 16:39:17 +13:00
Clément Foucault
ac11ccd2bd EEVEE-Next: Add Translucent BSDF support
This adds support for Translucent BSDF.

This also fixes a bug to allow correct
shadowing.

The input normal had to be set back to
non-inverted in the node function to allow
for correct interpretation of the Normal
by Screen Space Reflections.

This add the necessary optimization
and code deduplication to hybrid deferred
and forward pipeline.

Pull Request: https://projects.blender.org/blender/blender/pulls/116070
2023-12-13 02:19:19 +01:00
Clément Foucault
92bec9af0c Fix EEVEE: Compilation on Metal 2023-11-30 01:10:27 +01:00
Jeroen Bakker
8ae80abe5f Fix: Various Small GLSL Material Tweaks
We should use explicit casting. Although it is not always needed it
is a best practise in order to support the shaders on Metal.

* `float max(float, int)` is not supported on Metal and fails with a compilation error

Pull Request: https://projects.blender.org/blender/blender/pulls/115464
2023-11-27 12:06:28 +01:00
Jason Fielder
9042773d93 GPU: Resolve compilation error in Metal caused by type ambiguity
Recent change in commit 3f778150a9
caused compilation errors in Metal due to type ambiguity. Updating call to
explicitly utilise floats where appropriate.

Authored by Apple: Michael Parkin-White

Co-authored-by: Michael Parkin-White <mparkinwhite@apple.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/115301
2023-11-27 11:50:25 +01:00
Jeroen Bakker
53ebe40ed2 Fix: EEVEE Compiler Issue Emission Shader
Due to recent changes the local variables where not explicitly cast, that failed
when compiling on Metal.

Pull Request: https://projects.blender.org/blender/blender/pulls/115463
2023-11-27 08:46:23 +01:00
Campbell Barton
27c660707d Cleanup: spelling in comments, variables 2023-11-27 09:54:36 +11:00
Miguel Pozo
3f778150a9 GPU: Sanitize closure nodes inputs
Ensure all Closures are filled with correct values,
like the principled bsdf node already does.

The main reason is that the new AgX color transform doesn't play well
with negative values (see #113220), but it's probably best to ensure we
use sanitized values in the rendering code as a whole.

Pull Request: https://projects.blender.org/blender/blender/pulls/115059
2023-11-21 20:15:59 +01:00
Hoshinova
0b11c591ec Nodes: Merge Musgrave node into Noise node
This path merges the Musgrave and Noise Texture nodes into a single
combined Noise Texture node. The reasoning is that both nodes
intrinsically do the same thing, which is the layering of Perlin noise
derivatives to produce fractal noise. So the patch de-duplicates code
and unifies the use of fractal noise for the end use.

Since the Noise node had a Distortion input and a Color output, while
the Musgrave node did not, those are now available to the Musgrave types
as new functionalities.

The Dimension input of the Musgrave node is analogous to the Roughness
input of the Noise node, so both inputs were unified to follow the same
behavior of the Roughness input, which is arguable more intuitive to
control. Similarly, the Detail input was slightly different across both
nodes, since the Noise node evaluated one extra layer of noise. This was
also unified to follow the behavior of the Noise node.

The patch, coincidentally fixes an unreported bug causing repeated
output for certain noise types and another floating precision bug
#112180.

The versioning code implemented with this patch ensures backward
compatibility for both the Musgrave and Noise Texture nodes. When
opening older Blender files in Blender 4.1 the output of both nodes are
guaranteed to always be exactly identical to that of Blender files
created before the nodes were merged in all cases.

Forward compatibility with Blender 4.0 is implemented by #114236.
Forward compatibility with Blender 3.6 LTS is implemented by #115015.

Pull Request: #111187
2023-11-18 09:40:44 +01:00
Miguel Pozo
7c68e9a94c Fix #114524: EEVEE-Next: Wrong normal map node result
The new draw manager stores the object scale as a regular flag.
Update `node_normal_map` to read it correctly.

Pull Request: https://projects.blender.org/blender/blender/pulls/114587
2023-11-07 18:58:31 +01:00
Brecht Van Lommel
adb41fe6b2 Merge branch 'blender-v4.0-release' into main 2023-11-06 19:13:18 +01:00
Alaska
f1116f64bd Fix #114435: Harsh Principled BSDF Subsurface transition in EEVEE
Fixes a harsh transistion between diffuse and subsurface scattering
materials in the Principled BSDF as a user increases the Subsurface
Scattering Weight from 0 to 1.

Pull Request: https://projects.blender.org/blender/blender/pulls/114500
2023-11-06 17:25:14 +01:00
Lukas Stockner
d15013b583 Merge branch 'blender-v4.0-release' 2023-10-31 05:48:58 +01:00
Alaska
a15f9e49ec Shader: Only clamp undefined or unsupported inputs of Principled BSDF
Adjust clamping of inputs in the Principled BSDF to avoid errors and
inconsistencies between render engines, while trying to leave as many
inputs as possible unclamped for artisitc purposes.

Pull Request: https://projects.blender.org/blender/blender/pulls/112895
2023-10-31 03:14:04 +01:00
Brecht Van Lommel
39107b3133 Revert changes from main commits that were merged into blender-v4.0-release
The last good commit was 8474716abb.

After this commits from main were pushed to blender-v4.0-release. These are
being reverted.

Commits a4880576dc from to b26f176d1a that happend afterwards were meant for
4.0, and their contents is preserved.
2023-10-30 21:40:35 +01:00
Dalai Felinto
7b7cef7998 Merge remote-tracking branch 'origin/blender-v4.0-release' 2023-10-24 16:09:51 +02:00
Jeroen Bakker
ea2746d468 Fix #113235: Voronoi GLSL Shaders On Legacy Intel
When using Voronoi shader nodes on legacy Intel platforms (HD4400) Blender would crash
due to a driver bug. The bug is related to generating the `fractal_voronoi_x_fx` functions.
It doesn't effect all drivers, but mainly from vendors that don't allow installing the official
intel drivers.

We have tried several approaches including using unique function names and unroll only the
function of the body. But none worked on the failing platform.

In the future we could solve this by including our own GLSL compiler, but that is still very
experimental and requires a lot of testing.#113938

Pull Request: https://projects.blender.org/blender/blender/pulls/113834
2023-10-24 14:49:09 +02:00
Campbell Barton
ce7444fa50 Merge branch 'blender-v4.0-release' 2023-10-20 14:00:36 +11:00
Alaska
686aece797 Shader: Adjust Coat Tint Color intensity based on Coat Weight
The previous formula for adjusting Coat Tint intensity resulted
in strong tints and sudden colour changes when using a low coat weight.

This commit fixes these issues by mixing between a white tint (no tint)
and the chosen tint based on the Coat Weight.

Pull Request: https://projects.blender.org/blender/blender/pulls/113468
2023-10-20 00:34:24 +02:00
Clément Foucault
71dfcf4558 EEVEE-Next: Remove common lib usage
Replaces all usage by the the gpu_shader_math
equivalent. This is because the old shader
library was quite tangled.

This avoids dependency hell trying to
mix libraries.

Changes are split into isolated commits until
I had to do mass changes because of inter-
dependencies.

Pull Request: https://projects.blender.org/blender/blender/pulls/113631
2023-10-13 17:59:46 +02:00
Clément Foucault
a5741e0561 EEVEE: Change do_multiscatter to a bool internally
This avoid confusion outside of the shader node GLSL code.
The issue also is that Metal allow float to cast to bool
implicitly but this create a compilation error on
OpenGL.
2023-09-26 11:48:51 +02:00
Clément Foucault
0a4fa62f51 EEVEE: Add support for metallic F82 tint
This adds a new entry to the split sum LUT to isolate
the effect of the F82 tint.

The application of the tint part is similar to cycles
and uses the same way for precomputing the `b` factor.

Results matches almost perfectly to the extent of the
split sum approximation.

Note that this removes the unused LTC MAG LUT for
EEVEE next to make space for the new table. It can still
be added back if needed.

Pull Request: https://projects.blender.org/blender/blender/pulls/112881
2023-09-26 10:16:39 +02:00
Brecht Van Lommel
3d38b51435 Shaders: add "Weight" to Transmission/Subsurface/Coat/Sheen socket names
Ref #99447
Ref #112848
2023-09-25 19:51:27 +02:00
Brecht Van Lommel
1d265eed5d Shaders: rename Specular to Specular IOR Level in Principled BSDF
To clarify that this is no longer the primary control, but rather
and adjustment on IOR.

Ref #99447
Ref #112552
2023-09-25 19:51:22 +02:00
Brecht Van Lommel
239edb27ad EEVEE: optimize principled BSDF by skipping unused components
Ref #99447
Ref #112848
2023-09-25 19:51:17 +02:00
Alaska
a03ee1af81 Shaders: clamp various shader inputs for Principled BSDF
Ref #99447

Pull Request: https://projects.blender.org/blender/blender/pulls/112774
2023-09-25 19:51:12 +02:00
Lukas Stockner
6e2f29b421 Shader: change Specular input on Principled BSDF to affect IOR
This keeps the behavior similar to the Disney BRDF, where 0.5
is neutral and lower/higher values respectively decrease/increase
the dielectric specular. But it's more correct in that it's not
an arbitrary scale on Fresnel, but rather adjusting the IOR.

Ref #99447
Ref #112848

Pull Request: https://projects.blender.org/blender/blender/pulls/112552
2023-09-25 19:51:02 +02:00
Brecht Van Lommel
3d986b81c5 Shaders: move subsurface scale input below radius in Principled BSDF
To help clarify that this is a scale on the radius.

Ref #99447
Ref #112848
2023-09-25 19:50:56 +02:00
Brecht Van Lommel
334027063e Shader: use single Principled BSDF input for metallic and specular tint
To match Standard Surface and OpenPBR.

Ref #99447
Ref #112848
2023-09-25 19:50:44 +02:00
Weizhen Huang
def9b76207 Shader: Change specular tint in Principled BSDF from float to color
For more artistic control. Tints the reflection of dielectric materials
at normal incidence.

Ref #99447

Pull Request: https://projects.blender.org/blender/blender/pulls/112192
2023-09-25 19:42:05 +02:00
Lukas Stockner
86156566a7 Cycles: Add Metallic Tint to Principled BSDF using F82-Tint model
With the default value, this is backwards-compatible.

Ref #99447

Pull Request: https://projects.blender.org/blender/blender/pulls/112551
2023-09-25 19:42:05 +02:00
Weizhen Huang
e0dacfdda6 EEVEE: use Schlick's approximation instead of real Fresnel for glass
so that we can tint `F0` separately
Ref: #112192 #99447

Mostly affects `IOR < 1`. The overall appearance matches, with some changes in the reflection.

Pull Request: https://projects.blender.org/blender/blender/pulls/112390
2023-09-18 14:26:19 +02:00
Alaska
88ad79c2d1 Add panels to Principled BSDF node
Add panels to the Principled BSDF node to organize
and reduce the size of the node.

Layout inspired by previous work from @LukasStockner

Pull Request: https://projects.blender.org/blender/blender/pulls/112314
2023-09-17 15:42:15 +02:00
Weizhen Huang
5baf652374 Cleanup: EEVEE: rename glass BTDF to BSDF at several places
because it contains reflectance and transmittance, so BSDF would be a
morep proper name.
Also rename BSDF to BRDF at places where only reflectance is returned.
2023-09-14 16:06:26 +02:00