Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PBR dielectrics/metals is broken if blacked #666

Closed
0x4E69676874466F78 opened this issue Nov 22, 2023 · 7 comments
Closed

PBR dielectrics/metals is broken if blacked #666

0x4E69676874466F78 opened this issue Nov 22, 2023 · 7 comments
Labels
bug Something isn't working materials ray tracing visual bug Visual glitches, something looks incorrectly

Comments

@0x4E69676874466F78
Copy link
Collaborator

0x4E69676874466F78 commented Nov 22, 2023

Открываем mirror.mat находим там "for" "reflect1" и раскомментируем там

//"basecolor_map" "/colors/black.png"
//"metalness" "0"

Далее идём на test_glass и видим там где были зеркала абсолютно чёрное тело вместо блестящего "чёрного пластика".
Его даже фонарик не берёт. С белым basecolor_map всё работает вроде корректно.

Диэлектрик ещё так устроен что как раз на чёрном отражения у него лучше:
d5

Рендер substance designer, в режиме IRay (photoreal).

@0x4E69676874466F78 0x4E69676874466F78 added bug Something isn't working ray tracing visual bug Visual glitches, something looks incorrectly materials labels Nov 22, 2023
@0x4E69676874466F78
Copy link
Collaborator Author

@0x4E69676874466F78
Copy link
Collaborator Author

0x4E69676874466F78 commented Dec 1, 2023

Вместе с этим возникает ещё одна проблема PBR в отражениях:
image
Обрати внимание цвет от белой лампы на плитке жёлтый! так быть не должно.
В том же сабстенсе:
image
Если я сделаю ярче источник света это будет заметнее:
+0~FIFTS_LGHT5 255 255 255 20000
image
Усугубим проблему:
+0~FIFTS_LGHT5 0 0 255 20000
image
В сабстенсе:
image

@LifeKILLED
Copy link

При отражении от диэлектрика спектр световых волн не меняется, а при дифузе фотоны взаимодействуют с атомами, рассеиваясь под поверхностью во всех направлениях. Так в нашей реальности получаются два разных явления:

  1. отражение (а также спекуляр, как его аппроксимация)
  2. диффуз (прямой свет с тенями и глобальное освещение)

В случае с металлом отражение принимает цвет поверхности либо благодаря квантовым эффектам (золото) либо благодаря лаку/краске (то есть полупрозрачный цветной слой поверх железки).

Короче, у металла всё умножается на base_color, но у диэлектрика спекуляр на base_color умножать не надо.

У нас же диффуз с отражениями мешаются в одну кучу. Это неправильно.

@LifeKILLED
Copy link

Я у себя в пайплайне делал отдельно пасс отражения и пасс диффузного GI. Были вопросы к тому, как я всё это смешиваю после шумодава, но в целом выглядело получше.

В текущем варианте рендера ветки vulkan, чтобы совсем всё не переписывать, можно просто сохранять результат bounce.comp в две разных текстуры. Если у поверхности нарандомилось BRDF_SPECULAR, сохраняем в отражения, а если нет, то в диффуз. Потом отдельно их денойзим и правильно смешиваем (диффуз умножаем на base_color, а спекуляр не умножаем).

Могу попробовать быстро пофиксить

@0x4E69676874466F78 0x4E69676874466F78 changed the title PBR dielectrics is broken if blacked PBR dielectrics/metals is broken if blacked Dec 5, 2023
@0x4E69676874466F78
Copy link
Collaborator Author

Металлы с чёрным basecolor у нас тоже сломаны, вот референс как должно:
metals

@w23 w23 mentioned this issue Dec 11, 2023
2 tasks
@w23 w23 closed this as completed in c812395 Dec 12, 2023
w23 added a commit that referenced this issue Dec 12, 2023
Thing done during stream E345

- [x] fix incorrect basecolor brdf multiplication, #666 
- [x] Do not patch sprite textures for traditional raster, #695
@0x4E69676874466F78
Copy link
Collaborator Author

https://github.com/0x4E69676874466F78/test_maps_for_hlrtx_project/releases/tag/2023_12_15 карты обновил где добавил металло-дилектрики.

w23 added a commit that referenced this issue Jan 2, 2024
Deprecate `brdf.h` usage, start writing our own BRDF functions.

Use glTF 2.0 BRDF mixing model as a simple starting point.
Mix-in base_color into specular early, as it is light-direction
dependent and cannot be easily separated.

Disable bounces for now, as we don't have yet good sampling story, need
to write "backwards" BRDFs that give us ray directions to sample, and
accommodate for that sampling bias in BRDF attenuation itself.

Also introduces some other weird artifacts on `test_material` map, investigation pending.

Related to black metals in #666
w23 added a commit that referenced this issue Feb 1, 2024
Hand-made organic bespoke GMO-free BRDFs

- [x] Fix black metals in #666
  - [x] Better diffuse-vs-specular channels tracking
  - [x] specular reflections
- [x] Fix new `test_material` glitches
- [x] Fix #461 
- [x] Fix #151 
- [x] Fix #266 
- [x] Filter out zero-area degenerate triangles (NOTE: might affect normal smoothing)
- [x] Implement #126 
  - [x] sun solid angle parametrization
- [x] Make new brdfs sampling functions
- [ ] distant light circular glitches
  - [x] not enough float precision, addressed to a degree with slight modifications to equations
- [x] Address glow over weapons in RT, see #442 
- [x] bounces
  - [x] diffuse
    - [x] why is it so dark?
  - [x] specular
- [x] Peformance differences. Why is there no CPU-GPU parallelism anymore?
  - [x] `VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT` forces cpu-gpu sync. 💩 
    - [x] Make a special flag for it
- [x] Update rendertests
  - [x] add more channels
  - [x] add white furnace display test
@w23
Copy link
Owner

w23 commented Feb 2, 2024

Done in the handmade-brdfs branch/PR

@w23 w23 closed this as completed Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working materials ray tracing visual bug Visual glitches, something looks incorrectly
Projects
Status: Done
Development

No branches or pull requests

3 participants