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

ShaderChunk: Implemented mipped bicubic transmission texture filtering. #25483

Merged
merged 1 commit into from
Feb 14, 2023

Conversation

mrdoob
Copy link
Owner

@mrdoob mrdoob commented Feb 12, 2023

Description

The current transmission shader technique makes the 0.25-0.75 roughness ranges pretty unusable due to the artefacts.
This PR implements @N8python's shader for sampling the texture using bicubic filtering.

Screen_Shot_2023-02-11_at_3 53 48_PM

(Left side: bilinear, Right side: bicubic)

Haven't done performance comparisons yet.

@mrdoob mrdoob added this to the r150 milestone Feb 12, 2023
@N8python
Copy link
Contributor

N8python commented Feb 12, 2023

Some preliminary performance comparisons on an M1 indicate that the perf hit is negligible - but it may be more noticeable on lower-end devices. If anyone is on an iGPU/Phone, it would be great to see how the performance changes there - as the 7 extra texture reads the shader uses might cost more on such a lower-end platform.

@optimus007
Copy link

optimus007 commented Feb 12, 2023

i have some weak phones , can test if there's live url.

This blurring technique could also be used for scene.backgroundBlurriness right ? low values makes the hdri more blocky in the current version

@N8python
Copy link
Contributor

i have some weak phones , can test if there's live url.

This blurring technique could also be used for scene.backgroundBlurriness right ? low values makes the hdri more blocky in the current version

Depends! If the background is an hdri, definitely. I'm not sure how to apply this to cubemaps, however.

@trusktr
Copy link
Contributor

trusktr commented Feb 12, 2023

My intuition would say to make the blur mode be choosable by the end dev.

  • a first-person shooter may need low-quality pixelated blur on glass panes in the game env,
  • while a glass UI with a lot less things to render would need perfect high quality blur (like CSS backdrop-filter)

Maybe the only sampler size is enough to specify that?

@mrdoob
Copy link
Owner Author

mrdoob commented Feb 13, 2023

Here are a couple of performance test links:

https://mrdoob-sandbox.glitch.me/threejs_transmission_r149.html
https://mrdoob-sandbox.glitch.me/threejs_transmission_r150dev.html

r149 r150dev
MacBook Air M1 46 45
Pixel 7 70 64

@donmccurdy
Copy link
Collaborator

donmccurdy commented Feb 13, 2023

r149 r150dev
iPhone 11 Pro 60 60
iPhone SE 56 41
iPad Pro (2017) 39 31
Nexus 5x 20 14

+1 for the change. There are some worthwhile challenges in trying to enable MeshStandardMaterial and MeshPhysicalMaterial to "scale down" to low-end devices better, but I don't think keeping the old transmission texture filtering method around is the right approach to solve that.

@Mugen87
Copy link
Collaborator

Mugen87 commented Feb 13, 2023

Tested on three devices:

r149 r150dev
Mac mini M2 Pro 60 60
Lenovo Legion RTX 2070 144 144
Pixel 4a 24 20

@N8python
Copy link
Contributor

Judging by these perf tests, think it is definitely safe to merge :D!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants