Announcement

Collapse

The Infinity Blade Forums Have Moved

We've launched brand new Infinity Blade forums with improved features and revamped layout. We've also included a complete archive of the previous posts. Come check out the new Infinity Blade forums.
See more
See less

Simple Real Time Reflection + Distortion

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Simple Real Time Reflection + Distortion

    **Updated January 2011 due to changes in UDK and for greater clarity**

    This tutorial assumes you have a basic understanding of the UDK, such as accessing the Content Browser, and very basic knowledge of the material editor. If you don't, see the Documentation forum, and watch the stickied tutorials.

    In this tutorial I will refer to RenderToTexture as (RTT) and a SceneCaptureReflectActor (SCRA). See UDN documentation for further info: http://udn.epicgames.com/Three/RenderToTexture.html


    1. Open the content browser and create a RTT by simply right clicking empty space in the content browser and choosing New TextureRenderTarget2d (you may have to scroll down to see the option). Choose an appropriate texture size, for reference a 512 will be a bit blurry, 1024 quite nice, and a 2048 will be very clean, but obviously the higher the resolution, the more resources it takes.

    2. Next, within the content browser, find the tabs across the top and click the one that says Actor Classes. The SCRA can be found under Uncategorized -> SceneCaptureReflectActor. Highlight SCRA and rightclick somewhere in your map and choose Add SCRA Here. Initially, just put it somewhere central, roughly in line with the floor.

    3. With the SCRA selected, open its properties (hit F4), under the SceneCaptureActor heading, go to Scene Capture -> Capture -> Texture Target. Point Texture Target to the RTT you made in step 1 (have your RTT selected in the Content Browser, then click the green arrow). You can play with the other settings, but I largely leave them default, except that I have View Mode as SceneCapViewLit and I cap the FPS much, much lower than the 1000 default (note that 0 means it won't update and behaves like a cubemap).

    4. Once all that is setup, create a material and set it up as follows. For clarity, all Masks have R,G, check marked, and the ScreenPos has Screen Align checked:

    [shot]http://img192.imageshack.us/img192/6752/capture3cw.png[/shot]

    5. As for the distortion, since RTT is using R,G, to feed us 2d vector information (read the UDN article above to understand this better) and our Normal Map uses R,G,B, to feed us 3d information, it's a perfect candidate for some fake distortion that matches our underlying texture, once we take out the B with a Mask so it only feeds us R,G, values. This is shown in the material setup above.

    Obviously, you don't need to do Specularity like I've shown, that's just my material, and you could remove the distortion setup and get a clean reflection that looks rather glassy. You can also play with the distortion, especially the multiplier, and get a nice snow/ice material. Here's my result, the reflection is completely dynamic, you can look down and see yourself, push the barrels around and see their reflection rolling, and even see projectiles reflected as they shoot across the surface:

    [shot]http://img17.imageshack.us/img17/1305/screenshot00042.png[/shot]

  • #2
    Saw the final render in the WiP thread I think? Cool to see a tut for it. Was wondering how to do it... thanks Danimal.

    Comment


    • #3
      So where do I need to put the 1minus?

      I noticed that sometimes the green doesn't appear, it's very strange. It just pops up when it feels like it...

      Comment


      • #4
        Originally posted by SneakySoft View Post
        So where do I need to put the 1minus?

        I noticed that sometimes the green doesn't appear, it's very strange. It just pops up when it feels like it...
        The 1-x is in the material setup above, the screen shot setup is correct. You'll see that it's coming out of the Green Channel in the RTT, attempting to remove it from the material. Rebuild lighting if green shows up and of course have the level that has the SCA loaded, otherwise it has nothing to display and will be green. Epic has been notified of the "green glow" issue in this thread:

        http://forums.epicgames.com/showthread.php?t=734048

        Epic responded that they will look into it, a 'lil post informing them that you also experience the green glow might be nice since the initial response was that they couldn't replicate it. Which is odd since every person who has tried this has encountered it, but at least they're looking into it

        Comment


        • #5
          Hmm the material ed diagram looks a LITTLE complex lol, can you try and explain how you got to the stage where you had that screenshot? eg, what are those whitenoise looking textures and all the other stuff?

          What do I need to do to make a reflecting surface? this is way too hard to follow LOL. When I create the RTT and assign it to the SCRA, you can see the reflection in the editor, but once in the game, theres nothing.

          Lol I just cant get this to work at all. I thought this was supposed to be simple!!

          Comment


          • #6
            Just copy the materials setup, surely you can copy something? As I said in the actual tutorial, you do NOT have to have a specular, nor do you need to have distortion. Translation: only the top box needs to be reproduced, just copy the nodes in the top big box labeled Diffuse Plus RenderToTexture. If you do this, there will be no distortion to Add, so remove the Add, and go from the Mask into the RTT. There's nothing more I can do if you can't copy a simple material setup; if you are confused on Materials, I suggest watching a number of existing Materials tutorials out there to learn about the Materials editor.

            Comment


            • #7
              It's showing up black on emissive areas, like it's excluding the bloom or something.

              Comment


              • #8
                Can you post a pic of the problem? I might be able to help, but I need to see if we are referring to the same thing.

                Comment


                • #9
                  What does this do? Make like a realistic reflective surface?

                  Comment


                  • #10
                    Originally posted by Snufkin View Post
                    What does this do? Make like a realistic reflective surface?
                    This should answer your question.

                    Originally posted by danimal'
                    Here's my result, the reflection is completely dynamic, you can look down and see yourself, push the barrels around and see their reflection rolling, and even see projectiles reflected as they shoot across the surface:
                    A Screen Capture Real Time Actor takes a screenshot from wherever you set it and uses that screenshot as a texture in your material. You can set it to update the screenshot as often as your FPS will allow. If you set it to update 30 times per second, it'll appear to be a realtime reflection of everything that the SCRA sees.

                    Comment


                    • #11
                      Originally posted by Wyldhunt View Post
                      This should answer your question.



                      A Screen Capture Real Time Actor takes a screenshot from wherever you set it and uses that screenshot as a texture in your material. You can set it to update the screenshot as often as your FPS will allow. If you set it to update 30 times per second, it'll appear to be a realtime reflection of everything that the SCRA sees.
                      I see, that's pretty good.

                      Comment


                      • #12
                        the material setup above gives me an error if i try to use only RnG mask but alows it to work if i use RGB but look terrible

                        Image


                        any ideas why ?

                        Comment


                        • #13
                          Just a guess, but try using Masks with only one channel per Mask and Append them afterwards together.

                          Comment


                          • #14
                            Wow, talk about coincedence. Here I was playing around with cubemaps when I started to wonder whether there wasn't something like an actual reflection effect (considering that older game engines I worked with had a similar effect up and running using cameras to capture screenshots of everything above and below and UDK is far more advanced than those).

                            Then I stumble upon this thread

                            Will definitely check this out at a later date! Thanks!

                            Comment


                            • #15
                              My bad i was trying to use a cubemap not a reflect.

                              Anyway now its working great.
                              The only problem is im running a security cam setup over looking the floor thats reflecting and it gets green glow and green edges randomly when looking at the CCTV image.
                              which is a RTT2d.
                              if you could explain that 1-x for me as the screenshots alterd I might be able to rig my mat for the CCTV to not glow.

                              Comment

                              Working...
                              X