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

OrthographicSSRPass (screen space reflection) #20061

Closed
wants to merge 49 commits into from

Conversation

gonnavis
Copy link
Contributor

@gonnavis gonnavis commented Aug 13, 2020

Demo Demo2
Inspired by Blender EEVEE SSR, and this tut ( mostly by the two screen grid images imgA imgB, I only read a little text and hardly read the code, then start writing my own code. )
Now just support OrthographicCamera. I'm trying to support PerspectiveCamera.

----------------EDIT 2----------------
Now support PerspectiveCamera. New PR: #20156

----------------EDIT----------------
Demo ScreenShot
clipboard

@mrdoob
Copy link
Owner

mrdoob commented Aug 13, 2020

Thanks for working on this!

Is this how's supposed to look like?

Screen Shot 2020-08-13 at 4 22 03 PM

Also, it runs at ~5fps on my machine (MacBook Pro, Intel).

@gonnavis
Copy link
Contributor Author

gonnavis commented Aug 13, 2020

Hello Mr.doob

Yes, it is. I've already added the screenshot to the pr.
I know it's not look very well now, may need more advaced blur or anti-alias, and SSR has own limitations.
But I'm already satisfied with this reflection feeling.
My main goal now is to support PerspectiveCamera, after this, I will do in-depth study with the looking improvement.

I can run at 30fps at my win7 laptop with GTX 980M about 40% usage and 1920*1080 chrome maximized window.
The performance cost by the shader is mainly based on pixels count. May Mac retina monitor has too many pixels?
I'll consider these factors.

@gonnavis
Copy link
Contributor Author

gonnavis commented Aug 17, 2020

I found out that antialas was turned on and dpr was set before.
If turn them off, can reach about 12fps on Mac when the window is maximized.
If stepStride is set to 2, it can run to about 28fps.
Demo Demo2
Mac configuration

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 17, 2020

On my iMac I get only about 10 FPS which is definitely to low. Apart from the performance aspect, the visual appearance of the pass still looks buggy.

@gonnavis
Copy link
Contributor Author

Yes, I just want to mention that the performance of this pass is not that bad on mac. I'll keep improving.

@gonnavis
Copy link
Contributor Author

@mrdoob Hello Mr.doob

After use depthTexture instead of depthRenderTarget, the quality has been greatly improved.

I think it might be worth a second review now.

Demo

clipboard

@mrdoob
Copy link
Owner

mrdoob commented Aug 21, 2020

Nice! It is looking much better indeed!

@mrdoob
Copy link
Owner

mrdoob commented Aug 21, 2020

Would it be hard to make this work with PerspectiveCamera too?

@gonnavis
Copy link
Contributor Author

gonnavis commented Aug 21, 2020

Thanks!

Yes, it’s difficult for me to judge the ray position of the current pixel with PerspectiveCamera.
Because of the perspective effect, cannot simply use these code

vec3 ray=(length(xy-d0)/totalLen)*(reflectDir*maxDistance);

I'm still trying in this branch
https://github.com/gonnavis/three.js/blob/SSRPassPerspective/examples/webgl_postprocessing_ssr.html
https://github.com/gonnavis/three.js/blob/SSRPassPerspective/examples/jsm/postprocessing/SSRPass.js
https://github.com/gonnavis/three.js/blob/SSRPassPerspective/examples/jsm/shaders/SSRShader.js

@gonnavis
Copy link
Contributor Author

gonnavis commented Aug 21, 2020

After just calc the distance from viewPosition to reflectRay using pointToLineDistance function, instead of calc the reflectRay position at this pixel, I think perspectiveCamera support is almost OK.

But it need more adjustments ( some may be already done in OrthographicSSRPass ), I'll keep improving.

Perspective Demo

aaa

@gonnavis
Copy link
Contributor Author

After solving an obvious problem under the PerspectiveCamera, I think the SSRPass is ready to use.
So no need for OrthographicSSRPass now, I made a new PR #20156 .

@mrdoob
Copy link
Owner

mrdoob commented Aug 24, 2020

This one can be closed then?

@gonnavis
Copy link
Contributor Author

gonnavis commented Aug 24, 2020

Yes, I'll merge these codes to SSRPass #20156.

@mrdoob mrdoob closed this Aug 24, 2020
@mrdoob mrdoob removed this from the rXXX milestone Aug 24, 2020
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.

3 participants