-
-
Notifications
You must be signed in to change notification settings - Fork 35.3k
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
Faster cube uv envmaps #8284
Faster cube uv envmaps #8284
Conversation
Awesome! 👍 |
@mattdesl I've done a bit more optimization in the last couple minutes. Is there a way you can test it on your MBP retina? Old slower version: http://ci.threejs.org/api/pullrequests/8278/examples/webgl_materials_envmaps_hdr.html New faster (?) version: You might have to zoom the torus to get enough pixel coverage on screen. |
Great optimizations @bhouston ! |
How would you turn this on / off in code? |
I am not fill-rate bound in that scene even on full screen so I am not dipping below 60FPS. But in my own scene with god rays etc it becomes quickly fill rate bound when zooming into a mesh with the old cubeUV sampling. I will checkout this PR locally and test the optimizations. 😄 |
Since I haven't seen a visual quality difference yet, there is no way to turn off the opimizations I am doing. |
@bhouston In an ideal world we would have a reliable way to query/detect seamless cubemap support – I've opened some discussion here. |
We should still generate them using the pmrem but then load them into a Best regards,
|
@@ -1,5 +1,9 @@ | |||
#define DISABLE_CUBE_UV_MIPMAP_INTERPOLATION |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is temporal/testing code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was doing interpolation between different levels of roughness (based on material roughness) as well as different mipmap levels (based on texel derivatives). I have turned of interpolation between mipmap levels for now as I didn't see it having a huge quality impact (although we haven't tested this on complex models yet, so I worry that maybe it has an impact in complex cases, which is why I have temporarily kept it) and it did have a performance impact, at least as reported by @MattDes.
A faster way to do this would be to load the calculated roughness maps into a cubemap mipmap structure -- that option is only available in WebGL 2.0 or if the textureCubeLodEXT extension is available (e.g EXT_shader_texture_lod which has 70% availability.) I think that is the next optimization -- optionally load into cubemap mipmaps when possible. It would cut out all of this code at run time, but we would still fall back to it when the EXT_shader_texture_lod isn't available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can remove the commented code by now and restore from a previous state if needed. Just want to keep the code tidy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed the code in the latest commit per your recommendation.
Thanks! |
This PR adds a flag, DISABLE_CUBE_UV_MIPMAP_INTERPOLATION, into the cube_uv_reflection_fragment.glsl that disables mipmap interpolation. This halves the complexity of this part shader in terms of code as well as number of texel fetches while keeping quality roughly the same -- I can not tell the difference in the current examples.
We have had reports over the last few days that the cube_uv_reflection_fragment shader was too intense for some older MBPs who relied on Intel GPUs to drive retina displays - thx @mattdesl, and @wvl. This should help with that and other lower end devices driving high resolution displays.
This easy fix was suggested by @spidersharma03.