Announcement

Collapse
No announcement yet.

Make Objects Invisible but Still Have Reflections

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

    Make Objects Invisible but Still Have Reflections

    I am trying to make objects/particles/decals/THINGS IN GENERAL invisible to the player's view directly, however, these things still need to have reflections (That the player CAN see) on things like mirrors/reflective items. I have been unable to produce this effect with the simple "Owner No See" and "Only Owner See" options.

    I have been messing around with Planar Reflections for high quality reflections, and the Planar Reflection actor has "Hidden Actors" and "Show Only Actors" arrays, but I haven't been able to use those either to get the effect that I need.

    I have thought of trying to use things like Custom Depth, Render Targets, or even overlaying multiple Camera feeds onto the same player screen/viewport. However, I don't know enough about those to know how to do it, or if they're even possible.

    Any help or suggestions on how to get this effect would be greatly appreciated.

    #2
    If you're wanting only reflective objects to have reflections, then you'd need reflection probes, the other methods (SSR and planar reflections) only work in real-time so the objects would have to be visible. Probes are rendered beforehand so you'd have those generated and then when gameplay starts you would hide all of the objects that you don't want visible, except for the objects that will be reflecting things.

    Comment


      #3
      That is part of my problem. I need these reflections to be updated in real-time. The invisible objects will be moving around the level, so their reflections need to be updated in real-time. I need the player to be able to find these invisible objects by the reflections that they make. And since some of these items are going to be moving, I need a way to simulate real-time reflections.

      I don't know if actual reflections will handle this kind of effect, so I'm open to suggestions on how to fake a reflection in materials maybe through post-processing or custom depth or something.

      Comment


        #4
        So you want objects to be visible to reflection capture but not to the player camera?
        I have an idea:
        Get the player camera world position every tick, and store that to a material parameter colllection. Then, in the material (for the objects you want to be reflected, but hidden), get the difference between the camerapositionWS, and the material parameter collection. If there is any slight difference between them, make the object's opacity 1. If there is no difference, make the opacity 0 - the only camera that will have no difference is the player camera.


        Edit: I am assuming the material node "cameraPositionWS" gets the position of the camera that is rendering the current frame, not the player camera, is that correct?
        Last edited by somawheels; 08-21-2018, 03:26 PM.

        Comment


          #5
          Originally posted by somawheels View Post
          So you want objects to be visible to reflection capture but not to the player camera?
          I have an idea:
          Get the player camera world position every tick, and store that to a material parameter colllection. Then, in the material (for the objects you want to be reflected, but hidden), get the difference between the camerapositionWS, and the material parameter collection. If there is any slight difference between them, make the object's opacity 1. If there is no difference, make the opacity 0 - the only camera that will have no difference is the player camera.


          Edit: I am assuming the material node "cameraPositionWS" gets the position of the camera that is rendering the current frame, not the player camera, is that correct?
          Amazing! My initial tests are promising! As far as I can tell, this is a valid way to make it work. I don't know yet what the limitations/problems with this method are (If any). I'm going to keep expanding on this suggestion, and hopefully post some screenshots in this thread later. If anyone else has any other suggestions/methods to get this effect working or improve upon this method as well, I would appreciate them as well, just in case there is a better way that has been overlooked.

          Anyways, thanks for the help!
          Last edited by Meganaught; 08-21-2018, 04:32 PM.

          Comment


            #6
            Initial Results

            Alright, so I've done a few tests with this technique, and it does work pretty well. It's not 100% perfect, but I'll get into that in a bit. First of all, the effect is really easy to implement. This is my method of implementing the invisibility effect in a Material Function that can be used in an kind of material.

            Click image for larger version

Name:	image_145685.png
Views:	145
Size:	72.3 KB
ID:	1519043


            Click image for larger version  Name:	Material-Function-02.PNG Views:	1 Size:	83.3 KB ID:	1519044

            Important Note: The "if" node needs to have an "Equals Threshold" appropriate for 1 frame's distance of your player's movement speed. I have been unable to fix a 1 frame differential between the values of the "Camera Position" node and the stored position of the player's camera. This difference is unnoticeable if the player is not moving, but if they are, then material might think that the player's camera is actually too far away from "Camera Position" to make the object invisible.

            Click image for larger version  Name:	If-Statement.PNG Views:	1 Size:	15.8 KB ID:	1519047

            The Inputs and Output can handle (In my particular version) Scalars, and Vectors (Up to Vector 3 in my case, but they could handle a Vector 4 if I wanted them to). This allows them to be able to handle textures and masks as well as just the 0-1 values. Also, even though I am using this method only for opacity, it is fully capable of doing this for any material attribute, not just opacity. Here is what the Material Function looks like in a material.

            Click image for larger version  Name:	Material-Function-03.PNG Views:	1 Size:	16.9 KB ID:	1519046

            Here are some examples of the effect being used in conjunction with Planar Reflections to get the desired result.



            Mesh's Reflection with Normal Material vs. Invisible Material

            Click image for larger version  Name:	Meshes.PNG Views:	1 Size:	179.8 KB ID:	1519048



            Particle Systems with Normal Material vs. Invisible Material

            Click image for larger version  Name:	Particles.PNG Views:	1 Size:	203.4 KB ID:	1519049

            Now, I did run into a little bit of trouble trying to get this to work with particles, and I'm not 100% happy with the results, but it turns out that Particles in general have a difficult time with reflections, so I found this post (Particles aren't reflected by Planar Reflection) that helped me solve (Mostly) the reflection problem.



            Deferred Decals Using Invisible Material

            Click image for larger version  Name:	Deffered-Decals.PNG Views:	1 Size:	134.5 KB ID:	1519050

            So far, it seems to be a really nice solution. I think that it's robust enough for pretty much all my needs, so I am going to use this method unless I find something that is significantly better. However, I am still interested to hear other solutions or improvements to this method if anyone has some. Anyways, thanks again for the help! I really appreciate it!

            Comment

            Working...
            X