GithubHelp home page GithubHelp logo

kode80 / kode80ssr Goto Github PK

View Code? Open in Web Editor NEW
382.0 382.0 93.0 55.88 MB

An open source screen space reflections implementation for Unity3D 5.

License: BSD 2-Clause "Simplified" License

GLSL 54.72% C# 45.28%

kode80ssr's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kode80ssr's Issues

Transparent Reflection Shader

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...

[Suggestion] Contribute to reflection probes buffer instead of blend manually

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!

Reflection positions are displayed wrong on iOS

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)

img_0147

In the editor everything seems fine:

bildschirmfoto 2017-05-24 um 16 26 50

I am using Unity 5.5.0, iOS Target, Deferred, Metal

Distortions based on the angle

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º
image

With a sightly lower angle
image

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)
image

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.

Getting black screen while applying SSR in build.

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.

No blur on DX9

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!

SSR buffer does not handle HDR

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.

Shader Error

Hi,
the preview looks great. I have an Shader error in 'kode80/SSR': incorrect number of arguments to numeric-type constructor at line 290 (on d3d11).
After build the hole scene is pink/magenta...

kode80_issue

Artefacts

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..

Broken In Build (Null Reference Exception)

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.

image

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

image

Clip to Screen space

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 ?

Reflections not rendering correctly

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:

screenshot 2015-03-13 04 10 32

Original code, full render:

screenshot 2015-03-13 04 10 43

Modified, frame debugger:

screenshot 2015-03-13 04 11 02

Modified, full render:

screenshot 2015-03-13 04 11 15

Distance based roughness

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.