kode80 / kode80ssr Goto Github PK
View Code? Open in Web Editor NEWAn open source screen space reflections implementation for Unity3D 5.
License: BSD 2-Clause "Simplified" License
An open source screen space reflections implementation for Unity3D 5.
License: BSD 2-Clause "Simplified" License
If you create a new depth pass based on a layer ( TransparentFX layer for example ), is possible to create a Shader for reproduce reflections on transparent objects? I did some tests, the result is not great, the reflections are noticed, but are projected very bad. I've tried on a Opaque shader with alpha blending options...
Hello, this is not a real issue but a suggestion.
I think command buffers feature in U5 could be used to paint reflected pixels directly on reflection probes buffer. This way you just let unity render materials and apply blur, etc. by itself.
I don't know if that is possible in the current rendering pipeline (I don't when the cubemaps are blended in the rendering queue, (docs are not clear)) and I don't know if would be feasible to alter cubemap buffer texture in screen space, but it would be nice if possible.
Thank you for efforts!
Hi,
thank you for creating such a cool project. This is indeed the only SSR effect I got to show up on a mobile platform.
Unfortunately the position where the reflections are rendered to seems off - almost like the objects are only shoved to the side. (see the black & white sphere and the font in the background)
In the editor everything seems fine:
I am using Unity 5.5.0, iOS Target, Deferred, Metal
When the reflected ray angle is greater than 90º, and being increased as it comes close to 180º, the reflections start to distort (they grow infinitely on the reflecting surface).
If you bump (a lot) pixel stride, the ploblem is less appreciable, but still noticieable, and you lose a lot of quality, so is not a good workaround.
If you bump ssr downsample, surprisingly the problem is less appreciable too, but not a feasible solution.
Screens:
With a reflected angle of ~ 160º
As you can see there are also some artifacts, but could be related to the issue.
Here are my settings (Tweaking them doesn't alter the issue, excepting those I said above)
I'm using a lot of iterations and low pixel stride because it introduces a lot of artifacts in my specific case.
Using latest code from master 253e08f
Thank you so much for the amazing work.
Hey Kode80,
I was so stoked to try out your implementation of SSR with Unity 5 and it works absolute marvels in the editor, but when I build it, it just renders black screen. Not only that, but when I switch to another real-time lit (with pre-computed GI) scene (which doesn't have SSR) from black screen, there are no shadows in the scene. Not a single clue why this happens as I am programmer with Zero knowledge of graphics pipeline.
As to give more info about the scene, it is a arch-viz project. I have SSR as first effect on camera, then anti-aliasing and lastly bloom. Please help me, coz I need reflections (obviously, being an arch-viz project) to work properly. Thank you. I hope you will have some guidelines for me to set up the scene well.
Hello,
I cannot get the blur to do anything (Changing the radius or the roughness of the material does not affect anything)
But it works on DX11 and on OpenGL.
Thanks!
Currently reflections are not using full HDR range. I'm opening this issue as a reminder to look into the possibility of implementing HDR reflections.
I noticed that the sky does not reflect on the materials. I don't know if in your plans you want implement your SSR Shader. But ,probably, it's necessary for a real calculation of the reflections. It's too much for me write this, but i want help you. Anyway, Great work!
Reference ( Sky light from windows ):
http://abload.de/img/realisticrendering201gssdm.jpg
Hi.
I tested the actual version of your SSR. With the textures enabled it looks ok. But when i disable the textures you see clearly some artefacts in the reflection. And no matter which value i change, the artefacts stay.
And another problem is, that there are reflections, where no reflections shouldn't be.
I think you know these problems and you working on this ?! Maybe a update will come in the next time?
thanks and keep up the good work..
Kode80SSR Package as of 3/17/2015.
Unity 5.0.0f3 Pro
Nvidia 840M GPU, Intel Core i7 Quad
The Effect works perfectly fine inside the editor with no Errors (but I do get sending message header failed warning on build), but inside the in game Dev-Console it displays a bunch of generic Null Reference exceptions and the viewport is broken just returning an incomplete render pass with occasional flickering between normal pass.
Project Files for SSR are:
Assets/SSR/SSR.cs
Assets/SSR/ScreenResizeDetector.cs
Assets/SSR/Shaders/BackFaceDepth.shader
Assets/SSR/Shaders/BilateralBlur.shader
Assets/SSR/Shaders/DeferredTerrain.shader
Assets/SSR/Shaders/SSR.shader
Assets/SSR/Shaders/SSRBlurCombiner.shader
I used proper setup and have isolated the issue to the SSR component on the Main Camera, the SSR Scripts and Shaders are Un-modified and same as can be found in master.
Other Packages I used in my project:
-ShaderForge
-SSAO Pro
Hello!
I had some doubt about your conversion from clip space to screen space in the code present in the shader file: kode80SSR/Assets/Resources/Shaders/SSR.shader.
From line 136 - 146:
// Project into homogeneous clip space
float4 H0 = mul( _CameraProjectionMatrix, float4( rayOrigin, 1.0));
float4 H1 = mul( _CameraProjectionMatrix, float4( rayEnd, 1.0));
float k0 = 1.0 / H0.w, k1 = 1.0 / H1.w;
// The interpolated homogeneous version of the camera-space points
float3 Q0 = rayOrigin * k0, Q1 = rayEnd * k1;
// Screen-space endpoints
float2 P0 = H0.xy * k0, P1 = H1.xy * k1;
The final result that has been commented as screen space end points. Isn't that Normalized Device Coordinates or NDC ?
So the reflections didn't seem to work for me, see the two first screenshots below, first from the frame debugger, and the second from the game view. This is on a 2011 MBP with a Radeon 6870M GPU.
I tried hacking the shader a bit, and found that if I replace the last return statement
return half4(tex2D( _MainTex, i.uv).rgb, 0.0);
with a simple
return half4(0.0, 0.0, 0.0, 0.0);
the reflections seem to render correctly, as you can see in the two last screenshots.
Original code, frame debugger:
Original code, full render:
Modified, frame debugger:
Modified, full render:
Having blur/roughness calculated by per pixel roughness but also affected by ray distance (like UE4 does) would be amazing. Doesn't need to be fully physically correct I guess.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.