EEVEE Next: Subsurface Scattering #107407

Merged
Miguel Pozo merged 24 commits from pragma37/blender:pull-eevee-next-sss into main 2023-06-15 15:49:12 +02:00
Member

Port of subsurface scattering from the eevee-rewrite branch to EEVEE Next.
https://projects.blender.org/fclem/blender/src/branch/eevee-rewrite

Other changes:

  • Fix gbuffer normal and ior packing.
  • Write the material eClosureBits to the gbuffer stencil.

Known Issues:

  • SSS Transmittance energy is greater than Cycles with the same settings.
Cycles EEVEE Next
imagen imagen
Port of subsurface scattering from the eevee-rewrite branch to EEVEE Next. https://projects.blender.org/fclem/blender/src/branch/eevee-rewrite Other changes: * Fix gbuffer normal and ior packing. * Write the material eClosureBits to the gbuffer stencil. Known Issues: * SSS Transmittance energy is greater than Cycles with the same settings. | Cycles | EEVEE Next | | --- | --- | | ![imagen](/attachments/22bfa61e-5772-4dc0-bbdd-cc41f2224a5c) | ![imagen](/attachments/3b74ac72-f3e0-4e7e-9c0d-9181ea299a17) |
Miguel Pozo added this to the EEVEE & Viewport project 2023-04-27 18:12:43 +02:00
Miguel Pozo requested review from Clément Foucault 2023-04-27 18:12:53 +02:00
Miguel Pozo added the
Module
EEVEE & Viewport
label 2023-04-27 18:13:05 +02:00
Clément Foucault requested changes 2023-05-11 16:39:46 +02:00
@ -392,0 +395,4 @@
if (closure_bits_ & CLOSURE_SSS) {
inst_.subsurface.end_sync();
subsurface_ps_.init();

This subsurface pass should go inside SubsurfaceModule.

Note that, currently, the subsurface algorithm is quite simple, we might extend it in the future. Making everything in one place will avoid much trouble later on.

You can init the pass in all cases and only submit it if the closure bit is present.

This subsurface pass should go inside `SubsurfaceModule`. Note that, currently, the subsurface algorithm is quite simple, we might extend it in the future. Making everything in one place will avoid much trouble later on. You can init the pass in all cases and only submit it if the closure bit is present.
pragma37 marked this conversation as resolved
@ -183,0 +184,4 @@
.define("SSS_TRANSMITTANCE")
.sampler(SSS_TRANSMITTANCE_TEX_SLOT, ImageType::FLOAT_1D, "sss_transmittance_tx");
GPU_SHADER_CREATE_INFO(eevee_subsurface_eval)

Move subsurface infos to their own file.

Move subsurface infos to their own file.
pragma37 marked this conversation as resolved
Miguel Pozo force-pushed pull-eevee-next-sss from e26cef6b9d to 1d28e81235 2023-05-12 16:01:09 +02:00 Compare
Miguel Pozo added 2 commits 2023-06-01 17:54:45 +02:00
Jeroen Bakker approved these changes 2023-06-14 09:03:05 +02:00
Jeroen Bakker left a comment
Member

The PR has been discussed on blender.chat.

  • There is a difference between Cycles and Eevee-next. In a future iteration we should find out if we can get closer to Cycles.
  • Brecht did looked at the code and couldn't detect any issue.

I find the code to a level that it is fine to land in main.

The PR has been discussed on blender.chat. * There is a difference between Cycles and Eevee-next. In a future iteration we should find out if we can get closer to Cycles. * Brecht did looked at the code and couldn't detect any issue. I find the code to a level that it is fine to land in main.
Clément Foucault requested changes 2023-06-14 15:08:44 +02:00
Clément Foucault left a comment
Member

It is a bit difficult to guess what is causing this energy difference. I would say add a corrective factor that you empirically fit the best you can and leave a comment saying this is a workaround and should be fixed at some point.

There were many places where I did that in the past. It is better to break scenes by correcting a 2% energy error than a 50% energy error (given it is only a scaling issue).

I would also like to point out that it is still broken on Metal. But it is a problem for the Metal backend and should not hold this patch from landing.

It is a bit difficult to guess what is causing this energy difference. I would say add a corrective factor that you empirically fit the best you can and leave a comment saying this is a workaround and should be fixed at some point. There were many places where I did that in the past. It is better to break scenes by correcting a 2% energy error than a 50% energy error (given it is only a scaling issue). I would also like to point out that it is still broken on Metal. But it is a problem for the Metal backend and should not hold this patch from landing.
@ -97,2 +97,4 @@
#define SHADOW_RENDER_MAP_SLOT 13
#define RBUFS_UTILITY_TEX_SLOT 14
#define HIZ_TEX_SLOT 15
#define SSS_TRANSMITTANCE_TEX_SLOT 16

Do not use slot 16 (or anything above slot 15). It is not available in all implementations.

Do not use slot 16 (or anything above slot 15). It is not available in all implementations.
pragma37 marked this conversation as resolved
@ -0,0 +50,4 @@
subsurface_ps_.bind_texture("gbuffer_closure_tx", &inst_.gbuffer.closure_tx);
subsurface_ps_.bind_texture("gbuffer_color_tx", &inst_.gbuffer.color_tx);
subsurface_ps_.bind_ubo(RBUFS_BUF_SLOT, &inst_.render_buffers.data);
subsurface_ps_.bind_image(RBUFS_COLOR_SLOT, &inst_.render_buffers.rp_color_tx);

Also bind RBUFS_VALUE_SLOT otherwise it will trigger a warning / validation error.

Also bind `RBUFS_VALUE_SLOT` otherwise it will trigger a warning / validation error.
pragma37 marked this conversation as resolved
Miguel Pozo added 5 commits 2023-06-14 18:07:49 +02:00
Miguel Pozo added 1 commit 2023-06-14 19:50:29 +02:00
Author
Member

I've added a workaround so the values are closer to the Cycles ones, and mentioned the issue in the code comments. :(
I've also set the default thickness value to 0 so the result for very thin geometry matches Cycles and the current EEVE implementation better.

imagen

I've also "fixed" the texture slots issue, but I think we should look for a better solution.
I've opened another PR with one possible option: #108984

I've added a workaround so the values are closer to the Cycles ones, and mentioned the issue in the code comments. :( I've also set the default thickness value to 0 so the result for very thin geometry matches Cycles and the current EEVE implementation better. ![imagen](/attachments/7bd52f5b-89c7-4e70-a5a8-c9bf90710a02) I've also "fixed" the texture slots issue, but I think we should look for a better solution. I've opened another PR with one possible option: #108984
301 KiB
Clément Foucault approved these changes 2023-06-15 10:07:07 +02:00
Clément Foucault left a comment
Member

I am not sure if changing the default thickness to 0 is a good thing. This thickness it to avoid the ringing artifact caused by shadow map imprecision. The default is a good one for default settings and object size. Maybe we can make it 0.05 but clearly not 0.

Otherwise the patch can land.

I am not sure if changing the default thickness to 0 is a good thing. This thickness it to avoid the ringing artifact caused by shadow map imprecision. The default is a good one for default settings and object size. Maybe we can make it 0.05 but clearly not 0. Otherwise the patch can land.
Miguel Pozo added 2 commits 2023-06-15 15:45:25 +02:00
Miguel Pozo changed title from WIP: EEVEE Next: Subsurface Scattering to EEVEE Next: Subsurface Scattering 2023-06-15 15:46:15 +02:00
Miguel Pozo merged commit 4cf644939a into main 2023-06-15 15:49:12 +02:00
Miguel Pozo deleted branch pull-eevee-next-sss 2023-06-15 15:49:13 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#107407
No description provided.