Screen Space Glossy Reflections Demo Available

It’s Been a While

Earlier this year I wrote a post discussing an implementation of real-time screen space glossy reflections.  The post has received a lot of positive feedback, and I’ve had some very interesting conversations with various individuals since it went up discussing theory, details, shortcomings, and everything in between.  The response has been great, and I appreciate the community’s interest.  One request I’ve received a few times is for a working demo that users could play with to get a better feel for the effect in action.  I had originally hoped to finish updating the engine to support DirectX 12 before releasing anything, and while it’s probably about 90% done, there are still some areas that need work and my time lately has been limited.

Thankfully, it’s the year 2015 (for a little while longer) and we have this magical thing called source control.  I’ve decided to use a tag I created right before the DX 12 update began, and have modified it to provide a small demo for anyone that’s been waiting on it.  The goods news is that it’s entirely DirectX 11-based, so the hardware support will be much broader than that of a DX 12 solution.  The downside is that I’ve been able to make a few improvements, especially around blending missed ray hits with fallback solutions that won’t be present in the demo provided.  I should get a chance to release a demo with the new features once things settle down a bit and all will be right with the world.

Demo Controls

Once the scene loads, anyone familiar with first person applications should feel more or less at home with the basics.  A, W, S, and D control movement, with W and S moving the camera forwards and backwards, and A and D strafing the camera left and right.  The mouse controls where the camera looks.  The user is not glued to the ground, so will move forward in whatever direction the camera is facing.  J and K control the floor roughness value, with J making the floor smoother, and K making it rougher.  A uniform roughness texture is applied over the entire floor, but in a real-world application an artist-authored texture would be used to make the results much more convincing.  Q and E are used to change the time of day.

The Esc key is used to quit the application.  To restart the scene without exiting, use the left, right, or up arrow keys.

Some Ugliness

The fallback environment maps are setup exactly as they were in the original post.  Specifically, this means that a large area of the scene only has the global, undetailed environment map to fall back to.  This is quite noticeable in the beginning area of the scene underneath the characters.  If you move directly forward from the starting point of the scene, you’ll pass through a few walls and end up in an enclosed hallway-type structure.  This area does have localized environment maps to fallback to on ray hits and the results are cleaner.  As stated in the first section, more work has been done to improve blending that is not present in the demo.

Besides the shortcomings of the screen space approach discussed in the original blog post, the stack of boxes in the scene still use the engine’s old physics and collision system.  In the latest version, all of this has been updated to use the Bullet Physics implementation, but if you choose to knock the stack down (clicking the left mouse button throws a ball), be aware that you’re likely to see quite a bit of oddness.  That being said – go for it, it’s always fun to knock things over!

Also, ambient light is handled by sampling from environment maps placed throughout the scene.  To ensure maintaining these doesn’t become a bottleneck, only one is ever updated per frame, and they’re only updated when the lighting changes.  Namely, this means that as the time of day changes the environment maps will get rebuilt.  If the time of day changes slowly enough, as it would in a real-world application, these updates would be mostly unnoticeable.  However, since the user can control the time of day the overall lighting situation can change faster than the environment maps can keep up.  If the user holds down one of the keys to change the time of day, they’ll see stale lighting data being applied to most parts of the scene.  Once the key is released, the environment map renderer will catch up and the lighting will become coherent again.

The Demo

Below is a link to download the demo.  Feel free and encouraged to continue commenting, asking questions, and offering constructive criticism.

Download the demo here.

12 thoughts on “Screen Space Glossy Reflections Demo Available”

  1. I have got Windows 7 64-bit and DirectX 11 card. I have got error with lack of XAudio2_9.dll file. I read this file is for Windows 10. I downloaded this file manually but there is another problem with bad DLL entry point procedure (I use Polish language so I will not quote here full “error text” directly, I think my description is understandable).

  2. Another error:

    Original Polish:
    “Nie znaleziono punktu wej?cia procedury CreateFile2 w bibliotece KERNEL32.dll. ”

    It would be translate to English:
    “The procedure entrypoint CreateFile2 could not be located in the kernel32.dll”

    I heard that CreateFile2 is supported only in Windows 8 and higher. I have Windows 7 64-bit.

    1. Hi,
      I’ve been developing on Windows 10 exclusively for the past 6 months or so. I used DirectXTK for a few things like texture loading, audio, and text, and that chooses a few method calls based on target OS version. I’ve gone through the DirecXTK source and replaced all calls to CreateFile2 with CreateFileW and uploaded a new build. If there are any other issues let me know. If I still had a machine running 7 I could test it myself, but I’ve upgraded both my desktop and laptop to 10.

  3. Demo doesn’t start. There is redbud_output.log file and inside content:

    ERROR: 1450805961: Insufficient physical and/or virtual memory present.

    Strange. I have 8 GB RAM (physical) and 8 GB page file.

    1. Hi,
      Thanks for keeping at it. I went ahead and disabled most of the startup checks. Looks like I need to revisit some of that old code and make sure it’s still relevant. The newly uploaded version has those disabled, and includes the previous changes.

  4. Demo is working now. Good job :)

    I have another question:
    Whether you will try to experiment with something related to GPU physics simulation ? For example cloth, fluids, particles, water simulation with full GPU usage (like NVIDIA Flex).

    1. Ha! Thank goodness! :)
      The physics system that’s implemented in the demo has already been replaced with Bullet Physics 2.82 in newer builds and is MUCH better than what’s in the demo scene (I generated the demo from an older git tag). At some point once I get time and Bullet 3.0+ is stable/released I will likely experiment with that, which is aiming to support GPU-based physics simulation. You can follow the progress they’re making here: My main interests lie on the graphics side, so beyond skimming research I doubt I’ll be looking to implement too much of it myself.

  5. Hi!

    Thank you for the great demo!
    It will send the praise to the height of your technology

    By all means, I would like you to show your source code
    I also want to close to your technology

    We have been greatly looking forward to the future of your articles and programs?

      1. Hi!

        Thank you for your reply!

        It was written very details in the article
        I was surprised at the amazing technical capabilities

        In this demo, it other great technology is being used

        For example, simulation of the sky, physics-based rendering, translucent drawing (OIT?), It is amazing technical capabilities!

        I would not wearing doing what these techniques?
        I want to be like you great technician!

        Now, what are developing an engine for the DirectX12?
        I wrote in the article before.

        The source code of the engine you want it!
        Even paying the money!

  6. Hi
    I want to know can I implement screen space reflection using directx 9
    And i want to know shader data set If Possible provide source code of simple example with visual studio project

Leave a Reply

Your email address will not be published. Required fields are marked *